Merge from head r290483

This commit is contained in:
Baptiste Daroussin 2015-11-07 11:02:33 +00:00
commit 3e4f384ed2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/collation/; revision=290484
263 changed files with 5264 additions and 1761 deletions

View File

@ -26,7 +26,38 @@ sub-system.
subsystem login notes
-----------------------------
opencrypto jmg Pre-commit review requested. Documentation Required.
kqueue jmg Pre-commit review requested. Documentation Required.
share/mk imp, bapt, bdrewery, emaste, sjg Make is hard.
ath(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
net80211 adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
iwn(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
iwm(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
otus(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
dev/usb/wlan adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
openssl benl,jkim Pre-commit review requested.
release/release.sh gjb,re Pre-commit review and regression tests
requested.
sh(1) jilles Pre-commit review requested. This also applies
to kill(1), printf(1) and test(1) which are
compiled in as builtins.
isci(4) jimharris Pre-commit review requested.
nvme(4) jimharris Pre-commit review requested.
nvd(4) jimharris Pre-commit review requested.
nvmecontrol(8) jimharris Pre-commit review requested.
libfetch des Advance notification requested.
fetch des Advance notification requested.
libpam des Pre-commit review requested.
openssh des Pre-commit review requested.
pseudofs des Pre-commit review requested.
procfs des Pre-commit review requested.
linprocfs des Pre-commit review requested.
contrib/compiler-rt dim Pre-commit review preferred.
contrib/libc++ dim Pre-commit review preferred.
contrib/libcxxrt dim Pre-commit review preferred.
contrib/llvm dim Pre-commit review preferred.
contrib/llvm/tools/lldb emaste Pre-commit review preferred.
---- OLD ----
libc/posix1e rwatson Pre-commit review requested.
POSIX.1e ACLs rwatson Pre-commit review requested.
UFS EAs rwatson Pre-commit review requested.
@ -34,7 +65,6 @@ MAC Framework rwatson Pre-commit review requested.
MAC Modules rwatson Pre-commit review requested.
contrib/openbsm rwatson Pre-commit review requested.
sys/security/audit rwatson Pre-commit review requested.
ath(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
ahc(4) gibbs Pre-commit review requested.
ahd(4) gibbs Pre-commit review requested.
pci bus imp,jhb Pre-commit review requested.
@ -57,20 +87,11 @@ etc/mail gshapiro Pre-commit review requested.
Keep in sync with -STABLE.
etc/sendmail gshapiro Pre-commit review requested.
Keep in sync with -STABLE.
libfetch des Advance notification requested.
fetch des Advance notification requested.
libpam des Pre-commit review requested.
openssh des Pre-commit review requested.
pseudofs des Pre-commit review requested.
procfs des Pre-commit review requested.
linprocfs des Pre-commit review requested.
lpr gad Pre-commit review requested, particularly for
lpd/recvjob.c and lpd/printjob.c.
net80211 adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
nvi peter Try not to break it.
libz peter Try not to break it.
groff ru Recommends pre-commit review.
share/mk imp, bapt, bdrewery, emaste, sjg Make is hard.
ipfw ipfw Pre-commit review preferred. send to ipfw@freebsd.org
drm rnoland Just keep me informed of changes, try not to break it.
unifdef(1) fanf Pre-commit review requested.
@ -102,7 +123,6 @@ linux emul emulation Please discuss changes here.
bs{diff,patch} cperciva Pre-commit review requested.
portsnap cperciva Pre-commit review requested.
freebsd-update cperciva Pre-commit review requested.
openssl benl,jkim Pre-commit review requested.
sys/dev/usb hselasky If in doubt, ask.
sys/dev/sound/usb hselasky If in doubt, ask.
sys/compat/linuxkpi hselasky If in doubt, ask.
@ -120,18 +140,8 @@ usr.sbin/zic edwin Heads-up appreciated, since this code is
lib/libc/stdtime edwin Heads-up appreciated, since parts of this code
is maintained by a third party source.
sbin/routed bms Pre-commit review; notify vendor at rhyolite.com
isci(4) jimharris Pre-commit review requested.
cmx daniel@roe.ch Pre-commit review preferred.
filemon obrien Pre-commit review preferred.
sysdoc trhodes Pre-commit review preferred.
sh(1) jilles Pre-commit review requested. This also applies
to kill(1), printf(1) and test(1) which are
compiled in as builtins.
nvme(4) jimharris Pre-commit review requested.
nvd(4) jimharris Pre-commit review requested.
nvmecontrol(8) jimharris Pre-commit review requested.
release/release.sh gjb Pre-commit review and regression tests
requested.
nanobsd imp Pre-commit review requested for coordination.
vmm(4) neel,grehan Pre-commit review requested.
opencrypto jmg Pre-commit review requested. Documentation Required.

View File

@ -27,7 +27,7 @@
# when NO_ROOT is set. (default: ${DESTDIR}/METALOG)
# TARGET="machine" to crossbuild world for a different machine type
# TARGET_ARCH= may be required when a TARGET supports multiple endians
# BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh)
# BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
# WORLD_FLAGS= additional flags to pass to make(1) during buildworld
# KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
# SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
@ -48,9 +48,15 @@
.error "Both TARGET and TARGET_ARCH must be defined."
.endif
.include "share/mk/src.opts.mk"
.include <bsd.arch.inc.mk>
.include <bsd.compiler.mk>
# Cross toolchain changes must be in effect before bsd.compiler.mk
# so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
.if defined(CROSS_TOOLCHAIN)
LOCALBASE?= /usr/local
.include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
.endif
.include <bsd.compiler.mk> # don't depend on src.opts.mk doing it
.include "share/mk/src.opts.mk"
# We must do lib/ and libexec/ before bin/ in case of a mid-install error to
# keep the users system reasonably usable. For static->dynamic root upgrades,
@ -139,7 +145,7 @@ CLEANDIR= cleandir
LOCAL_TOOL_DIRS?=
BUILDENV_SHELL?=/bin/sh
BUILDENV_SHELL?=${SHELL}
SVN?= /usr/local/bin/svn
SVNFLAGS?= -r HEAD
@ -254,7 +260,7 @@ INSTALLTMP!= /usr/bin/mktemp -d -u -t install
BOOTSTRAPPING?= 0
# Common environment for world related stages
CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
MACHINE_ARCH=${TARGET_ARCH} \
MACHINE=${TARGET} \
CPUTYPE=${TARGET_CPUTYPE}
@ -329,10 +335,6 @@ HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
.endif
.if defined(CROSS_TOOLCHAIN)
LOCALBASE?= /usr/local
.include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
.endif
.if defined(CROSS_TOOLCHAIN_PREFIX)
CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
@ -369,7 +371,7 @@ X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
X${BINUTIL}?= ${${BINUTIL}}
.endif
.endfor
WMAKEENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCFLAGS} ${XCXXFLAGS}" \
DEPFLAGS="${DEPFLAGS}" \
CPP="${XCPP} ${XCFLAGS}" \
AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
@ -771,7 +773,7 @@ buildworld_epilogue:
# modification of the current environment's PATH. In addition, we need
# to quote multiword values.
#
buildenvvars:
buildenvvars: .PHONY
@echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
.if ${.TARGETS:Mbuildenv}
@ -779,9 +781,11 @@ buildenvvars:
.error The buildenv target is incompatible with -j
.endif
.endif
buildenv:
BUILDENV_DIR?= ${.CURDIR}
buildenv: .PHONY
@echo Entering world for ${TARGET_ARCH}:${TARGET}
@cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true
@cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \
|| true
TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32}
toolchain: ${TOOLCHAIN_TGTS}
@ -1367,10 +1371,10 @@ _sed= usr.bin/sed
.endif
.if ${BOOTSTRAPPING} < 1000002
_libohash= lib/libohash
_libopenbsd= lib/libopenbsd
_m4= usr.bin/m4
${_bt}-usr.bin/m4: ${_bt}-lib/libohash
${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd
.endif
.if ${BOOTSTRAPPING} < 1000026
@ -1443,10 +1447,10 @@ _kerberos5_bootstrap_tools= \
.endif
.if ${MK_MANDOCDB} != "no"
_libohash?= lib/libohash
_libopenbsd?= lib/libopenbsd
_makewhatis= lib/libsqlite3 \
usr.bin/mandoc
${_bt}-usr.bin/mandoc: ${_bt}-lib/libohash ${_bt}-lib/libsqlite3
${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd ${_bt}-lib/libsqlite3
.else
_makewhatis=usr.bin/makewhatis
.endif
@ -1469,7 +1473,7 @@ bootstrap-tools: .PHONY
${_awk} \
${_cat} \
usr.bin/lorder \
${_libohash} \
${_libopenbsd} \
${_makewhatis} \
usr.bin/rpcgen \
${_sed} \

View File

@ -38,7 +38,7 @@
# xargs -n1 | sort | uniq -d;
# done
# XXXXX: String collation improvements
# 20151107: String collation improvements
OLD_FILES+=usr/share/locale/kk_KZ.PT154/LC_COLLATE
OLD_FILES+=usr/share/locale/kk_KZ.PT154/LC_CTYPE
OLD_FILES+=usr/share/locale/kk_KZ.PT154/LC_MESSAGES
@ -97,6 +97,39 @@ OLD_FILES+=usr/bin/colldef
OLD_FILES+=usr/share/man/man1/colldef.1.gz
OLD_FILES+=usr/bin/mklocale
OLD_FILES+=usr/share/man/man1/mklocale.1.gz
# 20151101: added missing _test suffix on multiple tests in lib/libc
OLD_FILES+=usr/tests/lib/libc/c063/faccessat
OLD_FILES+=usr/tests/lib/libc/c063/fchmodat
OLD_FILES+=usr/tests/lib/libc/c063/fchownat
OLD_FILES+=usr/tests/lib/libc/c063/fexecve
OLD_FILES+=usr/tests/lib/libc/c063/fstatat
OLD_FILES+=usr/tests/lib/libc/c063/linkat
OLD_FILES+=usr/tests/lib/libc/c063/mkdirat
OLD_FILES+=usr/tests/lib/libc/c063/mkfifoat
OLD_FILES+=usr/tests/lib/libc/c063/mknodat
OLD_FILES+=usr/tests/lib/libc/c063/openat
OLD_FILES+=usr/tests/lib/libc/c063/readlinkat
OLD_FILES+=usr/tests/lib/libc/c063/renameat
OLD_FILES+=usr/tests/lib/libc/c063/symlinkat
OLD_FILES+=usr/tests/lib/libc/c063/unlinkat
OLD_FILES+=usr/tests/lib/libc/c063/utimensat
OLD_FILES+=usr/tests/lib/libc/string/memchr
OLD_FILES+=usr/tests/lib/libc/string/memcpy
OLD_FILES+=usr/tests/lib/libc/string/memmem
OLD_FILES+=usr/tests/lib/libc/string/memset
OLD_FILES+=usr/tests/lib/libc/string/strcat
OLD_FILES+=usr/tests/lib/libc/string/strchr
OLD_FILES+=usr/tests/lib/libc/string/strcmp
OLD_FILES+=usr/tests/lib/libc/string/strcpy
OLD_FILES+=usr/tests/lib/libc/string/strcspn
OLD_FILES+=usr/tests/lib/libc/string/strerror
OLD_FILES+=usr/tests/lib/libc/string/strlen
OLD_FILES+=usr/tests/lib/libc/string/strpbrk
OLD_FILES+=usr/tests/lib/libc/string/strrchr
OLD_FILES+=usr/tests/lib/libc/string/strspn
OLD_FILES+=usr/tests/lib/libc/string/swab
# 20151101: 430.status-rwho was renamed to 430.status-uptime
OLD_FILES+=etc/periodic/daily/430.status-rwho
# 20151030: OpenSSL 1.0.2d import
OLD_FILES+=usr/share/openssl/man/man3/CMS_set1_signer_certs.3.gz
OLD_FILES+=usr/share/openssl/man/man3/EVP_PKEY_ctrl.3.gz

View File

@ -32,7 +32,7 @@
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\" $FreeBSD$
.\"
.Dd April 25, 2013
.Dd November 7, 2015
.Dt RM 1
.Os
.Sh NAME
@ -234,7 +234,7 @@ not the standard error output.
The
.Nm
command conforms to
.St -p1003.2 .
.St -p1003.1-2013 .
.Pp
The simplified
.Nm unlink

View File

@ -155,8 +155,7 @@ main(int argc, char *argv[])
}
checkdot(argv);
if (getenv("POSIXLY_CORRECT") == NULL)
checkslash(argv);
checkslash(argv);
uid = geteuid();
(void)signal(SIGINFO, siginfo);

View File

@ -750,7 +750,7 @@ isdeclarationcmd(struct narg *arg)
}
static void
xtracecommand(struct arglist *varlist, struct arglist *arglist)
xtracecommand(struct arglist *varlist, int argc, char **argv)
{
char sep = 0;
const char *text, *p, *ps4;
@ -771,8 +771,8 @@ xtracecommand(struct arglist *varlist, struct arglist *arglist)
out2qstr(text);
sep = ' ';
}
for (i = 0; i < arglist->count; i++) {
text = arglist->args[i];
for (i = 0; i < argc; i++) {
text = argv[i];
if (sep != 0)
out2c(' ');
out2qstr(text);
@ -849,6 +849,8 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
do_clearcmdentry = 0;
oexitstatus = exitstatus;
exitstatus = 0;
/* Add one slot at the beginning for tryexec(). */
appendarglist(&arglist, nullstr);
for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
if (varflag && isassignment(argp->narg.text)) {
expandarg(argp, varflag == 1 ? &varlist : &arglist,
@ -858,13 +860,11 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
varflag = isdeclarationcmd(&argp->narg) ? 2 : 0;
expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
}
appendarglist(&arglist, nullstr);
expredir(cmd->ncmd.redirect);
argc = arglist.count;
/* Add one slot at the beginning for tryexec(). */
argv = stalloc(sizeof (char *) * (argc + 2));
argv++;
argc = arglist.count - 2;
argv = &arglist.args[1];
memcpy(argv, arglist.args, sizeof(*argv) * argc);
argv[argc] = NULL;
lastarg = NULL;
if (iflag && funcnest == 0 && argc > 0)
@ -872,7 +872,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
/* Print the command if xflag is set. */
if (xflag)
xtracecommand(&varlist, &arglist);
xtracecommand(&varlist, argc, argv);
/* Now locate the command. */
if (argc == 0) {

View File

@ -114,7 +114,6 @@ static void expmeta(char *, char *, struct arglist *);
static int expsortcmp(const void *, const void *);
static int patmatch(const char *, const char *, int);
static char *cvtnum(int, char *);
static void appendarglist(struct arglist *, char *);
static int collate_range_cmp(wchar_t, wchar_t);
void
@ -126,7 +125,7 @@ emptyarglist(struct arglist *list)
list->capacity = sizeof(list->smallarg) / sizeof(list->smallarg[0]);
}
static void
void
appendarglist(struct arglist *list, char *str)
{
char **newargs;

View File

@ -52,6 +52,7 @@ struct arglist {
void emptyarglist(struct arglist *);
void appendarglist(struct arglist *, char *);
union node;
void expandarg(union node *, struct arglist *, int);
void rmescapes(char *);

View File

@ -28,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 23, 2013
.Dd November 3, 2015
.Dt BACKTRACE 3
.Os
.Sh NAME
@ -47,7 +47,7 @@
.Ft "char **"
.Fn backtrace_symbols_fmt "void * const *addrlist" "size_t len" "const char *fmt"
.Ft int
.Fn backtrace_symbols_fmt_fd "void * const *addrlist" "size_t len" "const char *fmt" "int fd"
.Fn backtrace_symbols_fd_fmt "void * const *addrlist" "size_t len" "const char *fmt" "int fd"
.Sh DESCRIPTION
The
.Fn backtrace
@ -106,7 +106,7 @@ with a format argument of
The
.Fn backtrace_symbols_fd
and
.Fn backtrace_symbols_fmt_fd
.Fn backtrace_symbols_fd_fmt
are similar to the non _fd named functions, only instead of returning
an array or strings, they print a new-line separated array of strings in
fd, and return

View File

@ -7,7 +7,7 @@
.\" # LICENSE.
.\" # Phil Shafer, July 2014
.\"
.Dd December 4, 2014
.Dd November 6, 2015
.Dt LIBXO 3
.Os
.Sh NAME
@ -367,7 +367,7 @@ particular output styles:
.It l "leaf-list " "Field is a leaf-list, a list of leaf values"
.It n "no-quotes " "Do not quote the field when using JSON style"
.It q "quotes " "Quote the field when using JSON style"
.It q "trim " "Trim leading and trailing whitespace"
.It t "trim " "Trim leading and trailing whitespace"
.It w "white space " "A blank ("" "") is appended after the label"
.El
.Pp

View File

@ -115,8 +115,8 @@ daily_status_network_enable="YES" # Check network status
daily_status_network_usedns="YES" # DNS lookups are ok
daily_status_network_netstat_flags="-d" # netstat(1) flags
# 430.status-rwho
daily_status_rwho_enable="YES" # Check system status
# 430.status-uptime
daily_status_uptime_enable="YES" # Check system uptime
# 440.status-mailq
daily_status_mailq_enable="YES" # Check mail status

View File

@ -11,7 +11,7 @@ then
source_periodic_confs
fi
case "$daily_status_rwho_enable" in
case "$daily_status_uptime_enable" in
[Yy][Ee][Ss])
rwho=$(echo /var/rwho/*)
if [ -f "${rwho%% *}" ]

View File

@ -15,6 +15,7 @@ FILES= 100.clean-disks \
408.status-gstripe \
409.status-gconcat \
420.status-network \
430.status-uptime \
450.status-security \
510.status-world-kernel \
999.local
@ -38,8 +39,7 @@ FILES+= 480.status-ntpd
.endif
.if ${MK_RCMDS} != "no"
FILES+= 140.clean-rwho \
430.status-rwho
FILES+= 140.clean-rwho
.endif
.if ${MK_SENDMAIL} != "no"

View File

@ -44,7 +44,7 @@ rc=0
if check_yesno_period security_status_pfdenied_enable
then
TMP=`mktemp -t security`
if pfctl -sr -v 2>/dev/null | nawk '{if (/^block/) {buf=$0; getline; gsub(" +"," ",$0); print buf$0;} }' > ${TMP}; then
if pfctl -sr -v 2>/dev/null | nawk '{if (/^block/) {buf=$0; getline; gsub(" +"," ",$0); if ($5 > 0) print buf$0;} }' > ${TMP}; then
check_diff new_only pf ${TMP} "${host} pf denied packets:"
fi
rc=$?

View File

@ -71,6 +71,7 @@ char *stpcpy ();
#include <fnmatch.h>
#include "savedir.h"
#include "system.h"
char *path;
size_t pathlen;

View File

@ -327,9 +327,9 @@ int close(int);
void closefrom(int);
int dup(int);
int dup2(int, int);
int execl(const char *, const char *, ...) __sentinel;
int execl(const char *, const char *, ...) __null_sentinel;
int execle(const char *, const char *, ...);
int execlp(const char *, const char *, ...) __sentinel;
int execlp(const char *, const char *, ...) __null_sentinel;
int execv(const char *, char * const *);
int execve(const char *, char * const *, char * const *);
int execvp(const char *, char * const *);

View File

@ -75,7 +75,7 @@ SUBDIR= ${SUBDIR_ORDERED} \
${_libnetgraph} \
${_libngatm} \
libnv \
libohash \
libopenbsd \
libopie \
libpam \
libpcap \

View File

@ -122,7 +122,8 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen,
afd = find_afd(sa->sa_family);
if (afd == NULL)
return (EAI_FAMILY);
if (sa->sa_family == PF_LOCAL) {
switch (sa->sa_family) {
case PF_LOCAL:
/*
* PF_LOCAL uses variable sa->sa_len depending on the
* content length of sun_path. Require 1 byte in
@ -132,8 +133,17 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen,
salen <= afd->a_socklen -
sizeofmember(struct sockaddr_un, sun_path))
return (EAI_FAIL);
} else if (salen != afd->a_socklen)
return (EAI_FAIL);
break;
case PF_LINK:
if (salen <= afd->a_socklen -
sizeofmember(struct sockaddr_dl, sdl_data))
return (EAI_FAIL);
break;
default:
if (salen != afd->a_socklen)
return (EAI_FAIL);
break;
}
return ((*afd->a_func)(afd, sa, salen, host, hostlen,
serv, servlen, flags));

View File

@ -636,13 +636,10 @@ rpc_broadcast_exp(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc,
} /* The giant for loop */
done_broad:
if (inbuf)
(void) free(inbuf);
if (outbuf)
(void) free(outbuf);
free(inbuf);
free(outbuf);
#ifdef PORTMAP
if (outbuf_pmap)
(void) free(outbuf_pmap);
free(outbuf_pmap);
#endif /* PORTMAP */
for (i = 0; i < fdlistno; i++) {
(void)_close(fdlist[i].fd);

View File

@ -651,8 +651,7 @@ clnt_vc_destroy(CLIENT *cl)
(void)_close(ct->ct_fd);
}
XDR_DESTROY(&(ct->ct_xdrs));
if (ct->ct_addr.buf)
free(ct->ct_addr.buf);
free(ct->ct_addr.buf);
mem_free(ct, sizeof(struct ct_data));
if (cl->cl_netid && cl->cl_netid[0])
mem_free(cl->cl_netid, strlen(cl->cl_netid) +1);

View File

@ -164,8 +164,7 @@ __nc_error(void)
if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
nc_addr = (int *)malloc(sizeof (int));
if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
if (nc_addr)
free(nc_addr);
free(nc_addr);
return (&nc_error);
}
*nc_addr = 0;
@ -417,7 +416,7 @@ endnetconfig(void *handlep)
while (q != NULL) {
p = q->next;
if (q->ncp->nc_lookups != NULL) free(q->ncp->nc_lookups);
free(q->ncp->nc_lookups);
free(q->ncp);
free(q->linep);
free(q);
@ -537,8 +536,7 @@ freenetconfigent(struct netconfig *netconfigp)
{
if (netconfigp != NULL) {
free(netconfigp->nc_netid); /* holds all netconfigp's strings */
if (netconfigp->nc_lookups != NULL)
free(netconfigp->nc_lookups);
free(netconfigp->nc_lookups);
free(netconfigp);
}
return;
@ -628,8 +626,7 @@ parse_ncp(char *stringp, struct netconfig *ncp)
} else {
char *cp; /* tmp string */
if (ncp->nc_lookups != NULL) /* from last visit */
free(ncp->nc_lookups);
free(ncp->nc_lookups); /* from last visit */
ncp->nc_lookups = NULL;
ncp->nc_nlookups = 0;
while ((cp = tokenp) != NULL) {

View File

@ -106,8 +106,7 @@ __rpc_createerr(void)
rce_addr = (struct rpc_createerr *)
malloc(sizeof (struct rpc_createerr));
if (thr_setspecific(rce_key, (void *) rce_addr) != 0) {
if (rce_addr)
free(rce_addr);
free(rce_addr);
return (&rpc_createerr);
}
memset(rce_addr, 0, sizeof (struct rpc_createerr));

View File

@ -432,8 +432,7 @@ clntunix_create(struct sockaddr_un *raddr, u_long prog, u_long vers, int *sockp,
if ((raddr->sun_len == 0) ||
((svcaddr = malloc(sizeof(struct netbuf))) == NULL ) ||
((svcaddr->buf = malloc(sizeof(struct sockaddr_un))) == NULL)) {
if (svcaddr != NULL)
free(svcaddr);
free(svcaddr);
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
return(cl);

View File

@ -179,8 +179,7 @@ delete_cache(struct netbuf *addr)
free(cptr->ac_netid);
free(cptr->ac_taddr->buf);
free(cptr->ac_taddr);
if (cptr->ac_uaddr)
free(cptr->ac_uaddr);
free(cptr->ac_uaddr);
if (prevptr)
prevptr->ac_next = cptr->ac_next;
else
@ -216,14 +215,10 @@ add_cache(const char *host, const char *netid, struct netbuf *taddr,
ad_cache->ac_taddr->buf = (char *) malloc(taddr->len);
if (ad_cache->ac_taddr->buf == NULL) {
out:
if (ad_cache->ac_host)
free(ad_cache->ac_host);
if (ad_cache->ac_netid)
free(ad_cache->ac_netid);
if (ad_cache->ac_uaddr)
free(ad_cache->ac_uaddr);
if (ad_cache->ac_taddr)
free(ad_cache->ac_taddr);
free(ad_cache->ac_host);
free(ad_cache->ac_netid);
free(ad_cache->ac_uaddr);
free(ad_cache->ac_taddr);
free(ad_cache);
return;
}
@ -256,8 +251,7 @@ add_cache(const char *host, const char *netid, struct netbuf *taddr,
free(cptr->ac_netid);
free(cptr->ac_taddr->buf);
free(cptr->ac_taddr);
if (cptr->ac_uaddr)
free(cptr->ac_uaddr);
free(cptr->ac_uaddr);
if (prevptr) {
prevptr->ac_next = NULL;
@ -798,10 +792,8 @@ __rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version,
malloc(remote.len)) == NULL)) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
clnt_geterr(client, &rpc_createerr.cf_error);
if (address) {
free(address);
address = NULL;
}
free(address);
address = NULL;
goto error;
}
memcpy(address->buf, remote.buf, remote.len);

View File

@ -198,8 +198,7 @@ svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers,
rwlock_wrlock(&svc_lock);
if ((s = svc_find(prog, vers, &prev, netid)) != NULL) {
if (netid)
free(netid);
free(netid);
if (s->sc_dispatch == dispatch)
goto rpcb_it; /* he is registering another xptr */
rwlock_unlock(&svc_lock);
@ -207,8 +206,7 @@ svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers,
}
s = mem_alloc(sizeof (struct svc_callout));
if (s == NULL) {
if (netid)
free(netid);
free(netid);
rwlock_unlock(&svc_lock);
return (FALSE);
}

View File

@ -406,8 +406,7 @@ svc_dg_destroy(SVCXPRT *xprt)
(void) mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen);
if (xprt->xp_ltaddr.buf)
(void) mem_free(xprt->xp_ltaddr.buf, xprt->xp_ltaddr.maxlen);
if (xprt->xp_tp)
(void) free(xprt->xp_tp);
free(xprt->xp_tp);
svc_xprt_free(xprt);
}

View File

@ -166,10 +166,8 @@ rpc_reg(rpcprog_t prognum, rpcvers_t versnum, rpcproc_t procnum,
if (((xdrbuf = malloc((unsigned)recvsz)) == NULL) ||
((netid = strdup(nconf->nc_netid)) == NULL)) {
warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
if (xdrbuf != NULL)
free(xdrbuf);
if (netid != NULL)
free(netid);
free(xdrbuf);
free(netid);
SVC_DESTROY(svcxprt);
break;
}

View File

@ -394,10 +394,8 @@ __svc_vc_dodestroy(SVCXPRT *xprt)
mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen);
if (xprt->xp_ltaddr.buf)
mem_free(xprt->xp_ltaddr.buf, xprt->xp_ltaddr.maxlen);
if (xprt->xp_tp)
free(xprt->xp_tp);
if (xprt->xp_netid)
free(xprt->xp_netid);
free(xprt->xp_tp);
free(xprt->xp_netid);
svc_xprt_free(xprt);
}

View File

@ -2,21 +2,21 @@
#TODO: t_o_search
NETBSD_ATF_TESTS_C= faccessat
NETBSD_ATF_TESTS_C+= fchmodat
NETBSD_ATF_TESTS_C+= fchownat
NETBSD_ATF_TESTS_C+= fexecve
NETBSD_ATF_TESTS_C+= fstatat
NETBSD_ATF_TESTS_C+= linkat
NETBSD_ATF_TESTS_C+= mkdirat
NETBSD_ATF_TESTS_C+= mkfifoat
NETBSD_ATF_TESTS_C+= mknodat
NETBSD_ATF_TESTS_C+= openat
NETBSD_ATF_TESTS_C+= readlinkat
NETBSD_ATF_TESTS_C+= renameat
NETBSD_ATF_TESTS_C+= symlinkat
NETBSD_ATF_TESTS_C+= unlinkat
NETBSD_ATF_TESTS_C+= utimensat
NETBSD_ATF_TESTS_C= faccessat_test
NETBSD_ATF_TESTS_C+= fchmodat_test
NETBSD_ATF_TESTS_C+= fchownat_test
NETBSD_ATF_TESTS_C+= fexecve_test
NETBSD_ATF_TESTS_C+= fstatat_test
NETBSD_ATF_TESTS_C+= linkat_test
NETBSD_ATF_TESTS_C+= mkdirat_test
NETBSD_ATF_TESTS_C+= mkfifoat_test
NETBSD_ATF_TESTS_C+= mknodat_test
NETBSD_ATF_TESTS_C+= openat_test
NETBSD_ATF_TESTS_C+= readlinkat_test
NETBSD_ATF_TESTS_C+= renameat_test
NETBSD_ATF_TESTS_C+= symlinkat_test
NETBSD_ATF_TESTS_C+= unlinkat_test
NETBSD_ATF_TESTS_C+= utimensat_test
CFLAGS+= -D_INCOMPLETE_XOPEN_C063

View File

@ -1,10 +1,10 @@
# $FreeBSD$
NETBSD_ATF_TESTS_C= t_setjmp
NETBSD_ATF_TESTS_C+= t_threadjmp
NETBSD_ATF_TESTS_C= setjmp_test
NETBSD_ATF_TESTS_C+= threadjmp_test
DPADD.t_threadjmp+= ${LIBPTHREAD}
LDADD.t_threadjmp+= -lpthread
DPADD.threadjmp_test+= ${LIBPTHREAD}
LDADD.threadjmp_test+= -lpthread
WARNS?= 4

View File

@ -4,28 +4,28 @@
# TODO: popcount, stresep
NETBSD_ATF_TESTS_C+= memchr
NETBSD_ATF_TESTS_C+= memcpy
NETBSD_ATF_TESTS_C+= memmem
NETBSD_ATF_TESTS_C+= memset
NETBSD_ATF_TESTS_C+= strcat
NETBSD_ATF_TESTS_C+= strchr
NETBSD_ATF_TESTS_C+= strcmp
NETBSD_ATF_TESTS_C+= strcpy
NETBSD_ATF_TESTS_C+= strcspn
NETBSD_ATF_TESTS_C+= strerror
NETBSD_ATF_TESTS_C+= strlen
NETBSD_ATF_TESTS_C+= strpbrk
NETBSD_ATF_TESTS_C+= strrchr
NETBSD_ATF_TESTS_C+= strspn
NETBSD_ATF_TESTS_C+= swab
NETBSD_ATF_TESTS_C+= memchr_test
NETBSD_ATF_TESTS_C+= memcpy_test
NETBSD_ATF_TESTS_C+= memmem_test
NETBSD_ATF_TESTS_C+= memset_test
NETBSD_ATF_TESTS_C+= strcat_test
NETBSD_ATF_TESTS_C+= strchr_test
NETBSD_ATF_TESTS_C+= strcmp_test
NETBSD_ATF_TESTS_C+= strcpy_test
NETBSD_ATF_TESTS_C+= strcspn_test
NETBSD_ATF_TESTS_C+= strerror_test
NETBSD_ATF_TESTS_C+= strlen_test
NETBSD_ATF_TESTS_C+= strpbrk_test
NETBSD_ATF_TESTS_C+= strrchr_test
NETBSD_ATF_TESTS_C+= strspn_test
NETBSD_ATF_TESTS_C+= swab_test
.include "../Makefile.netbsd-tests"
LDADD.memchr+= -lmd
DPADD.memchr+= ${LIBMD}
LDADD.memchr_test+= -lmd
DPADD.memchr_test+= ${LIBMD}
LDADD.memcpy+= -lmd
DPADD.memcpy+= ${LIBMD}
LDADD.memcpy_test+= -lmd
DPADD.memcpy_test+= ${LIBMD}
.include <bsd.test.mk>

View File

@ -1,7 +1,5 @@
# $FreeBSD$
SRCDIR= ${SRCTOP}/contrib/netbsd/
.include <bsd.own.mk>
LIB= h_tls_dynamic

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org>
* Copyright (c) 2013-2015 Devin Teske <dteske@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -49,58 +49,58 @@ char gauge_color[STR_BUFSIZE] = "47b"; /* (BLUE,WHITE,ON) */
char separator[STR_BUFSIZE] = "";
/* Function prototypes */
static int setattr(struct fp_config *, uint32_t, char *, char *);
static int setbool(struct fp_config *, uint32_t, char *, char *);
static int setnum(struct fp_config *, uint32_t, char *, char *);
static int setstr(struct fp_config *, uint32_t, char *, char *);
static int setattr(struct figpar_config *, uint32_t, char *, char *);
static int setbool(struct figpar_config *, uint32_t, char *, char *);
static int setnum(struct figpar_config *, uint32_t, char *, char *);
static int setstr(struct figpar_config *, uint32_t, char *, char *);
/*
* Anatomy of DIALOGRC (~/.dialogrc by default)
* NOTE: Must appear after private function prototypes (above)
* NB: Brace-initialization of union requires cast to *first* member of union
*/
static struct fp_config dialogrc_config[] = {
/* TYPE Directive DEFAULT HANDLER */
{FP_TYPE_INT, "aspect", {(void *)0}, &setnum},
{FP_TYPE_STR, "separate_widget", {separator}, &setstr},
{FP_TYPE_INT, "tab_len", {(void *)0}, &setnum},
{FP_TYPE_BOOL, "visit_items", {(void *)0}, &setbool},
{FP_TYPE_BOOL, "use_shadow", {(void *)1}, &setbool},
{FP_TYPE_BOOL, "use_colors", {(void *)1}, &setbool},
{FP_TYPE_STR, "screen_color", {NULL}, &setattr},
{FP_TYPE_STR, "shadow_color", {NULL}, &setattr},
{FP_TYPE_STR, "dialog_color", {NULL}, &setattr},
{FP_TYPE_STR, "title_color", {NULL}, &setattr},
{FP_TYPE_STR, "border_color", {NULL}, &setattr},
{FP_TYPE_STR, "button_active_color", {NULL}, &setattr},
{FP_TYPE_STR, "button_inactive_color", {NULL}, &setattr},
{FP_TYPE_STR, "button_key_active_color", {NULL}, &setattr},
{FP_TYPE_STR, "button_key_inactive_color", {NULL}, &setattr},
{FP_TYPE_STR, "button_label_active_color", {NULL}, &setattr},
{FP_TYPE_STR, "button_label_inactive_color",{NULL}, &setattr},
{FP_TYPE_STR, "inputbox_color", {NULL}, &setattr},
{FP_TYPE_STR, "inputbox_border_color", {NULL}, &setattr},
{FP_TYPE_STR, "searchbox_color", {NULL}, &setattr},
{FP_TYPE_STR, "searchbox_title_color", {NULL}, &setattr},
{FP_TYPE_STR, "searchbox_border_color", {NULL}, &setattr},
{FP_TYPE_STR, "position_indicator_color", {NULL}, &setattr},
{FP_TYPE_STR, "menubox_color", {NULL}, &setattr},
{FP_TYPE_STR, "menubox_border_color", {NULL}, &setattr},
{FP_TYPE_STR, "item_color", {NULL}, &setattr},
{FP_TYPE_STR, "item_selected_color", {NULL}, &setattr},
{FP_TYPE_STR, "tag_color", {NULL}, &setattr},
{FP_TYPE_STR, "tag_selected_color", {NULL}, &setattr},
{FP_TYPE_STR, "tag_key_color", {NULL}, &setattr},
{FP_TYPE_STR, "tag_key_selected_color", {NULL}, &setattr},
{FP_TYPE_STR, "check_color", {NULL}, &setattr},
{FP_TYPE_STR, "check_selected_color", {NULL}, &setattr},
{FP_TYPE_STR, "uarrow_color", {NULL}, &setattr},
{FP_TYPE_STR, "darrow_color", {NULL}, &setattr},
{FP_TYPE_STR, "itemhelp_color", {NULL}, &setattr},
{FP_TYPE_STR, "form_active_text_color", {NULL}, &setattr},
{FP_TYPE_STR, "form_text_color", {NULL}, &setattr},
{FP_TYPE_STR, "form_item_readonly_color", {NULL}, &setattr},
{FP_TYPE_STR, "gauge_color", {gauge_color}, &setattr},
static struct figpar_config dialogrc_config[] = {
/* TYPE DIRECTIVE DEFAULT HANDLER */
{FIGPAR_TYPE_INT, "aspect", {(void *)0}, &setnum},
{FIGPAR_TYPE_STR, "separate_widget", {separator}, &setstr},
{FIGPAR_TYPE_INT, "tab_len", {(void *)0}, &setnum},
{FIGPAR_TYPE_BOOL, "visit_items", {(void *)0}, &setbool},
{FIGPAR_TYPE_BOOL, "use_shadow", {(void *)1}, &setbool},
{FIGPAR_TYPE_BOOL, "use_colors", {(void *)1}, &setbool},
{FIGPAR_TYPE_STR, "screen_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "shadow_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "dialog_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "title_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "border_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "button_active_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "button_inactive_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "button_key_active_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "button_key_inactive_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "button_label_active_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "button_label_inactive_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "inputbox_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "inputbox_border_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "searchbox_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "searchbox_title_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "searchbox_border_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "position_indicator_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "menubox_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "menubox_border_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "item_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "item_selected_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "tag_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "tag_selected_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "tag_key_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "tag_key_selected_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "check_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "check_selected_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "uarrow_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "darrow_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "itemhelp_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "form_active_text_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "form_text_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "form_item_readonly_color", {NULL}, &setattr},
{FIGPAR_TYPE_STR, "gauge_color", {gauge_color}, &setattr},
{0, NULL, {0}, NULL}
};
@ -108,7 +108,7 @@ static struct fp_config dialogrc_config[] = {
* figpar call-back for interpreting value as .dialogrc `Attribute'
*/
static int
setattr(struct fp_config *option, uint32_t line __unused,
setattr(struct figpar_config *option, uint32_t line __unused,
char *directive __unused, char *value)
{
char *cp = value;
@ -204,7 +204,7 @@ setattr(struct fp_config *option, uint32_t line __unused,
* figpar call-back for interpreting value as .dialogrc `Boolean'
*/
static int
setbool(struct fp_config *option, uint32_t line __unused,
setbool(struct figpar_config *option, uint32_t line __unused,
char *directive __unused, char *value)
{
@ -227,7 +227,7 @@ setbool(struct fp_config *option, uint32_t line __unused,
* figpar call-back for interpreting value as .dialogrc `Number'
*/
static int
setnum(struct fp_config *option, uint32_t line __unused,
setnum(struct figpar_config *option, uint32_t line __unused,
char *directive __unused, char *value)
{
@ -247,7 +247,7 @@ setnum(struct fp_config *option, uint32_t line __unused,
* figpar call-back for interpreting value as .dialogrc `String'
*/
static int
setstr(struct fp_config *option, uint32_t line __unused,
setstr(struct figpar_config *option, uint32_t line __unused,
char *directive __unused, char *value)
{
size_t len;
@ -315,7 +315,8 @@ parse_dialogrc(void)
}
/* Process file (either $DIALOGRC if set, or `$HOME/.dialogrc') */
res = parse_config(dialogrc_config, path, NULL, FP_BREAK_ON_EQUALS);
res = parse_config(dialogrc_config,
path, NULL, FIGPAR_BREAK_ON_EQUALS);
/* Set some globals based on what we parsed */
use_shadow = dialogrc_config_option("use_shadow")->value.boolean;
@ -328,10 +329,10 @@ parse_dialogrc(void)
/*
* Return a pointer to the `.dialogrc' config option specific to `directive' or
* static fp_dummy_config (full of NULLs) if none found (see
* static figpar_dummy_config (full of NULLs) if none found (see
* get_config_option(3); part of figpar(3)).
*/
struct fp_config *
struct figpar_config *
dialogrc_config_option(const char *directive)
{
return (get_config_option(dialogrc_config, directive));

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org>
* Copyright (c) 2013-2015 Devin Teske <dteske@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -50,7 +50,7 @@ extern char separator[];
__BEGIN_DECLS
void dialogrc_free(void);
int parse_dialogrc(void);
struct fp_config *dialogrc_config_option(const char *_directive);
struct figpar_config *dialogrc_config_option(const char *_directive);
__END_DECLS
#endif /* !_DIALOGRC_H_ */

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd Oct 22, 2015
.Dd Nov 2, 2015
.Dt FIGPAR 3
.Os
.Sh NAME
@ -38,13 +38,13 @@
.In figpar.h
.Ft int
.Fo parse_config
.Fa "struct fp_config options[], const char *path"
.Fa "int \*[lp]*unknown\*[rp]\*[lp]struct fp_config *option, uint32_t line"
.Fa "struct figpar_config options[], const char *path"
.Fa "int \*[lp]*unknown\*[rp]\*[lp]struct figpar_config *option, uint32_t line"
.Fa "char *directive, char *value\*[rp], uint8_t processing_options"
.Fc
.Ft "struct fp_config *"
.Ft "struct figpar_config *"
.Fo get_config_option
.Fa "struct fp_config options[], const char *directive"
.Fa "struct figpar_config options[], const char *directive"
.Fc
.In string_m.h
.Ft int
@ -91,32 +91,32 @@ Configuration directives, types, and callback functions are provided through
data structures defined in
.In figpar.h :
.Bd -literal -offset indent
struct fp_config {
enum fp_cfgtype type; /* value type */
const char *directive; /* keyword */
union fp_cfgvalue value; /* value */
struct figpar_config {
enum figpar_cfgtype type; /* value type */
const char *directive; /* keyword */
union figpar_cfgvalue value; /* value */
/* Pointer to function used when directive is found */
int (*action)(struct fp_config *option, uint32_t line,
int (*action)(struct figpar_config *option, uint32_t line,
char *directive, char *value);
};
enum fp_cfgtype {
FP_TYPE_NONE = 0x0000, /* for directives with no value */
FP_TYPE_BOOL = 0x0001, /* boolean */
FP_TYPE_INT = 0x0002, /* signed 32 bit integer */
FP_TYPE_UINT = 0x0004, /* unsigned 32 bit integer */
FP_TYPE_STR = 0x0008, /* string pointer */
FP_TYPE_STRARRAY = 0x0010, /* string array pointer */
FP_TYPE_DATA1 = 0x0020, /* void data type-1 (whatever) */
FP_TYPE_DATA2 = 0x0040, /* void data type-2 (whatever) */
FP_TYPE_DATA3 = 0x0080, /* void data type-3 (whatever) */
FP_TYPE_RESERVED1 = 0x0100, /* reserved data type-1 (future) */
FP_TYPE_RESERVED2 = 0x0200, /* reserved data type-2 (future) */
FP_TYPE_RESERVED3 = 0x0400, /* reserved data type-3 (future) */
enum figpar_cfgtype {
FIGPAR_TYPE_NONE = 0x0000, /* directives with no value */
FIGPAR_TYPE_BOOL = 0x0001, /* boolean */
FIGPAR_TYPE_INT = 0x0002, /* signed 32 bit integer */
FIGPAR_TYPE_UINT = 0x0004, /* unsigned 32 bit integer */
FIGPAR_TYPE_STR = 0x0008, /* string pointer */
FIGPAR_TYPE_STRARRAY = 0x0010, /* string array pointer */
FIGPAR_TYPE_DATA1 = 0x0020, /* void data type-1 (open) */
FIGPAR_TYPE_DATA2 = 0x0040, /* void data type-2 (open) */
FIGPAR_TYPE_DATA3 = 0x0080, /* void data type-3 (open) */
FIGPAR_TYPE_RESERVED1 = 0x0100, /* reserved data type-1 */
FIGPAR_TYPE_RESERVED2 = 0x0200, /* reserved data type-2 */
FIGPAR_TYPE_RESERVED3 = 0x0400, /* reserved data type-3 */
};
union fp_cfgvalue {
union figpar_cfgvalue {
void *data; /* Pointer to NUL-terminated string */
char *str; /* Pointer to NUL-terminated string */
char **strarray; /* Pointer to an array of strings */
@ -133,26 +133,26 @@ argument to
is a mask of bit fields which indicate various
processing options.
The possible flags are as follows:
.Bl -tag -width FP_BREAK_ON_SEMICOLON
.It Dv FP_BREAK_ON_EQUALS
.Bl -tag -width FIGPAR_BREAK_ON_SEMICOLON
.It Dv FIGPAR_BREAK_ON_EQUALS
An equals sign
.Pq Ql Li =
is normally considered part of the directive.
This flag enables terminating the directive at the equals sign.
Also makes equals sign optional and transient.
.It Dv FP_BREAK_ON_SEMICOLON
.It Dv FIGPAR_BREAK_ON_SEMICOLON
A semicolon
.Pq Ql Li \;
is normally considered part of the value.
This flag enables terminating the value at the semicolon.
Also allows multiple statements on a single line separated by semicolon.
.It Dv FP_CASE_SENSITIVE
.It Dv FIGPAR_CASE_SENSITIVE
Normally directives are matched case insensitively using
.Xr fnmatch 3 .
This flag enables directive matching to be case sensitive.
.It Dv FP_REQUIRE_EQUALS
.It Dv FIGPAR_REQUIRE_EQUALS
If a directive is not followed by an equals, processing is aborted.
.It Dv FP_STRICT_EQUALS
.It Dv FIGPAR_STRICT_EQUALS
Equals must be part of the directive to be considered a delimiter between
directive and value.
.El
@ -163,14 +163,14 @@ struct array pointer can be NULL and every directive will invoke the
.Fn unknown
function argument.
.Pp
The directive for each fp_config item in the
The directive for each figpar_config item in the
.Fn parse_config
options argument is matched against each parsed directive using
.Xr fnmatch 3
until a match is found.
If a match is found, the
.Fn action
function for that fp_config directive is invoked with the line number,
function for that figpar_config directive is invoked with the line number,
directive, and value.
Otherwise if no match, the
.Fn unknown
@ -192,11 +192,11 @@ or if no match a pointer to a static dummy struct is returned
.Pq whose values are all zero or NULL .
.Pp
The use of
.Fa "struct fp_config"
.Fa "struct figpar_config"
is entirely optional as-is the use of
.Fa "enum fp_cfgtype"
.Fa "enum figpar_cfgtype"
or
.Fa "union fp_cfgvalue" .
.Fa "union figpar_cfgvalue" .
For example, you could choose to pass a NULL pointer to
.Fn parse_config
for the first argument and then provide a simple

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2002-2014 Devin Teske <dteske@FreeBSD.org>
* Copyright (c) 2002-2015 Devin Teske <dteske@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,24 +40,25 @@ __FBSDID("$FreeBSD$");
#include "figpar.h"
#include "string_m.h"
struct fp_config fp_dummy_config = {0, NULL, {0}, NULL};
struct figpar_config figpar_dummy_config = {0, NULL, {0}, NULL};
/*
* Search for config option (struct fp_config) in the array of config options,
* returning the struct whose directive matches the given parameter. If no
* match is found, a pointer to the static dummy array (above) is returned.
* Search for config option (struct figpar_config) in the array of config
* options, returning the struct whose directive matches the given parameter.
* If no match is found, a pointer to the static dummy array (above) is
* returned.
*
* This is to eliminate dependency on the index position of an item in the
* array, since the index position is more apt to be changed as code grows.
*/
struct fp_config *
get_config_option(struct fp_config options[], const char *directive)
struct figpar_config *
get_config_option(struct figpar_config options[], const char *directive)
{
uint32_t n;
/* Check arguments */
if (options == NULL || directive == NULL)
return (&fp_dummy_config);
return (&figpar_dummy_config);
/* Loop through the array, return the index of the first match */
for (n = 0; options[n].directive != NULL; n++)
@ -65,12 +66,12 @@ get_config_option(struct fp_config options[], const char *directive)
return (&(options[n]));
/* Re-initialize the dummy variable in case it was written to */
fp_dummy_config.directive = NULL;
fp_dummy_config.type = 0;
fp_dummy_config.action = NULL;
fp_dummy_config.value.u_num = 0;
figpar_dummy_config.directive = NULL;
figpar_dummy_config.type = 0;
figpar_dummy_config.action = NULL;
figpar_dummy_config.value.u_num = 0;
return (&fp_dummy_config);
return (&figpar_dummy_config);
}
/*
@ -84,9 +85,9 @@ get_config_option(struct fp_config options[], const char *directive)
* Returns zero on success; otherwise returns -1 and errno should be consulted.
*/
int
parse_config(struct fp_config options[], const char *path,
int (*unknown)(struct fp_config *option, uint32_t line, char *directive,
char *value), uint16_t processing_options)
parse_config(struct figpar_config options[], const char *path,
int (*unknown)(struct figpar_config *option, uint32_t line,
char *directive, char *value), uint16_t processing_options)
{
uint8_t bequals;
uint8_t bsemicolon;
@ -119,11 +120,15 @@ parse_config(struct fp_config options[], const char *path,
return (-1);
/* Processing options */
bequals = (processing_options & FP_BREAK_ON_EQUALS) == 0 ? 0 : 1;
bsemicolon = (processing_options & FP_BREAK_ON_SEMICOLON) == 0 ? 0 : 1;
case_sensitive = (processing_options & FP_CASE_SENSITIVE) == 0 ? 0 : 1;
require_equals = (processing_options & FP_REQUIRE_EQUALS) == 0 ? 0 : 1;
strict_equals = (processing_options & FP_STRICT_EQUALS) == 0 ? 0 : 1;
bequals = (processing_options & FIGPAR_BREAK_ON_EQUALS) == 0 ? 0 : 1;
bsemicolon =
(processing_options & FIGPAR_BREAK_ON_SEMICOLON) == 0 ? 0 : 1;
case_sensitive =
(processing_options & FIGPAR_CASE_SENSITIVE) == 0 ? 0 : 1;
require_equals =
(processing_options & FIGPAR_REQUIRE_EQUALS) == 0 ? 0 : 1;
strict_equals =
(processing_options & FIGPAR_STRICT_EQUALS) == 0 ? 0 : 1;
/* Initialize strings */
directive = value = 0;

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2002-2014 Devin Teske <dteske@FreeBSD.org>
* Copyright (c) 2002-2015 Devin Teske <dteske@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
/*
* Union for storing various types of data in a single common container.
*/
union fp_cfgvalue {
union figpar_cfgvalue {
void *data; /* Pointer to NUL-terminated string */
char *str; /* Pointer to NUL-terminated string */
char **strarray; /* Pointer to an array of strings */
@ -46,53 +46,53 @@ union fp_cfgvalue {
/*
* Option types (based on above cfgvalue union)
*/
enum fp_cfgtype {
FP_TYPE_NONE = 0x0000, /* for directives with no value */
FP_TYPE_BOOL = 0x0001, /* boolean */
FP_TYPE_INT = 0x0002, /* signed 32 bit integer */
FP_TYPE_UINT = 0x0004, /* unsigned 32 bit integer */
FP_TYPE_STR = 0x0008, /* string pointer */
FP_TYPE_STRARRAY = 0x0010, /* string array pointer */
FP_TYPE_DATA1 = 0x0020, /* void data type-1 (whatever) */
FP_TYPE_DATA2 = 0x0040, /* void data type-2 (whatever) */
FP_TYPE_DATA3 = 0x0080, /* void data type-3 (whatever) */
FP_TYPE_RESERVED1 = 0x0100, /* reserved data type-1 (future) */
FP_TYPE_RESERVED2 = 0x0200, /* reserved data type-2 (future) */
FP_TYPE_RESERVED3 = 0x0400, /* reserved data type-3 (future) */
enum figpar_cfgtype {
FIGPAR_TYPE_NONE = 0x0000, /* directives with no value */
FIGPAR_TYPE_BOOL = 0x0001, /* boolean */
FIGPAR_TYPE_INT = 0x0002, /* signed 32 bit integer */
FIGPAR_TYPE_UINT = 0x0004, /* unsigned 32 bit integer */
FIGPAR_TYPE_STR = 0x0008, /* string pointer */
FIGPAR_TYPE_STRARRAY = 0x0010, /* string array pointer */
FIGPAR_TYPE_DATA1 = 0x0020, /* void data type-1 (open) */
FIGPAR_TYPE_DATA2 = 0x0040, /* void data type-2 (open) */
FIGPAR_TYPE_DATA3 = 0x0080, /* void data type-3 (open) */
FIGPAR_TYPE_RESERVED1 = 0x0100, /* reserved data type-1 */
FIGPAR_TYPE_RESERVED2 = 0x0200, /* reserved data type-2 */
FIGPAR_TYPE_RESERVED3 = 0x0400, /* reserved data type-3 */
};
/*
* Options to parse_config() for processing_options bitmask
*/
#define FP_BREAK_ON_EQUALS 0x0001 /* stop reading directive at `=' */
#define FP_BREAK_ON_SEMICOLON 0x0002 /* `;' starts a new line */
#define FP_CASE_SENSITIVE 0x0004 /* directives are case sensitive */
#define FP_REQUIRE_EQUALS 0x0008 /* assignment directives only */
#define FP_STRICT_EQUALS 0x0010 /* `=' must be part of directive */
#define FIGPAR_BREAK_ON_EQUALS 0x0001 /* stop reading directive at `=' */
#define FIGPAR_BREAK_ON_SEMICOLON 0x0002 /* `;' starts a new line */
#define FIGPAR_CASE_SENSITIVE 0x0004 /* directives are case sensitive */
#define FIGPAR_REQUIRE_EQUALS 0x0008 /* assignment directives only */
#define FIGPAR_STRICT_EQUALS 0x0010 /* `=' must be part of directive */
/*
* Anatomy of a config file option
*/
struct fp_config {
enum fp_cfgtype type; /* Option value type */
struct figpar_config {
enum figpar_cfgtype type; /* Option value type */
const char *directive; /* config file keyword */
union fp_cfgvalue value; /* NB: set by action */
union figpar_cfgvalue value; /* NB: set by action */
/*
* Function pointer; action to be taken when the directive is found
*/
int (*action)(struct fp_config *option, uint32_t line, char *directive,
char *value);
int (*action)(struct figpar_config *option, uint32_t line,
char *directive, char *value);
};
extern struct fp_config fp_dummy_config;
extern struct figpar_config figpar_dummy_config;
__BEGIN_DECLS
int parse_config(struct fp_config _options[],
int parse_config(struct figpar_config _options[],
const char *_path,
int (*_unknown)(struct fp_config *_option,
int (*_unknown)(struct figpar_config *_option,
uint32_t _line, char *_directive, char *_value),
uint16_t _processing_options);
struct fp_config *get_config_option(struct fp_config _options[],
struct figpar_config *get_config_option(struct figpar_config _options[],
const char *_directive);
__END_DECLS

View File

@ -2,6 +2,6 @@ $FreeBSD$
libnetbsd is a thin compatibility layer intended to allow a limited
set of NetBSD software to compile as part of the FreeBSD build with
little or no modifiction. It is built as a static library and not
little or no modification. It is built as a static library and not
installed for general use. Likewise, its header files are not
installed.

View File

@ -1,6 +1,6 @@
# $FreeBSD$
LIB= ohash
LIB= openbsd
SRCS= ohash.c
INTERNALLIB=

7
lib/libopenbsd/README Normal file
View File

@ -0,0 +1,7 @@
$FreeBSD$
libopenbsd is a thin compatibility layer intended to allow a limited
set of OpenBSD software to compile as part of the FreeBSD build with
little or no modification. It is built as a static library and not
installed for general use. Likewise, its header files are not
installed.

View File

@ -0,0 +1,309 @@
/* $OpenBSD: imsg-buffer.c,v 1.7 2015/07/12 18:40:49 nicm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* 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$
*/
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "imsg.h"
int ibuf_realloc(struct ibuf *, size_t);
void ibuf_enqueue(struct msgbuf *, struct ibuf *);
void ibuf_dequeue(struct msgbuf *, struct ibuf *);
struct ibuf *
ibuf_open(size_t len)
{
struct ibuf *buf;
if ((buf = calloc(1, sizeof(struct ibuf))) == NULL)
return (NULL);
if ((buf->buf = malloc(len)) == NULL) {
free(buf);
return (NULL);
}
buf->size = buf->max = len;
buf->fd = -1;
return (buf);
}
struct ibuf *
ibuf_dynamic(size_t len, size_t max)
{
struct ibuf *buf;
if (max < len)
return (NULL);
if ((buf = ibuf_open(len)) == NULL)
return (NULL);
if (max > 0)
buf->max = max;
return (buf);
}
int
ibuf_realloc(struct ibuf *buf, size_t len)
{
u_char *b;
/* on static buffers max is eq size and so the following fails */
if (buf->wpos + len > buf->max) {
errno = ERANGE;
return (-1);
}
b = realloc(buf->buf, buf->wpos + len);
if (b == NULL)
return (-1);
buf->buf = b;
buf->size = buf->wpos + len;
return (0);
}
int
ibuf_add(struct ibuf *buf, const void *data, size_t len)
{
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
return (-1);
memcpy(buf->buf + buf->wpos, data, len);
buf->wpos += len;
return (0);
}
void *
ibuf_reserve(struct ibuf *buf, size_t len)
{
void *b;
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
return (NULL);
b = buf->buf + buf->wpos;
buf->wpos += len;
return (b);
}
void *
ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
{
/* only allowed to seek in already written parts */
if (pos + len > buf->wpos)
return (NULL);
return (buf->buf + pos);
}
size_t
ibuf_size(struct ibuf *buf)
{
return (buf->wpos);
}
size_t
ibuf_left(struct ibuf *buf)
{
return (buf->max - buf->wpos);
}
void
ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
{
ibuf_enqueue(msgbuf, buf);
}
int
ibuf_write(struct msgbuf *msgbuf)
{
struct iovec iov[IOV_MAX];
struct ibuf *buf;
unsigned int i = 0;
ssize_t n;
memset(&iov, 0, sizeof(iov));
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = buf->buf + buf->rpos;
iov[i].iov_len = buf->wpos - buf->rpos;
i++;
}
again:
if ((n = writev(msgbuf->fd, iov, i)) == -1) {
if (errno == EINTR)
goto again;
if (errno == ENOBUFS)
errno = EAGAIN;
return (-1);
}
if (n == 0) { /* connection closed */
errno = 0;
return (0);
}
msgbuf_drain(msgbuf, n);
return (1);
}
void
ibuf_free(struct ibuf *buf)
{
free(buf->buf);
free(buf);
}
void
msgbuf_init(struct msgbuf *msgbuf)
{
msgbuf->queued = 0;
msgbuf->fd = -1;
TAILQ_INIT(&msgbuf->bufs);
}
void
msgbuf_drain(struct msgbuf *msgbuf, size_t n)
{
struct ibuf *buf, *next;
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
buf = next) {
next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->wpos) {
n -= buf->wpos - buf->rpos;
ibuf_dequeue(msgbuf, buf);
} else {
buf->rpos += n;
n = 0;
}
}
}
void
msgbuf_clear(struct msgbuf *msgbuf)
{
struct ibuf *buf;
while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL)
ibuf_dequeue(msgbuf, buf);
}
int
msgbuf_write(struct msgbuf *msgbuf)
{
struct iovec iov[IOV_MAX];
struct ibuf *buf;
unsigned int i = 0;
ssize_t n;
struct msghdr msg;
struct cmsghdr *cmsg;
union {
struct cmsghdr hdr;
char buf[CMSG_SPACE(sizeof(int))];
} cmsgbuf;
memset(&iov, 0, sizeof(iov));
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = buf->buf + buf->rpos;
iov[i].iov_len = buf->wpos - buf->rpos;
i++;
if (buf->fd != -1)
break;
}
msg.msg_iov = iov;
msg.msg_iovlen = i;
if (buf != NULL && buf->fd != -1) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
*(int *)CMSG_DATA(cmsg) = buf->fd;
}
again:
if ((n = sendmsg(msgbuf->fd, &msg, 0)) == -1) {
if (errno == EINTR)
goto again;
if (errno == ENOBUFS)
errno = EAGAIN;
return (-1);
}
if (n == 0) { /* connection closed */
errno = 0;
return (0);
}
/*
* assumption: fd got sent if sendmsg sent anything
* this works because fds are passed one at a time
*/
if (buf != NULL && buf->fd != -1) {
close(buf->fd);
buf->fd = -1;
}
msgbuf_drain(msgbuf, n);
return (1);
}
void
ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++;
}
void
ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
if (buf->fd != -1)
close(buf->fd);
msgbuf->queued--;
ibuf_free(buf);
}

307
lib/libopenbsd/imsg.c Normal file
View File

@ -0,0 +1,307 @@
/* $OpenBSD: imsg.c,v 1.10 2015/07/19 07:18:59 nicm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* 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$
*/
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "imsg.h"
int imsg_fd_overhead = 0;
int imsg_get_fd(struct imsgbuf *);
void
imsg_init(struct imsgbuf *ibuf, int fd)
{
msgbuf_init(&ibuf->w);
memset(&ibuf->r, 0, sizeof(ibuf->r));
ibuf->fd = fd;
ibuf->w.fd = fd;
ibuf->pid = getpid();
TAILQ_INIT(&ibuf->fds);
}
ssize_t
imsg_read(struct imsgbuf *ibuf)
{
struct msghdr msg;
struct cmsghdr *cmsg;
union {
struct cmsghdr hdr;
char buf[CMSG_SPACE(sizeof(int) * 1)];
} cmsgbuf;
struct iovec iov;
ssize_t n = -1;
int fd;
struct imsg_fd *ifd;
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
iov.iov_base = ibuf->r.buf + ibuf->r.wpos;
iov.iov_len = sizeof(ibuf->r.buf) - ibuf->r.wpos;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((ifd = calloc(1, sizeof(struct imsg_fd))) == NULL)
return (-1);
again:
if (getdtablecount() + imsg_fd_overhead +
(CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int)
>= getdtablesize()) {
errno = EAGAIN;
free(ifd);
return (-1);
}
if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) {
if (errno == EMSGSIZE)
goto fail;
if (errno != EINTR && errno != EAGAIN)
goto fail;
goto again;
}
ibuf->r.wpos += n;
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type == SCM_RIGHTS) {
int i;
int j;
/*
* We only accept one file descriptor. Due to C
* padding rules, our control buffer might contain
* more than one fd, and we must close them.
*/
j = ((char *)cmsg + cmsg->cmsg_len -
(char *)CMSG_DATA(cmsg)) / sizeof(int);
for (i = 0; i < j; i++) {
fd = ((int *)CMSG_DATA(cmsg))[i];
if (ifd != NULL) {
ifd->fd = fd;
TAILQ_INSERT_TAIL(&ibuf->fds, ifd,
entry);
ifd = NULL;
} else
close(fd);
}
}
/* we do not handle other ctl data level */
}
fail:
if (ifd)
free(ifd);
return (n);
}
ssize_t
imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
{
size_t av, left, datalen;
av = ibuf->r.wpos;
if (IMSG_HEADER_SIZE > av)
return (0);
memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr));
if (imsg->hdr.len < IMSG_HEADER_SIZE ||
imsg->hdr.len > MAX_IMSGSIZE) {
errno = ERANGE;
return (-1);
}
if (imsg->hdr.len > av)
return (0);
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
ibuf->r.rptr = ibuf->r.buf + IMSG_HEADER_SIZE;
if (datalen == 0)
imsg->data = NULL;
else if ((imsg->data = malloc(datalen)) == NULL)
return (-1);
if (imsg->hdr.flags & IMSGF_HASFD)
imsg->fd = imsg_get_fd(ibuf);
else
imsg->fd = -1;
memcpy(imsg->data, ibuf->r.rptr, datalen);
if (imsg->hdr.len < av) {
left = av - imsg->hdr.len;
memmove(&ibuf->r.buf, ibuf->r.buf + imsg->hdr.len, left);
ibuf->r.wpos = left;
} else
ibuf->r.wpos = 0;
return (datalen + IMSG_HEADER_SIZE);
}
int
imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, int fd, const void *data, u_int16_t datalen)
{
struct ibuf *wbuf;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
return (-1);
if (imsg_add(wbuf, data, datalen) == -1)
return (-1);
wbuf->fd = fd;
imsg_close(ibuf, wbuf);
return (1);
}
int
imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, int fd, const struct iovec *iov, int iovcnt)
{
struct ibuf *wbuf;
int i, datalen = 0;
for (i = 0; i < iovcnt; i++)
datalen += iov[i].iov_len;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
return (-1);
for (i = 0; i < iovcnt; i++)
if (imsg_add(wbuf, iov[i].iov_base, iov[i].iov_len) == -1)
return (-1);
wbuf->fd = fd;
imsg_close(ibuf, wbuf);
return (1);
}
/* ARGSUSED */
struct ibuf *
imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, u_int16_t datalen)
{
struct ibuf *wbuf;
struct imsg_hdr hdr;
datalen += IMSG_HEADER_SIZE;
if (datalen > MAX_IMSGSIZE) {
errno = ERANGE;
return (NULL);
}
hdr.type = type;
hdr.flags = 0;
hdr.peerid = peerid;
if ((hdr.pid = pid) == 0)
hdr.pid = ibuf->pid;
if ((wbuf = ibuf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) {
return (NULL);
}
if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1)
return (NULL);
return (wbuf);
}
int
imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
{
if (datalen)
if (ibuf_add(msg, data, datalen) == -1) {
ibuf_free(msg);
return (-1);
}
return (datalen);
}
void
imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
{
struct imsg_hdr *hdr;
hdr = (struct imsg_hdr *)msg->buf;
hdr->flags &= ~IMSGF_HASFD;
if (msg->fd != -1)
hdr->flags |= IMSGF_HASFD;
hdr->len = (u_int16_t)msg->wpos;
ibuf_close(&ibuf->w, msg);
}
void
imsg_free(struct imsg *imsg)
{
free(imsg->data);
}
int
imsg_get_fd(struct imsgbuf *ibuf)
{
int fd;
struct imsg_fd *ifd;
if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL)
return (-1);
fd = ifd->fd;
TAILQ_REMOVE(&ibuf->fds, ifd, entry);
free(ifd);
return (fd);
}
int
imsg_flush(struct imsgbuf *ibuf)
{
while (ibuf->w.queued)
if (msgbuf_write(&ibuf->w) <= 0)
return (-1);
return (0);
}
void
imsg_clear(struct imsgbuf *ibuf)
{
int fd;
msgbuf_clear(&ibuf->w);
while ((fd = imsg_get_fd(ibuf)) != -1)
close(fd);
}

114
lib/libopenbsd/imsg.h Normal file
View File

@ -0,0 +1,114 @@
/* $OpenBSD: imsg.h,v 1.3 2013/12/26 17:32:33 eric Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* 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$
*/
#ifndef _IMSG_H_
#define _IMSG_H_
#define IBUF_READ_SIZE 65535
#define IMSG_HEADER_SIZE sizeof(struct imsg_hdr)
#define MAX_IMSGSIZE 16384
struct ibuf {
TAILQ_ENTRY(ibuf) entry;
u_char *buf;
size_t size;
size_t max;
size_t wpos;
size_t rpos;
int fd;
};
struct msgbuf {
TAILQ_HEAD(, ibuf) bufs;
u_int32_t queued;
int fd;
};
struct ibuf_read {
u_char buf[IBUF_READ_SIZE];
u_char *rptr;
size_t wpos;
};
struct imsg_fd {
TAILQ_ENTRY(imsg_fd) entry;
int fd;
};
struct imsgbuf {
TAILQ_HEAD(, imsg_fd) fds;
struct ibuf_read r;
struct msgbuf w;
int fd;
pid_t pid;
};
#define IMSGF_HASFD 1
struct imsg_hdr {
u_int32_t type;
u_int16_t len;
u_int16_t flags;
u_int32_t peerid;
u_int32_t pid;
};
struct imsg {
struct imsg_hdr hdr;
int fd;
void *data;
};
/* buffer.c */
struct ibuf *ibuf_open(size_t);
struct ibuf *ibuf_dynamic(size_t, size_t);
int ibuf_add(struct ibuf *, const void *, size_t);
void *ibuf_reserve(struct ibuf *, size_t);
void *ibuf_seek(struct ibuf *, size_t, size_t);
size_t ibuf_size(struct ibuf *);
size_t ibuf_left(struct ibuf *);
void ibuf_close(struct msgbuf *, struct ibuf *);
int ibuf_write(struct msgbuf *);
void ibuf_free(struct ibuf *);
void msgbuf_init(struct msgbuf *);
void msgbuf_clear(struct msgbuf *);
int msgbuf_write(struct msgbuf *);
void msgbuf_drain(struct msgbuf *, size_t);
/* imsg.c */
void imsg_init(struct imsgbuf *, int);
ssize_t imsg_read(struct imsgbuf *);
ssize_t imsg_get(struct imsgbuf *, struct imsg *);
int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
int, const void *, u_int16_t);
int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
int, const struct iovec *, int);
struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
u_int16_t);
int imsg_add(struct ibuf *, const void *, u_int16_t);
void imsg_close(struct imsgbuf *, struct ibuf *);
void imsg_free(struct imsg *);
int imsg_flush(struct imsgbuf *);
void imsg_clear(struct imsgbuf *);
#endif

549
lib/libopenbsd/imsg_init.3 Normal file
View File

@ -0,0 +1,549 @@
.\" $OpenBSD: imsg_init.3,v 1.13 2015/07/11 16:23:59 deraadt Exp $
.\"
.\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org>
.\"
.\" 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 MIND, 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 $Mdocdate: July 11 2015 $
.Dt IMSG_INIT 3
.Os
.Sh NAME
.Nm imsg_init ,
.Nm imsg_read ,
.Nm imsg_get ,
.Nm imsg_compose ,
.Nm imsg_composev ,
.Nm imsg_create ,
.Nm imsg_add ,
.Nm imsg_close ,
.Nm imsg_free ,
.Nm imsg_flush ,
.Nm imsg_clear ,
.Nm ibuf_open ,
.Nm ibuf_dynamic ,
.Nm ibuf_add ,
.Nm ibuf_reserve ,
.Nm ibuf_seek ,
.Nm ibuf_size ,
.Nm ibuf_left ,
.Nm ibuf_close ,
.Nm ibuf_write ,
.Nm ibuf_free ,
.Nm msgbuf_init ,
.Nm msgbuf_clear ,
.Nm msgbuf_write ,
.Nm msgbuf_drain
.Nd IPC messaging functions
.Sh SYNOPSIS
.In sys/types.h
.In sys/queue.h
.In sys/uio.h
.In imsg.h
.Ft void
.Fn imsg_init "struct imsgbuf *ibuf" "int fd"
.Ft ssize_t
.Fn imsg_read "struct imsgbuf *ibuf"
.Ft ssize_t
.Fn imsg_get "struct imsgbuf *ibuf" "struct imsg *imsg"
.Ft int
.Fn imsg_compose "struct imsgbuf *ibuf" "u_int32_t type" "uint32_t peerid" \
"pid_t pid" "int fd" "const void *data" "u_int16_t datalen"
.Ft int
.Fn imsg_composev "struct imsgbuf *ibuf" "u_int32_t type" "u_int32_t peerid" \
"pid_t pid" "int fd" "const struct iovec *iov" "int iovcnt"
.Ft "struct ibuf *"
.Fn imsg_create "struct imsgbuf *ibuf" "u_int32_t type" "u_int32_t peerid" \
"pid_t pid" "u_int16_t datalen"
.Ft int
.Fn imsg_add "struct ibuf *buf" "const void *data" "u_int16_t datalen"
.Ft void
.Fn imsg_close "struct imsgbuf *ibuf" "struct ibuf *msg"
.Ft void
.Fn imsg_free "struct imsg *imsg"
.Ft int
.Fn imsg_flush "struct imsgbuf *ibuf"
.Ft void
.Fn imsg_clear "struct imsgbuf *ibuf"
.Ft "struct ibuf *"
.Fn ibuf_open "size_t len"
.Ft "struct ibuf *"
.Fn ibuf_dynamic "size_t len" "size_t max"
.Ft int
.Fn ibuf_add "struct ibuf *buf" "const void *data" "size_t len"
.Ft "void *"
.Fn ibuf_reserve "struct ibuf *buf" "size_t len"
.Ft "void *"
.Fn ibuf_seek "struct ibuf *buf" "size_t pos" "size_t len"
.Ft size_t
.Fn ibuf_size "struct ibuf *buf"
.Ft size_t
.Fn ibuf_left "struct ibuf *buf"
.Ft void
.Fn ibuf_close "struct msgbuf *msgbuf" "struct ibuf *buf"
.Ft int
.Fn ibuf_write "struct msgbuf *msgbuf"
.Ft void
.Fn ibuf_free "struct ibuf *buf"
.Ft void
.Fn msgbuf_init "struct msgbuf *msgbuf"
.Ft void
.Fn msgbuf_clear "struct msgbuf *msgbuf"
.Ft int
.Fn msgbuf_write "struct msgbuf *msgbuf"
.Ft void
.Fn msgbuf_drain "struct msgbuf *msgbuf" "size_t n"
.Sh DESCRIPTION
The
.Nm imsg
functions provide a simple mechanism for communication between processes
using sockets.
Each transmitted message is guaranteed to be presented to the receiving program
whole.
They are commonly used in privilege separated processes, where processes with
different rights are required to cooperate.
.Pp
A program using these functions should be linked with
.Em -lutil .
.Pp
The basic
.Nm
structure is the
.Em imsgbuf ,
which wraps a file descriptor and represents one side of a channel on which
messages are sent and received:
.Bd -literal -offset indent
struct imsgbuf {
TAILQ_HEAD(, imsg_fd) fds;
struct ibuf_read r;
struct msgbuf w;
int fd;
pid_t pid;
};
.Ed
.Pp
.Fn imsg_init
is a routine which initializes
.Fa ibuf
as one side of a channel associated with
.Fa fd .
The file descriptor is used to send and receive messages,
but is not closed by any of the imsg functions.
An imsgbuf is initialized with the
.Em w
member as the output buffer queue,
.Em fd
with the file descriptor passed to
.Fn imsg_init
and the other members for internal use only.
.Pp
The
.Fn imsg_clear
function frees any data allocated as part of an imsgbuf.
.Pp
.Fn imsg_create ,
.Fn imsg_add
and
.Fn imsg_close
are generic construction routines for messages that are to be sent using an
imsgbuf.
.Pp
.Fn imsg_create
creates a new message with header specified by
.Fa type ,
.Fa peerid
and
.Fa pid .
A
.Fa pid
of zero uses the process ID returned by
.Xr getpid 2
when
.Fa ibuf
was initialized.
In addition to this common imsg header,
.Fa datalen
bytes of space may be reserved for attaching to this imsg.
This space is populated using
.Fn imsg_add .
Additionally, the file descriptor
.Fa fd
may be passed over the socket to the other process.
If
.Fa fd
is given, it is closed in the sending program after the message is sent.
A value of \-1 indicates no file descriptor should be passed.
.Fn imsg_create
returns a pointer to a new message if it succeeds, NULL otherwise.
.Pp
.Fn imsg_add
appends to
.Fa imsg
.Fa len
bytes of ancillary data pointed to by
.Fa buf .
It returns
.Fa len
if it succeeds, \-1 otherwise.
.Pp
.Fn imsg_close
completes creation of
.Fa imsg
by adding it to
.Fa imsgbuf
output buffer.
.Pp
.Fn imsg_compose
is a routine which is used to quickly create and queue an imsg.
It takes the same parameters as the
.Fn imsg_create ,
.Fn imsg_add
and
.Fn imsg_close
routines,
except that only one ancillary data buffer can be provided.
This routine returns 1 if it succeeds, \-1 otherwise.
.Pp
.Fn imsg_composev
is similar to
.Fn imsg_compose .
It takes the same parameters, except that the ancillary data buffer is specified
by
.Fa iovec .
.Pp
.Fn imsg_flush
is a function which calls
.Fn msgbuf_write
in a loop until all imsgs in the output buffer are sent.
It returns 0 if it succeeds, \-1 otherwise.
.Pp
The
.Fn imsg_read
routine reads pending data with
.Xr recvmsg 2
and queues it as individual messages on
.Fa imsgbuf .
It returns the number of bytes read on success, or \-1 on error.
A return value of \-1 from
.Fn imsg_read
invalidates
.Fa imsgbuf ,
and renders it suitable only for passing to
.Fn imsg_clear .
.Pp
.Fn imsg_get
fills in an individual imsg pending on
.Fa imsgbuf
into the structure pointed to by
.Fa imsg .
It returns the total size of the message, 0 if no messages are ready, or \-1
for an error.
Received messages are returned as a
.Em struct imsg ,
which must be freed by
.Fn imsg_free
when no longer required.
.Em struct imsg
has this form:
.Bd -literal -offset indent
struct imsg {
struct imsg_hdr hdr;
int fd;
void *data;
};
struct imsg_hdr {
u_int32_t type;
u_int16_t len;
u_int16_t flags;
u_int32_t peerid;
u_int32_t pid;
};
.Ed
.Pp
The header members are:
.Bl -tag -width Ds -offset indent
.It type
A integer identifier, typically used to express the meaning of the message.
.It len
The total length of the imsg, including the header and any ancillary data
transmitted with the message (pointed to by the
.Em data
member of the message itself).
.It flags
Flags used internally by the imsg functions: should not be used by application
programs.
.It peerid, pid
32-bit values specified on message creation and free for any use by the
caller, normally used to identify the message sender.
.El
.Pp
In addition,
.Em struct imsg
has the following:
.Bl -tag -width Ds -offset indent
.It fd
The file descriptor specified when the message was created and passed using the
socket control message API, or \-1 if no file descriptor was sent.
.It data
A pointer to the ancillary data transmitted with the imsg.
.El
.Pp
The IMSG_HEADER_SIZE define is the size of the imsg message header, which
may be subtracted from the
.Fa len
member of
.Em struct imsg_hdr
to obtain the length of any additional data passed with the message.
.Pp
MAX_IMSGSIZE is defined as the maximum size of a single imsg, currently
16384 bytes.
.Sh BUFFERS
The imsg API defines functions to manipulate buffers, used internally and during
construction of imsgs with
.Fn imsg_create .
A
.Em struct ibuf
is a single buffer and a
.Em struct msgbuf
a queue of output buffers for transmission:
.Bd -literal -offset indent
struct ibuf {
TAILQ_ENTRY(ibuf) entry;
u_char *buf;
size_t size;
size_t max;
size_t wpos;
size_t rpos;
int fd;
};
struct msgbuf {
TAILQ_HEAD(, ibuf) bufs;
u_int32_t queued;
int fd;
};
.Ed
.Pp
The
.Fn ibuf_open
function allocates a fixed-length buffer.
The buffer may not be resized and may contain a maximum of
.Fa len
bytes.
On success
.Fn ibuf_open
returns a pointer to the buffer; on failure it returns NULL.
.Pp
.Fn ibuf_dynamic
allocates a resizeable buffer of initial length
.Fa len
and maximum size
.Fa max .
Buffers allocated with
.Fn ibuf_dynamic
are automatically grown if necessary when data is added.
.Pp
.Fn ibuf_add
is a routine which appends a block of data to
.Fa buf .
0 is returned on success and \-1 on failure.
.Pp
.Fn ibuf_reserve
is used to reserve
.Fa len
bytes in
.Fa buf .
A pointer to the start of the reserved space is returned, or NULL on error.
.Pp
.Fn ibuf_seek
is a function which returns a pointer to the part of the buffer at offset
.Fa pos
and of extent
.Fa len .
NULL is returned if the requested range is outside the part of the buffer
in use.
.Pp
.Fn ibuf_size
and
.Fn ibuf_left
are functions which return the total bytes used and available in
.Fa buf
respectively.
.Pp
.Fn ibuf_close
appends
.Fa buf
to
.Fa msgbuf
ready to be sent.
.Pp
The
.Fn ibuf_write
routine transmits as many pending buffers as possible from
.Fn msgbuf
using
.Xr writev 2 .
It returns 1 if it succeeds, \-1 on error and 0 when no buffers were
pending or an EOF condition on the socket is detected.
Temporary resource shortages are returned with errno
.Er EAGAIN
and require the application to retry again in the future.
.Pp
.Fn ibuf_free
frees
.Fa buf
and any associated storage.
.Pp
The
.Fn msgbuf_init
function initializes
.Fa msgbuf
so that buffers may be appended to it.
The
.Em fd
member should also be set directly before
.Fn msgbuf_write
is used.
.Pp
.Fn msgbuf_clear
empties a msgbuf, removing and discarding any queued buffers.
.Pp
The
.Fn msgbuf_write
routine calls
.Xr sendmsg 2
to transmit buffers queued in
.Fa msgbuf .
It returns 1 if it succeeds, \-1 on error, and 0 when the queue was empty
or an EOF condition on the socket is detected.
Temporary resource shortages are returned with errno
.Er EAGAIN
and require the application to retry again in the future.
.Pp
.Fn msgbuf_drain
discards data from buffers queued in
.Fa msgbuf
until
.Fa n
bytes have been removed or
.Fa msgbuf
is empty.
.Sh EXAMPLES
In a typical program, a channel between two processes is created with
.Xr socketpair 2 ,
and an
.Em imsgbuf
created around one file descriptor in each process:
.Bd -literal -offset indent
struct imsgbuf parent_ibuf, child_ibuf;
int imsg_fds[2];
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
err(1, "socketpair");
switch (fork()) {
case -1:
err(1, "fork");
case 0:
/* child */
close(imsg_fds[0]);
imsg_init(&child_ibuf, imsg_fds[1]);
exit(child_main(&child_ibuf));
}
/* parent */
close(imsg_fds[1]);
imsg_init(&parent_ibuf, imsg_fds[0]);
exit(parent_main(&parent_ibuf));
.Ed
.Pp
Messages may then be composed and queued on the
.Em imsgbuf ,
for example using the
.Fn imsg_compose
function:
.Bd -literal -offset indent
enum imsg_type {
IMSG_A_MESSAGE,
IMSG_MESSAGE2
};
int
child_main(struct imsgbuf *ibuf)
{
int idata;
...
idata = 42;
imsg_compose(ibuf, IMSG_A_MESSAGE,
0, 0, -1, &idata, sizeof idata);
...
}
.Ed
.Pp
A mechanism such as
.Xr poll 2
or the
.Xr event 3
library is used to monitor the socket file descriptor.
When the socket is ready for writing, queued messages are transmitted with
.Fn msgbuf_write :
.Bd -literal -offset indent
if (msgbuf_write(&ibuf-\*(Gtw) \*(Lt= 0 && errno != EAGAIN) {
/* handle write failure */
}
.Ed
.Pp
And when ready for reading, messages are first received using
.Fn imsg_read
and then extracted with
.Fn imsg_get :
.Bd -literal -offset indent
void
dispatch_imsg(struct imsgbuf *ibuf)
{
struct imsg imsg;
ssize_t n, datalen;
int idata;
if ((n = imsg_read(ibuf)) == -1 || n == 0) {
/* handle socket error */
}
for (;;) {
if ((n = imsg_get(ibuf, &imsg)) == -1) {
/* handle read error */
}
if (n == 0) /* no more messages */
return;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
switch (imsg.hdr.type) {
case IMSG_A_MESSAGE:
if (datalen \*(Lt sizeof idata) {
/* handle corrupt message */
}
memcpy(&idata, imsg.data, sizeof idata);
/* handle message received */
break;
...
}
imsg_free(&imsg);
}
}
.Ed
.Sh SEE ALSO
.Xr socketpair 2 ,
.Xr unix 4

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\" "
.Dd December 29, 1996
.Dd November 11, 2015
.Dt PTY 3
.Os
.Sh NAME
@ -120,7 +120,7 @@ function may fail and set the global variable
.Dv errno
for any of the errors specified for the
.Xr grantpt 3 ,
.Xr posix_openpt 3 ,
.Xr posix_openpt 2 ,
.Xr ptsname 3 ,
and
.Xr unlockpt 3

View File

@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
.Dd Aug 12, 2015
.Dd November 6, 2015
.Dt IFCONFIG 8
.Os
.Sh NAME
@ -2400,6 +2400,21 @@ which are shifted by the number of this parameter.
Enable lacp fast-timeout on the interface.
.It Cm -lacp_fast_timeout
Disable lacp fast-timeout on the interface.
.It Cm lacp_strict
Enable lacp strict compliance on the interface.
The default value can be set via the
.Va net.link.lagg.lacp.default_strict_mode
.Xr sysctl 8
variable.
.Li 0
means
.Dq disabled
and
.Li 1
means
.Dq enabled .
.It Cm -lacp_strict
Disable lacp strict compliance on the interface.
.El
.Pp
The following parameters are specific to IP tunnel interfaces,

View File

@ -3185,7 +3185,7 @@ list_scan(int s)
getchaninfo(s);
ssidmax = verbose ? IEEE80211_NWID_LEN - 1 : 14;
printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n"
printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n"
, ssidmax, ssidmax, "SSID/MESH ID"
, "BSSID"
, "CHAN"
@ -3208,7 +3208,7 @@ list_scan(int s)
idp = vp;
idlen = sr->isr_ssid_len;
}
printf("%-*.*s %s %3d %3dM %3d:%-3d %3d %-4.4s"
printf("%-*.*s %s %3d %3dM %4d:%-4d %4d %-4.4s"
, ssidmax
, copy_essid(ssid, ssidmax, idp, idlen)
, ssid

View File

@ -4983,10 +4983,48 @@ ipfw_flush(int force)
static struct _s_x intcmds[] = {
{ "talist", TOK_TALIST },
{ "iflist", TOK_IFLIST },
{ "olist", TOK_OLIST },
{ "vlist", TOK_VLIST },
{ NULL, 0 }
};
static void
ipfw_list_objects(int ac, char *av[])
{
ipfw_obj_lheader req, *olh;
ipfw_obj_ntlv *ntlv;
size_t sz;
int i;
memset(&req, 0, sizeof(req));
sz = sizeof(req);
if (do_get3(IP_FW_DUMP_SRVOBJECTS, &req.opheader, &sz) != 0)
if (errno != ENOMEM)
return;
sz = req.size;
if ((olh = calloc(1, sz)) == NULL)
return;
olh->size = sz;
if (do_get3(IP_FW_DUMP_SRVOBJECTS, &olh->opheader, &sz) != 0) {
free(olh);
return;
}
if (olh->count > 0)
printf("Objects list:\n");
else
printf("There are no objects\n");
ntlv = (ipfw_obj_ntlv *)(olh + 1);
for (i = 0; i < olh->count; i++) {
printf(" kidx: %4d\ttype: %2d\tname: %s\n", ntlv->idx,
ntlv->head.type, ntlv->name);
ntlv++;
}
free(olh);
}
void
ipfw_internal_handler(int ac, char *av[])
{
@ -5005,6 +5043,9 @@ ipfw_internal_handler(int ac, char *av[])
case TOK_TALIST:
ipfw_list_ta(ac, av);
break;
case TOK_OLIST:
ipfw_list_objects(ac, av);
break;
case TOK_VLIST:
ipfw_list_values(ac, av);
break;

View File

@ -227,6 +227,7 @@ enum tokens {
TOK_LOCK,
TOK_UNLOCK,
TOK_VLIST,
TOK_OLIST,
};
/*

View File

@ -491,9 +491,8 @@ DoFile(const char *savedir, const char *device)
}
lasthd = mediasize - sectorsize;
lseek(fd, lasthd, SEEK_SET);
error = read(fd, &kdhl, sizeof kdhl);
if (error != sizeof kdhl) {
if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
read(fd, &kdhl, sizeof(kdhl)) != sizeof(kdhl)) {
syslog(LOG_ERR,
"error reading last dump header at offset %lld in %s: %m",
(long long)lasthd, device);
@ -569,9 +568,8 @@ DoFile(const char *savedir, const char *device)
}
dumpsize = dtoh64(kdhl.dumplength);
firsthd = lasthd - dumpsize - sizeof kdhf;
lseek(fd, firsthd, SEEK_SET);
error = read(fd, &kdhf, sizeof kdhf);
if (error != sizeof kdhf) {
if (lseek(fd, firsthd, SEEK_SET) != firsthd ||
read(fd, &kdhf, sizeof(kdhf)) != sizeof(kdhf)) {
syslog(LOG_ERR,
"error reading first dump header at offset %lld in %s: %m",
(long long)firsthd, device);

View File

@ -86,29 +86,40 @@ static int strIKtoi(const char *, char **, const char *);
static int ctl_sign[CTLTYPE+1] = {
[CTLTYPE_INT] = 1,
[CTLTYPE_LONG] = 1,
[CTLTYPE_S8] = 1,
[CTLTYPE_S16] = 1,
[CTLTYPE_S32] = 1,
[CTLTYPE_S64] = 1,
};
static int ctl_size[CTLTYPE+1] = {
[CTLTYPE_U8] = sizeof(uint8_t),
[CTLTYPE_U16] = sizeof(uint16_t),
[CTLTYPE_INT] = sizeof(int),
[CTLTYPE_UINT] = sizeof(u_int),
[CTLTYPE_LONG] = sizeof(long),
[CTLTYPE_ULONG] = sizeof(u_long),
[CTLTYPE_S8] = sizeof(int8_t),
[CTLTYPE_S16] = sizeof(int16_t),
[CTLTYPE_S32] = sizeof(int32_t),
[CTLTYPE_S64] = sizeof(int64_t),
[CTLTYPE_U8] = sizeof(uint8_t),
[CTLTYPE_U16] = sizeof(uint16_t),
[CTLTYPE_U32] = sizeof(uint32_t),
[CTLTYPE_U64] = sizeof(uint64_t),
};
static const char *ctl_typename[CTLTYPE+1] = {
[CTLTYPE_U8] = "uint8_t",
[CTLTYPE_U16] = "uint16_t",
[CTLTYPE_INT] = "integer",
[CTLTYPE_UINT] = "unsigned integer",
[CTLTYPE_LONG] = "long integer",
[CTLTYPE_ULONG] = "unsigned long",
[CTLTYPE_S64] = "int64_t",
[CTLTYPE_U8] = "uint8_t",
[CTLTYPE_U16] = "uint16_t",
[CTLTYPE_U32] = "uint16_t",
[CTLTYPE_U64] = "uint64_t",
[CTLTYPE_S8] = "int8_t",
[CTLTYPE_S16] = "int16_t",
[CTLTYPE_S32] = "int32_t",
[CTLTYPE_S64] = "int64_t",
};
static void
@ -225,8 +236,12 @@ parse(const char *string, int lineno)
int len, i, j;
const void *newval;
const char *newvalstr = NULL;
int8_t i8val;
uint8_t u8val;
int16_t i16val;
uint16_t u16val;
int32_t i32val;
uint32_t u32val;
int intval;
unsigned int uintval;
long longval;
@ -328,13 +343,17 @@ parse(const char *string, int lineno)
}
switch (kind & CTLTYPE) {
case CTLTYPE_U8:
case CTLTYPE_U16:
case CTLTYPE_INT:
case CTLTYPE_UINT:
case CTLTYPE_LONG:
case CTLTYPE_ULONG:
case CTLTYPE_S8:
case CTLTYPE_S16:
case CTLTYPE_S32:
case CTLTYPE_S64:
case CTLTYPE_U8:
case CTLTYPE_U16:
case CTLTYPE_U32:
case CTLTYPE_U64:
if (strlen(newvalstr) == 0) {
warnx("empty numeric value");
@ -353,17 +372,6 @@ parse(const char *string, int lineno)
errno = 0;
switch (kind & CTLTYPE) {
case CTLTYPE_U8:
u8val = (uint8_t)strtoul(newvalstr, &endptr, 0);
newval = &u8val;
newsize = sizeof(u8val);
break;
case CTLTYPE_U16:
u16val = (uint16_t)strtoul(newvalstr, &endptr,
0);
newval = &u16val;
newsize = sizeof(u16val);
break;
case CTLTYPE_INT:
if (strncmp(fmt, "IK", 2) == 0)
intval = strIKtoi(newvalstr, &endptr, fmt);
@ -391,11 +399,45 @@ parse(const char *string, int lineno)
case CTLTYPE_STRING:
newval = newvalstr;
break;
case CTLTYPE_S8:
i8val = (int8_t)strtol(newvalstr, &endptr, 0);
newval = &i8val;
newsize = sizeof(i8val);
break;
case CTLTYPE_S16:
i16val = (int16_t)strtol(newvalstr, &endptr,
0);
newval = &i16val;
newsize = sizeof(i16val);
break;
case CTLTYPE_S32:
i32val = (int32_t)strtol(newvalstr, &endptr,
0);
newval = &i32val;
newsize = sizeof(i32val);
break;
case CTLTYPE_S64:
i64val = strtoimax(newvalstr, &endptr, 0);
newval = &i64val;
newsize = sizeof(i64val);
break;
case CTLTYPE_U8:
u8val = (uint8_t)strtoul(newvalstr, &endptr, 0);
newval = &u8val;
newsize = sizeof(u8val);
break;
case CTLTYPE_U16:
u16val = (uint16_t)strtoul(newvalstr, &endptr,
0);
newval = &u16val;
newsize = sizeof(u16val);
break;
case CTLTYPE_U32:
u32val = (uint32_t)strtoul(newvalstr, &endptr,
0);
newval = &u32val;
newsize = sizeof(u32val);
break;
case CTLTYPE_U64:
u64val = strtoumax(newvalstr, &endptr, 0);
newval = &u64val;
@ -909,13 +951,17 @@ show_var(int *oid, int nlen)
free(oval);
return (0);
case CTLTYPE_U8:
case CTLTYPE_U16:
case CTLTYPE_INT:
case CTLTYPE_UINT:
case CTLTYPE_LONG:
case CTLTYPE_ULONG:
case CTLTYPE_S8:
case CTLTYPE_S16:
case CTLTYPE_S32:
case CTLTYPE_S64:
case CTLTYPE_U8:
case CTLTYPE_U16:
case CTLTYPE_U32:
case CTLTYPE_U64:
if (!nflag)
printf("%s%s", name, sep);
@ -923,14 +969,6 @@ show_var(int *oid, int nlen)
sep1 = "";
while (len >= intlen) {
switch (kind & CTLTYPE) {
case CTLTYPE_U8:
umv = *(uint8_t *)p;
mv = *(int8_t *)p;
break;
case CTLTYPE_U16:
umv = *(uint16_t *)p;
mv = *(int16_t *)p;
break;
case CTLTYPE_INT:
case CTLTYPE_UINT:
umv = *(u_int *)p;
@ -941,6 +979,21 @@ show_var(int *oid, int nlen)
umv = *(u_long *)p;
mv = *(long *)p;
break;
case CTLTYPE_S8:
case CTLTYPE_U8:
umv = *(uint8_t *)p;
mv = *(int8_t *)p;
break;
case CTLTYPE_S16:
case CTLTYPE_U16:
umv = *(uint16_t *)p;
mv = *(int16_t *)p;
break;
case CTLTYPE_S32:
case CTLTYPE_U32:
umv = *(uint32_t *)p;
mv = *(int32_t *)p;
break;
case CTLTYPE_S64:
case CTLTYPE_U64:
umv = *(uint64_t *)p;

View File

@ -14,12 +14,12 @@ NO_LINT=
.if exists(Makefile.man)
.include "Makefile.man"
.endif
.include "Makefile.inc"
.if defined(NOTYET)
MAN+= config.5 des_modes.7
.endif
.include "Makefile.inc"
# base sources
SRCS= cpt_err.c cryptlib.c cversion.c ex_data.c mem.c mem_dbg.c o_dir.c \
o_fips.c o_init.c o_str.c o_time.c uid.c
@ -380,6 +380,8 @@ INCSDIR= ${INCLUDEDIR}/openssl
CSTD= gnu89
CFLAGS+= -I${.OBJDIR}
CFLAGS+= -I${LCRYPTO_SRC}/crypto
CFLAGS+= -I${LCRYPTO_SRC}/crypto/asn1
CFLAGS+= -I${LCRYPTO_SRC}/crypto/evp
CFLAGS+= -I${LCRYPTO_SRC}/crypto/modes
@ -391,32 +393,32 @@ AFLAGS+= --noexecstack
ACFLAGS+= -Wa,--noexecstack
.endif
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
OPENSSLCONF_H= opensslconf-x86.h
.else
OPENSSLCONF_H= opensslconf-${MACHINE_CPUARCH}.h
.endif
CLEANFILES= buildinf.h opensslconf.h
buildinf.h: ${.CURDIR}/Makefile
buildinf.h: Makefile
( echo "#ifndef MK1MF_BUILD"; \
echo " /* auto-generated by util/mkbuildinf.pl for crypto/cversion.c */"; \
echo " #define CFLAGS \"compiler: ${COMPILER_TYPE}\""; \
echo " #define PLATFORM \"platform: FreeBSD-${MACHINE_ARCH}\""; \
echo "#endif" ) > ${.TARGET}
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
opensslconf.h: opensslconf-x86.h
.else
opensslconf.h: opensslconf-${MACHINE_CPUARCH}.h
.endif
opensslconf.h: ${OPENSSLCONF_H}
${CP} ${.ALLSRC} ${.TARGET}
.include <bsd.lib.mk>
.if ${MACHINE_CPUARCH} == "amd64"
.PATH: ${.CURDIR}/amd64
.elif ${MACHINE_CPUARCH} == "i386"
.PATH: ${.CURDIR}/i386
_bn_asmpath= ${LCRYPTO_SRC}/crypto/bn/asm
.endif
.if ${MACHINE_CPUARCH} == "amd64"
_bn_asmpath= ${LCRYPTO_SRC}/crypto/bn/asm
.if exists(${.CURDIR}/${MACHINE_CPUARCH})
.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
.endif
.PATH: ${LCRYPTO_SRC}/crypto \

View File

@ -7,10 +7,10 @@ OPENSSL_VER= 1.0.2d
OPENSSL_DATE= 2015-07-09
LCRYPTO_SRC= ${.CURDIR}/../../../crypto/openssl
LCRYPTO_DOC= ${.CURDIR}/../../../crypto/openssl/doc
LCRYPTO_DOC= ${LCRYPTO_SRC}/doc
CFLAGS+= -I${LCRYPTO_SRC}
CFLAGS+= -DTERMIOS -DANSI_SOURCE
CFLAGS+= -I${LCRYPTO_SRC} -I${LCRYPTO_SRC}/crypto -I${.OBJDIR}
CFLAGS+= -DOPENSSL_THREADS -DDSO_DLFCN -DHAVE_DLFCN_H
.include <bsd.endian.mk>

View File

@ -23,6 +23,8 @@ INCSDIR=${INCLUDEDIR}/openssl
LIBADD= crypto
CFLAGS+= -I${LCRYPTO_SRC}/crypto
.include <bsd.lib.mk>
.PATH: ${LCRYPTO_SRC}/ssl \

View File

@ -9,7 +9,7 @@ LIBADD= ssl crypto
.endif
.include "../../lib/libcrypto/Makefile.inc"
CFLAGS+=-DMONOLITH -I${.CURDIR}
CFLAGS+= -DMONOLITH
SRCS+= app_rand.c apps.c asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c \
dgst.c dh.c dhparam.c dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c \

View File

@ -379,8 +379,6 @@ MAN= aac.4 \
oce.4 \
ohci.4 \
orm.4 \
otus.4 \
otusfw.4 \
ow.4 \
ow_temp.4 \
owc.4 \
@ -425,8 +423,6 @@ MAN= aac.4 \
rndtest.4 \
route.4 \
rp.4 \
rsu.4 \
rsufw.4 \
rue.4 \
rum.4 \
run.4 \
@ -672,7 +668,6 @@ MLINKS+=nge.4 if_nge.4
MLINKS+=${_ntb.4} ${_if_ntb.4} \
${_ntb.4} ${_ntb_hw.4}
MLINKS+=${_nxge.4} ${_if_nxge.4}
MLINKS+=otus.4 if_otus.4
MLINKS+=ow.4 onewire.4
MLINKS+=patm.4 if_patm.4
MLINKS+=pccbb.4 cbb.4
@ -686,7 +681,6 @@ MLINKS+=rl.4 if_rl.4
MLINKS+=rue.4 if_rue.4
MLINKS+=rum.4 if_rum.4
MLINKS+=run.4 if_run.4
MLINKS+=rsu.4 if_rsu.4
MLINKS+=scsi.4 CAM.4 \
scsi.4 cam.4 \
scsi.4 scbus.4 \
@ -715,7 +709,6 @@ MLINKS+=tl.4 if_tl.4
MLINKS+=tun.4 if_tun.4
MLINKS+=tx.4 if_tx.4
MLINKS+=txp.4 if_txp.4
MLINKS+=urtwn.4 if_urtwn.4
MLINKS+=vge.4 if_vge.4
MLINKS+=vlan.4 if_vlan.4
MLINKS+=vxlan.4 if_vxlan.4
@ -869,6 +862,10 @@ _pfsync.4= pfsync.4
.if ${MK_USB} != "no"
MAN+= \
otus.4 \
otusfw.4 \
rsu.4 \
rsufw.4 \
u3g.4 \
uark.4 \
uart.4 \
@ -922,6 +919,8 @@ MAN+= \
uvisor.4 \
uvscom.4 \
MLINKS+=otus.4 if_otus.4
MLINKS+=rsu.4 if_rsu.4
MLINKS+=u3g.4 u3gstub.4
MLINKS+=uath.4 if_uath.4
MLINKS+=udav.4 if_udav.4
@ -929,6 +928,7 @@ 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

@ -60,7 +60,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 16, 2015
.Dd November 5, 2015
.Dt DDB 4
.Os
.Sh NAME
@ -560,8 +560,8 @@ The same as "show pcpu", but for every CPU present in the system.
.Pp
.It Ic show Cm allrman
Show information related with resource management, including
interrupt request lines, DMA request lines, I/O ports and I/O memory
addresses.
interrupt request lines, DMA request lines, I/O ports, I/O memory
addresses, and Resource IDs.
.\"
.Pp
.It Ic show Cm apic

View File

@ -16,7 +16,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 1, 2014
.Dd November 6, 2015
.Dt LAGG 4
.Os
.Sh NAME
@ -156,6 +156,7 @@ Gigabit Ethernet interfaces:
.Bd -literal -offset indent
# ifconfig bge0 up
# ifconfig bge1 up
# ifconfig lagg0 create
# ifconfig lagg0 laggproto lacp laggport bge0 laggport bge1 \e
192.168.1.1 netmask 255.255.255.0
.Ed
@ -168,6 +169,7 @@ device will be used:
# ifconfig em0 up
# ifconfig ath0 ether 00:11:22:33:44:55
# ifconfig create wlan0 wlandev ath0 ssid my_net up
# ifconfig lagg0 create
# ifconfig lagg0 laggproto failover laggport em0 laggport wlan0 \e
192.168.1.1 netmask 255.255.255.0
.Ed

View File

@ -57,12 +57,12 @@ will run on Domain 0 and the netfront driver will run on a guest domain.
However, it is also possible to run
.Nm
on a guest domain.
It may be bridged or routed to provide the netfront's
It may be bridged or routed to provide the netfront
domain access to other guest domains or to a physical network.
.Pp
In most respects, the
.Nm
device appears to the OS as an other Ethernet device.
device appears to the OS as any other Ethernet device.
It can be configured at runtime entirely with
.Xr ifconfig 8 .
In particular, it supports MAC changing, arbitrary MTU sizes, checksum
@ -101,9 +101,8 @@ device driver first appeared in
The
.Nm
driver was written by
.An Alan Somers Aq Mt alans@spectralogic.com
and
.An John Suykerbuyk Aq Mt johns@spectralogic.com .
.An Alan Somers Aq Mt asomers@FreeBSD.org
and John Suykerbuyk.
.Sh CAVEATS
Packets sent through Xennet pass over shared memory, so the protocol includes
no form of link-layer checksum or CRC.

View File

@ -1,7 +1,7 @@
.\" DO NOT EDIT-- this file is automatically generated.
.\" from FreeBSD: head/tools/build/options/makeman 287942 2015-09-17 22:04:46Z bdrewery
.\" from FreeBSD: head/tools/build/options/makeman 290435 2015-11-06 05:28:08Z bdrewery
.\" $FreeBSD$
.Dd September 18, 2015
.Dd November 5, 2015
.Dt SRC.CONF 5
.Os
.Sh NAME
@ -484,6 +484,14 @@ arm64/aarch64.
.\" from FreeBSD: head/tools/build/options/WITHOUT_EXAMPLES 156938 2006-03-21 09:06:24Z ru
Set to avoid installing examples to
.Pa /usr/share/examples/ .
.It Va WITH_FAST_DEPEND
.\" from FreeBSD: head/tools/build/options/WITH_FAST_DEPEND 290433 2015-11-06 04:45:29Z bdrewery
Set to generate
.Sy .depend
files in the build during compilation instead of the
historial
.Xr mkdep 1
call during the "make depend" phase.
.It Va WITHOUT_FDT
.\" from FreeBSD: head/tools/build/options/WITHOUT_FDT 221539 2011-05-06 19:10:27Z ru
Set to not build Flattened Device Tree support as part of the base system.

View File

@ -1274,6 +1274,7 @@ MLINKS+=pci.9 pci_alloc_msi.9 \
pci.9 pci_find_device.9 \
pci.9 pci_find_extcap.9 \
pci.9 pci_find_htcap.9 \
pci.9 pci_find_pcie_root_port.9 \
pci.9 pci_get_max_read_req.9 \
pci.9 pci_get_powerstate.9 \
pci.9 pci_get_vpd_ident.9 \
@ -1290,7 +1291,10 @@ MLINKS+=pci.9 pci_alloc_msi.9 \
pci.9 pci_save_state.9 \
pci.9 pci_set_powerstate.9 \
pci.9 pci_set_max_read_req.9 \
pci.9 pci_write_config.9
pci.9 pci_write_config.9 \
pci.9 pcie_adjust_config.9 \
pci.9 pcie_read_config.9 \
pci.9 pcie_write_config.9
MLINKS+=pci_iov_schema.9 pci_iov_schema_alloc_node.9 \
pci_iov_schema.9 pci_iov_schema_add_bool.9 \
pci_iov_schema.9 pci_iov_schema_add_string.9 \
@ -1627,10 +1631,16 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \
sysctl.9 SYSCTL_ADD_PROC.9 \
sysctl.9 SYSCTL_ADD_QUAD.9 \
sysctl.9 SYSCTL_ADD_ROOT_NODE.9 \
sysctl.9 SYSCTL_ADD_S8.9 \
sysctl.9 SYSCTL_ADD_S16.9 \
sysctl.9 SYSCTL_ADD_S32.9 \
sysctl.9 SYSCTL_ADD_S64.9 \
sysctl.9 SYSCTL_ADD_STRING.9 \
sysctl.9 SYSCTL_ADD_STRUCT.9 \
sysctl.9 SYSCTL_ADD_U8.9 \
sysctl.9 SYSCTL_ADD_U16.9 \
sysctl.9 SYSCTL_ADD_U32.9 \
sysctl.9 SYSCTL_ADD_U64.9 \
sysctl.9 SYSCTL_ADD_UAUTO.9 \
sysctl.9 SYSCTL_ADD_UINT.9 \
sysctl.9 SYSCTL_ADD_ULONG.9 \
@ -1646,10 +1656,16 @@ MLINKS+=sysctl.9 SYSCTL_DECL.9 \
sysctl.9 SYSCTL_PROC.9 \
sysctl.9 SYSCTL_QUAD.9 \
sysctl.9 SYSCTL_ROOT_NODE.9 \
sysctl.9 SYSCTL_S8.9 \
sysctl.9 SYSCTL_S16.9 \
sysctl.9 SYSCTL_S32.9 \
sysctl.9 SYSCTL_S64.9 \
sysctl.9 SYSCTL_STRING.9 \
sysctl.9 SYSCTL_STRUCT.9 \
sysctl.9 SYSCTL_U8.9 \
sysctl.9 SYSCTL_U16.9 \
sysctl.9 SYSCTL_U32.9 \
sysctl.9 SYSCTL_U64.9 \
sysctl.9 SYSCTL_UINT.9 \
sysctl.9 SYSCTL_ULONG.9 \
sysctl.9 SYSCTL_UQUAD.9

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 8, 2015
.Dd November 5, 2015
.Dt PCI 9
.Os
.Sh NAME
@ -42,6 +42,7 @@
.Nm pci_find_device ,
.Nm pci_find_extcap ,
.Nm pci_find_htcap ,
.Nm pci_find_pcie_root_port ,
.Nm pci_get_max_read_req ,
.Nm pci_get_powerstate ,
.Nm pci_get_vpd_ident ,
@ -58,7 +59,10 @@
.Nm pci_save_state ,
.Nm pci_set_max_read_req ,
.Nm pci_set_powerstate ,
.Nm pci_write_config
.Nm pci_write_config ,
.Nm pcie_adjust_config ,
.Nm pcie_read_config ,
.Nm pcie_write_config
.Nd PCI bus interface
.Sh SYNOPSIS
.In sys/bus.h
@ -88,6 +92,8 @@
.Fn pci_find_extcap "device_t dev" "int capability" "int *capreg"
.Ft int
.Fn pci_find_htcap "device_t dev" "int capability" "int *capreg"
.Ft device_t
.Fn pci_find_pcie_root_port "device_t dev"
.Ft int
.Fn pci_get_max_read_req "device_t dev"
.Ft int
@ -118,6 +124,18 @@
.Fn pci_set_powerstate "device_t dev" "int state"
.Ft void
.Fn pci_write_config "device_t dev" "int reg" "uint32_t val" "int width"
.Ft uint32_t
.Fo pcie_adjust_config
.Fa "device_t dev"
.Fa "int reg"
.Fa "uint32_t mask"
.Fa "uint32_t val"
.Fa "int width"
.Fc
.Ft uint32_t
.Fn pcie_read_config "device_t dev" "int reg" "int width"
.Ft void
.Fn pcie_write_config "device_t dev" "int reg" "uint32_t val" "int width"
.In dev/pci/pci_iov.h
.Ft int
.Fn pci_iov_attach "device_t dev" "nvlist_t *pf_schema" "nvlist_t *vf_schema"
@ -159,6 +177,48 @@ with
.Fa width
specifying the size of the access.
.Pp
The
.Fn pcie_adjust_config
function is used to modify the value of a register in the PCI-express
capability register set of device
.Fa dev .
The offset
.Fa reg
specifies a relative offset in the register set with
.Fa width
specifying the size of the access.
The new value of the register is computed by modifying bits set in
.Fa mask
to the value in
.Fa val .
Any bits not specified in
.Fa mask
are preserved.
The previous value of the register is returned.
.Pp
The
.Fn pcie_read_config
function is used to read the value of a register in the PCI-express
capability register set of device
.Fa dev .
The offset
.Fa reg
specifies a relative offset in the register set with
.Fa width
specifying the size of the access.
.Pp
The
.Fn pcie_write_config
function is used to write the value
.Fa val
to a register in the PCI-express capability register set of device
.Fa dev .
The offset
.Fa reg
specifies a relative offset in the register set with
.Fa width
specifying the size of the access.
.Pp
.Em NOTE :
Device drivers should only use these functions for functionality that
is not available via another
@ -281,6 +341,16 @@ If the capability is not found or the device is not a HyperTransport device,
returns an error.
.Pp
The
.Fn pci_find_pcie_root_port
function walks up the PCI device hierarchy to locate the PCI-express root
port upstream of
.Fa dev .
If a root port is not found,
.Fn pci_find_pcie_root_port
returns
.Dv NULL .
.Pp
The
.Fn pci_get_vpd_ident
function is used to fetch a device's Vital Product Data
.Pq VPD

View File

@ -37,10 +37,16 @@
.Nm SYSCTL_ADD_PROC ,
.Nm SYSCTL_ADD_QUAD ,
.Nm SYSCTL_ADD_ROOT_NODE ,
.Nm SYSCTL_ADD_S8 ,
.Nm SYSCTL_ADD_S16 ,
.Nm SYSCTL_ADD_S32 ,
.Nm SYSCTL_ADD_S64 ,
.Nm SYSCTL_ADD_STRING ,
.Nm SYSCTL_ADD_STRUCT ,
.Nm SYSCTL_ADD_U8 ,
.Nm SYSCTL_ADD_U16 ,
.Nm SYSCTL_ADD_U32 ,
.Nm SYSCTL_ADD_U64 ,
.Nm SYSCTL_ADD_UAUTO ,
.Nm SYSCTL_ADD_UINT ,
.Nm SYSCTL_ADD_ULONG ,
@ -56,10 +62,16 @@
.Nm SYSCTL_PROC ,
.Nm SYSCTL_QUAD ,
.Nm SYSCTL_ROOT_NODE ,
.Nm SYSCTL_S8 ,
.Nm SYSCTL_S16 ,
.Nm SYSCTL_S32 ,
.Nm SYSCTL_S64 ,
.Nm SYSCTL_STRING ,
.Nm SYSCTL_STRUCT ,
.Nm SYSCTL_U8 ,
.Nm SYSCTL_U16 ,
.Nm SYSCTL_U32 ,
.Nm SYSCTL_U64 ,
.Nm SYSCTL_UINT ,
.Nm SYSCTL_ULONG ,
.Nm SYSCTL_UQUAD
@ -76,7 +88,7 @@
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "int *ptr"
.Fa "intptr_t val"
.Fa "int val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
@ -131,7 +143,7 @@
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "quad_t *ptr"
.Fa "int64_t *ptr"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
@ -144,6 +156,50 @@
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_S8
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "int8_t *ptr"
.Fa "int8_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_S16
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "int16_t *ptr"
.Fa "int16_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_S32
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "int32_t *ptr"
.Fa "int32_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_S64
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "int64_t *ptr"
.Fa "int64_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_STRING
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
@ -172,8 +228,8 @@
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "unsigned int *ptr"
.Fa "intptr_t val"
.Fa "uint8_t *ptr"
.Fa "uint8_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
@ -183,8 +239,30 @@
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "unsigned int *ptr"
.Fa "intptr_t val"
.Fa "uint16_t *ptr"
.Fa "uint16_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_U32
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "uint32_t *ptr"
.Fa "uint32_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
.Fo SYSCTL_ADD_U64
.Fa "struct sysctl_ctx_list *ctx"
.Fa "struct sysctl_oid_list *parent"
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "uint64_t *ptr"
.Fa "uint64_t val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
@ -195,7 +273,7 @@
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "unsigned int *ptr"
.Fa "intptr_t val"
.Fa "unsigned int val"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
@ -215,7 +293,7 @@
.Fa "int number"
.Fa "const char *name"
.Fa "int ctlflags"
.Fa "u_quad_t *ptr"
.Fa "uint64_t *ptr"
.Fa "const char *descr"
.Fc
.Ft struct sysctl_oid *
@ -251,11 +329,17 @@
.Fn SYSCTL_OPAQUE parent number name ctlflags ptr len format descr
.Fn SYSCTL_PROC parent number name ctlflags arg1 arg2 handler format descr
.Fn SYSCTL_QUAD parent number name ctlflags ptr val descr
.Fn SYSCTL_ROOT_NODE number name ctlflags handler descr
.Fn SYSCTL_S8 parent number name ctlflags ptr val descr
.Fn SYSCTL_S16 parent number name ctlflags ptr val descr
.Fn SYSCTL_S32 parent number name ctlflags ptr val descr
.Fn SYSCTL_S64 parent number name ctlflags ptr val descr
.Fn SYSCTL_STRING parent number name ctlflags arg len descr
.Fn SYSCTL_STRUCT parent number name ctlflags ptr struct_type descr
.Fn SYSCTL_ROOT_NODE number name ctlflags handler descr
.Fn SYSCTL_U8 parent number name ctlflags ptr val descr
.Fn SYSCTL_U16 parent number name ctlflags ptr val descr
.Fn SYSCTL_U32 parent number name ctlflags ptr val descr
.Fn SYSCTL_U64 parent number name ctlflags ptr val descr
.Fn SYSCTL_UINT parent number name ctlflags ptr val descr
.Fn SYSCTL_ULONG parent number name ctlflags ptr val descr
.Fn SYSCTL_UQUAD parent number name ctlflags ptr val descr
@ -439,10 +523,16 @@ Static sysctls are declared using one of the
.Fn SYSCTL_PROC ,
.Fn SYSCTL_QUAD ,
.Fn SYSCTL_ROOT_NODE ,
.Fn SYSCTL_S8 ,
.Fn SYSCTL_S16 ,
.Fn SYSCTL_S32 ,
.Fn SYSCTL_S64 ,
.Fn SYSCTL_STRING ,
.Fn SYSCTL_STRUCT ,
.Fn SYSCTL_U8 ,
.Fn SYSCTL_U16 ,
.Fn SYSCTL_U32 ,
.Fn SYSCTL_U64 ,
.Fn SYSCTL_UINT ,
.Fn SYSCTL_ULONG
or
@ -457,10 +547,16 @@ Dynamic nodes are created using one of the
.Fn SYSCTL_ADD_PROC ,
.Fn SYSCTL_ADD_QUAD ,
.Fn SYSCTL_ADD_ROOT_NODE ,
.Fn SYSCTL_ADD_S8 ,
.Fn SYSCTL_ADD_S16 ,
.Fn SYSCTL_ADD_S32 ,
.Fn SYSCTL_ADD_S64 ,
.Fn SYSCTL_ADD_STRING ,
.Fn SYSCTL_ADD_STRUCT ,
.Fn SYSCTL_ADD_U8 ,
.Fn SYSCTL_ADD_U16 ,
.Fn SYSCTL_ADD_U32 ,
.Fn SYSCTL_ADD_U64 ,
.Fn SYSCTL_ADD_UAUTO ,
.Fn SYSCTL_ADD_UINT ,
.Fn SYSCTL_ADD_ULONG ,
@ -484,6 +580,12 @@ This is a node intended to be a parent for other nodes.
This is a signed integer.
.It Dv CTLTYPE_STRING
This is a nul-terminated string stored in a character array.
.It Dv CTLTYPE_S8
This is an 8-bit signed integer.
.It Dv CTLTYPE_S16
This is a 16-bit signed integer.
.It Dv CTLTYPE_S32
This is a 32-bit signed integer.
.It Dv CTLTYPE_S64
This is a 64-bit signed integer.
.It Dv CTLTYPE_OPAQUE
@ -495,14 +597,16 @@ Alias for
This is an 8-bit unsigned integer.
.It Dv CTLTYPE_U16
This is a 16-bit unsigned integer.
.It Dv CTLTYPE_U32
This is a 32-bit unsigned integer.
.It Dv CTLTYPE_U64
This is a 64-bit unsigned integer.
.It Dv CTLTYPE_UINT
This is an unsigned integer.
.It Dv CTLTYPE_LONG
This is a signed long.
.It Dv CTLTYPE_ULONG
This is an unsigned long.
.It Dv CTLTYPE_U64
This is a 64-bit unsigned integer.
.El
.Pp
All sysctl types except for new node declarations require one of the following

View File

@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 28, 2014
.Dd November 6, 2015
.Dt SYSCTL_ADD_OID 9
.Os
.Sh NAME
@ -47,7 +47,7 @@
.Fa "const char *name"
.Fa "int kind"
.Fa "void *arg1"
.Fa "intptr_t arg2"
.Fa "intmax_t arg2"
.Fa "int (*handler) (SYSCTL_HANDLER_ARGS)"
.Fa "const char *format"
.Fa "const char *descr"

View File

@ -54,6 +54,18 @@ MKDEPCMD?= CC='${CC} ${DEPFLAGS}' mkdep
MKDEPCMD?= mkdep
.endif
DEPENDFILE?= .depend
DEPENDFILES= ${DEPENDFILE}
.if ${MK_FAST_DEPEND} == "yes"
DEPENDFILES+= ${DEPENDFILE}.*
DEPEND_CFLAGS+= -MD -MP -MF${DEPENDFILE}.${.TARGET}
DEPEND_CFLAGS+= -MT${.TARGET}
CFLAGS+= ${DEPEND_CFLAGS}
DEPENDOBJS+= ${OBJS} ${POBJS} ${SOBJS}
.for __obj in ${DEPENDOBJS:O:u}
.sinclude "${DEPENDFILE}.${__obj}"
DEPENDFILES_OBJS+= ${DEPENDFILE}.${__obj}
.endfor
.endif # ${MK_FAST_DEPEND} == "yes"
# Keep `tags' here, before SRCS are mangled below for `depend'.
.if !target(tags) && defined(SRCS) && !defined(NO_TAGS)
@ -161,7 +173,7 @@ afterdepend: beforedepend
depend: beforedepend ${DEPENDFILE} afterdepend
# Tell bmake not to look for generated files via .PATH
.NOPATH: ${DEPENDFILE}
.NOPATH: ${DEPENDFILE} ${DEPENDFILES_OBJS}
# Different types of sources are compiled with slightly different flags.
# Split up the sources, and filter out headers and non-applicable flags.
@ -172,6 +184,7 @@ MKDEP_CXXFLAGS= ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BIDU]*} \
DPSRCS+= ${SRCS}
${DEPENDFILE}: ${DPSRCS}
.if ${MK_FAST_DEPEND} == "no"
rm -f ${DEPENDFILE}
.if !empty(DPSRCS:M*.[cS])
${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
@ -182,7 +195,11 @@ ${DEPENDFILE}: ${DPSRCS}
${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
${MKDEP_CXXFLAGS} \
${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
.else
.endif
.else
: > ${.TARGET}
.endif # ${MK_FAST_DEPEND} == "no"
.if target(_EXTRADEPEND)
_EXTRADEPEND: .USE
${DEPENDFILE}: _EXTRADEPEND
@ -207,12 +224,12 @@ afterdepend:
cleandepend:
.if defined(SRCS)
.if ${CTAGS:T} == "gtags"
rm -f ${DEPENDFILE} GPATH GRTAGS GSYMS GTAGS
rm -f ${DEPENDFILES} GPATH GRTAGS GSYMS GTAGS
.if defined(HTML)
rm -rf HTML
.endif
.else
rm -f ${DEPENDFILE} tags
rm -f ${DEPENDFILES} tags
.endif
.endif
.endif

View File

@ -305,10 +305,12 @@ all: _manpages
.endif
_EXTRADEPEND:
.if ${MK_FAST_DEPEND} == "no"
@TMP=_depend$$$$; \
sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.So:/' < ${DEPENDFILE} \
> $$TMP; \
mv $$TMP ${DEPENDFILE}
.endif
.if !defined(NO_EXTRADEPEND) && defined(SHLIB_NAME)
.if defined(DPADD) && !empty(DPADD)
echo ${SHLIB_NAME_FULL}: ${DPADD} >> ${DEPENDFILE}

View File

@ -66,6 +66,7 @@ __DEFAULT_YES_OPTIONS = \
WARNS
__DEFAULT_NO_OPTIONS = \
FAST_DEPEND \
CTF \
DEBUG_FILES \
INSTALL_AS_USER \

View File

@ -1,6 +1,6 @@
# $FreeBSD$
#
# The include file <src.opts.mk> set common variables for owner,
# The include file <bsd.own.mk> set common variables for owner,
# group, mode, and directories. Defaults are in brackets.
#
#

View File

@ -82,9 +82,9 @@ ${PROG_FULL}: beforelinking
.endif
${PROG_FULL}: ${OBJS}
.if defined(PROG_CXX)
${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
${CXX} ${CXXFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.else
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
${CC} ${CFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.endif
.if ${MK_CTF} != "no"
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
@ -112,9 +112,9 @@ ${PROG_FULL}: beforelinking
.endif
${PROG_FULL}: ${OBJS}
.if defined(PROG_CXX)
${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
${CXX} ${CXXFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.else
${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
${CC} ${CFLAGS:N-M*} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
.endif
.if ${MK_CTF} != "no"
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}

View File

@ -38,3 +38,5 @@ CPP= ${HOST_CPP}
HOST_CFLAGS+= -DHOSTPROG
CFLAGS+= ${HOST_CFLAGS}
.endif
.-include "src.init.mk"

11
share/mk/src.init.mk Normal file
View File

@ -0,0 +1,11 @@
# $FreeBSD$
.if !target(__<src.init.mk>__)
__<src.init.mk>__:
.if !target(buildenv)
buildenv: .PHONY
${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv
.endif
.endif # !target(__<src.init.mk>__)

View File

@ -39,7 +39,7 @@ _INTERNALLIBS= \
netbsd \
ntp \
ntpevent \
ohash \
openbsd \
opts \
parse \
readline \
@ -314,8 +314,8 @@ LIBELFTC?= ${LIBELFTCDIR}/libelftc.a
LIBREADLINEDIR= ${ROOTOBJDIR}/gnu/lib/libreadline/readline
LIBREADLINE?= ${LIBREADLINEDIR}/libreadline.a
LIBOHASHDIR= ${ROOTOBJDIR}/lib/libohash
LIBOHASH?= ${LIBOHASHDIR}/libohash.a
LIBOPENBSDDIR= ${ROOTOBJDIR}/lib/libopenbsd
LIBOPENBSD?= ${LIBOPENBSDDIR}/libopenbsd.a
LIBSMDIR= ${ROOTOBJDIR}/lib/libsm
LIBSM?= ${LIBSMDIR}/libsm.a

View File

@ -473,11 +473,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
bus_dma_tag_t newtag;
int error = 0;
#if 0
if (!parent)
parent = arm_root_dma_tag;
#endif
/* Basic sanity checking. */
KASSERT(boundary == 0 || powerof2(boundary),
("dma tag boundary %lu, must be a power of 2", boundary));

View File

@ -224,9 +224,6 @@ static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
static void bus_dmamap_sync_sl(struct sync_list *sl, bus_dmasync_op_t op,
int bufaligned);
/* Default tag, as most drivers provide no parent tag. */
bus_dma_tag_t arm_root_dma_tag;
/*
* ----------------------------------------------------------------------------
* Begin block of code useful to transplant to other implementations.
@ -406,8 +403,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
int error = 0;
/* Return a NULL tag on failure */
*dmat = NULL;
if (!parent)
parent = arm_root_dma_tag;
newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_BUSDMA, M_NOWAIT);
if (newtag == NULL) {

View File

@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <machine/db_machdep.h>
#include <machine/machdep.h>
#include <machine/vmparam.h>
#include <machine/cpu.h>
@ -291,94 +292,35 @@ db_fetch_reg(int reg)
}
}
static u_int
db_branch_taken_read_int(void *cookie __unused, vm_offset_t offset, u_int *val)
{
u_int ret;
db_read_bytes(offset, 4, (char *)&ret);
*val = ret;
return (0);
}
static u_int
db_branch_taken_fetch_reg(void *cookie __unused, int reg)
{
return (db_fetch_reg(reg));
}
u_int
branch_taken(u_int insn, db_addr_t pc)
{
u_int addr, nregs, offset = 0;
register_t new_pc;
int ret;
switch ((insn >> 24) & 0xf) {
case 0x2: /* add pc, reg1, #value */
case 0x0: /* add pc, reg1, reg2, lsl #offset */
addr = db_fetch_reg((insn >> 16) & 0xf);
if (((insn >> 16) & 0xf) == 15)
addr += 8;
if (insn & 0x0200000) {
offset = (insn >> 7) & 0x1e;
offset = (insn & 0xff) << (32 - offset) |
(insn & 0xff) >> offset;
} else {
ret = arm_predict_branch(NULL, insn, (register_t)pc, &new_pc,
db_branch_taken_fetch_reg, db_branch_taken_read_int);
offset = db_fetch_reg(insn & 0x0f);
if ((insn & 0x0000ff0) != 0x00000000) {
if (insn & 0x10)
nregs = db_fetch_reg((insn >> 8) & 0xf);
else
nregs = (insn >> 7) & 0x1f;
switch ((insn >> 5) & 3) {
case 0:
/* lsl */
offset = offset << nregs;
break;
case 1:
/* lsr */
offset = offset >> nregs;
break;
default:
break; /* XXX */
}
}
return (addr + offset);
}
case 0xa: /* b ... */
case 0xb: /* bl ... */
addr = ((insn << 2) & 0x03ffffff);
if (addr & 0x02000000)
addr |= 0xfc000000;
return (pc + 8 + addr);
case 0x7: /* ldr pc, [pc, reg, lsl #2] */
addr = db_fetch_reg(insn & 0xf);
addr = pc + 8 + (addr << 2);
db_read_bytes(addr, 4, (char *)&addr);
return (addr);
case 0x1: /* mov pc, reg */
addr = db_fetch_reg(insn & 0xf);
return (addr);
case 0x4:
case 0x5: /* ldr pc, [reg] */
addr = db_fetch_reg((insn >> 16) & 0xf);
/* ldr pc, [reg, #offset] */
if (insn & (1 << 24))
offset = insn & 0xfff;
if (insn & 0x00800000)
addr += offset;
else
addr -= offset;
db_read_bytes(addr, 4, (char *)&addr);
return (addr);
case 0x8: /* ldmxx reg, {..., pc} */
case 0x9:
addr = db_fetch_reg((insn >> 16) & 0xf);
nregs = (insn & 0x5555) + ((insn >> 1) & 0x5555);
nregs = (nregs & 0x3333) + ((nregs >> 2) & 0x3333);
nregs = (nregs + (nregs >> 4)) & 0x0f0f;
nregs = (nregs + (nregs >> 8)) & 0x001f;
switch ((insn >> 23) & 0x3) {
case 0x0: /* ldmda */
addr = addr - 0;
break;
case 0x1: /* ldmia */
addr = addr + 0 + ((nregs - 1) << 2);
break;
case 0x2: /* ldmdb */
addr = addr - 4;
break;
case 0x3: /* ldmib */
addr = addr + 4 + ((nregs - 1) << 2);
break;
}
db_read_bytes(addr, 4, (char *)&addr);
return (addr);
default:
panic("branch_taken: botch");
}
if (ret != 0)
kdb_reenter();
return (new_pc);
}

View File

@ -95,6 +95,7 @@ __FBSDID("$FreeBSD$");
#include <machine/atags.h>
#include <machine/cpu.h>
#include <machine/cpuinfo.h>
#include <machine/db_machdep.h>
#include <machine/devmap.h>
#include <machine/frame.h>
#include <machine/intr.h>
@ -627,11 +628,81 @@ ptrace_write_int(struct thread *td, vm_offset_t addr, u_int32_t v)
return proc_rwmem(td->td_proc, &uio);
}
static u_int
ptrace_get_usr_reg(void *cookie, int reg)
{
int ret;
struct thread *td = cookie;
KASSERT(((reg >= 0) && (reg <= ARM_REG_NUM_PC)),
("reg is outside range"));
switch(reg) {
case ARM_REG_NUM_PC:
ret = td->td_frame->tf_pc;
break;
case ARM_REG_NUM_LR:
ret = td->td_frame->tf_usr_lr;
break;
case ARM_REG_NUM_SP:
ret = td->td_frame->tf_usr_sp;
break;
default:
ret = *((register_t*)&td->td_frame->tf_r0 + reg);
break;
}
return (ret);
}
static u_int
ptrace_get_usr_int(void* cookie, vm_offset_t offset, u_int* val)
{
struct thread *td = cookie;
u_int error;
error = ptrace_read_int(td, offset, val);
return (error);
}
/**
* This function parses current instruction opcode and decodes
* any possible jump (change in PC) which might occur after
* the instruction is executed.
*
* @param td Thread structure of analysed task
* @param cur_instr Currently executed instruction
* @param alt_next_address Pointer to the variable where
* the destination address of the
* jump instruction shall be stored.
*
* @return <0> when jump is possible
* <EINVAL> otherwise
*/
static int
ptrace_get_alternative_next(struct thread *td, uint32_t cur_instr,
uint32_t *alt_next_address)
{
int error;
if (inst_branch(cur_instr) || inst_call(cur_instr) ||
inst_return(cur_instr)) {
error = arm_predict_branch(td, cur_instr, td->td_frame->tf_pc,
alt_next_address, ptrace_get_usr_reg, ptrace_get_usr_int);
return (error);
}
return (EINVAL);
}
int
ptrace_single_step(struct thread *td)
{
struct proc *p;
int error;
int error, error_alt;
uint32_t cur_instr, alt_next = 0;
/* TODO: This needs to be updated for Thumb-2 */
if ((td->td_frame->tf_spsr & PSR_T) != 0)
@ -639,20 +710,48 @@ ptrace_single_step(struct thread *td)
KASSERT(td->td_md.md_ptrace_instr == 0,
("Didn't clear single step"));
KASSERT(td->td_md.md_ptrace_instr_alt == 0,
("Didn't clear alternative single step"));
p = td->td_proc;
PROC_UNLOCK(p);
error = ptrace_read_int(td, td->td_frame->tf_pc + 4,
&td->td_md.md_ptrace_instr);
error = ptrace_read_int(td, td->td_frame->tf_pc,
&cur_instr);
if (error)
goto out;
error = ptrace_write_int(td, td->td_frame->tf_pc + 4,
PTRACE_BREAKPOINT);
if (error)
td->td_md.md_ptrace_instr = 0;
td->td_md.md_ptrace_addr = td->td_frame->tf_pc + 4;
error = ptrace_read_int(td, td->td_frame->tf_pc + INSN_SIZE,
&td->td_md.md_ptrace_instr);
if (error == 0) {
error = ptrace_write_int(td, td->td_frame->tf_pc + INSN_SIZE,
PTRACE_BREAKPOINT);
if (error) {
td->td_md.md_ptrace_instr = 0;
} else {
td->td_md.md_ptrace_addr = td->td_frame->tf_pc +
INSN_SIZE;
}
}
error_alt = ptrace_get_alternative_next(td, cur_instr, &alt_next);
if (error_alt == 0) {
error_alt = ptrace_read_int(td, alt_next,
&td->td_md.md_ptrace_instr_alt);
if (error_alt) {
td->td_md.md_ptrace_instr_alt = 0;
} else {
error_alt = ptrace_write_int(td, alt_next,
PTRACE_BREAKPOINT);
if (error_alt)
td->td_md.md_ptrace_instr_alt = 0;
else
td->td_md.md_ptrace_addr_alt = alt_next;
}
}
out:
PROC_LOCK(p);
return (error);
return ((error != 0) && (error_alt != 0));
}
int
@ -664,7 +763,7 @@ ptrace_clear_single_step(struct thread *td)
if ((td->td_frame->tf_spsr & PSR_T) != 0)
return (EINVAL);
if (td->td_md.md_ptrace_instr) {
if (td->td_md.md_ptrace_instr != 0) {
p = td->td_proc;
PROC_UNLOCK(p);
ptrace_write_int(td, td->td_md.md_ptrace_addr,
@ -672,6 +771,16 @@ ptrace_clear_single_step(struct thread *td)
PROC_LOCK(p);
td->td_md.md_ptrace_instr = 0;
}
if (td->td_md.md_ptrace_instr_alt != 0) {
p = td->td_proc;
PROC_UNLOCK(p);
ptrace_write_int(td, td->td_md.md_ptrace_addr_alt,
td->td_md.md_ptrace_instr_alt);
PROC_LOCK(p);
td->td_md.md_ptrace_instr_alt = 0;
}
return (0);
}
@ -1074,6 +1183,111 @@ init_proc0(vm_offset_t kstack)
pcpup->pc_curpcb = thread0.td_pcb;
}
int
arm_predict_branch(void *cookie, u_int insn, register_t pc, register_t *new_pc,
u_int (*fetch_reg)(void*, int), u_int (*read_int)(void*, vm_offset_t, u_int*))
{
u_int addr, nregs, offset = 0;
int error = 0;
switch ((insn >> 24) & 0xf) {
case 0x2: /* add pc, reg1, #value */
case 0x0: /* add pc, reg1, reg2, lsl #offset */
addr = fetch_reg(cookie, (insn >> 16) & 0xf);
if (((insn >> 16) & 0xf) == 15)
addr += 8;
if (insn & 0x0200000) {
offset = (insn >> 7) & 0x1e;
offset = (insn & 0xff) << (32 - offset) |
(insn & 0xff) >> offset;
} else {
offset = fetch_reg(cookie, insn & 0x0f);
if ((insn & 0x0000ff0) != 0x00000000) {
if (insn & 0x10)
nregs = fetch_reg(cookie,
(insn >> 8) & 0xf);
else
nregs = (insn >> 7) & 0x1f;
switch ((insn >> 5) & 3) {
case 0:
/* lsl */
offset = offset << nregs;
break;
case 1:
/* lsr */
offset = offset >> nregs;
break;
default:
break; /* XXX */
}
}
*new_pc = addr + offset;
return (0);
}
case 0xa: /* b ... */
case 0xb: /* bl ... */
addr = ((insn << 2) & 0x03ffffff);
if (addr & 0x02000000)
addr |= 0xfc000000;
*new_pc = (pc + 8 + addr);
return (0);
case 0x7: /* ldr pc, [pc, reg, lsl #2] */
addr = fetch_reg(cookie, insn & 0xf);
addr = pc + 8 + (addr << 2);
error = read_int(cookie, addr, &addr);
*new_pc = addr;
return (error);
case 0x1: /* mov pc, reg */
*new_pc = fetch_reg(cookie, insn & 0xf);
return (0);
case 0x4:
case 0x5: /* ldr pc, [reg] */
addr = fetch_reg(cookie, (insn >> 16) & 0xf);
/* ldr pc, [reg, #offset] */
if (insn & (1 << 24))
offset = insn & 0xfff;
if (insn & 0x00800000)
addr += offset;
else
addr -= offset;
error = read_int(cookie, addr, &addr);
*new_pc = addr;
return (error);
case 0x8: /* ldmxx reg, {..., pc} */
case 0x9:
addr = fetch_reg(cookie, (insn >> 16) & 0xf);
nregs = (insn & 0x5555) + ((insn >> 1) & 0x5555);
nregs = (nregs & 0x3333) + ((nregs >> 2) & 0x3333);
nregs = (nregs + (nregs >> 4)) & 0x0f0f;
nregs = (nregs + (nregs >> 8)) & 0x001f;
switch ((insn >> 23) & 0x3) {
case 0x0: /* ldmda */
addr = addr - 0;
break;
case 0x1: /* ldmia */
addr = addr + 0 + ((nregs - 1) << 2);
break;
case 0x2: /* ldmdb */
addr = addr - 4;
break;
case 0x3: /* ldmib */
addr = addr + 4 + ((nregs - 1) << 2);
break;
}
error = read_int(cookie, addr, &addr);
*new_pc = addr;
return (error);
default:
return (EINVAL);
}
}
#ifdef ARM_NEW_PMAP
void
set_stackptrs(int cpu)

View File

@ -98,18 +98,18 @@ struct abort {
* - Always fatal as we do not know what does it mean.
* Imprecise External Abort:
* - Always fatal, but can be handled somehow in the future.
* Now, due to PCIe buggy harware, ignored.
* Now, due to PCIe buggy hardware, ignored.
* Precise External Abort:
* - Always fatal, but who knows in the future???
* Debug Event:
* - Special handling.
* External Translation Abort (L1 & L2)
* - Always fatal as something is screwed up in page tables or harware.
* - Always fatal as something is screwed up in page tables or hardware.
* Domain Fault (L1 & L2):
* - Always fatal as we do not play game with domains.
* Alignment Fault:
* - Everything should be aligned in kernel including user to kernel and
* vice versa data copying, so we ignore pcb_onfault, and it's always fatal.
* - Everything should be aligned in kernel with exception of user to kernel
* and vice versa data copying, so if pcb_onfault is not set, it's fatal.
* We generate signal in case of abort from user mode.
* Instruction cache maintenance:
* - According to manual, this is translation fault during cache maintenance
@ -125,7 +125,7 @@ struct abort {
* Translation Fault (L1 & L2):
* - Standard fault mechanism is held including vm_fault().
* Permission Fault (L1 & L2):
* - Fast harware emulation of modify bits and in other cases, standard
* - Fast hardware emulation of modify bits and in other cases, standard
* fault mechanism is held including vm_fault().
*/
@ -167,7 +167,6 @@ static const struct abort aborts[] = {
{abort_fatal, "Undefined Code (0x40F)"}
};
static __inline void
call_trapsignal(struct thread *td, int sig, int code, vm_offset_t addr)
{
@ -195,7 +194,7 @@ call_trapsignal(struct thread *td, int sig, int code, vm_offset_t addr)
*
* The imprecise means that we don't know where the abort happened,
* thus FAR is undefined. The abort should not never fire, but hot
* plugging or accidental harware failure can be the cause of it.
* plugging or accidental hardware failure can be the cause of it.
* If the abort happens, it can even be on different (thread) context.
* Without any additional support, the abort is fatal, as we do not
* know what really happened.
@ -214,7 +213,9 @@ call_trapsignal(struct thread *td, int sig, int code, vm_offset_t addr)
static __inline void
abort_imprecise(struct trapframe *tf, u_int fsr, u_int prefetch, u_int usermode)
{
/* XXXX We can got imprecise abort as result of access
/*
* XXX - We can got imprecise abort as result of access
* to not-present PCI/PCIe configuration space.
*/
#if 0
@ -245,6 +246,7 @@ static __inline void
abort_debug(struct trapframe *tf, u_int fsr, u_int prefetch, u_int usermode,
u_int far)
{
if (usermode) {
struct thread *td;
@ -316,6 +318,18 @@ abort_handler(struct trapframe *tf, int prefetch)
return;
}
/*
* ARM has a set of unprivileged load and store instructions
* (LDRT/LDRBT/STRT/STRBT ...) which are supposed to be used in other
* than user mode and OS should recognize their aborts and behave
* appropriately. However, there is no way how to do that reasonably
* in general unless we restrict the handling somehow.
*
* For now, these instructions are used only in copyin()/copyout()
* like functions where usermode buffers are checked in advance that
* they are not from KVA space. Thus, no action is needed here.
*/
#ifdef ARM_NEW_PMAP
rv = pmap_fault(PCPU_GET(curpmap), far, fsr, idx, usermode);
if (rv == 0) {
@ -330,7 +344,6 @@ abort_handler(struct trapframe *tf, int prefetch)
/*
* Now, when we handled imprecise and debug aborts, the rest of
* aborts should be really related to mapping.
*
*/
PCPU_INC(cnt.v_trap);
@ -417,7 +430,7 @@ abort_handler(struct trapframe *tf, int prefetch)
return;
}
/* Handle remaining I cache aborts. */
/* Handle remaining I-cache aborts. */
if (idx == FAULT_ICACHE) {
if (abort_icache(tf, idx, fsr, far, prefetch, td, &ksig))
goto do_trapsignal;
@ -434,7 +447,7 @@ abort_handler(struct trapframe *tf, int prefetch)
* the MMU.
*/
/* fusubailout is used by [fs]uswintr to avoid page faulting */
/* fusubailout is used by [fs]uswintr to avoid page faulting. */
pcb = td->td_pcb;
if (__predict_false(pcb->pcb_onfault == fusubailout)) {
tf->tf_r0 = EFAULT;
@ -442,19 +455,6 @@ abort_handler(struct trapframe *tf, int prefetch)
return;
}
/*
* QQQ: ARM has a set of unprivileged load and store instructions
* (LDRT/LDRBT/STRT/STRBT ...) which are supposed to be used
* in other than user mode and OS should recognize their
* aborts and behaved appropriately. However, there is no way
* how to do that reasonably in general unless we restrict
* the handling somehow. One way is to limit the handling for
* aborts which come from undefined mode only.
*
* Anyhow, we do not use these instructions and do not implement
* any special handling for them.
*/
va = trunc_page(far);
if (va >= KERNBASE) {
/*
@ -536,7 +536,7 @@ abort_handler(struct trapframe *tf, int prefetch)
/*
* abort_fatal() handles the following data aborts:
*
* FAULT_DEBUG - Debug Event
* FAULT_ACCESS_xx - Acces Bit
* FAULT_EA_PREC - Precise External Abort
@ -553,8 +553,8 @@ abort_handler(struct trapframe *tf, int prefetch)
* Note: If 'l' is NULL, we assume we're dealing with a prefetch abort.
*/
static int
abort_fatal(struct trapframe *tf, u_int idx, u_int fsr, u_int far, u_int prefetch,
struct thread *td, struct ksig *ksig)
abort_fatal(struct trapframe *tf, u_int idx, u_int fsr, u_int far,
u_int prefetch, struct thread *td, struct ksig *ksig)
{
u_int usermode;
const char *mode;
@ -609,37 +609,28 @@ abort_fatal(struct trapframe *tf, u_int idx, u_int fsr, u_int far, u_int prefetc
*
* FAULT_ALIGN - Alignment fault
*
* Every memory access should be correctly aligned in kernel including
* user to kernel and vice versa data copying, so we ignore pcb_onfault,
* and it's always fatal. We generate a signal in case of abort from user mode.
* Everything should be aligned in kernel with exception of user to kernel
* and vice versa data copying, so if pcb_onfault is not set, it's fatal.
* We generate signal in case of abort from user mode.
*/
static int
abort_align(struct trapframe *tf, u_int idx, u_int fsr, u_int far, u_int prefetch,
struct thread *td, struct ksig *ksig)
abort_align(struct trapframe *tf, u_int idx, u_int fsr, u_int far,
u_int prefetch, struct thread *td, struct ksig *ksig)
{
u_int usermode;
usermode = TRAPF_USERMODE(tf);
/*
* Alignment faults are always fatal if they occur in any but user mode.
*
* XXX The old trap code handles pcb fault even for alignment traps.
* Unfortunately, we don't known why and if is this need.
*/
if (!usermode) {
if (td->td_intr_nesting_level == 0 && td != NULL &&
td->td_pcb->pcb_onfault != NULL) {
printf("%s: Got alignment fault with pcb_onfault set"
", please report this issue\n", __func__);
tf->tf_r0 = EFAULT;;
tf->tf_r0 = EFAULT;
tf->tf_pc = (int)td->td_pcb->pcb_onfault;
return (0);
}
abort_fatal(tf, idx, fsr, far, prefetch, td, ksig);
}
/* Deliver a bus error signal to the process */
ksig->code = 0;
ksig->code = BUS_ADRALN;
ksig->sig = SIGBUS;
ksig->addr = far;
return (1);
@ -660,9 +651,10 @@ abort_align(struct trapframe *tf, u_int idx, u_int fsr, u_int far, u_int prefetc
* should be held here including vm_fault() calling.
*/
static int
abort_icache(struct trapframe *tf, u_int idx, u_int fsr, u_int far, u_int prefetch,
struct thread *td, struct ksig *ksig)
abort_icache(struct trapframe *tf, u_int idx, u_int fsr, u_int far,
u_int prefetch, struct thread *td, struct ksig *ksig)
{
abort_fatal(tf, idx, fsr, far, prefetch, td, ksig);
return(0);
}

View File

@ -661,7 +661,10 @@ static int
at91_pmc_probe(device_t dev)
{
#ifdef FDT
if (!ofw_bus_is_compatible(dev, "atmel,at91rm9200-pmc"))
if (!ofw_bus_is_compatible(dev, "atmel,at91rm9200-pmc") &&
!ofw_bus_is_compatible(dev, "atmel,at91sam9260-pmc") &&
!ofw_bus_is_compatible(dev, "atmel,at91sam9g45-pmc") &&
!ofw_bus_is_compatible(dev, "atmel,at91sam9x5-pmc"))
return (ENXIO);
#endif
device_set_desc(dev, "PMC");

View File

@ -24,6 +24,8 @@
* SUCH DAMAGE.
*/
#include "opt_platform.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -72,6 +74,12 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/intr.h>
#ifdef FDT
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#endif
/* "device miibus" required. See GENERIC if you get errors here. */
#include "miibus_if.h"
@ -1196,6 +1204,11 @@ macbioctl(struct ifnet * ifp, u_long cmd, caddr_t data)
static int
macb_probe(device_t dev)
{
#ifdef FDT
if (!ofw_bus_is_compatible(dev, "cdns,at32ap7000-macb"))
return (ENXIO);
#endif
device_set_desc(dev, "macb");
return (0);
}
@ -1546,7 +1559,11 @@ static driver_t macb_driver = {
};
#ifdef FDT
DRIVER_MODULE(macb, simplebus, macb_driver, macb_devclass, NULL, NULL);
#else
DRIVER_MODULE(macb, atmelarm, macb_driver, macb_devclass, 0, 0);
#endif
DRIVER_MODULE(miibus, macb, miibus_driver, miibus_devclass, 0, 0);
MODULE_DEPEND(macb, miibus, 1, 1, 1);
MODULE_DEPEND(macb, ether, 1, 1, 1);

View File

@ -81,7 +81,7 @@ bcm_fb_attach(device_t dev)
{
char bootargs[2048], *n, *p, *v;
device_t fbd;
int fbswap;
int fbswap, err;
phandle_t chosen;
struct bcm2835_fb_config fb;
struct bcmsc_softc *sc;
@ -89,11 +89,13 @@ bcm_fb_attach(device_t dev)
sc = device_get_softc(dev);
memset(&fb, 0, sizeof(fb));
if (bcm2835_mbox_fb_get_w_h(dev, &fb) != 0)
if (bcm2835_mbox_fb_get_w_h(&fb) != 0)
return (ENXIO);
fb.bpp = FB_DEPTH;
if (bcm2835_mbox_fb_init(dev, &fb) != 0)
if ((err = bcm2835_mbox_fb_init(&fb)) != 0) {
device_printf(dev, "bcm2835_mbox_fb_init failed, err=%d\n", err);
return (ENXIO);
}
info = malloc(sizeof(struct fb_info), M_DEVBUF, M_WAITOK | M_ZERO);
info->fb_name = device_get_nameunit(dev);

View File

@ -163,7 +163,9 @@ arm_get_next_irq(int last_irq)
irq = 0;
#ifdef SOC_BCM2836
if ((ret = bcm2836_get_next_irq(irq)) >= 0)
if ((ret = bcm2836_get_next_irq(irq)) < 0)
return (-1);
if (ret != BCM2836_GPU_IRQ)
return (ret + BANK3_START);
#endif

View File

@ -360,230 +360,162 @@ bcm2835_mbox_err(device_t dev, bus_addr_t msg_phys, uint32_t resp_phys,
}
int
bcm2835_mbox_set_power_state(device_t dev, uint32_t device_id, boolean_t on)
bcm2835_mbox_property(void *msg, size_t msg_size)
{
struct msg_set_power_state *msg;
struct msg_set_power_state *buf;
bus_dma_tag_t msg_tag;
bus_dmamap_t msg_map;
bus_addr_t msg_phys;
uint32_t reg;
device_t mbox;
int err;
/* get mbox device */
mbox = devclass_get_device(devclass_find("mbox"), 0);
if (mbox == NULL) {
device_printf(dev, "can't find mbox\n");
if (mbox == NULL)
return (ENXIO);
}
/* Allocate memory for the message */
msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), &msg_tag, &msg_map,
buf = bcm2835_mbox_init_dma(mbox, msg_size, &msg_tag, &msg_map,
&msg_phys);
if (msg == NULL)
if (buf == NULL)
return (ENOMEM);
memset(msg, 0, sizeof(*msg));
msg->hdr.buf_size = sizeof(*msg);
msg->hdr.code = BCM2835_MBOX_CODE_REQ;
msg->tag_hdr.tag = BCM2835_MBOX_TAG_SET_POWER_STATE;
msg->tag_hdr.val_buf_size = sizeof(msg->body);
msg->tag_hdr.val_len = sizeof(msg->body.req);
msg->body.req.device_id = device_id;
msg->body.req.state = (on ? BCM2835_MBOX_POWER_ON : 0) |
BCM2835_MBOX_POWER_WAIT;
msg->end_tag = 0;
memcpy(buf, msg, msg_size);
bus_dmamap_sync(msg_tag, msg_map,
BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
BUS_DMASYNC_PREWRITE);
MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys);
MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &reg);
bus_dmamap_unload(msg_tag, msg_map);
bus_dmamem_free(msg_tag, msg, msg_map);
bus_dma_tag_destroy(msg_tag);
bus_dmamap_sync(msg_tag, msg_map,
BUS_DMASYNC_PREREAD);
return (0);
}
memcpy(msg, buf, msg_size);
int
bcm2835_mbox_get_clock_rate(device_t dev, uint32_t clock_id, uint32_t *hz)
{
struct msg_get_clock_rate *msg;
bus_dma_tag_t msg_tag;
bus_dmamap_t msg_map;
bus_addr_t msg_phys;
uint32_t reg;
device_t mbox;
/* get mbox device */
mbox = devclass_get_device(devclass_find("mbox"), 0);
if (mbox == NULL) {
device_printf(dev, "can't find mbox\n");
return (ENXIO);
}
/* Allocate memory for the message */
msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), &msg_tag, &msg_map,
&msg_phys);
if (msg == NULL)
return (ENOMEM);
memset(msg, 0, sizeof(*msg));
msg->hdr.buf_size = sizeof(*msg);
msg->hdr.code = BCM2835_MBOX_CODE_REQ;
msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_CLOCK_RATE;
msg->tag_hdr.val_buf_size = sizeof(msg->body);
msg->tag_hdr.val_len = sizeof(msg->body.req);
msg->body.req.clock_id = clock_id;
msg->end_tag = 0;
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE);
MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTWRITE);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD);
MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &reg);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTREAD);
*hz = msg->body.resp.rate_hz;
err = bcm2835_mbox_err(mbox, msg_phys, reg,
(struct bcm2835_mbox_hdr *)msg, msg_size);
bus_dmamap_unload(msg_tag, msg_map);
bus_dmamem_free(msg_tag, msg, msg_map);
bus_dma_tag_destroy(msg_tag);
return (0);
}
int
bcm2835_mbox_fb_get_w_h(device_t dev, struct bcm2835_fb_config *fb)
{
device_t mbox;
int err;
bus_dma_tag_t msg_tag;
bus_dmamap_t msg_map;
bus_addr_t msg_phys;
struct msg_fb_get_w_h *msg;
uint32_t reg;
/* get mbox device */
mbox = devclass_get_device(devclass_find("mbox"), 0);
if (mbox == NULL) {
device_printf(dev, "can't find mbox\n");
return (ENXIO);
}
/* Allocate memory for the message */
msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), &msg_tag, &msg_map,
&msg_phys);
if (msg == NULL)
return (ENOMEM);
memset(msg, 0, sizeof(*msg));
msg->hdr.buf_size = sizeof(*msg);
msg->hdr.code = BCM2835_MBOX_CODE_REQ;
BCM2835_MBOX_INIT_TAG(&msg->physical_w_h, GET_PHYSICAL_W_H);
msg->physical_w_h.tag_hdr.val_len = 0;
BCM2835_MBOX_INIT_TAG(&msg->virtual_w_h, GET_VIRTUAL_W_H);
msg->virtual_w_h.tag_hdr.val_len = 0;
BCM2835_MBOX_INIT_TAG(&msg->offset, GET_VIRTUAL_OFFSET);
msg->offset.tag_hdr.val_len = 0;
msg->end_tag = 0;
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE);
MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTWRITE);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD);
MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &reg);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTREAD);
err = bcm2835_mbox_err(dev, msg_phys, reg, &msg->hdr, sizeof(*msg));
if (err == 0) {
fb->xres = msg->physical_w_h.body.resp.width;
fb->yres = msg->physical_w_h.body.resp.height;
fb->vxres = msg->virtual_w_h.body.resp.width;
fb->vyres = msg->virtual_w_h.body.resp.height;
fb->xoffset = msg->offset.body.resp.x;
fb->yoffset = msg->offset.body.resp.y;
}
bus_dmamap_unload(msg_tag, msg_map);
bus_dmamem_free(msg_tag, msg, msg_map);
bus_dmamem_free(msg_tag, buf, msg_map);
bus_dma_tag_destroy(msg_tag);
return (err);
}
int
bcm2835_mbox_fb_init(device_t dev, struct bcm2835_fb_config *fb)
bcm2835_mbox_set_power_state(uint32_t device_id, boolean_t on)
{
device_t mbox;
struct msg_set_power_state msg;
int err;
bus_dma_tag_t msg_tag;
bus_dmamap_t msg_map;
bus_addr_t msg_phys;
struct msg_fb_setup *msg;
uint32_t reg;
/* get mbox device */
mbox = devclass_get_device(devclass_find("mbox"), 0);
if (mbox == NULL) {
device_printf(dev, "can't find mbox\n");
return (ENXIO);
}
memset(&msg, 0, sizeof(msg));
msg.hdr.buf_size = sizeof(msg);
msg.hdr.code = BCM2835_MBOX_CODE_REQ;
msg.tag_hdr.tag = BCM2835_MBOX_TAG_SET_POWER_STATE;
msg.tag_hdr.val_buf_size = sizeof(msg.body);
msg.tag_hdr.val_len = sizeof(msg.body.req);
msg.body.req.device_id = device_id;
msg.body.req.state = (on ? BCM2835_MBOX_POWER_ON : 0) |
BCM2835_MBOX_POWER_WAIT;
msg.end_tag = 0;
/* Allocate memory for the message */
msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), &msg_tag, &msg_map,
&msg_phys);
if (msg == NULL)
return (ENOMEM);
memset(msg, 0, sizeof(*msg));
msg->hdr.buf_size = sizeof(*msg);
msg->hdr.code = BCM2835_MBOX_CODE_REQ;
BCM2835_MBOX_INIT_TAG(&msg->physical_w_h, SET_PHYSICAL_W_H);
msg->physical_w_h.body.req.width = fb->xres;
msg->physical_w_h.body.req.height = fb->yres;
BCM2835_MBOX_INIT_TAG(&msg->virtual_w_h, SET_VIRTUAL_W_H);
msg->virtual_w_h.body.req.width = fb->vxres;
msg->virtual_w_h.body.req.height = fb->vyres;
BCM2835_MBOX_INIT_TAG(&msg->offset, GET_VIRTUAL_OFFSET);
msg->offset.body.req.x = fb->xoffset;
msg->offset.body.req.y = fb->yoffset;
BCM2835_MBOX_INIT_TAG(&msg->depth, SET_DEPTH);
msg->depth.body.req.bpp = fb->bpp;
BCM2835_MBOX_INIT_TAG(&msg->alpha, SET_ALPHA_MODE);
msg->alpha.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
BCM2835_MBOX_INIT_TAG(&msg->buffer, ALLOCATE_BUFFER);
msg->buffer.body.req.alignment = PAGE_SIZE;
BCM2835_MBOX_INIT_TAG(&msg->pitch, GET_PITCH);
msg->end_tag = 0;
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE);
MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTWRITE);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD);
MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &reg);
bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTREAD);
err = bcm2835_mbox_err(dev, msg_phys, reg, &msg->hdr, sizeof(*msg));
if (err == 0) {
fb->xres = msg->physical_w_h.body.resp.width;
fb->yres = msg->physical_w_h.body.resp.height;
fb->vxres = msg->virtual_w_h.body.resp.width;
fb->vyres = msg->virtual_w_h.body.resp.height;
fb->xoffset = msg->offset.body.resp.x;
fb->yoffset = msg->offset.body.resp.y;
fb->pitch = msg->pitch.body.resp.pitch;
fb->base = VCBUS_TO_PHYS(msg->buffer.body.resp.fb_address);
fb->size = msg->buffer.body.resp.fb_size;
}
bus_dmamap_unload(msg_tag, msg_map);
bus_dmamem_free(msg_tag, msg, msg_map);
bus_dma_tag_destroy(msg_tag);
err = bcm2835_mbox_property(&msg, sizeof(msg));
return (err);
}
int
bcm2835_mbox_get_clock_rate(uint32_t clock_id, uint32_t *hz)
{
struct msg_get_clock_rate msg;
int err;
memset(&msg, 0, sizeof(msg));
msg.hdr.buf_size = sizeof(msg);
msg.hdr.code = BCM2835_MBOX_CODE_REQ;
msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_CLOCK_RATE;
msg.tag_hdr.val_buf_size = sizeof(msg.body);
msg.tag_hdr.val_len = sizeof(msg.body.req);
msg.body.req.clock_id = clock_id;
msg.end_tag = 0;
err = bcm2835_mbox_property(&msg, sizeof(msg));
*hz = msg.body.resp.rate_hz;
return (err);
}
int
bcm2835_mbox_fb_get_w_h(struct bcm2835_fb_config *fb)
{
int err;
struct msg_fb_get_w_h msg;
memset(&msg, 0, sizeof(msg));
msg.hdr.buf_size = sizeof(msg);
msg.hdr.code = BCM2835_MBOX_CODE_REQ;
BCM2835_MBOX_INIT_TAG(&msg.physical_w_h, GET_PHYSICAL_W_H);
msg.physical_w_h.tag_hdr.val_len = 0;
BCM2835_MBOX_INIT_TAG(&msg.virtual_w_h, GET_VIRTUAL_W_H);
msg.virtual_w_h.tag_hdr.val_len = 0;
BCM2835_MBOX_INIT_TAG(&msg.offset, GET_VIRTUAL_OFFSET);
msg.offset.tag_hdr.val_len = 0;
msg.end_tag = 0;
err = bcm2835_mbox_property(&msg, sizeof(msg));
if (err == 0) {
fb->xres = msg.physical_w_h.body.resp.width;
fb->yres = msg.physical_w_h.body.resp.height;
fb->vxres = msg.virtual_w_h.body.resp.width;
fb->vyres = msg.virtual_w_h.body.resp.height;
fb->xoffset = msg.offset.body.resp.x;
fb->yoffset = msg.offset.body.resp.y;
}
return (err);
}
int
bcm2835_mbox_fb_init(struct bcm2835_fb_config *fb)
{
int err;
struct msg_fb_setup msg;
memset(&msg, 0, sizeof(msg));
msg.hdr.buf_size = sizeof(msg);
msg.hdr.code = BCM2835_MBOX_CODE_REQ;
BCM2835_MBOX_INIT_TAG(&msg.physical_w_h, SET_PHYSICAL_W_H);
msg.physical_w_h.body.req.width = fb->xres;
msg.physical_w_h.body.req.height = fb->yres;
BCM2835_MBOX_INIT_TAG(&msg.virtual_w_h, SET_VIRTUAL_W_H);
msg.virtual_w_h.body.req.width = fb->vxres;
msg.virtual_w_h.body.req.height = fb->vyres;
BCM2835_MBOX_INIT_TAG(&msg.offset, GET_VIRTUAL_OFFSET);
msg.offset.body.req.x = fb->xoffset;
msg.offset.body.req.y = fb->yoffset;
BCM2835_MBOX_INIT_TAG(&msg.depth, SET_DEPTH);
msg.depth.body.req.bpp = fb->bpp;
BCM2835_MBOX_INIT_TAG(&msg.alpha, SET_ALPHA_MODE);
msg.alpha.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
BCM2835_MBOX_INIT_TAG(&msg.buffer, ALLOCATE_BUFFER);
msg.buffer.body.req.alignment = PAGE_SIZE;
BCM2835_MBOX_INIT_TAG(&msg.pitch, GET_PITCH);
msg.end_tag = 0;
err = bcm2835_mbox_property(&msg, sizeof(msg));
if (err == 0) {
fb->xres = msg.physical_w_h.body.resp.width;
fb->yres = msg.physical_w_h.body.resp.height;
fb->vxres = msg.virtual_w_h.body.resp.width;
fb->vyres = msg.virtual_w_h.body.resp.height;
fb->xoffset = msg.offset.body.resp.x;
fb->yoffset = msg.offset.body.resp.y;
fb->pitch = msg.pitch.body.resp.pitch;
fb->base = VCBUS_TO_PHYS(msg.buffer.body.resp.fb_address);
fb->size = msg.buffer.body.resp.fb_size;
}
return (err);
}

View File

@ -106,7 +106,7 @@ struct msg_set_power_state {
};
/* Sets the power state for a given device */
int bcm2835_mbox_set_power_state(device_t, uint32_t, boolean_t);
int bcm2835_mbox_set_power_state(uint32_t, boolean_t);
#define BCM2835_MBOX_CLOCK_ID_EMMC 0x00000001
#define BCM2835_MBOX_CLOCK_ID_UART 0x00000002
@ -185,7 +185,7 @@ struct msg_get_min_clock_rate {
uint32_t end_tag;
};
int bcm2835_mbox_get_clock_rate(device_t, uint32_t, uint32_t *);
int bcm2835_mbox_get_clock_rate(uint32_t, uint32_t *);
#define BCM2835_MBOX_TURBO_ON 1
#define BCM2835_MBOX_TURBO_OFF 0
@ -438,6 +438,21 @@ struct bcm2835_mbox_tag_release_buffer {
} body;
};
#define BCM2835_MBOX_TAG_GET_TOUCHBUF 0x0004000f
struct bcm2835_mbox_tag_touchbuf {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_hdr tag_hdr;
union {
struct {
} req;
struct {
uint32_t address;
} resp;
} body;
uint32_t end_tag;
};
struct bcm2835_fb_config {
uint32_t xres;
uint32_t yres;
@ -459,7 +474,7 @@ struct msg_fb_get_w_h {
uint32_t end_tag;
};
int bcm2835_mbox_fb_get_w_h(device_t, struct bcm2835_fb_config *);
int bcm2835_mbox_fb_get_w_h(struct bcm2835_fb_config *);
struct msg_fb_setup {
struct bcm2835_mbox_hdr hdr;
@ -473,6 +488,8 @@ struct msg_fb_setup {
uint32_t end_tag;
};
int bcm2835_mbox_fb_init(device_t, struct bcm2835_fb_config *);
int bcm2835_mbox_fb_init(struct bcm2835_fb_config *);
int bcm2835_mbox_property(void *, size_t);
#endif /* _BCM2835_MBOX_PROP_H_ */

View File

@ -145,7 +145,7 @@ bcm_sdhci_attach(device_t dev)
sc->sc_dev = dev;
sc->sc_req = NULL;
err = bcm2835_mbox_set_power_state(dev, BCM2835_MBOX_POWER_ID_EMMC,
err = bcm2835_mbox_set_power_state(BCM2835_MBOX_POWER_ID_EMMC,
TRUE);
if (err != 0) {
if (bootverbose)
@ -154,7 +154,7 @@ bcm_sdhci_attach(device_t dev)
}
default_freq = 0;
err = bcm2835_mbox_get_clock_rate(dev, BCM2835_MBOX_CLOCK_ID_EMMC,
err = bcm2835_mbox_get_clock_rate(BCM2835_MBOX_CLOCK_ID_EMMC,
&default_freq);
if (err == 0) {
/* Convert to MHz */

View File

@ -0,0 +1,122 @@
/*-
* Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
*
* 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/malloc.h>
#include <sys/module.h>
#include <sys/ioccom.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <arm/broadcom/bcm2835/bcm2835_mbox_prop.h>
MALLOC_DECLARE(M_VCIO);
MALLOC_DEFINE(M_VCIO, "vcio", "VCIO temporary buffers");
static struct cdev *sdev;
static d_ioctl_t vcio_ioctl;
static struct cdevsw vcio_devsw = {
/* version */ .d_version = D_VERSION,
/* ioctl */ .d_ioctl = vcio_ioctl,
};
#define VCIO_IOC_MAGIC 100
#define IOCTL_MBOX_PROPERTY _IOWR(VCIO_IOC_MAGIC, 0, char *)
int
vcio_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode,
struct thread *td)
{
int error;
void *ptr;
uint32_t size;
uint8_t *property;
error = 0;
switch(cmd) {
case IOCTL_MBOX_PROPERTY:
memcpy (&ptr, arg, sizeof(ptr));
error = copyin(ptr, &size, sizeof(size));
if (error != 0)
break;
property = malloc(size, M_VCIO, M_WAITOK);
if (property == NULL) {
error = ENOMEM;
break;
}
error = copyin(ptr, property, size);
if (error) {
free(property, M_VCIO);
break;
}
error = bcm2835_mbox_property(property, size);
if (error) {
free(property, M_VCIO);
break;
}
error = copyout(property, ptr, size);
free(property, M_VCIO);
break;
default:
error = EINVAL;
break;
}
return (error);
}
static int
vcio_load(module_t mod, int cmd, void *arg)
{
int err = 0;
switch (cmd) {
case MOD_LOAD:
sdev = make_dev(&vcio_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "vcio");
break;
case MOD_UNLOAD:
destroy_dev(sdev);
break;
default:
err = EOPNOTSUPP;
break;
}
return(err);
}
DEV_MODULE(vcio, vcio_load, NULL);
MODULE_DEPEND(vcio, mbox, 1, 1, 1);

View File

@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
#define ARM_LOCAL_INT_TIMER(n) (0x40 + (n) * 4)
#define ARM_LOCAL_INT_MAILBOX(n) (0x50 + (n) * 4)
#define ARM_LOCAL_INT_PENDING(n) (0x60 + (n) * 4)
#define INT_PENDING_MASK 0x01f
#define INT_PENDING_MASK 0x011f
#define MAILBOX0_IRQ 4
#define MAILBOX0_IRQEN (1 << 0)

View File

@ -30,6 +30,8 @@
#ifndef _BCM2815_BCM2836_H
#define _BCM2815_BCM2836_H
#define BCM2836_GPU_IRQ 8
int bcm2836_get_next_irq(int);
void bcm2836_mask_irq(uintptr_t);
void bcm2836_unmask_irq(uintptr_t);

View File

@ -72,8 +72,12 @@ bcm283x_dwc_otg_probe(device_t dev)
static int
bcm283x_dwc_otg_attach(device_t dev)
{
int err;
err = bcm2835_mbox_set_power_state(BCM2835_MBOX_POWER_ID_USB_HCD, TRUE);
if (err)
device_printf(dev, "failed to set power state, err=%d\n", err);
bcm2835_mbox_set_power_state(dev, BCM2835_MBOX_POWER_ID_USB_HCD, TRUE);
return (dwc_otg_attach(dev));
}

View File

@ -12,6 +12,7 @@ arm/broadcom/bcm2835/bcm2835_machdep.c standard
arm/broadcom/bcm2835/bcm2835_mbox.c standard
arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci
arm/broadcom/bcm2835/bcm2835_spi.c optional bcm2835_spi
arm/broadcom/bcm2835/bcm2835_vcio.c standard
arm/broadcom/bcm2835/bcm2835_wdog.c standard
arm/broadcom/bcm2835/bcm283x_dwc_fdt.c optional dwcotg fdt

View File

@ -403,7 +403,7 @@
#define FAULT_PERM_L1 0x00D /* Permission Fault (L1) */
#define FAULT_EA_TRAN_L2 0x00E /* External Translation Abort (L2) */
#define FAULT_PERM_L2 0x00F /* Permission Fault (L2) */
#define FAULT_TLB_CONFLICT 0x010 /* Permission Fault (L2) */
#define FAULT_TLB_CONFLICT 0x010 /* TLB Conflict Abort */
#define FAULT_EA_IMPREC 0x016 /* Asynchronous External Abort */
#define FAULT_PE_IMPREC 0x018 /* Asynchronous Parity Error */
#define FAULT_PARITY 0x019 /* Parity Error */
@ -444,6 +444,12 @@
#define INSN_COND_MASK 0xf0000000 /* Condition mask */
#define INSN_COND_AL 0xe0000000 /* Always condition */
/* ARM register defines */
#define ARM_REG_SIZE 4
#define ARM_REG_NUM_PC 15
#define ARM_REG_NUM_LR 14
#define ARM_REG_NUM_SP 13
#define THUMB_INSN_SIZE 2 /* Some are 4 bytes. */
#endif /* !MACHINE_ARMREG_H */

View File

@ -94,8 +94,6 @@ struct arm32_dma_range {
struct arm32_dma_range *bus_dma_get_range(void);
int bus_dma_get_range_nb(void);
extern bus_dma_tag_t arm_root_dma_tag;
#endif /* _ARM32_BUS_DMA_PRIVATE */
#endif /* _ARM_BUS_DMA_H */

View File

@ -74,7 +74,7 @@ typedef int db_expr_t;
#define inst_branch(ins) (((ins) & 0x0f000000) == 0x0a000000 || \
((ins) & 0x0fdffff0) == 0x079ff100 || \
((ins) & 0x0cf0f000) == 0x0490f000 || \
((ins) & 0x0cd0f000) == 0x0490f000 || \
((ins) & 0x0ffffff0) == 0x012fff30 || /* blx */ \
((ins) & 0x0de0f000) == 0x0080f000)
@ -90,7 +90,7 @@ typedef int db_expr_t;
int db_validate_address(vm_offset_t);
u_int branch_taken (u_int insn, u_int pc);
u_int branch_taken (u_int insn, db_addr_t pc);
#ifdef __ARMEB__
#define BYTE_MSF (1)

View File

@ -43,4 +43,7 @@ void arm_generic_initclocks(void);
void board_set_serial(uint64_t);
void board_set_revision(uint32_t);
int arm_predict_branch(void *, u_int, register_t, register_t *,
u_int (*)(void*, int), u_int (*)(void*, vm_offset_t, u_int*));
#endif /* !_MACHINE_MACHDEP_H_ */

View File

@ -51,6 +51,8 @@ struct mdthread {
register_t md_spurflt_addr; /* (k) Spurious page fault address. */
int md_ptrace_instr;
int md_ptrace_addr;
int md_ptrace_instr_alt;
int md_ptrace_addr_alt;
register_t md_tp;
void *md_ras_start;
void *md_ras_end;

View File

@ -92,6 +92,7 @@
/* VFPEXC */
#define VFPEXC_EX (0x80000000) /* exception v1 v2 */
#define VFPEXC_EN (0x40000000) /* vfp enable */
#define VFPEXC_DEX (0x20000000) /* Synchronous exception */
#define VFPEXC_FP2V (0x10000000) /* FPINST2 valid */
#define VFPEXC_INV (0x00000080) /* Input exception */
#define VFPEXC_UFC (0x00000008) /* Underflow exception */

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