Merge ^/head r307383 through r307735.

This commit is contained in:
Dimitry Andric 2016-10-21 16:29:40 +00:00
commit 5763f79695
623 changed files with 55612 additions and 20273 deletions

View File

@ -1586,7 +1586,7 @@ _strfile= usr.bin/fortune/strfile
_gperf= gnu/usr.bin/gperf
.endif
.if ${MK_SHAREDOCS} != "no" || ${MK_GROFF} != "no"
.if ${MK_SHAREDOCS} != "no" && ${MK_GROFF} != "no"
_groff= gnu/usr.bin/groff \
usr.bin/soelim
.endif
@ -1982,7 +1982,10 @@ libraries: .MAKE .PHONY
#
# static libgcc.a prerequisite for shared libc
#
_prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
_prereq_libs= gnu/lib/libgcc lib/libcompiler_rt
.if ${MK_SSP} != "no"
_prereq_libs+= gnu/lib/libssp/libssp_nonshared
.endif
# These dependencies are not automatically generated:
#

View File

@ -130,6 +130,9 @@ OLD_FILES+=usr/lib/clang/3.8.0/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
OLD_DIRS+=usr/lib/clang/3.8.0/lib/freebsd
OLD_DIRS+=usr/lib/clang/3.8.0/lib
OLD_DIRS+=usr/lib/clang/3.8.0
# 20161017: urtwn(4) was merged into rtwn(4)
OLD_FILES+=usr/share/man/man4/urtwn.4.gz
OLD_FILES+=usr/share/man/man4/urtwnfw.4.gz
# 20161015: Remove GNU rcs
OLD_FILES+=usr/bin/ci
OLD_FILES+=usr/bin/co

View File

@ -31,6 +31,30 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
****************************** SPECIAL WARNING: ******************************
Due to a bug in some versions of clang that's very hard to workaround in
the upgrade process, to upgrade to -current you must first upgrade
either stable/9 after r286035 or stable/10 after r286033 (including
10.3-RELEASE) or current after r286007 (including stable/11 and
11.0-RELEASE). These revisions post-date the 10.2 and 9.3 releases, so
you'll need to take the unusual step of upgrading to the tip of the
stable branch before moving to 11 or -current via a source upgrade.
stable/11 and 11.0-RELEASE post-date the fix so you can move from them
to -current. This differs from the historical situation where one could
upgrade from anywhere on the last couple of stable branches, so be
careful.
****************************** SPECIAL WARNING: ******************************
20161017:
The urtwn(4) driver was merged into rtwn(4) and now consists of
rtwn(4) main module + rtwn_usb(4) and rtwn_pci(4) bus-specific
parts.
Also, firmware for RTL8188CE was renamed due to possible name
conflict (rtwnrtl8192cU(B) -> rtwnrtl8192cE(B))
20161015:
GNU rcs has been removed from base. It is available as packages:
- rcs: Latest GPLv3 GNU rcs version.
@ -1460,11 +1484,15 @@ COMMON ITEMS:
your build attempts in an "environmental clean room", prefix all make
commands with 'env -i '. See the env(1) manual page for more details.
When upgrading from one major version to another it is generally best
to upgrade to the latest code in the currently installed branch first,
then do an upgrade to the new branch. This is the best-tested upgrade
path, and has the highest probability of being successful. Please try
this approach before reporting problems with a major version upgrade.
When upgrading from one major version to another it is generally best to
upgrade to the latest code in the currently installed branch first, then
do an upgrade to the new branch. This is the best-tested upgrade path,
and has the highest probability of being successful. Please try this
approach if you encounter problems with a major version upgrade. Since
the stable 4.x branch point, one has generally been able to upgade from
anywhere in the most recent stable branch to head / current (or even the
last couple of stable branches). See the top of this file when there's
an exception.
When upgrading a live system, having a root shell around before
installing anything can help undo problems. Not having a root shell

View File

@ -20,12 +20,13 @@ sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
name="pgrep -j <jid>"
sleep_amount=5
sleep_amount=15
jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_1.pid $sleep $sleep_amount &
jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_2.pid $sleep $sleep_amount &
sleep 0.5
for i in `seq 1 10`; do
jid1=$(jail_name_to_jid ${base}_1_1)
@ -53,7 +54,7 @@ fi
wait
name="pgrep -j any"
sleep_amount=6
sleep_amount=16
jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_2_1.pid $sleep $sleep_amount &
@ -74,7 +75,7 @@ fi
wait
name="pgrep -j none"
sleep_amount=7
sleep_amount=17
daemon -p ${PWD}/${base}_3_1.pid $sleep $sleep_amount &
jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_3_2.pid $sleep $sleep_amount &
@ -91,7 +92,7 @@ wait
# test 4 is like test 1 except with jname instead of jid.
name="pgrep -j <jname>"
sleep_amount=8
sleep_amount=18
jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount &

View File

@ -20,7 +20,7 @@ sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
name="pkill -j <jid>"
sleep_amount=5
sleep_amount=15
jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_1.pid $sleep $sleep_amount &
@ -54,7 +54,7 @@ fi 2>/dev/null
wait
name="pkill -j any"
sleep_amount=6
sleep_amount=16
jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_2_1.pid $sleep $sleep_amount &
@ -76,7 +76,7 @@ fi 2>/dev/null
wait
name="pkill -j none"
sleep_amount=7
sleep_amount=17
daemon -p ${PWD}/${base}_3_1.pid $sleep $sleep_amount
jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_3_2.pid $sleep $sleep_amount &
@ -94,7 +94,7 @@ wait
# test 4 is like test 1 except with jname instead of jid.
name="pkill -j <jname>"
sleep_amount=8
sleep_amount=18
jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount &

View File

@ -31,8 +31,8 @@
#include <unistd.h>
int
go(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6,
int arg7, int arg8, int arg9)
go(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6,
long arg7, long arg8, long arg9)
{
return (arg1);
}

View File

@ -72,6 +72,7 @@ exclude EXFAIL common/mib/tst.udp.ksh
exclude SKIP common/privs/tst.fds.ksh
exclude SKIP common/privs/tst.func_access.ksh
exclude SKIP common/privs/tst.getf.ksh
exclude SKIP common/privs/tst.kpriv.ksh
exclude SKIP common/privs/tst.op_access.ksh
exclude SKIP common/privs/tst.procpriv.ksh
exclude SKIP common/privs/tst.providers.ksh

View File

@ -1146,10 +1146,8 @@ mpages_merge(struct mparse *mp)
for (mpage = mpage_head; mpage != NULL; mpage = mpage->next) {
mlinks_undupe(mpage);
if ((mlink = mpage->mlinks) == NULL) {
mpage = mpage->next;
if ((mlink = mpage->mlinks) == NULL)
continue;
}
name_mask = NAME_MASK;
mandoc_ohash_init(&names, 4, offsetof(struct str, key));

View File

@ -93,7 +93,18 @@ subdirs_body() {
test_unmount
}
# Begin FreeBSD
if true; then
atf_test_case kqueue cleanup
kqueue_cleanup() {
Mount_Point=$(pwd)/mntpt test_unmount || :
}
else
# End FreeBSD
atf_test_case kqueue
# Begin FreeBSD
fi
# End FreeBSD
kqueue_head() {
atf_set "descr" "Verifies that creating a link raises the correct" \
"kqueue events"
@ -102,6 +113,10 @@ kqueue_head() {
kqueue_body() {
test_mount
# Begin FreeBSD
atf_expect_fail "fails with: dir/b did not receive NOTE_LINK - bug 213662"
# End FreeBSD
atf_check -s eq:0 -o empty -e empty mkdir dir
atf_check -s eq:0 -o empty -e empty touch dir/a
echo 'ln dir/a dir/b' | kqueue_monitor 2 dir dir/a

View File

@ -97,6 +97,15 @@ ATF_TC_BODY(swapcontext1, tc)
{
pthread_t thread;
#if defined(__FreeBSD__) && defined(__mips__)
/*
* MIPS modifies TLS pointer in set_mcontext(), so
* swapping contexts obtained from different threads
* gives us different pthread_self() return value.
*/
atf_tc_skip("Platform is not supported.");
#endif
oself = (void *)&val1;
nself = (void *)&val2;

View File

@ -24,7 +24,7 @@ options {
[0-9]+";
set wifi-driver-regex
"(ath|bwi|bwn|ipw|iwi|iwm|iwn|malo|mwl|ral|rsu|rum|run|uath|\
upgt|ural|urtw|urtwn|wi|wpi|wtap|zyd)[0-9]+";
upgt|ural|urtw|rtwn_usb|wi|wpi|wtap|zyd)[0-9]+";
};
# Note that the attach/detach with the highest value wins, so that one can

View File

@ -181,6 +181,14 @@ nomatch 32 {
action "kldload -n if_otus";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0409";
match "product" "0x0408";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -301,6 +309,14 @@ nomatch 32 {
action "kldload -n if_run";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0411";
match "product" "(0x0242|0x025d)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -549,6 +565,14 @@ nomatch 32 {
action "kldload -n if_run";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x04bb";
match "product" "0x0952";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -682,7 +706,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x04f2";
match "product" "(0xaff7|0xaff8|0xaff9|0xaffa|0xaffa)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -754,7 +778,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x050d";
match "product" "0x1102";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -778,7 +802,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x050d";
match "product" "(0x2102|0x2103)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -1050,7 +1074,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x056e";
match "product" "0x4008";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -1146,7 +1170,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0586";
match "product" "0x341f";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -1157,6 +1181,14 @@ nomatch 32 {
action "kldload -n if_run";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0586";
match "product" "0x3426";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -1442,7 +1474,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x06f8";
match "product" "0xe033";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -1658,7 +1690,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x07aa";
match "product" "0x0056";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -1722,7 +1754,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x07b8";
match "product" "(0x8178|0x8179|0x8188|0x8189)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2026,7 +2058,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0846";
match "product" "0x9021";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2041,8 +2073,8 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0846";
match "product" "0x9041";
action "kldload -n if_urtwn";
match "product" "(0x9041|0x9052)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2498,7 +2530,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0b05";
match "product" "0x17ab";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2522,7 +2554,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0b05";
match "product" "0x17ba";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2533,6 +2565,14 @@ nomatch 32 {
action "kldload -n ng_ubt";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0b05";
match "product" "0x17d2";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -2658,7 +2698,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0bda";
match "product" "(0x0179|0x018a|0x317f)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2682,7 +2722,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0bda";
match "product" "0x8170";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2698,7 +2738,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0bda";
match "product" "(0x8176|0x8177|0x8178|0x8179|0x817a|0x817b|0x817c|0x817d|0x817e|0x817f)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2714,7 +2754,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0bda";
match "product" "(0x818a|0x8191)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -2738,7 +2778,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0bda";
match "product" "0x8754";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -3162,7 +3202,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0df6";
match "product" "0x0052";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -3178,7 +3218,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0df6";
match "product" "(0x005c|0x0061)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -3189,6 +3229,14 @@ nomatch 32 {
action "kldload -n if_axge";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0df6";
match "product" "0x0074";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -3257,8 +3305,8 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0e66";
match "product" "0x0019";
action "kldload -n if_urtwn";
match "product" "(0x0019|0x0023)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -3330,7 +3378,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x0eb0";
match "product" "0x9071";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -3490,7 +3538,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x103c";
match "product" "0x1629";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -3973,6 +4021,14 @@ nomatch 32 {
action "kldload -n if_run";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x13b1";
match "product" "0x003f";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -4018,7 +4074,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x13d3";
match "product" "(0x3357|0x3358|0x3359)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -4565,6 +4621,14 @@ nomatch 32 {
action "kldload -n if_run";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x1740";
match "product" "0x0100";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -4961,8 +5025,8 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x2001";
match "product" "(0x3307|0x3308|0x3309|0x330a|0x330d|0x330f|0x3310)";
action "kldload -n if_urtwn";
match "product" "(0x3307|0x3308|0x3309|0x330a|0x330d|0x330f|0x3310|0x3314|0x3315|0x3316|0x3318)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5042,7 +5106,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x2019";
match "product" "(0x1201|0x4902)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5089,8 +5153,8 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x2019";
match "product" "(0xab2a|0xab2b|0xab2e)";
action "kldload -n if_urtwn";
match "product" "(0xab2a|0xab2b|0xab2e|0xab30)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5130,7 +5194,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x2019";
match "product" "0xed17";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5170,7 +5234,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x20f4";
match "product" "0x624d";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5185,8 +5249,8 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x20f4";
match "product" "0x648b";
action "kldload -n if_urtwn";
match "product" "(0x648b|0x805b)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5229,6 +5293,14 @@ nomatch 32 {
action "kldload -n u3g";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x2357";
match "product" "0x0101";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
@ -5354,7 +5426,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x4855";
match "product" "(0x0090|0x0091)";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5465,8 +5537,8 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x7392";
match "product" "(0x7811|0x7822)";
action "kldload -n if_urtwn";
match "product" "(0x7811|0x7822|0xa811|0xa812|0xa822)";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5522,7 +5594,7 @@ nomatch 32 {
match "mode" "host";
match "vendor" "0x9846";
match "product" "0x9041";
action "kldload -n if_urtwn";
action "kldload -n if_rtwn_usb";
};
nomatch 32 {
@ -5817,5 +5889,5 @@ nomatch 32 {
action "kldload -n umass";
};
# 2722 USB entries processed
# 2743 USB entries processed

View File

@ -396,6 +396,10 @@
..
file
..
fs
tmpfs
..
..
geom
class
concat

6
etc/rc
View File

@ -135,16 +135,16 @@ done
# Note: this assumes firstboot_sentinel is on / when we have
# a read-only /, or that it is on media that's writable.
if [ -e ${firstboot_sentinel} ]; then
[ ${root_rw_mount} = "yes" ] || mount -uw /
[ ${root_rw_mount#[Yy][Ee][Ss]} = "" ] || mount -uw /
chflags -R 0 ${firstboot_sentinel}
rm -rf ${firstboot_sentinel}
if [ -e ${firstboot_sentinel}-reboot ]; then
chflags -R 0 ${firstboot_sentinel}-reboot
rm -rf ${firstboot_sentinel}-reboot
[ ${root_rw_mount} = "yes" ] || mount -ur /
[ ${root_rw_mount#[Yy][Ee][Ss]} = "" ] || mount -ur /
kill -INT 1
fi
[ ${root_rw_mount} = "yes" ] || mount -ur /
[ ${root_rw_mount#[Yy][Ee][Ss]} = "" ] || mount -ur /
fi
echo ''

View File

@ -2,26 +2,23 @@
.include <src.opts.mk>
SUBDIR= csu libgcc libregex
SUBDIR= csu
SUBDIR+= libgcc
SUBDIR.${MK_DIALOG}+= libdialog
.if ${MK_GCC} != "no"
SUBDIR+= libgcov libgomp
.endif
.if ${MK_SSP} != "no"
SUBDIR+= libssp
.endif
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
SUBDIR.${MK_GCC}+= libgcov libgomp
SUBDIR.${MK_SSP}+= libssp
SUBDIR.${MK_TESTS}+= tests
.if ${MK_BINUTILS} != "no" && ${MK_GDB} != "no"
SUBDIR+= libreadline
.endif
.if ${MK_GNU_DIFF} != "no" || ${MK_GNU_GREP} != "no" || \
${MK_GNU_GREP_COMPAT} != "no" || ${MK_GDB} != "no"
SUBDIR+= libregex
.endif
# libsupc++ uses libstdc++ headers, although 'make includes' should
# have taken care of that already.
.if ${MK_GNUCXX} != "no"

View File

@ -2,48 +2,25 @@
.include <src.opts.mk>
SUBDIR= ${_binutils} \
${_cc} \
diff \
diff3 \
${_dtc} \
${_gdb} \
${_gperf} \
grep \
${_groff} \
${_tests}
SUBDIR_DEPEND_gdb= ${_binutils}
.if ${MK_CXX} != "no"
.if ${MK_GCC} != "no"
_gperf= gperf
.endif
.if ${MK_GROFF} != "no"
_groff= groff
.endif
SUBDIR.${MK_GCC}+= gperf
SUBDIR.${MK_GROFF}+= groff
.endif
.if ${MK_GPL_DTC} != "no"
_dtc= dtc
.endif
.if ${MK_TESTS} != "no"
_tests= tests
.endif
SUBDIR.${MK_BINUTILS}+= binutils
SUBDIR.${MK_DIALOG}+= dialog
.if ${MK_BINUTILS} != "no"
_binutils= binutils
.if ${MK_GDB} != "no"
_gdb= gdb
.endif
SUBDIR.${MK_GDB}+= gdb
.endif
.if ${MK_GCC} != "no"
_cc= cc
.endif
SUBDIR.${MK_DIALOG}+= dialog
SUBDIR.${MK_GCC}+= cc
SUBDIR.${MK_GNU_DIFF}+= diff diff3
SUBDIR.${MK_GNU_GREP}+= grep
SUBDIR.${MK_GPL_DTC}+= dtc
SUBDIR.${MK_TESTS}+= tests
SUBDIR_PARALLEL=

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 26, 2001
.Dd October 17, 2016
.Dt KLDSYM 2
.Os
.Sh NAME
@ -36,7 +36,7 @@
.In sys/param.h
.In sys/linker.h
.Ft int
.Fn kldsym "int fileid" "int command" "void *data"
.Fn kldsym "int fileid" "int cmd" "void *data"
.Sh DESCRIPTION
The
.Fn kldsym
@ -48,7 +48,7 @@ If
.Fa fileid
is 0, all loaded modules are searched.
Currently, the only
.Fa command
.Fa cmd
implemented is
.Dv KLDSYM_LOOKUP .
.Pp
@ -96,7 +96,7 @@ system call will fail if:
Invalid value in
.Fa data->version
or
.Fa command .
.Fa cmd .
.It Bq Er ENOENT
The
.Fa fileid

View File

@ -8,7 +8,6 @@ TESTS_SUBDIRS= c063
TESTS_SUBDIRS+= db
TESTS_SUBDIRS+= gen
TESTS_SUBDIRS+= hash
TESTS_SUBDIRS+= iconv
TESTS_SUBDIRS+= inet
TESTS_SUBDIRS+= net
TESTS_SUBDIRS+= nss
@ -26,6 +25,10 @@ TESTS_SUBDIRS+= ttyio
SUBDIR_DEPEND_tls= tls_dso
.if ${MK_ICONV} != "no"
TESTS_SUBDIRS+= iconv
.endif
.if ${MK_LOCALES} != "no"
TESTS_SUBDIRS+= locale
.endif

View File

@ -53,6 +53,12 @@ __BEGIN_DECLS
#ifndef MD4End
#define MD4End _libmd_MD4End
#endif
#ifndef MD4Fd
#define MD4Fd _libmd_MD4Fd
#endif
#ifndef MD4FdChunk
#define MD4FdChunk _libmd_MD4FdChunk
#endif
#ifndef MD4File
#define MD4File _libmd_MD4File
#endif
@ -68,6 +74,8 @@ void MD4Update(MD4_CTX *, const void *, unsigned int);
void MD4Pad(MD4_CTX *);
void MD4Final(unsigned char [16], MD4_CTX *);
char * MD4End(MD4_CTX *, char *);
char * MD4Fd(int, char *);
char * MD4FdChunk(int, char *, off_t, off_t);
char * MD4File(const char *, char *);
char * MD4FileChunk(const char *, char *, off_t, off_t);
char * MD4Data(const void *, unsigned int, char *);

View File

@ -25,6 +25,12 @@
#ifndef MD5End
#define MD5End _libmd_MD5End
#endif
#ifndef MD5Fd
#define MD5Fd _libmd_MD5Fd
#endif
#ifndef MD5FdChunk
#define MD5FdChunk _libmd_MD5FdChunk
#endif
#ifndef MD5File
#define MD5File _libmd_MD5File
#endif
@ -37,13 +43,5 @@
#endif
#ifdef __cplusplus
#define static
#endif
#include <sys/md5.h>
#ifdef __cplusplus
#undef static
#endif
#endif /* _MD5_H_ */

View File

@ -42,18 +42,18 @@ MDXEnd(MDX_CTX *ctx, char *buf)
}
char *
MDXFile(const char *filename, char *buf)
MDXFd(int fd, char *buf)
{
return (MDXFileChunk(filename, buf, 0, 0));
return MDXFdChunk(fd, buf, 0, 0);
}
char *
MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
MDXFdChunk(int fd, char *buf, off_t ofs, off_t len)
{
unsigned char buffer[16*1024];
MDX_CTX ctx;
struct stat stbuf;
int fd, readrv, e;
int readrv, e;
off_t remain;
if (len < 0) {
@ -62,9 +62,6 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
}
MDXInit(&ctx);
fd = open(filename, O_RDONLY);
if (fd < 0)
return NULL;
if (ofs != 0) {
errno = 0;
if (lseek(fd, ofs, SEEK_SET) != ofs ||
@ -86,14 +83,33 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
remain -= readrv;
}
error:
e = errno;
close(fd);
errno = e;
if (readrv < 0)
return NULL;
return (MDXEnd(&ctx, buf));
}
char *
MDXFile(const char *filename, char *buf)
{
return (MDXFileChunk(filename, buf, 0, 0));
}
char *
MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
{
char *ret;
int e, fd;
fd = open(filename, O_RDONLY);
if (fd < 0)
return NULL;
ret = MDXFdChunk(fd, buf, ofs, len);
e = errno;
close (fd);
errno = e;
return ret;
}
char *
MDXData (const void *data, unsigned int len, char *buf)
{

View File

@ -96,6 +96,12 @@ __BEGIN_DECLS
#ifndef RIPEMD160_End
#define RIPEMD160_End _libmd_RIPEMD160_End
#endif
#ifndef RIPEMD160_Fd
#define RIPEMD160_Fd _libmd_RIPEMD160_Fd
#endif
#ifndef RIPEMD160_FdChunk
#define RIPEMD160_FdChunk _libmd_RIPEMD160_FdChunk
#endif
#ifndef RIPEMD160_File
#define RIPEMD160_File _libmd_RIPEMD160_File
#endif
@ -121,6 +127,8 @@ void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data,
size_t len);
void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
char *RIPEMD160_End(RIPEMD160_CTX *, char *);
char *RIPEMD160_Fd(int, char *);
char *RIPEMD160_FdChunk(int, char *, off_t, off_t);
char *RIPEMD160_File(const char *, char *);
char *RIPEMD160_FileChunk(const char *, char *, off_t, off_t);
char *RIPEMD160_Data(const void *, unsigned int, char *);

View File

@ -94,6 +94,12 @@ __BEGIN_DECLS
#ifndef SHA_End
#define SHA_End _libmd_SHA_End
#endif
#ifndef SHA_Fd
#define SHA_Fd _libmd_SHA_Fd
#endif
#ifndef SHA_FdChunk
#define SHA_FdChunk _libmd_SHA_FdChunk
#endif
#ifndef SHA_File
#define SHA_File _libmd_SHA_File
#endif
@ -126,6 +132,12 @@ __BEGIN_DECLS
#ifndef SHA1_End
#define SHA1_End _libmd_SHA1_End
#endif
#ifndef SHA1_Fd
#define SHA1_Fd _libmd_SHA1_Fd
#endif
#ifndef SHA1_FdChunk
#define SHA1_FdChunk _libmd_SHA1_FdChunk
#endif
#ifndef SHA1_File
#define SHA1_File _libmd_SHA1_File
#endif
@ -150,6 +162,8 @@ void SHA_Init(SHA_CTX *c);
void SHA_Update(SHA_CTX *c, const void *data, size_t len);
void SHA_Final(unsigned char *md, SHA_CTX *c);
char *SHA_End(SHA_CTX *, char *);
char *SHA_Fd(int, char *);
char *SHA_FdChunk(int, char *, off_t, off_t);
char *SHA_File(const char *, char *);
char *SHA_FileChunk(const char *, char *, off_t, off_t);
char *SHA_Data(const void *, unsigned int, char *);
@ -158,6 +172,8 @@ void SHA1_Init(SHA_CTX *c);
void SHA1_Update(SHA_CTX *c, const void *data, size_t len);
void SHA1_Final(unsigned char *md, SHA_CTX *c);
char *SHA1_End(SHA_CTX *, char *);
char *SHA1_Fd(int, char *);
char *SHA1_FdChunk(int, char *, off_t, off_t);
char *SHA1_File(const char *, char *);
char *SHA1_FileChunk(const char *, char *, off_t, off_t);
char *SHA1_Data(const void *, unsigned int, char *);

View File

@ -5,20 +5,94 @@
PACKAGE=lib${LIB}
LIB= sysdecode
SRCS= errno.c ioctl.c syscallnames.c utrace.c
SRCS= errno.c flags.c ioctl.c signal.c syscallnames.c utrace.c
INCS= sysdecode.h
CFLAGS+= -I${.OBJDIR}
CFLAGS+= -I${.CURDIR}/../../sys
CFLAGS+= -I${.CURDIR}/../../libexec/rtld-elf
MAN+= sysdecode.3 \
MAN= sysdecode.3 \
sysdecode_abi_to_freebsd_errno.3 \
sysdecode_cap_rights.3 \
sysdecode_enum.3 \
sysdecode_fcntl_arg.3 \
sysdecode_ioctlname.3 \
sysdecode_mask.3 \
sysdecode_quotactl_cmd.3 \
sysdecode_sigcode.3 \
sysdecode_sockopt_name.3 \
sysdecode_syscallnames.3 \
sysdecode_utrace.3
MLINKS+= sysdecode_abi_to_freebsd_errno.3 sysdecode_freebsd_to_abi_errno.3
MLINKS= sysdecode_abi_to_freebsd_errno.3 sysdecode_freebsd_to_abi_errno.3
MLINKS+=sysdecode_enum.3 sysdecode_acltype.3 \
sysdecode_enum.3 sysdecode_atfd.3 \
sysdecode_enum.3 sysdecode_extattrnamespace.3 \
sysdecode_enum.3 sysdecode_fadvice.3 \
sysdecode_enum.3 sysdecode_fcntl_cmd.3 \
sysdecode_enum.3 sysdecode_idtype.3 \
sysdecode_enum.3 sysdecode_ipproto.3 \
sysdecode_enum.3 sysdecode_kldsym_cmd.3 \
sysdecode_enum.3 sysdecode_kldunload_flags.3 \
sysdecode_enum.3 sysdecode_lio_listio_mode.3 \
sysdecode_enum.3 sysdecode_madvice.3 \
sysdecode_enum.3 sysdecode_minherit_flags.3 \
sysdecode_enum.3 sysdecode_msgctl_cmd.3 \
sysdecode_enum.3 sysdecode_nfssvc_flags.3 \
sysdecode_enum.3 sysdecode_prio_which.3 \
sysdecode_enum.3 sysdecode_procctl_cmd.3 \
sysdecode_enum.3 sysdecode_ptrace_request.3 \
sysdecode_enum.3 sysdecode_rlimit.3 \
sysdecode_enum.3 sysdecode_rtprio_function.3 \
sysdecode_enum.3 sysdecode_scheduler_policy.3 \
sysdecode_enum.3 sysdecode_semctl_cmd.3 \
sysdecode_enum.3 sysdecode_shmctl_cmd.3 \
sysdecode_enum.3 sysdecode_shutdown_how.3 \
sysdecode_enum.3 sysdecode_sigbus_code.3 \
sysdecode_enum.3 sysdecode_sigchld_code.3 \
sysdecode_enum.3 sysdecode_sigfpe_code.3 \
sysdecode_enum.3 sysdecode_sigill_code.3 \
sysdecode_enum.3 sysdecode_signal.3 \
sysdecode_enum.3 sysdecode_sigprocmask_how.3 \
sysdecode_enum.3 sysdecode_sigsegv_code.3 \
sysdecode_enum.3 sysdecode_sigtrap_code.3 \
sysdecode_enum.3 sysdecode_sockaddr_family.3 \
sysdecode_enum.3 sysdecode_socketdomain.3 \
sysdecode_enum.3 sysdecode_sockettype.3 \
sysdecode_enum.3 sysdecode_sockopt_level.3 \
sysdecode_enum.3 sysdecode_umtx_op.3 \
sysdecode_enum.3 sysdecode_vmresult.3 \
sysdecode_enum.3 sysdecode_whence.3
MLINKS+=sysdecode_fcntl_arg.3 sysdecode_fcntl_arg_p.3
MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
sysdecode_mask.3 sysdecode_capfcntlrights.3 \
sysdecode_mask.3 sysdecode_fcntl_fileflags.3 \
sysdecode_mask.3 sysdecode_fileflags.3 \
sysdecode_mask.3 sysdecode_filemode.3 \
sysdecode_mask.3 sysdecode_flock_operation.3 \
sysdecode_mask.3 sysdecode_getfsstat_flags.3 \
sysdecode_mask.3 sysdecode_mlockall_flags.3 \
sysdecode_mask.3 sysdecode_mmap_flags.3 \
sysdecode_mask.3 sysdecode_mmap_prot.3 \
sysdecode_mask.3 sysdecode_mount_flags.3 \
sysdecode_mask.3 sysdecode_msg_flags.3 \
sysdecode_mask.3 sysdecode_msync_flags.3 \
sysdecode_mask.3 sysdecode_open_flags.3 \
sysdecode_mask.3 sysdecode_pipe2_flags.3 \
sysdecode_mask.3 sysdecode_reboot_howto.3 \
sysdecode_mask.3 sysdecode_rfork_flags.3 \
sysdecode_mask.3 sysdecode_semget_flags.3 \
sysdecode_mask.3 sysdecode_sendfile_flags.3 \
sysdecode_mask.3 sysdecode_shmat_flags.3 \
sysdecode_mask.3 sysdecode_socket_type.3 \
sysdecode_mask.3 sysdecode_thr_create_flags.3 \
sysdecode_mask.3 sysdecode_umtx_cvwait_flags.3 \
sysdecode_mask.3 sysdecode_umtx_rwlock_flags.3 \
sysdecode_mask.3 sysdecode_vmprot.3 \
sysdecode_mask.3 sysdecode_wait4_options.3 \
sysdecode_mask.3 sysdecode_wait6_options.3
CLEANFILES= ioctl.c
CLEANFILES= ioctl.c tables.h
.if defined(COMPAT_32BIT)
CPP+= -m32
@ -36,10 +110,13 @@ CFLAGS.gcc.ioctl.c+= -Wno-unused
CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
tables.h: mktables
sh ${.CURDIR}/mktables ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
ioctl.c: mkioctls
env MACHINE=${MACHINE} CPP="${CPP}" \
/bin/sh ${.CURDIR}/mkioctls ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
beforedepend: ioctl.c
beforedepend: ioctl.c tables.h
.include <bsd.lib.mk>

View File

@ -28,8 +28,11 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/acl.h>
#include <sys/wait.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <sysdecode.h>

982
lib/libsysdecode/flags.c Normal file
View File

@ -0,0 +1,982 @@
/*
* Copyright (c) 2006 "David Kirchner" <dpk@dpk.net>. 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define L2CAP_SOCKET_CHECKED
#include <sys/types.h>
#include <sys/acl.h>
#include <sys/capsicum.h>
#include <sys/extattr.h>
#include <sys/linker.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/procctl.h>
#include <sys/ptrace.h>
#include <sys/reboot.h>
#include <sys/resource.h>
#include <sys/rtprio.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/thr.h>
#include <sys/umtx.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <nfsserver/nfs.h>
#include <ufs/ufs/quota.h>
#include <vm/vm_param.h>
#include <aio.h>
#include <fcntl.h>
#include <sched.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <sysdecode.h>
#include <unistd.h>
#include <sys/bitstring.h>
#include <netgraph/bluetooth/include/ng_hci.h>
#include <netgraph/bluetooth/include/ng_l2cap.h>
#include <netgraph/bluetooth/include/ng_btsocket.h>
/*
* This is taken from the xlat tables originally in truss which were
* in turn taken from strace.
*/
struct name_table {
uintmax_t val;
const char *str;
};
#define X(a) { a, #a },
#define XEND { 0, NULL }
#define TABLE_START(n) static struct name_table n[] = {
#define TABLE_ENTRY X
#define TABLE_END XEND };
#include "tables.h"
#undef TABLE_START
#undef TABLE_ENTRY
#undef TABLE_END
/*
* These are simple support macros. print_or utilizes a variable
* defined in the calling function to track whether or not it should
* print a logical-OR character ('|') before a string. if_print_or
* simply handles the necessary "if" statement used in many lines
* of this file.
*/
#define print_or(fp,str,orflag) do { \
if (orflag) fputc(fp, '|'); else orflag = true; \
fprintf(fp, str); } \
while (0)
#define if_print_or(fp,i,flag,orflag) do { \
if ((i & flag) == flag) \
print_or(fp,#flag,orflag); } \
while (0)
static const char *
lookup_value(struct name_table *table, uintmax_t val)
{
for (; table->str != NULL; table++)
if (table->val == val)
return (table->str);
return (NULL);
}
/*
* Used when the value maps to a bitmask of #definition values in the
* table. This is a helper routine which outputs a symbolic mask of
* matched masks. Multiple masks are separated by a pipe ('|').
* The value is modified on return to only hold unmatched bits.
*/
static void
print_mask_part(FILE *fp, struct name_table *table, uintmax_t *valp,
bool *printed)
{
uintmax_t rem;
rem = *valp;
for (; table->str != NULL; table++) {
if ((table->val & rem) == table->val) {
/*
* Only print a zero mask if the raw value is
* zero.
*/
if (table->val == 0 && *valp != 0)
continue;
fprintf(fp, "%s%s", *printed ? "|" : "", table->str);
*printed = true;
rem &= ~table->val;
}
}
*valp = rem;
}
/*
* Used when the value maps to a bitmask of #definition values in the
* table. The return value is true if something was printed. If
* rem is not NULL, *rem holds any bits not decoded if something was
* printed. If nothing was printed and rem is not NULL, *rem holds
* the original value.
*/
static bool
print_mask_int(FILE *fp, struct name_table *table, int ival, int *rem)
{
uintmax_t val;
bool printed;
printed = false;
val = (unsigned)ival;
print_mask_part(fp, table, &val, &printed);
if (rem != NULL)
*rem = val;
return (printed);
}
/*
* Used for a mask of optional flags where a value of 0 is valid.
*/
static bool
print_mask_0(FILE *fp, struct name_table *table, int val, int *rem)
{
if (val == 0) {
fputs("0", fp);
if (rem != NULL)
*rem = 0;
return (true);
}
return (print_mask_int(fp, table, val, rem));
}
/*
* Like print_mask_0 but for a unsigned long instead of an int.
*/
static bool
print_mask_0ul(FILE *fp, struct name_table *table, u_long lval, u_long *rem)
{
uintmax_t val;
bool printed;
if (lval == 0) {
fputs("0", fp);
if (rem != NULL)
*rem = 0;
return (true);
}
printed = false;
val = lval;
print_mask_part(fp, table, &val, &printed);
if (rem != NULL)
*rem = val;
return (printed);
}
static void
print_integer(FILE *fp, int val, int base)
{
switch (base) {
case 8:
fprintf(fp, "0%o", val);
break;
case 10:
fprintf(fp, "%d", val);
break;
case 16:
fprintf(fp, "0x%x", val);
break;
default:
abort2("bad base", 0, NULL);
break;
}
}
static bool
print_value(FILE *fp, struct name_table *table, uintmax_t val)
{
const char *str;
str = lookup_value(table, val);
if (str != NULL) {
fputs(str, fp);
return (true);
}
return (false);
}
const char *
sysdecode_atfd(int fd)
{
if (fd == AT_FDCWD)
return ("AT_FDCWD");
return (NULL);
}
static struct name_table semctlops[] = {
X(GETNCNT) X(GETPID) X(GETVAL) X(GETALL) X(GETZCNT) X(SETVAL) X(SETALL)
X(IPC_RMID) X(IPC_SET) X(IPC_STAT) XEND
};
const char *
sysdecode_semctl_cmd(int cmd)
{
return (lookup_value(semctlops, cmd));
}
static struct name_table shmctlops[] = {
X(IPC_RMID) X(IPC_SET) X(IPC_STAT) XEND
};
const char *
sysdecode_shmctl_cmd(int cmd)
{
return (lookup_value(shmctlops, cmd));
}
const char *
sysdecode_msgctl_cmd(int cmd)
{
return (sysdecode_shmctl_cmd(cmd));
}
static struct name_table semgetflags[] = {
X(IPC_CREAT) X(IPC_EXCL) X(SEM_R) X(SEM_A) X((SEM_R>>3)) X((SEM_A>>3))
X((SEM_R>>6)) X((SEM_A>>6)) XEND
};
bool
sysdecode_semget_flags(FILE *fp, int flag, int *rem)
{
return (print_mask_int(fp, semgetflags, flag, rem));
}
static struct name_table idtypes[] = {
X(P_PID) X(P_PPID) X(P_PGID) X(P_SID) X(P_CID) X(P_UID) X(P_GID)
X(P_ALL) X(P_LWPID) X(P_TASKID) X(P_PROJID) X(P_POOLID) X(P_JAILID)
X(P_CTID) X(P_CPUID) X(P_PSETID) XEND
};
/* XXX: idtype is really an idtype_t */
const char *
sysdecode_idtype(int idtype)
{
return (lookup_value(idtypes, idtype));
}
/*
* [g|s]etsockopt's level argument can either be SOL_SOCKET or a
* protocol-specific value.
*/
const char *
sysdecode_sockopt_level(int level)
{
const char *str;
if (level == SOL_SOCKET)
return ("SOL_SOCKET");
/* SOL_* constants for Bluetooth sockets. */
str = lookup_value(ngbtsolevel, level);
if (str != NULL)
return (str);
/*
* IP and Infiniband sockets use IP protocols as levels. Not all
* protocols are valid but it is simpler to just allow all of them.
*
* XXX: IPPROTO_IP == 0, but UNIX domain sockets use a level of 0
* for private options.
*/
str = sysdecode_ipproto(level);
if (str != NULL)
return (str);
return (NULL);
}
bool
sysdecode_vmprot(FILE *fp, int type, int *rem)
{
return (print_mask_int(fp, vmprot, type, rem));
}
static struct name_table sockflags[] = {
X(SOCK_CLOEXEC) X(SOCK_NONBLOCK) XEND
};
bool
sysdecode_socket_type(FILE *fp, int type, int *rem)
{
const char *str;
uintmax_t val;
bool printed;
str = lookup_value(socktype, type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK));
if (str != NULL) {
fputs(str, fp);
*rem = 0;
printed = true;
} else {
*rem = type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK);
printed = false;
}
val = type & (SOCK_CLOEXEC | SOCK_NONBLOCK);
print_mask_part(fp, sockflags, &val, &printed);
return (printed);
}
bool
sysdecode_access_mode(FILE *fp, int mode, int *rem)
{
return (print_mask_int(fp, accessmode, mode, rem));
}
/* XXX: 'type' is really an acl_type_t. */
const char *
sysdecode_acltype(int type)
{
return (lookup_value(acltype, type));
}
bool
sysdecode_cap_fcntlrights(FILE *fp, uint32_t rights, uint32_t *rem)
{
return (print_mask_int(fp, capfcntl, rights, rem));
}
const char *
sysdecode_extattrnamespace(int namespace)
{
return (lookup_value(extattrns, namespace));
}
const char *
sysdecode_fadvice(int advice)
{
return (lookup_value(fadvisebehav, advice));
}
bool
sysdecode_open_flags(FILE *fp, int flags, int *rem)
{
bool printed;
int mode;
uintmax_t val;
mode = flags & O_ACCMODE;
flags &= ~O_ACCMODE;
switch (mode) {
case O_RDONLY:
if (flags & O_EXEC) {
flags &= ~O_EXEC;
fputs("O_EXEC", fp);
} else
fputs("O_RDONLY", fp);
printed = true;
mode = 0;
break;
case O_WRONLY:
fputs("O_WRONLY", fp);
printed = true;
mode = 0;
break;
case O_RDWR:
fputs("O_RDWR", fp);
printed = true;
mode = 0;
break;
default:
printed = false;
}
val = (unsigned)flags;
print_mask_part(fp, openflags, &val, &printed);
if (rem != NULL)
*rem = val | mode;
return (printed);
}
bool
sysdecode_fcntl_fileflags(FILE *fp, int flags, int *rem)
{
bool printed;
int oflags;
/*
* The file flags used with F_GETFL/F_SETFL mostly match the
* flags passed to open(2). However, a few open-only flag
* bits have been repurposed for fcntl-only flags.
*/
oflags = flags & ~(O_NOFOLLOW | FRDAHEAD);
printed = sysdecode_open_flags(fp, oflags, rem);
if (flags & O_NOFOLLOW) {
fprintf(fp, "%sFPOIXSHM", printed ? "|" : "");
printed = true;
}
if (flags & FRDAHEAD) {
fprintf(fp, "%sFRDAHEAD", printed ? "|" : "");
printed = true;
}
return (printed);
}
bool
sysdecode_flock_operation(FILE *fp, int operation, int *rem)
{
return (print_mask_int(fp, flockops, operation, rem));
}
bool
sysdecode_getfsstat_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, getfsstatflags, flags, rem));
}
const char *
sysdecode_kldsym_cmd(int cmd)
{
return (lookup_value(kldsymcmd, cmd));
}
const char *
sysdecode_kldunload_flags(int flags)
{
return (lookup_value(kldunloadfflags, flags));
}
const char *
sysdecode_lio_listio_mode(int mode)
{
return (lookup_value(lio_listiomodes, mode));
}
const char *
sysdecode_madvice(int advice)
{
return (lookup_value(madvisebehav, advice));
}
const char *
sysdecode_minherit_inherit(int inherit)
{
return (lookup_value(minheritflags, inherit));
}
bool
sysdecode_mlockall_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, mlockallflags, flags, rem));
}
bool
sysdecode_mmap_prot(FILE *fp, int prot, int *rem)
{
return (print_mask_int(fp, mmapprot, prot, rem));
}
bool
sysdecode_fileflags(FILE *fp, fflags_t flags, fflags_t *rem)
{
return (print_mask_0(fp, fileflags, flags, rem));
}
bool
sysdecode_filemode(FILE *fp, int mode, int *rem)
{
return (print_mask_0(fp, filemode, mode, rem));
}
bool
sysdecode_mount_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, mountflags, flags, rem));
}
bool
sysdecode_msync_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, msyncflags, flags, rem));
}
const char *
sysdecode_nfssvc_flags(int flags)
{
return (lookup_value(nfssvcflags, flags));
}
static struct name_table pipe2flags[] = {
X(O_CLOEXEC) X(O_NONBLOCK) XEND
};
bool
sysdecode_pipe2_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_0(fp, pipe2flags, flags, rem));
}
const char *
sysdecode_prio_which(int which)
{
return (lookup_value(prio, which));
}
const char *
sysdecode_procctl_cmd(int cmd)
{
return (lookup_value(procctlcmd, cmd));
}
const char *
sysdecode_ptrace_request(int request)
{
return (lookup_value(ptraceop, request));
}
static struct name_table quotatypes[] = {
X(GRPQUOTA) X(USRQUOTA) XEND
};
bool
sysdecode_quotactl_cmd(FILE *fp, int cmd)
{
const char *primary, *type;
primary = lookup_value(quotactlcmds, cmd >> SUBCMDSHIFT);
if (primary == NULL)
return (false);
fprintf(fp, "QCMD(%s,", primary);
type = lookup_value(quotatypes, cmd & SUBCMDMASK);
if (type != NULL)
fprintf(fp, "%s", type);
else
fprintf(fp, "%#x", cmd & SUBCMDMASK);
fprintf(fp, ")");
return (true);
}
bool
sysdecode_reboot_howto(FILE *fp, int howto, int *rem)
{
return (print_mask_int(fp, rebootopt, howto, rem));
}
bool
sysdecode_rfork_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, rforkflags, flags, rem));
}
const char *
sysdecode_rlimit(int resource)
{
return (lookup_value(rlimit, resource));
}
const char *
sysdecode_scheduler_policy(int policy)
{
return (lookup_value(schedpolicy, policy));
}
bool
sysdecode_sendfile_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, sendfileflags, flags, rem));
}
bool
sysdecode_shmat_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, shmatflags, flags, rem));
}
const char *
sysdecode_shutdown_how(int how)
{
return (lookup_value(shutdownhow, how));
}
const char *
sysdecode_sigbus_code(int si_code)
{
return (lookup_value(sigbuscode, si_code));
}
const char *
sysdecode_sigchld_code(int si_code)
{
return (lookup_value(sigchldcode, si_code));
}
const char *
sysdecode_sigfpe_code(int si_code)
{
return (lookup_value(sigfpecode, si_code));
}
const char *
sysdecode_sigill_code(int si_code)
{
return (lookup_value(sigillcode, si_code));
}
const char *
sysdecode_sigsegv_code(int si_code)
{
return (lookup_value(sigsegvcode, si_code));
}
const char *
sysdecode_sigtrap_code(int si_code)
{
return (lookup_value(sigtrapcode, si_code));
}
const char *
sysdecode_sigprocmask_how(int how)
{
return (lookup_value(sigprocmaskhow, how));
}
const char *
sysdecode_socketdomain(int domain)
{
return (lookup_value(sockdomain, domain));
}
const char *
sysdecode_sockaddr_family(int sa_family)
{
return (lookup_value(sockfamily, sa_family));
}
const char *
sysdecode_ipproto(int protocol)
{
return (lookup_value(sockipproto, protocol));
}
const char *
sysdecode_sockopt_name(int level, int optname)
{
if (level == SOL_SOCKET)
return (lookup_value(sockopt, optname));
if (level == IPPROTO_IP)
/* XXX: UNIX domain socket options use a level of 0 also. */
return (lookup_value(sockoptip, optname));
if (level == IPPROTO_TCP)
return (lookup_value(sockopttcp, optname));
if (level == IPPROTO_UDP)
return (lookup_value(sockoptudp, optname));
return (NULL);
}
bool
sysdecode_thr_create_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_int(fp, thrcreateflags, flags, rem));
}
const char *
sysdecode_umtx_op(int op)
{
return (lookup_value(umtxop, op));
}
const char *
sysdecode_vmresult(int result)
{
return (lookup_value(vmresult, result));
}
bool
sysdecode_wait4_options(FILE *fp, int options, int *rem)
{
bool printed;
int opt6;
/* A flags value of 0 is normal. */
if (options == 0) {
fputs("0", fp);
if (rem != NULL)
*rem = 0;
return (true);
}
/*
* These flags are implicit and aren't valid flags for wait4()
* directly (though they don't fail with EINVAL).
*/
opt6 = options & (WEXITED | WTRAPPED);
options &= ~opt6;
printed = print_mask_int(fp, wait6opt, options, rem);
if (rem != NULL)
*rem |= opt6;
return (printed);
}
bool
sysdecode_wait6_options(FILE *fp, int options, int *rem)
{
return (print_mask_int(fp, wait6opt, options, rem));
}
const char *
sysdecode_whence(int whence)
{
return (lookup_value(seekwhence, whence));
}
const char *
sysdecode_fcntl_cmd(int cmd)
{
return (lookup_value(fcntlcmd, cmd));
}
static struct name_table fcntl_fd_arg[] = {
X(FD_CLOEXEC) X(0) XEND
};
bool
sysdecode_fcntl_arg_p(int cmd)
{
switch (cmd) {
case F_GETFD:
case F_GETFL:
case F_GETOWN:
return (false);
default:
return (true);
}
}
void
sysdecode_fcntl_arg(FILE *fp, int cmd, uintptr_t arg, int base)
{
int rem;
switch (cmd) {
case F_SETFD:
if (!print_value(fp, fcntl_fd_arg, arg))
print_integer(fp, arg, base);
break;
case F_SETFL:
if (!sysdecode_fcntl_fileflags(fp, arg, &rem))
fprintf(fp, "%#x", rem);
else if (rem != 0)
fprintf(fp, "|%#x", rem);
break;
case F_GETLK:
case F_SETLK:
case F_SETLKW:
fprintf(fp, "%p", (void *)arg);
break;
default:
print_integer(fp, arg, base);
break;
}
}
bool
sysdecode_mmap_flags(FILE *fp, int flags, int *rem)
{
uintmax_t val;
bool printed;
int align;
/*
* MAP_ALIGNED can't be handled directly by print_mask_int().
* MAP_32BIT is also problematic since it isn't defined for
* all platforms.
*/
printed = false;
align = flags & MAP_ALIGNMENT_MASK;
val = (unsigned)flags & ~MAP_ALIGNMENT_MASK;
print_mask_part(fp, mmapflags, &val, &printed);
#ifdef MAP_32BIT
if (val & MAP_32BIT) {
fprintf(fp, "%sMAP_32BIT", printed ? "|" : "");
printed = true;
val &= ~MAP_32BIT;
}
#endif
if (align != 0) {
if (printed)
fputc('|', fp);
if (align == MAP_ALIGNED_SUPER)
fputs("MAP_ALIGNED_SUPER", fp);
else
fprintf(fp, "MAP_ALIGNED(%d)",
align >> MAP_ALIGNMENT_SHIFT);
printed = true;
}
if (rem != NULL)
*rem = val;
return (printed);
}
const char *
sysdecode_rtprio_function(int function)
{
return (lookup_value(rtpriofuncs, function));
}
bool
sysdecode_msg_flags(FILE *fp, int flags, int *rem)
{
return (print_mask_0(fp, msgflags, flags, rem));
}
const char *
sysdecode_sigcode(int sig, int si_code)
{
const char *str;
str = lookup_value(sigcode, si_code);
if (str != NULL)
return (str);
switch (sig) {
case SIGILL:
return (sysdecode_sigill_code(si_code));
case SIGBUS:
return (sysdecode_sigbus_code(si_code));
case SIGSEGV:
return (sysdecode_sigsegv_code(si_code));
case SIGFPE:
return (sysdecode_sigfpe_code(si_code));
case SIGTRAP:
return (sysdecode_sigtrap_code(si_code));
case SIGCHLD:
return (sysdecode_sigchld_code(si_code));
default:
return (NULL);
}
}
bool
sysdecode_umtx_cvwait_flags(FILE *fp, u_long flags, u_long *rem)
{
return (print_mask_0ul(fp, umtxcvwaitflags, flags, rem));
}
bool
sysdecode_umtx_rwlock_flags(FILE *fp, u_long flags, u_long *rem)
{
return (print_mask_0ul(fp, umtxrwlockflags, flags, rem));
}
/* XXX: This should be in <sys/capsicum.h> */
#define CAPMASK(right) ((right) && (((uint64_t)1 << 57) - 1))
void
sysdecode_cap_rights(FILE *fp, cap_rights_t *rightsp)
{
struct name_table *t;
int idx;
bool comma;
comma = false;
for (t = caprights; t->str != NULL; t++) {
idx = ffs(CAPIDXBIT(t->val)) - 1;
if (CAPARSIZE(rightsp) < idx)
continue;
if ((rightsp->cr_rights[CAPIDXBIT(t->val)] & CAPMASK(t->val)) ==
CAPMASK(t->val)) {
fprintf(fp, "%s%s", comma ? "," : "", t->str);
comma = true;
}
}
}

View File

@ -62,6 +62,7 @@ BEGIN {
print "#include <netinet6/ip6_mroute.h>"
print "#include <stdio.h>"
print "#include <cam/cam.h>"
print "#include <stdbool.h>"
print "#include <stddef.h>"
print "#include <stdint.h>"
print "#include <sysdecode.h>"

144
lib/libsysdecode/mktables Normal file
View File

@ -0,0 +1,144 @@
#!/bin/sh
#
# Copyright (c) 2006 "David Kirchner" <dpk@dpk.net>. 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$
#
# Generates tables.h
#
# Originally this script was 'mksubr' for kdump which generated a complete
# C file along with function definitions. Now this script generates tables
# of constants and names extracted from header files.
set -e
LC_ALL=C; export LC_ALL
if [ -z "$1" ]
then
echo "usage: sh $0 include-dir"
exit 1
fi
include_dir=$1
#
# Generate a table C #definitions. The including file can define the
# TABLE_NAME(n), TABLE_ENTRY(x), and TABLE_END macros to define what
# the tables map to.
#
gen_table()
{
local name grep file excl filter
name=$1
grep=$2
file=$3
excl=$4
if [ -z "$excl" ]; then
filter="cat"
else
filter="egrep -v"
fi
cat <<_EOF_
TABLE_START(${name})
_EOF_
egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
$include_dir/$file | ${filter} ${excl} | \
awk '{ for (i = 1; i <= NF; i++) \
if ($i ~ /define/) \
break; \
++i; \
printf "TABLE_ENTRY(%s)\n", $i }'
cat <<_EOF_
TABLE_END
_EOF_
}
cat <<_EOF_
/* This file is auto-generated. */
_EOF_
gen_table "accessmode" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h"
gen_table "acltype" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h"
gen_table "capfcntl" "CAP_FCNTL_[A-Z]+[[:space:]]+\(1" "sys/capsicum.h"
gen_table "extattrns" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h"
gen_table "fadvisebehav" "POSIX_FADV_[A-Z]+[[:space:]]+[0-9]+" "sys/fcntl.h"
gen_table "openflags" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" "O_RDONLY|O_RDWR|O_WRONLY"
gen_table "flockops" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h"
gen_table "getfsstatflags" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h"
gen_table "kldsymcmd" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
gen_table "kldunloadfflags" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
gen_table "lio_listiomodes" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h"
gen_table "madvisebehav" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
gen_table "minheritflags" "INHERIT_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
gen_table "mlockallflags" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
gen_table "mmapprot" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
gen_table "ngbtsolevel" "SOL_[A-Z0-9]+[[:space:]]+0x[0-9A-Fa-f]+" "netgraph/bluetooth/include/ng_btsocket.h"
gen_table "fileflags" "[SU]F_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/stat.h" "UF_COMPRESSED|UF_TRACKED|UF_SETTABLE|SF_SETTABLE"
gen_table "filemode" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h"
gen_table "mountflags" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h"
gen_table "msyncflags" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
gen_table "nfssvcflags" "NFSSVC_[A-Z0-9]+[[:space:]]+0x[0-9]+" "nfs/nfssvc.h"
gen_table "prio" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h"
gen_table "procctlcmd" "PROC_[A-Z_]+[[:space:]]+[0-9]" "sys/procctl.h" "PROC_TRACE_CTL_"
gen_table "ptraceop" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h"
gen_table "quotactlcmds" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h"
gen_table "rebootopt" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
gen_table "rforkflags" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h"
gen_table "rlimit" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
gen_table "schedpolicy" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
gen_table "sendfileflags" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
gen_table "shmatflags" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h"
gen_table "shutdownhow" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
gen_table "sigbuscode" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigchldcode" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigfpecode" "FPE_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigprocmaskhow" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigillcode" "ILL_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigsegvcode" "SEGV_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigtrapcode" "TRAP_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sockdomain" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
gen_table "sockfamily" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
gen_table "sockipproto" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h"
gen_table "sockopt" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
gen_table "sockoptip" "(IP_[[:alnum:]_]+|MCAST_[[:alnum:]_]+_GROUP)[[:space:]]+" "netinet/in.h" "IP_DEFAULT|IP_MIN|IP_MAX|IP_PORTRANGE"
gen_table "sockopttcp" "TCP_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/tcp.h" "TCP_MIN|TCP_MAX[^S]|TCP_MSS|TCP_[[:alnum:]_]+_MAX"
gen_table "sockoptudp" "UDP_[[:alnum:]]+[[:space:]]+[0-9]+" "netinet/udp.h" "UDP_ENCAP_"
gen_table "socktype" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h"
gen_table "thrcreateflags" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
gen_table "umtxop" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h"
gen_table "vmprot" "VM_PROT_[A-Z]+[[:space:]]+\(\(vm_prot_t\)\)" "vm/vm.h"
gen_table "vmresult" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h"
gen_table "wait6opt" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h"
gen_table "seekwhence" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h"
gen_table "fcntlcmd" "F_[A-Z0-9_]+[[:space:]]+[0-9]+[[:space:]]+" "sys/fcntl.h" "F_CANCEL|F_..LCK"
gen_table "mmapflags" "MAP_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
gen_table "rtpriofuncs" "RTP_[A-Z]+[[:space:]]+[0-9]+" "sys/rtprio.h"
gen_table "msgflags" "MSG_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" "MSG_SOCALLBCK"
gen_table "sigcode" "SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?" "sys/signal.h"
gen_table "umtxcvwaitflags" "CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/umtx.h"
gen_table "umtxrwlockflags" "URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+" "sys/umtx.h"
gen_table "caprights" "CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)" "sys/capsicum.h"

143
lib/libsysdecode/signal.c Normal file
View File

@ -0,0 +1,143 @@
/*-
* Copyright (c) 2016 John H. Baldwin <jhb@FreeBSD.org>
* 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <sysdecode.h>
static const char *signames[] = {
[SIGHUP] = "SIGHUP",
[SIGINT] = "SIGINT",
[SIGQUIT] = "SIGQUIT",
[SIGILL] = "SIGILL",
[SIGTRAP] = "SIGTRAP",
[SIGABRT] = "SIGABRT",
[SIGEMT] = "SIGEMT",
[SIGFPE] = "SIGFPE",
[SIGKILL] = "SIGKILL",
[SIGBUS] = "SIGBUS",
[SIGSEGV] = "SIGSEGV",
[SIGSYS] = "SIGSYS",
[SIGPIPE] = "SIGPIPE",
[SIGALRM] = "SIGALRM",
[SIGTERM] = "SIGTERM",
[SIGURG] = "SIGURG",
[SIGSTOP] = "SIGSTOP",
[SIGTSTP] = "SIGTSTP",
[SIGCONT] = "SIGCONT",
[SIGCHLD] = "SIGCHLD",
[SIGTTIN] = "SIGTTIN",
[SIGTTOU] = "SIGTTOU",
[SIGIO] = "SIGIO",
[SIGXCPU] = "SIGXCPU",
[SIGXFSZ] = "SIGXFSZ",
[SIGVTALRM] = "SIGVTALRM",
[SIGPROF] = "SIGPROF",
[SIGWINCH] = "SIGWINCH",
[SIGINFO] = "SIGINFO",
[SIGUSR1] = "SIGUSR1",
[SIGUSR2] = "SIGUSR2",
[SIGTHR] = "SIGTHR",
[SIGLIBRT] = "SIGLIBRT",
/* XXX: Solaris uses SIGRTMIN, SIGRTMIN+<x>...SIGRTMAX-<x>, SIGRTMAX */
[SIGRTMIN] = "SIGRT0",
[SIGRTMIN + 1] = "SIGRT1",
[SIGRTMIN + 2] = "SIGRT2",
[SIGRTMIN + 3] = "SIGRT3",
[SIGRTMIN + 4] = "SIGRT4",
[SIGRTMIN + 5] = "SIGRT5",
[SIGRTMIN + 6] = "SIGRT6",
[SIGRTMIN + 7] = "SIGRT7",
[SIGRTMIN + 8] = "SIGRT8",
[SIGRTMIN + 9] = "SIGRT9",
[SIGRTMIN + 10] = "SIGRT10",
[SIGRTMIN + 11] = "SIGRT11",
[SIGRTMIN + 12] = "SIGRT12",
[SIGRTMIN + 13] = "SIGRT13",
[SIGRTMIN + 14] = "SIGRT14",
[SIGRTMIN + 15] = "SIGRT15",
[SIGRTMIN + 16] = "SIGRT16",
[SIGRTMIN + 17] = "SIGRT17",
[SIGRTMIN + 18] = "SIGRT18",
[SIGRTMIN + 19] = "SIGRT19",
[SIGRTMIN + 20] = "SIGRT20",
[SIGRTMIN + 21] = "SIGRT21",
[SIGRTMIN + 22] = "SIGRT22",
[SIGRTMIN + 23] = "SIGRT23",
[SIGRTMIN + 24] = "SIGRT24",
[SIGRTMIN + 25] = "SIGRT25",
[SIGRTMIN + 26] = "SIGRT26",
[SIGRTMIN + 27] = "SIGRT27",
[SIGRTMIN + 28] = "SIGRT28",
[SIGRTMIN + 29] = "SIGRT29",
[SIGRTMIN + 30] = "SIGRT30",
[SIGRTMIN + 31] = "SIGRT31",
[SIGRTMIN + 32] = "SIGRT32",
[SIGRTMIN + 33] = "SIGRT33",
[SIGRTMIN + 34] = "SIGRT34",
[SIGRTMIN + 35] = "SIGRT35",
[SIGRTMIN + 36] = "SIGRT36",
[SIGRTMIN + 37] = "SIGRT37",
[SIGRTMIN + 38] = "SIGRT38",
[SIGRTMIN + 39] = "SIGRT39",
[SIGRTMIN + 40] = "SIGRT40",
[SIGRTMIN + 41] = "SIGRT41",
[SIGRTMIN + 42] = "SIGRT42",
[SIGRTMIN + 43] = "SIGRT43",
[SIGRTMIN + 44] = "SIGRT44",
[SIGRTMIN + 45] = "SIGRT45",
[SIGRTMIN + 46] = "SIGRT46",
[SIGRTMIN + 47] = "SIGRT47",
[SIGRTMIN + 48] = "SIGRT48",
[SIGRTMIN + 49] = "SIGRT49",
[SIGRTMIN + 50] = "SIGRT50",
[SIGRTMIN + 51] = "SIGRT51",
[SIGRTMIN + 52] = "SIGRT52",
[SIGRTMIN + 53] = "SIGRT53",
[SIGRTMIN + 54] = "SIGRT54",
[SIGRTMIN + 55] = "SIGRT55",
[SIGRTMIN + 56] = "SIGRT56",
[SIGRTMIN + 57] = "SIGRT57",
[SIGRTMIN + 58] = "SIGRT58",
[SIGRTMIN + 59] = "SIGRT59",
[SIGRTMIN + 60] = "SIGRT60",
[SIGRTMIN + 61] = "SIGRT61",
};
const char *
sysdecode_signal(int sig)
{
if ((unsigned)sig < nitems(signames))
return (signames[sig]);
return (NULL);
}

View File

@ -35,6 +35,9 @@ __FBSDID("$FreeBSD$");
*/
#include <sys/param.h>
#include <sys/acl.h>
#include <sys/wait.h>
#include <stdbool.h>
#include <stdio.h>
#include <sysdecode.h>

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 29, 2016
.Dd October 17, 2016
.Dt SYSDECODE 3
.Os
.Sh NAME
@ -33,6 +33,10 @@
.Nd system argument decoding library
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Sh DESCRIPTION
The
.Nm
@ -65,7 +69,14 @@ A placeholder for use when the ABI is not known.
.El
.Sh SEE ALSO
.Xr sysdecode_abi_to_freebsd_errno 3 ,
.Xr sysdecode_cap_rights 3 ,
.Xr sysdecode_enum 3 ,
.Xr sysdecode_fcntl_arg 3 ,
.Xr sysdecode_ioctlname 3 ,
.Xr sysdecode_mask 3 ,
.Xr sysdecode_quotactl_cmd 3 ,
.Xr sysdecode_sigcode 3 ,
.Xr sysdecode_sockopt_name 3 ,
.Xr sysdecode_syscallnames 3 ,
.Xr sysdecode_utrace 3
.Sh HISTORY

View File

@ -39,9 +39,79 @@ enum sysdecode_abi {
};
int sysdecode_abi_to_freebsd_errno(enum sysdecode_abi _abi, int _error);
bool sysdecode_access_mode(FILE *_fp, int _mode, int *_rem);
const char *sysdecode_acltype(int _type);
const char *sysdecode_atfd(int _fd);
bool sysdecode_cap_fcntlrights(FILE *_fp, uint32_t _rights, uint32_t *_rem);
void sysdecode_cap_rights(FILE *_fp, cap_rights_t *_rightsp);
const char *sysdecode_extattrnamespace(int _namespace);
const char *sysdecode_fadvice(int _advice);
void sysdecode_fcntl_arg(FILE *_fp, int _cmd, uintptr_t _arg, int _base);
bool sysdecode_fcntl_arg_p(int _cmd);
const char *sysdecode_fcntl_cmd(int _cmd);
bool sysdecode_fcntl_fileflags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_fileflags(FILE *_fp, fflags_t _flags, fflags_t *_rem);
bool sysdecode_filemode(FILE *_fp, int _mode, int *_rem);
bool sysdecode_flock_operation(FILE *_fp, int _operation, int *_rem);
int sysdecode_freebsd_to_abi_errno(enum sysdecode_abi _abi, int _error);
bool sysdecode_getfsstat_flags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_idtype(int _idtype);
const char *sysdecode_ioctlname(unsigned long _val);
const char *sysdecode_ipproto(int _protocol);
const char *sysdecode_kldsym_cmd(int _cmd);
const char *sysdecode_kldunload_flags(int _flags);
const char *sysdecode_lio_listio_mode(int _mode);
const char *sysdecode_madvice(int _advice);
const char *sysdecode_minherit_inherit(int _inherit);
const char *sysdecode_msgctl_cmd(int _cmd);
bool sysdecode_mlockall_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_mmap_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_mmap_prot(FILE *_fp, int _prot, int *_rem);
bool sysdecode_mount_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_msg_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_msync_flags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_nfssvc_flags(int _flags);
bool sysdecode_open_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_pipe2_flags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_prio_which(int _which);
const char *sysdecode_procctl_cmd(int _cmd);
const char *sysdecode_ptrace_request(int _request);
bool sysdecode_quotactl_cmd(FILE *_fp, int _cmd);
bool sysdecode_reboot_howto(FILE *_fp, int _howto, int *_rem);
bool sysdecode_rfork_flags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_rlimit(int _resource);
const char *sysdecode_rtprio_function(int _function);
const char *sysdecode_scheduler_policy(int _policy);
const char *sysdecode_semctl_cmd(int _cmd);
bool sysdecode_semget_flags(FILE *_fp, int _flag, int *_rem);
bool sysdecode_sendfile_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_shmat_flags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_shmctl_cmd(int _cmd);
const char *sysdecode_shutdown_how(int _how);
const char *sysdecode_sigbus_code(int _si_code);
const char *sysdecode_sigchld_code(int _si_code);
const char *sysdecode_sigcode(int _sig, int _si_code);
const char *sysdecode_sigfpe_code(int _si_code);
const char *sysdecode_sigill_code(int _si_code);
const char *sysdecode_signal(int _sig);
const char *sysdecode_sigprocmask_how(int _how);
const char *sysdecode_sigsegv_code(int _si_code);
const char *sysdecode_sigtrap_code(int _si_code);
const char *sysdecode_sockaddr_family(int _sa_family);
const char *sysdecode_socketdomain(int _domain);
bool sysdecode_socket_type(FILE *_fp, int _type, int *_rem);
const char *sysdecode_sockopt_level(int _level);
const char *sysdecode_sockopt_name(int _level, int _optname);
const char *sysdecode_syscallname(enum sysdecode_abi _abi, unsigned int _code);
bool sysdecode_thr_create_flags(FILE *_fp, int _flags, int *_rem);
bool sysdecode_umtx_cvwait_flags(FILE *_fp, u_long _flags, u_long *_rem);
const char *sysdecode_umtx_op(int _op);
bool sysdecode_umtx_rwlock_flags(FILE *_fp, u_long _flags, u_long *_rem);
int sysdecode_utrace(FILE *_fp, void *_buf, size_t _len);
bool sysdecode_vmprot(FILE *_fp, int _type, int *_rem);
const char *sysdecode_vmresult(int _result);
bool sysdecode_wait4_options(FILE *_fp, int _options, int *_rem);
bool sysdecode_wait6_options(FILE *_fp, int _options, int *_rem);
const char *sysdecode_whence(int _whence);
#endif /* !__SYSDECODE_H__ */

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 23, 2016
.Dd October 17, 2016
.Dt sysdecode_abi_to_freebsd_errno 3
.Os
.Sh NAME
@ -35,6 +35,9 @@
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft int
.Fn sysdecode_abi_to_freebsd_errno "enum sysdecode_abi abi" "int error"
.Ft int

View File

@ -0,0 +1,50 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_cap_rights 3
.Os
.Sh NAME
.Nm sysdecode_cap_rights
.Nd output list of capability rights
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft void
.Fn sysdecode_cap_rights "FILE *fp" "cap_rights_t *rightsp"
.Sh DESCRIPTION
The
.Fn sysdecode_cap_rights
function outputs a comma-separated list of capability rights at
.Fa rightsp
to the stream
.Fa fp .
.Sh SEE ALSO
.Xr sysdecode 3

View File

@ -0,0 +1,235 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_enum 3
.Os
.Sh NAME
.Nm sysdecode_enum ,
.Nm sysdecode_acltype ,
.Nm sysdecode_atfd ,
.Nm sysdecode_extattrnamespace ,
.Nm sysdecode_fadvice ,
.Nm sysdecode_fcntl_cmd ,
.Nm sysdecode_idtype ,
.Nm sysdecode_ipproto ,
.Nm sysdecode_kldsym_cmd ,
.Nm sysdecode_kldunload_flags ,
.Nm sysdecode_lio_listio_mode ,
.Nm sysdecode_madvice ,
.Nm sysdecode_minherit_flags ,
.Nm sysdecode_msgctl_cmd ,
.Nm sysdecode_nfssvc_flags ,
.Nm sysdecode_prio_which ,
.Nm sysdecode_procctl_cmd ,
.Nm sysdecode_ptrace_request ,
.Nm sysdecode_rlimit ,
.Nm sysdecode_rtprio_function ,
.Nm sysdecode_scheduler_policy ,
.Nm sysdecode_semctl_cmd ,
.Nm sysdecode_shmctl_cmd ,
.Nm sysdecode_shutdown_how ,
.Nm sysdecode_sigbus_code ,
.Nm sysdecode_sigchld_code ,
.Nm sysdecode_sigfpe_code ,
.Nm sysdecode_sigill_code ,
.Nm sysdecode_signal ,
.Nm sysdecode_sigprocmask_how ,
.Nm sysdecode_sigsegv_code ,
.Nm sysdecode_sigtrap_code ,
.Nm sysdecode_sockaddr_family ,
.Nm sysdecode_socketdomain ,
.Nm sysdecode_sockettype ,
.Nm sysdecode_sockopt_level ,
.Nm sysdecode_umtx_op ,
.Nm sysdecode_vmresult ,
.Nm sysdecode_whence
.Nd lookup name of various enumerated values
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft const char *
.Fn sysdecode_acltype "int type"
.Ft const char *
.Fn sysdecode_atfd "int fd"
.Ft const char *
.Fn sysdecode_extattrnamespace "int namespace"
.Ft const char *
.Fn sysdecode_fadvice "int advice"
.Ft const char *
.Fn sysdecode_fcntl_cmd "int cmd"
.Ft const char *
.Fn sysdecode_idtype "int idtype"
.Ft const char *
.Fn sysdecode_ipproto "int protocol"
.Ft const char *
.Fn sysdecode_kldsym_cmd "int cmd"
.Ft const char *
.Fn sysdecode_kldunload_flags "int flags"
.Ft const char *
.Fn sysdecode_lio_listio_mode "int mode"
.Ft const char *
.Fn sysdecode_madvice "int advice"
.Ft const char *
.Fn sysdecode_minherit_flags "int inherit"
.Ft const char *
.Fn sysdecode_msgctl_cmd "int cmd"
.Ft const char *
.Fn sysdecode_nfssvc_flags "int flags"
.Ft const char *
.Fn sysdecode_prio_which "int which"
.Ft const char *
.Fn sysdecode_procctl_cmd "int cmd"
.Ft const char *
.Fn sysdecode_ptrace_request "int request"
.Ft const char *
.Fn sysdecode_rlimit "int resource"
.Ft const char *
.Fn sysdecode_rtprio_function "int function"
.Ft const char *
.Fn sysdecode_scheduler_policy "int policy"
.Ft const char *
.Fn sysdecode_semctl_cmd "int cmd"
.Ft const char *
.Fn sysdecode_shmctl_cmd "int cmd"
.Ft const char *
.Fn sysdecode_shutdown_how "int how"
.Ft const char *
.Fn sysdecode_sigbus_code "int si_code"
.Ft const char *
.Fn sysdecode_sigchld_code "int si_code"
.Ft const char *
.Fn sysdecode_sigfpe_code "int si_code"
.Ft const char *
.Fn sysdecode_sigill_code "int si_code"
.Ft const char *
.Fn sysdecode_signal "int sig"
.Ft const char *
.Fn sysdecode_sigprocmask_how "int how"
.Ft const char *
.Fn sysdecode_sigsegv_code "int si_code"
.Ft const char *
.Fn sysdecode_sigtrap_code "int si_code"
.Ft const char *
.Fn sysdecode_sockaddr_family "int sa_family"
.Ft const char *
.Fn sysdecode_socketdomain "int domain"
.Ft const char *
.Fn sysdecode_sockettype "int type"
.Ft const char *
.Fn sysdecode_sockopt_level "int level"
.Ft const char *
.Fn sysdecode_umtx_op "int op"
.Ft const char *
.Fn sysdecode_vmresult "int result"
.Ft const char *
.Fn sysdecode_whence "int whence"
.Sh DESCRIPTION
The
.Nm
functions return a text description of an integer value.
The text description matches the name of a C macro with the same value as the
sole function argument.
.Dv NULL
is returned if there is no matching C macro name.
.Pp
Most of these functions decode an argument passed to a system call:
.Bl -column "Fn sysdecode_extattrnamespace" "Xr sched_setscheduler 2"
.It Sy Function Ta Sy System Call Ta Sy Argument
.It Fn sysdecode_acltype Ta Xr acl_get_file 3 Ta Fa type
.It Fn sysdecode_atfd Ta Xr openat 2 Ta Fa fd
.It Fn sysdecode_extattrnamespace Ta Xr extattr_get_fd 2 Ta Fa attrnamespace
.It Fn sysdecode_fadvice Ta Xr posix_fadvise 2 Ta Fa advice
.It Fn sysdecode_fcntl_cmd Ta Xr fcntl 2 Ta Fa cmd
.It Fn sysdecode_idtype Ta
.Xr procctl 2 ,
.Xr waitid 2
.Ta Fa idtype
.It Fn sysdecode_kldsym_cmd Ta Xr kldsym 2 Ta Fa cmd
.It Fn sysdecode_kldunload_flags Ta Xr kldunloadf 2 Ta Fa flags
.It Fn sysdecode_lio_listio_mode Ta Xr lio_listio 2 Ta Fa mode
.It Fn sysdecode_madvice Ta Xr madvise 2 Ta Fa advice
.It Fn sysdecode_minherit_inherit Ta Xr minherit 2 Ta Fa inherit
.It Fn sysdecode_msgctl_cmd Ta Xr msgctl 2 Ta Fa cmd
.It Fn sysdecode_nfssvc_flags Ta Xr nfssvc 2 Ta Fa flags
.It Fn sysdecode_prio_which Ta Xr getpriority 2 Ta Fa which
.It Fn sysdecode_procctl_cmd Ta Xr procctl 2 Ta Fa cmd
.It Fn sysdecode_ptrace_request Ta Xr ptrace 2 Ta Fa request
.It Fn sysdecode_rlimit Ta Xr getrlimit 2 Ta Fa resource
.It Fn sysdecode_rtprio_function Ta Xr rtprio 2 Ta Fa function
.It Fn sysdecode_scheduler_policy Ta Xr sched_setscheduler 2 Ta Fa policy
.It Fn sysdecode_semctl_cmd Ta Xr semctl 2 Ta Fa cmd
.It Fn sysdecode_shmctl_cmd Ta Xr shmctl 2 Ta Fa cmd
.It Fn sysdecode_shutdown_how Ta Xr shutdown 2 Ta Fa how
.It Fn sysdecode_sigprocmask_how Ta Xr sigprocmask 2 Ta Fa how
.It Fn sysdecode_sockopt_level Ta Xr getsockopt 2 Ta Fa level
.It Fn sysdecode_umtx_op Ta Xr _umtx_op 2 Ta Fa op
.It Fn sysdecode_whence Ta Xr lseek 2 Ta Fa whence
.El
.Pp
These functions decode signal-specific signal codes stored in the
.Fa si_code
field of the
.Vt siginfo_t
object associated with an instance of signal:
.Bl -column "Fn sysdecode_sigchld_code"
.It Sy Function Ta Sy Signal
.It Fn sysdecode_sigbus_code Ta Dv SIGBUS
.It Fn sysdecode_sigchld_code Ta Dv SIGCHLD
.It Fn sysdecode_sigfpe_code Ta Dv SIGFPE
.It Fn sysdecode_sigill_code Ta Dv SIGILL
.It Fn sysdecode_sigsegv_code Ta Dv SIGSEGV
.It Fn sysdecode_sigtrap_code Ta Dv SIGBTRAP
.El
.Pp
Other functions decode the values described below:
.Bl -tag -width "Fn sysdecode_sockaddr_family"
.It Fn sysdecode_ipproto
An IP protocol.
.It Fn sysdecode_signal
A process signal.
.It Fn sysdecode_sockaddr_family
A socket address family.
.It Fn sysdecode_socketdomain
A socket domain.
.It Fn sysdecode_vmresult
The return value of a function in the virtual memory subsystem of the kernel
indicating the status of the associated request.
.El
.Sh RETURN VALUES
The
.Nm
functions return the name of a matching C macro or
.Dv NULL
if no matching C macro was found.
.Sh SEE ALSO
.Xr sysdecode 3 ,
.Xr sysdecode_mask 3 ,
.Xr sysdecode_sigcode 3

View File

@ -0,0 +1,121 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_fcntl_arg 3
.Os
.Sh NAME
.Nm sysdecode_fcntl_arg ,
.Nm sysdecode_fcntl_arg_p
.Nd output description of fcntl argument
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft void
.Fn sysdecode_fcntl_arg "FILE *fp" "int cmd" "uintptr_t arg" "int base"
.Ft bool
.Fn sysdecode_fcntl_arg_p "int cmd"
.Sh DESCRIPTION
The
.Fn sysdecode_fcntl_arg
function outputs a text description of the optional
.Fa arg
argument to
.Xr fcntl 2
to the stream
.Fa fp .
The type and format of
.Fa arg
are determined by
.Fa cmd :
.Bl -column ".Dv F_SETLKW" "Vt struct flock *"
.It Sy Command Ta Fa arg Sy Type Ta Sy Output Format
.It
.It Dv F_SETFD Ta Vt int Ta
.Dq FD_CLOEXEC
or the value of
.Fa arg
in the indicated
.Fa base
.Pq one of 8, 10, or 16 .
.It
.It Dv F_SETFL Ta Vt int Ta
File flags as output by
.Xr sysdecode_fcntl_fileflags 3
with any unknown or remaining bits output in hexadecimal.
.It
.It Dv F_GETLK Ta Vt struct flock * Ta
.It Dv F_SETLK Ta Vt struct flock * Ta
.It Dv F_SETLKW Ta Vt struct flock * Ta
The value of
.Fa arg
using the
.Dq %p
conversion specification.
.It
.It Others Ta Vt int Ta
The value of
.Fa arg
in the indicated
.Fa base
.Pq one of 8, 10, or 16 .
.El
.Pp
The
.Fn sysdecode_fcntl_arg_p
function can be used to determine if a
.Xr fcntl 2
command uses the optional third argument to
.Xr fcntl 2 .
The function returns
.Dv true
if
.Fa cmd
accepts a third argument to
.Xr fcntl 2
and
.Dv false
if it does not.
.Sh RETURN VALUES
The
.Nm sysdecode_fcntl_arg_p
function returns
.Dv true
if
.Fa cmd
accepts a third argument to
.Xr fcntl 2
and
.Dv false
if it does not.
.Sh SEE ALSO
.Xr sysdecode 3 ,
.Xr sysdecode_fcntl_cmd 3 ,
.Xr sysdecode_fcntl_fileflags 3

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 12, 2015
.Dd October 17, 2016
.Dt sysdecode_ioctlname 3
.Os
.Sh NAME
@ -34,6 +34,9 @@
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft conts char *
.Fn sysdecode_ioctlname "unsigned long request"
.Sh DESCRIPTION

View File

@ -0,0 +1,216 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_mask 3
.Os
.Sh NAME
.Nm sysdecode_mask ,
.Nm sysdecode_accessmode ,
.Nm sysdecode_capfcntlrights ,
.Nm sysdecode_fcntl_fileflags ,
.Nm sysdecode_fileflags ,
.Nm sysdecode_filemode ,
.Nm sysdecode_flock_operation ,
.Nm sysdecode_getfsstat_flags ,
.Nm sysdecode_mlockall_flags ,
.Nm sysdecode_mmap_flags ,
.Nm sysdecode_mmap_prot ,
.Nm sysdecode_mount_flags ,
.Nm sysdecode_msg_flags ,
.Nm sysdecode_msync_flags ,
.Nm sysdecode_open_flags ,
.Nm sysdecode_pipe2_flags ,
.Nm sysdecode_reboot_howto ,
.Nm sysdecode_rfork_flags ,
.Nm sysdecode_semget_flags ,
.Nm sysdecode_sendfile_flags ,
.Nm sysdecode_shmat_flags ,
.Nm sysdecode_socket_type ,
.Nm sysdecode_thr_create_flags ,
.Nm sysdecode_umtx_cvwait_flags ,
.Nm sysdecode_umtx_rwlock_flags ,
.Nm sysdecode_vmprot ,
.Nm sysdecode_wait4_options ,
.Nm sysdecode_wait6_options
.Nd print name of various bitmask values
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft bool
.Fn sysdecode_access_mode "FILE *fp" "int mode" "int *rem"
.Ft bool
.Fn sysdecode_cap_fcntlrights "FILE *fp" "uint32_t rights" "uint32_t *rem"
.Ft bool
.Fn sysdecode_fcntl_fileflags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_fileflags "FILE *fp" "fflags_t flags" "fflags_t *rem"
.Ft bool
.Fn sysdecode_filemode "FILE *fp" "int mode" "int *rem"
.Ft bool
.Fn sysdecode_flock_operation "FILE *fp" "int operation" "int *rem"
.Ft bool
.Fn sysdecode_mlockall_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_mmap_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_mmap_prot "FILE *fp" "int prot" "int *rem"
.Ft bool
.Fn sysdecode_mount_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_msg_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_msync_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_open_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_pipe2_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_reboot_howto "FILE *fp" "int howto" "int *rem"
.Ft bool
.Fn sysdecode_rfork_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_semget_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_sendfile_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_shmat_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_socket_type "FILE *fp" "int type" "int *rem"
.Ft bool
.Fn sysdecode_thr_create_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
.Fn sysdecode_umtx_cvwait_flags "FILE *fp" "u_long flags" "u_long *rem"
.Ft bool
.Fn sysdecode_umtx_rwlock_flags "FILE *fp" "u_long flags" "u_long *rem"
.Ft bool
.Fn sysdecode_vmprot "FILE *fp" "int type" "int *rem"
.Ft bool
.Fn sysdecode_wait4_options "FILE *fp" "int options" "int *rem"
.Ft bool
.Fn sysdecode_wait6_options "FILE *fp" "int options" "int *rem"
.Sh DESCRIPTION
The
.Nm
functions are used to generate a text description of an integer value
built from a mask of bitfields.
The text description lists the C macros for field values joined by pipe
.Sq |
characters matching the format used in C source code.
Most of the values decoded by these functions are passed as arguments to
system calls,
though some of these values are used internally in the kernel.
.Pp
Each function writes the text description to
.Fa fp .
The second argument should contain the integer value to be decoded.
The
.Fa rem
argument is set to the value of any bits that were not decoded
.Pq bit fields that do not have a corresponding C macro .
.Fa rem
may be set to
.Dv NULL
if the caller does not need this value.
Each function returns
.Dv true
if any bit fields in the value were decoded and
.Dv false
if no bit fields were decoded.
.Pp
Most of these functions decode an argument passed to a system call:
.Bl -column "Fn sysdecode_flock_operation" "Xr cap_fcntls_limit 2"
.It Sy Function Ta Sy System Call Ta Sy Argument
.It Fn sysdecode_access_mode Ta Xr access 2 Ta Fa mode
.It Fn sysdecode_cap_fcntlrights Ta Xr cap_fcntls_limit 2 Ta Fa fcntlrights
.It Fn sysdecode_fileflags Ta Xr chflags 2 Ta Fa flags
.It Fn sysdecode_filemode Ta Xr chmod 2 , Xr open 2 Ta mode
.It Fn sysdecode_flock_operation Ta Xr flock 2 Ta Fa operation
.It Fn sysdecode_getfsstat_flags Ta Xr getfsstatflags 2 Ta Fa flags
.It Fn sysdecode_mlockall_flags Ta Xr mlockall 2 Ta Fa flags
.It Fn sysdecode_mmap_flags Ta Xr mmap 2 Ta Fa flags
.It Fn sysdecode_mmap_prot Ta Xr mmap 2 Ta Fa prot
.It Fn sysdecode_mount_flags Ta Xr mount 2 Ta Fa flags
.It Fn sysdecode_msg_flags Ta Xr recv 2 , Xr send 2 Ta Fa flags
.It Fn sysdecode_msync_flags Ta Xr msync 2 Ta Fa flags
.It Fn sysdecode_open_flags Ta Xr open 2 Ta Fa flags
.It Fn sysdecode_pipe2_flags Ta Xr pipe2 Ta Fa flags
.It Fn sysdecode_reboot_howto Ta Xr reboot 2 Ta Fa howto
.It Fn sysdecode_rfork_flags Ta Xr rfork 2 Ta Fa flags
.It Fn sysdecode_semget_flags Ta Xr semget 2 Ta Fa flags
.It Fn sysdecode_sendfile_flags Ta Xr sendfile 2 Ta Fa flags
.It Fn sysdecode_shmat_flags Ta Xr shmat 2 Ta Fa flags
.It Fn sysdecode_socket_type Ta Xr socket 2 Ta Fa type
.It Fn sysdecode_thr_create_flags Ta Xr thr_create 2 Ta Fa flags
.It Fn sysdecode_wait4_options Ta Xr wait4 2 Ta Fa options
.It Fn sysdecode_wait6_options Ta Xr wait6 2 Ta Fa options
.El
.Pp
Other functions decode the values described below:
.Bl -tag -width ".Fn sysdecode_umtx_cvwait_flags"
.It Fn sysdecode_fcntl_fileflags
The file flags used with the
.Dv F_GETFL
and
.Dv F_SETFL
.Xr fcntl 2
commands.
.It Fn sysdecode_umtx_cvwait_flags
The
.Fa val
argument to
.Xr _umtx_op 2
for
.Dv UMTX_OP_CV_WAIT
operations.
.It Fn sysdecode_umtx_rwlock_flags
The
.Fa val
argument to
.Xr _umtx_op 2
for
.Dv UMTX_OP_RW_RDLOCK
operations.
.It Fn sysdecode_vmprot
The memory protection flags stored in
.Vt vm_prot_t
variables.
.El
.Sh RETURN VALUES
The
.Nm
functions return
.Dv true
if any bit fields in the value were decoded and
.Dv false
if no bit fields were decoded.
.Sh SEE ALSO
.Xr sysdecode 3 ,
.Xr sysdecode_enum 3

View File

@ -0,0 +1,93 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_quotactl_cmd 3
.Os
.Sh NAME
.Nm sysdecode_quotactl_cmd
.Nd output name of quotactl command
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft bool
.Fn sysdecode_quotactl_cmd "FILE *fp" "int cmd"
.Sh DESCRIPTION
The
.Fn sysdecode_quotactl_cmd
function outputs a text description of the
.Fa cmd
argument to
.Xr quotactl 2
to the stream
.Fa fp .
The description is formatted as an invocation of the
.Dv QCMD
macro defined in the
.In ufs/ufs/quota.h
header.
.Pp
The function first computes the primary and secondary values used by
.Dv QCMD
to construct
.Fa cmd .
If the primary command value does not represent a known constant,
.Fn sysdecode_quotactl_cmd
does not generate any output and returns
.Dv false .
Otherwise,
.Fn sysdecode_quotactl_cmd
outputs text depicting an invocation of
.Dv QCMD
with the associated constants for the primary and secondary command values
and returns
.Dv true .
If the secondary command values does not represent a known constant,
its value is output as a hexadecimal integer.
.Sh RETURN VALUES
The
.Nm sysdecode_quotactl_cmd
function returns
.Dv true
if it outputs a description of
.Fa cmd
and
.Dv false
if it does not.
.Sh EXAMPLES
The statement
.Pp
.Dl sysdecode_quotatcl_cmd(stdout, QCMD(Q_GETQUOTA, USRQUOTA);
.Pp
outputs the text
.Dq QCMD(Q_GETQUOTA, USRQUOTA)
to standard output.
.Sh SEE ALSO
.Xr sysdecode 3

View File

@ -0,0 +1,83 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_sigcode 3
.Os
.Sh NAME
.Nm sysdecode_sigcode
.Nd lookup name of signal code
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft const char *
.Fn sysdecode_sigcode "int signal" "int si_code"
.Sh DESCRIPTION
The
.Fn sysdecode_sigcode
function returns a text description of the
.Fa si_code
field of the
.Vt siginfo_t
object associated with an instance of signal
.Fa sig .
The text description contains the name of the C macro whose value matches
.Fa si_code .
General purpose signal codes such as
.Dv SI_USER
are handled as well as signal-specific codes for
.Dv SIGBUS ,
.Dv SIGCHLD ,
.Dv SIGFPE ,
.Dv SIGILL ,
.Dv SIGSEGV
and
.Dv SIGTRAP .
If
.Fa si_code
does not represent a known signal code,
.Fn sysdecode_sigcode
returns
.Dv NULL .
.Sh RETURN VALUES
The
.Fn sysdecode_sigcode
function returns a pointer to a signal code description or
.Dv NULL
if
.Fa si_code
is not a known signal code.
.Sh SEE ALSO
.Xr sysdecode_sigbus_code 3 ,
.Xr sysdecode_sigchld_code 3 ,
.Xr sysdecode_sigfpe_code 3 ,
.Xr sysdecode_sigill_code 3 ,
.Xr sysdecode_sigsegv_code 3 ,
.Xr sysdecode_sigtrap_code 3

View File

@ -0,0 +1,61 @@
.\"
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
.\" 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 October 17, 2016
.Dt sysdecode_sockopt_name 3
.Os
.Sh NAME
.Nm sysdecode_sockopt_name
.Nd lookup name of socket option
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft const char *
.Fn sysdecode_sockopt_name "int level" "int optname"
.Sh DESCRIPTION
The
.Fn sysdecode_sockopt_name
function returns a text description of the socket option name passed in the
.Fa optname
argument to
.Xr getsockopt 2 .
.Fn sysdecode_sockopt_name
takes the socket option
.Fa level
as well as the option name to uniquely identify the option.
.Sh SEE ALSO
.Xr sysdecode_sockopt_level 3
.Sh BUGS
Socket option levels and names are protocol-specific.
Both
.Fn sysdecode_sockopt_level
and
.Fn sysdecode_sockopt_name
should possibly accept the protocol family as an additional argument.

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 30, 2016
.Dd October 17, 2016
.Dt sysdecode_syscallnames 3
.Os
.Sh NAME
@ -34,6 +34,9 @@
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft const char *
.Fn sysdecode_syscallnames "enum sysdecode_abi abi" "unsigned int code"
.Sh DESCRIPTION

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd December 11, 2015
.Dd October 17, 2016
.Dt sysdecode_utrace 3
.Os
.Sh NAME
@ -34,6 +34,9 @@
.Sh LIBRARY
.Lb libsysdecode
.Sh SYNOPSIS
.In sys/types.h
.In stdbool.h
.In sysdecode.h
.Ft int
.Fn sysdecode_utrace "FILE *fp" "void *buf" "size_t len" "int decimal"
.Sh DESCRIPTION

View File

@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <dlfcn.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sysdecode.h>

View File

@ -43,8 +43,8 @@ __FBSDID("$FreeBSD$");
extern bool_t xdr_ypresp_all_seq(XDR *, unsigned long *);
static int (*ypresp_allfn)();
static void *ypresp_data;
extern int (*ypresp_allfn)();
extern void *ypresp_data;
extern DB *specdbp;
extern enum ypstat yp_errno;

View File

@ -1013,8 +1013,6 @@
&hwlist.urtw;
&hwlist.urtwn;
<para>[&arch.amd64;, &arch.i386;, &arch.pc98;] Lucent
Technologies WaveLAN/IEEE 802.11b wireless network adapters
and workalikes using the Lucent Hermes, Intersil PRISM-II,

View File

@ -3139,6 +3139,8 @@ rescan_or_reset_bus(path_id_t bus, int rescan)
return(1);
}
bzero(&ccb, sizeof(ccb));
if (bus != CAM_BUS_WILDCARD) {
ccb.ccb_h.func_code = rescan ? XPT_SCAN_BUS : XPT_RESET_BUS;
ccb.ccb_h.path_id = bus;
@ -3181,7 +3183,7 @@ rescan_or_reset_bus(path_id_t bus, int rescan)
* no-op, sending a rescan to the xpt bus would result in a status of
* CAM_REQ_INVALID.
*/
CCB_CLEAR_ALL_EXCEPT_HDR(&matchccb.cdm);
bzero(&matchccb, sizeof(matchccb));
matchccb.ccb_h.func_code = XPT_DEV_MATCH;
matchccb.ccb_h.path_id = CAM_BUS_WILDCARD;
bufsize = sizeof(struct dev_match_result) * 20;

View File

@ -1,7 +1,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 21, 2016
.Dd October 18, 2016
.Dt IPFW 8
.Os
.Sh NAME
@ -1357,6 +1357,24 @@ or a hostname)
and mask width of
.Cm masklen
bits.
.It Ar addr Ns / Ns Ar mask
Matches all IPv6 addresses with base
.Ar addr
(specified as allowed by
.Xr inet_pton
or a hostname)
and the mask of
.Ar mask ,
specified as allowed by
.Xr inet_pton.
As an example, fe::640:0:0/ffff::ffff:ffff:0:0 will match
fe:*:*:*:0:640:*:*.
This form is advised only for non-contiguous
masks.
It is better to resort to the
.Ar addr Ns / Ns Ar masklen
format for contiguous masks, which is more compact and less
error-prone.
.El
.Pp
No support for sets of IPv6 addresses is provided because IPv6 addresses

View File

@ -124,8 +124,8 @@ print_ip6(struct buf_pr *bp, ipfw_insn_ip6 *cmd, char const *s)
if (inet_ntop(AF_INET6, a, trad, sizeof( trad ) ) == NULL)
bprintf(bp, "Error ntop in print_ip6\n");
bprintf(bp, "%s", trad );
if (mb < 0) /* XXX not really legal... */
bprintf(bp, ":%s",
if (mb < 0) /* mask not contiguous */
bprintf(bp, "/%s",
inet_ntop(AF_INET6, &a[1], trad, sizeof(trad)));
else if (mb < 128)
bprintf(bp, "/%d", mb);
@ -325,9 +325,10 @@ lookup_host6 (char *host, struct in6_addr *ip6addr)
* any matches any IP6. Actually returns an empty instruction.
* me returns O_IP6_*_ME
*
* 03f1::234:123:0342 single IP6 address
* 03f1::234:123:0342/24 address/mask
* 03f1::234:123:0342/24,03f1::234:123:0343/ List of address
* 03f1::234:123:0342 single IP6 address
* 03f1::234:123:0342/24 address/masklen
* 03f1::234:123:0342/ffff::ffff:ffff address/mask
* 03f1::234:123:0342/24,03f1::234:123:0343/ List of address
*
* Set of address (as in ipv6) not supported because ipv6 address
* are typically random past the initial prefix.
@ -382,13 +383,18 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av, int cblen)
* or ',' indicating another address follows.
*/
char *p;
char *p, *q;
int masklen;
char md = '\0';
CHECK_LENGTH(cblen, 1 + len + 2 * F_INSN_SIZE(struct in6_addr));
if ((p = strpbrk(av, "/,")) ) {
if ((q = strchr(av, ',')) ) {
*q = '\0';
q++;
}
if ((p = strchr(av, '/')) ) {
md = *p; /* save the separator */
*p = '\0'; /* terminate address string */
p++; /* and skip past it */
@ -401,22 +407,22 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av, int cblen)
errx(EX_DATAERR, "bad address \"%s\"", av);
}
/* next, look at the mask, if any */
masklen = (md == '/') ? atoi(p) : 128;
if (masklen > 128 || masklen < 0)
errx(EX_DATAERR, "bad width \"%s\''", p);
else
n2mask(&d[1], masklen);
if (md == '/' && strchr(p, ':')) {
if (!inet_pton(AF_INET6, p, &d[1]))
errx(EX_DATAERR, "bad mask \"%s\"", p);
masklen = contigmask((uint8_t *)&(d[1]), 128);
} else {
masklen = (md == '/') ? atoi(p) : 128;
if (masklen > 128 || masklen < 0)
errx(EX_DATAERR, "bad width \"%s\''", p);
else
n2mask(&d[1], masklen);
}
APPLY_MASK(d, &d[1]) /* mask base address with mask */
/* find next separator */
if (md == '/') { /* find separator past the mask */
p = strpbrk(p, ",");
if (p != NULL)
p++;
}
av = p;
av = q;
/* Check this entry */
if (masklen == 0) {

View File

@ -21,8 +21,10 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/capsicum.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <capsicum_helpers.h>
#include <err.h>
#include <md5.h>
#include <ripemd.h>
@ -74,7 +76,7 @@ typedef struct Algorithm_t {
DIGEST_Update *Update;
DIGEST_End *End;
char *(*Data)(const void *, unsigned int, char *);
char *(*File)(const char *, char *);
char *(*Fd)(int, char *);
} Algorithm_t;
static void MD5_Update(MD5_CTX *, const unsigned char *, size_t);
@ -106,34 +108,34 @@ typedef union {
static const struct Algorithm_t Algorithm[] = {
{ "md5", "MD5", &MD5TestOutput, (DIGEST_Init*)&MD5Init,
(DIGEST_Update*)&MD5_Update, (DIGEST_End*)&MD5End,
&MD5Data, &MD5File },
&MD5Data, &MD5Fd },
{ "sha1", "SHA1", &SHA1_TestOutput, (DIGEST_Init*)&SHA1_Init,
(DIGEST_Update*)&SHA1_Update, (DIGEST_End*)&SHA1_End,
&SHA1_Data, &SHA1_File },
&SHA1_Data, &SHA1_Fd },
{ "sha256", "SHA256", &SHA256_TestOutput, (DIGEST_Init*)&SHA256_Init,
(DIGEST_Update*)&SHA256_Update, (DIGEST_End*)&SHA256_End,
&SHA256_Data, &SHA256_File },
&SHA256_Data, &SHA256_Fd },
{ "sha384", "SHA384", &SHA384_TestOutput, (DIGEST_Init*)&SHA384_Init,
(DIGEST_Update*)&SHA384_Update, (DIGEST_End*)&SHA384_End,
&SHA384_Data, &SHA384_File },
&SHA384_Data, &SHA384_Fd },
{ "sha512", "SHA512", &SHA512_TestOutput, (DIGEST_Init*)&SHA512_Init,
(DIGEST_Update*)&SHA512_Update, (DIGEST_End*)&SHA512_End,
&SHA512_Data, &SHA512_File },
&SHA512_Data, &SHA512_Fd },
{ "sha512t256", "SHA512t256", &SHA512t256_TestOutput, (DIGEST_Init*)&SHA512_256_Init,
(DIGEST_Update*)&SHA512_256_Update, (DIGEST_End*)&SHA512_256_End,
&SHA512_256_Data, &SHA512_256_File },
&SHA512_256_Data, &SHA512_256_Fd },
{ "rmd160", "RMD160", &RIPEMD160_TestOutput,
(DIGEST_Init*)&RIPEMD160_Init, (DIGEST_Update*)&RIPEMD160_Update,
(DIGEST_End*)&RIPEMD160_End, &RIPEMD160_Data, &RIPEMD160_File },
(DIGEST_End*)&RIPEMD160_End, &RIPEMD160_Data, &RIPEMD160_Fd },
{ "skein256", "Skein256", &SKEIN256_TestOutput,
(DIGEST_Init*)&SKEIN256_Init, (DIGEST_Update*)&SKEIN256_Update,
(DIGEST_End*)&SKEIN256_End, &SKEIN256_Data, &SKEIN256_File },
(DIGEST_End*)&SKEIN256_End, &SKEIN256_Data, &SKEIN256_Fd },
{ "skein512", "Skein512", &SKEIN512_TestOutput,
(DIGEST_Init*)&SKEIN512_Init, (DIGEST_Update*)&SKEIN512_Update,
(DIGEST_End*)&SKEIN512_End, &SKEIN512_Data, &SKEIN512_File },
(DIGEST_End*)&SKEIN512_End, &SKEIN512_Data, &SKEIN512_Fd },
{ "skein1024", "Skein1024", &SKEIN1024_TestOutput,
(DIGEST_Init*)&SKEIN1024_Init, (DIGEST_Update*)&SKEIN1024_Update,
(DIGEST_End*)&SKEIN1024_End, &SKEIN1024_Data, &SKEIN1024_File }
(DIGEST_End*)&SKEIN1024_End, &SKEIN1024_Data, &SKEIN1024_Fd }
};
static void
@ -154,7 +156,8 @@ Arguments (may be any combination):
int
main(int argc, char *argv[])
{
int ch;
cap_rights_t rights;
int ch, fd;
char *p;
char buf[HEX_DIGEST_LENGTH];
int failed;
@ -206,10 +209,30 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if (caph_limit_stdout() < 0 || caph_limit_stderr() < 0)
err(1, "unable to limit rights for stdio");
if (*argv) {
do {
p = Algorithm[digest].File(*argv, buf);
if (!p) {
if ((fd = open(*argv, O_RDONLY)) < 0) {
warn("%s", *argv);
failed++;
continue;
}
/*
* XXX Enter capability mode on the last argv file.
* When a casper file service or other approach is
* available, switch to that and enter capability mode
* earlier.
*/
if (*(argv + 1) == NULL) {
cap_rights_init(&rights, CAP_READ);
if ((cap_rights_limit(fd, &rights) < 0 &&
errno != ENOSYS) ||
(cap_enter() < 0 && errno != ENOSYS))
err(1, "capsicum");
}
if ((p = Algorithm[digest].Fd(fd, buf)) == NULL) {
warn("%s", *argv);
failed++;
} else {
@ -229,8 +252,12 @@ main(int argc, char *argv[])
printf("\n");
}
} while (*++argv);
} else if (!sflag && (optind == 1 || qflag || rflag))
} else if (!sflag && (optind == 1 || qflag || rflag)) {
if (caph_limit_stdin() < 0 ||
(cap_enter() < 0 && errno != ENOSYS))
err(1, "capsicum");
MDFilter(&Algorithm[digest], 0);
}
if (failed != 0)
return (1);

View File

@ -1,6 +1,6 @@
# $FreeBSD$
FILES= ${.CURDIR}/../../../../sys/contrib/dev/urtwn/LICENSE
FILES= ${.CURDIR}/../../../../sys/contrib/dev/rtwn/LICENSE
FILESDIR= ${SHAREDIR}/doc/legal
FILESNAME= realtek.LICENSE

View File

@ -433,6 +433,7 @@ MAN= aac.4 \
rp.4 \
rtwn.4 \
rtwnfw.4 \
rtwn_pci.4 \
rue.4 \
rum.4 \
run.4 \
@ -692,6 +693,8 @@ MLINKS+=pms.4 pmspcv.4
MLINKS+=ral.4 if_ral.4
MLINKS+=re.4 if_re.4
MLINKS+=rl.4 if_rl.4
MLINKS+=rtwn.4 if_rtwn.4
MLINKS+=rtwn_pci.4 if_rtwn_pci.4
MLINKS+=rue.4 if_rue.4
MLINKS+=rum.4 if_rum.4
MLINKS+=run.4 if_run.4
@ -886,6 +889,7 @@ MAN+= \
otusfw.4 \
rsu.4 \
rsufw.4 \
rtwn_usb.4 \
u3g.4 \
uark.4 \
uart.4 \
@ -928,8 +932,6 @@ MAN+= \
urio.4 \
urndis.4 \
${_urtw.4} \
urtwn.4 \
urtwnfw.4 \
usb.4 \
usb_quirk.4 \
usb_template.4 \
@ -941,6 +943,7 @@ MAN+= \
MLINKS+=otus.4 if_otus.4
MLINKS+=rsu.4 if_rsu.4
MLINKS+=rtwn_usb.4 if_rtwn_usb.4
MLINKS+=u3g.4 u3gstub.4
MLINKS+=uath.4 if_uath.4
MLINKS+=udav.4 if_udav.4
@ -948,7 +951,6 @@ MLINKS+=upgt.4 if_upgt.4
MLINKS+=ural.4 if_ural.4
MLINKS+=urndis.4 if_urndis.4
MLINKS+=${_urtw.4} ${_if_urtw.4}
MLINKS+=urtwn.4 if_urtwn.4
.endif
.include <bsd.prog.mk>

View File

@ -49,7 +49,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 15, 2010
.Dd October 21, 2016
.Dt BPF 4
.Os
.Sh NAME
@ -881,16 +881,20 @@ BPF_ALU+BPF_ADD+BPF_K A <- A + k
BPF_ALU+BPF_SUB+BPF_K A <- A - k
BPF_ALU+BPF_MUL+BPF_K A <- A * k
BPF_ALU+BPF_DIV+BPF_K A <- A / k
BPF_ALU+BPF_MOD+BPF_K A <- A % k
BPF_ALU+BPF_AND+BPF_K A <- A & k
BPF_ALU+BPF_OR+BPF_K A <- A | k
BPF_ALU+BPF_XOR+BPF_K A <- A ^ k
BPF_ALU+BPF_LSH+BPF_K A <- A << k
BPF_ALU+BPF_RSH+BPF_K A <- A >> k
BPF_ALU+BPF_ADD+BPF_X A <- A + X
BPF_ALU+BPF_SUB+BPF_X A <- A - X
BPF_ALU+BPF_MUL+BPF_X A <- A * X
BPF_ALU+BPF_DIV+BPF_X A <- A / X
BPF_ALU+BPF_MOD+BPF_X A <- A % X
BPF_ALU+BPF_AND+BPF_X A <- A & X
BPF_ALU+BPF_OR+BPF_X A <- A | X
BPF_ALU+BPF_XOR+BPF_X A <- A ^ X
BPF_ALU+BPF_LSH+BPF_X A <- A << X
BPF_ALU+BPF_RSH+BPF_X A <- A >> X
BPF_ALU+BPF_NEG A <- -A

View File

@ -33,10 +33,10 @@
.Sh NAME
.Nm netmap
.Nd a framework for fast packet I/O
.Pp
.br
.Nm VALE
.Nd a fast VirtuAl Local Ethernet using the netmap API
.Pp
.br
.Nm netmap pipes
.Nd a shared memory packet transport channel
.Sh SYNOPSIS
@ -44,28 +44,49 @@
.Sh DESCRIPTION
.Nm
is a framework for extremely fast and efficient packet I/O
for both userspace and kernel clients.
for userspace and kernel clients, and for Virtual Machines.
It runs on
.Fx
and Linux, and includes
.Nm VALE ,
a very fast and modular in-kernel software switch/dataplane,
and
.Nm netmap pipes ,
a shared memory packet transport channel.
All these are accessed interchangeably with the same API.
Linux and some versions of Windows, and supports a variety of
.Nm netmap ports ,
including
.Bl -tag -width XXXX
.It Nm physical NIC ports
to access individual queues of network interfaces;
.It Nm host ports
to inject packets into the host stack;
.It Nm VALE ports
implementing a very fast and modular in-kernel software switch/dataplane;
.It Nm netmap pipes
a shared memory packet transport channel;
.It Nm netmap monitors
a mechanism similar to
.Xr bpf
to capture traffic
.El
.Pp
.Nm ,
.Nm VALE
and
.Nm netmap pipes
are at least one order of magnitude faster than
All these
.Nm netmap ports
are accessed interchangeably with the same API,
and are at least one order of magnitude faster than
standard OS mechanisms
(sockets, bpf, tun/tap interfaces, native switches, pipes),
reaching 14.88 million packets per second (Mpps)
with much less than one core on a 10 Gbit NIC,
about 20 Mpps per core for VALE ports,
and over 100 Mpps for netmap pipes.
(sockets, bpf, tun/tap interfaces, native switches, pipes).
With suitably fast hardware (NICs, PCIe buses, CPUs),
packet I/O using
.Nm
on supported NICs
reaches 14.88 million packets per second (Mpps)
with much less than one core on 10 Gbit/s NICs;
35-40 Mpps on 40 Gbit/s NICs (limited by the hardware);
about 20 Mpps per core for VALE ports;
and over 100 Mpps for
.Nm netmap pipes.
NICs without native
.Nm
support can still use the API in emulated mode,
which uses unmodified device drivers and is 3-5 times faster than
.Xr bpf
or raw sockets.
.Pp
Userspace clients can dynamically switch NICs into
.Nm
@ -73,8 +94,10 @@ mode and send and receive raw packets through
memory mapped buffers.
Similarly,
.Nm VALE
switch instances and ports, and
switch instances and ports,
.Nm netmap pipes
and
.Nm netmap monitors
can be created dynamically,
providing high speed packet I/O between processes,
virtual machines, NICs and the host stack.
@ -89,17 +112,17 @@ and standard OS mechanisms such as
.Xr epoll 2 ,
and
.Xr kqueue 2 .
.Nm VALE
and
.Nm netmap pipes
All types of
.Nm netmap ports
and the
.Nm VALE switch
are implemented by a single kernel module, which also emulates the
.Nm
API over standard drivers for devices without native
.Nm
support.
API over standard drivers.
For best performance,
.Nm
requires explicit support in device drivers.
requires native support in device drivers.
A list of such devices is at the end of this document.
.Pp
In the rest of this (long) manual page we document
various aspects of the
@ -116,7 +139,7 @@ which can be connected to a physical interface
to the host stack,
or to a
.Nm VALE
switch).
switch.
Ports use preallocated circular queues of buffers
.Em ( rings )
residing in an mmapped region.
@ -166,16 +189,18 @@ has multiple modes of operation controlled by the
.Vt struct nmreq
argument.
.Va arg.nr_name
specifies the port name, as follows:
specifies the netmap port name, as follows:
.Bl -tag -width XXXX
.It Dv OS network interface name (e.g. 'em0', 'eth1', ... )
the data path of the NIC is disconnected from the host stack,
and the file descriptor is bound to the NIC (one or all queues),
or to the host stack;
.It Dv valeXXX:YYY (arbitrary XXX and YYY)
the file descriptor is bound to port YYY of a VALE switch called XXX,
both dynamically created if necessary.
The string cannot exceed IFNAMSIZ characters, and YYY cannot
.It Dv valeSSS:PPP
the file descriptor is bound to port PPP of VALE switch SSS.
Switch instances and ports are dynamically created if necessary.
.br
Both SSS and PPP have the form [0-9a-zA-Z_]+ , the string
cannot exceed IFNAMSIZ characters, and PPP cannot
be the name of any existing OS network interface.
.El
.Pp
@ -312,9 +337,6 @@ one slot is always kept empty.
The ring size
.Va ( num_slots )
should not be assumed to be a power of two.
.br
(NOTE: older versions of netmap used head/count format to indicate
the content of a ring).
.Pp
.Va head
is the first slot available to userspace;
@ -585,6 +607,15 @@ it from the host stack.
Multiple file descriptors can be bound to the same port,
with proper synchronization left to the user.
.Pp
The recommended way to bind a file descriptor to a port is
to use function
.Va nm_open(..)
(see
.Xr LIBRARIES )
which parses names to access specific port types and
enable features.
In the following we document the main features.
.Pp
.Dv NIOCREGIF can also bind a file descriptor to one endpoint of a
.Em netmap pipe ,
consisting of two netmap ports with a crossover connection.
@ -734,7 +765,7 @@ similar to
binds a file descriptor to a port.
.Bl -tag -width XX
.It Va ifname
is a port name, in the form "netmap:XXX" for a NIC and "valeXXX:YYY" for a
is a port name, in the form "netmap:PPP" for a NIC and "valeSSS:PPP" for a
.Nm VALE
port.
.It Va req
@ -774,28 +805,39 @@ similar to pcap_next(), fetches the next packet
natively supports the following devices:
.Pp
On FreeBSD:
.Xr cxgbe 4 ,
.Xr em 4 ,
.Xr igb 4 ,
.Xr ixgbe 4 ,
.Xr ixl 4 ,
.Xr lem 4 ,
.Xr re 4 .
.Pp
On Linux
.Xr e1000 4 ,
.Xr e1000e 4 ,
.Xr i40e 4 ,
.Xr igb 4 ,
.Xr ixgbe 4 ,
.Xr mlx4 4 ,
.Xr forcedeth 4 ,
.Xr r8169 4 .
.Pp
NICs without native support can still be used in
.Nm
mode through emulation.
Performance is inferior to native netmap
mode but still significantly higher than sockets, and approaching
that of in-kernel solutions such as Linux's
.Xr pktgen .
mode but still significantly higher than various raw socket types
(bpf, PF_PACKET, etc.).
Note that for slow devices (such as 1 Gbit/s and slower NICs,
or several 10 Gbit/s NICs whose hardware is unable to sustain line rate),
emulated and native mode will likely have similar or same throughput.
.br
When emulation is in use, packet sniffer programs such as tcpdump
could see received packets before they are diverted by netmap. This behaviour
is not intentional, being just an artifact of the implementation of emulation.
Note that in case the netmap application subsequently moves packets received
from the emulated adapter onto the host RX ring, the sniffer will intercept
those packets again, since the packets are injected to the host stack as they
were received by the network interface.
.Pp
Emulation is also available for devices with native netmap support,
which can be used for testing or performance comparison.
@ -812,8 +854,12 @@ and module parameters on Linux
.Bl -tag -width indent
.It Va dev.netmap.admode: 0
Controls the use of native or emulated adapter mode.
0 uses the best available option, 1 forces native and
fails if not available, 2 forces emulated hence never fails.
.br
0 uses the best available option;
.br
1 forces native mode and fails if not available;
.br
2 forces emulated hence never fails.
.It Va dev.netmap.generic_ringsize: 1024
Ring size used for emulated netmap mode
.It Va dev.netmap.generic_mit: 100000
@ -861,9 +907,9 @@ performance.
uses
.Xr select 2 ,
.Xr poll 2 ,
.Xr epoll
.Xr epoll 2
and
.Xr kqueue
.Xr kqueue 2
to wake up processes when significant events occur, and
.Xr mmap 2
to map memory.
@ -1015,8 +1061,8 @@ e.g. running the following in two different terminals:
.Dl pkt-gen -i vale1:b -f tx # sender
The same example can be used to test netmap pipes, by simply
changing port names, e.g.
.Dl pkt-gen -i vale:x{3 -f rx # receiver on the master side
.Dl pkt-gen -i vale:x}3 -f tx # sender on the slave side
.Dl pkt-gen -i vale2:x{3 -f rx # receiver on the master side
.Dl pkt-gen -i vale2:x}3 -f tx # sender on the slave side
.Pp
The following command attaches an interface and the host stack
to a switch:

View File

@ -2,6 +2,7 @@
.\"
.\" Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
.\" Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org>
.\" Copyright (c) 2016 Andriy Voskoboinyk <avos@freebsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
@ -17,89 +18,88 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 28, 2015
.Dd October 17, 2016
.Dt RTWN 4
.Os
.Sh NAME
.Nm rtwn
.Nd Realtek RTL8188CE PCIe IEEE 802.11b/g/n wireless network device
.Nd Realtek IEEE 802.11 wireless network driver
.Sh SYNOPSIS
.Cd "options RTWN_DEBUG"
.Cd "options RTWN_WITHOUT_UCODE"
.Pp
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device rtwn"
.Cd "device rtwnfw"
.Cd "device rtwn_usb"
.Cd "device rtwn_pci"
.Cd "device wlan"
.Cd "device firmware"
.Ed
.Pp
Alternatively, to load the driver as a
module at boot time, place the following line in
module at boot time, place following lines in
.Xr loader.conf 5 :
.Bd -literal -offset indent
if_rtwn_load="YES"
.Ed
.Pp
After you have read the license in
.Pa /usr/share/doc/legal/realtek.LICENSE
you will want to add the following lines to
.Xr loader.conf 5 :
.Bd -literal -offset indent
legal.realtek.license_ack=1
rtwn-rtl8192cfwU_load="YES"
rtwn-rtl8192cfwU_B_load="YES"
if_rtwn_pci_load="YES"
if_rtwn_usb_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver supports PCIe wireless network devices based on the Realtek
RTL8188CE chipset.
driver provides support for wireless network devices based on
the Realtek RTL8192C, RTL8188E, RTL8812A and RTL8821A programming APIs.
These APIs are used by a wide variety of chips; most chips with USB
and some with PCI interface are supported.
.Pp
The RTL8188CE is a highly integrated 802.11n adapter that combines a MAC,
a 1T1R capable baseband and an RF in a single chip.
It operates in the 2GHz spectrum only.
To enable use for PCI/PCIe systems, see the rtwn_pci(4) driver;
for USB devices, use the rtwn_usb(4) driver.
.Pp
These are the modes the
.Nm
driver can operate in:
.Bl -tag -width "IBSS-masterXX"
.It BSS mode
Also known as
.Em infrastructure
mode, this is used when associating with an access point, through
which all traffic passes.
This mode is the default.
.It monitor mode
In this mode the driver is able to receive packets without
associating with an access point.
This disables the internal receive filter and enables the card to
capture packets from networks which it wouldn't normally have access to,
or to scan for access points.
.El
The driver supports
.Cm station ,
.Cm adhoc ,
.Cm hostap
and
.Cm monitor
mode operation.
There are no limitations for number of
.Cm monitor
mode
virtual interfaces; in addition to any other virtual interface
one
.Cm station
interface can be added (Note: RTL8821AU supports two non-monitor
mode interfaces at the same time).
.Pp
The
.Nm
driver can be configured to use
Wired Equivalent Privacy (WEP) or
Wi-Fi Protected Access (WPA-PSK and WPA2-PSK).
WPA is the current encryption standard for wireless networks.
It is strongly recommended that WEP
not be used as the sole mechanism
to secure wireless communication,
due to serious weaknesses in it.
All chips have hardware support for WEP, AES-CCM and TKIP encryption.
.Pp
The
.Nm
driver can be configured at runtime with
.Xr ifconfig 8 .
.Sh FILES
The driver needs at least version 1.0 of the following firmware files,
which are loaded when an interface is brought up:
.Bl -tag -width ".Pa /usr/share/doc/legal/realtek.LICENSE" -compact
.It Pa /usr/share/doc/legal/realtek.LICENSE
.Nm
firmware license
.El
.Pp
The driver (if not compiled with
.Cd options RTWN_WITHOUT_UCODE
) may use following firmware files, which are loaded
when an interface is brought up:
.Bl -tag -width Ds -offset indent -compact
.It Pa /boot/kernel/rtwn-rtl8188eufw.ko
.It Pa /boot/kernel/rtwn-rtl8192cfwE_B.ko
.It Pa /boot/kernel/rtwn-rtl8192cfwE.ko
.It Pa /boot/kernel/rtwn-rtl8192cfwT.ko
.It Pa /boot/kernel/rtwn-rtl8192cfwU.ko
.It Pa /boot/kernel/rtwn-rtl8192cfwU_B.ko
.It Pa /boot/kernel/rtwn-rtl8812aufw.ko
.It Pa /boot/kernel/rtwn-rtl8821aufw.ko
.El
.Sh EXAMPLES
Join an existing BSS network (i.e., connect to an access point):
@ -118,48 +118,124 @@ Join a specific BSS network with 64-bit WEP encryption:
ifconfig wlan create wlandev rtwn0 ssid my_net \e
wepmode on wepkey 0x1234567890 weptxkey 1 up
.Ed
.Pp
Create an IBSS network with 128-bit WEP encryption on the channel 4:
.Bd -literal -offset indent
ifconfig wlan create wlandev rtwn0 wlanmode adhoc ssid my_net \e
wepmode on wepkey 0x01020304050607080910111213 weptxkey 1 \e
channel 4
.Ed
.Pp
Join/create an 802.11b IBSS network with network name
.Dq Li my_net :
.Bd -literal -offset indent
ifconfig wlan0 create wlandev rtwn0 wlanmode adhoc
ifconfig wlan0 inet 192.168.0.22 netmask 0xffffff00 ssid my_net \e
mode 11b
.Ed
.Pp
Create a host-based access point:
.Bd -literal -offset indent
ifconfig wlan0 create wlandev rtwn0 wlanmode hostap
ifconfig wlan0 inet 192.168.0.10 netmask 0xffffff00 ssid my_ap
.Ed
.Sh LOADER TUNABLES
Tunables can be set at the
.Xr loader 8
prompt before booting the kernel or stored in
.Xr loader.conf 5 .
.Bl -tag -width indent
.It Va dev.rtwn.%d.hwcrypto
This tunable controls how key slots are assigned:
.br
0 - disable h/w crypto support. Features that require access
to frame contents (e.g., TCP/UDP/IP Rx checksum validation)
will not work;
.br
1 - use h/w crypto support for pairwise keys only;
.br
2 - use h/w crypto support for all keys; may not work for
multi-vap configurations.
.br
By default it is set to 1.
.It Va dev.rtwn.%d.ratectl
This tunable switches between rate control implementations:
.br
0 - no rate control;
.br
1 - driver sends 'tx complete' reports to net80211; algorithm
is controlled via net80211;
.br
2 - firmware-based rate control.
.br
By default it is set to 1; however driver may choose another
algorithm in case if it is not implemented
.br
Currently selected algorithm is reported via
.Em Va dev.rtwn.%d.ratectl_selected
read-only OID.
.El
.Sh DIAGNOSTICS
.Bl -diag
.It "could not read firmware %s"
.It "rtwn%d: could not read efuse byte at address 0x%x"
.It "rtwn%d: %s: cannot read rom, error %d"
There was an error while reading ROM; device attach will be aborted.
This should not happen.
.It "rtwn%d: failed loadfirmware of file %s"
For some reason, the driver was unable to read the microcode file from the
filesystem.
The file might be missing or corrupted.
.It "device timeout"
The driver will disable firmware-dependent features.
.It "rtwn%d: wrong firmware size (%zu)"
.It "rtwn%d: %s: failed to upload firmware %s (error %d)"
.It "rtwn%d: timeout waiting for firmware readiness"
Firmware upload failed; the file might be corrupted.
The driver will disable firmware-dependent features.
This should not happen.
.It "rtwn%d: device timeout"
A frame dispatched to the hardware for transmission did not complete in time.
The driver will reset the hardware.
This should not happen.
.El
.Sh SEE ALSO
.Xr pci 4 ,
.Xr intro 4 ,
.Xr netintro 4 ,
.Xr rtwn_pci 4 ,
.Xr rtwn_usb 4 ,
.Xr rtwnfw 4 ,
.Xr wlan 4 ,
.Xr wlan_amrr 4 ,
.Xr wlan_ccmp 4 ,
.Xr wlan_tkip 4 ,
.Xr wlan_wep 4 ,
.Xr wlan_xauth 4 ,
.Xr hostapd 4 ,
.Xr ifconfig 8 ,
.Xr wpa_supplicant 8
.Sh HISTORY
The
.Cm urtwn
driver first appeared in
.Ox 4.9
and
.Fx 10.0 ;
the
.Nm
driver first appeared in
.Ox 5.8 .
.Sh AUTHORS
The
.Nm
driver was written by
driver was initially written by
.An -nosplit
.An Stefan Sperling Aq Mt stsp@openbsd.org
and ported by
.An Kevin Lo Aq Mt kevlo@freebsd.org .
It was based on the
.Xr urtwn 4
.Cm urtwn
driver written by
.An Damien Bergamini Aq Mt damien.bergamini@free.fr .
.Sh CAVEATS
.Sh BUGS
The
.Nm
driver does not support any of the 802.11n capabilities offered by the
adapters.
Additional work is required in
.Xr ieee80211 9
before those features can be supported.
driver currently does not implement firmware-based rate control.

63
share/man/man4/rtwn_pci.4 Normal file
View File

@ -0,0 +1,63 @@
.\"-
.\" Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd
.\" Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
.\" 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$
.\"/
.Dd October 17, 2016
.Dt RTWN_PCI 4
.Os
.Sh NAME
.Nm rtwn_pci
.Nd "Realtek PCI device glue"
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device rtwn_pci"
.Cd "device pci"
.Cd "device wlan"
.Ed
.Sh DESCRIPTION
The
.Nm
driver supports PCIe wireless network devices based on the Realtek
RTL8188CE chipset.
.Pp
The RTL8188CE is a highly integrated 802.11n adapter that combines a MAC,
a 1T1R capable baseband and an RF in a single chip.
It operates in the 2GHz spectrum only.
.Sh SEE ALSO
.Xr rtwn 4 ,
.Xr rtwnfw 4 ,
.Xr rtwn_usb 4 ,
.Xr pci 4
.Sh CAVEATS
Most 802.11 capabilities were turned off; some more testing
is required to re-enable them.

111
share/man/man4/rtwn_usb.4 Normal file
View File

@ -0,0 +1,111 @@
.\"-
.\" Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd
.\" Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
.\" 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$
.\"/
.Dd October 17, 2016
.Dt RTWN_USB 4
.Os
.Sh NAME
.Nm rtwn_usb
.Nd "Realtek USB device glue"
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device xhci"
.Cd "device ehci"
.Cd "device uhci"
.Cd "device ohci"
.Cd "device usb"
.Cd "device rtwn_usb"
.Cd "device wlan"
.Ed
.Sh DESCRIPTION
This module provides the USB bus glue needed for the devices supported
by the
.Xr rtwn 4
driver.
.Sh HARDWARE
The
.Nm
driver supports Realtek RTL8188CU/RTL8188RU/RTL8188EU/RTL8192CU/RTL8812AU/RTL8821AU
based USB wireless network adapters, including:
.Pp
.Bl -column -compact "Belkin F7D1102 Surf Wireless Micro" "Bus"
.It Em Card Ta Em Bus
.It "Alfa AWUS036NHR v2" Ta USB 2.0
.It "ASUS USB-AC56" Ta USB 3.0
.It "ASUS USB-N10 NANO" Ta USB 2.0
.It "Belkin F7D1102 Surf Wireless Micro" Ta USB 2.0
.It "Buffalo WI-U2-433DM" Ta USB 2.0
.It "Buffalo WI-U3-866D" Ta USB 3.0
.It "D-Link DWA-123 rev D1" Ta USB 2.0
.It "D-Link DWA-125 rev D1" Ta USB 2.0
.It "D-Link DWA-131" Ta USB 2.0
.It "D-Link DWA-171 rev A1" Ta USB 2.0
.It "D-Link DWA-172 rev A1" Ta USB 2.0
.It "D-Link DWA-180 rev A1" Ta USB 2.0
.It "D-Link DWA-182 rev C1" Ta USB 3.0
.It "Edimax EW-7811Un" Ta USB 2.0
.It "Edimax EW-7811UTC" Ta USB 2.0
.It "Edimax EW-7822UAC" Ta USB 3.0
.It "Elecom WDC-150SU2M" Ta USB 2.0
.It "EnGenius EUB1200AC" Ta USB 3.0
.It "Hawking HD65U" Ta USB 2.0
.It "Hercules Wireless N USB Pico" Ta USB 2.0
.It "I-O Data WN-AC867U" Ta USB 3.0
.It "Linksys WUSB6300" Ta USB 3.0
.It "NEC AtermWL900U PA-WL900U" Ta USB 3.0
.It "Netgear A6100" Ta USB 2.0
.It "Netgear WNA1000M" Ta USB 2.0
.It "Planex GW-900D" Ta USB 3.0
.It "Realtek RTL8192CU" Ta USB 2.0
.It "Realtek RTL8188CUS" Ta USB 2.0
.It "Sitecom WLA-7100" Ta USB 3.0
.It "TP-Link Archer T4U" Ta USB 3.0
.It "TP-LINK TL-WN723N v3" Ta USB 2.0
.It "TP-LINK TL-WN725N v2" Ta USB 2.0
.It "TRENDnet TEW-805UB" Ta USB 3.0
.It "ZyXEL NWD6605" Ta USB 3.0
.El
.Sh SEE ALSO
.Xr rtwn 4 ,
.Xr rtwnfw 4 ,
.Xr rtwn_pci 4 ,
.Xr usb 4
.Sh BUGS
The
.Nm
driver does not support any of the 802.11ac capabilities offered by the
adapters.
Additional work is required in
.Xr ieee80211 9
before those features can be supported.

View File

@ -1,4 +1,5 @@
.\" Copyright (c) 2015 Kevin Lo
.\" Copyright (c) 2016 Andriy Voskoboinyk
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -36,26 +37,39 @@ kernel configuration file:
.Cd "device rtwnfw"
.Ed
.Pp
This will include three firmware images inside the kernel.
This will include all firmware images inside the kernel.
If you want to pick only the firmware image for your network adapter choose one
of the following:
.Bd -ragged -offset indent
.Cd "device rtwn-rtl8188eufw"
.Cd "device rtwn-rtl8192cfwE_B"
.Cd "device rtwn-rtl8192cfwE"
.Cd "device rtwn-rtl8192cfwT"
.Cd "device rtwn-rtl8192cfwU"
.Cd "device rtwn-rtl8192cfwU_B"
.Cd "device rtwn-rtl8812aufw"
.Cd "device rtwn-rtl8821aufw"
.Ed
.Pp
Alternatively, to load the driver as a
Alternatively, to load all firmware images as a
module at boot time, place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
rtwn-rtl8188eufw_load="YES"
rtwn-rtl8192cfwE_B_load="YES"
rtwn-rtl8192cfwE_load="YES"
rtwn-rtl8192cfwT_load="YES"
rtwn-rtl8192cfwU_load="YES"
rtwn-rtl8192cfwU_B_load="YES"
rtwn-rtl8812aufw_load="YES"
rtwn-rtl8821aufw_load="YES"
.Ed
.Sh DESCRIPTION
This module provides access to firmware sets for the
Realtek RTL8188CE chip based PCIe adapters.
It may be
statically linked into the kernel, or loaded as a module.
rtwn-rtl8192cfwE and rtl8192cfwE_B modules provide access
to firmware sets for the Realtek RTL8188CE chip based PCIe adapters.
Other modules provide access to firmware sets for the Realtek RTL8188CUS,
RTL8188CE-VAU, RTL8188EUS, RTL8188RU, RTL8192CU, RTL8812AU and RTL8821AU
chip based USB WiFi adapters.
They may be
statically linked into the kernel, or loaded as a modules.
.Pp
For the loaded firmware to be enabled for use the license at
.Pa /usr/share/doc/legal/realtek.LICENSE

View File

@ -34,7 +34,7 @@
.\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
.Dd June 28, 2016
.Dd October 21, 2016
.Dt TCP 4
.Os
.Sh NAME
@ -586,6 +586,12 @@ downshift.
List of available TCP function blocks (TCP stacks).
.It Va functions_default
The default TCP function block (TCP stack).
.It Va insecure_rst
Use criterias defined in RFC793 instead of RFC5961 for accepting RST segments.
Default is false.
.It Va insecure_syn
Use criterias defined in RFC793 instead of RFC5961 for accepting SYN segments.
Default is false.
.El
.Sh ERRORS
A socket operation may fail with one of the following errors returned:

View File

@ -1,190 +0,0 @@
.\" Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
.\"
.\" 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.
.\"
.\" $FreeBSD$
.\"
.Dd June 9, 2016
.Dt URTWN 4
.Os
.Sh NAME
.Nm urtwn
.Nd Realtek RTL8188CU/RTL8188RU/RTL8188EU/RTL8192CU USB IEEE 802.11b/g/n wireless network device
.Sh SYNOPSIS
.Cd "options URTWN_WITHOUT_UCODE"
.Pp
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device ehci"
.Cd "device uhci"
.Cd "device ohci"
.Cd "device usb"
.Cd "device urtwn"
.Cd "device wlan"
.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
if_urtwn_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver supports USB 2.0 wireless network devices based on Realtek
RTL8188CUS, RTL8188CE-VAU, RTL8188EUS, RTL8188RU and RTL8192CU chipsets.
.Pp
The RTL8188CUS and RTL8188EUS are highly integrated 802.11n adapters that
combine a MAC, a 1T1R capable baseband and an RF in a single chip.
They operate in the 2GHz spectrum only.
The RTL8188RU is a high-power variant of the RTL8188CUS.
The RTL8188CE-VAU is a PCI Express Mini Card adapter that attaches
to the USB interface.
.Pp
The RTL8192CU is a highly integrated multiple-in, multiple-out (MIMO)
802.11n adapter that combines a MAC, a 2T2R capable baseband and an
RF in a single chip.
It operates in the 2GHz spectrum only.
.Pp
All chips have hardware support for WEP, AES-CCM and TKIP encryption.
.Pp
The driver supports
.Cm station ,
.Cm adhoc ,
.Cm hostap ,
and
.Cm monitor
mode operation.
Only one virtual interface may be configured at any time.
.Pp
This driver may use the firmware built with the
.Nm urtwnfw
module for some additional features
(when URTWN_WITHOUT_UCODE kernel option is not set).
.Sh FILES
.Bl -tag -width ".Pa /usr/share/doc/legal/realtek.LICENSE" -compact
.It Pa /usr/share/doc/legal/realtek.LICENSE
.Nm
firmware license
.El
.Sh HARDWARE
The
.Nm
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-123 rev D1
.It D-Link DWA-125 rev D1
.It D-Link DWA-131
.It Edimax EW-7811Un
.It Elecom WDC-150SU2M
.It Netgear WNA1000M
.It Realtek RTL8192CU
.It Realtek RTL8188CUS
.It TP-LINK TL-WN723N v3
.It TP-LINK TL-WN725N v2
.El
.Sh EXAMPLES
Join an existing BSS network (i.e., connect to an access point):
.Bd -literal -offset indent
ifconfig wlan create wlandev urtwn0 inet 192.168.0.20 \e
netmask 0xffffff00
.Ed
.Pp
Join a specific BSS network with network name
.Dq Li my_net :
.Pp
.Dl "ifconfig wlan create wlandev urtwn0 ssid my_net up"
.Pp
Join a specific BSS network with 64-bit WEP encryption:
.Bd -literal -offset indent
ifconfig wlan create wlandev urtwn0 ssid my_net \e
wepmode on wepkey 0x1234567890 weptxkey 1 up
.Ed
.Pp
Create an IBSS network with 128-bit WEP encryption on the channel 4:
.Bd -literal -offset indent
ifconfig wlan0 create wlandev urtwn0 wlanmode adhoc ssid my_net \e
wepmode on wepkey 0x01020304050607080910111213 weptxkey 1 \e
channel 4
.Ed
.Pp
Join/create an 802.11b IBSS network with network name
.Dq Li my_net :
.Bd -literal -offset indent
ifconfig wlan0 create wlandev urtwn0 wlanmode adhoc
ifconfig wlan0 inet 192.168.0.22 netmask 0xffffff00 ssid my_net \e
mode 11b
.Ed
.Pp
Create an 802.11g host-based access point:
.Bd -literal -offset indent
ifconfig wlan0 create wlandev urtwn0 wlanmode hostap
ifconfig wlan0 inet 192.168.0.10 netmask 0xffffff00 ssid my_ap \e
mode 11g
.Ed
.Sh DIAGNOSTICS
.Bl -diag
.It "urtwn%d: error %d, could not read firmware %s"
For some reason, the driver was unable to read the microcode file from the
filesystem.
The file might be missing or corrupted.
.It "urtwn%d: device timeout"
A frame dispatched to the hardware for transmission did not complete in time.
The driver will reset the hardware.
This should not happen.
.El
.Sh SEE ALSO
.Xr intro 4 ,
.Xr netintro 4 ,
.Xr urtwnfw 4 ,
.Xr usb 4 ,
.Xr wlan 4 ,
.Xr wlan_amrr 4 ,
.Xr wlan_ccmp 4 ,
.Xr wlan_tkip 4 ,
.Xr wlan_wep 4 ,
.Xr ifconfig 8 ,
.Xr wpa_supplicant 8
.Rs
.%T Realtek
.%U http://www.realtek.com.tw
.Re
.Sh HISTORY
The
.Nm
driver first appeared in
.Ox 4.9
and
.Fx 10.0 .
.Sh AUTHORS
The
.Nm
driver was written by
.An Damien Bergamini Aq Mt damien@openbsd.org .
.Sh CAVEATS
The
.Nm
driver currently does not support A-MPDU 802.11n transmit aggregation.
.Pp
For non-RTL8188EUS chips
.Dq "rate control"
algorithm is absent; this may result in increased packet loss in noisy
networks.

View File

@ -1,77 +0,0 @@
.\" Copyright (c) 2013 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. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd October 15, 2015
.Dt URTWNFW 4
.Os
.Sh NAME
.Nm urtwnfw
.Nd "Firmware Module for Realtek Wireless driver"
.Sh SYNOPSIS
To compile this module into the kernel,
place the following line in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device urtwnfw"
.Ed
.Pp
This will include three firmware images inside the kernel.
If you want to pick only the firmware image for your network adapter choose one
of the following:
.Bd -ragged -offset indent
.Cd "device urtwn-rtl8192cfwT"
.Cd "device urtwn-rtl8192cfwU"
.Cd "device urtwn-rtl8188eufw"
.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
urtwn-rtl8192cfwT_load="YES"
urtwn-rtl8192cfwU_load="YES"
urtwn-rtl8188eufw_load="YES"
.Ed
.Sh DESCRIPTION
This module provides access to firmware sets for the
Realtek RTL8188CUS, RTL8188CE-VAU, RTL8188EUS, RTL8188RU and RTL8192CU
chip based USB WiFi adapters.
It may be
statically linked into the kernel, or loaded as a module.
.Pp
For the loaded firmware to be enabled for use the license at
.Pa /usr/share/doc/legal/realtek.LICENSE
must be agreed to by adding the following line to
.Xr loader.conf 5 :
.Pp
.Dl "legal.realtek.license_ack=1"
.Sh FILES
.Bl -tag -width ".Pa /usr/share/doc/legal/realtek.LICENSE" -compact
.It Pa /usr/share/doc/legal/realtek.LICENSE
.Nm
firmware license
.El
.Sh SEE ALSO
.Xr urtwn 4 ,
.Xr firmware 9

View File

@ -185,13 +185,13 @@ may not interoperate.
.Xr otus 4 ,
.Xr ral 4 ,
.Xr rsu 4 ,
.Xr rtwn 4 ,
.Xr rum 4 ,
.Xr run 4 ,
.Xr uath 4 ,
.Xr upgt 4 ,
.Xr ural 4 ,
.Xr urtw 4 ,
.Xr urtwn 4 ,
.Xr wi 4 ,
.Xr wlan_acl 4 ,
.Xr wlan_ccmp 4 ,

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 19, 2016
.Dd October 20, 2016
.Dt ARCH 7
.Os
.Sh NAME
@ -130,7 +130,7 @@ included here.
.Pp
The full set of predefined macros can be obtained with this command:
.Bd -literal -offset indent
cc -x c -Dm -E /dev/null
cc -x c -dM -E /dev/null
.Ed
.Pp
Common type size and endianness macros:

View File

@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 23, 2014
.Dd October 20, 2016
.Dt FPU_KERN 9
.Os
.Sh NAME
@ -134,11 +134,11 @@ of increased system latency.
.El
.Pp
The function does not sleep or block.
It could cause the
It could cause an FPU trap during execution, and on the first FPU access
after the function returns, as well as after each context switch.
On i386 and amd64 this will be the
.Nm Device Not Available
exception during execution, and on the first FPU access after the
function returns, as well as after each context switch
(see Intel Software Developer Manual for the reference).
exception (see Intel Software Developer Manual for the reference).
Currently, no errors are defined which can be returned by
.Fn fpu_kern_enter
to the caller.
@ -190,7 +190,7 @@ and false otherwise.
.Sh NOTES
The
.Nm
is currently implemented only for the i386 and amd64 architectures.
is currently implemented only for the i386, amd64, and arm64 architectures.
.Pp
There is no way to handle floating point exceptions raised from
kernel mode.
@ -208,3 +208,5 @@ The
.Nm
facitily and this manual page were written by
.An Konstantin Belousov Aq Mt kib@FreeBSD.org .
The arm64 support was added by
.An Andrew Turner Aq Mt andrew@FreeBSD.org .

View File

@ -178,7 +178,8 @@ _LIBS= lib${LIB_PRIVATE}${LIB}.a
lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
@${ECHO} building static ${LIB} library
@rm -f ${.TARGET}
${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
${LORDER} ${OBJS} ${STATICOBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
${RANLIB} ${RANLIBFLAGS} ${.TARGET}
.endif
@ -193,7 +194,8 @@ CLEANFILES+= ${POBJS}
lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
@${ECHO} building profiled ${LIB} library
@rm -f ${.TARGET}
${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${POBJS} | tsort -q` ${ARADD}
${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
${LORDER} ${POBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
${RANLIB} ${RANLIBFLAGS} ${.TARGET}
.endif
@ -241,7 +243,8 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
.endif
${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
-o ${.TARGET} -Wl,-soname,${SONAME} \
`NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${SOBJS} | tsort -q` ${LDADD}
`NM='${NM}' NMFLAGS='${NMFLAGS}' ${LORDER} ${SOBJS} | \
${TSORT} ${TSORTFLAGS}` ${LDADD}
.if ${MK_CTF} != "no"
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
.endif

View File

@ -20,12 +20,24 @@
${CC} ${STATIC_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
.c.bco:
${CC} -emit-llvm ${IR_CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
.c.llo:
${CC} -emit-llvm ${IR_CFLAGS} -S ${.IMPSRC} -o ${.TARGET}
.cc .cpp .cxx .C:
${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
.cc.o .cpp.o .cxx.o .C.o:
${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
.cc.bco .cpp.bco .cxx.bco .C.bco:
${CXX} -emit-llvm ${IR_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
.cc.llo .cpp.llo .cxx.llo .C.llo:
${CXX} -emit-llvm ${IR_CXXFLAGS} -S ${.IMPSRC} -o ${.TARGET}
.m.o:
${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}

View File

@ -98,6 +98,8 @@ __DEFAULT_YES_OPTIONS = \
GCOV \
GDB \
GNU \
GNU_DIFF \
GNU_GREP \
GNU_GREP_COMPAT \
GPIO \
GPL_DTC \
@ -300,6 +302,10 @@ MK_${var}:= no
MK_LLVM_LIBUNWIND:= no
.endif
.if ${MK_BINUTILS} == "no"
MK_GDB:= no
.endif
.if ${MK_LIBPTHREAD} == "no"
MK_LIBTHR:= no
.endif

View File

@ -153,6 +153,7 @@ CFLAGS ?= -O2 -pipe
CFLAGS += -fno-strict-aliasing
.endif
.endif
IR_CFLAGS ?= ${STATIC_CFLAGS:N-O*} ${CFLAGS:N-O*}
PO_CFLAGS ?= ${CFLAGS}
# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
@ -173,6 +174,7 @@ CTFFLAGS += -g
CXX ?= c++
CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
IR_CXXFLAGS ?= ${STATIC_CXXFLAGS:N-O*} ${CXXFLAGS:N-O*}
PO_CXXFLAGS ?= ${CXXFLAGS}
DTRACE ?= dtrace
@ -229,6 +231,8 @@ LINTLIBFLAGS ?= -cghapbxu -C ${LIB}
MAKE ?= make
.if !defined(%POSIX)
LORDER ?= lorder
NM ?= nm
NMFLAGS ?=
@ -242,6 +246,9 @@ PFLAGS ?=
RC ?= f77
RFLAGS ?=
TSORT ?= tsort
TSORTFLAGS ?= -q
.endif
SHELL ?= sh

View File

@ -1,6 +1,6 @@
/*-
* Copyright (C) 2002-2003 NetGroup, Politecnico di Torino (Italy)
* Copyright (C) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
* Copyright (C) 2005-2016 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -83,12 +83,13 @@ emit_code(bpf_bin_stream *stream, u_int value, u_int len)
break;
case 2:
*((u_short *)(stream->ibuf + stream->cur_ip)) = (u_short)value;
*((u_short *)(void *)(stream->ibuf + stream->cur_ip)) =
(u_short)value;
stream->cur_ip += 2;
break;
case 4:
*((u_int *)(stream->ibuf + stream->cur_ip)) = value;
*((u_int *)(void *)(stream->ibuf + stream->cur_ip)) = value;
stream->cur_ip += 4;
break;
}
@ -424,75 +425,58 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
break;
case BPF_JMP|BPF_JGT|BPF_K:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
CMPid(ins->k, EAX);
JCC(JA, JBE);
break;
case BPF_JMP|BPF_JGE|BPF_K:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
CMPid(ins->k, EAX);
JCC(JAE, JB);
break;
case BPF_JMP|BPF_JEQ|BPF_K:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
CMPid(ins->k, EAX);
JCC(JE, JNE);
break;
case BPF_JMP|BPF_JSET|BPF_K:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
TESTid(ins->k, EAX);
JCC(JNE, JE);
break;
case BPF_JMP|BPF_JGT|BPF_X:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
CMPrd(EDX, EAX);
JCC(JA, JBE);
break;
case BPF_JMP|BPF_JGE|BPF_X:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
CMPrd(EDX, EAX);
JCC(JAE, JB);
break;
case BPF_JMP|BPF_JEQ|BPF_X:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
CMPrd(EDX, EAX);
JCC(JE, JNE);
break;
case BPF_JMP|BPF_JSET|BPF_X:
if (ins->jt == ins->jf) {
JUMP(ins->jt);
break;
}
TESTrd(EDX, EAX);
JCC(JNE, JE);
switch (ins->code) {
case BPF_JMP|BPF_JGT|BPF_K:
CMPid(ins->k, EAX);
JCC(JA, JBE);
break;
case BPF_JMP|BPF_JGE|BPF_K:
CMPid(ins->k, EAX);
JCC(JAE, JB);
break;
case BPF_JMP|BPF_JEQ|BPF_K:
CMPid(ins->k, EAX);
JCC(JE, JNE);
break;
case BPF_JMP|BPF_JSET|BPF_K:
TESTid(ins->k, EAX);
JCC(JNE, JE);
break;
case BPF_JMP|BPF_JGT|BPF_X:
CMPrd(EDX, EAX);
JCC(JA, JBE);
break;
case BPF_JMP|BPF_JGE|BPF_X:
CMPrd(EDX, EAX);
JCC(JAE, JB);
break;
case BPF_JMP|BPF_JEQ|BPF_X:
CMPrd(EDX, EAX);
JCC(JE, JNE);
break;
case BPF_JMP|BPF_JSET|BPF_X:
TESTrd(EDX, EAX);
JCC(JNE, JE);
break;
}
break;
case BPF_ALU|BPF_ADD|BPF_X:
@ -510,6 +494,7 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
break;
case BPF_ALU|BPF_DIV|BPF_X:
case BPF_ALU|BPF_MOD|BPF_X:
TESTrd(EDX, EDX);
if (fmem) {
JNEb(4);
@ -523,6 +508,8 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
MOVrd(EDX, ECX);
ZEROrd(EDX);
DIVrd(ECX);
if (BPF_OP(ins->code) == BPF_MOD)
MOVrd(EDX, EAX);
MOVrd(ECX, EDX);
break;
@ -534,6 +521,10 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
ORrd(EDX, EAX);
break;
case BPF_ALU|BPF_XOR|BPF_X:
XORrd(EDX, EAX);
break;
case BPF_ALU|BPF_LSH|BPF_X:
MOVrd(EDX, ECX);
SHL_CLrb(EAX);
@ -560,10 +551,13 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
break;
case BPF_ALU|BPF_DIV|BPF_K:
case BPF_ALU|BPF_MOD|BPF_K:
MOVrd(EDX, ECX);
ZEROrd(EDX);
MOVid(ins->k, ESI);
DIVrd(ESI);
if (BPF_OP(ins->code) == BPF_MOD)
MOVrd(EDX, EAX);
MOVrd(ECX, EDX);
break;
@ -575,6 +569,10 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
ORid(ins->k, EAX);
break;
case BPF_ALU|BPF_XOR|BPF_K:
XORid(ins->k, EAX);
break;
case BPF_ALU|BPF_LSH|BPF_K:
SHLib((ins->k) & 0xff, EAX);
break;
@ -650,5 +648,5 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
}
#endif
return ((bpf_filter_func)stream.ibuf);
return ((bpf_filter_func)(void *)stream.ibuf);
}

View File

@ -1,6 +1,6 @@
/*-
* Copyright (C) 2002-2003 NetGroup, Politecnico di Torino (Italy)
* Copyright (C) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
* Copyright (C) 2005-2016 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -357,6 +357,24 @@ typedef void (*emit_func)(bpf_bin_stream *stream, u_int value, u_int n);
emitm(&stream, i32, 4); \
} while (0)
/* xorl sr32,dr32 */
#define XORrd(sr32, dr32) do { \
emitm(&stream, 0x31, 1); \
emitm(&stream, \
(3 << 6) | ((sr32 & 0x7) << 3) | (dr32 & 0x7), 1); \
} while (0)
/* xorl i32,r32 */
#define XORid(i32, r32) do { \
if (r32 == EAX) { \
emitm(&stream, 0x35, 1); \
} else { \
emitm(&stream, 0x81, 1); \
emitm(&stream, (25 << 3) | r32, 1); \
} \
emitm(&stream, i32, 4); \
} while (0)
/* shll i8,r32 */
#define SHLib(i8, r32) do { \
emitm(&stream, 0xc1, 1); \

View File

@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
static struct efi_systbl *efi_systbl;
static struct efi_cfgtbl *efi_cfgtbl;
static struct efi_rt *efi_runtime;
static struct cdev *efi_cdev;
static int efi_status2err[25] = {
0, /* EFI_SUCCESS */
@ -403,15 +402,13 @@ efi_init(void)
return (ENXIO);
}
return (efidev_init(&efi_cdev));
return (0);
}
static void
efi_uninit(void)
{
efidev_uninit(efi_cdev);
efi_destroy_1t1_map();
efi_systbl = NULL;
@ -566,7 +563,6 @@ efirt_modevents(module_t m, int event, void *arg __unused)
switch (event) {
case MOD_LOAD:
return (efi_init());
break;
case MOD_UNLOAD:
efi_uninit();

View File

@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/kerneldump.h>
#include <sys/msgbuf.h>
#include <sys/sysctl.h>
#include <sys/watchdog.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@ -68,6 +69,9 @@ static void *dump_va;
static size_t counter, progress, dumpsize;
CTASSERT(sizeof(*vm_page_dump) == 8);
static int dump_retry_count = 5;
SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN,
&dump_retry_count, 0, "Number of times dump has to retry before bailing out");
static int
is_dumpable(vm_paddr_t pa)
@ -447,7 +451,7 @@ minidumpsys(struct dumperinfo *di)
printf("\n");
if (error == ENOSPC) {
printf("Dump map grown while dumping. ");
if (retry_count < 5) {
if (retry_count < dump_retry_count) {
printf("Retrying...\n");
goto retry;
}

View File

@ -275,17 +275,11 @@ a10_ehci_detach(device_t self)
struct aw_ehci_softc *aw_sc = device_get_softc(self);
ehci_softc_t *sc = &aw_sc->sc;
const struct aw_ehci_conf *conf;
device_t bdev;
int err;
uint32_t reg_value = 0;
conf = USB_CONF(self);
if (sc->sc_bus.bdev) {
bdev = sc->sc_bus.bdev;
device_detach(bdev);
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(self);

View File

@ -82,7 +82,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun6i-a31s", CLOCK_CCU },
{ "allwinner,sun50i-a64", CLOCK_CCU },
{ "allwinner,sun8i-a83t", CLOCK_CCU|CLOCK_PRCM|CLOCK_SYSCTRL },
{ "allwinner,sun8i-h3", CLOCK_CCU },
{ "allwinner,sun8i-h3", CLOCK_CCU|CLOCK_PRCM },
{ NULL, 0 }
};

View File

@ -0,0 +1,394 @@
/*-
* Copyright (c) 2015,2016 Annapurna Labs Ltd. and affiliates
* All rights reserved.
*
* Developed by Semihalf.
*
* 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/vmem.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include "msi_if.h"
#include "pic_if.h"
#define AL_SPI_INTR 0
#define AL_EDGE_HIGH 1
#define ERR_NOT_IN_MAP -1
#define IRQ_OFFSET 1
#define GIC_INTR_CELL_CNT 3
#define INTR_RANGE_COUNT 2
#define MAX_MSIX_COUNT 160
static int al_msix_attach(device_t);
static int al_msix_probe(device_t);
static msi_alloc_msi_t al_msix_alloc_msi;
static msi_release_msi_t al_msix_release_msi;
static msi_alloc_msix_t al_msix_alloc_msix;
static msi_release_msix_t al_msix_release_msix;
static msi_map_msi_t al_msix_map_msi;
static int al_find_intr_pos_in_map(device_t, struct intr_irqsrc *);
static struct ofw_compat_data compat_data[] = {
{"annapurna-labs,al-msix", true},
{"annapurna-labs,alpine-msix", true},
{NULL, false}
};
/*
* Bus interface definitions.
*/
static device_method_t al_msix_methods[] = {
DEVMETHOD(device_probe, al_msix_probe),
DEVMETHOD(device_attach, al_msix_attach),
/* Interrupt controller interface */
DEVMETHOD(msi_alloc_msi, al_msix_alloc_msi),
DEVMETHOD(msi_release_msi, al_msix_release_msi),
DEVMETHOD(msi_alloc_msix, al_msix_alloc_msix),
DEVMETHOD(msi_release_msix, al_msix_release_msix),
DEVMETHOD(msi_map_msi, al_msix_map_msi),
DEVMETHOD_END
};
struct al_msix_softc {
bus_addr_t base_addr;
struct resource *res;
uint32_t irq_min;
uint32_t irq_max;
uint32_t irq_count;
struct mtx msi_mtx;
vmem_t *irq_alloc;
device_t gic_dev;
/* Table of isrcs maps isrc pointer to vmem_alloc'd irq number */
struct intr_irqsrc *isrcs[MAX_MSIX_COUNT];
};
static driver_t al_msix_driver = {
"al_msix",
al_msix_methods,
sizeof(struct al_msix_softc),
};
devclass_t al_msix_devclass;
DRIVER_MODULE(al_msix, ofwbus, al_msix_driver, al_msix_devclass, 0, 0);
DRIVER_MODULE(al_msix, simplebus, al_msix_driver, al_msix_devclass, 0, 0);
MALLOC_DECLARE(M_AL_MSIX);
MALLOC_DEFINE(M_AL_MSIX, "al_msix", "Alpine MSIX");
static int
al_msix_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, "Annapurna-Labs MSI-X Controller");
return (BUS_PROBE_DEFAULT);
}
static int
al_msix_attach(device_t dev)
{
struct al_msix_softc *sc;
device_t gic_dev;
phandle_t iparent;
phandle_t node;
intptr_t xref;
int interrupts[INTR_RANGE_COUNT];
int nintr, i, rid;
uint32_t icells, *intr;
sc = device_get_softc(dev);
node = ofw_bus_get_node(dev);
xref = OF_xref_from_node(node);
OF_device_register_xref(xref, dev);
rid = 0;
sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
if (sc->res == NULL) {
device_printf(dev, "Failed to allocate resource\n");
return (ENXIO);
}
sc->base_addr = (bus_addr_t)rman_get_start(sc->res);
/* Register this device to handle MSI interrupts */
if (intr_msi_register(dev, xref) != 0) {
device_printf(dev, "could not register MSI-X controller\n");
return (ENXIO);
}
else
device_printf(dev, "MSI-X controller registered\n");
/* Find root interrupt controller */
iparent = ofw_bus_find_iparent(node);
if (iparent == 0) {
device_printf(dev, "No interrupt-parrent found. "
"Error in DTB\n");
return (ENXIO);
} else {
/* While at parent - store interrupt cells prop */
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "DTB: Missing #interrupt-cells "
"property in GIC node\n");
return (ENXIO);
}
}
gic_dev = OF_device_from_xref(iparent);
if (gic_dev == NULL) {
device_printf(dev, "Cannot find GIC device\n");
return (ENXIO);
}
sc->gic_dev = gic_dev;
/* Manually read range of interrupts from DTB */
nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
(void **)&intr);
if (nintr == 0) {
device_printf(dev, "Cannot read interrupts prop from DTB\n");
return (ENXIO);
} else if ((nintr / icells) != INTR_RANGE_COUNT) {
/* Supposed to have min and max value only */
device_printf(dev, "Unexpected count of interrupts "
"in DTB node\n");
return (EINVAL);
}
/* Read interrupt range values */
for (i = 0; i < INTR_RANGE_COUNT; i++)
interrupts[i] = intr[(i * icells) + IRQ_OFFSET];
sc->irq_min = interrupts[0];
sc->irq_max = interrupts[1];
sc->irq_count = (sc->irq_max - sc->irq_min + 1);
if (sc->irq_count > MAX_MSIX_COUNT) {
device_printf(dev, "Available MSI-X count exceeds buffer size."
" Capping to %d\n", MAX_MSIX_COUNT);
sc->irq_count = MAX_MSIX_COUNT;
}
mtx_init(&sc->msi_mtx, "msi_mtx", NULL, MTX_DEF);
sc->irq_alloc = vmem_create("Alpine MSI-X IRQs", 0, sc->irq_count,
1, 0, M_FIRSTFIT | M_WAITOK);
device_printf(dev, "MSI-X SPI IRQ %d-%d\n", sc->irq_min, sc->irq_max);
return (bus_generic_attach(dev));
}
static int
al_find_intr_pos_in_map(device_t dev, struct intr_irqsrc *isrc)
{
struct al_msix_softc *sc;
int i;
sc = device_get_softc(dev);
for (i = 0; i < MAX_MSIX_COUNT; i++)
if (sc->isrcs[i] == isrc)
return (i);
return (ERR_NOT_IN_MAP);
}
static int
al_msix_map_msi(device_t dev, device_t child, struct intr_irqsrc *isrc,
uint64_t *addr, uint32_t *data)
{
struct al_msix_softc *sc;
int i, spi;
sc = device_get_softc(dev);
i = al_find_intr_pos_in_map(dev, isrc);
if (i == ERR_NOT_IN_MAP)
return (EINVAL);
spi = sc->irq_min + i;
/*
* MSIX message address format:
* [63:20] - MSIx TBAR
* Same value as the MSIx Translation Base Address Register
* [19] - WFE_EXIT
* Once set by MSIx message, an EVENTI is signal to the CPUs
* cluster specified by Local GIC Target List
* [18:17] - Target GIC ID
* Specifies which IO-GIC (external shared GIC) is targeted
* 0: Local GIC, as specified by the Local GIC Target List
* 1: IO-GIC 0
* 2: Reserved
* 3: Reserved
* [16:13] - Local GIC Target List
* Specifies the Local GICs list targeted by this MSIx
* message.
* [16] If set, SPIn is set in Cluster 0 local GIC
* [15:13] Reserved
* [15] If set, SPIn is set in Cluster 1 local GIC
* [14] If set, SPIn is set in Cluster 2 local GIC
* [13] If set, SPIn is set in Cluster 3 local GIC
* [12:3] - SPIn
* Specifies the SPI (Shared Peripheral Interrupt) index to
* be set in target GICs
* Notes:
* If targeting any local GIC than only SPI[249:0] are valid
* [2] - Function vector
* MSI Data vector extension hint
* [1:0] - Reserved
* Must be set to zero
*/
*addr = (uint64_t)sc->base_addr + (uint64_t)((1 << 16) + (spi << 3));
*data = 0;
if (bootverbose)
device_printf(dev, "MSI mapping: SPI: %d addr: %jx data: %x\n",
spi, (uintmax_t)*addr, *data);
return (0);
}
static int
al_msix_alloc_msi(device_t dev, device_t child, int count, int maxcount,
device_t *pic, struct intr_irqsrc **srcs)
{
struct intr_map_data_fdt *fdt_data;
struct al_msix_softc *sc;
vmem_addr_t irq_base;
int error;
u_int i, j;
sc = device_get_softc(dev);
if ((powerof2(count) == 0) || (count > 8))
return (EINVAL);
if (vmem_alloc(sc->irq_alloc, count, M_FIRSTFIT | M_NOWAIT,
&irq_base) != 0)
return (ENOMEM);
/* Fabricate OFW data to get ISRC from GIC and return it */
fdt_data = malloc(sizeof(*fdt_data) +
GIC_INTR_CELL_CNT * sizeof(pcell_t), M_AL_MSIX, M_WAITOK);
fdt_data->hdr.type = INTR_MAP_DATA_FDT;
fdt_data->iparent = 0;
fdt_data->ncells = GIC_INTR_CELL_CNT;
fdt_data->cells[0] = AL_SPI_INTR; /* code for SPI interrupt */
fdt_data->cells[1] = 0; /* SPI number (uninitialized) */
fdt_data->cells[2] = AL_EDGE_HIGH; /* trig = edge, pol = high */
mtx_lock(&sc->msi_mtx);
for (i = irq_base; i < irq_base + count; i++) {
fdt_data->cells[1] = sc->irq_min + i;
error = PIC_MAP_INTR(sc->gic_dev,
(struct intr_map_data *)fdt_data, srcs);
if (error) {
for (j = irq_base; j < i; j++)
sc->isrcs[j] = NULL;
mtx_unlock(&sc->msi_mtx);
vmem_free(sc->irq_alloc, irq_base, count);
free(fdt_data, M_AL_MSIX);
return (error);
}
sc->isrcs[i] = *srcs;
srcs++;
}
mtx_unlock(&sc->msi_mtx);
free(fdt_data, M_AL_MSIX);
if (bootverbose)
device_printf(dev,
"MSI-X allocation: start SPI %d, count %d\n",
(int)irq_base + sc->irq_min, count);
*pic = sc->gic_dev;
return (0);
}
static int
al_msix_release_msi(device_t dev, device_t child, int count,
struct intr_irqsrc **srcs)
{
struct al_msix_softc *sc;
int i, pos;
sc = device_get_softc(dev);
mtx_lock(&sc->msi_mtx);
pos = al_find_intr_pos_in_map(dev, *srcs);
vmem_free(sc->irq_alloc, pos, count);
for (i = 0; i < count; i++) {
pos = al_find_intr_pos_in_map(dev, *srcs);
if (pos != ERR_NOT_IN_MAP)
sc->isrcs[pos] = NULL;
srcs++;
}
mtx_unlock(&sc->msi_mtx);
return (0);
}
static int
al_msix_alloc_msix(device_t dev, device_t child, device_t *pic,
struct intr_irqsrc **isrcp)
{
return (al_msix_alloc_msi(dev, child, 1, 1, pic, isrcp));
}
static int
al_msix_release_msix(device_t dev, device_t child, struct intr_irqsrc *isrc)
{
return (al_msix_release_msi(dev, child, 1, &isrc));
}

View File

@ -0,0 +1,225 @@
/*-
* Copyright (c) 2015,2016 Annapurna Labs Ltd. and affiliates
* All rights reserved.
*
* Developed by Semihalf.
*
* 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/conf.h>
#include <sys/resource.h>
#include <machine/bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include "al_serdes.h"
#include "alpine_serdes.h"
#define SERDES_NUM_GROUPS 5
static void *serdes_base;
static uint32_t serdes_grp_offset[] = {0, 0x400, 0x800, 0xc00, 0x2000};
static struct alpine_serdes_eth_group_mode {
struct mtx lock;
enum alpine_serdes_eth_mode mode;
bool mode_set;
} alpine_serdes_eth_group_mode[SERDES_NUM_GROUPS];
static int al_serdes_probe(device_t dev);
static int al_serdes_attach(device_t dev);
static int al_serdes_detach(device_t dev);
static struct resource_spec al_serdes_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ -1, 0 }
};
struct al_serdes_softc {
struct resource *res;
};
static device_method_t al_serdes_methods[] = {
DEVMETHOD(device_probe, al_serdes_probe),
DEVMETHOD(device_attach, al_serdes_attach),
DEVMETHOD(device_detach, al_serdes_detach),
DEVMETHOD_END
};
static driver_t al_serdes_driver = {
"serdes",
al_serdes_methods,
sizeof(struct al_serdes_softc)
};
static devclass_t al_serdes_devclass;
DRIVER_MODULE(al_serdes, simplebus, al_serdes_driver,
al_serdes_devclass, 0, 0);
DRIVER_MODULE(al_serdes, ofwbus, al_serdes_driver,
al_serdes_devclass, 0, 0);
static int
al_serdes_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_is_compatible(dev, "annapurna-labs,al-serdes"))
return (ENXIO);
device_set_desc(dev, "Alpine Serdes");
return (BUS_PROBE_DEFAULT);
}
static int
al_serdes_attach(device_t dev)
{
struct al_serdes_softc *sc;
int err;
sc = device_get_softc(dev);
err = bus_alloc_resources(dev, al_serdes_spec, &sc->res);
if (err != 0) {
device_printf(dev, "could not allocate resources\n");
return (err);
}
/* Initialize Serdes group locks and mode */
for (int i = 0; i < nitems(alpine_serdes_eth_group_mode); i++) {
mtx_init(&alpine_serdes_eth_group_mode[i].lock, "AlSerdesMtx",
NULL, MTX_DEF);
alpine_serdes_eth_group_mode[i].mode_set = false;
}
serdes_base = (void *)rman_get_bushandle(sc->res);
return (0);
}
static int
al_serdes_detach(device_t dev)
{
struct al_serdes_softc *sc;
sc = device_get_softc(dev);
bus_release_resources(dev, al_serdes_spec, &sc->res);
for (int i = 0; i < nitems(alpine_serdes_eth_group_mode); i++) {
mtx_destroy(&alpine_serdes_eth_group_mode[i].lock);
alpine_serdes_eth_group_mode[i].mode_set = false;
}
return (0);
}
void *
alpine_serdes_resource_get(uint32_t group)
{
void *base;
base = NULL;
if (group >= SERDES_NUM_GROUPS)
return (NULL);
if (serdes_base != NULL)
base = (void *)((uintptr_t)serdes_base +
serdes_grp_offset[group]);
return (base);
}
int
alpine_serdes_eth_mode_set(uint32_t group, enum alpine_serdes_eth_mode mode)
{
struct alpine_serdes_eth_group_mode *group_mode;
group_mode = &alpine_serdes_eth_group_mode[group];
if (serdes_base == NULL)
return (EINVAL);
if (group >= SERDES_NUM_GROUPS)
return (EINVAL);
mtx_lock(&group_mode->lock);
if (!group_mode->mode_set || (group_mode->mode != mode)) {
struct al_serdes_grp_obj obj;
al_serdes_handle_grp_init(alpine_serdes_resource_get(group),
group, &obj);
if (mode == ALPINE_SERDES_ETH_MODE_SGMII)
obj.mode_set_sgmii(&obj);
else
obj.mode_set_kr(&obj);
group_mode->mode = mode;
group_mode->mode_set = true;
}
mtx_unlock(&group_mode->lock);
return (0);
}
void
alpine_serdes_eth_group_lock(uint32_t group)
{
struct alpine_serdes_eth_group_mode *group_mode;
group_mode = &alpine_serdes_eth_group_mode[group];
if (mtx_initialized(&group_mode->lock) == 0)
return;
mtx_lock(&group_mode->lock);
}
void
alpine_serdes_eth_group_unlock(uint32_t group)
{
struct alpine_serdes_eth_group_mode *group_mode;
group_mode = &alpine_serdes_eth_group_mode[group];
if (mtx_initialized(&group_mode->lock) == 0)
return;
mtx_unlock(&group_mode->lock);
}

View File

@ -0,0 +1,61 @@
/*-
* Copyright (c) 2015,2016 Annapurna Labs Ltd. and affiliates
* All rights reserved.
*
* Developed by Semihalf.
*
* 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 __ALPINE_SERDES_H__
#define __ALPINE_SERDES_H__
/* SerDes ETH mode */
enum alpine_serdes_eth_mode {
ALPINE_SERDES_ETH_MODE_SGMII,
ALPINE_SERDES_ETH_MODE_KR,
};
/*
* Get SerDes group regs base, to be used in relevant Alpine drivers.
* Valid group is 0..3.
* Returns virtual base address of the group regs base.
*/
void *alpine_serdes_resource_get(uint32_t group);
/*
* Set SerDes ETH mode for an entire group, unless already set
* Valid group is 0..3.
* Returns 0 upon success.
*/
int alpine_serdes_eth_mode_set(uint32_t group,
enum alpine_serdes_eth_mode mode);
/* Lock the all serdes group for using common registers */
void alpine_serdes_eth_group_lock(uint32_t group);
/* Unlock the all serdes group for using common registers */
void alpine_serdes_eth_group_unlock(uint32_t group);
#endif /* __ALPINE_SERDES_H__ */

View File

@ -165,14 +165,8 @@ static int
ohci_atmelarm_detach(device_t dev)
{
struct at91_ohci_softc *sc = device_get_softc(dev);
device_t bdev;
int err;
if (sc->sc_ohci.sc_bus.bdev) {
bdev = sc->sc_ohci.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(dev);

View File

@ -171,14 +171,8 @@ static int
ohci_at91_fdt_detach(device_t dev)
{
struct at91_ohci_softc *sc = device_get_softc(dev);
device_t bdev;
int err;
if (sc->sc_ohci.sc_bus.bdev) {
bdev = sc->sc_ohci.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(dev);

View File

@ -184,14 +184,8 @@ static int
ehci_ebus_detach(device_t self)
{
ehci_softc_t *sc = device_get_softc(self);
device_t bdev;
int err;
if (sc->sc_bus.bdev) {
bdev = sc->sc_bus.bdev;
device_detach(bdev);
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(self);

View File

@ -177,14 +177,8 @@ static int
ohci_ec_detach(device_t dev)
{
struct ec_ohci_softc *sc = device_get_softc(dev);
device_t bdev;
int err;
if (sc->sc_ohci.sc_bus.bdev) {
bdev = sc->sc_ohci.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(dev);

View File

@ -35,6 +35,9 @@ options INTRNG
# Annapurna Alpine drivers
device al_ccu # Alpine Cache Coherency Unit
device al_nb_service # Alpine North Bridge Service
device al_iofic # I/O Fabric Interrupt Controller
device al_serdes # Serializer/Deserializer
device al_udma # Universal DMA
# Pseudo devices
device loop
@ -69,6 +72,7 @@ device al_pci # Annapurna Alpine PCI-E
device ether
device mii
device bpf
device al_eth # Annapurna Alpine Ethernet NIC
options DEVICE_POLLING
# USB ethernet support, requires miibus

View File

@ -30,6 +30,8 @@ hints "PANDABOARD.hints"
include "std.armv6"
include "../ti/omap4/pandaboard/std.pandaboard"
makeoptions MODULES_EXTRA=dtb/omap4
options SCHED_ULE # ULE scheduler
options PLATFORM
options SMP # Enable multiple cores

View File

@ -71,13 +71,6 @@ enum as3722_reg_id {
AS3722_REG_ID_LDO11,
};
struct regulator_range {
u_int min_uvolt;
u_int step_uvolt;
u_int min_sel;
u_int max_sel;
};
/* Regulator HW definition. */
struct reg_def {
@ -107,40 +100,32 @@ struct as3722_reg_sc {
int enable_usec;
};
#define RANGE_INIT(_min_sel, _max_sel, _min_uvolt, _step_uvolt) \
{ \
.min_sel = _min_sel, \
.max_sel = _max_sel, \
.min_uvolt = _min_uvolt, \
.step_uvolt = _step_uvolt, \
}
static struct regulator_range as3722_sd016_ranges[] = {
RANGE_INIT(0x00, 0x00, 0, 0),
RANGE_INIT(0x01, 0x5A, 610000, 10000),
REG_RANGE_INIT(0x00, 0x00, 0, 0),
REG_RANGE_INIT(0x01, 0x5A, 610000, 10000),
};
static struct regulator_range as3722_sd0_lv_ranges[] = {
RANGE_INIT(0x00, 0x00, 0, 0),
RANGE_INIT(0x01, 0x6E, 410000, 10000),
REG_RANGE_INIT(0x00, 0x00, 0, 0),
REG_RANGE_INIT(0x01, 0x6E, 410000, 10000),
};
static struct regulator_range as3722_sd_ranges[] = {
RANGE_INIT(0x00, 0x00, 0, 0),
RANGE_INIT(0x01, 0x40, 612500, 12500),
RANGE_INIT(0x41, 0x70, 1425000, 25000),
RANGE_INIT(0x71, 0x7F, 2650000, 50000),
REG_RANGE_INIT(0x00, 0x00, 0, 0),
REG_RANGE_INIT(0x01, 0x40, 612500, 12500),
REG_RANGE_INIT(0x41, 0x70, 1425000, 25000),
REG_RANGE_INIT(0x71, 0x7F, 2650000, 50000),
};
static struct regulator_range as3722_ldo3_ranges[] = {
RANGE_INIT(0x00, 0x00, 0, 0),
RANGE_INIT(0x01, 0x2D, 620000, 20000),
REG_RANGE_INIT(0x00, 0x00, 0, 0),
REG_RANGE_INIT(0x01, 0x2D, 620000, 20000),
};
static struct regulator_range as3722_ldo_ranges[] = {
RANGE_INIT(0x00, 0x00, 0, 0),
RANGE_INIT(0x01, 0x24, 825000, 25000),
RANGE_INIT(0x40, 0x7F, 1725000, 25000),
REG_RANGE_INIT(0x00, 0x00, 0, 0),
REG_RANGE_INIT(0x01, 0x24, 825000, 25000),
REG_RANGE_INIT(0x40, 0x7F, 1725000, 25000),
};
static struct reg_def as3722s_def[] = {
@ -401,87 +386,6 @@ static regnode_method_t as3722_regnode_methods[] = {
DEFINE_CLASS_1(as3722_regnode, as3722_regnode_class, as3722_regnode_methods,
sizeof(struct as3722_reg_sc), regnode_class);
static int
regulator_range_sel_to_volt(struct as3722_reg_sc *sc, uint8_t sel, int *volt)
{
struct regulator_range *range;
struct reg_def *def;
int i;
def = sc->def;
if (def->nranges == 0)
panic("Voltage regulator have zero ranges\n");
for (i = 0; i < def->nranges ; i++) {
range = def->ranges + i;
if (!(sel >= range->min_sel &&
sel <= range->max_sel))
continue;
sel -= range->min_sel;
*volt = range->min_uvolt + sel * range->step_uvolt;
return (0);
}
return (ERANGE);
}
static int
regulator_range_volt_to_sel(struct as3722_reg_sc *sc, int min_uvolt,
int max_uvolt, uint8_t *out_sel)
{
struct regulator_range *range;
struct reg_def *def;
uint8_t sel;
int uvolt;
int rv, i;
def = sc->def;
if (def->nranges == 0)
panic("Voltage regulator have zero ranges\n");
for (i = 0; i < def->nranges; i++) {
range = def->ranges + i;
uvolt = range->min_uvolt +
(range->max_sel - range->min_sel) * range->step_uvolt;
if ((min_uvolt > uvolt) ||
(max_uvolt < range->min_uvolt))
continue;
if (min_uvolt <= range->min_uvolt)
min_uvolt = range->min_uvolt;
/* If step is zero then range is fixed voltage range. */
if (range->step_uvolt == 0)
sel = 0;
else
sel = DIV_ROUND_UP(min_uvolt - range->min_uvolt,
range->step_uvolt);
sel += range->min_sel;
break;
}
if (i >= def->nranges)
return (ERANGE);
/* Verify new settings. */
rv = regulator_range_sel_to_volt(sc, sel, &uvolt);
if (rv != 0)
return (rv);
if ((uvolt < min_uvolt) || (uvolt > max_uvolt))
return (ERANGE);
*out_sel = sel;
return (0);
}
static int
as3722_read_sel(struct as3722_reg_sc *sc, uint8_t *sel)
{
@ -783,7 +687,8 @@ as3722_regnode_set_volt(struct regnode *regnode, int min_uvolt, int max_uvolt,
sc = regnode_get_softc(regnode);
*udelay = 0;
rv = regulator_range_volt_to_sel(sc, min_uvolt, max_uvolt, &sel);
rv = regulator_range_volt_to_sel8(sc->def->ranges, sc->def->nranges,
min_uvolt, max_uvolt, &sel);
if (rv != 0)
return (rv);
rv = as3722_write_sel(sc, sel);
@ -806,6 +711,7 @@ as3722_regnode_get_volt(struct regnode *regnode, int *uvolt)
/* LDO6 have bypass. */
if (sc->def->id == AS3722_REG_ID_LDO6 && sel == AS3722_LDO6_SEL_BYPASS)
return (ENOENT);
rv = regulator_range_sel_to_volt(sc, sel, uvolt);
rv = regulator_range_sel8_to_volt(sc->def->ranges, sc->def->nranges,
sel, uvolt);
return (rv);
}

View File

@ -178,10 +178,14 @@ tegra124_coretemp_ofw_parse(struct tegra124_coretemp_softc *sc)
static void
tegra124_coretemp_identify(driver_t *driver, device_t parent)
{
phandle_t root;
if (device_find_child(parent, "coretemp", -1) != NULL)
root = OF_finddevice("/");
if (!ofw_bus_node_is_compatible(root, "nvidia,tegra124"))
return;
if (BUS_ADD_CHILD(parent, 0, "coretemp", -1) == NULL)
if (device_find_child(parent, "tegra124_coretemp", -1) != NULL)
return;
if (BUS_ADD_CHILD(parent, 0, "tegra124_coretemp", -1) == NULL)
device_printf(parent, "add child failed\n");
}
@ -262,7 +266,7 @@ static device_method_t tegra124_coretemp_methods[] = {
};
static devclass_t tegra124_coretemp_devclass;
static DEFINE_CLASS_0(coretemp, tegra124_coretemp_driver,
static DEFINE_CLASS_0(tegra124_coretemp, tegra124_coretemp_driver,
tegra124_coretemp_methods, sizeof(struct tegra124_coretemp_softc));
DRIVER_MODULE(tegra124_coretemp, cpu, tegra124_coretemp_driver,
tegra124_coretemp_devclass, NULL, NULL);

View File

@ -141,7 +141,7 @@ static struct speedo_entry tegra124_speedo_pllx_tbl[] =
static struct cpu_volt_def tegra124_cpu_volt_pllx_def =
{
.min_uvolt = 900000, /* 0.9 V */
.min_uvolt = 1000000, /* XXX 0.9 V doesn't work on all boards */
.max_uvolt = 1260000, /* 1.26 */
.step_uvolt = 10000, /* 10 mV */
.speedo_scale = 100,
@ -172,7 +172,6 @@ static uint64_t cpu_freq_tbl[] = {
2116000000ULL,
2218000000ULL,
2320000000ULL,
2320000000ULL,
2422000000ULL,
2524000000ULL,
};
@ -475,6 +474,11 @@ get_fdt_resources(struct tegra124_cpufreq_softc *sc, phandle_t node)
static void
tegra124_cpufreq_identify(driver_t *driver, device_t parent)
{
phandle_t root;
root = OF_finddevice("/");
if (!ofw_bus_node_is_compatible(root, "nvidia,tegra124"))
return;
if (device_get_unit(parent) != 0)
return;

View File

@ -120,18 +120,18 @@ tegra124_cpu_reset(platform_t plat)
/*
* Early putc routine for EARLY_PRINTF support. To use, add to kernel config:
* option SOCDEV_PA=0x02000000
* option SOCDEV_VA=0x02000000
* option SOCDEV_PA=0x70000000
* option SOCDEV_VA=0x70000000
* option EARLY_PRINTF
*/
#if 0
#ifdef EARLY_PRINTF
static void
tegra124_early_putc(int c)
{
volatile uint32_t * UART_STAT_REG = (uint32_t *)0x02020098;
volatile uint32_t * UART_TX_REG = (uint32_t *)0x02020040;
const uint32_t UART_TXRDY = (1 << 3);
volatile uint32_t * UART_STAT_REG = (uint32_t *)(0x70006314);
volatile uint32_t * UART_TX_REG = (uint32_t *)(0x70006300);
const uint32_t UART_TXRDY = (1 << 6);
while ((*UART_STAT_REG & UART_TXRDY) == 0)
continue;
*UART_TX_REG = c;

View File

@ -288,14 +288,8 @@ static int
exynos_xhci_detach(device_t dev)
{
struct exynos_xhci_softc *esc = device_get_softc(dev);
device_t bdev;
int err;
if (esc->base.sc_bus.bdev != NULL) {
bdev = esc->base.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* During module unload there are lots of children leftover */
device_delete_children(dev);

View File

@ -366,14 +366,10 @@ static int
musbotg_detach(device_t dev)
{
struct musbotg_super_softc *sc = device_get_softc(dev);
device_t bdev;
int err;
if (sc->sc_otg.sc_bus.bdev) {
bdev = sc->sc_otg.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(dev);
if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
/*
@ -397,9 +393,6 @@ musbotg_detach(device_t dev)
bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
sc->sc_otg.sc_irq_res);
/* during module unload there are lots of children leftover */
device_delete_children(dev);
return (0);
}

View File

@ -392,15 +392,8 @@ omap_ehci_detach(device_t dev)
{
struct omap_ehci_softc *isc = device_get_softc(dev);
ehci_softc_t *sc = &isc->base;
device_t bdev;
int err;
if (sc->sc_bus.bdev) {
bdev = sc->sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(dev);

View File

@ -323,20 +323,17 @@ zy7_ehci_detach(device_t dev)
{
ehci_softc_t *sc = device_get_softc(dev);
/* during module unload there are lots of children leftover */
device_delete_children(dev);
sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
if (device_is_attached(dev))
bus_generic_detach(dev);
if (sc->sc_irq_res && sc->sc_intr_hdl)
/* call ehci_detach() after ehci_init() called after
* successful bus_setup_intr().
*/
ehci_detach(sc);
if (sc->sc_bus.bdev) {
device_detach(sc->sc_bus.bdev);
device_delete_child(dev, sc->sc_bus.bdev);
}
if (sc->sc_irq_res) {
if (sc->sc_intr_hdl != NULL)
bus_teardown_intr(dev, sc->sc_irq_res,

View File

@ -341,6 +341,8 @@ get_fpcontext(struct thread *td, mcontext_t *mcp)
KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate,
("Called get_fpcontext while the kernel is using the VFP"));
KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
("Non-userspace FPU flags set in get_fpcontext"));
memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs,
sizeof(mcp->mc_fpregs));
mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr;
@ -376,7 +378,7 @@ set_fpcontext(struct thread *td, mcontext_t *mcp)
sizeof(mcp->mc_fpregs));
curpcb->pcb_fpustate.vfp_fpcr = mcp->mc_fpregs.fp_cr;
curpcb->pcb_fpustate.vfp_fpsr = mcp->mc_fpregs.fp_sr;
curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags;
curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK;
}
critical_exit();

View File

@ -282,9 +282,17 @@ do_el1h_sync(struct trapframe *frame)
switch(exception) {
case EXCP_FP_SIMD:
case EXCP_TRAP_FP:
print_registers(frame);
printf(" esr: %.8lx\n", esr);
panic("VFP exception in the kernel");
#ifdef VFP
if ((curthread->td_pcb->pcb_fpflags & PCB_FP_KERN) != 0) {
vfp_restore_state();
} else
#endif
{
print_registers(frame);
printf(" esr: %.8lx\n", esr);
panic("VFP exception in the kernel");
}
break;
case EXCP_INSN_ABORT:
case EXCP_DATA_ABORT:
far = READ_SPECIALREG(far_el1);
@ -409,6 +417,12 @@ do_el0_sync(struct trapframe *frame)
userret(td, frame);
break;
}
KASSERT((curthread->td_pcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0,
("Kernel VFP flags set while entering userspace"));
KASSERT(
curthread->td_pcb->pcb_fpusaved == &curthread->td_pcb->pcb_fpustate,
("Kernel VFP state in use when entering userspace"));
}
void

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2015 The FreeBSD Foundation
* Copyright (c) 2015-2016 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Andrew Turner under
@ -48,6 +48,14 @@ CTASSERT(sizeof(((struct pcb *)0)->pcb_fpustate.vfp_regs) == 16 * 32);
static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx",
"Kernel contexts for VFP state");
struct fpu_kern_ctx {
struct vfpstate *prev;
#define FPU_KERN_CTX_DUMMY 0x01 /* avoided save for the kern thread */
#define FPU_KERN_CTX_INUSE 0x02
uint32_t flags;
struct vfpstate state;
};
static void
vfp_enable(void)
{
@ -71,9 +79,10 @@ vfp_disable(void)
}
/*
* Called when the thread is dying. If the thread was the last to use the
* VFP unit mark it as unused to tell the kernel the fp state is unowned.
* Ensure the VFP unit is off so we get an exception on the next access.
* Called when the thread is dying or when discarding the kernel VFP state.
* If the thread was the last to use the VFP unit mark it as unused to tell
* the kernel the fp state is unowned. Ensure the VFP unit is off so we get
* an exception on the next access.
*/
void
vfp_discard(struct thread *td)
@ -226,4 +235,111 @@ vfp_init(void)
SYSINIT(vfp, SI_SUB_CPU, SI_ORDER_ANY, vfp_init, NULL);
struct fpu_kern_ctx *
fpu_kern_alloc_ctx(u_int flags)
{
struct fpu_kern_ctx *res;
size_t sz;
sz = sizeof(struct fpu_kern_ctx);
res = malloc(sz, M_FPUKERN_CTX, ((flags & FPU_KERN_NOWAIT) ?
M_NOWAIT : M_WAITOK) | M_ZERO);
return (res);
}
void
fpu_kern_free_ctx(struct fpu_kern_ctx *ctx)
{
KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("free'ing inuse ctx"));
/* XXXAndrew clear the memory ? */
free(ctx, M_FPUKERN_CTX);
}
int
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
{
struct pcb *pcb;
pcb = td->td_pcb;
KASSERT(ctx == NULL || (ctx->flags & FPU_KERN_CTX_INUSE) == 0,
("using inuse ctx"));
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
return (0);
}
/*
* Check either we are already using the VFP in the kernel, or
* the the saved state points to the default user space.
*/
KASSERT((pcb->pcb_fpflags & PCB_FP_KERN) != 0 ||
pcb->pcb_fpusaved == &pcb->pcb_fpustate,
("Mangled pcb_fpusaved %x %p %p", pcb->pcb_fpflags, pcb->pcb_fpusaved, &pcb->pcb_fpustate));
ctx->flags = FPU_KERN_CTX_INUSE;
vfp_save_state(curthread, pcb);
ctx->prev = pcb->pcb_fpusaved;
pcb->pcb_fpusaved = &ctx->state;
pcb->pcb_fpflags |= PCB_FP_KERN;
pcb->pcb_fpflags &= ~PCB_FP_STARTED;
return (0);
}
int
fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx)
{
struct pcb *pcb;
pcb = td->td_pcb;
KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) != 0,
("FPU context not inuse"));
ctx->flags &= ~FPU_KERN_CTX_INUSE;
if (is_fpu_kern_thread(0) &&
(ctx->flags & FPU_KERN_CTX_DUMMY) != 0)
return (0);
KASSERT((ctx->flags & FPU_KERN_CTX_DUMMY) == 0, ("dummy ctx"));
critical_enter();
vfp_discard(td);
critical_exit();
pcb->pcb_fpflags &= ~PCB_FP_STARTED;
pcb->pcb_fpusaved = ctx->prev;
if (pcb->pcb_fpusaved == &pcb->pcb_fpustate) {
pcb->pcb_fpflags &= ~PCB_FP_KERN;
} else {
KASSERT((pcb->pcb_fpflags & PCB_FP_KERN) != 0,
("unpaired fpu_kern_leave"));
}
return (0);
}
int
fpu_kern_thread(u_int flags)
{
struct pcb *pcb = curthread->td_pcb;
KASSERT((curthread->td_pflags & TDP_KTHREAD) != 0,
("Only kthread may use fpu_kern_thread"));
KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate,
("Mangled pcb_fpusaved"));
KASSERT((pcb->pcb_fpflags & PCB_FP_KERN) == 0,
("Thread already setup for the VFP"));
pcb->pcb_fpflags |= PCB_FP_KERN;
return (0);
}
int
is_fpu_kern_thread(u_int flags)
{
struct pcb *curpcb;
if ((curthread->td_pflags & TDP_KTHREAD) == 0)
return (0);
curpcb = curthread->td_pcb;
return ((curpcb->pcb_fpflags & PCB_FP_KERN) != 0);
}
#endif

View File

@ -94,6 +94,9 @@ options SOC_HISI_HI6220
# Annapurna Alpine drivers
device al_ccu # Alpine Cache Coherency Unit
device al_nb_service # Alpine North Bridge Service
device al_iofic # I/O Fabric Interrupt Controller
device al_serdes # Serializer/Deserializer
device al_udma # Universal DMA
# VirtIO support
device virtio
@ -119,6 +122,7 @@ device igb # Intel PRO/1000 PCIE Server Gigabit Family
device ix # Intel 10Gb Ethernet Family
device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet
device vnic # Cavium ThunderX NIC
device al_eth # Annapurna Alpine Ethernet NIC
# Block devices
device ahci
@ -129,6 +133,7 @@ device da
device pass # Passthrough device (direct ATA/SCSI access)
# MMC/SD/SDIO Card slot support
device sdhci
device aw_mmc # Allwinner SD/MMC controller
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
@ -152,13 +157,19 @@ device usb # USB Bus (required)
device ukbd # Keyboard
device umass # Disks/Mass storage - Requires scbus and da
# USB ethernet support
device smcphy
device smsc
# GPIO
device aw_gpio # Allwinner GPIO controller
device gpio
device gpioled
device fdt_pinctrl
# I2C
device aw_rsb # Allwinner Reduced Serial Bus
device bcm2835_bsc # Broadcom BCM283x I2C bus
device iicbus
# Clock and reset controllers
@ -182,6 +193,14 @@ device aw_sid # Allwinner Secure ID EFUSE
# Thermal sensors
device aw_thermal # Allwinner Thermal Sensor Controller
# SPI
device spibus
device bcm2835_spi # Broadcom BCM283x SPI bus
# Console
device vt
device kbdmux
# Pseudo devices.
device loop # Network loopback
device random # Entropy device

25
sys/arm64/conf/GENERIC-UP Normal file
View File

@ -0,0 +1,25 @@
#
# GENERIC -- Generic kernel configuration file for FreeBSD/arm64 with SMP disabled
#
# 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$
include GENERIC
ident GENERIC-UP
nooptions SMP
options SOC_BRCM_BCM2837

View File

@ -1,157 +0,0 @@
#
#
# RPI3 -- Custom configuration for the Raspberry Pi 3
#
# 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$
cpu ARM64
ident RPI3
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
#makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support
options SCHED_ULE # ULE scheduler
options PREEMPTION # Enable kernel thread preemption
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options IPSEC # IP (v4/v6) security
options TCP_HHOOK # hhook(9) framework for TCP
options TCP_OFFLOAD # TCP offload
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 QUOTA # Enable disk quotas for UFS
options MD_ROOT # MD is a potential root device
options NFSCL # Network Filesystem Client
options NFSD # Network Filesystem Server
options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
options MSDOSFS # MSDOS Filesystem
options CD9660 # ISO 9660 Filesystem
options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
options GEOM_PART_GPT # GUID Partition Tables.
options GEOM_RAID # Soft RAID functionality.
options GEOM_LABEL # Provides labelization
options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
options KTRACE # ktrace(1) support
options STACK # stack(9) 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 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 KDTRACE_FRAME # Ensure frames are compiled in
options KDTRACE_HOOKS # Kernel DTrace hooks
options VFP # Floating-point support
options RACCT # Resource accounting framework
options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
options RCTL # Resource limits
# SMP is not there yet
# options SMP
options INTRNG
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
options KDB_TRACE # Print a stack trace for a panic.
# For full debugger support use (turn off in stable branch):
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
options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
options SOC_BRCM_BCM2837
options ROOTDEVNAME=\"ufs:mmcsd0s2\"
# SPI
device spibus
device bcm2835_spi
# MMC/SD/SDIO Card slot support
device sdhci
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
# Serial (COM) ports
device uart # Generic UART driver
device uart_ns8250 # ns8250-type UART driver
device pl011
# USB support
options USB_DEBUG # enable debug msgs
device usb # USB Bus (required)
device dwcotg # DWC OTG controller
# USB storage support
device scbus
device da
device umass
# USB ethernet support
device smcphy
device mii
device smsc
# Comment following lines for boot console on serial port
device vt
device kbdmux
device ukbd # Keyboard
# GPIO
device gpio
device fdt_pinctrl
device gpioled
# I2C
device iicbus
device bcm2835_bsc
# Not ready for ARM64 yet
# device vchiq
# device sound
# Pseudo devices.
device bpf
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 firmware # firmware assist module
device psci # Support for ARM PSCI
options FDT
# The crypto framework is required by IPSEC
device crypto # Required by IPSEC

View File

@ -54,6 +54,9 @@ struct pcb {
struct vfpstate *pcb_fpusaved;
int pcb_fpflags;
#define PCB_FP_STARTED 0x01
#define PCB_FP_KERN 0x02
/* The bits passed to userspace in get_fpcontext */
#define PCB_FP_USERMASK (PCB_FP_STARTED)
u_int pcb_vfpcpu; /* Last cpu this thread ran VFP code */
/*

View File

@ -45,6 +45,23 @@ void vfp_init(void);
void vfp_discard(struct thread *);
void vfp_restore_state(void);
void vfp_save_state(struct thread *, struct pcb *);
struct fpu_kern_ctx;
/*
* Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread().
*/
#define FPU_KERN_NORMAL 0x0000
#define FPU_KERN_NOWAIT 0x0001
#define FPU_KERN_KTHR 0x0002
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int);
void fpu_kern_free_ctx(struct fpu_kern_ctx *);
int fpu_kern_enter(struct thread *, struct fpu_kern_ctx *, u_int);
int fpu_kern_leave(struct thread *, struct fpu_kern_ctx *);
int fpu_kern_thread(u_int);
int is_fpu_kern_thread(u_int);
#endif
#endif

View File

@ -159,6 +159,12 @@
interrupt-parent = <&MPIC>;
};
/* SerDes */
serdes {
compatible = "annapurna-labs,al-serdes";
reg = <0x28c0000 0x1000>;
};
serial0: serial@2883000 {
compatible = "ns16550";
reg = <0x2883000 0x20>;
@ -170,6 +176,16 @@
};
};
/* MSIX Configuration */
msix: msix {
compatible = "annapurna-labs,al-msix";
#address-cells = <2>;
#size-cells = <1>;
reg = <0xfbe00000 0x100000>;
interrupts = <0 96 1 0 159 1>;
interrupt-parent = <&MPIC>;
};
pcie-internal {
compatible = "annapurna-labs,al-internal-pcie";
device_type = "pci";
@ -182,6 +198,7 @@
<0x3800 0 0 1 &MPIC 0 36 4>,
<0x4000 0 0 1 &MPIC 0 43 4>, // SATA 0 (PCIe expander)
<0x4800 0 0 1 &MPIC 0 44 1>; // SATA 1 (onboard)
msi-parent = <&msix>;
// ranges:
// - ECAM - non prefetchable config space

Some files were not shown because too many files have changed in this diff Show More