Remove NetBSD-related files
This commit is contained in:
parent
156d5c3e51
commit
b7c1515188
|
|
@ -1,71 +0,0 @@
|
||||||
# MINIX fetch rules
|
|
||||||
#
|
|
||||||
# Rules used to fetch a GNU package. Expects GNUHOSTDIST to be set
|
|
||||||
# and <bsd.own.mk> to be previously .include'd.
|
|
||||||
#
|
|
||||||
# New interface:
|
|
||||||
#
|
|
||||||
# * When using the `cleandir' target, defining CLEANFETCHED=yes will
|
|
||||||
# additionally remove all the fetched files.
|
|
||||||
# This is particularly useful when a GNU package is updated.
|
|
||||||
#
|
|
||||||
# The rest should be operations hidden to the normal programmers.
|
|
||||||
#
|
|
||||||
# How to use: (maintainers manual)
|
|
||||||
#
|
|
||||||
# * put a fetch.sh script one directory below the GNUHOSTDIST;
|
|
||||||
#
|
|
||||||
# * .include "path/to/minix/Makefile.fetchgnu", after having
|
|
||||||
# defined GNUHOSTDIST and before any use of the variable below;
|
|
||||||
#
|
|
||||||
# * insert ${fetch_done} as source before performing any operation
|
|
||||||
# on the files under GPL license which are usually found
|
|
||||||
# within NetBSD src/ tree;
|
|
||||||
#
|
|
||||||
# * rinse and repeat for every target which assumes the presence of
|
|
||||||
# these files, and for every Makefile operating upon them.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# TODO: does not handle correctly the cases where there are more than
|
|
||||||
# one package downloaded by fetch.sh (e.g.gnu/dist with texinfo+gmake):
|
|
||||||
# .gitignore only "protects" the first package which triggers.
|
|
||||||
|
|
||||||
.if !defined(__MINIX) || !defined(GNUHOSTDIST)
|
|
||||||
.error Bad logic in Makefiles.
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.if !defined(_MINIX_FETCHGNU_MK_)
|
|
||||||
_MINIX_FETCHGNU_MK_=1
|
|
||||||
|
|
||||||
# MINIX /usr/src does not have the sources for the GNU utilities
|
|
||||||
# in-tree, for licensing reasons. So to successfully use them while
|
|
||||||
# cross-compiling, we have to fetch them. The success of that operation
|
|
||||||
# is indicated by the presence of a .gitignore file in the corresponding
|
|
||||||
# source parent directory, which also conveniently hides from git.
|
|
||||||
.if exists(${GNUHOSTDIST:H}/fetch.sh)
|
|
||||||
${GNUHOSTDIST:H}/.gitignore: ${GNUHOSTDIST:H}/fetch.sh
|
|
||||||
SED=${TOOL_SED} ${HOST_SH} ${GNUHOSTDIST:H}/fetch.sh
|
|
||||||
@test -e ${GNUHOSTDIST}/configure
|
|
||||||
@echo "${MODULE:U${.CURDIR:T}:C,gcc[0-9]*,gcc,:C,gmake*,make,}-*.tar.*z*" >> $@
|
|
||||||
@echo ${GNUHOSTDIST:T} >> $@
|
|
||||||
|
|
||||||
# Do the fetching as an extra step, to force serialization
|
|
||||||
.fetch_done: ${GNUHOSTDIST:H}/.gitignore
|
|
||||||
@touch $@
|
|
||||||
fetch_done=.fetch_done
|
|
||||||
|
|
||||||
# Special target for MINIX, reset the source tree as pristine
|
|
||||||
# Note it does NOT remove the downloaded tarball
|
|
||||||
.if ${CLEANFETCHED:Uno} == "yes"
|
|
||||||
cleandir: clean_gnu_src
|
|
||||||
clean_gnu_src:
|
|
||||||
-rm -r -f ${GNUHOSTDIST} ${GNUHOSTDIST:H}/.gitignore
|
|
||||||
.endif # CLEANFETCHED == yes
|
|
||||||
|
|
||||||
clean: clean.fetchgnu
|
|
||||||
clean.fetchgnu:
|
|
||||||
-@rm -f .fetch_done
|
|
||||||
|
|
||||||
.endif # exists(GNUHOSTDIST:H/fetch.sh) on MINIX
|
|
||||||
|
|
||||||
.endif # !defined(_MINIX_FETCHGNU_MK_)
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
PROG = devmand
|
|
||||||
MAN =
|
|
||||||
|
|
||||||
SRCS = main.c usb_scan.l usb.y
|
|
||||||
CPPFLAGS+= -I${.CURDIR}
|
|
||||||
|
|
||||||
YFLAGS:= -d
|
|
||||||
CLEANFILES+= y.tab.h
|
|
||||||
|
|
||||||
usb_scan.l: usb.y
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
||||||
|
|
||||||
# LSC: Seems that this file is implicitly taken into account by NetBSD's make,
|
|
||||||
# still seems to be ignored / not found currently.
|
|
||||||
# It's a sad story, as it has default rules to manage yacc / lex files. So for
|
|
||||||
# a happy ending here it is explicitly included:
|
|
||||||
.include <sys.mk>
|
|
||||||
|
|
||||||
|
|
@ -1,265 +0,0 @@
|
||||||
.\" $NetBSD: fetch.1,v 1.4 2009/02/07 15:25:51 wiz Exp $
|
|
||||||
.\"-
|
|
||||||
.\" Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\" Portions Copyright (c) 1999 Massachusetts Institute of Technology; used
|
|
||||||
.\" by permission.
|
|
||||||
.\"
|
|
||||||
.\" 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
|
|
||||||
.\" in this position and unchanged.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. The name of the author may not be used to endorse or promote products
|
|
||||||
.\" derived from this software without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $FreeBSD$
|
|
||||||
.\"
|
|
||||||
.Dd February 5, 2009
|
|
||||||
.Dt FETCH 1
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm fetch
|
|
||||||
.Nd retrieve a file by Uniform Resource Locator
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm
|
|
||||||
.Op Fl 146AFMRUadilmnqrsv
|
|
||||||
.Op Fl B Ar bytes
|
|
||||||
.Op Fl N Ar file
|
|
||||||
.Op Fl o Ar file
|
|
||||||
.Op Fl S Ar bytes
|
|
||||||
.Op Fl T Ar seconds
|
|
||||||
.Op Fl w Ar seconds
|
|
||||||
.Op Ar URL ...
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
utility provides a command-line interface to the
|
|
||||||
.Xr fetch 3
|
|
||||||
library.
|
|
||||||
Its purpose is to retrieve the file(s) pointed to by the URL(s) on the
|
|
||||||
command line.
|
|
||||||
.Pp
|
|
||||||
The following options are available:
|
|
||||||
.Bl -tag -width Fl
|
|
||||||
.It Fl 1
|
|
||||||
Stop and return exit code 0 at the first successfully retrieved file.
|
|
||||||
.It Fl 4
|
|
||||||
Forces
|
|
||||||
.Nm
|
|
||||||
to use IPv4 addresses only.
|
|
||||||
.It Fl 6
|
|
||||||
Forces
|
|
||||||
.Nm
|
|
||||||
to use IPv6 addresses only.
|
|
||||||
.It Fl A
|
|
||||||
Do not automatically follow
|
|
||||||
.Dq temporary
|
|
||||||
(302) redirects.
|
|
||||||
Some broken Web sites will return a redirect instead of a not-found
|
|
||||||
error when the requested object does not exist.
|
|
||||||
.It Fl a
|
|
||||||
Automatically retry the transfer upon soft failures.
|
|
||||||
.It Fl B Ar bytes
|
|
||||||
Specify the read buffer size in bytes.
|
|
||||||
The default is 4096 bytes.
|
|
||||||
Attempts to set a buffer size lower than this will be silently
|
|
||||||
ignored.
|
|
||||||
The number of reads actually performed is reported at verbosity level
|
|
||||||
two or higher (see the
|
|
||||||
.Fl v
|
|
||||||
flag).
|
|
||||||
.It Fl d
|
|
||||||
Use a direct connection even if a proxy is configured.
|
|
||||||
.It Fl F
|
|
||||||
In combination with the
|
|
||||||
.Fl r
|
|
||||||
flag, forces a restart even if the local and remote files have
|
|
||||||
different modification times.
|
|
||||||
Implies
|
|
||||||
.Fl R .
|
|
||||||
.It Fl i
|
|
||||||
Only fetch if it the output file is older than the referenced URL.
|
|
||||||
This option is overriden by
|
|
||||||
.Fl o Ar - .
|
|
||||||
.It Fl l
|
|
||||||
If the target is a file-scheme URL, make a symbolic link to the target
|
|
||||||
rather than trying to copy it.
|
|
||||||
.It Fl M
|
|
||||||
.It Fl m
|
|
||||||
Mirror mode: if the file already exists locally and has the same size
|
|
||||||
and modification time as the remote file, it will not be fetched.
|
|
||||||
Note that the
|
|
||||||
.Fl m
|
|
||||||
and
|
|
||||||
.Fl r
|
|
||||||
flags are mutually exclusive.
|
|
||||||
.It Fl N Ar file
|
|
||||||
Use
|
|
||||||
.Ar file
|
|
||||||
instead of
|
|
||||||
.Pa ~/.netrc
|
|
||||||
to look up login names and passwords for FTP sites.
|
|
||||||
See
|
|
||||||
.Xr ftp 1
|
|
||||||
for a description of the file format.
|
|
||||||
This feature is experimental.
|
|
||||||
.It Fl n
|
|
||||||
Do not preserve the modification time of the transferred file.
|
|
||||||
.It Fl o Ar file
|
|
||||||
Set the output file name to
|
|
||||||
.Ar file .
|
|
||||||
By default, a
|
|
||||||
.Dq pathname
|
|
||||||
is extracted from the specified URI, and
|
|
||||||
its basename is used as the name of the output file.
|
|
||||||
A
|
|
||||||
.Ar file
|
|
||||||
argument of
|
|
||||||
.Sq Li \&-
|
|
||||||
indicates that results are to be directed to the standard output.
|
|
||||||
If the
|
|
||||||
.Ar file
|
|
||||||
argument is a directory, fetched file(s) will be placed within the
|
|
||||||
directory, with name(s) selected as in the default behaviour.
|
|
||||||
.It Fl q
|
|
||||||
Quiet mode.
|
|
||||||
.It Fl R
|
|
||||||
The output files are precious, and should not be deleted under any
|
|
||||||
circumstances, even if the transfer failed or was incomplete.
|
|
||||||
.It Fl r
|
|
||||||
Restart a previously interrupted transfer.
|
|
||||||
Note that the
|
|
||||||
.Fl m
|
|
||||||
and
|
|
||||||
.Fl r
|
|
||||||
flags are mutually exclusive.
|
|
||||||
.It Fl S Ar bytes
|
|
||||||
Require the file size reported by the server to match the specified
|
|
||||||
value.
|
|
||||||
If it does not, a message is printed and the file is not fetched.
|
|
||||||
If the server does not support reporting file sizes, this option is
|
|
||||||
ignored and the file is fetched unconditionally.
|
|
||||||
.It Fl s
|
|
||||||
Print the size in bytes of each requested file, without fetching it.
|
|
||||||
.It Fl T Ar seconds
|
|
||||||
Set timeout value to
|
|
||||||
.Ar seconds .
|
|
||||||
Overrides the environment variables
|
|
||||||
.Ev FTP_TIMEOUT
|
|
||||||
for FTP transfers or
|
|
||||||
.Ev HTTP_TIMEOUT
|
|
||||||
for HTTP transfers if set.
|
|
||||||
.It Fl U
|
|
||||||
When using passive FTP, allocate the port for the data connection from
|
|
||||||
the low (default) port range.
|
|
||||||
See
|
|
||||||
.Xr ip 4
|
|
||||||
for details on how to specify which port range this corresponds to.
|
|
||||||
.It Fl v
|
|
||||||
Increase verbosity level.
|
|
||||||
.It Fl w Ar seconds
|
|
||||||
When the
|
|
||||||
.Fl a
|
|
||||||
flag is specified, wait this many seconds between successive retries.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
If
|
|
||||||
.Nm
|
|
||||||
receives a
|
|
||||||
.Dv SIGINFO
|
|
||||||
signal (see the
|
|
||||||
.Cm status
|
|
||||||
argument for
|
|
||||||
.Xr stty 1 ) ,
|
|
||||||
the current transfer rate statistics will be written to the
|
|
||||||
standard error output, in the same format as the standard completion
|
|
||||||
message.
|
|
||||||
.Sh EXIT STATUS
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
command returns zero on success, or one on failure.
|
|
||||||
If multiple URLs are listed on the command line,
|
|
||||||
.Nm
|
|
||||||
will attempt to retrieve each one of them in turn, and will return
|
|
||||||
zero only if they were all successfully retrieved.
|
|
||||||
.Sh ENVIRONMENT
|
|
||||||
.Bl -tag -width HTTP_TIMEOUT
|
|
||||||
.It Ev FTP_TIMEOUT
|
|
||||||
Maximum time, in seconds, to wait before aborting an FTP connection.
|
|
||||||
.It Ev HTTP_TIMEOUT
|
|
||||||
Maximum time, in seconds, to wait before aborting an HTTP connection.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
See
|
|
||||||
.Xr fetch 3
|
|
||||||
for a description of additional environment variables, including
|
|
||||||
.Ev FETCH_BIND_ADDRESS ,
|
|
||||||
.Ev FTP_LOGIN ,
|
|
||||||
.Ev FTP_PASSIVE_MODE ,
|
|
||||||
.Ev FTP_PASSWORD ,
|
|
||||||
.Ev FTP_PROXY ,
|
|
||||||
.Ev ftp_proxy ,
|
|
||||||
.Ev HTTP_AUTH ,
|
|
||||||
.Ev HTTP_PROXY ,
|
|
||||||
.Ev http_proxy ,
|
|
||||||
.Ev HTTP_PROXY_AUTH ,
|
|
||||||
.Ev HTTP_REFERER ,
|
|
||||||
.Ev HTTP_USER_AGENT ,
|
|
||||||
.Ev NETRC ,
|
|
||||||
.Ev NO_PROXY
|
|
||||||
and
|
|
||||||
.Ev no_proxy .
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr fetch 3
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
command appeared in
|
|
||||||
.Fx 2.1.5 .
|
|
||||||
This implementation first appeared in
|
|
||||||
.Fx 4.1 .
|
|
||||||
.Sh AUTHORS
|
|
||||||
.An -nosplit
|
|
||||||
The original implementation of
|
|
||||||
.Nm
|
|
||||||
was done by
|
|
||||||
.An Jean-Marc Zucconi Aq jmz@FreeBSD.org .
|
|
||||||
It was extensively re-worked for
|
|
||||||
.Fx 2.2
|
|
||||||
by
|
|
||||||
.An Garrett Wollman Aq wollman@FreeBSD.org ,
|
|
||||||
and later completely rewritten to use the
|
|
||||||
.Xr fetch 3
|
|
||||||
library by
|
|
||||||
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
|
|
||||||
.Sh NOTES
|
|
||||||
The
|
|
||||||
.Fl b
|
|
||||||
and
|
|
||||||
.Fl t
|
|
||||||
options are no longer supported and will generate warnings.
|
|
||||||
They were workarounds for bugs in other OSes which this implementation
|
|
||||||
does not trigger.
|
|
||||||
.Pp
|
|
||||||
One cannot both use the
|
|
||||||
.Fl h ,
|
|
||||||
.Fl c ,
|
|
||||||
and
|
|
||||||
.Fl f
|
|
||||||
options and specify URLs on the command line.
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
.Dd February 22, 2017
|
|
||||||
.Dt NETCONF 8
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm netconf
|
|
||||||
.Nd configure the network interactively
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm
|
|
||||||
.Op Fl lh
|
|
||||||
.Op Fl p Ar prefix
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
utility allows the root user to configure the network in an interactive mode.
|
|
||||||
.Sh OPTIONS
|
|
||||||
.Bl -tag -width XpXprefixXX
|
|
||||||
.It Fl l
|
|
||||||
Print a list of configurable interfaces.
|
|
||||||
.It Fl h
|
|
||||||
Print usage.
|
|
||||||
.It Fl p Ar prefix
|
|
||||||
Set a path prefix for configuration files (e.g., /mnt).
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr ifconfig.if 5 ,
|
|
||||||
.Xr resolv.conf 5 ,
|
|
||||||
.Xr ifconfig 8 ,
|
|
||||||
.Xr route 8 ,
|
|
||||||
.Xr dhcpcd 8
|
|
||||||
.Sh BUGS
|
|
||||||
IPv6 support is limited at this time.
|
|
||||||
.Sh AUTHORS
|
|
||||||
Original version by Thomas Veerman <thomas@minix3.org>.
|
|
||||||
.Pp
|
|
||||||
NetBSD networking rewrite by David van Moolenbroek <david@minix3.org>.
|
|
||||||
.Pp
|
|
||||||
Original manual page by Leith Brandeland <lb.minix@gmail.com>.
|
|
||||||
|
|
@ -1,415 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# netconf 0.2 - Configure network
|
|
||||||
#
|
|
||||||
# Changes:
|
|
||||||
# v0.2: rewrite for NetBSD network infrastructure
|
|
||||||
# - the primary choice is now for an interface, not a network card;
|
|
||||||
# - manual driver configuration is now an exception;
|
|
||||||
# - the menu transition system is slightly more solid;
|
|
||||||
# - all non-interactive functionality has been removed.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Get system config
|
|
||||||
. /etc/rc.conf
|
|
||||||
|
|
||||||
LOCALRC=/usr/etc/rc.local
|
|
||||||
IFCONF=/etc/ifconfig.
|
|
||||||
RESOLVCONF=/etc/resolv.conf
|
|
||||||
HOSTNAME=/etc/hostname.file
|
|
||||||
USRKBFILE=/.usrkb
|
|
||||||
|
|
||||||
prefix=""
|
|
||||||
cd="no" # running from cd?
|
|
||||||
changed="no" # have any ifconfig.if(5) files been changed?
|
|
||||||
|
|
||||||
usage()
|
|
||||||
{
|
|
||||||
cat >&2 <<'EOF'
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
netconf [-lh] [-p <prefix>]
|
|
||||||
|
|
||||||
flags:
|
|
||||||
-l Print a list of configurable interfaces
|
|
||||||
-h Print this help file
|
|
||||||
-p Set a path prefix for all configuration files (e.g., /mnt)
|
|
||||||
EOF
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
backup_file()
|
|
||||||
{
|
|
||||||
# Do not make backups if we're running from CD.
|
|
||||||
if [ "$cd" != "yes" -a -f "$1" ]; then
|
|
||||||
mv "$1" "$1~" || exit 1
|
|
||||||
echo
|
|
||||||
echo "Backed up $1 to $1~"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
select_number()
|
|
||||||
{
|
|
||||||
while true; do
|
|
||||||
echo -n "$4 [$3] "
|
|
||||||
read input
|
|
||||||
case "$input" in
|
|
||||||
'')
|
|
||||||
return $3
|
|
||||||
;;
|
|
||||||
*[!0-9]*)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
[ $input -ge $1 -a $input -le $2 ] && return $input
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaces()
|
|
||||||
{
|
|
||||||
# Get a list of interfaces that are not virtual (i.e., cloners). There
|
|
||||||
# is always one virtual interface type ("lo", loopback).
|
|
||||||
cloners_regex='^('`ifconfig -C | sed 's/ /[0-9]|/g'`'[0-9])'
|
|
||||||
iflist=`ifconfig -l | tr ' ' '\n' | grep -vE "$cloners_regex"`
|
|
||||||
|
|
||||||
ifcount=0
|
|
||||||
ifunconf=0 # the first interface with no configuration file, or 0
|
|
||||||
if [ -z "$iflist" ]; then
|
|
||||||
echo " No network hardware interfaces detected!"
|
|
||||||
else
|
|
||||||
for if in $iflist; do
|
|
||||||
ifcount=$(($ifcount + 1))
|
|
||||||
if [ -r $IFCONF$if ]; then
|
|
||||||
info="($1)"
|
|
||||||
else
|
|
||||||
[ $ifunconf -eq 0 ] && ifunconf=$ifcount
|
|
||||||
info=""
|
|
||||||
fi
|
|
||||||
printf "%2d. %-8s %s\n" $ifcount "$if" "$info"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
do_step1()
|
|
||||||
{
|
|
||||||
echo "
|
|
||||||
The following network interfaces are available for configuration. These are
|
|
||||||
interfaces corresponding to network drivers that are currently running. If no
|
|
||||||
interface is listed for your network card here, then either MINIX 3 does not
|
|
||||||
support your card, or, if it is not a plug-and-play device, it may require
|
|
||||||
manual configuration first.
|
|
||||||
|
|
||||||
Please choose the interface you would like to configure, or another option.
|
|
||||||
"
|
|
||||||
interfaces "already configured"
|
|
||||||
echo
|
|
||||||
manual_choice=$(($ifcount + 1))
|
|
||||||
quit_choice=$(($ifcount + 2))
|
|
||||||
printf "%2d. Manually configure an ethernet driver\n" $manual_choice
|
|
||||||
printf "%2d. Quit\n\n" $quit_choice
|
|
||||||
|
|
||||||
default_choice=$ifunconf
|
|
||||||
[ $default_choice -eq 0 ] && default_choice=$quit_choice
|
|
||||||
|
|
||||||
select_number 1 $quit_choice $default_choice "Interface choice?"
|
|
||||||
choice=$?
|
|
||||||
|
|
||||||
case $choice in
|
|
||||||
$manual_choice)
|
|
||||||
step=do_stepM
|
|
||||||
;;
|
|
||||||
$quit_choice)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
ifchoice="$(echo $iflist | cut -d' ' -f$choice)"
|
|
||||||
step=do_step2
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
do_stepM()
|
|
||||||
{
|
|
||||||
# TODO: it would be nice if this list changed on a per-platform basis..
|
|
||||||
echo "
|
|
||||||
MINIX 3 has drivers for a limited number of older cards that require manual
|
|
||||||
configuration. They are shown below. Please choose one of the listed options.
|
|
||||||
|
|
||||||
1. 3Com 501 or 3Com 509 based ISA card (i386)
|
|
||||||
2. NE2000, 3Com 503, or WD based ISA card (i386) (emulated by Bochs, Qemu)
|
|
||||||
|
|
||||||
3. Go back to interface selection
|
|
||||||
4. Quit
|
|
||||||
"
|
|
||||||
|
|
||||||
select_number 1 4 4 "Card choice?"
|
|
||||||
|
|
||||||
case $? in
|
|
||||||
1)
|
|
||||||
driver=dpeth
|
|
||||||
driverargs="#dpeth_args='DPETH0=port:irq:memory'"
|
|
||||||
echo "
|
|
||||||
Note: After installing, edit $LOCALRC to the right configuration."
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
driver=dp8390
|
|
||||||
driverargs="dp8390_args='DPETH0=300:9'"
|
|
||||||
echo "
|
|
||||||
Note: After installing, edit $LOCALRC to the right configuration.
|
|
||||||
You may then also have to edit /etc/system.conf.d/dp8390 to match.
|
|
||||||
For now, the defaults for emulation by Bochs/Qemu have been set."
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
step=do_step1
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
4)
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
backup_file "$LOCALRC"
|
|
||||||
echo "# Generated by netconf(8). Edit as necessary." > $LOCALRC
|
|
||||||
echo "netdriver='"$driver"'" >> $LOCALRC
|
|
||||||
echo "$driverargs" >> $LOCALRC
|
|
||||||
|
|
||||||
# $LOCALRC typically expands to /mnt/usr/etc/rc.local, so leave room..
|
|
||||||
echo "
|
|
||||||
A template to start the driver has been written to $LOCALRC . As
|
|
||||||
noted above, you may have to edit it. Once you are done editing, reboot the
|
|
||||||
system, after which the driver will be started. Once the driver is running,
|
|
||||||
you can run 'netconf' to configure the corresponding network interface."
|
|
||||||
}
|
|
||||||
|
|
||||||
do_step2()
|
|
||||||
{
|
|
||||||
iffile="$IFCONF$ifchoice"
|
|
||||||
|
|
||||||
echo "
|
|
||||||
Configure interface $ifchoice using DHCP or manually?
|
|
||||||
|
|
||||||
For now, the choice here is primarily about IPv4. With DHCP it is possible to
|
|
||||||
enable IPv6 as well. Even if the local network has no IPv6 facilities, enabling
|
|
||||||
IPv6 should do no harm. For IPv6-only mode or any other configuration that is
|
|
||||||
not supported here, you will have to edit $iffile yourself.
|
|
||||||
|
|
||||||
1. Automatically using DHCP (IPv4 + IPv6)
|
|
||||||
2. Automatically using DHCP (IPv4 only)
|
|
||||||
3. Manually (IPv4 only)"
|
|
||||||
|
|
||||||
if [ -r "$iffile" ]; then
|
|
||||||
echo " 4. Remove current configuration"
|
|
||||||
remove_choice=4
|
|
||||||
goback_choice=5
|
|
||||||
quit_choice=6
|
|
||||||
else
|
|
||||||
remove_choice=X
|
|
||||||
goback_choice=4
|
|
||||||
quit_choice=5
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
printf "%2d. Go back to interface selection\n" $goback_choice
|
|
||||||
printf "%2d. Quit\n\n" $quit_choice
|
|
||||||
|
|
||||||
select_number 1 $quit_choice 1 "Configuration choice?"
|
|
||||||
|
|
||||||
case $? in
|
|
||||||
1)
|
|
||||||
backup_file "$iffile"
|
|
||||||
echo 'up' > $iffile
|
|
||||||
echo '!dhcpcd -qM $int' >> $iffile
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Interface $ifchoice configured for DHCP (IPv4 + IPv6)."
|
|
||||||
step=do_step3
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
backup_file "$iffile"
|
|
||||||
echo 'up' > $iffile
|
|
||||||
echo '!dhcpcd -qM -4 $int' >> $iffile
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Interface $ifchoice configured for DHCP (IPv4 only)."
|
|
||||||
step=do_step3
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
# Query user for settings
|
|
||||||
#
|
|
||||||
# Some of these settings (hostname, nameservers) do not apply
|
|
||||||
# to just the selected interface. Still, they are what one has
|
|
||||||
# to specify for a complete manual configuration. In order to
|
|
||||||
# make manual configuration of multiple interfaces less
|
|
||||||
# frustrating in this regard, offer defaults that match what
|
|
||||||
# may just have been set already.
|
|
||||||
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Hostname
|
|
||||||
if [ -r $HOSTNAME ]; then
|
|
||||||
hostname_default=$(cat $HOSTNAME)
|
|
||||||
else
|
|
||||||
hostname_default="minix"
|
|
||||||
fi
|
|
||||||
echo -n "Hostname [$hostname_default]: "
|
|
||||||
read hostname
|
|
||||||
if [ -z "$hostname" ]; then
|
|
||||||
hostname="$hostname_default"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# IP address
|
|
||||||
ip=""
|
|
||||||
while [ -z "$ip" ]; do
|
|
||||||
echo -n "IP address []: "
|
|
||||||
read ip
|
|
||||||
done
|
|
||||||
|
|
||||||
# Netmask
|
|
||||||
echo -n "Netmask (optional) []: "
|
|
||||||
read netmask
|
|
||||||
[ -n "$netmask" ] && netmask=" netmask $netmask"
|
|
||||||
|
|
||||||
# Gateway (no gateway is fine for local networking)
|
|
||||||
echo -n "Gateway (optional) []: "
|
|
||||||
read gateway
|
|
||||||
|
|
||||||
# DNS Servers
|
|
||||||
dns1_default="$(grep '^nameserver' $RESOLVCONF 2>/dev/null | \
|
|
||||||
sed '1q' | awk '{print $2}')"
|
|
||||||
dns2_default="$(grep '^nameserver' $RESOLVCONF 2>/dev/null | \
|
|
||||||
sed '2q;d' | awk '{print $2}')"
|
|
||||||
|
|
||||||
echo -n "Primary DNS Server [$dns1_default]: "
|
|
||||||
read dns1
|
|
||||||
[ -z "$dns1" ] && dns1="$dns1_default"
|
|
||||||
|
|
||||||
if [ -n "$dns1" ]; then
|
|
||||||
echo -n "Secondary DNS Server (optional) [$dns2_default]: "
|
|
||||||
read dns2
|
|
||||||
[ -z "$dns2" ] && dns2="$dns2_default"
|
|
||||||
else
|
|
||||||
dns2=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
backup_file "$HOSTNAME"
|
|
||||||
echo "$hostname" > $HOSTNAME
|
|
||||||
hostname "$hostname"
|
|
||||||
|
|
||||||
backup_file "$iffile"
|
|
||||||
echo 'up' > $iffile
|
|
||||||
echo "inet $ip$netmask" >> $iffile
|
|
||||||
if [ -n "$gateway" ]; then
|
|
||||||
echo "!route -q add default $gateway" >> $iffile
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$dns1" ]; then
|
|
||||||
backup_file "$RESOLVCONF"
|
|
||||||
echo "nameserver $dns1" > $RESOLVCONF
|
|
||||||
if [ -n "$dns2" ]; then
|
|
||||||
echo "nameserver $dns2" >> $RESOLVCONF
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Interface $ifchoice configured manually."
|
|
||||||
step=do_step3
|
|
||||||
;;
|
|
||||||
$remove_choice)
|
|
||||||
backup_file "$iffile"
|
|
||||||
rm -f "$iffile"
|
|
||||||
echo
|
|
||||||
echo "Removed configuration for interface $ifchoice."
|
|
||||||
step=do_step3
|
|
||||||
;;
|
|
||||||
$goback_choice)
|
|
||||||
step=do_step1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
do_step3()
|
|
||||||
{
|
|
||||||
|
|
||||||
# We get here only if one of the ifconfig.if(5) files have changed.
|
|
||||||
changed="yes"
|
|
||||||
|
|
||||||
echo "
|
|
||||||
Do you want to configure additional interfaces?
|
|
||||||
|
|
||||||
You can also invoke the 'netconf' command as root at any later time.
|
|
||||||
|
|
||||||
1. Go back to interface selection
|
|
||||||
2. Quit
|
|
||||||
"
|
|
||||||
|
|
||||||
# Note that "quit" is deliberately the default choice: most people will
|
|
||||||
# want to configure at most one interface, and keep pressing Enter in
|
|
||||||
# order to make it through the setup procedure as easily as possible.
|
|
||||||
select_number 1 2 2 "Menu choice?"
|
|
||||||
|
|
||||||
[ $? -eq 1 ] && step=do_step1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse options
|
|
||||||
while getopts "p:hl" arg; do
|
|
||||||
case "$arg" in
|
|
||||||
p) prefix=$OPTARG; ;;
|
|
||||||
h) usage ;;
|
|
||||||
l) echo "The following network hardware interfaces are detected:"
|
|
||||||
echo
|
|
||||||
interfaces "configured"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
\?) echo "Unknown option -$OPTARG"; usage ;;
|
|
||||||
:) echo "Missing required argument for -$OPTARG"; usage ;;
|
|
||||||
*) usage ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$prefix" ] ; then
|
|
||||||
if [ ! -d $prefix ]; then
|
|
||||||
echo -e "It seems the supplied prefix (\`$prefix') is invalid."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
LOCALRC=$prefix$LOCALRC
|
|
||||||
IFCONF=$prefix$IFCONF
|
|
||||||
RESOLVCONF=$prefix$RESOLVCONF
|
|
||||||
HOSTNAME=$prefix$HOSTNAME
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `whoami` != root ] ; then
|
|
||||||
echo "Please run netconf as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! ifconfig -l >/dev/null 2>&1; then
|
|
||||||
echo "Unable to obtain a list of interfaces. Is the LWIP service running?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Are we running from CD?
|
|
||||||
if [ -f "$USRKBFILE" ] ; then
|
|
||||||
cd="yes" # We are running from CD
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The interactive program.
|
|
||||||
step=do_step1
|
|
||||||
while [ $step != exit ]; do
|
|
||||||
proc=$step
|
|
||||||
step=exit
|
|
||||||
$proc
|
|
||||||
done
|
|
||||||
|
|
||||||
# Skip printing this last bit of information if it will not actually work. The
|
|
||||||
# fact that it will not work on the CD (i.e. from the setup program) at least
|
|
||||||
# yet, is also the reason why we do not simply issue the command ourselves
|
|
||||||
# right now. We might reconsider this later.
|
|
||||||
if [ "$changed" = "yes" -a -z "$prefix" ]; then
|
|
||||||
echo
|
|
||||||
echo "One or more of the interface configuration files have been changed."
|
|
||||||
echo "You can use the command 'service network restart' to reload them now."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Aesthetics.
|
|
||||||
echo
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
@ -1,876 +0,0 @@
|
||||||
/*
|
|
||||||
* This file implements support for i2c on the BeagleBone and BeagleBoard-xM
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* kernel headers */
|
|
||||||
#include <minix/chardriver.h>
|
|
||||||
#include <minix/clkconf.h>
|
|
||||||
#include <minix/drivers.h>
|
|
||||||
#include <minix/ds.h>
|
|
||||||
#include <minix/log.h>
|
|
||||||
#include <minix/mmio.h>
|
|
||||||
#include <minix/padconf.h>
|
|
||||||
#include <minix/sysutil.h>
|
|
||||||
#include <minix/type.h>
|
|
||||||
#include <minix/board.h>
|
|
||||||
#include <minix/spin.h>
|
|
||||||
|
|
||||||
/* device headers */
|
|
||||||
#include <minix/i2c.h>
|
|
||||||
|
|
||||||
/* system headers */
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/* usr headers */
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/* local headers */
|
|
||||||
#include "omap_i2c.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* defines the set of register
|
|
||||||
*
|
|
||||||
* Warning: always use the 16-bit variants of read/write/set from mmio.h
|
|
||||||
* to access these registers. The DM37XX TRM Section 17.6 warns that 32-bit
|
|
||||||
* accesses can corrupt the register contents.
|
|
||||||
*/
|
|
||||||
typedef struct omap_i2c_registers
|
|
||||||
{
|
|
||||||
vir_bytes I2C_REVNB_LO; /* AM335X Only */
|
|
||||||
vir_bytes I2C_REVNB_HI; /* AM335X Only */
|
|
||||||
vir_bytes I2C_REV; /* DM37XX Only */
|
|
||||||
vir_bytes I2C_IE; /* DM37XX Only */
|
|
||||||
vir_bytes I2C_STAT; /* DM37XX Only */
|
|
||||||
vir_bytes I2C_SYSC;
|
|
||||||
vir_bytes I2C_IRQSTATUS_RAW; /* AM335X Only */
|
|
||||||
vir_bytes I2C_IRQSTATUS; /* AM335X Only */
|
|
||||||
vir_bytes I2C_IRQENABLE_SET; /* AM335X Only */
|
|
||||||
vir_bytes I2C_IRQENABLE_CLR; /* AM335X Only */
|
|
||||||
vir_bytes I2C_WE;
|
|
||||||
vir_bytes I2C_DMARXENABLE_SET; /* AM335X Only */
|
|
||||||
vir_bytes I2C_DMATXENABLE_SET; /* AM335X Only */
|
|
||||||
vir_bytes I2C_DMARXENABLE_CLR; /* AM335X Only */
|
|
||||||
vir_bytes I2C_DMATXENABLE_CLR; /* AM335X Only */
|
|
||||||
vir_bytes I2C_DMARXWAKE_EN; /* AM335X Only */
|
|
||||||
vir_bytes I2C_DMATXWAKE_EN; /* AM335X Only */
|
|
||||||
vir_bytes I2C_SYSS;
|
|
||||||
vir_bytes I2C_BUF;
|
|
||||||
vir_bytes I2C_CNT;
|
|
||||||
vir_bytes I2C_DATA;
|
|
||||||
vir_bytes I2C_CON;
|
|
||||||
vir_bytes I2C_OA; /* AM335X Only */
|
|
||||||
vir_bytes I2C_OA0; /* DM37XX Only */
|
|
||||||
vir_bytes I2C_SA;
|
|
||||||
vir_bytes I2C_PSC;
|
|
||||||
vir_bytes I2C_SCLL;
|
|
||||||
vir_bytes I2C_SCLH;
|
|
||||||
vir_bytes I2C_SYSTEST;
|
|
||||||
vir_bytes I2C_BUFSTAT;
|
|
||||||
vir_bytes I2C_OA1;
|
|
||||||
vir_bytes I2C_OA2;
|
|
||||||
vir_bytes I2C_OA3;
|
|
||||||
vir_bytes I2C_ACTOA;
|
|
||||||
vir_bytes I2C_SBLOCK;
|
|
||||||
} omap_i2c_regs_t;
|
|
||||||
|
|
||||||
/* generic definition an i2c bus */
|
|
||||||
|
|
||||||
typedef struct omap_i2c_bus
|
|
||||||
{
|
|
||||||
enum bus_types
|
|
||||||
{ AM335X_I2C_BUS, DM37XX_I2C_BUS} bus_type;
|
|
||||||
phys_bytes mr_base;
|
|
||||||
phys_bytes mr_size;
|
|
||||||
vir_bytes mapped_addr;
|
|
||||||
omap_i2c_regs_t *regs;
|
|
||||||
uint32_t functional_clock;
|
|
||||||
uint32_t module_clock;
|
|
||||||
uint32_t bus_speed;
|
|
||||||
uint16_t major;
|
|
||||||
uint16_t minor;
|
|
||||||
int irq;
|
|
||||||
int irq_hook_id;
|
|
||||||
int irq_hook_kernel_id;
|
|
||||||
} omap_i2c_bus_t;
|
|
||||||
|
|
||||||
/* Define the registers for each chip */
|
|
||||||
|
|
||||||
static omap_i2c_regs_t am335x_i2c_regs = {
|
|
||||||
.I2C_REVNB_LO = AM335X_I2C_REVNB_LO,
|
|
||||||
.I2C_REVNB_HI = AM335X_I2C_REVNB_HI,
|
|
||||||
.I2C_SYSC = AM335X_I2C_SYSC,
|
|
||||||
.I2C_IRQSTATUS_RAW = AM335X_I2C_IRQSTATUS_RAW,
|
|
||||||
.I2C_IRQSTATUS = AM335X_I2C_IRQSTATUS,
|
|
||||||
.I2C_IRQENABLE_SET = AM335X_I2C_IRQENABLE_SET,
|
|
||||||
.I2C_IRQENABLE_CLR = AM335X_I2C_IRQENABLE_CLR,
|
|
||||||
.I2C_WE = AM335X_I2C_WE,
|
|
||||||
.I2C_DMARXENABLE_SET = AM335X_I2C_DMARXENABLE_SET,
|
|
||||||
.I2C_DMATXENABLE_SET = AM335X_I2C_DMATXENABLE_SET,
|
|
||||||
.I2C_DMARXENABLE_CLR = AM335X_I2C_DMARXENABLE_CLR,
|
|
||||||
.I2C_DMATXENABLE_CLR = AM335X_I2C_DMATXENABLE_CLR,
|
|
||||||
.I2C_DMARXWAKE_EN = AM335X_I2C_DMARXWAKE_EN,
|
|
||||||
.I2C_DMATXWAKE_EN = AM335X_I2C_DMATXWAKE_EN,
|
|
||||||
.I2C_SYSS = AM335X_I2C_SYSS,
|
|
||||||
.I2C_BUF = AM335X_I2C_BUF,
|
|
||||||
.I2C_CNT = AM335X_I2C_CNT,
|
|
||||||
.I2C_DATA = AM335X_I2C_DATA,
|
|
||||||
.I2C_CON = AM335X_I2C_CON,
|
|
||||||
.I2C_OA = AM335X_I2C_OA,
|
|
||||||
.I2C_SA = AM335X_I2C_SA,
|
|
||||||
.I2C_PSC = AM335X_I2C_PSC,
|
|
||||||
.I2C_SCLL = AM335X_I2C_SCLL,
|
|
||||||
.I2C_SCLH = AM335X_I2C_SCLH,
|
|
||||||
.I2C_SYSTEST = AM335X_I2C_SYSTEST,
|
|
||||||
.I2C_BUFSTAT = AM335X_I2C_BUFSTAT,
|
|
||||||
.I2C_OA1 = AM335X_I2C_OA1,
|
|
||||||
.I2C_OA2 = AM335X_I2C_OA2,
|
|
||||||
.I2C_OA3 = AM335X_I2C_OA3,
|
|
||||||
.I2C_ACTOA = AM335X_I2C_ACTOA,
|
|
||||||
.I2C_SBLOCK = AM335X_I2C_SBLOCK
|
|
||||||
};
|
|
||||||
|
|
||||||
static omap_i2c_regs_t dm37xx_i2c_regs = {
|
|
||||||
.I2C_REV = DM37XX_I2C_REV,
|
|
||||||
.I2C_IE = DM37XX_I2C_IE,
|
|
||||||
.I2C_STAT = DM37XX_I2C_STAT,
|
|
||||||
.I2C_WE = DM37XX_I2C_WE,
|
|
||||||
.I2C_SYSS = DM37XX_I2C_SYSS,
|
|
||||||
.I2C_BUF = DM37XX_I2C_BUF,
|
|
||||||
.I2C_CNT = DM37XX_I2C_CNT,
|
|
||||||
.I2C_DATA = DM37XX_I2C_DATA,
|
|
||||||
.I2C_SYSC = DM37XX_I2C_SYSC,
|
|
||||||
.I2C_CON = DM37XX_I2C_CON,
|
|
||||||
.I2C_OA0 = DM37XX_I2C_OA0,
|
|
||||||
.I2C_SA = DM37XX_I2C_SA,
|
|
||||||
.I2C_PSC = DM37XX_I2C_PSC,
|
|
||||||
.I2C_SCLL = DM37XX_I2C_SCLL,
|
|
||||||
.I2C_SCLH = DM37XX_I2C_SCLH,
|
|
||||||
.I2C_SYSTEST = DM37XX_I2C_SYSTEST,
|
|
||||||
.I2C_BUFSTAT = DM37XX_I2C_BUFSTAT,
|
|
||||||
.I2C_OA1 = DM37XX_I2C_OA1,
|
|
||||||
.I2C_OA2 = DM37XX_I2C_OA2,
|
|
||||||
.I2C_OA3 = DM37XX_I2C_OA3,
|
|
||||||
.I2C_ACTOA = DM37XX_I2C_ACTOA,
|
|
||||||
.I2C_SBLOCK = DM37XX_I2C_SBLOCK
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Define the buses available on each chip */
|
|
||||||
|
|
||||||
static omap_i2c_bus_t am335x_i2c_buses[] = {
|
|
||||||
{AM335X_I2C_BUS, AM335X_I2C0_BASE, AM335X_I2C0_SIZE, 0, &am335x_i2c_regs,
|
|
||||||
AM335X_FUNCTIONAL_CLOCK, AM335X_MODULE_CLOCK,
|
|
||||||
BUS_SPEED_400KHz, AM335X_REV_MAJOR, AM335X_REV_MINOR,
|
|
||||||
AM335X_I2C0_IRQ, 1, 1},
|
|
||||||
{AM335X_I2C_BUS, AM335X_I2C1_BASE, AM335X_I2C1_SIZE, 0, &am335x_i2c_regs,
|
|
||||||
AM335X_FUNCTIONAL_CLOCK, AM335X_MODULE_CLOCK,
|
|
||||||
BUS_SPEED_100KHz, AM335X_REV_MAJOR, AM335X_REV_MINOR,
|
|
||||||
AM335X_I2C1_IRQ, 2, 3},
|
|
||||||
{AM335X_I2C_BUS, AM335X_I2C2_BASE, AM335X_I2C2_SIZE, 0, &am335x_i2c_regs,
|
|
||||||
AM335X_FUNCTIONAL_CLOCK, AM335X_MODULE_CLOCK,
|
|
||||||
BUS_SPEED_100KHz, AM335X_REV_MAJOR, AM335X_REV_MINOR,
|
|
||||||
AM335X_I2C2_IRQ, 3, 3}
|
|
||||||
};
|
|
||||||
|
|
||||||
#define AM335X_OMAP_NBUSES (sizeof(am335x_i2c_buses) / sizeof(omap_i2c_bus_t))
|
|
||||||
|
|
||||||
static omap_i2c_bus_t dm37xx_i2c_buses[] = {
|
|
||||||
{DM37XX_I2C_BUS, DM37XX_I2C0_BASE, DM37XX_I2C0_SIZE, 0, &dm37xx_i2c_regs,
|
|
||||||
DM37XX_FUNCTIONAL_CLOCK, DM37XX_MODULE_CLOCK,
|
|
||||||
BUS_SPEED_100KHz, DM37XX_REV_MAJOR, DM37XX_REV_MINOR,
|
|
||||||
DM37XX_I2C0_IRQ, 1, 1},
|
|
||||||
{DM37XX_I2C_BUS, DM37XX_I2C1_BASE, DM37XX_I2C1_SIZE, 0, &dm37xx_i2c_regs,
|
|
||||||
DM37XX_FUNCTIONAL_CLOCK, DM37XX_MODULE_CLOCK,
|
|
||||||
BUS_SPEED_100KHz, DM37XX_REV_MAJOR, DM37XX_REV_MINOR,
|
|
||||||
DM37XX_I2C1_IRQ, 2, 2},
|
|
||||||
{DM37XX_I2C_BUS, DM37XX_I2C2_BASE, DM37XX_I2C2_SIZE, 0, &dm37xx_i2c_regs,
|
|
||||||
DM37XX_FUNCTIONAL_CLOCK, DM37XX_MODULE_CLOCK,
|
|
||||||
BUS_SPEED_100KHz, DM37XX_REV_MAJOR, DM37XX_REV_MINOR,
|
|
||||||
DM37XX_I2C2_IRQ, 3, 3}
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DM37XX_OMAP_NBUSES (sizeof(dm37xx_i2c_buses) / sizeof(omap_i2c_bus_t))
|
|
||||||
|
|
||||||
/* Globals */
|
|
||||||
|
|
||||||
static omap_i2c_bus_t *omap_i2c_buses; /* all available buses for this SoC */
|
|
||||||
static omap_i2c_bus_t *omap_i2c_bus; /* the bus selected at start-up */
|
|
||||||
static int omap_i2c_nbuses; /* number of buses supported by SoC */
|
|
||||||
|
|
||||||
/* logging - use with log_warn(), log_info(), log_debug(), log_trace() */
|
|
||||||
static struct log log = {
|
|
||||||
.name = "i2c",
|
|
||||||
.log_level = LEVEL_INFO,
|
|
||||||
.log_func = default_log
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Local Function Prototypes */
|
|
||||||
|
|
||||||
/* Implementation of Generic I2C Interface using Bus Specific Code */
|
|
||||||
static int omap_i2c_process(minix_i2c_ioctl_exec_t * m);
|
|
||||||
|
|
||||||
/* Bus Specific Code */
|
|
||||||
static void omap_i2c_flush(void);
|
|
||||||
static uint16_t omap_i2c_poll(uint16_t mask);
|
|
||||||
static int omap_i2c_bus_is_free(void);
|
|
||||||
static int omap_i2c_soft_reset(void);
|
|
||||||
static void omap_i2c_bus_init(void);
|
|
||||||
static void omap_i2c_padconf(int i2c_bus_id);
|
|
||||||
static void omap_i2c_clkconf(int i2c_bus_id);
|
|
||||||
static void omap_i2c_intr_enable(void);
|
|
||||||
static uint16_t omap_i2c_read_status(void);
|
|
||||||
static void omap_i2c_write_status(uint16_t mask);
|
|
||||||
static int omap_i2c_read(i2c_addr_t addr, uint8_t * buf, size_t buflen,
|
|
||||||
int dostop);
|
|
||||||
static int omap_i2c_write(i2c_addr_t addr, const uint8_t * buf, size_t buflen,
|
|
||||||
int dostop);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Performs the action in minix_i2c_ioctl_exec_t.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
omap_i2c_process(minix_i2c_ioctl_exec_t * ioctl_exec)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Zero data bytes transfers are not allowed. The controller treats
|
|
||||||
* I2C_CNT register value of 0x0 as 65536. This is true for both the
|
|
||||||
* am335x and dm37xx. Full details in the TRM on the I2C_CNT page.
|
|
||||||
*/
|
|
||||||
if (ioctl_exec->iie_buflen == 0) {
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
omap_i2c_flush(); /* clear any garbage in the fifo */
|
|
||||||
|
|
||||||
/* Check bus busy flag before using the bus */
|
|
||||||
r = omap_i2c_bus_is_free();
|
|
||||||
if (r == 0) {
|
|
||||||
log_warn(&log, "Bus is busy\n");
|
|
||||||
return EBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl_exec->iie_cmdlen > 0) {
|
|
||||||
r = omap_i2c_write(ioctl_exec->iie_addr, ioctl_exec->iie_cmd,
|
|
||||||
ioctl_exec->iie_cmdlen,
|
|
||||||
!(I2C_OP_READ_P(ioctl_exec->iie_op)));
|
|
||||||
if (r != OK) {
|
|
||||||
omap_i2c_soft_reset();
|
|
||||||
omap_i2c_bus_init();
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (I2C_OP_READ_P(ioctl_exec->iie_op)) {
|
|
||||||
r = omap_i2c_read(ioctl_exec->iie_addr, ioctl_exec->iie_buf,
|
|
||||||
ioctl_exec->iie_buflen, I2C_OP_STOP_P(ioctl_exec->iie_op));
|
|
||||||
} else {
|
|
||||||
r = omap_i2c_write(ioctl_exec->iie_addr, ioctl_exec->iie_buf,
|
|
||||||
ioctl_exec->iie_buflen, I2C_OP_STOP_P(ioctl_exec->iie_op));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r != OK) {
|
|
||||||
omap_i2c_soft_reset();
|
|
||||||
omap_i2c_bus_init();
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Drain the incoming FIFO.
|
|
||||||
*
|
|
||||||
* Usually called to clear any garbage that may be in the buffer before
|
|
||||||
* doing a read.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
omap_i2c_flush(void)
|
|
||||||
{
|
|
||||||
int tries;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
for (tries = 0; tries < 1000; tries++) {
|
|
||||||
status = omap_i2c_poll(1 << RRDY);
|
|
||||||
if ((status & (1 << RRDY)) != 0) { /* bytes available for reading */
|
|
||||||
|
|
||||||
/* consume the byte and throw it away */
|
|
||||||
(void) read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_DATA);
|
|
||||||
|
|
||||||
/* clear the read ready flag */
|
|
||||||
omap_i2c_write_status(1 << RRDY);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
break; /* buffer drained */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Poll the status register checking the bits set in 'mask'.
|
|
||||||
* Returns the status if any bits set or 0x0000 when the timeout is reached.
|
|
||||||
*/
|
|
||||||
static uint16_t
|
|
||||||
omap_i2c_poll(uint16_t mask)
|
|
||||||
{
|
|
||||||
spin_t spin;
|
|
||||||
uint16_t status;
|
|
||||||
|
|
||||||
/* poll for up to 1 s */
|
|
||||||
spin_init(&spin, 1000000);
|
|
||||||
do {
|
|
||||||
status = omap_i2c_read_status();
|
|
||||||
if ((status & mask) != 0) { /* any bits in mask set */
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (spin_check(&spin));
|
|
||||||
|
|
||||||
return status; /* timeout reached, abort */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Poll Bus Busy Flag until the bus becomes free (return 1) or the timeout
|
|
||||||
* expires (return 0).
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
omap_i2c_bus_is_free(void)
|
|
||||||
{
|
|
||||||
spin_t spin;
|
|
||||||
uint16_t status;
|
|
||||||
|
|
||||||
/* wait for up to 1 second for the bus to become free */
|
|
||||||
spin_init(&spin, 1000000);
|
|
||||||
do {
|
|
||||||
|
|
||||||
status = omap_i2c_read_status();
|
|
||||||
if ((status & (1 << BB)) == 0) {
|
|
||||||
return 1; /* bus is free */
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (spin_check(&spin));
|
|
||||||
|
|
||||||
return 0; /* timeout expired */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
omap_i2c_clkconf(int i2c_bus_id)
|
|
||||||
{
|
|
||||||
clkconf_init();
|
|
||||||
|
|
||||||
if (omap_i2c_bus->bus_type == DM37XX_I2C_BUS) {
|
|
||||||
|
|
||||||
clkconf_set(CM_ICLKEN1_CORE, BIT((15 + i2c_bus_id)),
|
|
||||||
0xffffffff);
|
|
||||||
clkconf_set(CM_FCLKEN1_CORE, BIT((15 + i2c_bus_id)),
|
|
||||||
0xffffffff);
|
|
||||||
|
|
||||||
} else if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
|
|
||||||
switch (i2c_bus_id) {
|
|
||||||
case 0:
|
|
||||||
clkconf_set(CM_WKUP_I2C0_CLKCTRL, BIT(1), 0xffffffff);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
clkconf_set(CM_PER_I2C1_CLKCTRL, BIT(1), 0xffffffff);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
clkconf_set(CM_PER_I2C2_CLKCTRL, BIT(1), 0xffffffff);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log_warn(&log, "Invalid i2c_bus_id\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clkconf_release();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
omap_i2c_padconf(int i2c_bus_id)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
u32_t pinopts;
|
|
||||||
|
|
||||||
if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
|
|
||||||
/* use the options suggested in starterware driver */
|
|
||||||
pinopts =
|
|
||||||
CONTROL_CONF_SLEWCTRL | CONTROL_CONF_RXACTIVE |
|
|
||||||
CONTROL_CONF_PUTYPESEL;
|
|
||||||
|
|
||||||
switch (i2c_bus_id) {
|
|
||||||
case 0:
|
|
||||||
pinopts |= CONTROL_CONF_MUXMODE(0);
|
|
||||||
|
|
||||||
r = sys_padconf(CONTROL_CONF_I2C0_SDA, 0xffffffff,
|
|
||||||
pinopts);
|
|
||||||
if (r != OK) {
|
|
||||||
log_warn(&log, "padconf failed (r=%d)\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = sys_padconf(CONTROL_CONF_I2C0_SCL, 0xffffffff,
|
|
||||||
pinopts);
|
|
||||||
if (r != OK) {
|
|
||||||
log_warn(&log, "padconf failed (r=%d)\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_debug(&log, "pinopts=0x%x\n", pinopts);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
pinopts |= CONTROL_CONF_MUXMODE(2);
|
|
||||||
|
|
||||||
r = sys_padconf(CONTROL_CONF_SPI0_CS0, 0xffffffff,
|
|
||||||
pinopts);
|
|
||||||
if (r != OK) {
|
|
||||||
log_warn(&log, "padconf failed (r=%d)\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = sys_padconf(CONTROL_CONF_SPI0_D1, 0xffffffff,
|
|
||||||
pinopts);
|
|
||||||
if (r != OK) {
|
|
||||||
log_warn(&log, "padconf failed (r=%d)\n", r);
|
|
||||||
}
|
|
||||||
log_debug(&log, "pinopts=0x%x\n", pinopts);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
pinopts |= CONTROL_CONF_MUXMODE(3);
|
|
||||||
|
|
||||||
r = sys_padconf(CONTROL_CONF_UART1_CTSN, 0xffffffff,
|
|
||||||
pinopts);
|
|
||||||
if (r != OK) {
|
|
||||||
log_warn(&log, "padconf failed (r=%d)\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = sys_padconf(CONTROL_CONF_UART1_RTSN,
|
|
||||||
0xffffffff, pinopts);
|
|
||||||
if (r != OK) {
|
|
||||||
log_warn(&log, "padconf failed (r=%d)\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_debug(&log, "pinopts=0x%x\n", pinopts);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
log_warn(&log, "Invalid i2c_bus_id\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* nothing to do for the DM37XX */
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
omap_i2c_soft_reset(void)
|
|
||||||
{
|
|
||||||
spin_t spin;
|
|
||||||
|
|
||||||
/* Disable to do soft reset */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CON, 0);
|
|
||||||
micro_delay(50000);
|
|
||||||
|
|
||||||
/* Do a soft reset */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SYSC, (1 << SRST));
|
|
||||||
|
|
||||||
/* Have to temporarily enable I2C to read RDONE */
|
|
||||||
set16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CON, (1<<I2C_EN), (1<<I2C_EN));
|
|
||||||
micro_delay(50000);
|
|
||||||
|
|
||||||
/* wait up to 3 seconds for reset to complete */
|
|
||||||
spin_init(&spin, 3000000);
|
|
||||||
do {
|
|
||||||
if (read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SYSS) & (1 << RDONE)) {
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (spin_check(&spin));
|
|
||||||
|
|
||||||
log_warn(&log, "Tried soft reset, but bus never came back.\n");
|
|
||||||
return EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
omap_i2c_intr_enable(void)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
uint16_t intmask;
|
|
||||||
static int policy_set = 0;
|
|
||||||
static int enabled = 0;
|
|
||||||
|
|
||||||
if (!policy_set) {
|
|
||||||
r = sys_irqsetpolicy(omap_i2c_bus->irq, 0,
|
|
||||||
&omap_i2c_bus->irq_hook_kernel_id);
|
|
||||||
if (r == OK) {
|
|
||||||
policy_set = 1;
|
|
||||||
} else {
|
|
||||||
log_warn(&log, "Couldn't set irq policy\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (policy_set && !enabled) {
|
|
||||||
r = sys_irqenable(&omap_i2c_bus->irq_hook_kernel_id);
|
|
||||||
if (r == OK) {
|
|
||||||
enabled = 1;
|
|
||||||
} else {
|
|
||||||
log_warn(&log, "Couldn't enable irq %d (hooked)\n",
|
|
||||||
omap_i2c_bus->irq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* According to NetBSD driver and u-boot, these are needed even
|
|
||||||
* if just using polling (i.e. non-interrupt driver programming).
|
|
||||||
*/
|
|
||||||
intmask = 0;
|
|
||||||
intmask |= (1 << ROVR);
|
|
||||||
intmask |= (1 << AERR);
|
|
||||||
intmask |= (1 << XRDY);
|
|
||||||
intmask |= (1 << RRDY);
|
|
||||||
intmask |= (1 << ARDY);
|
|
||||||
intmask |= (1 << NACK);
|
|
||||||
intmask |= (1 << AL);
|
|
||||||
|
|
||||||
if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_IRQENABLE_SET, intmask);
|
|
||||||
} else if (omap_i2c_bus->bus_type == DM37XX_I2C_BUS) {
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_IE, intmask);
|
|
||||||
} else {
|
|
||||||
log_warn(&log, "Don't know how to enable interrupts.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
omap_i2c_bus_init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Ensure i2c module is disabled before setting prescalar & bus speed */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CON, 0);
|
|
||||||
micro_delay(50000);
|
|
||||||
|
|
||||||
/* Disable autoidle */
|
|
||||||
set16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SYSC, (1<<AUTOIDLE), (0<<AUTOIDLE));
|
|
||||||
|
|
||||||
/* Set prescalar to obtain 12 MHz i2c module clock */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_PSC,
|
|
||||||
((omap_i2c_bus->functional_clock / omap_i2c_bus->module_clock) -
|
|
||||||
1));
|
|
||||||
|
|
||||||
/* Set the bus speed */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SCLL,
|
|
||||||
((omap_i2c_bus->module_clock / (2 * omap_i2c_bus->bus_speed)) -
|
|
||||||
7));
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SCLH,
|
|
||||||
((omap_i2c_bus->module_clock / (2 * omap_i2c_bus->bus_speed)) -
|
|
||||||
5));
|
|
||||||
|
|
||||||
/* Set own I2C address */
|
|
||||||
if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_OA, I2C_OWN_ADDRESS);
|
|
||||||
} else if (omap_i2c_bus->bus_type == DM37XX_I2C_BUS) {
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_OA0, I2C_OWN_ADDRESS);
|
|
||||||
} else {
|
|
||||||
log_warn(&log, "Don't know how to set own address.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set TX/RX Threshold to 1 and disable I2C DMA */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_BUF, 0x0000);
|
|
||||||
|
|
||||||
/* Bring the i2c module out of reset */
|
|
||||||
set16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CON, (1<<I2C_EN), (1<<I2C_EN));
|
|
||||||
micro_delay(50000);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enable interrupts
|
|
||||||
*/
|
|
||||||
omap_i2c_intr_enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t
|
|
||||||
omap_i2c_read_status(void)
|
|
||||||
{
|
|
||||||
uint16_t status = 0x0000;
|
|
||||||
|
|
||||||
if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
/* TRM says to use RAW for polling for events */
|
|
||||||
status = read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_IRQSTATUS_RAW);
|
|
||||||
} else if (omap_i2c_bus->bus_type == DM37XX_I2C_BUS) {
|
|
||||||
status = read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_STAT);
|
|
||||||
} else {
|
|
||||||
log_warn(&log, "Don't know how to read i2c bus status.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
omap_i2c_write_status(uint16_t mask)
|
|
||||||
{
|
|
||||||
if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
/* write 1's to IRQSTATUS (not RAW) to clear the bits */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_IRQSTATUS, mask);
|
|
||||||
} else if (omap_i2c_bus->bus_type == DM37XX_I2C_BUS) {
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_STAT, mask);
|
|
||||||
} else {
|
|
||||||
log_warn(&log, "Don't know how to clear i2c bus status.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
omap_i2c_read(i2c_addr_t addr, uint8_t * buf, size_t buflen, int dostop)
|
|
||||||
{
|
|
||||||
int r, i;
|
|
||||||
uint16_t conopts;
|
|
||||||
uint16_t pollmask;
|
|
||||||
uint16_t errmask;
|
|
||||||
|
|
||||||
/* Set address of slave device */
|
|
||||||
conopts = 0;
|
|
||||||
addr &= MAX_I2C_SA_MASK; /* sanitize address (10-bit max) */
|
|
||||||
if (addr > 0x7f) {
|
|
||||||
/* 10-bit extended address in use, need to set XSA */
|
|
||||||
conopts |= (1 << XSA);
|
|
||||||
}
|
|
||||||
|
|
||||||
errmask = 0;
|
|
||||||
errmask |= (1 << ROVR);
|
|
||||||
errmask |= (1 << AERR);
|
|
||||||
errmask |= (1 << NACK);
|
|
||||||
errmask |= (1 << AL);
|
|
||||||
|
|
||||||
pollmask = 0;
|
|
||||||
pollmask |= (1 << RRDY);
|
|
||||||
|
|
||||||
/* Set bytes to read and slave address */
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CNT, buflen);
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SA, addr);
|
|
||||||
|
|
||||||
/* Set control register */
|
|
||||||
conopts |= (1 << I2C_EN); /* enabled */
|
|
||||||
conopts |= (1 << MST); /* master mode */
|
|
||||||
conopts |= (1 << STT); /* start condition */
|
|
||||||
|
|
||||||
if (dostop != 0) {
|
|
||||||
conopts |= (1 << STP); /* stop condition */
|
|
||||||
}
|
|
||||||
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CON, conopts);
|
|
||||||
|
|
||||||
for (i = 0; i < buflen; i++) {
|
|
||||||
/* Data to read? */
|
|
||||||
r = omap_i2c_poll(pollmask | errmask);
|
|
||||||
if ((r & errmask) != 0) {
|
|
||||||
/* only debug log level because i2cscan trigers this */
|
|
||||||
log_debug(&log, "Read Error! Status=%x\n", r);
|
|
||||||
return EIO;
|
|
||||||
} else if ((r & pollmask) == 0) {
|
|
||||||
log_warn(&log, "No RRDY Interrupt. Status=%x\n", r);
|
|
||||||
log_warn(&log,
|
|
||||||
"Likely cause: bad pinmux or no devices on bus\n");
|
|
||||||
return EBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* read a byte */
|
|
||||||
buf[i] = read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_DATA) & 0xff;
|
|
||||||
|
|
||||||
/* clear the read ready flag */
|
|
||||||
omap_i2c_write_status(pollmask);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = omap_i2c_read_status();
|
|
||||||
if ((r & (1 << NACK)) != 0) {
|
|
||||||
log_warn(&log, "NACK\n");
|
|
||||||
return EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for operation to complete */
|
|
||||||
pollmask = (1<<ARDY); /* poll access ready bit */
|
|
||||||
r = omap_i2c_poll(pollmask);
|
|
||||||
if ((r & pollmask) == 0) {
|
|
||||||
log_warn(&log, "Read operation never finished.\n");
|
|
||||||
return EBUSY;
|
|
||||||
}
|
|
||||||
omap_i2c_write_status(0x7fff);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
omap_i2c_write(i2c_addr_t addr, const uint8_t * buf, size_t buflen, int dostop)
|
|
||||||
{
|
|
||||||
int r, i;
|
|
||||||
uint16_t conopts;
|
|
||||||
uint16_t pollmask;
|
|
||||||
uint16_t errmask;
|
|
||||||
|
|
||||||
/* Set address of slave device */
|
|
||||||
conopts = 0;
|
|
||||||
addr &= MAX_I2C_SA_MASK; /* sanitize address (10-bit max) */
|
|
||||||
if (addr > 0x7f) {
|
|
||||||
/* 10-bit extended address in use, need to set XSA */
|
|
||||||
conopts |= (1 << XSA);
|
|
||||||
}
|
|
||||||
|
|
||||||
pollmask = 0;
|
|
||||||
pollmask |= (1 << XRDY);
|
|
||||||
|
|
||||||
errmask = 0;
|
|
||||||
errmask |= (1 << ROVR);
|
|
||||||
errmask |= (1 << AERR);
|
|
||||||
errmask |= (1 << NACK);
|
|
||||||
errmask |= (1 << AL);
|
|
||||||
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CNT, buflen);
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_SA, addr);
|
|
||||||
|
|
||||||
/* Set control register */
|
|
||||||
conopts |= (1 << I2C_EN); /* enabled */
|
|
||||||
conopts |= (1 << MST); /* master mode */
|
|
||||||
conopts |= (1 << TRX); /* TRX mode */
|
|
||||||
conopts |= (1 << STT); /* start condition */
|
|
||||||
|
|
||||||
if (dostop != 0) {
|
|
||||||
conopts |= (1 << STP); /* stop condition */
|
|
||||||
}
|
|
||||||
|
|
||||||
omap_i2c_write_status(0x7fff);
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_CON, conopts);
|
|
||||||
|
|
||||||
for (i = 0; i < buflen; i++) {
|
|
||||||
|
|
||||||
/* Ready to write? */
|
|
||||||
r = omap_i2c_poll(pollmask | errmask);
|
|
||||||
if ((r & errmask) != 0) {
|
|
||||||
log_warn(&log, "Write Error! Status=%x\n", r);
|
|
||||||
return EIO;
|
|
||||||
} else if ((r & pollmask) == 0) {
|
|
||||||
log_warn(&log, "Not ready for write? Status=%x\n", r);
|
|
||||||
return EBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
write16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_DATA, buf[i]);
|
|
||||||
|
|
||||||
/* clear the write ready flag */
|
|
||||||
omap_i2c_write_status(pollmask);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = omap_i2c_read_status();
|
|
||||||
if ((r & (1 << NACK)) != 0) {
|
|
||||||
log_warn(&log, "NACK\n");
|
|
||||||
return EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for operation to complete */
|
|
||||||
pollmask = (1<<ARDY); /* poll access ready bit */
|
|
||||||
r = omap_i2c_poll(pollmask);
|
|
||||||
if ((r & pollmask) == 0) {
|
|
||||||
log_warn(&log, "Write operation never finished.\n");
|
|
||||||
return EBUSY;
|
|
||||||
}
|
|
||||||
omap_i2c_write_status(0x7fff);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
omap_interface_setup(int (**process) (minix_i2c_ioctl_exec_t * ioctl_exec),
|
|
||||||
int i2c_bus_id)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
int i2c_rev, major, minor;
|
|
||||||
struct minix_mem_range mr;
|
|
||||||
struct machine machine;
|
|
||||||
sys_getmachine(&machine);
|
|
||||||
|
|
||||||
/* Fill in the function pointer */
|
|
||||||
|
|
||||||
*process = omap_i2c_process;
|
|
||||||
|
|
||||||
/* Select the correct i2c definition for this SoC */
|
|
||||||
|
|
||||||
if (BOARD_IS_BBXM(machine.board_id)){
|
|
||||||
omap_i2c_buses = dm37xx_i2c_buses;
|
|
||||||
omap_i2c_nbuses = DM37XX_OMAP_NBUSES;
|
|
||||||
} else if (BOARD_IS_BB(machine.board_id)){
|
|
||||||
omap_i2c_buses = am335x_i2c_buses;
|
|
||||||
omap_i2c_nbuses = AM335X_OMAP_NBUSES;
|
|
||||||
} else {
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i2c_bus_id < 0 || i2c_bus_id >= omap_i2c_nbuses) {
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* select the bus to operate on */
|
|
||||||
omap_i2c_bus = &omap_i2c_buses[i2c_bus_id];
|
|
||||||
|
|
||||||
/* Configure Pins */
|
|
||||||
omap_i2c_padconf(i2c_bus_id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Map I2C Registers
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Configure memory access */
|
|
||||||
mr.mr_base = omap_i2c_bus->mr_base; /* start addr */
|
|
||||||
mr.mr_limit = mr.mr_base + omap_i2c_bus->mr_size; /* end addr */
|
|
||||||
|
|
||||||
/* ask for privileges to access the I2C memory range */
|
|
||||||
if (sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr) != OK) {
|
|
||||||
panic("Unable to obtain i2c memory range privileges");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* map the memory into this process */
|
|
||||||
omap_i2c_bus->mapped_addr = (vir_bytes) vm_map_phys(SELF,
|
|
||||||
(void *) omap_i2c_bus->mr_base, omap_i2c_bus->mr_size);
|
|
||||||
|
|
||||||
if (omap_i2c_bus->mapped_addr == (vir_bytes) MAP_FAILED) {
|
|
||||||
panic("Unable to map i2c registers");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable Clocks */
|
|
||||||
omap_i2c_clkconf(i2c_bus_id);
|
|
||||||
|
|
||||||
/* Perform a soft reset of the I2C module to ensure a fresh start */
|
|
||||||
r = omap_i2c_soft_reset();
|
|
||||||
if (r != OK) {
|
|
||||||
/* module didn't come back up :( */
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bring up I2C module */
|
|
||||||
omap_i2c_bus_init();
|
|
||||||
|
|
||||||
/* Get I2C Revision */
|
|
||||||
if (omap_i2c_bus->bus_type == AM335X_I2C_BUS) {
|
|
||||||
/* I2C_REVLO revision: major (bits 10-8), minor (bits 5-0) */
|
|
||||||
i2c_rev = read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_REVNB_LO);
|
|
||||||
major = (i2c_rev >> 8) & 0x07;
|
|
||||||
minor = i2c_rev & 0x3f;
|
|
||||||
|
|
||||||
} else if (omap_i2c_bus->bus_type == DM37XX_I2C_BUS) {
|
|
||||||
/* I2C_REV revision: major (bits 7-4), minor (bits 3-0) */
|
|
||||||
i2c_rev = read16(omap_i2c_bus->mapped_addr + omap_i2c_bus->regs->I2C_REV);
|
|
||||||
major = (i2c_rev >> 4) & 0x0f;
|
|
||||||
minor = i2c_rev & 0x0f;
|
|
||||||
} else {
|
|
||||||
panic("Don't know how to read i2c revision.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (major != omap_i2c_bus->major || minor != omap_i2c_bus->minor) {
|
|
||||||
log_warn(&log, "Unrecognized value in I2C_REV register.\n");
|
|
||||||
log_warn(&log, "Read: 0x%x.0x%x | Expected: 0x%x.0x%x\n",
|
|
||||||
major, minor, omap_i2c_bus->major, omap_i2c_bus->minor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* display i2c revision information for debugging purposes */
|
|
||||||
log_debug(&log, "i2c_%d: I2C rev 0x%x.0x%x\n", (i2c_bus_id + 1),
|
|
||||||
major, minor);
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
pci.h
|
|
||||||
|
|
||||||
Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct pci_isabridge
|
|
||||||
{
|
|
||||||
u16_t vid;
|
|
||||||
u16_t did;
|
|
||||||
int checkclass;
|
|
||||||
int type;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pci_acl
|
|
||||||
{
|
|
||||||
int inuse;
|
|
||||||
struct rs_pci acl;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NR_DRIVERS NR_SYS_PROCS
|
|
||||||
|
|
||||||
#define PCI_IB_PIIX 1 /* Intel PIIX compatible ISA bridge */
|
|
||||||
#define PCI_IB_VIA 2 /* VIA compatible ISA bridge */
|
|
||||||
#define PCI_IB_AMD 3 /* AMD compatible ISA bridge */
|
|
||||||
#define PCI_IB_SIS 4 /* SIS compatible ISA bridge */
|
|
||||||
|
|
||||||
#define PCI_PPB_STD 1 /* Standard PCI-to-PCI bridge */
|
|
||||||
#define PCI_PPB_CB 2 /* Cardbus bridge */
|
|
||||||
/* Still needed? */
|
|
||||||
#define PCI_AGPB_VIA 3 /* VIA compatible AGP bridge */
|
|
||||||
|
|
||||||
extern int debug;
|
|
||||||
|
|
||||||
extern struct pci_isabridge pci_isabridge[];
|
|
||||||
extern struct pci_acl pci_acl[NR_DRIVERS];
|
|
||||||
|
|
||||||
/* Function prototypes. */
|
|
||||||
int sef_cb_init(int type, sef_init_info_t *info);
|
|
||||||
int map_service(struct rprocpub *rpub);
|
|
||||||
|
|
||||||
int _pci_grant_access(int devind, endpoint_t proc);
|
|
||||||
int _pci_reserve(int devind, endpoint_t proc, struct rs_pci *aclp);
|
|
||||||
void _pci_release(endpoint_t proc);
|
|
||||||
|
|
||||||
int _pci_first_dev(struct rs_pci *aclp, int *devindp, u16_t *vidp,
|
|
||||||
u16_t *didp);
|
|
||||||
int _pci_next_dev(struct rs_pci *aclp, int *devindp, u16_t *vidp, u16_t
|
|
||||||
*didp);
|
|
||||||
int _pci_find_dev(u8_t bus, u8_t dev, u8_t func, int *devindp);
|
|
||||||
|
|
||||||
void _pci_rescan_bus(u8_t busnr);
|
|
||||||
const char *_pci_dev_name(u16_t vid, u16_t did);
|
|
||||||
|
|
||||||
|
|
||||||
int _pci_get_bar(int devind, int port, u32_t *base, u32_t *size, int
|
|
||||||
*ioflag);
|
|
||||||
int _pci_slot_name(int devind, char **cpp);
|
|
||||||
int _pci_ids(int devind, u16_t *vidp, u16_t *didp);
|
|
||||||
|
|
||||||
/* PCI Config Read functions */
|
|
||||||
int _pci_attr_r8(int devind, int port, u8_t *vp);
|
|
||||||
int _pci_attr_r16(int devind, int port, u16_t *vp);
|
|
||||||
int _pci_attr_r32(int devind, int port, u32_t *vp);
|
|
||||||
|
|
||||||
/* PCI Config Write functions */
|
|
||||||
int _pci_attr_w8(int devind, int port, u8_t value);
|
|
||||||
int _pci_attr_w16(int devind, int port, u16_t value);
|
|
||||||
int _pci_attr_w32(int devind, int port, u32_t value);
|
|
||||||
|
|
||||||
/* minix hooks into NetBSD PCI IDS DB */
|
|
||||||
typedef uint32_t pcireg_t;
|
|
||||||
const char *pci_baseclass_name(pcireg_t reg);
|
|
||||||
const char *pci_subclass_name(pcireg_t reg);
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
# Makefile for the Faulty Block Device (FBD)
|
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
|
||||||
|
|
||||||
PROG= fbd
|
|
||||||
SRCS= fbd.c rule.c action.c
|
|
||||||
|
|
||||||
DPADD+= ${LIBBLOCKDRIVER} ${LIBSYS}
|
|
||||||
LDADD+= -lblockdriver -lsys
|
|
||||||
CPPFLAGS+= -DDEBUG=0
|
|
||||||
|
|
||||||
# The FBD driver requires NetBSD libc.
|
|
||||||
|
|
||||||
.include <minix.service.mk>
|
|
||||||
|
|
@ -1,202 +0,0 @@
|
||||||
/* $NetBSD: sdhcreg.h,v 1.6 2012/03/02 18:20:34 nonaka Exp $ */
|
|
||||||
/* $OpenBSD: sdhcreg.h,v 1.4 2006/07/30 17:20:40 fgsch Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2006 Uwe Stuehler <uwe@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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SDHCREG_H_
|
|
||||||
#define _SDHCREG_H_
|
|
||||||
|
|
||||||
/* Host standard register set */
|
|
||||||
#define SDHC_DMA_ADDR 0x00
|
|
||||||
#define SDHC_BLOCK_SIZE 0x04
|
|
||||||
#define SDHC_BLOCK_COUNT 0x06
|
|
||||||
#define SDHC_BLOCK_COUNT_MAX 512
|
|
||||||
#define SDHC_ARGUMENT 0x08
|
|
||||||
#define SDHC_TRANSFER_MODE 0x0c
|
|
||||||
#define SDHC_MULTI_BLOCK_MODE (1<<5)
|
|
||||||
#define SDHC_READ_MODE (1<<4)
|
|
||||||
#define SDHC_AUTO_CMD12_ENABLE (1<<2)
|
|
||||||
#define SDHC_BLOCK_COUNT_ENABLE (1<<1)
|
|
||||||
#define SDHC_DMA_ENABLE (1<<0)
|
|
||||||
#define SDHC_COMMAND 0x0e
|
|
||||||
/* 14-15 reserved */
|
|
||||||
#define SDHC_COMMAND_INDEX_SHIFT 8
|
|
||||||
#define SDHC_COMMAND_INDEX_MASK 0x3f
|
|
||||||
#define SDHC_COMMAND_TYPE_ABORT (3<<6)
|
|
||||||
#define SDHC_COMMAND_TYPE_RESUME (2<<6)
|
|
||||||
#define SDHC_COMMAND_TYPE_SUSPEND (1<<6)
|
|
||||||
#define SDHC_COMMAND_TYPE_NORMAL (0<<6)
|
|
||||||
#define SDHC_DATA_PRESENT_SELECT (1<<5)
|
|
||||||
#define SDHC_INDEX_CHECK_ENABLE (1<<4)
|
|
||||||
#define SDHC_CRC_CHECK_ENABLE (1<<3)
|
|
||||||
/* 2 reserved */
|
|
||||||
#define SDHC_RESP_LEN_48_CHK_BUSY (3<<0)
|
|
||||||
#define SDHC_RESP_LEN_48 (2<<0)
|
|
||||||
#define SDHC_RESP_LEN_136 (1<<0)
|
|
||||||
#define SDHC_NO_RESPONSE (0<<0)
|
|
||||||
#define SDHC_RESPONSE 0x10 /* - 0x1f */
|
|
||||||
#define SDHC_DATA 0x20
|
|
||||||
#define SDHC_PRESENT_STATE 0x24
|
|
||||||
/* 25-31 reserved */
|
|
||||||
#define SDHC_CMD_LINE_SIGNAL_LEVEL (1<<24)
|
|
||||||
#define SDHC_DAT3_LINE_LEVEL (1<<23)
|
|
||||||
#define SDHC_DAT2_LINE_LEVEL (1<<22)
|
|
||||||
#define SDHC_DAT1_LINE_LEVEL (1<<21)
|
|
||||||
#define SDHC_DAT0_LINE_LEVEL (1<<20)
|
|
||||||
#define SDHC_WRITE_PROTECT_SWITCH (1<<19)
|
|
||||||
#define SDHC_CARD_DETECT_PIN_LEVEL (1<<18)
|
|
||||||
#define SDHC_CARD_STATE_STABLE (1<<17)
|
|
||||||
#define SDHC_CARD_INSERTED (1<<16)
|
|
||||||
/* 12-15 reserved */
|
|
||||||
#define SDHC_BUFFER_READ_ENABLE (1<<11)
|
|
||||||
#define SDHC_BUFFER_WRITE_ENABLE (1<<10)
|
|
||||||
#define SDHC_READ_TRANSFER_ACTIVE (1<<9)
|
|
||||||
#define SDHC_WRITE_TRANSFER_ACTIVE (1<<8)
|
|
||||||
/* 3-7 reserved */
|
|
||||||
#define SDHC_DAT_ACTIVE (1<<2)
|
|
||||||
#define SDHC_CMD_INHIBIT_DAT (1<<1)
|
|
||||||
#define SDHC_CMD_INHIBIT_CMD (1<<0)
|
|
||||||
#define SDHC_CMD_INHIBIT_MASK 0x0003
|
|
||||||
#define SDHC_HOST_CTL 0x28
|
|
||||||
#define SDHC_HIGH_SPEED (1<<2)
|
|
||||||
#define SDHC_ESDHC_8BIT_MODE (1<<2) /* eSDHC */
|
|
||||||
#define SDHC_4BIT_MODE (1<<1)
|
|
||||||
#define SDHC_LED_ON (1<<0)
|
|
||||||
#define SDHC_POWER_CTL 0x29
|
|
||||||
#define SDHC_VOLTAGE_SHIFT 1
|
|
||||||
#define SDHC_VOLTAGE_MASK 0x07
|
|
||||||
#define SDHC_VOLTAGE_3_3V 0x07
|
|
||||||
#define SDHC_VOLTAGE_3_0V 0x06
|
|
||||||
#define SDHC_VOLTAGE_1_8V 0x05
|
|
||||||
#define SDHC_BUS_POWER (1<<0)
|
|
||||||
#define SDHC_BLOCK_GAP_CTL 0x2a
|
|
||||||
#define SDHC_WAKEUP_CTL 0x2b
|
|
||||||
#define SDHC_CLOCK_CTL 0x2c
|
|
||||||
#define SDHC_SDCLK_DIV_SHIFT 8
|
|
||||||
#define SDHC_SDCLK_DIV_MASK 0xff
|
|
||||||
#define SDHC_SDCLK_XDIV_SHIFT 6
|
|
||||||
#define SDHC_SDCLK_XDIV_MASK 0x3
|
|
||||||
#define SDHC_SDCLK_CGM (1<<5)
|
|
||||||
#define SDHC_SDCLK_DVS_SHIFT 4
|
|
||||||
#define SDHC_SDCLK_DVS_MASK 0xf
|
|
||||||
#define SDHC_SDCLK_ENABLE (1<<2)
|
|
||||||
#define SDHC_INTCLK_STABLE (1<<1)
|
|
||||||
#define SDHC_INTCLK_ENABLE (1<<0)
|
|
||||||
#define SDHC_TIMEOUT_CTL 0x2e
|
|
||||||
#define SDHC_TIMEOUT_MAX 0x0e
|
|
||||||
#define SDHC_SOFTWARE_RESET 0x2f
|
|
||||||
#define SDHC_INIT_ACTIVE (1<<3)
|
|
||||||
#define SDHC_RESET_MASK 0x5
|
|
||||||
#define SDHC_RESET_DAT (1<<2)
|
|
||||||
#define SDHC_RESET_CMD (1<<1)
|
|
||||||
#define SDHC_RESET_ALL (1<<0)
|
|
||||||
#define SDHC_NINTR_STATUS 0x30
|
|
||||||
#define SDHC_ERROR_INTERRUPT (1<<15)
|
|
||||||
#define SDHC_CARD_INTERRUPT (1<<8)
|
|
||||||
#define SDHC_CARD_REMOVAL (1<<7)
|
|
||||||
#define SDHC_CARD_INSERTION (1<<6)
|
|
||||||
#define SDHC_BUFFER_READ_READY (1<<5)
|
|
||||||
#define SDHC_BUFFER_WRITE_READY (1<<4)
|
|
||||||
#define SDHC_DMA_INTERRUPT (1<<3)
|
|
||||||
#define SDHC_BLOCK_GAP_EVENT (1<<2)
|
|
||||||
#define SDHC_TRANSFER_COMPLETE (1<<1)
|
|
||||||
#define SDHC_COMMAND_COMPLETE (1<<0)
|
|
||||||
#define SDHC_NINTR_STATUS_MASK 0x81ff
|
|
||||||
#define SDHC_EINTR_STATUS 0x32
|
|
||||||
#define SDHC_DMA_ERROR (1<<12)
|
|
||||||
#define SDHC_AUTO_CMD12_ERROR (1<<8)
|
|
||||||
#define SDHC_CURRENT_LIMIT_ERROR (1<<7)
|
|
||||||
#define SDHC_DATA_END_BIT_ERROR (1<<6)
|
|
||||||
#define SDHC_DATA_CRC_ERROR (1<<5)
|
|
||||||
#define SDHC_DATA_TIMEOUT_ERROR (1<<4)
|
|
||||||
#define SDHC_CMD_INDEX_ERROR (1<<3)
|
|
||||||
#define SDHC_CMD_END_BIT_ERROR (1<<2)
|
|
||||||
#define SDHC_CMD_CRC_ERROR (1<<1)
|
|
||||||
#define SDHC_CMD_TIMEOUT_ERROR (1<<0)
|
|
||||||
#define SDHC_EINTR_STATUS_MASK 0x01ff /* excluding vendor signals */
|
|
||||||
#define SDHC_NINTR_STATUS_EN 0x34
|
|
||||||
#define SDHC_EINTR_STATUS_EN 0x36
|
|
||||||
#define SDHC_NINTR_SIGNAL_EN 0x38
|
|
||||||
#define SDHC_NINTR_SIGNAL_MASK 0x01ff
|
|
||||||
#define SDHC_EINTR_SIGNAL_EN 0x3a
|
|
||||||
#define SDHC_EINTR_SIGNAL_MASK 0x01ff /* excluding vendor signals */
|
|
||||||
#define SDHC_CMD12_ERROR_STATUS 0x3c
|
|
||||||
#define SDHC_CAPABILITIES 0x40
|
|
||||||
#define SDHC_VOLTAGE_SUPP_1_8V (1<<26)
|
|
||||||
#define SDHC_VOLTAGE_SUPP_3_0V (1<<25)
|
|
||||||
#define SDHC_VOLTAGE_SUPP_3_3V (1<<24)
|
|
||||||
#define SDHC_DMA_SUPPORT (1<<22)
|
|
||||||
#define SDHC_HIGH_SPEED_SUPP (1<<21)
|
|
||||||
#define SDHC_MAX_BLK_LEN_512 0
|
|
||||||
#define SDHC_MAX_BLK_LEN_1024 1
|
|
||||||
#define SDHC_MAX_BLK_LEN_2048 2
|
|
||||||
#define SDHC_MAX_BLK_LEN_4096 3
|
|
||||||
#define SDHC_MAX_BLK_LEN_SHIFT 16
|
|
||||||
#define SDHC_MAX_BLK_LEN_MASK 0x3
|
|
||||||
#define SDHC_BASE_FREQ_SHIFT 8
|
|
||||||
#define SDHC_BASE_FREQ_MASK 0x3f
|
|
||||||
#define SDHC_TIMEOUT_FREQ_UNIT (1<<7) /* 0=KHz, 1=MHz */
|
|
||||||
#define SDHC_TIMEOUT_FREQ_SHIFT 0
|
|
||||||
#define SDHC_TIMEOUT_FREQ_MASK 0x1f
|
|
||||||
#define SDHC_MAX_CAPABILITIES 0x48
|
|
||||||
#define SDHC_HOST_VER 0xFC
|
|
||||||
#define SDHC_VVN_MASK 0x0f
|
|
||||||
#define SDHC_VVN_SHIFT 0x04
|
|
||||||
#define SDHC_SVN_MASK 0x0f
|
|
||||||
#define SDHC_SVN_SHIFT 0x00
|
|
||||||
#define SDHC_SLOT_INTR_STATUS 0xfc
|
|
||||||
#define SDHC_HOST_CTL_VERSION 0xfe
|
|
||||||
#define SDHC_SPEC_VERS_SHIFT 0
|
|
||||||
#define SDHC_SPEC_VERS_MASK 0xff
|
|
||||||
#define SDHC_VENDOR_VERS_SHIFT 8
|
|
||||||
#define SDHC_VENDOR_VERS_MASK 0xff
|
|
||||||
#define SDHC_DMA_CTL 0x40c /* eSDHC */
|
|
||||||
#define SDHC_DMA_SNOOP 0x40
|
|
||||||
|
|
||||||
/* SDHC_SPEC_VERS */
|
|
||||||
#define SDHC_SPEC_VERS_100 0x00
|
|
||||||
#define SDHC_SPEC_VERS_200 0x01
|
|
||||||
#define SDHC_SPEC_VERS_300 0x02
|
|
||||||
|
|
||||||
/* SDHC_CAPABILITIES decoding */
|
|
||||||
#define SDHC_BASE_FREQ_KHZ(cap) \
|
|
||||||
((((cap) >> SDHC_BASE_FREQ_SHIFT) & SDHC_BASE_FREQ_MASK) * 1000)
|
|
||||||
#define SDHC_TIMEOUT_FREQ(cap) \
|
|
||||||
(((cap) >> SDHC_TIMEOUT_FREQ_SHIFT) & SDHC_TIMEOUT_FREQ_MASK)
|
|
||||||
#define SDHC_TIMEOUT_FREQ_KHZ(cap) \
|
|
||||||
(((cap) & SDHC_TIMEOUT_FREQ_UNIT) ? \
|
|
||||||
SDHC_TIMEOUT_FREQ(cap) * 1000: \
|
|
||||||
SDHC_TIMEOUT_FREQ(cap))
|
|
||||||
|
|
||||||
/* SDHC_HOST_CTL_VERSION decoding */
|
|
||||||
#define SDHC_SPEC_VERSION(hcv) \
|
|
||||||
(((hcv) >> SDHC_SPEC_VERS_SHIFT) & SDHC_SPEC_VERS_MASK)
|
|
||||||
#define SDHC_VENDOR_VERSION(hcv) \
|
|
||||||
(((hcv) >> SDHC_VENDOR_VERS_SHIFT) & SDHC_VENDOR_VERS_MASK)
|
|
||||||
|
|
||||||
#define SDHC_PRESENT_STATE_BITS \
|
|
||||||
"\20\31CL\30D3L\27D2L\26D1L\25D0L\24WPS\23CD\22CSS\21CI" \
|
|
||||||
"\14BRE\13BWE\12RTA\11WTA\3DLA\2CID\1CIC"
|
|
||||||
#define SDHC_NINTR_STATUS_BITS \
|
|
||||||
"\20\20ERROR\11CARD\10REMOVAL\7INSERTION\6READ\5WRITE" \
|
|
||||||
"\4DMA\3GAP\2XFER\1CMD"
|
|
||||||
#define SDHC_EINTR_STATUS_BITS \
|
|
||||||
"\20\11ACMD12\10CL\7DEB\6DCRC\5DT\4CI\3CEB\2CCRC\1CT"
|
|
||||||
#define SDHC_CAPABILITIES_BITS \
|
|
||||||
"\20\33Vdd1.8V\32Vdd3.0V\31Vdd3.3V\30SUSPEND\27DMA\26HIGHSPEED"
|
|
||||||
|
|
||||||
#endif /* _SDHCREG_H_ */
|
|
||||||
|
|
@ -1,355 +0,0 @@
|
||||||
/* $NetBSD: sdmmcreg.h,v 1.8 2012/01/27 03:07:21 matt Exp $ */
|
|
||||||
/* $OpenBSD: sdmmcreg.h,v 1.4 2009/01/09 10:55:22 jsg Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2006 Uwe Stuehler <uwe@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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SDMMCREG_H_
|
|
||||||
#define _SDMMCREG_H_
|
|
||||||
|
|
||||||
/* MMC commands */ /* response type */
|
|
||||||
#define MMC_GO_IDLE_STATE 0 /* R0 */
|
|
||||||
#define MMC_SEND_OP_COND 1 /* R3 */
|
|
||||||
#define MMC_ALL_SEND_CID 2 /* R2 */
|
|
||||||
#define MMC_SET_RELATIVE_ADDR 3 /* R1 */
|
|
||||||
#define MMC_SWITCH 6 /* R1b */
|
|
||||||
#define MMC_SELECT_CARD 7 /* R1 */
|
|
||||||
#define MMC_SEND_EXT_CSD 8 /* R1 */
|
|
||||||
#define MMC_SEND_CSD 9 /* R2 */
|
|
||||||
#define MMC_SEND_CID 10 /* R2 */
|
|
||||||
#define MMC_STOP_TRANSMISSION 12 /* R1b */
|
|
||||||
#define MMC_SEND_STATUS 13 /* R1 */
|
|
||||||
#define MMC_INACTIVE_STATE 15 /* R0 */
|
|
||||||
#define MMC_SET_BLOCKLEN 16 /* R1 */
|
|
||||||
#define MMC_READ_BLOCK_SINGLE 17 /* R1 */
|
|
||||||
#define MMC_READ_BLOCK_MULTIPLE 18 /* R1 */
|
|
||||||
#define MMC_SET_BLOCK_COUNT 23 /* R1 */
|
|
||||||
#define MMC_WRITE_BLOCK_SINGLE 24 /* R1 */
|
|
||||||
#define MMC_WRITE_BLOCK_MULTIPLE 25 /* R1 */
|
|
||||||
#define MMC_PROGRAM_CSD 27 /* R1 */
|
|
||||||
#define MMC_SET_WRITE_PROT 28 /* R1b */
|
|
||||||
#define MMC_SET_CLR_WRITE_PROT 29 /* R1b */
|
|
||||||
#define MMC_SET_SEND_WRITE_PROT 30 /* R1 */
|
|
||||||
#define MMC_TAG_SECTOR_START 32 /* R1 */
|
|
||||||
#define MMC_TAG_SECTOR_END 33 /* R1 */
|
|
||||||
#define MMC_UNTAG_SECTOR 34 /* R1 */
|
|
||||||
#define MMC_TAG_ERASE_GROUP_START 35 /* R1 */
|
|
||||||
#define MMC_TAG_ERASE_GROUP_END 36 /* R1 */
|
|
||||||
#define MMC_UNTAG_ERASE_GROUP 37 /* R1 */
|
|
||||||
#define MMC_ERASE 38 /* R1b */
|
|
||||||
#define MMC_LOCK_UNLOCK 42 /* R1b */
|
|
||||||
#define MMC_APP_CMD 55 /* R1 */
|
|
||||||
#define MMC_READ_OCR 58 /* R3 */
|
|
||||||
|
|
||||||
/* SD commands */ /* response type */
|
|
||||||
#define SD_SEND_RELATIVE_ADDR 3 /* R6 */
|
|
||||||
#define SD_SEND_SWITCH_FUNC 6 /* R1 */
|
|
||||||
#define SD_SEND_IF_COND 8 /* R7 */
|
|
||||||
|
|
||||||
/* SD application commands */ /* response type */
|
|
||||||
#define SD_APP_SET_BUS_WIDTH 6 /* R1 */
|
|
||||||
#define SD_APP_OP_COND 41 /* R3 */
|
|
||||||
#define SD_APP_SEND_SCR 51 /* R1 */
|
|
||||||
|
|
||||||
/* OCR bits */
|
|
||||||
#define MMC_OCR_MEM_READY (1U<<31)/* memory power-up status bit */
|
|
||||||
#define MMC_OCR_HCS (1<<30)
|
|
||||||
#define MMC_OCR_3_5V_3_6V (1<<23)
|
|
||||||
#define MMC_OCR_3_4V_3_5V (1<<22)
|
|
||||||
#define MMC_OCR_3_3V_3_4V (1<<21)
|
|
||||||
#define MMC_OCR_3_2V_3_3V (1<<20)
|
|
||||||
#define MMC_OCR_3_1V_3_2V (1<<19)
|
|
||||||
#define MMC_OCR_3_0V_3_1V (1<<18)
|
|
||||||
#define MMC_OCR_2_9V_3_0V (1<<17)
|
|
||||||
#define MMC_OCR_2_8V_2_9V (1<<16)
|
|
||||||
#define MMC_OCR_2_7V_2_8V (1<<15)
|
|
||||||
#define MMC_OCR_2_6V_2_7V (1<<14)
|
|
||||||
#define MMC_OCR_2_5V_2_6V (1<<13)
|
|
||||||
#define MMC_OCR_2_4V_2_5V (1<<12)
|
|
||||||
#define MMC_OCR_2_3V_2_4V (1<<11)
|
|
||||||
#define MMC_OCR_2_2V_2_3V (1<<10)
|
|
||||||
#define MMC_OCR_2_1V_2_2V (1<<9)
|
|
||||||
#define MMC_OCR_2_0V_2_1V (1<<8)
|
|
||||||
#define MMC_OCR_1_9V_2_0V (1<<7)
|
|
||||||
#define MMC_OCR_1_8V_1_9V (1<<6)
|
|
||||||
#define MMC_OCR_1_7V_1_8V (1<<5)
|
|
||||||
#define MMC_OCR_1_6V_1_7V (1<<4)
|
|
||||||
|
|
||||||
/* R1 response type bits */
|
|
||||||
#define MMC_R1_READY_FOR_DATA (1<<8) /* ready for next transfer */
|
|
||||||
#define MMC_R1_APP_CMD (1<<5) /* app. commands supported */
|
|
||||||
|
|
||||||
/* 48-bit response decoding (32 bits w/o CRC) */
|
|
||||||
#define MMC_R1(resp) ((resp)[0])
|
|
||||||
#define MMC_R3(resp) ((resp)[0])
|
|
||||||
#define SD_R6(resp) ((resp)[0])
|
|
||||||
#define MMC_R7(resp) ((resp)[0])
|
|
||||||
#define MMC_SPI_R1(resp) ((resp)[0])
|
|
||||||
#define MMC_SPI_R7(resp) ((resp)[1])
|
|
||||||
|
|
||||||
/* RCA argument and response */
|
|
||||||
#define MMC_ARG_RCA(rca) ((rca) << 16)
|
|
||||||
#define SD_R6_RCA(resp) (SD_R6((resp)) >> 16)
|
|
||||||
|
|
||||||
/* bus width argument */
|
|
||||||
#define SD_ARG_BUS_WIDTH_1 0
|
|
||||||
#define SD_ARG_BUS_WIDTH_4 2
|
|
||||||
|
|
||||||
/* EXT_CSD fields */
|
|
||||||
#define EXT_CSD_BUS_WIDTH 183 /* WO */
|
|
||||||
#define EXT_CSD_HS_TIMING 185 /* R/W */
|
|
||||||
#define EXT_CSD_REV 192 /* RO */
|
|
||||||
#define EXT_CSD_STRUCTURE 194 /* RO */
|
|
||||||
#define EXT_CSD_CARD_TYPE 196 /* RO */
|
|
||||||
|
|
||||||
/* EXT_CSD field definitions */
|
|
||||||
#define EXT_CSD_CMD_SET_NORMAL (1U << 0)
|
|
||||||
#define EXT_CSD_CMD_SET_SECURE (1U << 1)
|
|
||||||
#define EXT_CSD_CMD_SET_CPSECURE (1U << 2)
|
|
||||||
|
|
||||||
/* EXT_CSD_BUS_WIDTH */
|
|
||||||
#define EXT_CSD_BUS_WIDTH_1 0 /* 1 bit mode */
|
|
||||||
#define EXT_CSD_BUS_WIDTH_4 1 /* 4 bit mode */
|
|
||||||
#define EXT_CSD_BUS_WIDTH_8 2 /* 8 bit mode */
|
|
||||||
|
|
||||||
/* EXT_CSD_STRUCTURE */
|
|
||||||
#define EXT_CSD_STRUCTURE_VER_1_0 0 /* CSD Version No.1.0 */
|
|
||||||
#define EXT_CSD_STRUCTURE_VER_1_1 1 /* CSD Version No.1.1 */
|
|
||||||
#define EXT_CSD_STRUCTURE_VER_1_2 2 /* Version 4.1-4.2-4.3 */
|
|
||||||
|
|
||||||
/* EXT_CSD_CARD_TYPE */
|
|
||||||
#define EXT_CSD_CARD_TYPE_26M (1 << 0)
|
|
||||||
#define EXT_CSD_CARD_TYPE_52M (1 << 1)
|
|
||||||
|
|
||||||
/* MMC_SWITCH access mode */
|
|
||||||
#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */
|
|
||||||
#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits in value */
|
|
||||||
#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits in value */
|
|
||||||
#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
|
|
||||||
|
|
||||||
/* SPI mode reports R1/R2(SEND_STATUS) status. */
|
|
||||||
#define R1_SPI_IDLE (1 << 0)
|
|
||||||
#define R1_SPI_ERASE_RESET (1 << 1)
|
|
||||||
#define R1_SPI_ILLEGAL_COMMAND (1 << 2)
|
|
||||||
#define R1_SPI_COM_CRC (1 << 3)
|
|
||||||
#define R1_SPI_ERASE_SEQ (1 << 4)
|
|
||||||
#define R1_SPI_ADDRESS (1 << 5)
|
|
||||||
#define R1_SPI_PARAMETER (1 << 6)
|
|
||||||
/* R1 bit 7 is always zero */
|
|
||||||
#define R2_SPI_CARD_LOCKED (1 << 8)
|
|
||||||
#define R2_SPI_WP_ERASE_SKIP (1 << 9) /* or lock/unlock fail */
|
|
||||||
#define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP
|
|
||||||
#define R2_SPI_ERROR (1 << 10)
|
|
||||||
#define R2_SPI_CC_ERROR (1 << 11)
|
|
||||||
#define R2_SPI_CARD_ECC_ERROR (1 << 12)
|
|
||||||
#define R2_SPI_WP_VIOLATION (1 << 13)
|
|
||||||
#define R2_SPI_ERASE_PARAM (1 << 14)
|
|
||||||
#define R2_SPI_OUT_OF_RANGE (1 << 15) /* or CSD overwrite */
|
|
||||||
#define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE
|
|
||||||
|
|
||||||
/* MMC R2 response (CSD) */
|
|
||||||
#define MMC_CSD_CSDVER(resp) MMC_RSP_BITS((resp), 126, 2)
|
|
||||||
#define MMC_CSD_CSDVER_1_0 0
|
|
||||||
#define MMC_CSD_CSDVER_1_1 1
|
|
||||||
#define MMC_CSD_CSDVER_1_2 2 /* MMC 4.1 - 4.2 - 4.3 */
|
|
||||||
#define MMC_CSD_CSDVER_EXT_CSD 3 /* Version is coded in CSD_STRUCTURE in EXT_CSD */
|
|
||||||
#define MMC_CSD_MMCVER(resp) MMC_RSP_BITS((resp), 122, 4)
|
|
||||||
#define MMC_CSD_MMCVER_1_0 0 /* MMC 1.0 - 1.2 */
|
|
||||||
#define MMC_CSD_MMCVER_1_4 1 /* MMC 1.4 */
|
|
||||||
#define MMC_CSD_MMCVER_2_0 2 /* MMC 2.0 - 2.2 */
|
|
||||||
#define MMC_CSD_MMCVER_3_1 3 /* MMC 3.1 - 3.3 */
|
|
||||||
#define MMC_CSD_MMCVER_4_0 4 /* MMC 4.1 - 4.2 - 4.3 */
|
|
||||||
#define MMC_CSD_TAAC(resp) MMC_RSP_BITS((resp), 112, 8)
|
|
||||||
#define MMC_CSD_TAAC_MANT(resp) MMC_RSP_BITS((resp), 115, 4)
|
|
||||||
#define MMC_CSD_TAAC_EXP(resp) MMC_RSP_BITS((resp), 112, 3)
|
|
||||||
#define MMC_CSD_NSAC(resp) MMC_RSP_BITS((resp), 104, 8)
|
|
||||||
#define MMC_CSD_TRAN_SPEED(resp) MMC_RSP_BITS((resp), 96, 8)
|
|
||||||
#define MMC_CSD_TRAN_SPEED_MANT(resp) MMC_RSP_BITS((resp), 99, 4)
|
|
||||||
#define MMC_CSD_TRAN_SPEED_EXP(resp) MMC_RSP_BITS((resp), 96, 3)
|
|
||||||
#define MMC_CSD_READ_BL_LEN(resp) MMC_RSP_BITS((resp), 80, 4)
|
|
||||||
#define MMC_CSD_C_SIZE(resp) MMC_RSP_BITS((resp), 62, 12)
|
|
||||||
#define MMC_CSD_CAPACITY(resp) ((MMC_CSD_C_SIZE((resp))+1) << \
|
|
||||||
(MMC_CSD_C_SIZE_MULT((resp))+2))
|
|
||||||
#define MMC_CSD_C_SIZE_MULT(resp) MMC_RSP_BITS((resp), 47, 3)
|
|
||||||
#define MMC_CSD_R2W_FACTOR(resp) MMC_RSP_BITS((resp), 26, 3)
|
|
||||||
#define MMC_CSD_WRITE_BL_LEN(resp) MMC_RSP_BITS((resp), 22, 4)
|
|
||||||
|
|
||||||
/* MMC v1 R2 response (CID) */
|
|
||||||
#define MMC_CID_MID_V1(resp) MMC_RSP_BITS((resp), 104, 24)
|
|
||||||
#define MMC_CID_PNM_V1_CPY(resp, pnm) \
|
|
||||||
do { \
|
|
||||||
(pnm)[0] = MMC_RSP_BITS((resp), 96, 8); \
|
|
||||||
(pnm)[1] = MMC_RSP_BITS((resp), 88, 8); \
|
|
||||||
(pnm)[2] = MMC_RSP_BITS((resp), 80, 8); \
|
|
||||||
(pnm)[3] = MMC_RSP_BITS((resp), 72, 8); \
|
|
||||||
(pnm)[4] = MMC_RSP_BITS((resp), 64, 8); \
|
|
||||||
(pnm)[5] = MMC_RSP_BITS((resp), 56, 8); \
|
|
||||||
(pnm)[6] = MMC_RSP_BITS((resp), 48, 8); \
|
|
||||||
(pnm)[7] = '\0'; \
|
|
||||||
} while (/*CONSTCOND*/0)
|
|
||||||
#define MMC_CID_REV_V1(resp) MMC_RSP_BITS((resp), 40, 8)
|
|
||||||
#define MMC_CID_PSN_V1(resp) MMC_RSP_BITS((resp), 16, 24)
|
|
||||||
#define MMC_CID_MDT_V1(resp) MMC_RSP_BITS((resp), 8, 8)
|
|
||||||
|
|
||||||
/* MMC v2 R2 response (CID) */
|
|
||||||
#define MMC_CID_MID_V2(resp) MMC_RSP_BITS((resp), 120, 8)
|
|
||||||
#define MMC_CID_OID_V2(resp) MMC_RSP_BITS((resp), 104, 16)
|
|
||||||
#define MMC_CID_PNM_V2_CPY(resp, pnm) \
|
|
||||||
do { \
|
|
||||||
(pnm)[0] = MMC_RSP_BITS((resp), 96, 8); \
|
|
||||||
(pnm)[1] = MMC_RSP_BITS((resp), 88, 8); \
|
|
||||||
(pnm)[2] = MMC_RSP_BITS((resp), 80, 8); \
|
|
||||||
(pnm)[3] = MMC_RSP_BITS((resp), 72, 8); \
|
|
||||||
(pnm)[4] = MMC_RSP_BITS((resp), 64, 8); \
|
|
||||||
(pnm)[5] = MMC_RSP_BITS((resp), 56, 8); \
|
|
||||||
(pnm)[6] = '\0'; \
|
|
||||||
} while (/*CONSTCOND*/0)
|
|
||||||
#define MMC_CID_PSN_V2(resp) MMC_RSP_BITS((resp), 16, 32)
|
|
||||||
|
|
||||||
/* SD R2 response (CSD) */
|
|
||||||
#define SD_CSD_CSDVER(resp) MMC_RSP_BITS((resp), 126, 2)
|
|
||||||
#define SD_CSD_CSDVER_1_0 0
|
|
||||||
#define SD_CSD_CSDVER_2_0 1
|
|
||||||
#define SD_CSD_MMCVER(resp) MMC_RSP_BITS((resp), 122, 4)
|
|
||||||
#define SD_CSD_TAAC(resp) MMC_RSP_BITS((resp), 112, 8)
|
|
||||||
#define SD_CSD_TAAC_EXP(resp) MMC_RSP_BITS((resp), 115, 4)
|
|
||||||
#define SD_CSD_TAAC_MANT(resp) MMC_RSP_BITS((resp), 112, 3)
|
|
||||||
#define SD_CSD_TAAC_1_5_MSEC 0x26
|
|
||||||
#define SD_CSD_NSAC(resp) MMC_RSP_BITS((resp), 104, 8)
|
|
||||||
#define SD_CSD_SPEED(resp) MMC_RSP_BITS((resp), 96, 8)
|
|
||||||
#define SD_CSD_SPEED_MANT(resp) MMC_RSP_BITS((resp), 99, 4)
|
|
||||||
#define SD_CSD_SPEED_EXP(resp) MMC_RSP_BITS((resp), 96, 3)
|
|
||||||
#define SD_CSD_SPEED_25_MHZ 0x32
|
|
||||||
#define SD_CSD_SPEED_50_MHZ 0x5a
|
|
||||||
#define SD_CSD_CCC(resp) MMC_RSP_BITS((resp), 84, 12)
|
|
||||||
#define SD_CSD_CCC_BASIC (1 << 0) /* basic */
|
|
||||||
#define SD_CSD_CCC_BR (1 << 2) /* block read */
|
|
||||||
#define SD_CSD_CCC_BW (1 << 4) /* block write */
|
|
||||||
#define SD_CSD_CCC_ERACE (1 << 5) /* erase */
|
|
||||||
#define SD_CSD_CCC_WP (1 << 6) /* write protection */
|
|
||||||
#define SD_CSD_CCC_LC (1 << 7) /* lock card */
|
|
||||||
#define SD_CSD_CCC_AS (1 << 8) /*application specific*/
|
|
||||||
#define SD_CSD_CCC_IOM (1 << 9) /* I/O mode */
|
|
||||||
#define SD_CSD_CCC_SWITCH (1 << 10) /* switch */
|
|
||||||
#define SD_CSD_READ_BL_LEN(resp) MMC_RSP_BITS((resp), 80, 4)
|
|
||||||
#define SD_CSD_READ_BL_PARTIAL(resp) MMC_RSP_BITS((resp), 79, 1)
|
|
||||||
#define SD_CSD_WRITE_BLK_MISALIGN(resp) MMC_RSP_BITS((resp), 78, 1)
|
|
||||||
#define SD_CSD_READ_BLK_MISALIGN(resp) MMC_RSP_BITS((resp), 77, 1)
|
|
||||||
#define SD_CSD_DSR_IMP(resp) MMC_RSP_BITS((resp), 76, 1)
|
|
||||||
#define SD_CSD_C_SIZE(resp) MMC_RSP_BITS((resp), 62, 12)
|
|
||||||
#define SD_CSD_CAPACITY(resp) ((SD_CSD_C_SIZE((resp))+1) << \
|
|
||||||
(SD_CSD_C_SIZE_MULT((resp))+2))
|
|
||||||
#define SD_CSD_VDD_R_CURR_MIN(resp) MMC_RSP_BITS((resp), 59, 3)
|
|
||||||
#define SD_CSD_VDD_R_CURR_MAX(resp) MMC_RSP_BITS((resp), 56, 3)
|
|
||||||
#define SD_CSD_VDD_W_CURR_MIN(resp) MMC_RSP_BITS((resp), 53, 3)
|
|
||||||
#define SD_CSD_VDD_W_CURR_MAX(resp) MMC_RSP_BITS((resp), 50, 3)
|
|
||||||
#define SD_CSD_VDD_RW_CURR_100mA 0x7
|
|
||||||
#define SD_CSD_VDD_RW_CURR_80mA 0x6
|
|
||||||
#define SD_CSD_V2_C_SIZE(resp) MMC_RSP_BITS((resp), 48, 22)
|
|
||||||
#define SD_CSD_V2_CAPACITY(resp) ((SD_CSD_V2_C_SIZE((resp))+1) << 10)
|
|
||||||
#define SD_CSD_V2_BL_LEN 0x9 /* 512 */
|
|
||||||
#define SD_CSD_C_SIZE_MULT(resp) MMC_RSP_BITS((resp), 47, 3)
|
|
||||||
#define SD_CSD_ERASE_BLK_EN(resp) MMC_RSP_BITS((resp), 46, 1)
|
|
||||||
#define SD_CSD_SECTOR_SIZE(resp) MMC_RSP_BITS((resp), 39, 7) /* +1 */
|
|
||||||
#define SD_CSD_WP_GRP_SIZE(resp) MMC_RSP_BITS((resp), 32, 7) /* +1 */
|
|
||||||
#define SD_CSD_WP_GRP_ENABLE(resp) MMC_RSP_BITS((resp), 31, 1)
|
|
||||||
#define SD_CSD_R2W_FACTOR(resp) MMC_RSP_BITS((resp), 26, 3)
|
|
||||||
#define SD_CSD_WRITE_BL_LEN(resp) MMC_RSP_BITS((resp), 22, 4)
|
|
||||||
#define SD_CSD_RW_BL_LEN_2G 0xa
|
|
||||||
#define SD_CSD_RW_BL_LEN_1G 0x9
|
|
||||||
#define SD_CSD_WRITE_BL_PARTIAL(resp) MMC_RSP_BITS((resp), 21, 1)
|
|
||||||
#define SD_CSD_FILE_FORMAT_GRP(resp) MMC_RSP_BITS((resp), 15, 1)
|
|
||||||
#define SD_CSD_COPY(resp) MMC_RSP_BITS((resp), 14, 1)
|
|
||||||
#define SD_CSD_PERM_WRITE_PROTECT(resp) MMC_RSP_BITS((resp), 13, 1)
|
|
||||||
#define SD_CSD_TMP_WRITE_PROTECT(resp) MMC_RSP_BITS((resp), 12, 1)
|
|
||||||
#define SD_CSD_FILE_FORMAT(resp) MMC_RSP_BITS((resp), 10, 2)
|
|
||||||
|
|
||||||
/* SD R2 response (CID) */
|
|
||||||
#define SD_CID_MID(resp) MMC_RSP_BITS((resp), 120, 8)
|
|
||||||
#define SD_CID_OID(resp) MMC_RSP_BITS((resp), 104, 16)
|
|
||||||
#define SD_CID_PNM_CPY(resp, pnm) \
|
|
||||||
do { \
|
|
||||||
(pnm)[0] = MMC_RSP_BITS((resp), 96, 8); \
|
|
||||||
(pnm)[1] = MMC_RSP_BITS((resp), 88, 8); \
|
|
||||||
(pnm)[2] = MMC_RSP_BITS((resp), 80, 8); \
|
|
||||||
(pnm)[3] = MMC_RSP_BITS((resp), 72, 8); \
|
|
||||||
(pnm)[4] = MMC_RSP_BITS((resp), 64, 8); \
|
|
||||||
(pnm)[5] = '\0'; \
|
|
||||||
} while (/*CONSTCOND*/0)
|
|
||||||
#define SD_CID_REV(resp) MMC_RSP_BITS((resp), 56, 8)
|
|
||||||
#define SD_CID_PSN(resp) MMC_RSP_BITS((resp), 24, 32)
|
|
||||||
#define SD_CID_MDT(resp) MMC_RSP_BITS((resp), 8, 12)
|
|
||||||
|
|
||||||
/* SCR (SD Configuration Register) */
|
|
||||||
#define SCR_STRUCTURE(scr) MMC_RSP_BITS((scr), 60, 4)
|
|
||||||
#define SCR_STRUCTURE_VER_1_0 0 /* Version 1.0 */
|
|
||||||
#define SCR_SD_SPEC(scr) MMC_RSP_BITS((scr), 56, 4)
|
|
||||||
#define SCR_SD_SPEC_VER_1_0 0 /* Version 1.0 and 1.01 */
|
|
||||||
#define SCR_SD_SPEC_VER_1_10 1 /* Version 1.10 */
|
|
||||||
#define SCR_SD_SPEC_VER_2 2 /* Version 2.00 or Version 3.0X */
|
|
||||||
#define SCR_DATA_STAT_AFTER_ERASE(scr) MMC_RSP_BITS((scr), 55, 1)
|
|
||||||
#define SCR_SD_SECURITY(scr) MMC_RSP_BITS((scr), 52, 3)
|
|
||||||
#define SCR_SD_SECURITY_NONE 0 /* no security */
|
|
||||||
#define SCR_SD_SECURITY_1_0 1 /* security protocol 1.0 */
|
|
||||||
#define SCR_SD_SECURITY_1_0_2 2 /* security protocol 1.0 */
|
|
||||||
#define SCR_SD_BUS_WIDTHS(scr) MMC_RSP_BITS((scr), 48, 4)
|
|
||||||
#define SCR_SD_BUS_WIDTHS_1BIT (1 << 0) /* 1bit (DAT0) */
|
|
||||||
#define SCR_SD_BUS_WIDTHS_4BIT (1 << 2) /* 4bit (DAT0-3) */
|
|
||||||
#define SCR_RESERVED(scr) MMC_RSP_BITS((scr), 32, 16)
|
|
||||||
#define SCR_RESERVED2(scr) MMC_RSP_BITS((scr), 0, 32)
|
|
||||||
|
|
||||||
/* Status of Switch Function */
|
|
||||||
#define SFUNC_STATUS_GROUP(status, group) \
|
|
||||||
be16toh(__bitfield((uint32_t *)(status), (7 - (group)) << 4, 16))
|
|
||||||
|
|
||||||
/* Might be slow, but it should work on big and little endian systems. */
|
|
||||||
|
|
||||||
|
|
||||||
/* The macro used to do a (start)-8 to work around a bug in hardware see sdhc.c
|
|
||||||
* of the openbsd mmc code driver.
|
|
||||||
*/
|
|
||||||
#define MMC_RSP_BITS(resp, start, len) __bitfield((resp), (start), (len))
|
|
||||||
static inline int
|
|
||||||
__bitfield(uint32_t *src, int start, int len)
|
|
||||||
{
|
|
||||||
uint8_t *sp;
|
|
||||||
uint32_t dst, mask;
|
|
||||||
int shift, bs, bc;
|
|
||||||
|
|
||||||
if (start < 0 || len < 0 || len > 32)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
dst = 0;
|
|
||||||
mask = len % 32 ? UINT_MAX >> (32 - (len % 32)) : UINT_MAX;
|
|
||||||
shift = 0;
|
|
||||||
|
|
||||||
while (len > 0) {
|
|
||||||
sp = (uint8_t *)src + start / 8;
|
|
||||||
bs = start % 8;
|
|
||||||
bc = 8 - bs;
|
|
||||||
if (bc > len)
|
|
||||||
bc = len;
|
|
||||||
dst |= (*sp >> bs) << shift;
|
|
||||||
shift += bc;
|
|
||||||
start += bc;
|
|
||||||
len -= bc;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst &= mask;
|
|
||||||
return (int)dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _SDMMCREG_H_ */
|
|
||||||
|
|
@ -1,116 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
|
||||||
|
|
||||||
FSCK=/bin/fsck_mfs
|
|
||||||
ACPI=/service/acpi
|
|
||||||
|
|
||||||
if [ X`sysenv arch` = Xi386 ]
|
|
||||||
then if [ -e $ACPI -a -n "`sysenv acpi`" ]
|
|
||||||
then
|
|
||||||
minix-service -c up $ACPI
|
|
||||||
fi
|
|
||||||
minix-service -c up /service/pci -dev /dev/pci
|
|
||||||
|
|
||||||
minix-service -c up /service/input -dev /dev/kbdmux
|
|
||||||
minix-service -c up /service/pckbd || :
|
|
||||||
|
|
||||||
# Start procfs so we can access /proc/pci
|
|
||||||
mount -t procfs none /proc >/dev/null
|
|
||||||
|
|
||||||
# Do we want to use the virtio block device?
|
|
||||||
# If not specified, default to yes if the device is found.
|
|
||||||
if sysenv virtio_blk >/dev/null
|
|
||||||
then virtio_blk="`sysenv virtio_blk`"
|
|
||||||
elif grep '^[^ ]* [^ ]* 1AF4:1001[^ ]* ' /proc/pci >/dev/null
|
|
||||||
then echo "virtio_blk not set, defaulting to using found virtio device."
|
|
||||||
virtio_blk=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
minix-service -cn up /service/floppy -dev /dev/fd0
|
|
||||||
if [ X`sysenv ahci` = Xyes ]
|
|
||||||
then
|
|
||||||
# this is here temporarily, for testing purposes
|
|
||||||
minix-service -c up /service/ahci -dev /dev/c0d0 -label ahci_0 -args instance=0
|
|
||||||
elif [ X"$virtio_blk" = Xyes ]
|
|
||||||
then
|
|
||||||
minix-service -c up /service/virtio_blk -dev /dev/c0d0 -label virtio_blk_0 -args instance=0
|
|
||||||
else
|
|
||||||
minix-service -c up /service/at_wini -dev /dev/c0d0 -label at_wini_0
|
|
||||||
minix-service -cr up /service/at_wini -dev /dev/c1d0 -label at_wini_1 -args instance=1 2>/dev/null || :
|
|
||||||
fi
|
|
||||||
umount /proc >/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ X`sysenv arch` = Xearm ]
|
|
||||||
then echo Starting the mmc driver
|
|
||||||
minix-service -c up /service/mmc -dev /dev/c0d0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Load ProcFS from the ramdisk to minimize the chance of a desync with the boot
|
|
||||||
# image services from which it obtains data structures directly. As we move to
|
|
||||||
# the MIB service, this will eventually become obsolete.
|
|
||||||
minix-service up /service/procfs || echo "WARNING: couldn't start procfs"
|
|
||||||
|
|
||||||
if sysenv rootdevname >/dev/null
|
|
||||||
then rootdevname=/dev/`sysenv rootdevname`
|
|
||||||
else
|
|
||||||
if ! sysenv cdproberoot >/dev/null && ! sysenv bootramdisk >/dev/null
|
|
||||||
then echo "rootdevname not set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "`sysenv bin_img`" = 1 ]
|
|
||||||
then
|
|
||||||
bin_img="-i "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if sysenv cdproberoot >/dev/null
|
|
||||||
then
|
|
||||||
echo
|
|
||||||
echo 'Looking for boot CD. This may take a minute.'
|
|
||||||
echo 'Please ignore any error messages.'
|
|
||||||
echo
|
|
||||||
rootdevname=$(cdprobe) || { echo 'No CD found'; exit 1; }
|
|
||||||
export rootdevname
|
|
||||||
elif [ "$rootdevname" = "/dev/ram" ]
|
|
||||||
then
|
|
||||||
ramimagename=/dev/`sysenv ramimagename`
|
|
||||||
echo "Loading ramdisk from $ramimagename"
|
|
||||||
loadramdisk "$ramimagename" || echo "WARNING: loadramdisk failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if sysenv bootramdisk >/dev/null
|
|
||||||
then
|
|
||||||
rootdevname=imgrd
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Root device name is $rootdevname"
|
|
||||||
|
|
||||||
if ! sysenv cdproberoot >/dev/null
|
|
||||||
then
|
|
||||||
if [ -e $FSCK ]
|
|
||||||
then $FSCK -p $rootdevname
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change root from temporary boot ramdisk to the configure root device
|
|
||||||
if ! sysenv bootramdisk >/dev/null; then
|
|
||||||
mount -n $bin_img"$rootdevname" /
|
|
||||||
|
|
||||||
# Reopen standard file descriptors, so that we can unmount the ramdisk.
|
|
||||||
# That is essentially a VFS shortcoming that should be fixed, though..
|
|
||||||
exec >/dev/log
|
|
||||||
exec 2>/dev/log
|
|
||||||
exec </dev/console
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Mount the ProcFS instance that was loaded from the ramdisk, on the root FS.
|
|
||||||
mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs"
|
|
||||||
|
|
||||||
# Start the NetBSD rc infrastructure
|
|
||||||
if ! sysenv bootramdisk >/dev/null; then
|
|
||||||
exec sh /etc/rc "$@"
|
|
||||||
fi
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
Development notes regarding VND. Original document by David van Moolenbroek.
|
|
||||||
|
|
||||||
|
|
||||||
DESIGN DECISIONS
|
|
||||||
|
|
||||||
As simple as the VND driver implementation looks, several important decisions
|
|
||||||
had to be made in the design process. These decisions are listed here.
|
|
||||||
|
|
||||||
Multiple instances instead of a single instance: The decision to spawn a
|
|
||||||
separate driver instance for each VND unit was not ideologically inspired, but
|
|
||||||
rather based on a practical issue. Namely, users may reasonably expect to be
|
|
||||||
able to set up a VND using a backing file that resides on a file system hosted
|
|
||||||
on another VND. If one single driver instance were to host both VND units, its
|
|
||||||
implementation would have to perform all its backcalls to VFS asynchronously,
|
|
||||||
so as to be able to process another incoming request that was initiated as part
|
|
||||||
of such an ongoing backcall. As of writing, MINIX3 does not support any form of
|
|
||||||
asynchronous I/O, but this would not even be sufficient: the asynchrony would
|
|
||||||
have to extend even to the close(2) call that takes place during device
|
|
||||||
unconfiguration, as this call could spark I/O to another VND device.
|
|
||||||
Ultimately, using one driver instance per VND unit avoids these complications
|
|
||||||
altogether, thus making nesting possible with a maximum depth of the number of
|
|
||||||
VFS threads. Of course, this comes at the cost of having more VND driver
|
|
||||||
processes; in order to avoid this cost in the common case, driver instances are
|
|
||||||
dynamically started and stopped by vndconfig(8).
|
|
||||||
|
|
||||||
copyfd(2) instead of openas(2): Compared to the NetBSD interface, the MINIX3
|
|
||||||
VND API requires that the user program configuring a device pass in a file
|
|
||||||
descriptor in the vnd_ioctl structure instead of a pointer to a path name.
|
|
||||||
While binary compatibility with NetBSD would be impossible anyway (MINIX3 can
|
|
||||||
not support pointers in IOCTL data structures), providing a path name buffer
|
|
||||||
would be closer to what NetBSD does. There are two reasons behind the choice to
|
|
||||||
pass in a file descriptor instead. First, performing an open(2)-like call as
|
|
||||||
a driver backcall is tricky in terms of avoiding deadlocks in VFS, since it
|
|
||||||
would by nature violate the VFS locking order. On top of that, special
|
|
||||||
provisions would have to be added to support opening a file in the context of
|
|
||||||
another process so that chrooted processes would be supported, for example.
|
|
||||||
In contrast, copying a file descriptor to a remote process is relatively easy
|
|
||||||
because there is only one potential deadlock case to cover - that of the given
|
|
||||||
file descriptor identifying the VFS filp object used to control the very same
|
|
||||||
device - and VFS need only implement a procedure that very much resembles
|
|
||||||
sending a file descriptor across a UNIX domain socket. Second, since passing a
|
|
||||||
file descriptor is effectively passing an object capability, it is easier to
|
|
||||||
improve the isolation of the VND drivers in the future, as described below.
|
|
||||||
|
|
||||||
No separate control device: The driver uses the same minor (block) device for
|
|
||||||
configuration and for actual (whole-disk) I/O, instead of exposing a separate
|
|
||||||
device that exists only for the purpose of configuring the device. The reason
|
|
||||||
for this is that such a control device simply does not fit the NetBSD
|
|
||||||
opendisk(3) API. While MINIX3 may at some point implement support for NetBSD's
|
|
||||||
notion of raw devices, such raw devices are still expected to support I/O, and
|
|
||||||
that means they cannot be control-only. In this regard, it should be mentioned
|
|
||||||
that the entire VND infrastructure relies on block caches being invalidated
|
|
||||||
properly upon (un)configuration of VND units, and that such invalidation
|
|
||||||
(through the REQ_FLUSH file system request) is currently initiated only by
|
|
||||||
closing block devices. Support for configuration or I/O through character
|
|
||||||
devices would thus require more work on that side first. In any case, the
|
|
||||||
primary downside of not having a separate control device is that handling
|
|
||||||
access permissions on device open is a bit of a hack in order to keep the
|
|
||||||
MINIX3 userland happy.
|
|
||||||
|
|
||||||
|
|
||||||
FUTURE IMPROVEMENTS
|
|
||||||
|
|
||||||
Currently, the VND driver instances are run as root just and only because the
|
|
||||||
copyfd(2) call requires root. Obviously, nonroot user processes should never
|
|
||||||
be able to copy file descriptors from arbitrary processes, and thus, some
|
|
||||||
security check is required there. However, an access control list for VFS calls
|
|
||||||
would be a much better solution: in that case, VND driver processes can be
|
|
||||||
given exclusive rights to the use of the copyfd(2) call, while they can be
|
|
||||||
given a normal driver UID at the same time.
|
|
||||||
|
|
||||||
In MINIX3's dependability model, drivers are generally not considered to be
|
|
||||||
malicious. However, the VND case is interesting because it is possible to
|
|
||||||
isolate individual driver instances to the point of actual "least authority".
|
|
||||||
The copyfd(2) call currently allows any file descriptor to be copied, but it
|
|
||||||
would be possible to extend the scheme to let user processes (and vndconfig(8)
|
|
||||||
in particular) mark the file descriptors that may be the target of a copyfd(2)
|
|
||||||
call. One of several schemes may be implemented in VFS for this purpose. For
|
|
||||||
example, each process could be allowed to mark one of its file descriptors as
|
|
||||||
"copyable" using a new VFS call, and VFS would then allow copyfd(2) only on a
|
|
||||||
"copyable" file descriptor from a process blocked on a call to the driver that
|
|
||||||
invoked copyfd(2). This approach precludes hiding a VND driver behind a RAID
|
|
||||||
or FBD (etc) driver, but more sophisticated approaches can solve that as well.
|
|
||||||
Regardless of the scheme, the end result would be a situation where the VND
|
|
||||||
drivers are strictly limited to operating on the resources given to them.
|
|
||||||
|
|
||||||
Note that copyfd(2) was originally called dupfrom(2), and then extended to copy
|
|
||||||
file descriptors *to* remote processes as well. The latter is not as security
|
|
||||||
sensitive, but may have to be restricted in a similar way. If this is not
|
|
||||||
possible, copyfd(2) can always be split into multiple calls.
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# Makefile for the framebuffer driver.
|
|
||||||
PROG= fb
|
|
||||||
|
|
||||||
.include "arch/${MACHINE_ARCH}/Makefile.inc"
|
|
||||||
|
|
||||||
SRCS+= fb_edid.c fb.c
|
|
||||||
|
|
||||||
# re-use EDID parsing/validation code from NetBSD.
|
|
||||||
.PATH: ${NETBSDSRCDIR}/sys/dev/videomode
|
|
||||||
SRCS+= edid.c pickmode.c videomode.c vesagtf.c
|
|
||||||
|
|
||||||
# Put this dir and the EDID headers (dev/videomode/*.h) in the search path.
|
|
||||||
CPPFLAGS+= -I${.CURDIR} -I${NETBSDSRCDIR}/sys
|
|
||||||
|
|
||||||
DPADD+= ${LIBCHARDRIVER} ${LIBSYS}
|
|
||||||
LDADD+= -lchardriver -lsys
|
|
||||||
|
|
||||||
.include <minix.service.mk>
|
|
||||||
|
|
@ -1,351 +0,0 @@
|
||||||
/* $NetBSD: multiboot.h,v 1.8 2009/02/22 18:05:42 ahoka Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Julio M. Merino Vidal.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef __MULTIBOOT_H__
|
|
||||||
#define __MULTIBOOT_H__
|
|
||||||
|
|
||||||
#if !defined(_KERNEL) && defined(_STANDALONE)
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Multiboot header structure.
|
|
||||||
*/
|
|
||||||
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
|
||||||
#define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001
|
|
||||||
#define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002
|
|
||||||
#define MULTIBOOT_HEADER_HAS_VBE 0x00000004
|
|
||||||
#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000
|
|
||||||
|
|
||||||
#if !defined(_LOCORE)
|
|
||||||
struct multiboot_header {
|
|
||||||
uint32_t mh_magic;
|
|
||||||
uint32_t mh_flags;
|
|
||||||
uint32_t mh_checksum;
|
|
||||||
|
|
||||||
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
|
|
||||||
paddr_t mh_header_addr;
|
|
||||||
paddr_t mh_load_addr;
|
|
||||||
paddr_t mh_load_end_addr;
|
|
||||||
paddr_t mh_bss_end_addr;
|
|
||||||
paddr_t mh_entry_addr;
|
|
||||||
|
|
||||||
/* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */
|
|
||||||
uint32_t mh_mode_type;
|
|
||||||
uint32_t mh_width;
|
|
||||||
uint32_t mh_height;
|
|
||||||
uint32_t mh_depth;
|
|
||||||
};
|
|
||||||
#endif /* !defined(_LOCORE) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Symbols defined in locore.S.
|
|
||||||
*/
|
|
||||||
#if !defined(_LOCORE) && defined(_KERNEL)
|
|
||||||
extern struct multiboot_header *Multiboot_Header;
|
|
||||||
#endif /* !defined(_LOCORE) && defined(_KERNEL) */
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Multiboot information structure.
|
|
||||||
*/
|
|
||||||
#define MULTIBOOT_INFO_MAGIC 0x2BADB002
|
|
||||||
#define MULTIBOOT_INFO_HAS_MEMORY 0x00000001
|
|
||||||
#define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002
|
|
||||||
#define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004
|
|
||||||
#define MULTIBOOT_INFO_HAS_MODS 0x00000008
|
|
||||||
#define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010
|
|
||||||
#define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020
|
|
||||||
#define MULTIBOOT_INFO_HAS_MMAP 0x00000040
|
|
||||||
#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080
|
|
||||||
#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100
|
|
||||||
#define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200
|
|
||||||
#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400
|
|
||||||
#define MULTIBOOT_INFO_HAS_VBE 0x00000800
|
|
||||||
|
|
||||||
#if !defined(_LOCORE)
|
|
||||||
struct multiboot_info {
|
|
||||||
uint32_t mi_flags;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */
|
|
||||||
uint32_t mi_mem_lower;
|
|
||||||
uint32_t mi_mem_upper;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */
|
|
||||||
uint8_t mi_boot_device_part3;
|
|
||||||
uint8_t mi_boot_device_part2;
|
|
||||||
uint8_t mi_boot_device_part1;
|
|
||||||
uint8_t mi_boot_device_drive;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */
|
|
||||||
char * mi_cmdline;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */
|
|
||||||
uint32_t mi_mods_count;
|
|
||||||
vaddr_t mi_mods_addr;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */
|
|
||||||
uint32_t mi_elfshdr_num;
|
|
||||||
uint32_t mi_elfshdr_size;
|
|
||||||
vaddr_t mi_elfshdr_addr;
|
|
||||||
uint32_t mi_elfshdr_shndx;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */
|
|
||||||
uint32_t mi_mmap_length;
|
|
||||||
vaddr_t mi_mmap_addr;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */
|
|
||||||
uint32_t mi_drives_length;
|
|
||||||
vaddr_t mi_drives_addr;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */
|
|
||||||
void * unused_mi_config_table;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */
|
|
||||||
char * mi_loader_name;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */
|
|
||||||
void * unused_mi_apm_table;
|
|
||||||
|
|
||||||
/* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */
|
|
||||||
void * unused_mi_vbe_control_info;
|
|
||||||
void * unused_mi_vbe_mode_info;
|
|
||||||
paddr_t unused_mi_vbe_interface_seg;
|
|
||||||
paddr_t unused_mi_vbe_interface_off;
|
|
||||||
uint32_t unused_mi_vbe_interface_len;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Drive information. This describes an entry in the drives table as
|
|
||||||
* pointed to by mi_drives_addr.
|
|
||||||
*/
|
|
||||||
struct multiboot_drive {
|
|
||||||
uint32_t md_length;
|
|
||||||
uint8_t md_number;
|
|
||||||
uint8_t md_mode;
|
|
||||||
uint16_t md_cylinders;
|
|
||||||
uint8_t md_heads;
|
|
||||||
uint8_t md_sectors;
|
|
||||||
|
|
||||||
/* The variable-sized 'ports' field comes here, so this structure
|
|
||||||
* can be longer. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Memory mapping. This describes an entry in the memory mappings table
|
|
||||||
* as pointed to by mi_mmap_addr.
|
|
||||||
*
|
|
||||||
* Be aware that mm_size specifies the size of all other fields *except*
|
|
||||||
* for mm_size. In order to jump between two different entries, you
|
|
||||||
* have to count mm_size + 4 bytes.
|
|
||||||
*/
|
|
||||||
struct multiboot_mmap {
|
|
||||||
uint32_t mm_size;
|
|
||||||
uint64_t mm_base_addr;
|
|
||||||
uint64_t mm_length;
|
|
||||||
uint32_t mm_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Modules. This describes an entry in the modules table as pointed
|
|
||||||
* to by mi_mods_addr.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct multiboot_module {
|
|
||||||
uint32_t mmo_start;
|
|
||||||
uint32_t mmo_end;
|
|
||||||
char * mmo_string;
|
|
||||||
uint32_t mmo_reserved;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* !defined(_LOCORE) */
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prototypes for public functions defined in multiboot.c.
|
|
||||||
*/
|
|
||||||
#if !defined(_LOCORE) && defined(_KERNEL)
|
|
||||||
void multiboot_pre_reloc(struct multiboot_info *);
|
|
||||||
void multiboot_post_reloc(void);
|
|
||||||
void multiboot_print_info(void);
|
|
||||||
bool multiboot_ksyms_addsyms_elf(void);
|
|
||||||
#endif /* !defined(_LOCORE) */
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
#else /* !defined(_KERNEL) && defined(_STANDALONE) */
|
|
||||||
/* LSC FIXME: OLD MINIX DEFINITION: should be removed and replace with
|
|
||||||
definition above... */
|
|
||||||
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
|
||||||
|
|
||||||
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
|
|
||||||
|
|
||||||
/* Must pass memory information to OS. */
|
|
||||||
#define MULTIBOOT_PAGE_ALIGN 0x00000001
|
|
||||||
|
|
||||||
#define MULTIBOOT_MEMORY_INFO 0x00000002
|
|
||||||
|
|
||||||
#define MULTIBOOT_VIDEO_MODE 0x00000004
|
|
||||||
|
|
||||||
#define MULTIBOOT_AOUT_KLUDGE 0x00010000
|
|
||||||
|
|
||||||
/* consts used for Multiboot pre-init */
|
|
||||||
|
|
||||||
#define MULTIBOOT_VIDEO_MODE_EGA 1
|
|
||||||
|
|
||||||
#define MULTIBOOT_VIDEO_BUFFER 0xB8000
|
|
||||||
|
|
||||||
/* Usable lower memory chunk has a upper bound */
|
|
||||||
#define MULTIBOOT_LOWER_MEM_MAX 0x7f800
|
|
||||||
|
|
||||||
#define MULTIBOOT_CONSOLE_LINES 25
|
|
||||||
#define MULTIBOOT_CONSOLE_COLS 80
|
|
||||||
|
|
||||||
#define MULTIBOOT_VIDEO_BUFFER_BYTES \
|
|
||||||
(MULTIBOOT_CONSOLE_LINES*MULTIBOOT_CONSOLE_COLS*2)
|
|
||||||
|
|
||||||
#define MULTIBOOT_STACK_SIZE 4096
|
|
||||||
#define MULTIBOOT_PARAM_BUF_SIZE 1024
|
|
||||||
|
|
||||||
#define MULTIBOOT_MAX_MODS 20
|
|
||||||
|
|
||||||
/* Flags to be set in the ’flags’ member of the multiboot info structure. */
|
|
||||||
|
|
||||||
#define MULTIBOOT_INFO_MEMORY 0x00000001
|
|
||||||
#define MULTIBOOT_INFO_MEM_MAP 0x00000040
|
|
||||||
|
|
||||||
/* Is there a boot device set? */
|
|
||||||
#define MULTIBOOT_INFO_BOOTDEV 0x00000002
|
|
||||||
|
|
||||||
/* Is the command-line defined? */
|
|
||||||
#define MULTIBOOT_INFO_CMDLINE 0x00000004
|
|
||||||
|
|
||||||
/* Are there modules to do something with? */
|
|
||||||
#define MULTIBOOT_INFO_MODS 0x00000008
|
|
||||||
|
|
||||||
#define MULTIBOOT_HIGH_MEM_BASE 0x100000
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
/* The symbol table for a.out. */
|
|
||||||
struct multiboot_aout_symbol_table
|
|
||||||
{
|
|
||||||
u32_t tabsize;
|
|
||||||
u32_t strsize;
|
|
||||||
u32_t addr;
|
|
||||||
u32_t reserved;
|
|
||||||
};
|
|
||||||
/* The section header table for ELF. */
|
|
||||||
struct multiboot_elf_section_header_table
|
|
||||||
{
|
|
||||||
u32_t num;
|
|
||||||
u32_t size;
|
|
||||||
u32_t addr;
|
|
||||||
u32_t shndx;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
|
||||||
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
|
||||||
|
|
||||||
struct multiboot_info
|
|
||||||
{
|
|
||||||
/* Multiboot info version number */
|
|
||||||
u32_t flags;
|
|
||||||
/* Available memory from BIOS */
|
|
||||||
u32_t mem_lower_unused; /* minix uses memmap instead */
|
|
||||||
u32_t mem_upper_unused;
|
|
||||||
/* "root" partition */
|
|
||||||
u32_t boot_device;
|
|
||||||
/* Kernel command line */
|
|
||||||
u32_t cmdline;
|
|
||||||
/* Boot-Module list */
|
|
||||||
u32_t mi_mods_count;
|
|
||||||
u32_t mods_addr;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
multiboot_aout_symbol_table_t aout_sym;
|
|
||||||
multiboot_elf_section_header_table_t elf_sec;
|
|
||||||
} u;
|
|
||||||
/* Memory Mapping buffer */
|
|
||||||
u32_t mmap_length;
|
|
||||||
u32_t mmap_addr;
|
|
||||||
/* Drive Info buffer */
|
|
||||||
u32_t drives_length;
|
|
||||||
u32_t drives_addr;
|
|
||||||
/* ROM configuration table */
|
|
||||||
u32_t config_table;
|
|
||||||
/* Boot Loader Name */
|
|
||||||
u32_t boot_loader_name;
|
|
||||||
/* APM table */
|
|
||||||
u32_t apm_table;
|
|
||||||
/* Video */
|
|
||||||
u32_t vbe_control_info;
|
|
||||||
u32_t vbe_mode_info;
|
|
||||||
u16_t vbe_mode;
|
|
||||||
u16_t vbe_interface_seg;
|
|
||||||
u16_t vbe_interface_off;
|
|
||||||
u16_t vbe_interface_len;
|
|
||||||
};
|
|
||||||
typedef struct multiboot_info multiboot_info_t;
|
|
||||||
|
|
||||||
struct multiboot_mod_list
|
|
||||||
{
|
|
||||||
/* Memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
|
||||||
u32_t mod_start;
|
|
||||||
u32_t mod_end;
|
|
||||||
/* Module command line */
|
|
||||||
u32_t cmdline;
|
|
||||||
/* Pad struct to 16 bytes (must be zero) */
|
|
||||||
u32_t pad;
|
|
||||||
};
|
|
||||||
typedef struct multiboot_mod_list multiboot_module_t;
|
|
||||||
|
|
||||||
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
|
||||||
#define MULTIBOOT_MEMORY_RESERVED 2
|
|
||||||
struct multiboot_mmap_entry
|
|
||||||
{
|
|
||||||
u32_t size;
|
|
||||||
u64_t mm_base_addr;
|
|
||||||
u64_t mm_length;
|
|
||||||
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
|
||||||
#define MULTIBOOT_MEMORY_RESERVED 2
|
|
||||||
u32_t type;
|
|
||||||
} __attribute__((packed));
|
|
||||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
|
||||||
#endif /* !defined(_KERNEL) && defined(_STANDALONE) */
|
|
||||||
#endif /* __MULTIBOOT_H__ */
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
/* The <lib.h> header is the master header used by the library.
|
|
||||||
* All the C files in the lib subdirectories include it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIB_H
|
|
||||||
#define _LIB_H
|
|
||||||
|
|
||||||
/* First come the defines. */
|
|
||||||
#include <sys/featuretest.h> /* tell headers to include NetBSD stuff. */
|
|
||||||
|
|
||||||
/* The following are so basic, all the lib files get them automatically. */
|
|
||||||
#include <minix/config.h> /* must be first */
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <minix/const.h>
|
|
||||||
#include <minix/com.h>
|
|
||||||
#include <minix/type.h>
|
|
||||||
#include <minix/callnr.h>
|
|
||||||
#include <minix/endpoint.h>
|
|
||||||
#include <minix/ipc.h>
|
|
||||||
|
|
||||||
struct minix_kerninfo *get_minix_kerninfo(void);
|
|
||||||
|
|
||||||
vir_bytes minix_get_user_sp(void);
|
|
||||||
|
|
||||||
struct ps_strings; /* forward declaration for minix_stack_fill. */
|
|
||||||
|
|
||||||
void minix_stack_params(const char *path, char * const *argv,
|
|
||||||
char * const *envp, size_t *stack_size, char *overflow, int *argc,
|
|
||||||
int *envc);
|
|
||||||
void minix_stack_fill(const char *path, int argc, char * const *argv,
|
|
||||||
int envc, char * const *envp, size_t stack_size, char *frame,
|
|
||||||
int *vsp, struct ps_strings **psp);
|
|
||||||
|
|
||||||
int __execve(const char *_path, char *const _argv[], char *const
|
|
||||||
_envp[], int _nargs, int _nenvps);
|
|
||||||
int _syscall(endpoint_t _who, int _syscallnr, message *_msgptr);
|
|
||||||
void _loadname(const char *_name, message *_msgptr);
|
|
||||||
int _len(const char *_s);
|
|
||||||
void _begsig(int _dummy);
|
|
||||||
|
|
||||||
#define _VECTORIO_READ 1
|
|
||||||
#define _VECTORIO_WRITE 2
|
|
||||||
ssize_t _vectorio_setup(const struct iovec * iov, int iovcnt, char ** ptr,
|
|
||||||
int op);
|
|
||||||
void _vectorio_cleanup(const struct iovec * iov, int iovcnt, char * buffer,
|
|
||||||
ssize_t r, int op);
|
|
||||||
|
|
||||||
#endif /* _LIB_H */
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#ifndef _MINIX_BPF_H
|
|
||||||
#define _MINIX_BPF_H
|
|
||||||
|
|
||||||
#include <net/bpf.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MINIX3-specific extensions to the NetBSD Berkeley Packet Filter header.
|
|
||||||
* These extensions are necessary because NetBSD BPF uses a few ioctl(2)
|
|
||||||
* structure formats that contain pointers--something that MINIX3 has to avoid,
|
|
||||||
* due to its memory granting mechanisms. Thus, those ioctl(2) calls have to
|
|
||||||
* be converted from NetBSD to MINIX3 format. We currently do that in libc.
|
|
||||||
* This header specifies the numbers and formats for the MINIX3 versions.
|
|
||||||
*
|
|
||||||
* See <minix/if.h> for details on how things work here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* BIOCSETF: set BPF filter program. */
|
|
||||||
/*
|
|
||||||
* This ioctl is an exception, as it is write-only, so we do not need the
|
|
||||||
* original structure. Also, the size of this structure is currently slightly
|
|
||||||
* over 4KB, which makes it too big for a regular ioctl call. Thus, we have to
|
|
||||||
* use a big ioctl call. Note that future changes of BPF_MAXINSNS will
|
|
||||||
* unfortunately (necessarily) change the ioctl call number.
|
|
||||||
*/
|
|
||||||
struct minix_bpf_program {
|
|
||||||
u_int mbf_len;
|
|
||||||
struct bpf_insn mbf_insns[BPF_MAXINSNS];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MINIX_BIOCSETF _IOW_BIG(2, struct minix_bpf_program)
|
|
||||||
|
|
||||||
/* BIOCGDLTLIST: retrieve list of possible data link types. */
|
|
||||||
#define MINIX_BPF_MAXDLT 256
|
|
||||||
|
|
||||||
struct minix_bpf_dltlist {
|
|
||||||
struct bpf_dltlist mbfl_dltlist; /* MUST be first */
|
|
||||||
u_int mbfl_list[MINIX_BPF_MAXDLT];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MINIX_BIOCGDLTLIST _IOWR('B', 119, struct minix_bpf_dltlist)
|
|
||||||
|
|
||||||
#endif /* !_MINIX_BPF_H */
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
#ifndef __MINIX_I2C_H
|
|
||||||
#define __MINIX_I2C_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Minix I2C /dev Interface.
|
|
||||||
*
|
|
||||||
* Same as NetBSD/OpenBSD interface but with a flat struct (i.e. no pointers).
|
|
||||||
* The NetBSD/OpenBSD interface can still be used on i2c device files. The
|
|
||||||
* ioctl(2) function will translate to/from the Minix version of the struct.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dev/i2c/i2c_io.h>
|
|
||||||
#include <minix/ioctl.h>
|
|
||||||
|
|
||||||
typedef struct minix_i2c_ioctl_exec {
|
|
||||||
i2c_op_t iie_op; /* operation to perform */
|
|
||||||
i2c_addr_t iie_addr; /* address of device */
|
|
||||||
uint8_t iie_cmd[I2C_EXEC_MAX_CMDLEN]; /* pointer to command */
|
|
||||||
size_t iie_cmdlen; /* length of command */
|
|
||||||
uint8_t iie_buf[I2C_EXEC_MAX_BUFLEN]; /* pointer to data buffer */
|
|
||||||
size_t iie_buflen; /* length of data buffer */
|
|
||||||
} minix_i2c_ioctl_exec_t;
|
|
||||||
|
|
||||||
#define MINIX_I2C_IOCTL_EXEC _IOWR('I', 1, minix_i2c_ioctl_exec_t)
|
|
||||||
|
|
||||||
#endif /* __MINIX_I2C_H */
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
#ifndef _MINIX_IF_H
|
|
||||||
#define _MINIX_IF_H
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_media.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MINIX3-specific extensions to the network interface headers. These
|
|
||||||
* extensions are necessary because NetBSD IF uses a few ioctl(2) structure
|
|
||||||
* formats that contain pointers--something that MINIX3 has to avoid, due to
|
|
||||||
* its memory granting mechanisms. Thus, those ioctl(2) calls have to be
|
|
||||||
* converted from NetBSD to MINIX3 format. We currently do that in libc.
|
|
||||||
* This header specifies the numbers and formats for the MINIX3 versions.
|
|
||||||
*
|
|
||||||
* The general idea is that we rewrite the ioctl request data to include both
|
|
||||||
* the original structure and a buffer for the array of values to which the
|
|
||||||
* original structure uses a pointer. Important: in those cases, the original
|
|
||||||
* structure is expected to be the first element of the replacement structure.
|
|
||||||
*
|
|
||||||
* There is typically no configured upper bound for the maximum number of
|
|
||||||
* values in the array, and so we pick size values that are hopefully always
|
|
||||||
* oversized and yet keep the ioctl sizes within the range of regular ioctls
|
|
||||||
* (4095 bytes, as per sys/ioccom.h). If there may be larger amounts of data,
|
|
||||||
* we have to use "big" ioctls.
|
|
||||||
*
|
|
||||||
* For the replacement ioctl codes, we use the original ioctl class and number
|
|
||||||
* with a different size. That should virtually eliminate the possibility of
|
|
||||||
* accidental collisions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* SIOCGIFMEDIA: retrieve interface media status and types. */
|
|
||||||
#define MINIX_IF_MAXMEDIA 256
|
|
||||||
|
|
||||||
struct minix_ifmediareq {
|
|
||||||
struct ifmediareq mifm_ifm; /* MUST be first */
|
|
||||||
int mifm_list[MINIX_IF_MAXMEDIA];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MINIX_SIOCGIFMEDIA _IOWR('i', 54, struct minix_ifmediareq)
|
|
||||||
|
|
||||||
/* SIOCIFGCLONERS: retrieve interface "cloners" (virtual types). */
|
|
||||||
#define MINIX_IF_MAXCLONERS 128
|
|
||||||
|
|
||||||
struct minix_if_clonereq {
|
|
||||||
struct if_clonereq mifcr_ifcr; /* MUST be first */
|
|
||||||
char mifcr_buffer[MINIX_IF_MAXCLONERS * IFNAMSIZ];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MINIX_SIOCIFGCLONERS _IOWR('i', 120, struct minix_if_clonereq)
|
|
||||||
|
|
||||||
#endif /* !_MINIX_IF_H */
|
|
||||||
|
|
@ -1,188 +0,0 @@
|
||||||
#ifndef _MINIX_RMIB_H
|
|
||||||
#define _MINIX_RMIB_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This header file is for use by services that use the remote MIB (RMIB)
|
|
||||||
* functionality of libsys. RMIB allows services to mount and handle certain
|
|
||||||
* subtrees of the MIB service's sysctl tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The maximum number of I/O vector elements that can be passed to the
|
|
||||||
* rmib_vcopyout function.
|
|
||||||
*/
|
|
||||||
#define RMIB_IOV_MAX SCPVEC_NR
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This structure contains a number of less heavily used parameters for handler
|
|
||||||
* functions, mainly to provide extensibility while limiting argument clutter.
|
|
||||||
*/
|
|
||||||
struct rmib_call {
|
|
||||||
endpoint_t call_endpt; /* endpoint of the user process */
|
|
||||||
const int *call_oname; /* original full name of the request */
|
|
||||||
const int *call_name; /* remaining part of the name */
|
|
||||||
unsigned int call_namelen; /* length of the remaining name part */
|
|
||||||
unsigned int call_flags; /* RMIB_FLAG_ call flags */
|
|
||||||
uint32_t call_rootver; /* version of all nodes in subtree */
|
|
||||||
uint32_t call_treever; /* version of the entire MIB tree */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call flags.
|
|
||||||
*
|
|
||||||
* TODO: this is effectively a flag used on the wire. This should be turned
|
|
||||||
* into a proper definition shared with the MIB service. As long as we have
|
|
||||||
* only one flag anyway, this is not exactly urgent though.
|
|
||||||
*/
|
|
||||||
#define RMIB_FLAG_AUTH 0x1 /* user has superuser privileges */
|
|
||||||
|
|
||||||
struct rmib_node;
|
|
||||||
struct rmib_oldp;
|
|
||||||
struct rmib_newp;
|
|
||||||
|
|
||||||
typedef ssize_t (*rmib_func_ptr)(struct rmib_call *, struct rmib_node *,
|
|
||||||
struct rmib_oldp *, struct rmib_newp *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Indirect node, used for sparse nodes. Sparse nodes are node-type nodes with
|
|
||||||
* the CTLFLAG_SPARSE flag set. A sparse node points not to an array of child
|
|
||||||
* nodes (using rnode_cptr), but to a array of {id,child pointer} elements
|
|
||||||
* (using rnode_icptr). At the cost of O(n) lookups, sparse nodes save memory.
|
|
||||||
* Currently for presentation reasons only, indirect lists must be sorted
|
|
||||||
* ascending by node identifiers. They may also not have ID duplicates, may not
|
|
||||||
* have NULL node pointers, and may not point to nodes with zero flags fields.
|
|
||||||
*/
|
|
||||||
#define CTLFLAG_SPARSE CTLFLAG_ROOT /* overloaded NetBSD flag */
|
|
||||||
|
|
||||||
struct rmib_indir {
|
|
||||||
unsigned int rindir_id; /* node identifier */
|
|
||||||
struct rmib_node *rindir_node; /* pointer to actual node */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The central structure for remote MIB nodes. This is essentially a somewhat
|
|
||||||
* cut-down version of the node structure used within the MIB service. See the
|
|
||||||
* source code of that service for several details that apply here as well.
|
|
||||||
* The 'rnode_' prefix makes it possible to include both this header file and
|
|
||||||
* the MIB service's internal header file at once--neat if useless.
|
|
||||||
*/
|
|
||||||
struct rmib_node {
|
|
||||||
uint32_t rnode_flags; /* CTLTYPE_ type and CTLFLAG_ flags */
|
|
||||||
size_t rnode_size; /* size of associated data */
|
|
||||||
union ixfer_rnode_val_u {
|
|
||||||
bool rvu_bool; /* immediate boolean */
|
|
||||||
int rvu_int; /* immediate integer */
|
|
||||||
u_quad_t rvu_quad; /* immediate quad */
|
|
||||||
uint32_t rvu_clen; /* number of actual children */
|
|
||||||
} rnode_val_u;
|
|
||||||
union pxfer_rnode_ptr_u {
|
|
||||||
void *rpu_data; /* struct or string data pointer */
|
|
||||||
struct rmib_node *rpu_cptr; /* child node array */
|
|
||||||
struct rmib_indir *rpu_icptr; /* indirect child node array */
|
|
||||||
} rnode_ptr_u;
|
|
||||||
rmib_func_ptr rnode_func; /* handler function */
|
|
||||||
const char *rnode_name; /* node name string */
|
|
||||||
const char *rnode_desc; /* node description (may be NULL) */
|
|
||||||
};
|
|
||||||
#define rnode_bool rnode_val_u.rvu_bool
|
|
||||||
#define rnode_int rnode_val_u.rvu_int
|
|
||||||
#define rnode_quad rnode_val_u.rvu_quad
|
|
||||||
#define rnode_clen rnode_val_u.rvu_clen
|
|
||||||
#define rnode_data rnode_ptr_u.rpu_data
|
|
||||||
#define rnode_cptr rnode_ptr_u.rpu_cptr
|
|
||||||
#define rnode_icptr rnode_ptr_u.rpu_icptr
|
|
||||||
|
|
||||||
/* Various macros to initialize nodes at compile time. */
|
|
||||||
#define RMIB_NODE(f,t,n,d) { \
|
|
||||||
.rnode_flags = CTLTYPE_NODE | CTLFLAG_READONLY | \
|
|
||||||
CTLFLAG_PERMANENT | f, \
|
|
||||||
.rnode_size = __arraycount(t), \
|
|
||||||
.rnode_cptr = t, \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
#define RMIB_SNODE(f,t,n,d) { \
|
|
||||||
.rnode_flags = CTLTYPE_NODE | CTLFLAG_READONLY | \
|
|
||||||
CTLFLAG_PERMANENT | CTLFLAG_SPARSE | f, \
|
|
||||||
.rnode_size = 0, \
|
|
||||||
.rnode_icptr = t, \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
#define RMIB_FUNC(f,s,fp,n,d) { \
|
|
||||||
.rnode_flags = CTLFLAG_PERMANENT | f, \
|
|
||||||
.rnode_size = s, \
|
|
||||||
.rnode_func = fp, \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
#define RMIB_BOOL(f,b,n,d) { \
|
|
||||||
.rnode_flags = CTLTYPE_BOOL | CTLFLAG_PERMANENT | \
|
|
||||||
CTLFLAG_IMMEDIATE | f, \
|
|
||||||
.rnode_size = sizeof(bool), \
|
|
||||||
.rnode_bool = b, \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
#define RMIB_INT(f,i,n,d) { \
|
|
||||||
.rnode_flags = CTLTYPE_INT | CTLFLAG_PERMANENT | \
|
|
||||||
CTLFLAG_IMMEDIATE | f, \
|
|
||||||
.rnode_size = sizeof(int), \
|
|
||||||
.rnode_int = i, \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
#define RMIB_QUAD(f,q,n,d) { \
|
|
||||||
.rnode_flags = CTLTYPE_QUAD | CTLFLAG_PERMANENT | \
|
|
||||||
CTLFLAG_IMMEDIATE | f, \
|
|
||||||
.rnode_size = sizeof(u_quad_t), \
|
|
||||||
.rnode_quad = q, \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
#define _RMIB_DATA(f,s,p,n,d) { \
|
|
||||||
.rnode_flags = CTLFLAG_PERMANENT | f, \
|
|
||||||
.rnode_size = s, \
|
|
||||||
.rnode_data = __UNCONST(p), \
|
|
||||||
.rnode_name = n, \
|
|
||||||
.rnode_desc = d \
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* The following macros really require a pointer to the proper data type; weird
|
|
||||||
* casts may not trigger compiler warnings but do allow for memory corruption.
|
|
||||||
* The first three need to be passed a pointer to a bool, int, and u_quad_t,
|
|
||||||
* respectively. RMIB_STRING needs a pointer to a character array, so that
|
|
||||||
* sizeof(array) yields the proper size. Since RMIB_STRUCT may be given a
|
|
||||||
* pointer to either a structure or an array, it must also be given a size.
|
|
||||||
*/
|
|
||||||
#define RMIB_BOOLPTR(f,p,n,d) _RMIB_DATA(CTLTYPE_BOOL | f, sizeof(*p), p, n, d)
|
|
||||||
#define RMIB_INTPTR(f,p,n,d) _RMIB_DATA(CTLTYPE_INT | f, sizeof(*p), p, n, d)
|
|
||||||
#define RMIB_QUADPTR(f,p,n,d) _RMIB_DATA(CTLTYPE_QUAD | f, sizeof(*p), p, n, d)
|
|
||||||
#define RMIB_STRING(f,p,n,d) \
|
|
||||||
_RMIB_DATA(CTLTYPE_STRING | f, sizeof(p), p, n, d)
|
|
||||||
#define RMIB_STRUCT(f,s,p,n,d) _RMIB_DATA(CTLTYPE_STRUCT | f, s, p, n, d)
|
|
||||||
|
|
||||||
/* Shortcut flag macros. */
|
|
||||||
#define RMIB_RO CTLFLAG_READONLY /* shortcut for read-only nodes */
|
|
||||||
#define RMIB_RW CTLFLAG_READWRITE /* shortcut for read-write nodes */
|
|
||||||
|
|
||||||
/* Function prototypes. */
|
|
||||||
int rmib_register(const int * name, unsigned int namelen, struct rmib_node *);
|
|
||||||
int rmib_deregister(struct rmib_node *);
|
|
||||||
void rmib_reregister(void);
|
|
||||||
void rmib_reset(void);
|
|
||||||
void rmib_process(const message *, int);
|
|
||||||
|
|
||||||
int rmib_inrange(struct rmib_oldp *, size_t);
|
|
||||||
size_t rmib_getoldlen(struct rmib_oldp *);
|
|
||||||
ssize_t rmib_copyout(struct rmib_oldp *, size_t, const void * __restrict,
|
|
||||||
size_t);
|
|
||||||
ssize_t rmib_vcopyout(struct rmib_oldp *, size_t, const iovec_t *,
|
|
||||||
unsigned int);
|
|
||||||
int rmib_copyin(struct rmib_newp * __restrict, void * __restrict, size_t);
|
|
||||||
ssize_t rmib_readwrite(struct rmib_call *, struct rmib_node *,
|
|
||||||
struct rmib_oldp *, struct rmib_newp *);
|
|
||||||
|
|
||||||
#endif /* !_MINIX_RMIB_H */
|
|
||||||
|
|
@ -1,210 +0,0 @@
|
||||||
#ifndef RS_H
|
|
||||||
#define RS_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
minix/rs.h
|
|
||||||
|
|
||||||
Interface to the reincarnation server
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <minix/bitmap.h>
|
|
||||||
#include <minix/com.h>
|
|
||||||
#include <minix/ipc_filter.h>
|
|
||||||
|
|
||||||
#define SERVICE_LOGIN "service" /* passwd file entry for services */
|
|
||||||
|
|
||||||
/* The following definition should be kept in sync with the actual
|
|
||||||
* /etc/master.passwd value for SERVICE_LOGIN for now, and removed altogether
|
|
||||||
* once we are able to obtain its value dynamically everywhere. The value has
|
|
||||||
* been chosen so as to avoid creating conflicts with future NetBSD additions
|
|
||||||
* to the password files, although one can never be sure.
|
|
||||||
*/
|
|
||||||
#define SERVICE_UID 999 /* user ID for services */
|
|
||||||
|
|
||||||
/* RSS definitions. */
|
|
||||||
#define RSS_NR_IRQ 16
|
|
||||||
#define RSS_NR_IO 16
|
|
||||||
#define RSS_IRQ_ALL (RSS_NR_IRQ+1)
|
|
||||||
#define RSS_IO_ALL (RSS_NR_IO+1)
|
|
||||||
#define RSS_IPC_ALL "IPC_ALL"
|
|
||||||
#define RSS_IPC_ALL_SYS "IPC_ALL_SYS"
|
|
||||||
|
|
||||||
/* RSS flags. */
|
|
||||||
#define RSS_COPY 0x01 /* keep an in-memory copy of the binary */
|
|
||||||
#define RSS_REUSE 0x04 /* Try to reuse previously copied binary */
|
|
||||||
#define RSS_NOBLOCK 0x08 /* unblock caller immediately */
|
|
||||||
#define RSS_REPLICA 0x10 /* keep a replica of the service */
|
|
||||||
#define RSS_BATCH 0x20 /* batch mode */
|
|
||||||
#define RSS_SELF_LU 0x40 /* perform self update */
|
|
||||||
#define RSS_ASR_LU 0x80 /* perform ASR update */
|
|
||||||
#define RSS_FORCE_SELF_LU 0x0100 /* force self update */
|
|
||||||
#define RSS_PREPARE_ONLY_LU 0x0200 /* request prepare-only update */
|
|
||||||
#define RSS_FORCE_INIT_CRASH 0x0400 /* force crash at initialization time (for debugging) */
|
|
||||||
#define RSS_FORCE_INIT_FAIL 0x0800 /* force failure at initialization time (for debugging) */
|
|
||||||
#define RSS_FORCE_INIT_TIMEOUT 0x1000 /* force timeout at initialization time (for debugging) */
|
|
||||||
#define RSS_FORCE_INIT_DEFCB 0x2000 /* force default cb at initialization time (for debugging) */
|
|
||||||
#define RSS_SYS_BASIC_CALLS 0x4000 /* include basic kernel calls */
|
|
||||||
#define RSS_VM_BASIC_CALLS 0x8000 /* include basic vm calls */
|
|
||||||
#define RSS_NOMMAP_LU 0x10000 /* don't inherit mmapped regions */
|
|
||||||
#define RSS_DETACH 0x20000 /* detach on update/restart */
|
|
||||||
#define RSS_NORESTART 0x40000 /* don't restart */
|
|
||||||
#define RSS_FORCE_INIT_ST 0x80000 /* force state transfer at initialization time */
|
|
||||||
#define RSS_NO_BIN_EXP 0x100000 /* suppress binary exponential offset */
|
|
||||||
|
|
||||||
/* Common definitions. */
|
|
||||||
#define RS_NR_CONTROL 8
|
|
||||||
#define RS_NR_PCI_DEVICE 32
|
|
||||||
#define RS_NR_PCI_CLASS 4
|
|
||||||
#define RS_MAX_LABEL_LEN 16
|
|
||||||
#define RS_MAX_IPCF_STR_LEN (RS_MAX_LABEL_LEN+12)
|
|
||||||
#define RS_MAX_IPC_FILTERS 4
|
|
||||||
|
|
||||||
/* CPU special values */
|
|
||||||
#define RS_CPU_DEFAULT -1 /* use the default cpu or do not change the current one */
|
|
||||||
#define RS_CPU_BSP -2 /* use the bootstrap cpu */
|
|
||||||
|
|
||||||
/* Labels are copied over separately. */
|
|
||||||
struct rss_label
|
|
||||||
{
|
|
||||||
char *l_addr;
|
|
||||||
size_t l_len;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rs_pci_id {
|
|
||||||
u16_t vid;
|
|
||||||
u16_t did;
|
|
||||||
u16_t sub_vid;
|
|
||||||
u16_t sub_did;
|
|
||||||
};
|
|
||||||
#define NO_SUB_VID 0xffff
|
|
||||||
#define NO_SUB_DID 0xffff
|
|
||||||
|
|
||||||
struct rs_pci_class {
|
|
||||||
u32_t pciclass;
|
|
||||||
u32_t mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* State-related data. */
|
|
||||||
struct rs_ipc_filter_el {
|
|
||||||
int flags;
|
|
||||||
char m_label[RS_MAX_LABEL_LEN];
|
|
||||||
int m_type;
|
|
||||||
};
|
|
||||||
struct rs_state_data {
|
|
||||||
size_t size;
|
|
||||||
void *ipcf_els;
|
|
||||||
size_t ipcf_els_size;
|
|
||||||
int ipcf_els_gid;
|
|
||||||
void *eval_addr;
|
|
||||||
size_t eval_len;
|
|
||||||
int eval_gid;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Arguments needed to start a new driver or server */
|
|
||||||
struct rs_start
|
|
||||||
{
|
|
||||||
unsigned rss_flags;
|
|
||||||
char *rss_cmd;
|
|
||||||
size_t rss_cmdlen;
|
|
||||||
uid_t rss_uid;
|
|
||||||
endpoint_t rss_sigmgr;
|
|
||||||
endpoint_t rss_scheduler;
|
|
||||||
int rss_priority;
|
|
||||||
int rss_quantum;
|
|
||||||
int rss_major;
|
|
||||||
long rss_period;
|
|
||||||
char *rss_script;
|
|
||||||
size_t rss_scriptlen;
|
|
||||||
long rss_asr_count;
|
|
||||||
long rss_restarts;
|
|
||||||
long rss_heap_prealloc_bytes;
|
|
||||||
long rss_map_prealloc_bytes;
|
|
||||||
int rss_nr_irq;
|
|
||||||
int rss_irq[RSS_NR_IRQ];
|
|
||||||
int rss_nr_io;
|
|
||||||
struct { unsigned base; unsigned len; } rss_io[RSS_NR_IO];
|
|
||||||
int rss_nr_pci_id;
|
|
||||||
struct rs_pci_id rss_pci_id[RS_NR_PCI_DEVICE];
|
|
||||||
int rss_nr_pci_class;
|
|
||||||
struct rs_pci_class rss_pci_class[RS_NR_PCI_CLASS];
|
|
||||||
bitchunk_t rss_system[SYS_CALL_MASK_SIZE];
|
|
||||||
struct rss_label rss_label;
|
|
||||||
struct rss_label rss_trg_label;
|
|
||||||
char *rss_ipc;
|
|
||||||
size_t rss_ipclen;
|
|
||||||
bitchunk_t rss_vm[VM_CALL_MASK_SIZE];
|
|
||||||
int rss_nr_control;
|
|
||||||
struct rss_label rss_control[RS_NR_CONTROL];
|
|
||||||
struct rs_state_data rss_state_data;
|
|
||||||
int devman_id;
|
|
||||||
char *rss_progname;
|
|
||||||
size_t rss_prognamelen;
|
|
||||||
int rss_nr_domain;
|
|
||||||
int rss_domain[NR_DOMAIN];
|
|
||||||
/*
|
|
||||||
* SMP specific data
|
|
||||||
*
|
|
||||||
* must be at the end of the structure for binary compatibility with
|
|
||||||
* non-smp sysytems
|
|
||||||
*/
|
|
||||||
int rss_cpu;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ACL information for access to PCI devices */
|
|
||||||
struct rs_pci
|
|
||||||
{
|
|
||||||
char rsp_label[RS_MAX_LABEL_LEN];
|
|
||||||
int rsp_endpoint;
|
|
||||||
int rsp_nr_device;
|
|
||||||
struct rs_pci_id rsp_device[RS_NR_PCI_DEVICE];
|
|
||||||
int rsp_nr_class;
|
|
||||||
struct rs_pci_class rsp_class[RS_NR_PCI_CLASS];
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Definition of a public entry of the system process table. */
|
|
||||||
struct rprocpub {
|
|
||||||
short in_use; /* set when the entry is in use */
|
|
||||||
unsigned sys_flags; /* sys flags */
|
|
||||||
endpoint_t endpoint; /* process endpoint number */
|
|
||||||
endpoint_t old_endpoint; /* old instance endpoint number (for VM, when updating) */
|
|
||||||
endpoint_t new_endpoint; /* new instance endpoint number (for VM, when updating) */
|
|
||||||
|
|
||||||
devmajor_t dev_nr; /* major device number or NO_DEV */
|
|
||||||
int nr_domain; /* number of socket driver domains */
|
|
||||||
int domain[NR_DOMAIN]; /* set of socket driver domains */
|
|
||||||
|
|
||||||
char label[RS_MAX_LABEL_LEN]; /* label of this service */
|
|
||||||
char proc_name[RS_MAX_LABEL_LEN]; /* process name of this service */
|
|
||||||
|
|
||||||
bitchunk_t vm_call_mask[VM_CALL_MASK_SIZE]; /* vm call mask */
|
|
||||||
|
|
||||||
struct rs_pci pci_acl; /* pci acl */
|
|
||||||
int devman_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Return whether the given boot process is a user process, as opposed to a
|
|
||||||
* system process. Only usable by core services during SEF initialization.
|
|
||||||
*/
|
|
||||||
#define IS_RPUB_BOOT_USR(rpub) ((rpub)->endpoint == INIT_PROC_NR)
|
|
||||||
|
|
||||||
/* Sys flag values. */
|
|
||||||
#define SF_CORE_SRV 0x001 /* set for core system services */
|
|
||||||
#define SF_SYNCH_BOOT 0X002 /* set when process needs synch boot init */
|
|
||||||
#define SF_NEED_COPY 0x004 /* set when process needs copy to start */
|
|
||||||
#define SF_USE_COPY 0x008 /* set when process has a copy in memory */
|
|
||||||
#define SF_NEED_REPL 0x010 /* set when process needs replica to start */
|
|
||||||
#define SF_USE_REPL 0x020 /* set when process has a replica */
|
|
||||||
#define SF_VM_UPDATE 0x040 /* set when process needs vm update */
|
|
||||||
#define SF_VM_ROLLBACK 0x080 /* set when vm update is a rollback */
|
|
||||||
#define SF_VM_NOMMAP 0x100 /* set when vm update ignores mmapped regions */
|
|
||||||
#define SF_USE_SCRIPT 0x200 /* set when process has restart script */
|
|
||||||
#define SF_DET_RESTART 0x400 /* set when process detaches on restart */
|
|
||||||
#define SF_NORESTART 0x800 /* set when process should not be restarted */
|
|
||||||
#define SF_NO_BIN_EXP 0x1000 /* set when we should ignore binary exp. offset */
|
|
||||||
|
|
||||||
#define IMM_SF \
|
|
||||||
(SF_NO_BIN_EXP | SF_CORE_SRV | SF_SYNCH_BOOT | SF_NEED_COPY | SF_NEED_REPL) /* immutable */
|
|
||||||
|
|
||||||
int minix_rs_lookup(const char *name, endpoint_t *value);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
#ifndef _MINIX_SYSCTL_H
|
|
||||||
#define _MINIX_SYSCTL_H
|
|
||||||
|
|
||||||
/* MINIX3-specific sysctl(2) extensions. */
|
|
||||||
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <minix/endpoint.h>
|
|
||||||
|
|
||||||
/* Special values. */
|
|
||||||
#define SYSCTL_NODE_FN ((sysctlfn)0x1) /* node is function-driven */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The top-level MINIX3 identifier is quite a bit beyond the last top-level
|
|
||||||
* identifier in use by NetBSD, because NetBSD may add more later, and we do
|
|
||||||
* not want conflicts: this definition is part of the MINIX3 ABI.
|
|
||||||
*/
|
|
||||||
#define CTL_MINIX 32
|
|
||||||
|
|
||||||
#if CTL_MAXID > CTL_MINIX
|
|
||||||
#error "CTL_MAXID has grown too large!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The identifiers below follow the standard sysctl naming scheme, which means
|
|
||||||
* care should be taken not to introduce clashes with other definitions
|
|
||||||
* elsewhere. On the upside, not many places need to include this header file.
|
|
||||||
*/
|
|
||||||
#define MINIX_TEST 0
|
|
||||||
#define MINIX_MIB 1
|
|
||||||
#define MINIX_PROC 2
|
|
||||||
#define MINIX_LWIP 3
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These identifiers, under MINIX_TEST, are used by test87 to test the MIB
|
|
||||||
* service.
|
|
||||||
*/
|
|
||||||
#define TEST_INT 0
|
|
||||||
#define TEST_BOOL 1
|
|
||||||
#define TEST_QUAD 2
|
|
||||||
#define TEST_STRING 3
|
|
||||||
#define TEST_STRUCT 4
|
|
||||||
#define TEST_PRIVATE 5
|
|
||||||
#define TEST_ANYWRITE 6
|
|
||||||
#define TEST_DYNAMIC 7
|
|
||||||
#define TEST_SECRET 8
|
|
||||||
#define TEST_PERM 9
|
|
||||||
#define TEST_DESTROY1 10
|
|
||||||
#define TEST_DESTROY2 11
|
|
||||||
|
|
||||||
#define SECRET_VALUE 0
|
|
||||||
|
|
||||||
/* Identifiers for subnodes of MINIX_MIB. */
|
|
||||||
#define MIB_NODES 1
|
|
||||||
#define MIB_OBJECTS 2
|
|
||||||
#define MIB_REMOTES 3
|
|
||||||
|
|
||||||
/* Identifiers for subnodes of MINIX_PROC. */
|
|
||||||
#define PROC_LIST 1
|
|
||||||
#define PROC_DATA 2
|
|
||||||
|
|
||||||
/* Structure used for PROC_LIST. Not part of the ABI. Used by ProcFS only. */
|
|
||||||
struct minix_proc_list {
|
|
||||||
uint32_t mpl_flags; /* process flags (MPLF_) */
|
|
||||||
pid_t mpl_pid; /* process PID */
|
|
||||||
uid_t mpl_uid; /* effective user ID */
|
|
||||||
gid_t mpl_gid; /* effective group ID */
|
|
||||||
};
|
|
||||||
#define MPLF_IN_USE 0x01 /* process slot is in use */
|
|
||||||
#define MPLF_ZOMBIE 0x02 /* process is a zombie */
|
|
||||||
|
|
||||||
/* Structure used for PROC_DATA. Not part of the ABI. Used by ProcFS only. */
|
|
||||||
struct minix_proc_data {
|
|
||||||
endpoint_t mpd_endpoint; /* process endpoint */
|
|
||||||
uint32_t mpd_flags; /* procses flags (MPDF_) */
|
|
||||||
endpoint_t mpd_blocked_on; /* blocked on other process, or NONE */
|
|
||||||
uint32_t mpd_priority; /* current process priority */
|
|
||||||
uint32_t mpd_user_time; /* user time, in clock ticks */
|
|
||||||
uint32_t mpd_sys_time; /* system time, in clock ticks */
|
|
||||||
uint64_t mpd_cycles; /* cycles spent by the process */
|
|
||||||
uint64_t mpd_kipc_cycles; /* cycles spent on kernel IPC */
|
|
||||||
uint64_t mpd_kcall_cycles; /* cycles spent on kernel calls */
|
|
||||||
uint32_t mpd_nice; /* nice value */
|
|
||||||
char mpd_name[16]; /* short process name */
|
|
||||||
};
|
|
||||||
#define MPDF_SYSTEM 0x01 /* process is a system service */
|
|
||||||
#define MPDF_ZOMBIE 0x02 /* process is a zombie */
|
|
||||||
#define MPDF_RUNNABLE 0x04 /* process is runnable */
|
|
||||||
#define MPDF_STOPPED 0x08 /* process is stopped */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Expose sysctl(2) to system services (ProcFS in particular), so as to avoid
|
|
||||||
* including the CTL_USER subtree handling of sysctl(3) as well.
|
|
||||||
*/
|
|
||||||
int __sysctl(const int *, unsigned int, void *, size_t *, const void *,
|
|
||||||
size_t);
|
|
||||||
|
|
||||||
#endif /* !_MINIX_SYSCTL_H */
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
#ifndef MINIX_USB_CH9_H
|
|
||||||
#define MINIX_USB_CH9_H
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Lennart Augustsson (lennart@augustsson.net) at
|
|
||||||
* Carlstedt Research & Technology.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the NetBSD
|
|
||||||
* Foundation, Inc. and its contributors.
|
|
||||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/* USB DESCRIPTORS */
|
|
||||||
/*
|
|
||||||
* The USB records contain some unaligned little-endian word
|
|
||||||
* components. The U[SG]ETW macros take care of both the alignment
|
|
||||||
* and endian problem and should always be used to access non-byte
|
|
||||||
* values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
typedef u8_t uByte;
|
|
||||||
typedef u8_t uWord[2];
|
|
||||||
typedef u8_t uDWord[4];
|
|
||||||
|
|
||||||
#define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
#define UGETW(w) ((w)[0] | ((w)[1] << 8))
|
|
||||||
#define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
|
|
||||||
#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
|
|
||||||
#define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
|
|
||||||
(w)[1] = (u_int8_t)((v) >> 8), \
|
|
||||||
(w)[2] = (u_int8_t)((v) >> 16), \
|
|
||||||
(w)[3] = (u_int8_t)((v) >> 24))
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* On little-endian machines that can handle unanliged accesses
|
|
||||||
* (e.g. i386) these macros can be replaced by the following.
|
|
||||||
*/
|
|
||||||
#define UGETW(w) (*(u_int16_t *)(w))
|
|
||||||
#define USETW(w,v) (*(u_int16_t *)(w) = (v))
|
|
||||||
#define UGETDW(w) (*(u_int32_t *)(w))
|
|
||||||
#define USETDW(w,v) (*(u_int32_t *)(w) = (v))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define UPACKED __attribute__((__packed__))
|
|
||||||
|
|
||||||
/* Requests */
|
|
||||||
#define UR_GET_STATUS 0x00
|
|
||||||
#define UR_CLEAR_FEATURE 0x01
|
|
||||||
#define UR_SET_FEATURE 0x03
|
|
||||||
#define UR_SET_ADDRESS 0x05
|
|
||||||
#define UR_GET_DESCRIPTOR 0x06
|
|
||||||
#define UDESC_DEVICE 0x01
|
|
||||||
#define UDESC_CONFIG 0x02
|
|
||||||
#define UDESC_STRING 0x03
|
|
||||||
#define USB_LANGUAGE_TABLE 0x00 /* language ID string index */
|
|
||||||
#define UDESC_INTERFACE 0x04
|
|
||||||
#define UDESC_ENDPOINT 0x05
|
|
||||||
#define UDESC_DEVICE_QUALIFIER 0x06
|
|
||||||
#define UDESC_OTHER_SPEED_CONFIGURATION 0x07
|
|
||||||
#define UDESC_INTERFACE_POWER 0x08
|
|
||||||
#define UDESC_OTG 0x09
|
|
||||||
#define UDESC_DEBUG 0x0A
|
|
||||||
#define UDESC_IFACE_ASSOC 0x0B /* interface association */
|
|
||||||
#define UDESC_BOS 0x0F /* binary object store */
|
|
||||||
#define UDESC_DEVICE_CAPABILITY 0x10
|
|
||||||
#define UDESC_CS_DEVICE 0x21 /* class specific */
|
|
||||||
#define UDESC_CS_CONFIG 0x22
|
|
||||||
#define UDESC_CS_STRING 0x23
|
|
||||||
#define UDESC_CS_INTERFACE 0x24
|
|
||||||
#define UDESC_CS_ENDPOINT 0x25
|
|
||||||
#define UDESC_HUB 0x29
|
|
||||||
#define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */
|
|
||||||
#define UR_SET_DESCRIPTOR 0x07
|
|
||||||
#define UR_GET_CONFIG 0x08
|
|
||||||
#define UR_SET_CONFIG 0x09
|
|
||||||
#define UR_GET_INTERFACE 0x0a
|
|
||||||
#define UR_SET_INTERFACE 0x0b
|
|
||||||
#define UR_SYNCH_FRAME 0x0c
|
|
||||||
#define UR_SET_SEL 0x30
|
|
||||||
#define UR_ISOCH_DELAY 0x31
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uByte bLength;
|
|
||||||
uByte bDescriptorType;
|
|
||||||
uByte bDescriptorSubtype;
|
|
||||||
} UPACKED usb_descriptor_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uByte bLength;
|
|
||||||
uByte bDescriptorType;
|
|
||||||
uWord bcdUSB;
|
|
||||||
#define UD_USB_2_0 0x0200
|
|
||||||
#define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0)
|
|
||||||
uByte bDeviceClass;
|
|
||||||
uByte bDeviceSubClass;
|
|
||||||
uByte bDeviceProtocol;
|
|
||||||
uByte bMaxPacketSize;
|
|
||||||
/* The fields below are not part of the initial descriptor. */
|
|
||||||
uWord idVendor;
|
|
||||||
uWord idProduct;
|
|
||||||
uWord bcdDevice;
|
|
||||||
uByte iManufacturer;
|
|
||||||
uByte iProduct;
|
|
||||||
uByte iSerialNumber;
|
|
||||||
uByte bNumConfigurations;
|
|
||||||
} UPACKED usb_device_descriptor_t;
|
|
||||||
#define USB_DEVICE_DESCRIPTOR_SIZE 18
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uByte bLength;
|
|
||||||
uByte bDescriptorType;
|
|
||||||
uWord wTotalLength;
|
|
||||||
uByte bNumInterface;
|
|
||||||
uByte bConfigurationValue;
|
|
||||||
uByte iConfiguration;
|
|
||||||
uByte bmAttributes;
|
|
||||||
#define UC_BUS_POWERED 0x80
|
|
||||||
#define UC_SELF_POWERED 0x40
|
|
||||||
#define UC_REMOTE_WAKEUP 0x20
|
|
||||||
uByte bMaxPower; /* max current in 2 mA units */
|
|
||||||
#define UC_POWER_FACTOR 2
|
|
||||||
} UPACKED usb_config_descriptor_t;
|
|
||||||
#define USB_CONFIG_DESCRIPTOR_SIZE 9
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uByte bLength;
|
|
||||||
uByte bDescriptorType;
|
|
||||||
uByte bInterfaceNumber;
|
|
||||||
uByte bAlternateSetting;
|
|
||||||
uByte bNumEndpoints;
|
|
||||||
uByte bInterfaceClass;
|
|
||||||
uByte bInterfaceSubClass;
|
|
||||||
uByte bInterfaceProtocol;
|
|
||||||
uByte iInterface;
|
|
||||||
} UPACKED usb_interface_descriptor_t;
|
|
||||||
#define USB_INTERFACE_DESCRIPTOR_SIZE 9
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uByte bLength;
|
|
||||||
uByte bDescriptorType;
|
|
||||||
uByte bEndpointAddress;
|
|
||||||
#define UE_GET_DIR(a) ((a) & 0x80)
|
|
||||||
#define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
|
|
||||||
#define UE_DIR_IN 0x80
|
|
||||||
#define UE_DIR_OUT 0x00
|
|
||||||
#define UE_ADDR 0x0f
|
|
||||||
#define UE_GET_ADDR(a) ((a) & UE_ADDR)
|
|
||||||
uByte bmAttributes;
|
|
||||||
#define UE_XFERTYPE 0x03
|
|
||||||
#define UE_CONTROL 0x00
|
|
||||||
#define UE_ISOCHRONOUS 0x01
|
|
||||||
#define UE_BULK 0x02
|
|
||||||
#define UE_INTERRUPT 0x03
|
|
||||||
#define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
|
|
||||||
#define UE_ISO_TYPE 0x0c
|
|
||||||
#define UE_ISO_ASYNC 0x04
|
|
||||||
#define UE_ISO_ADAPT 0x08
|
|
||||||
#define UE_ISO_SYNC 0x0c
|
|
||||||
#define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
|
|
||||||
uWord wMaxPacketSize;
|
|
||||||
uByte bInterval;
|
|
||||||
} UPACKED usb_endpoint_descriptor_t;
|
|
||||||
#define USB_ENDPOINT_DESCRIPTOR_SIZE 7
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uByte bLength;
|
|
||||||
uByte bDescriptorType;
|
|
||||||
uWord bString[127];
|
|
||||||
} UPACKED usb_string_descriptor_t;
|
|
||||||
|
|
||||||
#define USB_MAX_STRING_LEN 128
|
|
||||||
#define USB_MAX_ENCODED_STRING_LEN (USB_MAX_STRING_LEN * 3) /* UTF8 */
|
|
||||||
|
|
||||||
struct usb_device_request {
|
|
||||||
uByte bmRequestType;
|
|
||||||
uByte bRequest;
|
|
||||||
uWord wValue;
|
|
||||||
uWord wIndex;
|
|
||||||
uWord wLength;
|
|
||||||
} UPACKED;
|
|
||||||
typedef struct usb_device_request usb_device_request_t;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,961 +0,0 @@
|
||||||
/*-
|
|
||||||
* Copyright (c) 1998 John D. Polstra.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_ELF_COMMON_H_
|
|
||||||
#define _SYS_ELF_COMMON_H_ 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ELF definitions that are independent of architecture or word size.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note header. The ".note" section contains an array of notes. Each
|
|
||||||
* begins with this header, aligned to a word boundary. Immediately
|
|
||||||
* following the note header is n_namesz bytes of name, padded to the
|
|
||||||
* next word boundary. Then comes n_descsz bytes of descriptor, again
|
|
||||||
* padded to a word boundary. The values of n_namesz and n_descsz do
|
|
||||||
* not include the padding.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t n_namesz; /* Length of name. */
|
|
||||||
uint32_t n_descsz; /* Length of descriptor. */
|
|
||||||
uint32_t n_type; /* Type of this note. */
|
|
||||||
} Elf_Note;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The header for GNU-style hash sections.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t gh_nbuckets; /* Number of hash buckets. */
|
|
||||||
uint32_t gh_symndx; /* First visible symbol in .dynsym. */
|
|
||||||
uint32_t gh_maskwords; /* #maskwords used in bloom filter. */
|
|
||||||
uint32_t gh_shift2; /* Bloom filter shift count. */
|
|
||||||
} Elf_GNU_Hash_Header;
|
|
||||||
|
|
||||||
/* Indexes into the e_ident array. Keep synced with
|
|
||||||
http://www.sco.com/developers/gabi/latest/ch4.eheader.html */
|
|
||||||
#define EI_MAG0 0 /* Magic number, byte 0. */
|
|
||||||
#define EI_MAG1 1 /* Magic number, byte 1. */
|
|
||||||
#define EI_MAG2 2 /* Magic number, byte 2. */
|
|
||||||
#define EI_MAG3 3 /* Magic number, byte 3. */
|
|
||||||
#define EI_CLASS 4 /* Class of machine. */
|
|
||||||
#define EI_DATA 5 /* Data format. */
|
|
||||||
#define EI_VERSION 6 /* ELF format version. */
|
|
||||||
#define EI_OSABI 7 /* Operating system / ABI identification */
|
|
||||||
#define EI_ABIVERSION 8 /* ABI version */
|
|
||||||
#define OLD_EI_BRAND 8 /* Start of architecture identification. */
|
|
||||||
#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */
|
|
||||||
#define EI_NIDENT 16 /* Size of e_ident array. */
|
|
||||||
|
|
||||||
/* Values for the magic number bytes. */
|
|
||||||
#define ELFMAG0 0x7f
|
|
||||||
#define ELFMAG1 'E'
|
|
||||||
#define ELFMAG2 'L'
|
|
||||||
#define ELFMAG3 'F'
|
|
||||||
#define ELFMAG "\177ELF" /* magic string */
|
|
||||||
#define SELFMAG 4 /* magic string size */
|
|
||||||
|
|
||||||
/* Values for e_ident[EI_VERSION] and e_version. */
|
|
||||||
#define EV_NONE 0
|
|
||||||
#define EV_CURRENT 1
|
|
||||||
|
|
||||||
/* Values for e_ident[EI_CLASS]. */
|
|
||||||
#define ELFCLASSNONE 0 /* Unknown class. */
|
|
||||||
#define ELFCLASS32 1 /* 32-bit architecture. */
|
|
||||||
#define ELFCLASS64 2 /* 64-bit architecture. */
|
|
||||||
|
|
||||||
/* Values for e_ident[EI_DATA]. */
|
|
||||||
#define ELFDATANONE 0 /* Unknown data format. */
|
|
||||||
#define ELFDATA2LSB 1 /* 2's complement little-endian. */
|
|
||||||
#define ELFDATA2MSB 2 /* 2's complement big-endian. */
|
|
||||||
|
|
||||||
/* Values for e_ident[EI_OSABI]. */
|
|
||||||
#define ELFOSABI_NONE 0 /* UNIX System V ABI */
|
|
||||||
#define ELFOSABI_HPUX 1 /* HP-UX operating system */
|
|
||||||
#define ELFOSABI_NETBSD 2 /* NetBSD */
|
|
||||||
#define ELFOSABI_LINUX 3 /* GNU/Linux */
|
|
||||||
#define ELFOSABI_HURD 4 /* GNU/Hurd */
|
|
||||||
#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
|
|
||||||
#define ELFOSABI_SOLARIS 6 /* Solaris */
|
|
||||||
#define ELFOSABI_AIX 7 /* AIX */
|
|
||||||
#define ELFOSABI_IRIX 8 /* IRIX */
|
|
||||||
#define ELFOSABI_FREEBSD 9 /* FreeBSD */
|
|
||||||
#define ELFOSABI_TRU64 10 /* TRU64 UNIX */
|
|
||||||
#define ELFOSABI_MODESTO 11 /* Novell Modesto */
|
|
||||||
#define ELFOSABI_OPENBSD 12 /* OpenBSD */
|
|
||||||
#define ELFOSABI_OPENVMS 13 /* Open VMS */
|
|
||||||
#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */
|
|
||||||
#define ELFOSABI_AROS 15 /* Amiga Research OS */
|
|
||||||
#define ELFOSABI_ARM 97 /* ARM */
|
|
||||||
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
|
|
||||||
|
|
||||||
#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */
|
|
||||||
#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */
|
|
||||||
|
|
||||||
/* e_ident */
|
|
||||||
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
|
|
||||||
(ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
|
|
||||||
(ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
|
|
||||||
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
|
|
||||||
|
|
||||||
/* Values for e_type. */
|
|
||||||
#define ET_NONE 0 /* Unknown type. */
|
|
||||||
#define ET_REL 1 /* Relocatable. */
|
|
||||||
#define ET_EXEC 2 /* Executable. */
|
|
||||||
#define ET_DYN 3 /* Shared object. */
|
|
||||||
#define ET_CORE 4 /* Core file. */
|
|
||||||
#define ET_LOOS 0xfe00 /* First operating system specific. */
|
|
||||||
#define ET_HIOS 0xfeff /* Last operating system-specific. */
|
|
||||||
#define ET_LOPROC 0xff00 /* First processor-specific. */
|
|
||||||
#define ET_HIPROC 0xffff /* Last processor-specific. */
|
|
||||||
|
|
||||||
/* Values for e_machine. */
|
|
||||||
#define EM_NONE 0 /* Unknown machine. */
|
|
||||||
#define EM_M32 1 /* AT&T WE32100. */
|
|
||||||
#define EM_SPARC 2 /* Sun SPARC. */
|
|
||||||
#define EM_386 3 /* Intel i386. */
|
|
||||||
#define EM_68K 4 /* Motorola 68000. */
|
|
||||||
#define EM_88K 5 /* Motorola 88000. */
|
|
||||||
#define EM_860 7 /* Intel i860. */
|
|
||||||
#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */
|
|
||||||
#define EM_S370 9 /* IBM System/370. */
|
|
||||||
#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */
|
|
||||||
#define EM_PARISC 15 /* HP PA-RISC. */
|
|
||||||
#define EM_VPP500 17 /* Fujitsu VPP500. */
|
|
||||||
#define EM_SPARC32PLUS 18 /* SPARC v8plus. */
|
|
||||||
#define EM_960 19 /* Intel 80960. */
|
|
||||||
#define EM_PPC 20 /* PowerPC 32-bit. */
|
|
||||||
#define EM_PPC64 21 /* PowerPC 64-bit. */
|
|
||||||
#define EM_S390 22 /* IBM System/390. */
|
|
||||||
#define EM_V800 36 /* NEC V800. */
|
|
||||||
#define EM_FR20 37 /* Fujitsu FR20. */
|
|
||||||
#define EM_RH32 38 /* TRW RH-32. */
|
|
||||||
#define EM_RCE 39 /* Motorola RCE. */
|
|
||||||
#define EM_ARM 40 /* ARM. */
|
|
||||||
#define EM_SH 42 /* Hitachi SH. */
|
|
||||||
#define EM_SPARCV9 43 /* SPARC v9 64-bit. */
|
|
||||||
#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */
|
|
||||||
#define EM_ARC 45 /* Argonaut RISC Core. */
|
|
||||||
#define EM_H8_300 46 /* Hitachi H8/300. */
|
|
||||||
#define EM_H8_300H 47 /* Hitachi H8/300H. */
|
|
||||||
#define EM_H8S 48 /* Hitachi H8S. */
|
|
||||||
#define EM_H8_500 49 /* Hitachi H8/500. */
|
|
||||||
#define EM_IA_64 50 /* Intel IA-64 Processor. */
|
|
||||||
#define EM_MIPS_X 51 /* Stanford MIPS-X. */
|
|
||||||
#define EM_COLDFIRE 52 /* Motorola ColdFire. */
|
|
||||||
#define EM_68HC12 53 /* Motorola M68HC12. */
|
|
||||||
#define EM_MMA 54 /* Fujitsu MMA. */
|
|
||||||
#define EM_PCP 55 /* Siemens PCP. */
|
|
||||||
#define EM_NCPU 56 /* Sony nCPU. */
|
|
||||||
#define EM_NDR1 57 /* Denso NDR1 microprocessor. */
|
|
||||||
#define EM_STARCORE 58 /* Motorola Star*Core processor. */
|
|
||||||
#define EM_ME16 59 /* Toyota ME16 processor. */
|
|
||||||
#define EM_ST100 60 /* STMicroelectronics ST100 processor. */
|
|
||||||
#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */
|
|
||||||
#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */
|
|
||||||
#define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */
|
|
||||||
#define EM_PDSP 63 /* Sony DSP Processor. */
|
|
||||||
#define EM_FX66 66 /* Siemens FX66 microcontroller. */
|
|
||||||
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16
|
|
||||||
microcontroller. */
|
|
||||||
#define EM_ST7 68 /* STmicroelectronics ST7 8-bit
|
|
||||||
microcontroller. */
|
|
||||||
#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */
|
|
||||||
#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */
|
|
||||||
#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */
|
|
||||||
#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */
|
|
||||||
#define EM_SVX 73 /* Silicon Graphics SVx. */
|
|
||||||
#define EM_ST19 74 /* STMicroelectronics ST19 8-bit mc. */
|
|
||||||
#define EM_VAX 75 /* Digital VAX. */
|
|
||||||
#define EM_CRIS 76 /* Axis Communications 32-bit embedded
|
|
||||||
processor. */
|
|
||||||
#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded
|
|
||||||
processor. */
|
|
||||||
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor. */
|
|
||||||
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */
|
|
||||||
#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc. */
|
|
||||||
#define EM_HUANY 81 /* Harvard University machine-independent
|
|
||||||
object files. */
|
|
||||||
#define EM_PRISM 82 /* SiTera Prism. */
|
|
||||||
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */
|
|
||||||
#define EM_FR30 84 /* Fujitsu FR30. */
|
|
||||||
#define EM_D10V 85 /* Mitsubishi D10V. */
|
|
||||||
#define EM_D30V 86 /* Mitsubishi D30V. */
|
|
||||||
#define EM_V850 87 /* NEC v850. */
|
|
||||||
#define EM_M32R 88 /* Mitsubishi M32R. */
|
|
||||||
#define EM_MN10300 89 /* Matsushita MN10300. */
|
|
||||||
#define EM_MN10200 90 /* Matsushita MN10200. */
|
|
||||||
#define EM_PJ 91 /* picoJava. */
|
|
||||||
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor. */
|
|
||||||
#define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */
|
|
||||||
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */
|
|
||||||
#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */
|
|
||||||
#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose
|
|
||||||
Processor. */
|
|
||||||
#define EM_NS32K 97 /* National Semiconductor 32000 series. */
|
|
||||||
#define EM_TPC 98 /* Tenor Network TPC processor. */
|
|
||||||
#define EM_SNP1K 99 /* Trebia SNP 1000 processor. */
|
|
||||||
#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */
|
|
||||||
#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family. */
|
|
||||||
#define EM_MAX 102 /* MAX Processor. */
|
|
||||||
#define EM_CR 103 /* National Semiconductor CompactRISC
|
|
||||||
microprocessor. */
|
|
||||||
#define EM_F2MC16 104 /* Fujitsu F2MC16. */
|
|
||||||
#define EM_MSP430 105 /* Texas Instruments embedded microcontroller
|
|
||||||
msp430. */
|
|
||||||
#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor. */
|
|
||||||
#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */
|
|
||||||
#define EM_SEP 108 /* Sharp embedded microprocessor. */
|
|
||||||
#define EM_ARCA 109 /* Arca RISC Microprocessor. */
|
|
||||||
#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd.
|
|
||||||
and MPRC of Peking University */
|
|
||||||
|
|
||||||
/* Non-standard or deprecated. */
|
|
||||||
#define EM_486 6 /* Intel i486. */
|
|
||||||
#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
|
|
||||||
#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */
|
|
||||||
#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */
|
|
||||||
|
|
||||||
/* Special section indexes. */
|
|
||||||
#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */
|
|
||||||
#define SHN_LORESERVE 0xff00 /* First of reserved range. */
|
|
||||||
#define SHN_LOPROC 0xff00 /* First processor-specific. */
|
|
||||||
#define SHN_HIPROC 0xff1f /* Last processor-specific. */
|
|
||||||
#define SHN_LOOS 0xff20 /* First operating system-specific. */
|
|
||||||
#define SHN_HIOS 0xff3f /* Last operating system-specific. */
|
|
||||||
#define SHN_ABS 0xfff1 /* Absolute values. */
|
|
||||||
#define SHN_COMMON 0xfff2 /* Common data. */
|
|
||||||
#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */
|
|
||||||
#define SHN_HIRESERVE 0xffff /* Last of reserved range. */
|
|
||||||
|
|
||||||
/* sh_type */
|
|
||||||
#define SHT_NULL 0 /* inactive */
|
|
||||||
#define SHT_PROGBITS 1 /* program defined information */
|
|
||||||
#define SHT_SYMTAB 2 /* symbol table section */
|
|
||||||
#define SHT_STRTAB 3 /* string table section */
|
|
||||||
#define SHT_RELA 4 /* relocation section with addends */
|
|
||||||
#define SHT_HASH 5 /* symbol hash table section */
|
|
||||||
#define SHT_DYNAMIC 6 /* dynamic section */
|
|
||||||
#define SHT_NOTE 7 /* note section */
|
|
||||||
#define SHT_NOBITS 8 /* no space section */
|
|
||||||
#define SHT_REL 9 /* relocation section - no addends */
|
|
||||||
#define SHT_SHLIB 10 /* reserved - purpose unknown */
|
|
||||||
#define SHT_DYNSYM 11 /* dynamic symbol table section */
|
|
||||||
#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */
|
|
||||||
#define SHT_FINI_ARRAY 15 /* Termination function pointers. */
|
|
||||||
#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */
|
|
||||||
#define SHT_GROUP 17 /* Section group. */
|
|
||||||
#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */
|
|
||||||
#define SHT_LOOS 0x60000000 /* First of OS specific semantics */
|
|
||||||
#define SHT_LOSUNW 0x6ffffff4
|
|
||||||
#define SHT_SUNW_dof 0x6ffffff4
|
|
||||||
#define SHT_SUNW_cap 0x6ffffff5
|
|
||||||
#define SHT_SUNW_SIGNATURE 0x6ffffff6
|
|
||||||
#define SHT_GNU_HASH 0x6ffffff6
|
|
||||||
#define SHT_SUNW_ANNOTATE 0x6ffffff7
|
|
||||||
#define SHT_SUNW_DEBUGSTR 0x6ffffff8
|
|
||||||
#define SHT_SUNW_DEBUG 0x6ffffff9
|
|
||||||
#define SHT_SUNW_move 0x6ffffffa
|
|
||||||
#define SHT_SUNW_COMDAT 0x6ffffffb
|
|
||||||
#define SHT_SUNW_syminfo 0x6ffffffc
|
|
||||||
#define SHT_SUNW_verdef 0x6ffffffd
|
|
||||||
#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */
|
|
||||||
#define SHT_SUNW_verneed 0x6ffffffe
|
|
||||||
#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */
|
|
||||||
#define SHT_SUNW_versym 0x6fffffff
|
|
||||||
#define SHT_GNU_versym 0x6fffffff /* Symbol version table */
|
|
||||||
#define SHT_HISUNW 0x6fffffff
|
|
||||||
#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */
|
|
||||||
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
|
|
||||||
#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */
|
|
||||||
#define SHT_HIPROC 0x7fffffff /* specific section header types */
|
|
||||||
#define SHT_LOUSER 0x80000000 /* reserved range for application */
|
|
||||||
#define SHT_HIUSER 0xffffffff /* specific indexes */
|
|
||||||
|
|
||||||
/* Flags for sh_flags. */
|
|
||||||
#define SHF_WRITE 0x1 /* Section contains writable data. */
|
|
||||||
#define SHF_ALLOC 0x2 /* Section occupies memory. */
|
|
||||||
#define SHF_EXECINSTR 0x4 /* Section contains instructions. */
|
|
||||||
#define SHF_MERGE 0x10 /* Section may be merged. */
|
|
||||||
#define SHF_STRINGS 0x20 /* Section contains strings. */
|
|
||||||
#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */
|
|
||||||
#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */
|
|
||||||
#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */
|
|
||||||
#define SHF_GROUP 0x200 /* Member of section group. */
|
|
||||||
#define SHF_TLS 0x400 /* Section contains TLS data. */
|
|
||||||
#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */
|
|
||||||
#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */
|
|
||||||
|
|
||||||
/* Values for p_type. */
|
|
||||||
#define PT_NULL 0 /* Unused entry. */
|
|
||||||
#define PT_LOAD 1 /* Loadable segment. */
|
|
||||||
#define PT_DYNAMIC 2 /* Dynamic linking information segment. */
|
|
||||||
#define PT_INTERP 3 /* Pathname of interpreter. */
|
|
||||||
#define PT_NOTE 4 /* Auxiliary information. */
|
|
||||||
#define PT_SHLIB 5 /* Reserved (not used). */
|
|
||||||
#define PT_PHDR 6 /* Location of program header itself. */
|
|
||||||
#define PT_TLS 7 /* Thread local storage segment */
|
|
||||||
#define PT_LOOS 0x60000000 /* First OS-specific. */
|
|
||||||
#define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */
|
|
||||||
#define PT_GNU_EH_FRAME 0x6474e550
|
|
||||||
#define PT_LOSUNW 0x6ffffffa
|
|
||||||
#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
|
|
||||||
#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */
|
|
||||||
#define PT_SUNWDTRACE 0x6ffffffc /* private */
|
|
||||||
#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */
|
|
||||||
#define PT_HISUNW 0x6fffffff
|
|
||||||
#define PT_HIOS 0x6fffffff /* Last OS-specific. */
|
|
||||||
#define PT_LOPROC 0x70000000 /* First processor-specific type. */
|
|
||||||
#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */
|
|
||||||
|
|
||||||
/* Values for p_flags. */
|
|
||||||
#define PF_X 0x1 /* Executable. */
|
|
||||||
#define PF_W 0x2 /* Writable. */
|
|
||||||
#define PF_R 0x4 /* Readable. */
|
|
||||||
#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */
|
|
||||||
#define PF_MASKPROC 0xf0000000 /* Processor-specific. */
|
|
||||||
|
|
||||||
/* Extended program header index. */
|
|
||||||
#define PN_XNUM 0xffff
|
|
||||||
|
|
||||||
/* Values for d_tag. */
|
|
||||||
#define DT_NULL 0 /* Terminating entry. */
|
|
||||||
#define DT_NEEDED 1 /* String table offset of a needed shared
|
|
||||||
library. */
|
|
||||||
#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */
|
|
||||||
#define DT_PLTGOT 3 /* Processor-dependent address. */
|
|
||||||
#define DT_HASH 4 /* Address of symbol hash table. */
|
|
||||||
#define DT_STRTAB 5 /* Address of string table. */
|
|
||||||
#define DT_SYMTAB 6 /* Address of symbol table. */
|
|
||||||
#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */
|
|
||||||
#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */
|
|
||||||
#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */
|
|
||||||
#define DT_STRSZ 10 /* Size of string table. */
|
|
||||||
#define DT_SYMENT 11 /* Size of each symbol table entry. */
|
|
||||||
#define DT_INIT 12 /* Address of initialization function. */
|
|
||||||
#define DT_FINI 13 /* Address of finalization function. */
|
|
||||||
#define DT_SONAME 14 /* String table offset of shared object
|
|
||||||
name. */
|
|
||||||
#define DT_RPATH 15 /* String table offset of library path. [sup] */
|
|
||||||
#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */
|
|
||||||
#define DT_REL 17 /* Address of ElfNN_Rel relocations. */
|
|
||||||
#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */
|
|
||||||
#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */
|
|
||||||
#define DT_PLTREL 20 /* Type of relocation used for PLT. */
|
|
||||||
#define DT_DEBUG 21 /* Reserved (not used). */
|
|
||||||
#define DT_TEXTREL 22 /* Indicates there may be relocations in
|
|
||||||
non-writable segments. [sup] */
|
|
||||||
#define DT_JMPREL 23 /* Address of PLT relocations. */
|
|
||||||
#define DT_BIND_NOW 24 /* [sup] */
|
|
||||||
#define DT_INIT_ARRAY 25 /* Address of the array of pointers to
|
|
||||||
initialization functions */
|
|
||||||
#define DT_FINI_ARRAY 26 /* Address of the array of pointers to
|
|
||||||
termination functions */
|
|
||||||
#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of
|
|
||||||
initialization functions. */
|
|
||||||
#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of
|
|
||||||
terminationfunctions. */
|
|
||||||
#define DT_RUNPATH 29 /* String table offset of a null-terminated
|
|
||||||
library search path string. */
|
|
||||||
#define DT_FLAGS 30 /* Object specific flag values. */
|
|
||||||
#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING
|
|
||||||
and less than DT_LOOS follow the rules for
|
|
||||||
the interpretation of the d_un union
|
|
||||||
as follows: even == 'd_ptr', even == 'd_val'
|
|
||||||
or none */
|
|
||||||
#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to
|
|
||||||
pre-initialization functions. */
|
|
||||||
#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of
|
|
||||||
pre-initialization functions. */
|
|
||||||
#define DT_MAXPOSTAGS 34 /* number of positive tags */
|
|
||||||
#define DT_LOOS 0x6000000d /* First OS-specific */
|
|
||||||
#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */
|
|
||||||
#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */
|
|
||||||
#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */
|
|
||||||
#define DT_SUNW_CAP 0x60000010 /* hardware/software */
|
|
||||||
#define DT_HIOS 0x6ffff000 /* Last OS-specific */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
|
|
||||||
* Dyn.d_un.d_val field of the Elf*_Dyn structure.
|
|
||||||
*/
|
|
||||||
#define DT_VALRNGLO 0x6ffffd00
|
|
||||||
#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */
|
|
||||||
#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */
|
|
||||||
#define DT_MOVEENT 0x6ffffdfa /* move table entry size */
|
|
||||||
#define DT_MOVESZ 0x6ffffdfb /* move table size */
|
|
||||||
#define DT_FEATURE_1 0x6ffffdfc /* feature holder */
|
|
||||||
#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */
|
|
||||||
/* the following DT_* entry. */
|
|
||||||
/* See DF_P1_* definitions */
|
|
||||||
#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */
|
|
||||||
#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */
|
|
||||||
#define DT_VALRNGHI 0x6ffffdff
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
|
|
||||||
* Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
|
|
||||||
*
|
|
||||||
* If any adjustment is made to the ELF object after it has been
|
|
||||||
* built, these entries will need to be adjusted.
|
|
||||||
*/
|
|
||||||
#define DT_ADDRRNGLO 0x6ffffe00
|
|
||||||
#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */
|
|
||||||
#define DT_CONFIG 0x6ffffefa /* configuration information */
|
|
||||||
#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */
|
|
||||||
#define DT_AUDIT 0x6ffffefc /* object auditing */
|
|
||||||
#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */
|
|
||||||
#define DT_MOVETAB 0x6ffffefe /* move table */
|
|
||||||
#define DT_SYMINFO 0x6ffffeff /* syminfo table */
|
|
||||||
#define DT_ADDRRNGHI 0x6ffffeff
|
|
||||||
|
|
||||||
#define DT_VERSYM 0x6ffffff0 /* Address of versym section. */
|
|
||||||
#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */
|
|
||||||
#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */
|
|
||||||
#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */
|
|
||||||
#define DT_VERDEF 0x6ffffffc /* Address of verdef section. */
|
|
||||||
#define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */
|
|
||||||
#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */
|
|
||||||
#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */
|
|
||||||
|
|
||||||
#define DT_LOPROC 0x70000000 /* First processor-specific type. */
|
|
||||||
#define DT_DEPRECATED_SPARC_REGISTER 0x7000001
|
|
||||||
#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */
|
|
||||||
#define DT_USED 0x7ffffffe /* ignored - same as needed */
|
|
||||||
#define DT_FILTER 0x7fffffff /* shared library filter name */
|
|
||||||
#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */
|
|
||||||
|
|
||||||
/* Values for DT_FLAGS */
|
|
||||||
#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may
|
|
||||||
make reference to the $ORIGIN substitution
|
|
||||||
string */
|
|
||||||
#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */
|
|
||||||
#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in
|
|
||||||
non-writable segments. */
|
|
||||||
#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should
|
|
||||||
process all relocations for the object
|
|
||||||
containing this entry before transferring
|
|
||||||
control to the program. */
|
|
||||||
#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or
|
|
||||||
executable contains code using a static
|
|
||||||
thread-local storage scheme. */
|
|
||||||
|
|
||||||
/* Values for DT_FLAGS_1 */
|
|
||||||
#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */
|
|
||||||
#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */
|
|
||||||
#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */
|
|
||||||
#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */
|
|
||||||
#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */
|
|
||||||
|
|
||||||
/* Values for n_type. Used in core files. */
|
|
||||||
#define NT_PRSTATUS 1 /* Process status. */
|
|
||||||
#define NT_FPREGSET 2 /* Floating point registers. */
|
|
||||||
#define NT_PRPSINFO 3 /* Process state info. */
|
|
||||||
|
|
||||||
/* Symbol Binding - ELFNN_ST_BIND - st_info */
|
|
||||||
#define STB_LOCAL 0 /* Local symbol */
|
|
||||||
#define STB_GLOBAL 1 /* Global symbol */
|
|
||||||
#define STB_WEAK 2 /* like global - lower precedence */
|
|
||||||
#define STB_LOOS 10 /* Reserved range for operating system */
|
|
||||||
#define STB_HIOS 12 /* specific semantics. */
|
|
||||||
#define STB_LOPROC 13 /* reserved range for processor */
|
|
||||||
#define STB_HIPROC 15 /* specific semantics. */
|
|
||||||
|
|
||||||
/* Symbol type - ELFNN_ST_TYPE - st_info */
|
|
||||||
#define STT_NOTYPE 0 /* Unspecified type. */
|
|
||||||
#define STT_OBJECT 1 /* Data object. */
|
|
||||||
#define STT_FUNC 2 /* Function. */
|
|
||||||
#define STT_SECTION 3 /* Section. */
|
|
||||||
#define STT_FILE 4 /* Source file. */
|
|
||||||
#define STT_COMMON 5 /* Uninitialized common block. */
|
|
||||||
#define STT_TLS 6 /* TLS object. */
|
|
||||||
#define STT_NUM 7
|
|
||||||
#define STT_LOOS 10 /* Reserved range for operating system */
|
|
||||||
#define STT_HIOS 12 /* specific semantics. */
|
|
||||||
#define STT_LOPROC 13 /* reserved range for processor */
|
|
||||||
#define STT_HIPROC 15 /* specific semantics. */
|
|
||||||
|
|
||||||
/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */
|
|
||||||
#define STV_DEFAULT 0x0 /* Default visibility (see binding). */
|
|
||||||
#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */
|
|
||||||
#define STV_HIDDEN 0x2 /* Not visible. */
|
|
||||||
#define STV_PROTECTED 0x3 /* Visible but not preemptible. */
|
|
||||||
#define STV_EXPORTED 0x4
|
|
||||||
#define STV_SINGLETON 0x5
|
|
||||||
#define STV_ELIMINATE 0x6
|
|
||||||
|
|
||||||
/* Special symbol table indexes. */
|
|
||||||
#define STN_UNDEF 0 /* Undefined symbol index. */
|
|
||||||
|
|
||||||
/* Symbol versioning flags. */
|
|
||||||
#define VER_DEF_CURRENT 1
|
|
||||||
#define VER_DEF_IDX(x) VER_NDX(x)
|
|
||||||
|
|
||||||
#define VER_FLG_BASE 0x01
|
|
||||||
#define VER_FLG_WEAK 0x02
|
|
||||||
|
|
||||||
#define VER_NEED_CURRENT 1
|
|
||||||
#define VER_NEED_WEAK (1u << 15)
|
|
||||||
#define VER_NEED_HIDDEN VER_NDX_HIDDEN
|
|
||||||
#define VER_NEED_IDX(x) VER_NDX(x)
|
|
||||||
|
|
||||||
#define VER_NDX_LOCAL 0
|
|
||||||
#define VER_NDX_GLOBAL 1
|
|
||||||
#define VER_NDX_GIVEN 2
|
|
||||||
|
|
||||||
#define VER_NDX_HIDDEN (1u << 15)
|
|
||||||
#define VER_NDX(x) ((x) & ~(1u << 15))
|
|
||||||
|
|
||||||
#define CA_SUNW_NULL 0
|
|
||||||
#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */
|
|
||||||
#define CA_SUNW_SF_1 2 /* first software capabilities entry */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Syminfo flag values
|
|
||||||
*/
|
|
||||||
#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */
|
|
||||||
/* to object containing defn. */
|
|
||||||
#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */
|
|
||||||
#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */
|
|
||||||
#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */
|
|
||||||
/* lazily-loaded */
|
|
||||||
#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */
|
|
||||||
/* object containing defn. */
|
|
||||||
#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */
|
|
||||||
/* directly bind to this symbol */
|
|
||||||
#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */
|
|
||||||
#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Syminfo.si_boundto values.
|
|
||||||
*/
|
|
||||||
#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */
|
|
||||||
#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */
|
|
||||||
#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */
|
|
||||||
#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */
|
|
||||||
#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Syminfo version values.
|
|
||||||
*/
|
|
||||||
#define SYMINFO_NONE 0 /* Syminfo version */
|
|
||||||
#define SYMINFO_CURRENT 1
|
|
||||||
#define SYMINFO_NUM 2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Relocation types.
|
|
||||||
*
|
|
||||||
* All machine architectures are defined here to allow tools on one to
|
|
||||||
* handle others.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define R_386_NONE 0 /* No relocation. */
|
|
||||||
#define R_386_32 1 /* Add symbol value. */
|
|
||||||
#define R_386_PC32 2 /* Add PC-relative symbol value. */
|
|
||||||
#define R_386_GOT32 3 /* Add PC-relative GOT offset. */
|
|
||||||
#define R_386_PLT32 4 /* Add PC-relative PLT offset. */
|
|
||||||
#define R_386_COPY 5 /* Copy data from shared object. */
|
|
||||||
#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */
|
|
||||||
#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */
|
|
||||||
#define R_386_RELATIVE 8 /* Add load address of shared object. */
|
|
||||||
#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */
|
|
||||||
#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */
|
|
||||||
#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */
|
|
||||||
#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */
|
|
||||||
#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */
|
|
||||||
#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */
|
|
||||||
#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */
|
|
||||||
#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */
|
|
||||||
#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */
|
|
||||||
#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */
|
|
||||||
#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */
|
|
||||||
#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */
|
|
||||||
#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */
|
|
||||||
#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */
|
|
||||||
#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */
|
|
||||||
#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */
|
|
||||||
#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */
|
|
||||||
#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */
|
|
||||||
#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */
|
|
||||||
#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */
|
|
||||||
#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */
|
|
||||||
#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */
|
|
||||||
|
|
||||||
#define R_ARM_NONE 0 /* No relocation. */
|
|
||||||
#define R_ARM_PC24 1
|
|
||||||
#define R_ARM_ABS32 2
|
|
||||||
#define R_ARM_REL32 3
|
|
||||||
#define R_ARM_PC13 4
|
|
||||||
#define R_ARM_ABS16 5
|
|
||||||
#define R_ARM_ABS12 6
|
|
||||||
#define R_ARM_THM_ABS5 7
|
|
||||||
#define R_ARM_ABS8 8
|
|
||||||
#define R_ARM_SBREL32 9
|
|
||||||
#define R_ARM_THM_PC22 10
|
|
||||||
#define R_ARM_THM_PC8 11
|
|
||||||
#define R_ARM_AMP_VCALL9 12
|
|
||||||
#define R_ARM_SWI24 13
|
|
||||||
#define R_ARM_THM_SWI8 14
|
|
||||||
#define R_ARM_XPC25 15
|
|
||||||
#define R_ARM_THM_XPC22 16
|
|
||||||
#define R_ARM_COPY 20 /* Copy data from shared object. */
|
|
||||||
#define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */
|
|
||||||
#define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */
|
|
||||||
#define R_ARM_RELATIVE 23 /* Add load address of shared object. */
|
|
||||||
#define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */
|
|
||||||
#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */
|
|
||||||
#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */
|
|
||||||
#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */
|
|
||||||
#define R_ARM_GNU_VTENTRY 100
|
|
||||||
#define R_ARM_GNU_VTINHERIT 101
|
|
||||||
#define R_ARM_RSBREL32 250
|
|
||||||
#define R_ARM_THM_RPC22 251
|
|
||||||
#define R_ARM_RREL32 252
|
|
||||||
#define R_ARM_RABS32 253
|
|
||||||
#define R_ARM_RPC24 254
|
|
||||||
#define R_ARM_RBASE 255
|
|
||||||
|
|
||||||
/* Name Value Field Calculation */
|
|
||||||
#define R_IA_64_NONE 0 /* None */
|
|
||||||
#define R_IA_64_IMM14 0x21 /* immediate14 S + A */
|
|
||||||
#define R_IA_64_IMM22 0x22 /* immediate22 S + A */
|
|
||||||
#define R_IA_64_IMM64 0x23 /* immediate64 S + A */
|
|
||||||
#define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */
|
|
||||||
#define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */
|
|
||||||
#define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */
|
|
||||||
#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */
|
|
||||||
#define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */
|
|
||||||
#define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */
|
|
||||||
#define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */
|
|
||||||
#define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */
|
|
||||||
#define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */
|
|
||||||
#define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */
|
|
||||||
#define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */
|
|
||||||
#define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */
|
|
||||||
#define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */
|
|
||||||
#define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */
|
|
||||||
#define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */
|
|
||||||
#define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */
|
|
||||||
#define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */
|
|
||||||
#define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */
|
|
||||||
#define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */
|
|
||||||
#define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */
|
|
||||||
#define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */
|
|
||||||
#define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */
|
|
||||||
#define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */
|
|
||||||
#define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */
|
|
||||||
#define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */
|
|
||||||
#define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */
|
|
||||||
#define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */
|
|
||||||
#define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */
|
|
||||||
#define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */
|
|
||||||
#define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */
|
|
||||||
#define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */
|
|
||||||
#define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */
|
|
||||||
#define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */
|
|
||||||
#define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */
|
|
||||||
#define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */
|
|
||||||
#define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */
|
|
||||||
#define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */
|
|
||||||
#define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */
|
|
||||||
#define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */
|
|
||||||
#define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */
|
|
||||||
#define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */
|
|
||||||
#define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */
|
|
||||||
#define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */
|
|
||||||
#define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */
|
|
||||||
#define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */
|
|
||||||
#define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */
|
|
||||||
#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */
|
|
||||||
#define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */
|
|
||||||
#define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */
|
|
||||||
#define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */
|
|
||||||
#define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */
|
|
||||||
#define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */
|
|
||||||
#define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */
|
|
||||||
#define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */
|
|
||||||
#define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */
|
|
||||||
#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */
|
|
||||||
#define R_IA_64_SUB 0x85 /* immediate64 A - S */
|
|
||||||
#define R_IA_64_LTOFF22X 0x86 /* immediate22 special */
|
|
||||||
#define R_IA_64_LDXMOV 0x87 /* immediate22 special */
|
|
||||||
#define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */
|
|
||||||
#define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */
|
|
||||||
#define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */
|
|
||||||
#define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */
|
|
||||||
#define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */
|
|
||||||
#define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */
|
|
||||||
#define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */
|
|
||||||
#define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */
|
|
||||||
#define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */
|
|
||||||
#define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */
|
|
||||||
#define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */
|
|
||||||
#define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */
|
|
||||||
#define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */
|
|
||||||
#define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */
|
|
||||||
#define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */
|
|
||||||
#define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */
|
|
||||||
#define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */
|
|
||||||
|
|
||||||
#define R_MIPS_NONE 0 /* No reloc */
|
|
||||||
#define R_MIPS_16 1 /* Direct 16 bit */
|
|
||||||
#define R_MIPS_32 2 /* Direct 32 bit */
|
|
||||||
#define R_MIPS_REL32 3 /* PC relative 32 bit */
|
|
||||||
#define R_MIPS_26 4 /* Direct 26 bit shifted */
|
|
||||||
#define R_MIPS_HI16 5 /* High 16 bit */
|
|
||||||
#define R_MIPS_LO16 6 /* Low 16 bit */
|
|
||||||
#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
|
|
||||||
#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
|
|
||||||
#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
|
|
||||||
#define R_MIPS_PC16 10 /* PC relative 16 bit */
|
|
||||||
#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
|
|
||||||
#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
|
|
||||||
#define R_MIPS_GOTHI16 21 /* GOT HI 16 bit */
|
|
||||||
#define R_MIPS_GOTLO16 22 /* GOT LO 16 bit */
|
|
||||||
#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */
|
|
||||||
#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */
|
|
||||||
|
|
||||||
#define R_PPC_NONE 0 /* No relocation. */
|
|
||||||
#define R_PPC_ADDR32 1
|
|
||||||
#define R_PPC_ADDR24 2
|
|
||||||
#define R_PPC_ADDR16 3
|
|
||||||
#define R_PPC_ADDR16_LO 4
|
|
||||||
#define R_PPC_ADDR16_HI 5
|
|
||||||
#define R_PPC_ADDR16_HA 6
|
|
||||||
#define R_PPC_ADDR14 7
|
|
||||||
#define R_PPC_ADDR14_BRTAKEN 8
|
|
||||||
#define R_PPC_ADDR14_BRNTAKEN 9
|
|
||||||
#define R_PPC_REL24 10
|
|
||||||
#define R_PPC_REL14 11
|
|
||||||
#define R_PPC_REL14_BRTAKEN 12
|
|
||||||
#define R_PPC_REL14_BRNTAKEN 13
|
|
||||||
#define R_PPC_GOT16 14
|
|
||||||
#define R_PPC_GOT16_LO 15
|
|
||||||
#define R_PPC_GOT16_HI 16
|
|
||||||
#define R_PPC_GOT16_HA 17
|
|
||||||
#define R_PPC_PLTREL24 18
|
|
||||||
#define R_PPC_COPY 19
|
|
||||||
#define R_PPC_GLOB_DAT 20
|
|
||||||
#define R_PPC_JMP_SLOT 21
|
|
||||||
#define R_PPC_RELATIVE 22
|
|
||||||
#define R_PPC_LOCAL24PC 23
|
|
||||||
#define R_PPC_UADDR32 24
|
|
||||||
#define R_PPC_UADDR16 25
|
|
||||||
#define R_PPC_REL32 26
|
|
||||||
#define R_PPC_PLT32 27
|
|
||||||
#define R_PPC_PLTREL32 28
|
|
||||||
#define R_PPC_PLT16_LO 29
|
|
||||||
#define R_PPC_PLT16_HI 30
|
|
||||||
#define R_PPC_PLT16_HA 31
|
|
||||||
#define R_PPC_SDAREL16 32
|
|
||||||
#define R_PPC_SECTOFF 33
|
|
||||||
#define R_PPC_SECTOFF_LO 34
|
|
||||||
#define R_PPC_SECTOFF_HI 35
|
|
||||||
#define R_PPC_SECTOFF_HA 36
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 64-bit relocations
|
|
||||||
*/
|
|
||||||
#define R_PPC64_ADDR64 38
|
|
||||||
#define R_PPC64_ADDR16_HIGHER 39
|
|
||||||
#define R_PPC64_ADDR16_HIGHERA 40
|
|
||||||
#define R_PPC64_ADDR16_HIGHEST 41
|
|
||||||
#define R_PPC64_ADDR16_HIGHESTA 42
|
|
||||||
#define R_PPC64_UADDR64 43
|
|
||||||
#define R_PPC64_REL64 44
|
|
||||||
#define R_PPC64_PLT64 45
|
|
||||||
#define R_PPC64_PLTREL64 46
|
|
||||||
#define R_PPC64_TOC16 47
|
|
||||||
#define R_PPC64_TOC16_LO 48
|
|
||||||
#define R_PPC64_TOC16_HI 49
|
|
||||||
#define R_PPC64_TOC16_HA 50
|
|
||||||
#define R_PPC64_TOC 51
|
|
||||||
#define R_PPC64_DTPMOD64 68
|
|
||||||
#define R_PPC64_TPREL64 73
|
|
||||||
#define R_PPC64_DTPREL64 78
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TLS relocations
|
|
||||||
*/
|
|
||||||
#define R_PPC_TLS 67
|
|
||||||
#define R_PPC_DTPMOD32 68
|
|
||||||
#define R_PPC_TPREL16 69
|
|
||||||
#define R_PPC_TPREL16_LO 70
|
|
||||||
#define R_PPC_TPREL16_HI 71
|
|
||||||
#define R_PPC_TPREL16_HA 72
|
|
||||||
#define R_PPC_TPREL32 73
|
|
||||||
#define R_PPC_DTPREL16 74
|
|
||||||
#define R_PPC_DTPREL16_LO 75
|
|
||||||
#define R_PPC_DTPREL16_HI 76
|
|
||||||
#define R_PPC_DTPREL16_HA 77
|
|
||||||
#define R_PPC_DTPREL32 78
|
|
||||||
#define R_PPC_GOT_TLSGD16 79
|
|
||||||
#define R_PPC_GOT_TLSGD16_LO 80
|
|
||||||
#define R_PPC_GOT_TLSGD16_HI 81
|
|
||||||
#define R_PPC_GOT_TLSGD16_HA 82
|
|
||||||
#define R_PPC_GOT_TLSLD16 83
|
|
||||||
#define R_PPC_GOT_TLSLD16_LO 84
|
|
||||||
#define R_PPC_GOT_TLSLD16_HI 85
|
|
||||||
#define R_PPC_GOT_TLSLD16_HA 86
|
|
||||||
#define R_PPC_GOT_TPREL16 87
|
|
||||||
#define R_PPC_GOT_TPREL16_LO 88
|
|
||||||
#define R_PPC_GOT_TPREL16_HI 89
|
|
||||||
#define R_PPC_GOT_TPREL16_HA 90
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The remaining relocs are from the Embedded ELF ABI, and are not in the
|
|
||||||
* SVR4 ELF ABI.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define R_PPC_EMB_NADDR32 101
|
|
||||||
#define R_PPC_EMB_NADDR16 102
|
|
||||||
#define R_PPC_EMB_NADDR16_LO 103
|
|
||||||
#define R_PPC_EMB_NADDR16_HI 104
|
|
||||||
#define R_PPC_EMB_NADDR16_HA 105
|
|
||||||
#define R_PPC_EMB_SDAI16 106
|
|
||||||
#define R_PPC_EMB_SDA2I16 107
|
|
||||||
#define R_PPC_EMB_SDA2REL 108
|
|
||||||
#define R_PPC_EMB_SDA21 109
|
|
||||||
#define R_PPC_EMB_MRKREF 110
|
|
||||||
#define R_PPC_EMB_RELSEC16 111
|
|
||||||
#define R_PPC_EMB_RELST_LO 112
|
|
||||||
#define R_PPC_EMB_RELST_HI 113
|
|
||||||
#define R_PPC_EMB_RELST_HA 114
|
|
||||||
#define R_PPC_EMB_BIT_FLD 115
|
|
||||||
#define R_PPC_EMB_RELSDA 116
|
|
||||||
|
|
||||||
#define R_SPARC_NONE 0
|
|
||||||
#define R_SPARC_8 1
|
|
||||||
#define R_SPARC_16 2
|
|
||||||
#define R_SPARC_32 3
|
|
||||||
#define R_SPARC_DISP8 4
|
|
||||||
#define R_SPARC_DISP16 5
|
|
||||||
#define R_SPARC_DISP32 6
|
|
||||||
#define R_SPARC_WDISP30 7
|
|
||||||
#define R_SPARC_WDISP22 8
|
|
||||||
#define R_SPARC_HI22 9
|
|
||||||
#define R_SPARC_22 10
|
|
||||||
#define R_SPARC_13 11
|
|
||||||
#define R_SPARC_LO10 12
|
|
||||||
#define R_SPARC_GOT10 13
|
|
||||||
#define R_SPARC_GOT13 14
|
|
||||||
#define R_SPARC_GOT22 15
|
|
||||||
#define R_SPARC_PC10 16
|
|
||||||
#define R_SPARC_PC22 17
|
|
||||||
#define R_SPARC_WPLT30 18
|
|
||||||
#define R_SPARC_COPY 19
|
|
||||||
#define R_SPARC_GLOB_DAT 20
|
|
||||||
#define R_SPARC_JMP_SLOT 21
|
|
||||||
#define R_SPARC_RELATIVE 22
|
|
||||||
#define R_SPARC_UA32 23
|
|
||||||
#define R_SPARC_PLT32 24
|
|
||||||
#define R_SPARC_HIPLT22 25
|
|
||||||
#define R_SPARC_LOPLT10 26
|
|
||||||
#define R_SPARC_PCPLT32 27
|
|
||||||
#define R_SPARC_PCPLT22 28
|
|
||||||
#define R_SPARC_PCPLT10 29
|
|
||||||
#define R_SPARC_10 30
|
|
||||||
#define R_SPARC_11 31
|
|
||||||
#define R_SPARC_64 32
|
|
||||||
#define R_SPARC_OLO10 33
|
|
||||||
#define R_SPARC_HH22 34
|
|
||||||
#define R_SPARC_HM10 35
|
|
||||||
#define R_SPARC_LM22 36
|
|
||||||
#define R_SPARC_PC_HH22 37
|
|
||||||
#define R_SPARC_PC_HM10 38
|
|
||||||
#define R_SPARC_PC_LM22 39
|
|
||||||
#define R_SPARC_WDISP16 40
|
|
||||||
#define R_SPARC_WDISP19 41
|
|
||||||
#define R_SPARC_GLOB_JMP 42
|
|
||||||
#define R_SPARC_7 43
|
|
||||||
#define R_SPARC_5 44
|
|
||||||
#define R_SPARC_6 45
|
|
||||||
#define R_SPARC_DISP64 46
|
|
||||||
#define R_SPARC_PLT64 47
|
|
||||||
#define R_SPARC_HIX22 48
|
|
||||||
#define R_SPARC_LOX10 49
|
|
||||||
#define R_SPARC_H44 50
|
|
||||||
#define R_SPARC_M44 51
|
|
||||||
#define R_SPARC_L44 52
|
|
||||||
#define R_SPARC_REGISTER 53
|
|
||||||
#define R_SPARC_UA64 54
|
|
||||||
#define R_SPARC_UA16 55
|
|
||||||
#define R_SPARC_TLS_GD_HI22 56
|
|
||||||
#define R_SPARC_TLS_GD_LO10 57
|
|
||||||
#define R_SPARC_TLS_GD_ADD 58
|
|
||||||
#define R_SPARC_TLS_GD_CALL 59
|
|
||||||
#define R_SPARC_TLS_LDM_HI22 60
|
|
||||||
#define R_SPARC_TLS_LDM_LO10 61
|
|
||||||
#define R_SPARC_TLS_LDM_ADD 62
|
|
||||||
#define R_SPARC_TLS_LDM_CALL 63
|
|
||||||
#define R_SPARC_TLS_LDO_HIX22 64
|
|
||||||
#define R_SPARC_TLS_LDO_LOX10 65
|
|
||||||
#define R_SPARC_TLS_LDO_ADD 66
|
|
||||||
#define R_SPARC_TLS_IE_HI22 67
|
|
||||||
#define R_SPARC_TLS_IE_LO10 68
|
|
||||||
#define R_SPARC_TLS_IE_LD 69
|
|
||||||
#define R_SPARC_TLS_IE_LDX 70
|
|
||||||
#define R_SPARC_TLS_IE_ADD 71
|
|
||||||
#define R_SPARC_TLS_LE_HIX22 72
|
|
||||||
#define R_SPARC_TLS_LE_LOX10 73
|
|
||||||
#define R_SPARC_TLS_DTPMOD32 74
|
|
||||||
#define R_SPARC_TLS_DTPMOD64 75
|
|
||||||
#define R_SPARC_TLS_DTPOFF32 76
|
|
||||||
#define R_SPARC_TLS_DTPOFF64 77
|
|
||||||
#define R_SPARC_TLS_TPOFF32 78
|
|
||||||
#define R_SPARC_TLS_TPOFF64 79
|
|
||||||
|
|
||||||
#define R_X86_64_NONE 0 /* No relocation. */
|
|
||||||
#define R_X86_64_64 1 /* Add 64 bit symbol value. */
|
|
||||||
#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */
|
|
||||||
#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */
|
|
||||||
#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */
|
|
||||||
#define R_X86_64_COPY 5 /* Copy data from shared object. */
|
|
||||||
#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */
|
|
||||||
#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */
|
|
||||||
#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */
|
|
||||||
#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */
|
|
||||||
#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */
|
|
||||||
#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */
|
|
||||||
#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */
|
|
||||||
#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */
|
|
||||||
#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */
|
|
||||||
#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */
|
|
||||||
#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
|
|
||||||
#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */
|
|
||||||
#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */
|
|
||||||
#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */
|
|
||||||
#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */
|
|
||||||
#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
|
|
||||||
#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */
|
|
||||||
#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !_SYS_ELF_COMMON_H_ */
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
/* sys/ioc_net.h - NetBSD-friendly version of Minix net/ioctl.h
|
|
||||||
*/
|
|
||||||
/* net/ioctl.h - Network ioctl() command codes. Author: Kees J. Bot
|
|
||||||
* 23 Nov 2002
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_IOC_NET_H_
|
|
||||||
#define _SYS_IOC_NET_H_
|
|
||||||
|
|
||||||
#include <minix/ioctl.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
|
|
||||||
#include <sys/ansi.h>
|
|
||||||
#ifndef socklen_t
|
|
||||||
typedef __socklen_t socklen_t;
|
|
||||||
#define socklen_t __socklen_t
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MSG_CONTROL_MAX (1024 - sizeof(socklen_t))
|
|
||||||
struct msg_control
|
|
||||||
{
|
|
||||||
char msg_control[MSG_CONTROL_MAX];
|
|
||||||
socklen_t msg_controllen;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Network ioctls. */
|
|
||||||
#define NWIOSETHOPT _IOW('n', 16, struct nwio_ethopt)
|
|
||||||
#define NWIOGETHOPT _IOR('n', 17, struct nwio_ethopt)
|
|
||||||
#define NWIOGETHSTAT _IOR('n', 18, struct nwio_ethstat)
|
|
||||||
|
|
||||||
#define NWIOARPGIP _IOWR('n',20, struct nwio_arp)
|
|
||||||
#define NWIOARPGNEXT _IOWR('n',21, struct nwio_arp)
|
|
||||||
#define NWIOARPSIP _IOW ('n',22, struct nwio_arp)
|
|
||||||
#define NWIOARPDIP _IOW ('n',23, struct nwio_arp)
|
|
||||||
|
|
||||||
#define NWIOSIPCONF2 _IOW('n', 32, struct nwio_ipconf2)
|
|
||||||
#define NWIOSIPCONF _IOW('n', 32, struct nwio_ipconf)
|
|
||||||
#define NWIOGIPCONF2 _IOR('n', 33, struct nwio_ipconf2)
|
|
||||||
#define NWIOGIPCONF _IOR('n', 33, struct nwio_ipconf)
|
|
||||||
#define NWIOSIPOPT _IOW('n', 34, struct nwio_ipopt)
|
|
||||||
#define NWIOGIPOPT _IOR('n', 35, struct nwio_ipopt)
|
|
||||||
|
|
||||||
#define NWIOGIPOROUTE _IOWR('n', 40, struct nwio_route)
|
|
||||||
#define NWIOSIPOROUTE _IOW ('n', 41, struct nwio_route)
|
|
||||||
#define NWIODIPOROUTE _IOW ('n', 42, struct nwio_route)
|
|
||||||
#define NWIOGIPIROUTE _IOWR('n', 43, struct nwio_route)
|
|
||||||
#define NWIOSIPIROUTE _IOW ('n', 44, struct nwio_route)
|
|
||||||
#define NWIODIPIROUTE _IOW ('n', 45, struct nwio_route)
|
|
||||||
|
|
||||||
#define NWIOSTCPCONF _IOW('n', 48, struct nwio_tcpconf)
|
|
||||||
#define NWIOGTCPCONF _IOR('n', 49, struct nwio_tcpconf)
|
|
||||||
#define NWIOTCPCONN _IOW('n', 50, struct nwio_tcpcl)
|
|
||||||
#define NWIOTCPLISTEN _IOW('n', 51, struct nwio_tcpcl)
|
|
||||||
#define NWIOTCPATTACH _IOW('n', 52, struct nwio_tcpatt)
|
|
||||||
#define NWIOTCPSHUTDOWN _IO ('n', 53)
|
|
||||||
#define NWIOSTCPOPT _IOW('n', 54, struct nwio_tcpopt)
|
|
||||||
#define NWIOGTCPOPT _IOR('n', 55, struct nwio_tcpopt)
|
|
||||||
#define NWIOTCPPUSH _IO ('n', 56)
|
|
||||||
#define NWIOTCPLISTENQ _IOW('n', 57, int)
|
|
||||||
#define NWIOGTCPCOOKIE _IOR('n', 58, struct tcp_cookie)
|
|
||||||
#define NWIOTCPACCEPTTO _IOW('n', 59, struct tcp_cookie)
|
|
||||||
#define NWIOTCPGERROR _IOR('n', 60, int)
|
|
||||||
|
|
||||||
#define NWIOSUDPOPT _IOW('n', 64, struct nwio_udpopt)
|
|
||||||
#define NWIOGUDPOPT _IOR('n', 65, struct nwio_udpopt)
|
|
||||||
#define NWIOUDPPEEK _IOR('n', 66, struct udp_io_hdr)
|
|
||||||
|
|
||||||
#define NWIOGUDSFADDR _IOR ('n', 67, struct sockaddr_un) /* recvfrom() */
|
|
||||||
#define NWIOSUDSTADDR _IOW ('n', 68, struct sockaddr_un) /* sendto() */
|
|
||||||
#define NWIOSUDSADDR _IOW ('n', 69, struct sockaddr_un) /* bind() */
|
|
||||||
#define NWIOGUDSADDR _IOR ('n', 70, struct sockaddr_un) /* getsockname() */
|
|
||||||
#define NWIOGUDSPADDR _IOR ('n', 71, struct sockaddr_un) /* getpeername() */
|
|
||||||
#define NWIOSUDSTYPE _IOW ('n', 72, int) /* socket() */
|
|
||||||
#define NWIOSUDSBLOG _IOW ('n', 73, int) /* listen() */
|
|
||||||
#define NWIOSUDSCONN _IOW ('n', 74, struct sockaddr_un) /* connect() */
|
|
||||||
#define NWIOSUDSSHUT _IOW ('n', 75, int) /* shutdown() */
|
|
||||||
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
|
|
||||||
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
|
|
||||||
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
|
|
||||||
#define NWIOGUDSCTRL _IOWR('n', 79, struct msg_control) /* recvmsg() */
|
|
||||||
|
|
||||||
#define NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt)
|
|
||||||
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
|
|
||||||
|
|
||||||
/* setsockopt/setsockopt for unix domain sockets */
|
|
||||||
#define NWIOGUDSSOTYPE _IOR('n', 90, int) /* SO_TYPE */
|
|
||||||
#define NWIOGUDSPEERCRED _IOR('n', 91, struct uucred) /* SO_PEERCRED */
|
|
||||||
#define NWIOGUDSSNDBUF _IOR('n', 92, size_t) /* SO_SNDBUF */
|
|
||||||
#define NWIOSUDSSNDBUF _IOW('n', 93, size_t) /* SO_SNDBUF */
|
|
||||||
#define NWIOGUDSRCVBUF _IOR('n', 94, size_t) /* SO_RCVBUF */
|
|
||||||
#define NWIOSUDSRCVBUF _IOW('n', 95, size_t) /* SO_RCVBUF */
|
|
||||||
|
|
||||||
#endif /* _NET__IOCTL_H */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $PchId: ioctl.h,v 1.2 2003/07/25 14:34:03 philip Exp $
|
|
||||||
*/
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
/* $NetBSD: varargs.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Matthias Scheler.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VARARGS_H_
|
|
||||||
#define _VARARGS_H_
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
#if __GNUC_PREREQ__(3, 3)
|
|
||||||
#error "GCC 3.3 and newer no longer implements <varargs.h>."
|
|
||||||
#error "Revise your code to use <stdarg.h>."
|
|
||||||
#else
|
|
||||||
#include <machine/varargs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_VARARGS_H_ */
|
|
||||||
|
|
||||||
|
|
@ -1,304 +0,0 @@
|
||||||
/* $NetBSD: memset.S,v 1.7 2013/12/02 21:21:33 joerg Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2003 Wasabi Systems, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Written by Steve C. Woodford for Wasabi Systems, Inc.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed for the NetBSD Project by
|
|
||||||
* Wasabi Systems, Inc.
|
|
||||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
||||||
* or promote products derived from this software without specific prior
|
|
||||||
* written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995 Mark Brinicombe.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by Mark Brinicombe.
|
|
||||||
* 4. The name of the company nor the name of the author may be used to
|
|
||||||
* endorse or promote products derived from this software without specific
|
|
||||||
* prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
||||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <machine/asm.h>
|
|
||||||
|
|
||||||
#if 0 && defined(__minix)
|
|
||||||
#if defined(__ARM_EABI__) && !defined(_BZERO)
|
|
||||||
ENTRY(__aeabi_memset)
|
|
||||||
mov r3, r1
|
|
||||||
mov r1, r2
|
|
||||||
mov r2, r3
|
|
||||||
b memset
|
|
||||||
END(__aeabi_memset)
|
|
||||||
STRONG_ALIAS(__aeabi_memset4, __aeabi_memset)
|
|
||||||
STRONG_ALIAS(__aeabi_memset8, __aeabi_memset)
|
|
||||||
|
|
||||||
ENTRY(__aeabi_memclr)
|
|
||||||
mov r2, r1
|
|
||||||
mov r1, #0
|
|
||||||
b memset
|
|
||||||
END(__aeabi_memclr)
|
|
||||||
STRONG_ALIAS(__aeabi_memclr4, __aeabi_memclr)
|
|
||||||
STRONG_ALIAS(__aeabi_memclr8, __aeabi_memclr)
|
|
||||||
#endif
|
|
||||||
#endif /* #if 0 && defined(__minix) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* memset: Sets a block of memory to the specified value
|
|
||||||
*
|
|
||||||
* On entry:
|
|
||||||
* r0 - dest address
|
|
||||||
* r1 - byte to write
|
|
||||||
* r2 - number of bytes to write
|
|
||||||
*
|
|
||||||
* On exit:
|
|
||||||
* r0 - dest address
|
|
||||||
*/
|
|
||||||
#ifdef _BZERO
|
|
||||||
/* LINTSTUB: Func: void bzero(void *, size_t) */
|
|
||||||
ENTRY(bzero)
|
|
||||||
mov r3, #0x00
|
|
||||||
#else
|
|
||||||
#if defined(__minix)
|
|
||||||
/* LINTSTUB: Func: void *phys_memset(void *, int, size_t) */
|
|
||||||
ENTRY(phys_memset)
|
|
||||||
#else
|
|
||||||
/* LINTSTUB: Func: void *memset(void *, int, size_t) */
|
|
||||||
ENTRY(memset)
|
|
||||||
#endif
|
|
||||||
and r3, r1, #0xff /* We deal with bytes */
|
|
||||||
mov r1, r2
|
|
||||||
#endif
|
|
||||||
cmp r1, #0x04 /* Do we have less than 4 bytes */
|
|
||||||
mov ip, r0
|
|
||||||
blt .Lmemset_lessthanfour
|
|
||||||
|
|
||||||
/* Ok first we will word align the address */
|
|
||||||
ands r2, ip, #0x03 /* Get the bottom two bits */
|
|
||||||
bne .Lmemset_wordunaligned /* The address is not word aligned */
|
|
||||||
|
|
||||||
/* We are now word aligned */
|
|
||||||
.Lmemset_wordaligned:
|
|
||||||
#ifndef _BZERO
|
|
||||||
orr r3, r3, r3, lsl #8 /* Extend value to 16-bits */
|
|
||||||
#endif
|
|
||||||
#ifdef _ARM_ARCH_DWORD_OK
|
|
||||||
tst ip, #0x04 /* Quad-align for Xscale */
|
|
||||||
#else
|
|
||||||
cmp r1, #0x10
|
|
||||||
#endif
|
|
||||||
#ifndef _BZERO
|
|
||||||
orr r3, r3, r3, lsl #16 /* Extend value to 32-bits */
|
|
||||||
#endif
|
|
||||||
#ifdef _ARM_ARCH_DWORD_OK
|
|
||||||
subne r1, r1, #0x04 /* Quad-align if necessary */
|
|
||||||
strne r3, [ip], #0x04
|
|
||||||
cmp r1, #0x10
|
|
||||||
#endif
|
|
||||||
blt .Lmemset_loop4 /* If less than 16 then use words */
|
|
||||||
mov r2, r3 /* Duplicate data */
|
|
||||||
cmp r1, #0x80 /* If < 128 then skip the big loop */
|
|
||||||
blt .Lmemset_loop32
|
|
||||||
|
|
||||||
/* Do 128 bytes at a time */
|
|
||||||
.Lmemset_loop128:
|
|
||||||
subs r1, r1, #0x80
|
|
||||||
#ifdef _ARM_ARCH_DWORD_OK
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
#else
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
#endif
|
|
||||||
bgt .Lmemset_loop128
|
|
||||||
#if defined(__minix)
|
|
||||||
moveq r0, #0
|
|
||||||
#endif
|
|
||||||
RETc(eq) /* Zero length so just exit */
|
|
||||||
|
|
||||||
add r1, r1, #0x80 /* Adjust for extra sub */
|
|
||||||
|
|
||||||
/* Do 32 bytes at a time */
|
|
||||||
.Lmemset_loop32:
|
|
||||||
subs r1, r1, #0x20
|
|
||||||
#ifdef _ARM_ARCH_DWORD_OK
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
#else
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
#endif
|
|
||||||
bgt .Lmemset_loop32
|
|
||||||
#if defined(__minix)
|
|
||||||
moveq r0, #0
|
|
||||||
#endif
|
|
||||||
RETc(eq) /* Zero length so just exit */
|
|
||||||
|
|
||||||
adds r1, r1, #0x10 /* Partially adjust for extra sub */
|
|
||||||
|
|
||||||
/* Deal with 16 bytes or more */
|
|
||||||
#ifdef _ARM_ARCH_DWORD_OK
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
strdge r2, r3, [ip], #0x08
|
|
||||||
#else
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
stmiage ip!, {r2-r3}
|
|
||||||
#endif
|
|
||||||
#if defined(__minix)
|
|
||||||
moveq r0, #0
|
|
||||||
#endif
|
|
||||||
RETc(eq) /* Zero length so just exit */
|
|
||||||
|
|
||||||
addlt r1, r1, #0x10 /* Possibly adjust for extra sub */
|
|
||||||
|
|
||||||
/* We have at least 4 bytes so copy as words */
|
|
||||||
.Lmemset_loop4:
|
|
||||||
subs r1, r1, #0x04
|
|
||||||
strge r3, [ip], #0x04
|
|
||||||
bgt .Lmemset_loop4
|
|
||||||
#if defined(__minix)
|
|
||||||
moveq r0, #0
|
|
||||||
#endif
|
|
||||||
RETc(eq) /* Zero length so just exit */
|
|
||||||
|
|
||||||
#ifdef _ARM_ARCH_DWORD_OK
|
|
||||||
/* Compensate for 64-bit alignment check */
|
|
||||||
adds r1, r1, #0x04
|
|
||||||
#if defined(__minix)
|
|
||||||
moveq r0, #0
|
|
||||||
#endif
|
|
||||||
RETc(eq)
|
|
||||||
cmp r1, #2
|
|
||||||
#else
|
|
||||||
cmp r1, #-2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
strb r3, [ip], #0x01 /* Set 1 byte */
|
|
||||||
strbge r3, [ip], #0x01 /* Set another byte */
|
|
||||||
strbgt r3, [ip] /* and a third */
|
|
||||||
#if defined(__minix)
|
|
||||||
mov r0, #0
|
|
||||||
#endif
|
|
||||||
RET /* Exit */
|
|
||||||
|
|
||||||
.Lmemset_wordunaligned:
|
|
||||||
rsb r2, r2, #0x004
|
|
||||||
strb r3, [ip], #0x01 /* Set 1 byte */
|
|
||||||
cmp r2, #0x02
|
|
||||||
strbge r3, [ip], #0x01 /* Set another byte */
|
|
||||||
sub r1, r1, r2
|
|
||||||
strbgt r3, [ip], #0x01 /* and a third */
|
|
||||||
cmp r1, #0x04 /* More than 4 bytes left? */
|
|
||||||
bge .Lmemset_wordaligned /* Yup */
|
|
||||||
|
|
||||||
.Lmemset_lessthanfour:
|
|
||||||
cmp r1, #0x00
|
|
||||||
#if defined(__minix)
|
|
||||||
moveq r0, #0
|
|
||||||
#endif
|
|
||||||
RETc(eq) /* Zero length so exit */
|
|
||||||
strb r3, [ip], #0x01 /* Set 1 byte */
|
|
||||||
cmp r1, #0x02
|
|
||||||
strbge r3, [ip], #0x01 /* Set another byte */
|
|
||||||
strbgt r3, [ip] /* and a third */
|
|
||||||
#if defined(__minix)
|
|
||||||
mov r0, #0
|
|
||||||
#endif
|
|
||||||
RET /* Exit */
|
|
||||||
#ifdef _BZERO
|
|
||||||
END(bzero)
|
|
||||||
#else
|
|
||||||
#if !defined(__minix)
|
|
||||||
END(memset)
|
|
||||||
#else
|
|
||||||
END(phys_memset)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__minix)
|
|
||||||
LABEL(memset_fault) /* kernel can send us here */
|
|
||||||
mov r0, #0
|
|
||||||
RET
|
|
||||||
|
|
||||||
LABEL(memset_fault_in_kernel) /* kernel can send us here */
|
|
||||||
mrc p15, 0, r0, c6, c0, 0 /* Read DFAR */
|
|
||||||
RET
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
/* $NetBSD: poll.c,v 1.3 2008/04/29 05:46:08 martin Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Charles Blundell.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#include "namespace.h"
|
|
||||||
#include <lib.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/poll.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
poll(struct pollfd *p, nfds_t nfds, int timout)
|
|
||||||
{
|
|
||||||
fd_set rd, wr, except;
|
|
||||||
struct timeval tv;
|
|
||||||
nfds_t i;
|
|
||||||
int highfd, rval;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* select cannot tell us much wrt POLL*BAND, POLLPRI, POLLHUP or
|
|
||||||
* POLLNVAL.
|
|
||||||
*/
|
|
||||||
FD_ZERO(&rd);
|
|
||||||
FD_ZERO(&wr);
|
|
||||||
FD_ZERO(&except);
|
|
||||||
|
|
||||||
highfd = -1;
|
|
||||||
for (i = 0; i < nfds; i++) {
|
|
||||||
p[i].revents = 0;
|
|
||||||
if (p[i].fd < 0)
|
|
||||||
continue;
|
|
||||||
if (p[i].fd >= FD_SETSIZE) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (p[i].fd > highfd)
|
|
||||||
highfd = p[i].fd;
|
|
||||||
|
|
||||||
if (p[i].events & (POLLIN|POLLRDNORM))
|
|
||||||
FD_SET(p[i].fd, &rd);
|
|
||||||
if (p[i].events & (POLLOUT|POLLWRNORM|POLLWRBAND))
|
|
||||||
FD_SET(p[i].fd, &wr);
|
|
||||||
if (p[i].events & (POLLRDBAND|POLLPRI))
|
|
||||||
FD_SET(p[i].fd, &except);
|
|
||||||
}
|
|
||||||
|
|
||||||
tv.tv_sec = timout / 1000;
|
|
||||||
tv.tv_usec = (timout % 1000) * 1000;
|
|
||||||
|
|
||||||
rval = select(highfd + 1, &rd, &wr, &except,
|
|
||||||
timout == -1 ? NULL : &tv);
|
|
||||||
if (rval <= 0)
|
|
||||||
return rval;
|
|
||||||
|
|
||||||
rval = 0;
|
|
||||||
for (i = 0; i < nfds; i++) {
|
|
||||||
if (p[i].fd < 0)
|
|
||||||
continue;
|
|
||||||
if (FD_ISSET(p[i].fd, &rd))
|
|
||||||
p[i].revents |= p[i].events & (POLLIN|POLLRDNORM);
|
|
||||||
if (FD_ISSET(p[i].fd, &wr))
|
|
||||||
p[i].revents |=
|
|
||||||
p[i].events & (POLLOUT|POLLWRNORM|POLLWRBAND);
|
|
||||||
if (FD_ISSET(p[i].fd, &except))
|
|
||||||
p[i].revents |= p[i].events & (POLLRDBAND|POLLPRI);
|
|
||||||
/* XXX: POLLERR/POLLHUP/POLLNVAL? */
|
|
||||||
if (p[i].revents != 0)
|
|
||||||
rval++;
|
|
||||||
}
|
|
||||||
return rval;
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,287 +0,0 @@
|
||||||
/*
|
|
||||||
* Routines to maintain a decaying average of per-process CPU utilization, in a
|
|
||||||
* way that results in numbers that are (hopefully) similar to those produced
|
|
||||||
* by NetBSD. Once a second, NetBSD performs the following basic computation
|
|
||||||
* for each process:
|
|
||||||
*
|
|
||||||
* avg = ccpu * avg + (1 - ccpu) * (run / hz)
|
|
||||||
*
|
|
||||||
* In this formula, 'avg' is the running average, 'hz' is the number of clock
|
|
||||||
* ticks per second, 'run' is the number of ticks during which the process was
|
|
||||||
* found running in the last second, and 'ccpu' is a decay value chosen such
|
|
||||||
* that only 5% of the original average remains after 60 seconds: e**(-1/20).
|
|
||||||
*
|
|
||||||
* Here, the idea is that we update the average lazily, namely, only when the
|
|
||||||
* process is running when the kernel processes a clock tick - no matter how
|
|
||||||
* long it had not been running before that. The result is that at any given
|
|
||||||
* time, the average may be out of date. For that reason, this code is shared
|
|
||||||
* between the kernel and the MIB service: the latter occasionally obtains the
|
|
||||||
* raw kernel process table, for example because a user runs ps(1), and it then
|
|
||||||
* needs to bring the values up to date. The kernel could do that itself just
|
|
||||||
* before copying out the process table, but the MIB service is equally capable
|
|
||||||
* of doing it post-copy - while also being preemptible during the computation.
|
|
||||||
* There is more to be said about this, but the summary is that it is not clear
|
|
||||||
* which of the two options is better in practice. We simply chose this one.
|
|
||||||
*
|
|
||||||
* In addition, we deliberately delay updating the actual average by one
|
|
||||||
* second, keeping the last second's number of process run ticks in a separate
|
|
||||||
* variable 'last'. This allows us to produce an estimate of short-term
|
|
||||||
* activity of the process as well. We use this to generate a "CPU estimate"
|
|
||||||
* value. BSD generates such a value for the purpose of scheduling, but we
|
|
||||||
* have no actual use for that, and generating the value just for userland is
|
|
||||||
* a bit too costly in our case. Our inaccurate value should suffice for most
|
|
||||||
* practical purposes though (e.g., comparisons between active processes).
|
|
||||||
*
|
|
||||||
* Overall, in terms of overhead, our approach should produce the same values
|
|
||||||
* as NetBSD while having only the same overhead as NetBSD in the very worst
|
|
||||||
* case, and much less overhead on average. Even in the worst case, in our
|
|
||||||
* case, the computation is spread out across each second, rather than all done
|
|
||||||
* at once. In terms of implementation, since this code is running in the
|
|
||||||
* kernel, we make use of small tables of precomputed values, and we try to
|
|
||||||
* save on computation as much as possible. We copy much of the NetBSD
|
|
||||||
* approach of avoiding divisions using FSCALE.
|
|
||||||
*
|
|
||||||
* Another difference with NetBSD is that our kernel does not actually call
|
|
||||||
* this function from its clock interrupt handler, but rather when a process
|
|
||||||
* has spent a number of CPU cycles that adds up to one clock tick worth of
|
|
||||||
* execution time. The result is better accuracy (no process can escape
|
|
||||||
* accounting by yielding just before each clock interrupt), but due to the
|
|
||||||
* inaccuracy of converting CPU cycles to clock ticks, a process may end up
|
|
||||||
* using more than 'hz' clock ticks per second. We could correct for this;
|
|
||||||
* however, it has not yet shown to be a problem.
|
|
||||||
*
|
|
||||||
* Zooming out a bit again, the current average is fairly accurate but not
|
|
||||||
* very precise. There are two reasons for this. First, the accounting is in
|
|
||||||
* clock tick fractions, which means that a per-second CPU usage below 1/hz
|
|
||||||
* cannot be measured. Second, the NetBSD FSCALE and ccpu values are such that
|
|
||||||
* (FSCALE - ccpu) equals 100, which means that a per-second CPU usage below
|
|
||||||
* 1/100 cannot be measured either. Both issues can be resolved by switching
|
|
||||||
* to a CPU cycle based accounting approach, which requires 64-bit arithmetic
|
|
||||||
* and a MINIX3-specific FSCALE value. For now, this is just not worth doing.
|
|
||||||
*
|
|
||||||
* Finally, it should be noted that in terms of overall operating system
|
|
||||||
* functionality, the CPU averages feature is entirely optional; as of writing,
|
|
||||||
* the produced values are only used in the output of utilities such as ps(1).
|
|
||||||
* If computing the CPU average becomes too burdensome in terms of either
|
|
||||||
* performance or maintenance, it can simply be removed again.
|
|
||||||
*
|
|
||||||
* Original author: David van Moolenbroek <david@minix3.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sysutil.h"
|
|
||||||
#include <sys/param.h>
|
|
||||||
|
|
||||||
#define CCPUTAB_SHIFT 3 /* 2**3 == 8 */
|
|
||||||
#define CCPUTAB_MASK ((1 << CCPUTAB_SHIFT) - 1)
|
|
||||||
|
|
||||||
#define F(n) ((uint32_t)((n) * FSCALE))
|
|
||||||
|
|
||||||
/* e**(-1/20*n)*FSCALE for n=1..(2**CCPUTAB_SHIFT-1) */
|
|
||||||
static const uint32_t ccpu_low[CCPUTAB_MASK] = {
|
|
||||||
F(0.951229424501), F(0.904837418036), F(0.860707976425),
|
|
||||||
F(0.818730753078), F(0.778800783071), F(0.740818220682),
|
|
||||||
F(0.704688089719)
|
|
||||||
};
|
|
||||||
#define ccpu (ccpu_low[0])
|
|
||||||
|
|
||||||
/* e**(-1/20*8*n)*FSCALE for n=1.. until the value is zero (for FSCALE=2048) */
|
|
||||||
static const uint32_t ccpu_high[] = {
|
|
||||||
F(0.670320046036), F(0.449328964117), F(0.301194211912),
|
|
||||||
F(0.201896517995), F(0.135335283237), F(0.090717953289),
|
|
||||||
F(0.060810062625), F(0.040762203978), F(0.027323722447),
|
|
||||||
F(0.018315638889), F(0.012277339903), F(0.008229747049),
|
|
||||||
F(0.005516564421), F(0.003697863716), F(0.002478752177),
|
|
||||||
F(0.001661557273), F(0.001113775148), F(0.000746585808),
|
|
||||||
F(0.000500451433)
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the per-process CPU average structure. To be called when the
|
|
||||||
* process is started, that is, as part of a fork call.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
cpuavg_init(struct cpuavg * ca)
|
|
||||||
{
|
|
||||||
|
|
||||||
ca->ca_base = 0;
|
|
||||||
ca->ca_run = 0;
|
|
||||||
ca->ca_last = 0;
|
|
||||||
ca->ca_avg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return a new CPU usage average value, resulting from decaying the old value
|
|
||||||
* by the given number of seconds, using the formula (avg * ccpu**secs).
|
|
||||||
* We use two-level lookup tables to limit the computational expense to two
|
|
||||||
* multiplications while keeping the tables themselves relatively small.
|
|
||||||
*/
|
|
||||||
static uint32_t
|
|
||||||
cpuavg_decay(uint32_t avg, uint32_t secs)
|
|
||||||
{
|
|
||||||
unsigned int slot;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The ccpu_high table is set up such that with the default FSCALE, the
|
|
||||||
* values of any array entries beyond the end would be zero. That is,
|
|
||||||
* the average would be decayed to a value that, if represented in
|
|
||||||
* FSCALE units, would be zero. Thus, if it has been that long ago
|
|
||||||
* that we updated the average, we can just reset it to zero.
|
|
||||||
*/
|
|
||||||
if (secs > (__arraycount(ccpu_high) << CCPUTAB_SHIFT))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (secs > CCPUTAB_MASK) {
|
|
||||||
slot = (secs >> CCPUTAB_SHIFT) - 1;
|
|
||||||
|
|
||||||
avg = (ccpu_high[slot] * avg) >> FSHIFT; /* decay #3 */
|
|
||||||
|
|
||||||
secs &= CCPUTAB_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secs > 0)
|
|
||||||
avg = (ccpu_low[secs - 1] * avg) >> FSHIFT; /* decay #4 */
|
|
||||||
|
|
||||||
return avg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Update the CPU average value, either because the kernel is processing a
|
|
||||||
* clock tick, or because the MIB service updates obtained averages. We
|
|
||||||
* perform the decay in at most four computation steps (shown as "decay #n"),
|
|
||||||
* and thus, this algorithm is O(1).
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
cpuavg_update(struct cpuavg * ca, clock_t now, clock_t hz)
|
|
||||||
{
|
|
||||||
clock_t delta;
|
|
||||||
uint32_t secs;
|
|
||||||
|
|
||||||
delta = now - ca->ca_base;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If at least a second elapsed since we last updated the average, we
|
|
||||||
* must do so now. If not, we need not do anything for now.
|
|
||||||
*/
|
|
||||||
if (delta < hz)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decay the average by one second, and merge in the run fraction of
|
|
||||||
* the previous second, as though that second only just ended - even
|
|
||||||
* though the real time is at least one whole second ahead. By doing
|
|
||||||
* so, we roll the statistics time forward by one virtual second.
|
|
||||||
*/
|
|
||||||
ca->ca_avg = (ccpu * ca->ca_avg) >> FSHIFT; /* decay #1 */
|
|
||||||
ca->ca_avg += (FSCALE - ccpu) * (ca->ca_last / hz) >> FSHIFT;
|
|
||||||
|
|
||||||
ca->ca_last = ca->ca_run; /* move 'run' into 'last' */
|
|
||||||
ca->ca_run = 0;
|
|
||||||
|
|
||||||
ca->ca_base += hz; /* move forward by a second */
|
|
||||||
delta -= hz;
|
|
||||||
|
|
||||||
if (delta < hz)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* At least a whole second more elapsed since the start of the recorded
|
|
||||||
* second. That means that our current 'run' counter (now moved into
|
|
||||||
* 'last') is also outdated, and we need to merge it in as well, before
|
|
||||||
* performing the next decay steps.
|
|
||||||
*/
|
|
||||||
ca->ca_avg = (ccpu * ca->ca_avg) >> FSHIFT; /* decay #2 */
|
|
||||||
ca->ca_avg += (FSCALE - ccpu) * (ca->ca_last / hz) >> FSHIFT;
|
|
||||||
|
|
||||||
ca->ca_last = 0; /* 'run' is already zero now */
|
|
||||||
|
|
||||||
ca->ca_base += hz; /* move forward by a second */
|
|
||||||
delta -= hz;
|
|
||||||
|
|
||||||
if (delta < hz)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If additional whole seconds elapsed since the start of the last
|
|
||||||
* second slot, roll forward in time by that many whole seconds, thus
|
|
||||||
* decaying the value properly while maintaining alignment to whole-
|
|
||||||
* second slots. The decay takes up to another two computation steps.
|
|
||||||
*/
|
|
||||||
secs = delta / hz;
|
|
||||||
|
|
||||||
ca->ca_avg = cpuavg_decay(ca->ca_avg, secs);
|
|
||||||
|
|
||||||
ca->ca_base += secs * hz; /* move forward by whole seconds */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The clock ticked, and this last clock tick is accounted to the process for
|
|
||||||
* which the CPU average statistics are stored in 'ca'. Update the statistics
|
|
||||||
* accordingly, decaying the average as necessary. The current system uptime
|
|
||||||
* must be given as 'now', and the number of clock ticks per second must be
|
|
||||||
* given as 'hz'.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
cpuavg_increment(struct cpuavg * ca, clock_t now, clock_t hz)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (ca->ca_base == 0)
|
|
||||||
ca->ca_base = now;
|
|
||||||
else
|
|
||||||
cpuavg_update(ca, now, hz);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Register that the process was running at this clock tick. We could
|
|
||||||
* avoid one division above by precomputing (FSCALE/hz), but this is
|
|
||||||
* typically not a clean division and would therefore result in (more)
|
|
||||||
* loss of accuracy.
|
|
||||||
*/
|
|
||||||
ca->ca_run += FSCALE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve the decaying CPU utilization average (as return value), the number
|
|
||||||
* of CPU run ticks in the current second so far (stored in 'cpticks'), and an
|
|
||||||
* opaque CPU utilization estimate (stored in 'estcpu'). The caller must
|
|
||||||
* provide the CPU average structure ('ca_orig'), which will not be modified,
|
|
||||||
* as well as the current uptime in clock ticks ('now') and the number of clock
|
|
||||||
* ticks per second ('hz').
|
|
||||||
*/
|
|
||||||
uint32_t
|
|
||||||
cpuavg_getstats(const struct cpuavg * ca_orig, uint32_t * cpticks,
|
|
||||||
uint32_t * estcpu, clock_t now, clock_t hz)
|
|
||||||
{
|
|
||||||
struct cpuavg ca;
|
|
||||||
|
|
||||||
ca = *ca_orig;
|
|
||||||
|
|
||||||
/* Update the average as necessary. */
|
|
||||||
cpuavg_update(&ca, now, hz);
|
|
||||||
|
|
||||||
/* Merge the last second into the average. */
|
|
||||||
ca.ca_avg = (ccpu * ca.ca_avg) >> FSHIFT;
|
|
||||||
ca.ca_avg += (FSCALE - ccpu) * (ca.ca_last / hz) >> FSHIFT;
|
|
||||||
|
|
||||||
*cpticks = ca.ca_run >> FSHIFT;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In traditional BSD kernels, the 'estcpu' value determines a
|
|
||||||
* scheduling queue and decays to 10% in 5*(the current load average)
|
|
||||||
* seconds. MINIX reports the process's percentage of CPU usage in the
|
|
||||||
* last second instead, yielding a value in the range 0..100 with a
|
|
||||||
* decay of 100% after one second. This should be good enough for most
|
|
||||||
* practical purposes.
|
|
||||||
*/
|
|
||||||
*estcpu = (ca.ca_last / hz * 100) >> FSHIFT;
|
|
||||||
|
|
||||||
return ca.ca_avg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the ccpu decay value, in FSCALE units.
|
|
||||||
*/
|
|
||||||
uint32_t
|
|
||||||
cpuavg_getccpu(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
return ccpu;
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,77 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
cd $(dirname $0)
|
|
||||||
|
|
||||||
: ${NETBSDSRCDIR=${PWD}/../..}
|
|
||||||
: ${LLVMSRCDIR=${NETBSDSRCDIR}/external/bsd/llvm/dist}
|
|
||||||
: ${ARCH=i386}
|
|
||||||
: ${JOBS=1}
|
|
||||||
: ${OBJ_LLVM=${NETBSDSRCDIR}/../obj_llvm.${ARCH}}
|
|
||||||
: ${OBJ=${NETBSDSRCDIR}/../obj.${ARCH}}
|
|
||||||
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}
|
|
||||||
: ${MAKE=make}
|
|
||||||
|
|
||||||
echo ${NETBSDSRCDIR}
|
|
||||||
echo ${LLVMSRCDIR}
|
|
||||||
echo ${OBJ_LLVM}
|
|
||||||
echo ${OBJ}
|
|
||||||
echo ${CROSS_TOOLS}
|
|
||||||
|
|
||||||
# Retrieve all the GPL sources
|
|
||||||
cd ${NETBSDSRCDIR}
|
|
||||||
find . -name fetch.sh -exec '{}' \;
|
|
||||||
|
|
||||||
# Build LLVM manually
|
|
||||||
mkdir -p ${OBJ_LLVM}
|
|
||||||
cd ${OBJ_LLVM}
|
|
||||||
|
|
||||||
${LLVMSRCDIR}/llvm/configure \
|
|
||||||
--enable-targets=x86 \
|
|
||||||
--with-c-include-dirs=/usr/include/clang-3.6:/usr/include \
|
|
||||||
--disable-timestamps \
|
|
||||||
--prefix=/usr \
|
|
||||||
--sysconfdir=/etc/llvm \
|
|
||||||
--with-clang-srcdir=${LLVMSRCDIR}/clang \
|
|
||||||
--host=i586-elf32-minix \
|
|
||||||
--with-binutils-include=${NETBSDSRCDIR}/external/gpl3/binutils/dist/include \
|
|
||||||
--disable-debug-symbols \
|
|
||||||
--enable-assertions \
|
|
||||||
--enable-bindings=none \
|
|
||||||
llvm_cv_gnu_make_command=${MAKE} \
|
|
||||||
ac_cv_path_CIRCO="echo circo" \
|
|
||||||
ac_cv_path_DOT="echo dot" \
|
|
||||||
ac_cv_path_DOTTY="echo dotty" \
|
|
||||||
ac_cv_path_FDP="echo fdp" \
|
|
||||||
ac_cv_path_NEATO="echo neato" \
|
|
||||||
ac_cv_path_TWOPI="echo twopi" \
|
|
||||||
ac_cv_path_XDOT="echo xdot" \
|
|
||||||
--enable-optimized
|
|
||||||
|
|
||||||
${MAKE} -j ${JOBS}
|
|
||||||
|
|
||||||
# Copy the gold plugin where the NetBSD build system expects it.
|
|
||||||
mkdir -p ${NETBSDSRCDIR}/minix/llvm/bin/
|
|
||||||
cp ${OBJ_LLVM}/./Release+Asserts/lib/libLTO.so ${NETBSDSRCDIR}/minix/llvm/bin/
|
|
||||||
cp ${OBJ_LLVM}/./Release+Asserts/lib/LLVMgold.so ${NETBSDSRCDIR}/minix/llvm/bin/
|
|
||||||
|
|
||||||
# Copy useful LLVM tools
|
|
||||||
mkdir -p ${CROSS_TOOLS}
|
|
||||||
cp ${OBJ_LLVM}/./Release+Asserts/bin/llc ${CROSS_TOOLS}
|
|
||||||
cp ${OBJ_LLVM}/./Release+Asserts/bin/opt ${CROSS_TOOLS}
|
|
||||||
cp ${OBJ_LLVM}/./Release+Asserts/bin/llvm-* ${CROSS_TOOLS}
|
|
||||||
|
|
||||||
# Generate and Install default MINIX passes
|
|
||||||
cd ${NETBSDSRCDIR}/minix/llvm/passes/WeakAliasModuleOverride
|
|
||||||
${MAKE} install
|
|
||||||
|
|
||||||
cd ${NETBSDSRCDIR}/minix/llvm/passes/hello
|
|
||||||
${MAKE} install
|
|
||||||
|
|
||||||
cd ${NETBSDSRCDIR}/minix/llvm/passes/sectionify
|
|
||||||
${MAKE} install
|
|
||||||
|
|
||||||
cd ${NETBSDSRCDIR}/minix/llvm/passes/magic
|
|
||||||
${MAKE} install
|
|
||||||
|
|
||||||
cd ${NETBSDSRCDIR}/minix/llvm/passes/asr
|
|
||||||
${MAKE} install
|
|
||||||
|
|
@ -1,215 +0,0 @@
|
||||||
.\" $NetBSD: pkg_install.conf.5.in,v 1.14 2010/06/16 23:02:49 joerg Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
.\" by Thomas Klausner.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.Dd June 16, 2010
|
|
||||||
.Dt PKG_INSTALL.CONF 5
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm pkg_install.conf
|
|
||||||
.Nd configuration file for package installation tools
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The file
|
|
||||||
.Nm
|
|
||||||
contains system defaults for the package installation tools
|
|
||||||
as a list of variable-value pairs.
|
|
||||||
Each line has the format
|
|
||||||
.Ev VARIABLE=VALUE .
|
|
||||||
If the value consists of more than one line, each line is prefixed with
|
|
||||||
.Ev VARIABLE= .
|
|
||||||
.Pp
|
|
||||||
The current value of a variable can be checked by running
|
|
||||||
.Dl Ic pkg_admin config-var VARIABLE
|
|
||||||
.Pp
|
|
||||||
Some variables are overriden by environmental variables of the same name.
|
|
||||||
Those are marked by (*).
|
|
||||||
.Pp
|
|
||||||
The following variables are supported:
|
|
||||||
.Bl -tag -width indent
|
|
||||||
.It Dv ACCEPTABLE_LICENSES
|
|
||||||
List of licenses packages are allowed to carry.
|
|
||||||
License names are case-sensitive.
|
|
||||||
.It Dv ACTIVE_FTP
|
|
||||||
Force the use of active FTP.
|
|
||||||
.It Dv CACHE_INDEX
|
|
||||||
Cache directory listenings in memory.
|
|
||||||
This avoids retransfers of the large directory index for HTTP and is
|
|
||||||
enabled by default.
|
|
||||||
.It Dv CERTIFICATE_ANCHOR_PKGS
|
|
||||||
Path to the file containing the certificates used for validating
|
|
||||||
binary packages.
|
|
||||||
A package is trusted when a certificate chain ends in one of the
|
|
||||||
certificates contained in this file.
|
|
||||||
The certificates must be PEM-encoded.
|
|
||||||
.It Dv CERTIFICATE_ANCHOR_PKGVULN
|
|
||||||
Analogous to
|
|
||||||
.Dv CERTIFICATE_ANCHOR_PKGS .
|
|
||||||
The
|
|
||||||
.Pa pkg-vulnerabilities
|
|
||||||
is trusted when a certificate chain ends in one of the certificates
|
|
||||||
contained in this file.
|
|
||||||
.It Dv CERTIFICATE_CHAIN
|
|
||||||
Path to a file containing additional certificates that can be used
|
|
||||||
for completing certificate chains when validating binary packages or
|
|
||||||
pkg-vulnerabilities files.
|
|
||||||
.It Dv CHECK_LICENSE
|
|
||||||
Check the license conditions of packages before installing them.
|
|
||||||
Supported values are:
|
|
||||||
.Bl -tag -width interactiveXX
|
|
||||||
.It Dv no
|
|
||||||
The check is not performed.
|
|
||||||
.It Dv yes
|
|
||||||
The check is performed if the package has license conditions set.
|
|
||||||
.It Dv always
|
|
||||||
Passing the license check is required.
|
|
||||||
Missing license conditions are considered an error.
|
|
||||||
.El
|
|
||||||
.It Dv CHECK_END_OF_FILE
|
|
||||||
During vulnerability checks, consider packages that have reached end-of-life
|
|
||||||
as vulnerable.
|
|
||||||
This option is enabled by default.
|
|
||||||
.It Dv CHECK_VULNERABILITIES
|
|
||||||
Check for vulnerabilities when installing packages.
|
|
||||||
Supported values are:
|
|
||||||
.Bl -tag -width interactiveXX
|
|
||||||
.It Dv never
|
|
||||||
No check is performed.
|
|
||||||
.It Dv always
|
|
||||||
Passing the vulnerability check is required.
|
|
||||||
A missing pkg-vulnerabilities file is considered an error.
|
|
||||||
.It Dv interactive
|
|
||||||
The user is always asked to confirm installation of vulnerable packages.
|
|
||||||
.El
|
|
||||||
.It Dv CONFIG_CACHE_CONNECTIONS
|
|
||||||
Limit the global connection cache to this value.
|
|
||||||
For FTP this is the number of sessions without active command.
|
|
||||||
For HTTP this is the number of connections open with keep-alive.
|
|
||||||
.It Dv CONFIG_CACHE_CONNECTIONS_HOST
|
|
||||||
Like
|
|
||||||
.Dv CONFIG_CACHE_CONNECTIONS ,
|
|
||||||
but limit the number of connections to the host as well.
|
|
||||||
See
|
|
||||||
.Xr fetch 3
|
|
||||||
for further details
|
|
||||||
.It Dv DEFAULT_ACCEPTABLE_LICENSES
|
|
||||||
List of common Free and Open Source licenses packages are allowed to carry.
|
|
||||||
The default value contains all OSI approved licenses in pkgsrc on the date
|
|
||||||
pkg_install was released.
|
|
||||||
License names are case-sensitive.
|
|
||||||
.It Dv GPG
|
|
||||||
Path to
|
|
||||||
.Xr gpg 1 ,
|
|
||||||
which can be used to verify the signature in the
|
|
||||||
.Pa pkg-vulnerabilities
|
|
||||||
file when running
|
|
||||||
.Dl Ic pkg_admin check-pkg-vulnerabilities -s
|
|
||||||
or
|
|
||||||
.Dl Ic pkg_admin fetch-pkg-vulnerabilities -s
|
|
||||||
It can also be used to verify and sign binary packages.
|
|
||||||
.It Dv GPG_KEYRING_PKGVULN
|
|
||||||
Non-default keyring to use for verifying GPG signatures of
|
|
||||||
.Pa pkg-vulnerabilities .
|
|
||||||
.It Dv GPG_KEYRING_SIGN
|
|
||||||
Non-default keyring to use for signing packages with GPG.
|
|
||||||
.It Dv GPG_KEYRING_VERIFY
|
|
||||||
Non-default keyring to use for verifying GPG signature of packages.
|
|
||||||
.It Dv GPG_SIGN_AS
|
|
||||||
User-id to use for signing packages.
|
|
||||||
.It Dv IGNORE_PROXY
|
|
||||||
Use direct connections and ignore
|
|
||||||
.Ev FTP_PROXY
|
|
||||||
and
|
|
||||||
.Ev HTTP_PROXY .
|
|
||||||
.It Dv IGNORE_URL
|
|
||||||
One line per advisory which should be ignored when running
|
|
||||||
.Dl Ic pkg_admin audit
|
|
||||||
The URL from the
|
|
||||||
.Pa pkg-vulnerabilities
|
|
||||||
file should be used as value.
|
|
||||||
.It Dv PKG_DBDIR (*)
|
|
||||||
Location of the packages database.
|
|
||||||
This option is always overriden by the argument of the
|
|
||||||
.Fl K
|
|
||||||
option.
|
|
||||||
.It Dv PKG_PATH (*)
|
|
||||||
Search path for packages.
|
|
||||||
The entries are separated by semicolon.
|
|
||||||
Each entry specifies a directory or URL to search for packages.
|
|
||||||
.It Dv PKG_REFCOUNT_DBDIR (*)
|
|
||||||
Location of the package reference counts database directory.
|
|
||||||
The default value is
|
|
||||||
.Pa ${PKG_DBDIR}.refcount .
|
|
||||||
.It Dv PKGVULNDIR
|
|
||||||
Directory name in which the
|
|
||||||
.Pa pkg-vulnerabilities
|
|
||||||
file resides.
|
|
||||||
Default is
|
|
||||||
.Pa ${PKG_DBDIR} .
|
|
||||||
.It Dv PKGVULNURL
|
|
||||||
URL which is used for updating the local
|
|
||||||
.Pa pkg-vulnerabilities
|
|
||||||
file when running
|
|
||||||
.Dl Ic pkg_admin fetch-pkg-vulnerabilities
|
|
||||||
The default location is ftp.minix3.org using HTTP.
|
|
||||||
.Em Note :
|
|
||||||
Usually, only the compression type should be changed.
|
|
||||||
Currently supported are uncompressed files and files compressed by
|
|
||||||
.Xr bzip2 1
|
|
||||||
.Pq Pa .bz2
|
|
||||||
or
|
|
||||||
.Xr gzip 1
|
|
||||||
.Pq Pa .gz .
|
|
||||||
.It Dv VERBOSE_NETIO
|
|
||||||
Log details of network IO to stderr.
|
|
||||||
.It Dv VERIFIED_INSTALLATION
|
|
||||||
Set trust level used when installation.
|
|
||||||
Supported values are:
|
|
||||||
.Bl -tag -width interactiveXX
|
|
||||||
.It Dv never
|
|
||||||
No signature checks are performed.
|
|
||||||
.It Dv always
|
|
||||||
A valid signature is required.
|
|
||||||
If the binary package can not be verified, the installation is terminated
|
|
||||||
.It Dv trusted
|
|
||||||
A valid signature is required.
|
|
||||||
If the binary package can not be verified, the user is asked interactively.
|
|
||||||
.It Dv interactive
|
|
||||||
The user is always asked interactively when installing a package.
|
|
||||||
.El
|
|
||||||
.El
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width ".Pa /etc/pkg_install.conf"
|
|
||||||
.It Pa /etc/pkg_install.conf
|
|
||||||
Default location for the file described in this manual page.
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr pkg_add 1 ,
|
|
||||||
.Xr pkg_admin 1
|
|
||||||
.Xr pkg_create 1 ,
|
|
||||||
.Xr pkg_delete 1 ,
|
|
||||||
.Xr pkg_info 1
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
||||||
.\" $NetBSD: pkg_summary.5,v 1.9 2009/05/02 16:14:37 reed Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 2006 The NetBSD Foundation
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. Neither the name of the NetBSD Foundation nor the names of its
|
|
||||||
.\" contributors may be used to endorse or promote products derived from
|
|
||||||
.\" this software without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION AND ITS CONTRIBUTORS
|
|
||||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
|
||||||
.\" NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
.\" FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
.\" SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
||||||
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.Dd April 11, 2009
|
|
||||||
.Dt PKG_SUMMARY 5
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm pkg_summary
|
|
||||||
.Nd summary of binary package repository
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The file
|
|
||||||
.Nm
|
|
||||||
contains information about each package in a binary package
|
|
||||||
repository as a list of variable-value pairs.
|
|
||||||
The variables describing different packages are separated by one empty
|
|
||||||
line.
|
|
||||||
Each line has the format
|
|
||||||
.Ev VARIABLE=VALUE .
|
|
||||||
If the value consists of more than one line, each line is prefixed with
|
|
||||||
.Ev VARIABLE= .
|
|
||||||
Multi-line variables are guaranteed to be in consecutive lines.
|
|
||||||
.Pp
|
|
||||||
The following variables are used:
|
|
||||||
.Bl -tag -width indent
|
|
||||||
.It Ev BUILD_DATE
|
|
||||||
(required) The date and time when the package was built.
|
|
||||||
.It Ev CATEGORIES
|
|
||||||
(required) A list of categories which this package fits in, separated by
|
|
||||||
space.
|
|
||||||
.It Ev COMMENT
|
|
||||||
(required) A one-line description of the package.
|
|
||||||
.It Ev CONFLICTS
|
|
||||||
(optional) A list of dewey patterns of packages the package conflicts
|
|
||||||
with, one per line.
|
|
||||||
If missing, this package has no conflicts.
|
|
||||||
.It Ev DEPENDS
|
|
||||||
(optional) A list of dewey patterns of packages the package depends
|
|
||||||
on, one per line.
|
|
||||||
If missing, this package has no dependencies.
|
|
||||||
.It Ev DESCRIPTION
|
|
||||||
(required) A more detailed description of the package.
|
|
||||||
.\" DIGEST
|
|
||||||
.It Ev FILE_NAME
|
|
||||||
(optional) The name of the binary package file.
|
|
||||||
If not given,
|
|
||||||
.Pa PKGNAME.tgz
|
|
||||||
can be assumed.
|
|
||||||
.It Ev FILE_SIZE
|
|
||||||
(optional) The size of the binary package file, in bytes.
|
|
||||||
.It Ev HOMEPAGE
|
|
||||||
(optional) A URL where more information about the package can be found.
|
|
||||||
.It Ev LICENSE
|
|
||||||
(optional) The type of license this package is distributed under.
|
|
||||||
If empty or missing, it is OSI-approved.
|
|
||||||
.It Ev MACHINE_ARCH
|
|
||||||
(required) The architecture on which the package was compiled.
|
|
||||||
.It Ev OPSYS
|
|
||||||
(required) The operating system on which the package was compiled.
|
|
||||||
.It Ev OS_VERSION
|
|
||||||
(required) The version of the operating system on which the package
|
|
||||||
was compiled.
|
|
||||||
.It Ev PKG_OPTIONS
|
|
||||||
(optional) Any options selected to compile this package.
|
|
||||||
If missing, the package does not support options.
|
|
||||||
.It Ev PKGNAME
|
|
||||||
(required) The name of the package.
|
|
||||||
.It Ev PKGPATH
|
|
||||||
(required) The path of the package directory within pkgsrc.
|
|
||||||
.It Ev PKGTOOLS_VERSION
|
|
||||||
(required) The version of the package tools used to create the package.
|
|
||||||
.It Ev PREV_PKGPATH
|
|
||||||
(optional) The previous path of the package directory within pkgsrc when
|
|
||||||
a package was moved.
|
|
||||||
(See
|
|
||||||
.Ev SUPERSEDES
|
|
||||||
below for a renamed package.)
|
|
||||||
.It Ev PROVIDES
|
|
||||||
(optional) A list of shared libraries provided by the package,
|
|
||||||
including major version number, one per line.
|
|
||||||
If missing, this package does not provide shared libraries.
|
|
||||||
.It Ev REQUIRES
|
|
||||||
(optional) A list of shared libraries needed by the package, including
|
|
||||||
major version number, one per line.
|
|
||||||
If missing, this package does not require shared libraries.
|
|
||||||
.It Ev SIZE_PKG
|
|
||||||
(required) The size of the package when installed, in bytes.
|
|
||||||
.It Ev SUPERSEDES
|
|
||||||
(optional) A list of dewey patterns of previous packages this
|
|
||||||
package replaces, one per line.
|
|
||||||
This is used for package renaming.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Nm pkg_summary
|
|
||||||
file can be generated using the
|
|
||||||
.Xr pkg_info 1
|
|
||||||
.Fl X
|
|
||||||
option.
|
|
||||||
For example, the following will list this data for all installed packages:
|
|
||||||
.Pp
|
|
||||||
.Dl "pkg_info -X -a"
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr pkg_info 1
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm pkg_summary
|
|
||||||
format was first officially documented in April 2006.
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
.\" $NetBSD: statvfs.5,v 1.10 2008/06/23 04:22:36 dholland Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1989, 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. Neither the name of the University nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" @(#)statfs.2 8.5 (Berkeley) 5/24/95
|
|
||||||
.\"
|
|
||||||
.Dd June 23, 2008
|
|
||||||
.Dt STATVFS 5
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm statvfs
|
|
||||||
.Nd file system statistics
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In sys/types.h
|
|
||||||
.In sys/statvfs.h
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Aq Pa sys/statvfs.h
|
|
||||||
header defines the structures and functions that
|
|
||||||
return information about a mounted file system.
|
|
||||||
The
|
|
||||||
.Nm statvfs
|
|
||||||
structure is defined as follows:
|
|
||||||
.Bd -literal
|
|
||||||
|
|
||||||
struct statvfs {
|
|
||||||
unsigned long f_bsize; /* system block size */
|
|
||||||
unsigned long f_frsize; /* system fragment size */
|
|
||||||
|
|
||||||
fsblkcnt_t f_blocks; /* number of blocks in file system */
|
|
||||||
fsblkcnt_t f_bfree; /* free blocks avail in file system */
|
|
||||||
fsblkcnt_t f_bavail; /* free blocks avail to non-root */
|
|
||||||
|
|
||||||
fsfilcnt_t f_files; /* total file nodes in file system */
|
|
||||||
fsfilcnt_t f_ffree; /* free file nodes in file system */
|
|
||||||
fsfilcnt_t f_favail; /* free file nodes avail to non-root */
|
|
||||||
|
|
||||||
unsigned long f_fsid; /* File system ID */
|
|
||||||
|
|
||||||
unsigned long f_flag; /* flags */
|
|
||||||
|
|
||||||
unsigned long f_namemax;/* maximum filename length */
|
|
||||||
};
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fa f_flag
|
|
||||||
argument can have the following bits set:
|
|
||||||
.Bl -tag -width ST_SYNCHRONOUS
|
|
||||||
.It Dv ST_RDONLY
|
|
||||||
The filesystem is mounted read-only;
|
|
||||||
Even the super-user may not write on it.
|
|
||||||
.It Dv ST_NOSUID
|
|
||||||
Setuid and setgid bits on files are not honored when they are executed.
|
|
||||||
.It Dv ST_NOTRUNC
|
|
||||||
File names longer than NAME_MAX are not truncated.
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr statvfs 2
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Aq Pa sys/statvfs.h
|
|
||||||
header first appeared in
|
|
||||||
.Nx 3.0 .
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
.\" $NetBSD: pkgsrc.7,v 1.2 2007/10/07 12:59:14 kano Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
.\" by Thomas Klausner.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.Dd March 2, 2007
|
|
||||||
.Dt PKGSRC 7
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm pkgsrc
|
|
||||||
.Nd MINIX packages collection (framework for third-party software)
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.The
|
|
||||||
.Mx
|
|
||||||
Packages Collection (pkgsrc) is a framework for building and
|
|
||||||
maintaining third-party software on
|
|
||||||
.Mx
|
|
||||||
and other
|
|
||||||
.Ux Ns -like
|
|
||||||
systems.
|
|
||||||
It is used to enable freely available software to be configured
|
|
||||||
and built easily on supported platforms.
|
|
||||||
.Pp
|
|
||||||
Tools are available to install ready-to-use packages and to perform
|
|
||||||
various administrative tasks for the package system.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr pkg_add 1 ,
|
|
||||||
.Xr pkg_delete 1 ,
|
|
||||||
.Xr pkg_info 1 ,
|
|
||||||
.Pa https://wiki.minix3.org/doku.php?id=developersguide:pkgsrc
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
/* $NetBSD: h_spawn.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Charles Zhang <charles@NetBSD.org> and
|
|
||||||
* Martin Husemann <martin@NetBSD.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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
unsigned long ret;
|
|
||||||
char *endp;
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "usage:\n\t%s (retcode)\n", getprogname());
|
|
||||||
exit(255);
|
|
||||||
}
|
|
||||||
ret = strtoul(argv[1], &endp, 10);
|
|
||||||
#if DEBUG
|
|
||||||
fprintf(stderr, "%s exiting with status %lu\n", getprogname(), ret);
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
/* $NetBSD: h_spawnattr.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Charles Zhang <charles@NetBSD.org> and
|
|
||||||
* Martin Husemann <martin@NetBSD.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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Helper to test the hardcoded assumptions from t_spawnattr.c
|
|
||||||
* Exit with apropriate exit status and print diagnostics to
|
|
||||||
* stderr explaining what is wrong.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int parent_pipe, res = EXIT_SUCCESS;
|
|
||||||
sigset_t sig;
|
|
||||||
struct sigaction act;
|
|
||||||
ssize_t rd;
|
|
||||||
char tmp;
|
|
||||||
|
|
||||||
sigemptyset(&sig);
|
|
||||||
if (sigprocmask(0, NULL, &sig) < 0) {
|
|
||||||
fprintf(stderr, "%s: sigprocmask error\n", getprogname());
|
|
||||||
res = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
if (!sigismember(&sig, SIGUSR1)) {
|
|
||||||
fprintf(stderr, "%s: SIGUSR not in procmask\n", getprogname());
|
|
||||||
res = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
if (sigaction(SIGUSR1, NULL, &act) < 0) {
|
|
||||||
fprintf(stderr, "%s: sigaction error\n", getprogname());
|
|
||||||
res = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
if (act.sa_sigaction != (void *)SIG_DFL) {
|
|
||||||
fprintf(stderr, "%s: SIGUSR1 action != SIG_DFL\n",
|
|
||||||
getprogname());
|
|
||||||
res = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc >= 2) {
|
|
||||||
parent_pipe = atoi(argv[1]);
|
|
||||||
if (parent_pipe > 2) {
|
|
||||||
#if DEBUG
|
|
||||||
printf("%s: waiting for command from parent on pipe "
|
|
||||||
"%d\n", getprogname(), parent_pipe);
|
|
||||||
#endif
|
|
||||||
rd = read(parent_pipe, &tmp, 1);
|
|
||||||
if (rd == 1) {
|
|
||||||
#if DEBUG
|
|
||||||
printf("%s: got command %c from parent\n",
|
|
||||||
getprogname(), tmp);
|
|
||||||
#endif
|
|
||||||
} else if (rd == -1) {
|
|
||||||
printf("%s: %d is no pipe, errno %d\n",
|
|
||||||
getprogname(), parent_pipe, errno);
|
|
||||||
res = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
@ -1,607 +0,0 @@
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int max_error = 3;
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#define err() e(__LINE__)
|
|
||||||
|
|
||||||
static void printstr(const char *s)
|
|
||||||
{
|
|
||||||
if (s)
|
|
||||||
printf("\"%s\"", s);
|
|
||||||
else
|
|
||||||
printf("NULL");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_getaddrinfo_err(
|
|
||||||
int n,
|
|
||||||
const char *nodename,
|
|
||||||
const char *servname,
|
|
||||||
int passhints,
|
|
||||||
int flags,
|
|
||||||
int family,
|
|
||||||
int socktype,
|
|
||||||
const char *exp_result,
|
|
||||||
const char *result)
|
|
||||||
{
|
|
||||||
printf("error %d: getaddrinfo(", n);
|
|
||||||
printstr(nodename);
|
|
||||||
printf(", ");
|
|
||||||
printstr(servname);
|
|
||||||
printf(", ");
|
|
||||||
if (passhints)
|
|
||||||
printf("{ 0x%x, %d, %d }", flags, family, socktype);
|
|
||||||
else
|
|
||||||
printf("NULL");
|
|
||||||
|
|
||||||
printf("); result: ");
|
|
||||||
printstr(result);
|
|
||||||
printf("; expected: ");
|
|
||||||
printstr(exp_result);
|
|
||||||
printf("\n");
|
|
||||||
err();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* yes, this is ugly, but not as ugly as repeating it all every time */
|
|
||||||
#define TEST_GETADDRINFO_ERR_PARAMS \
|
|
||||||
nodename, servname, passhints, flags, family, socktype
|
|
||||||
|
|
||||||
static void test_getaddrinfo_err_nr(
|
|
||||||
int n,
|
|
||||||
const char *nodename,
|
|
||||||
const char *servname,
|
|
||||||
int passhints,
|
|
||||||
int flags,
|
|
||||||
int family,
|
|
||||||
int socktype,
|
|
||||||
int exp_result,
|
|
||||||
int result)
|
|
||||||
{
|
|
||||||
char exp_result_s[23], result_s[23];
|
|
||||||
|
|
||||||
/* convert result to string */
|
|
||||||
snprintf(exp_result_s, sizeof(exp_result_s), "%d/0x%x",
|
|
||||||
exp_result, exp_result);
|
|
||||||
snprintf(result_s, sizeof(result_s), "%d/0x%x", result, result);
|
|
||||||
test_getaddrinfo_err(n, TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
exp_result_s, result_s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_getnameinfo_err(
|
|
||||||
int n,
|
|
||||||
unsigned long ipaddr,
|
|
||||||
unsigned short port,
|
|
||||||
socklen_t nodelen,
|
|
||||||
socklen_t servicelen,
|
|
||||||
int flags,
|
|
||||||
const char *exp_result,
|
|
||||||
const char *result)
|
|
||||||
{
|
|
||||||
printf("error %d: getnameinfo(0x%.8x, %d, %d, %d, 0x%x); result: ",
|
|
||||||
n, ntohl(ipaddr), ntohs(port), nodelen, servicelen, flags);
|
|
||||||
printstr(result);
|
|
||||||
printf("; expected: ");
|
|
||||||
printstr(exp_result);
|
|
||||||
printf("\n");
|
|
||||||
err();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* yes, this is ugly, but not as ugly as repeating it all every time */
|
|
||||||
#define TEST_GETNAMEINFO_ERR_PARAMS ipaddr, port, nodelen, servicelen, flags
|
|
||||||
|
|
||||||
static void test_getnameinfo_err_nr(
|
|
||||||
int n,
|
|
||||||
unsigned long ipaddr,
|
|
||||||
unsigned short port,
|
|
||||||
socklen_t nodelen,
|
|
||||||
socklen_t servicelen,
|
|
||||||
int flags,
|
|
||||||
int exp_result,
|
|
||||||
int result)
|
|
||||||
{
|
|
||||||
char exp_result_s[23], result_s[23];
|
|
||||||
|
|
||||||
/* convert result to string */
|
|
||||||
snprintf(exp_result_s, sizeof(exp_result_s), "%d/0x%x",
|
|
||||||
exp_result, exp_result);
|
|
||||||
snprintf(result_s, sizeof(result_s), "%d/0x%x", result, result);
|
|
||||||
test_getnameinfo_err(n, TEST_GETNAMEINFO_ERR_PARAMS,
|
|
||||||
exp_result_s, result_s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_getaddrinfo(
|
|
||||||
const char *nodename,
|
|
||||||
int nodename_numerical,
|
|
||||||
const char *servname,
|
|
||||||
int servname_numerical,
|
|
||||||
int passhints,
|
|
||||||
int flags,
|
|
||||||
int family,
|
|
||||||
int socktype,
|
|
||||||
int exp_results,
|
|
||||||
unsigned long exp_ip,
|
|
||||||
int exp_canonname,
|
|
||||||
unsigned short exp_port)
|
|
||||||
{
|
|
||||||
struct addrinfo *ai, *ai_cur;
|
|
||||||
struct addrinfo hints;
|
|
||||||
struct sockaddr_in *sockaddr_in;
|
|
||||||
int ai_count_dgram, ai_count_stream, r;
|
|
||||||
|
|
||||||
/* some parameters are only meaningful with hints */
|
|
||||||
assert(passhints || !flags);
|
|
||||||
assert(passhints || family == AF_UNSPEC);
|
|
||||||
assert(passhints || !socktype);
|
|
||||||
|
|
||||||
/* a combination of parameters don't make sense to test */
|
|
||||||
if (nodename == NULL && servname == NULL) return;
|
|
||||||
if (nodename == NULL && (flags & AI_NUMERICHOST)) return;
|
|
||||||
if (servname == NULL && (flags & AI_NUMERICSERV)) return;
|
|
||||||
|
|
||||||
/* initialize hints */
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
hints.ai_flags = flags;
|
|
||||||
hints.ai_family = family;
|
|
||||||
hints.ai_socktype = socktype;
|
|
||||||
|
|
||||||
/* perform query and test result */
|
|
||||||
ai = (struct addrinfo *) 0xDEADBEEF;
|
|
||||||
r = getaddrinfo(nodename, servname, passhints ? &hints : NULL, &ai);
|
|
||||||
if (r < 0 || r >= 32 || !((1 << r) & exp_results))
|
|
||||||
test_getaddrinfo_err_nr(1, TEST_GETADDRINFO_ERR_PARAMS, exp_results, r);
|
|
||||||
|
|
||||||
if (r)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* the function succeeded; do the results make sense? */
|
|
||||||
ai_cur = ai;
|
|
||||||
ai_count_dgram = 0;
|
|
||||||
ai_count_stream = 0;
|
|
||||||
while (ai_cur)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* TODO: this test was written for IPv4. For now, skip IPv6
|
|
||||||
* results altogether. Later, we should add additional code
|
|
||||||
* for IPv6. However, since this test now largely exercises
|
|
||||||
* NetBSD code, it is not as important as it once was.
|
|
||||||
*/
|
|
||||||
if (ai_cur->ai_family == AF_INET6) {
|
|
||||||
ai_cur = ai_cur->ai_next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* test result fields */
|
|
||||||
if (ai_cur->ai_family != AF_INET)
|
|
||||||
test_getaddrinfo_err_nr(2, TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
AF_INET, ai_cur->ai_family);
|
|
||||||
|
|
||||||
if (socktype && ai_cur->ai_socktype != socktype)
|
|
||||||
test_getaddrinfo_err_nr(3, TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
socktype, ai_cur->ai_socktype);
|
|
||||||
|
|
||||||
switch (ai_cur->ai_socktype)
|
|
||||||
{
|
|
||||||
case SOCK_DGRAM: ai_count_dgram++; break;
|
|
||||||
case SOCK_STREAM: ai_count_stream++; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do address and port match? */
|
|
||||||
if (ai_cur->ai_addrlen != sizeof(struct sockaddr_in))
|
|
||||||
test_getaddrinfo_err_nr(4, TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
sizeof(struct sockaddr_in),
|
|
||||||
ai_cur->ai_addrlen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sockaddr_in = (struct sockaddr_in *) ai_cur->ai_addr;
|
|
||||||
if (sockaddr_in->sin_addr.s_addr != exp_ip)
|
|
||||||
test_getaddrinfo_err_nr(5,
|
|
||||||
TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
ntohl(exp_ip),
|
|
||||||
ntohl(sockaddr_in->sin_addr.s_addr));
|
|
||||||
|
|
||||||
if (sockaddr_in->sin_port != exp_port)
|
|
||||||
test_getaddrinfo_err_nr(6,
|
|
||||||
TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
ntohs(exp_port),
|
|
||||||
ntohs(sockaddr_in->sin_port));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If a hostname is numeric, there can't be a canonical name.
|
|
||||||
* Instead, the returned canonname (if requested) will be
|
|
||||||
* identical to the supplied hostname */
|
|
||||||
if (nodename != NULL && nodename_numerical &&
|
|
||||||
(flags & AI_CANONNAME)) {
|
|
||||||
if (strncmp(ai_cur->ai_canonname, nodename,
|
|
||||||
strlen(nodename)))
|
|
||||||
test_getaddrinfo_err(11,
|
|
||||||
TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
nodename, ai_cur->ai_canonname);
|
|
||||||
} else {
|
|
||||||
/* is canonical supplied? */
|
|
||||||
if (exp_canonname && nodename &&
|
|
||||||
(!ai_cur->ai_canonname || !*ai_cur->ai_canonname))
|
|
||||||
test_getaddrinfo_err(7,
|
|
||||||
TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
"(anything)", ai_cur->ai_canonname);
|
|
||||||
|
|
||||||
if (!exp_canonname && ai_cur->ai_canonname)
|
|
||||||
test_getaddrinfo_err(8,
|
|
||||||
TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
NULL, ai_cur->ai_canonname);
|
|
||||||
|
|
||||||
}
|
|
||||||
/* move to next result */
|
|
||||||
ai_cur = ai_cur->ai_next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If socket type is non-zero, make sure we got what we wanted. Else
|
|
||||||
* any result is okay. */
|
|
||||||
if (socktype) {
|
|
||||||
if (ai_count_dgram != ((socktype == SOCK_STREAM) ? 0 : 1))
|
|
||||||
test_getaddrinfo_err_nr(9, TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
(socktype == SOCK_STREAM) ? 0 : 1, ai_count_dgram);
|
|
||||||
|
|
||||||
if (ai_count_stream != ((socktype == SOCK_DGRAM) ? 0 : 1))
|
|
||||||
test_getaddrinfo_err_nr(10, TEST_GETADDRINFO_ERR_PARAMS,
|
|
||||||
(socktype == SOCK_DGRAM) ? 0 : 1, ai_count_stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clean up */
|
|
||||||
freeaddrinfo(ai);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void memsetl(void *s, unsigned long c, size_t n)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *) s;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
p[i] = c >> (8 * (i % sizeof(c)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_getnameinfo(
|
|
||||||
unsigned long ipaddr,
|
|
||||||
unsigned short port,
|
|
||||||
const char *exp_node,
|
|
||||||
socklen_t nodelen,
|
|
||||||
const char *exp_service,
|
|
||||||
socklen_t servicelen,
|
|
||||||
int flags,
|
|
||||||
int exp_results)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sockaddr;
|
|
||||||
char node[256], service[256];
|
|
||||||
int r;
|
|
||||||
|
|
||||||
/* avoid buffer overflows */
|
|
||||||
assert(nodelen <= sizeof(node));
|
|
||||||
assert(servicelen <= sizeof(service));
|
|
||||||
|
|
||||||
/* perform query and test result */
|
|
||||||
sockaddr.sin_family = AF_INET;
|
|
||||||
sockaddr.sin_addr.s_addr = ipaddr;
|
|
||||||
sockaddr.sin_port = port;
|
|
||||||
memsetl(node, 0xDEADBEEF, nodelen);
|
|
||||||
memsetl(service, 0xDEADBEEF, servicelen);
|
|
||||||
r = getnameinfo((struct sockaddr *) &sockaddr, sizeof(sockaddr),
|
|
||||||
node, nodelen, service, servicelen, flags);
|
|
||||||
|
|
||||||
if (r < 0 || r >= 32 || !((1 << r) & exp_results))
|
|
||||||
test_getnameinfo_err_nr(1, TEST_GETNAMEINFO_ERR_PARAMS,
|
|
||||||
exp_results, r);
|
|
||||||
|
|
||||||
if (r)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* check results */
|
|
||||||
if (nodelen && strcmp(exp_node, node) != 0)
|
|
||||||
test_getnameinfo_err(2, TEST_GETNAMEINFO_ERR_PARAMS,
|
|
||||||
exp_node, node);
|
|
||||||
|
|
||||||
if (servicelen && strcmp(exp_service, service) != 0)
|
|
||||||
test_getnameinfo_err(2, TEST_GETNAMEINFO_ERR_PARAMS,
|
|
||||||
exp_service, service);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
const char *nodename;
|
|
||||||
unsigned long ipaddr;
|
|
||||||
int numeric;
|
|
||||||
int canonname;
|
|
||||||
int need_network;
|
|
||||||
int exp_result;
|
|
||||||
} hosts[] = {
|
|
||||||
{ NULL, 0x7f000001, 1, 1, 0, 0 },
|
|
||||||
{ "0.0.0.0", 0x00000000, 1, 0, 0, 0 },
|
|
||||||
{ "0.0.0.255", 0x000000ff, 1, 0, 0, 0 },
|
|
||||||
{ "0.0.255.0", 0x0000ff00, 1, 0, 0, 0 },
|
|
||||||
{ "0.255.0.0", 0x00ff0000, 1, 0, 0, 0 },
|
|
||||||
{ "255.0.0.0", 0xff000000, 1, 0, 0, 0 },
|
|
||||||
{ "127.0.0.1", 0x7f000001, 1, 0, 0, 0 },
|
|
||||||
{ "localhost", 0x7f000001, 0, 1, 0, 0, },
|
|
||||||
{ "test48.minix3.org", 0x7f010203, 0, 1, 1, 0, },
|
|
||||||
{ "minix3.example.com", 0x00000000, 0, 0, 1, (1<<EAI_NONAME)|(1<<EAI_FAIL)|(1<<EAI_NODATA)}};
|
|
||||||
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
const char *servname;
|
|
||||||
unsigned short port;
|
|
||||||
int numeric;
|
|
||||||
int socktype;
|
|
||||||
int exp_result;
|
|
||||||
} services[] = {
|
|
||||||
{ NULL, 0, 1, 0, 0 },
|
|
||||||
{ "0", 0, 1, 0, 0 },
|
|
||||||
{ "1", 1, 1, 0, 0 },
|
|
||||||
{ "32767", 32767, 1, 0, 0 },
|
|
||||||
{ "32768", 32768, 1, 0, 0 },
|
|
||||||
{ "65535", 65535, 1, 0, 0 },
|
|
||||||
{ "echo", 7, 0, 0, 0 },
|
|
||||||
{ "ftp", 21, 0, 0, 0 },
|
|
||||||
{ "tftp", 69, 0, 0, 0 },
|
|
||||||
{ "-1", 0, 1, 0, (1<<EAI_NONAME) | (1<<EAI_SERVICE) },
|
|
||||||
{ "", 0, 1, 0, (1<<EAI_NONAME) | (1<<EAI_SERVICE) },
|
|
||||||
{ "65537", 0, 1, 0, (1 << EAI_SERVICE) },
|
|
||||||
{ "XXX", 0, 0, 0, (1 << EAI_SERVICE) }};
|
|
||||||
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
int value;
|
|
||||||
int exp_result;
|
|
||||||
} families[] = {
|
|
||||||
{ AF_UNSPEC, 0 },
|
|
||||||
{ AF_INET, 0 },
|
|
||||||
{ AF_UNSPEC + AF_INET + 1, (1 << EAI_FAMILY) }};
|
|
||||||
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
int value;
|
|
||||||
int exp_result;
|
|
||||||
} socktypes[] = {
|
|
||||||
{ 0, 0 },
|
|
||||||
{ SOCK_STREAM, 0 },
|
|
||||||
{ SOCK_DGRAM, 0 },
|
|
||||||
{ SOCK_STREAM + SOCK_DGRAM + 1,
|
|
||||||
(1 << EAI_SOCKTYPE) | (1 << EAI_FAIL) | (1 << EAI_NONAME) }};
|
|
||||||
|
|
||||||
#define LENGTH(a) (sizeof((a)) / sizeof((a)[0]))
|
|
||||||
|
|
||||||
static void test_getaddrinfo_all(int use_network)
|
|
||||||
{
|
|
||||||
int flag_PASSIVE, flag_CANONNAME, flag_NUMERICHOST, flag_NUMERICSERV;
|
|
||||||
int exp_results, flags, flagcount, i, j, k, l, passhints;
|
|
||||||
unsigned long ipaddr;
|
|
||||||
|
|
||||||
/* loop through various parameter values */
|
|
||||||
for (i = 0; i < LENGTH(hosts); i++)
|
|
||||||
for (j = 0; j < LENGTH(services); j++)
|
|
||||||
for (k = 0; k < LENGTH(families); k++)
|
|
||||||
for (l = 0; l < LENGTH(socktypes); l++)
|
|
||||||
for (flag_PASSIVE = 0; flag_PASSIVE < 2; flag_PASSIVE++)
|
|
||||||
for (flag_CANONNAME = 0; flag_CANONNAME < 2; flag_CANONNAME++)
|
|
||||||
for (flag_NUMERICHOST = 0; flag_NUMERICHOST < 2; flag_NUMERICHOST++)
|
|
||||||
for (flag_NUMERICSERV = 0; flag_NUMERICSERV < 2; flag_NUMERICSERV++)
|
|
||||||
for (passhints = 0; passhints < 2; passhints++)
|
|
||||||
{
|
|
||||||
/* skip some redundant combinations */
|
|
||||||
flagcount = flag_PASSIVE + flag_CANONNAME +
|
|
||||||
flag_NUMERICHOST + flag_NUMERICSERV;
|
|
||||||
if (flagcount > 1 && flagcount < 4) continue;
|
|
||||||
|
|
||||||
/* skip tests that need but cannot use network */
|
|
||||||
if (!use_network && hosts[i].need_network)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* determine flags */
|
|
||||||
flags = (flag_PASSIVE ? AI_PASSIVE : 0) |
|
|
||||||
(flag_CANONNAME ? AI_CANONNAME : 0) |
|
|
||||||
(flag_NUMERICHOST ? AI_NUMERICHOST : 0) |
|
|
||||||
(flag_NUMERICSERV ? AI_NUMERICSERV : 0);
|
|
||||||
|
|
||||||
/* some options require hints */
|
|
||||||
if (families[k].value != AF_UNSPEC ||
|
|
||||||
socktypes[l].value != 0 || flags) {
|
|
||||||
passhints = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flags may influence IP address */
|
|
||||||
ipaddr = hosts[i].ipaddr;
|
|
||||||
if (!hosts[i].nodename && flag_PASSIVE)
|
|
||||||
ipaddr = INADDR_ANY;
|
|
||||||
|
|
||||||
/* determine expected result */
|
|
||||||
exp_results =
|
|
||||||
hosts[i].exp_result |
|
|
||||||
services[j].exp_result |
|
|
||||||
families[k].exp_result |
|
|
||||||
socktypes[l].exp_result;
|
|
||||||
if (!hosts[i].nodename && !services[j].servname)
|
|
||||||
exp_results |= (1 << EAI_NONAME);
|
|
||||||
|
|
||||||
if (flag_NUMERICHOST && !hosts[i].numeric)
|
|
||||||
exp_results |= (1 << EAI_NONAME);
|
|
||||||
|
|
||||||
if (flag_NUMERICSERV && !services[j].numeric)
|
|
||||||
exp_results |= (1 << EAI_NONAME);
|
|
||||||
|
|
||||||
/* When we don't pass hints, getaddrinfo will find suitable
|
|
||||||
* settings for us. If we do pass hints, there might be
|
|
||||||
* conflicts.
|
|
||||||
*/
|
|
||||||
if (passhints) {
|
|
||||||
/* Can't have conflicting socket types */
|
|
||||||
if (services[j].socktype &&
|
|
||||||
socktypes[l].value &&
|
|
||||||
socktypes[l].value != services[j].socktype) {
|
|
||||||
exp_results |= (1 << EAI_SERVICE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* with no reason for failure, we demand success */
|
|
||||||
if (!exp_results)
|
|
||||||
exp_results |= (1 << 0);
|
|
||||||
|
|
||||||
/* test getaddrinfo function */
|
|
||||||
test_getaddrinfo(
|
|
||||||
hosts[i].nodename,
|
|
||||||
hosts[i].numeric,
|
|
||||||
services[j].servname,
|
|
||||||
services[j].numeric,
|
|
||||||
passhints,
|
|
||||||
flags,
|
|
||||||
families[k].value,
|
|
||||||
socktypes[l].value,
|
|
||||||
exp_results,
|
|
||||||
htonl(ipaddr),
|
|
||||||
flag_CANONNAME && hosts[i].canonname,
|
|
||||||
htons(services[j].port));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
const char *nodename;
|
|
||||||
const char *nodenum;
|
|
||||||
unsigned long ipaddr;
|
|
||||||
int havename;
|
|
||||||
} ipaddrs[] = {
|
|
||||||
{ "0.0.0.0", "0.0.0.0", 0x00000000, 0 },
|
|
||||||
{ "0.0.0.255", "0.0.0.255", 0x000000ff, 0 },
|
|
||||||
{ "0.0.255.0", "0.0.255.0", 0x0000ff00, 0 },
|
|
||||||
{ "0.255.0.0", "0.255.0.0", 0x00ff0000, 0 },
|
|
||||||
{ "255.0.0.0", "255.0.0.0", 0xff000000, 0 },
|
|
||||||
{ "localhost", "127.0.0.1", 0x7f000001, 1 },
|
|
||||||
/* no reverse DNS unfortunately */
|
|
||||||
/* { "minix3.org", "130.37.20.20", 0x82251414, 1 } */};
|
|
||||||
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
const char *servname;
|
|
||||||
const char *servnum;
|
|
||||||
unsigned short port;
|
|
||||||
int socktype;
|
|
||||||
struct servent *se_tcp; /* getservbyport() s_name on this port with "tcp" */
|
|
||||||
struct servent *se_udp; /* getservbyport() s_name on this port with "udp" */
|
|
||||||
} ports[] = {
|
|
||||||
{ "0", "0", 0, 0 },
|
|
||||||
{ "tcpmux", "1", 1, SOCK_STREAM },
|
|
||||||
{ "32767", "32767", 32767, 0 },
|
|
||||||
{ "32768", "32768", 32768, 0 },
|
|
||||||
{ "65535", "65535", 65535, 0 },
|
|
||||||
{ "echo", "7", 7, 0 },
|
|
||||||
{ "ftp", "21", 21, SOCK_STREAM },
|
|
||||||
{ "tftp", "69", 69, SOCK_DGRAM }};
|
|
||||||
|
|
||||||
static int buflens[] = { 0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 255 };
|
|
||||||
|
|
||||||
static void test_getnameinfo_all(void)
|
|
||||||
{
|
|
||||||
int flag_NUMERICHOST, flag_NAMEREQD, flag_NUMERICSERV, flag_DGRAM;
|
|
||||||
int exp_results, flagcount, flags, i, j, k, l;
|
|
||||||
const char *nodename, *servname;
|
|
||||||
|
|
||||||
/* set ports servent structs */
|
|
||||||
for (j = 0; j < LENGTH(ports); j++) {
|
|
||||||
struct servent *se_tcp, *se_udp;
|
|
||||||
|
|
||||||
se_tcp = getservbyport(htons(ports[j].port), "tcp");
|
|
||||||
ports[j].se_tcp = se_tcp;
|
|
||||||
|
|
||||||
if(ports[j].se_tcp) {
|
|
||||||
ports[j].se_tcp = malloc(sizeof(struct servent));
|
|
||||||
memcpy(ports[j].se_tcp, se_tcp, sizeof(*se_tcp));
|
|
||||||
assert(ports[j].se_tcp->s_name);
|
|
||||||
ports[j].se_tcp->s_name = strdup(ports[j].se_tcp->s_name);
|
|
||||||
assert(ports[j].se_tcp->s_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
se_udp = getservbyport(htons(ports[j].port), "udp");
|
|
||||||
ports[j].se_udp = se_udp;
|
|
||||||
|
|
||||||
if(ports[j].se_udp) {
|
|
||||||
ports[j].se_udp = malloc(sizeof(struct servent));
|
|
||||||
memcpy(ports[j].se_udp, se_udp, sizeof(*se_udp));
|
|
||||||
assert(ports[j].se_udp->s_name);
|
|
||||||
ports[j].se_udp->s_name = strdup(ports[j].se_udp->s_name);
|
|
||||||
assert(ports[j].se_udp->s_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop through various parameter values */
|
|
||||||
for (i = 0; i < LENGTH(ipaddrs); i++)
|
|
||||||
for (j = 0; j < LENGTH(ports); j++)
|
|
||||||
for (k = 0; k < LENGTH(buflens); k++)
|
|
||||||
for (l = 0; l < LENGTH(buflens); l++)
|
|
||||||
for (flag_NUMERICHOST = 0; flag_NUMERICHOST < 2; flag_NUMERICHOST++)
|
|
||||||
for (flag_NAMEREQD = 0; flag_NAMEREQD < 2; flag_NAMEREQD++)
|
|
||||||
for (flag_NUMERICSERV = 0; flag_NUMERICSERV < 2; flag_NUMERICSERV++)
|
|
||||||
for (flag_DGRAM = 0; flag_DGRAM < 2; flag_DGRAM++)
|
|
||||||
{
|
|
||||||
/* skip some redundant combinations */
|
|
||||||
flagcount = flag_NUMERICHOST + flag_NAMEREQD +
|
|
||||||
flag_NUMERICSERV + flag_DGRAM;
|
|
||||||
if (flagcount > 1 && flagcount < 4) continue;
|
|
||||||
if (k > 1 && k < LENGTH(buflens) - 2 &&
|
|
||||||
l > 1 && l < LENGTH(buflens) - 2) continue;
|
|
||||||
|
|
||||||
/* determine flags */
|
|
||||||
flags = (flag_NUMERICHOST ? NI_NUMERICHOST : 0) |
|
|
||||||
(flag_NAMEREQD ? NI_NAMEREQD : 0) |
|
|
||||||
(flag_NUMERICSERV ? NI_NUMERICSERV : 0) |
|
|
||||||
(flag_DGRAM ? NI_DGRAM : 0);
|
|
||||||
|
|
||||||
/* determine expected result */
|
|
||||||
exp_results = 0;
|
|
||||||
|
|
||||||
nodename = flag_NUMERICHOST ? ipaddrs[i].nodenum : ipaddrs[i].nodename;
|
|
||||||
if (buflens[k] > 0 && buflens[k] <= strlen(nodename))
|
|
||||||
exp_results |= (1 << EAI_OVERFLOW) | (1 << EAI_MEMORY);
|
|
||||||
|
|
||||||
struct servent *se = flag_DGRAM ? ports[j].se_udp : ports[j].se_tcp;
|
|
||||||
|
|
||||||
servname = (flag_NUMERICSERV) ?
|
|
||||||
ports[j].servnum : (se ? se->s_name : ports[j].servname);
|
|
||||||
|
|
||||||
if (buflens[l] > 0 && buflens[l] <= strlen(servname))
|
|
||||||
exp_results |= (1 << EAI_OVERFLOW) | (1 << EAI_MEMORY);
|
|
||||||
|
|
||||||
if (flag_NAMEREQD && (!ipaddrs[i].havename || flag_NUMERICHOST) && buflens[k])
|
|
||||||
exp_results |= (1 << EAI_NONAME);
|
|
||||||
|
|
||||||
/* with no reason for failure, we demand success */
|
|
||||||
if (!exp_results)
|
|
||||||
exp_results |= (1 << 0);
|
|
||||||
|
|
||||||
/* perform the test */
|
|
||||||
test_getnameinfo(
|
|
||||||
htonl(ipaddrs[i].ipaddr),
|
|
||||||
htons(ports[j].port),
|
|
||||||
nodename,
|
|
||||||
buflens[k],
|
|
||||||
servname,
|
|
||||||
buflens[l],
|
|
||||||
flags,
|
|
||||||
exp_results);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int use_network;
|
|
||||||
|
|
||||||
start(48);
|
|
||||||
|
|
||||||
use_network = get_setting_use_network();
|
|
||||||
test_getaddrinfo_all(use_network);
|
|
||||||
test_getnameinfo_all();
|
|
||||||
|
|
||||||
quit();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
1733
minix/tests/test56.c
1733
minix/tests/test56.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,373 +0,0 @@
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/syslimits.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int max_error = 5;
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
|
|
||||||
void copy_subtests(void);
|
|
||||||
void test_pipe_cloexec(void);
|
|
||||||
void test_pipe_flag_setting(void);
|
|
||||||
void test_pipe_nonblock(void);
|
|
||||||
void test_pipe_normal(void);
|
|
||||||
void test_pipe_nosigpipe(void);
|
|
||||||
void alarm_handler(int sig);
|
|
||||||
void pipe_handler(int sig);
|
|
||||||
|
|
||||||
static int seen_pipe_signal = 0;
|
|
||||||
static int seen_alarm_signal = 0;
|
|
||||||
|
|
||||||
void
|
|
||||||
alarm_handler(int sig)
|
|
||||||
{
|
|
||||||
if (seen_pipe_signal == 0)
|
|
||||||
seen_pipe_signal = -1;
|
|
||||||
seen_alarm_signal = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
pipe_handler(int sig)
|
|
||||||
{
|
|
||||||
seen_pipe_signal = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
copy_subtests()
|
|
||||||
{
|
|
||||||
char *subtests[] = { "t68a", "t68b" };
|
|
||||||
char copy_cmd[8 + PATH_MAX + 1];
|
|
||||||
int i, no_tests;
|
|
||||||
|
|
||||||
no_tests = sizeof(subtests) / sizeof(char *);
|
|
||||||
|
|
||||||
for (i = 0; i < no_tests; i++) {
|
|
||||||
snprintf(copy_cmd, 8 + PATH_MAX, "cp ../%s .", subtests[i]);
|
|
||||||
system(copy_cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test_pipe_normal()
|
|
||||||
{
|
|
||||||
/* Verify pipe2 creates pipes that behave like a normal pipe */
|
|
||||||
|
|
||||||
int pipes[2];
|
|
||||||
char buf_in[1], buf_out[1];
|
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
subtest = 2;
|
|
||||||
|
|
||||||
if (pipe2(pipes, 0) != 0) e(1);
|
|
||||||
|
|
||||||
buf_out[0] = 'T';
|
|
||||||
if (write(pipes[1], buf_out, sizeof(buf_out)) != sizeof(buf_out)) e(2);
|
|
||||||
if (read(pipes[0], buf_in, sizeof(buf_in)) != sizeof(buf_in)) e(3);
|
|
||||||
if (buf_out[0] != buf_in[0]) e(4);
|
|
||||||
|
|
||||||
/* When we close the write end, reading should fail */
|
|
||||||
if (close(pipes[1]) != 0) e(5);
|
|
||||||
if (read(pipes[0], buf_in, sizeof(buf_in)) != 0) e(6);
|
|
||||||
|
|
||||||
/* Let's retry that experiment the other way around. Install a signal
|
|
||||||
* handler to catch SIGPIPE. Install an alarm handler to make sure
|
|
||||||
* this test finishes in finite time. */
|
|
||||||
if (pipe2(pipes, 0) != 0) e(7);
|
|
||||||
signal(SIGPIPE, pipe_handler);
|
|
||||||
signal(SIGALRM, alarm_handler);
|
|
||||||
seen_pipe_signal = 0;
|
|
||||||
seen_alarm_signal = 0;
|
|
||||||
alarm(1);
|
|
||||||
if (close(pipes[0]) != 0) e(8);
|
|
||||||
if (write(pipes[1], buf_out, sizeof(buf_out)) != -1) e(9);
|
|
||||||
while (seen_pipe_signal == 0)
|
|
||||||
;
|
|
||||||
if (seen_pipe_signal != 1) e(10);
|
|
||||||
if (close(pipes[1]) != 0) e(11);
|
|
||||||
|
|
||||||
/* Collect alarm signal */
|
|
||||||
while (seen_alarm_signal == 0)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (pipe2(pipes, 0) != 0) e(12);
|
|
||||||
|
|
||||||
/* Now fork and verify we can write to the pipe */
|
|
||||||
pid = fork();
|
|
||||||
if (pid < 0) e(13);
|
|
||||||
if (pid == 0) {
|
|
||||||
/* We're the child */
|
|
||||||
char fd_buf[2];
|
|
||||||
|
|
||||||
/* Verify we can still write a byte into the pipe */
|
|
||||||
if (write(pipes[1], buf_out, sizeof(buf_out)) != 1) e(14);
|
|
||||||
|
|
||||||
snprintf(fd_buf, sizeof(fd_buf), "%d", pipes[1]);
|
|
||||||
execl("./t68a", "t68a", fd_buf, NULL);
|
|
||||||
|
|
||||||
exit(1); /* Should not be reached */
|
|
||||||
} else {
|
|
||||||
/* We're the parent */
|
|
||||||
int result;
|
|
||||||
|
|
||||||
if (waitpid(pid, &result, 0) == -1) e(15);
|
|
||||||
if (WEXITSTATUS(result) != 0) e(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (close(pipes[0]) != 0) e(17);
|
|
||||||
if (close(pipes[1]) != 0) e(18);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test_pipe_cloexec()
|
|
||||||
{
|
|
||||||
/* Open a pipe with O_CLOEXEC */
|
|
||||||
int flags;
|
|
||||||
int pipes[2];
|
|
||||||
pid_t pid;
|
|
||||||
char buf_in[1], buf_out[1];
|
|
||||||
|
|
||||||
subtest = 3;
|
|
||||||
|
|
||||||
if (pipe2(pipes, O_CLOEXEC) != 0) e(1);
|
|
||||||
|
|
||||||
/* Verify O_CLOEXEC flag is set */
|
|
||||||
flags = fcntl(pipes[0], F_GETFD);
|
|
||||||
if (flags < 0) e(2);
|
|
||||||
if (!(flags & FD_CLOEXEC)) e(3);
|
|
||||||
|
|
||||||
pid = fork();
|
|
||||||
if (pid < 0) e(4);
|
|
||||||
if (pid == 0) {
|
|
||||||
/* We're the child */
|
|
||||||
char fd_buf[2];
|
|
||||||
|
|
||||||
/* Verify we can still write a byte into the pipe */
|
|
||||||
buf_in[0] = 0;
|
|
||||||
buf_out[0] = 'T';
|
|
||||||
if (write(pipes[1], buf_out, sizeof(buf_out)) != 1) e(5);
|
|
||||||
if (read(pipes[0], buf_in, sizeof(buf_in)) != 1) e(6);
|
|
||||||
if (buf_out[0] != buf_in[0]) e(7);
|
|
||||||
|
|
||||||
/* Verify FD_CLOEXEC flag is still set */
|
|
||||||
flags = fcntl(pipes[0], F_GETFD);
|
|
||||||
if (flags < 0) e(8);
|
|
||||||
if (!(flags & FD_CLOEXEC)) e(9);
|
|
||||||
|
|
||||||
snprintf(fd_buf, sizeof(fd_buf), "%d", pipes[0]);
|
|
||||||
execl("./t68b", "t68b", fd_buf, NULL);
|
|
||||||
|
|
||||||
exit(1); /* Should not be reached */
|
|
||||||
} else {
|
|
||||||
/* We're the parent */
|
|
||||||
int result;
|
|
||||||
|
|
||||||
if (waitpid(pid, &result, 0) == -1) e(10);
|
|
||||||
if (WEXITSTATUS(result) != 0) e(11);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Eventhough our child's pipe should've been closed upon exec, our
|
|
||||||
* pipe should still be functioning.
|
|
||||||
*/
|
|
||||||
buf_in[0] = 0;
|
|
||||||
buf_out[0] = 't';
|
|
||||||
if (write(pipes[1], buf_out, sizeof(buf_out)) != sizeof(buf_out)) e(12);
|
|
||||||
if (read(pipes[0], buf_in, sizeof(buf_in)) != sizeof(buf_in)) e(13);
|
|
||||||
if (buf_out[0] != buf_in[0]) e(14);
|
|
||||||
|
|
||||||
if (close(pipes[0]) != 0) e(15);
|
|
||||||
if (close(pipes[1]) != 0) e(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test_pipe_nonblock()
|
|
||||||
{
|
|
||||||
/* Open a pipe with O_NONBLOCK */
|
|
||||||
char *buf_in, *buf_out;
|
|
||||||
int pipes[2];
|
|
||||||
size_t pipe_size;
|
|
||||||
|
|
||||||
subtest = 4;
|
|
||||||
|
|
||||||
if (pipe2(pipes, O_NONBLOCK) != 0) e(1);
|
|
||||||
if ((pipe_size = fpathconf(pipes[0], _PC_PIPE_BUF)) == -1) e(2);
|
|
||||||
buf_in = calloc(2, pipe_size); /* Allocate twice the buffer size */
|
|
||||||
if (buf_in == NULL) e(3);
|
|
||||||
buf_out = calloc(2, pipe_size); /* Idem dito for output buffer */
|
|
||||||
if (buf_out == NULL) e(4);
|
|
||||||
|
|
||||||
/* According to POSIX, a pipe with O_NONBLOCK set shall never block.
|
|
||||||
* When we attempt to write PIPE_BUF or less bytes, and there is
|
|
||||||
* sufficient space available, write returns nbytes. Else write will
|
|
||||||
* return -1 and not transfer any data.
|
|
||||||
*/
|
|
||||||
if (write(pipes[1], buf_out, 1) != 1) e(5); /* Write 1 byte */
|
|
||||||
if (write(pipes[1], buf_out, pipe_size) != -1) e(6); /* Can't fit */
|
|
||||||
if (errno != EAGAIN) e(7);
|
|
||||||
|
|
||||||
/* When writing more than PIPE_BUF bytes and when at least 1 byte can
|
|
||||||
* be tranferred, return the number of bytes written. We've written 1
|
|
||||||
* byte, so there are PIPE_BUF - 1 bytes left. */
|
|
||||||
if (write(pipes[1], buf_out, pipe_size + 1) != pipe_size - 1) e(8);
|
|
||||||
|
|
||||||
/* Read out all data and try again. This time we should be able to
|
|
||||||
* write PIPE_BUF bytes. */
|
|
||||||
if (read(pipes[0], buf_in, pipe_size) != pipe_size) e(9);
|
|
||||||
if (read(pipes[0], buf_in, 1) != -1) e(10); /* Empty, can't read */
|
|
||||||
if (errno != EAGAIN) e(11);
|
|
||||||
if (write(pipes[1], buf_out, pipe_size + 1) != pipe_size) e(12);
|
|
||||||
if (close(pipes[0]) != 0) e(13);
|
|
||||||
if (close(pipes[1]) != 0) e(14);
|
|
||||||
free(buf_in);
|
|
||||||
free(buf_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test_pipe_nosigpipe(void)
|
|
||||||
{
|
|
||||||
/* Let's retry the writing to pipe without readers experiment. This time we set
|
|
||||||
* the O_NOSIGPIPE flag to prevent getting a signal. */
|
|
||||||
int pipes[2];
|
|
||||||
char buf_out[1];
|
|
||||||
|
|
||||||
subtest = 5;
|
|
||||||
|
|
||||||
if (pipe2(pipes, O_NOSIGPIPE) != 0) e(7);
|
|
||||||
signal(SIGPIPE, pipe_handler);
|
|
||||||
signal(SIGALRM, alarm_handler);
|
|
||||||
seen_pipe_signal = 0;
|
|
||||||
seen_alarm_signal = 0;
|
|
||||||
alarm(1);
|
|
||||||
if (close(pipes[0]) != 0) e(8);
|
|
||||||
if (write(pipes[1], buf_out, sizeof(buf_out)) != -1) e(9);
|
|
||||||
|
|
||||||
/* Collect alarm signal */
|
|
||||||
while (seen_alarm_signal == 0)
|
|
||||||
;
|
|
||||||
if (errno != EPIPE) e(10);
|
|
||||||
if (seen_pipe_signal != -1) e(11); /* Alarm sig handler set it to -1 */
|
|
||||||
if (close(pipes[1]) != 0) e(12);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test_pipe_flag_setting()
|
|
||||||
{
|
|
||||||
int pipes[2];
|
|
||||||
|
|
||||||
subtest = 1;
|
|
||||||
|
|
||||||
/* Create standard pipe with no flags and verify they're off */
|
|
||||||
if (pipe2(pipes, 0) != 0) e(1);
|
|
||||||
if (fcntl(pipes[0], F_GETFD) != 0) e(2);
|
|
||||||
if (fcntl(pipes[1], F_GETFD) != 0) e(3);
|
|
||||||
if (fcntl(pipes[0], F_GETFL) & O_NONBLOCK) e(4);
|
|
||||||
if (fcntl(pipes[1], F_GETFL) & O_NONBLOCK) e(5);
|
|
||||||
if (fcntl(pipes[0], F_GETNOSIGPIPE) != 0) e(6);
|
|
||||||
if (fcntl(pipes[1], F_GETNOSIGPIPE) != 0) e(7);
|
|
||||||
if (close(pipes[0]) != 0) e(8);
|
|
||||||
if (close(pipes[1]) != 0) e(9);
|
|
||||||
|
|
||||||
/* Create pipe with all flags and verify they're on */
|
|
||||||
if (pipe2(pipes, O_CLOEXEC|O_NONBLOCK|O_NOSIGPIPE) != 0) e(10);
|
|
||||||
if (fcntl(pipes[0], F_GETFD) != FD_CLOEXEC) e(11);
|
|
||||||
if (fcntl(pipes[1], F_GETFD) != FD_CLOEXEC) e(12);
|
|
||||||
if (!(fcntl(pipes[0], F_GETFL) & O_NONBLOCK)) e(13);
|
|
||||||
if (!(fcntl(pipes[1], F_GETFL) & O_NONBLOCK)) e(14);
|
|
||||||
if (fcntl(pipes[0], F_GETNOSIGPIPE) == 0) e(15);
|
|
||||||
if (fcntl(pipes[1], F_GETNOSIGPIPE) == 0) e(16);
|
|
||||||
if (fcntl(pipes[0], F_SETNOSIGPIPE, 0) != 0) e(17);
|
|
||||||
if (fcntl(pipes[0], F_GETNOSIGPIPE) != 0) e(18);
|
|
||||||
if (fcntl(pipes[0], F_SETNOSIGPIPE, 1) != 0) e(19);
|
|
||||||
if (fcntl(pipes[0], F_GETNOSIGPIPE) == 0) e(20);
|
|
||||||
if (close(pipes[0]) != 0) e(21);
|
|
||||||
if (close(pipes[1]) != 0) e(22);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Test the behavior of a large pipe write that achieves partial progress
|
|
||||||
* before the reader end is closed. The write call is expected to return EPIPE
|
|
||||||
* and generate a SIGPIPE signal, and otherwise leave the system in good order.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
test_pipe_partial_write(void)
|
|
||||||
{
|
|
||||||
char buf[PIPE_BUF + 2];
|
|
||||||
int pfd[2], status;
|
|
||||||
|
|
||||||
signal(SIGPIPE, pipe_handler);
|
|
||||||
|
|
||||||
if (pipe(pfd) < 0) e(1);
|
|
||||||
|
|
||||||
switch (fork()) {
|
|
||||||
case 0:
|
|
||||||
close(pfd[1]);
|
|
||||||
|
|
||||||
sleep(1); /* let the parent block on the write(2) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This one-byte read raises the question whether the write
|
|
||||||
* should return partial progress or not, since consumption of
|
|
||||||
* part of its data is now clearly visible. NetBSD chooses
|
|
||||||
* *not* to return partial progress, and MINIX3 follows suit.
|
|
||||||
*/
|
|
||||||
if (read(pfd[0], buf, 1) != 1) e(2);
|
|
||||||
|
|
||||||
sleep(1); /* let VFS retry satisfying the write(2) */
|
|
||||||
|
|
||||||
exit(errct); /* close the reader side of the pipe */
|
|
||||||
|
|
||||||
case -1:
|
|
||||||
e(3);
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(pfd[0]);
|
|
||||||
|
|
||||||
seen_pipe_signal = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following large write should block until the child exits, as
|
|
||||||
* that is when the read end closes, thus making eventual completion of
|
|
||||||
* the write impossible.
|
|
||||||
*/
|
|
||||||
if (write(pfd[1], buf, sizeof(buf)) != -1) e(4);
|
|
||||||
if (errno != EPIPE) e(5);
|
|
||||||
if (seen_pipe_signal != 1) e(6);
|
|
||||||
|
|
||||||
seen_pipe_signal = 0;
|
|
||||||
|
|
||||||
/* A subsequent write used to cause a system crash. */
|
|
||||||
if (write(pfd[1], buf, 1) != -1) e(7);
|
|
||||||
if (errno != EPIPE) e(8);
|
|
||||||
if (seen_pipe_signal != 1) e(9);
|
|
||||||
|
|
||||||
/* Clean up. */
|
|
||||||
close(pfd[1]);
|
|
||||||
|
|
||||||
if (wait(&status) <= 0) e(10);
|
|
||||||
if (!WIFEXITED(status)) e(11);
|
|
||||||
errct += WEXITSTATUS(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
start(68);
|
|
||||||
copy_subtests();
|
|
||||||
test_pipe_flag_setting();
|
|
||||||
test_pipe_normal();
|
|
||||||
test_pipe_cloexec();
|
|
||||||
test_pipe_nonblock();
|
|
||||||
test_pipe_nosigpipe();
|
|
||||||
test_pipe_partial_write();
|
|
||||||
quit();
|
|
||||||
return(-1); /* Unreachable */
|
|
||||||
}
|
|
||||||
|
|
||||||
1148
minix/tests/test77.c
1148
minix/tests/test77.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,335 +0,0 @@
|
||||||
/*
|
|
||||||
* Based off tests/lib/libc/gen/posix_spawn/t_spawn.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $NetBSD: t_spawn.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Charles Zhang <charles@NetBSD.org> and
|
|
||||||
* Martin Husemann <martin@NetBSD.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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <spawn.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
/* reroute stdout to /dev/null while returning another fd for the old stdout */
|
|
||||||
/* this is just for aesthetics: we don't want to see the output of 'ls' */
|
|
||||||
static int
|
|
||||||
sink_stdout(void)
|
|
||||||
{
|
|
||||||
int fd, fd2;
|
|
||||||
|
|
||||||
if ((fd = fcntl(1, F_DUPFD, 3)) == -1 || close(1) == -1) {
|
|
||||||
e(0);
|
|
||||||
quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd2 = open("/dev/null", O_WRONLY)) != 1) {
|
|
||||||
if (fd2 == -1 || dup2(fd2, 1) != 1) {
|
|
||||||
dup2(fd, 1);
|
|
||||||
e(0);
|
|
||||||
quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* restore stdout */
|
|
||||||
static void
|
|
||||||
restore_stdout(int fd)
|
|
||||||
{
|
|
||||||
|
|
||||||
dup2(fd, 1);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tests a simple posix_spawn executing /bin/ls */
|
|
||||||
static void
|
|
||||||
test_posix_spawn_ls(void)
|
|
||||||
{
|
|
||||||
char * const args[] = { "ls", "-la", NULL };
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "/bin/ls", NULL, NULL, args, NULL);
|
|
||||||
if (err != 0)
|
|
||||||
e(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tests a simple posix_spawnp executing ls via $PATH */
|
|
||||||
static void
|
|
||||||
test_posix_spawnp_ls(void)
|
|
||||||
{
|
|
||||||
char * const args[] = { "ls", "-la", NULL };
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = posix_spawnp(NULL, "ls", NULL, NULL, args, NULL);
|
|
||||||
if(err != 0)
|
|
||||||
e(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* posix_spawn a non existant binary */
|
|
||||||
static void
|
|
||||||
test_posix_spawn_missing(void)
|
|
||||||
{
|
|
||||||
char * const args[] = { "t84_h_nonexist", NULL };
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "../t84_h_nonexist", NULL, NULL, args, NULL);
|
|
||||||
if (err != ENOENT)
|
|
||||||
e(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* posix_spawn a script with non existing interpreter */
|
|
||||||
static void
|
|
||||||
test_posix_spawn_nonexec(void)
|
|
||||||
{
|
|
||||||
char * const args[] = { "t84_h_nonexec", NULL };
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "../t84_h_nonexec", NULL, NULL, args, NULL);
|
|
||||||
if (err != ENOENT)
|
|
||||||
e(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* posix_spawn a child and get it's return code */
|
|
||||||
static void
|
|
||||||
test_posix_spawn_child(void)
|
|
||||||
{
|
|
||||||
char * const args0[] = { "t84_h_spawn", "0", NULL };
|
|
||||||
char * const args1[] = { "t84_h_spawn", "1", NULL };
|
|
||||||
char * const args7[] = { "t84_h_spawn", "7", NULL };
|
|
||||||
int err, status;
|
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
err = posix_spawn(&pid, "../t84_h_spawn", NULL, NULL, args0, NULL);
|
|
||||||
if (err != 0 || pid < 1)
|
|
||||||
e(1);
|
|
||||||
waitpid(pid, &status, 0);
|
|
||||||
if (! (WIFEXITED(status) && WEXITSTATUS(status) == 0))
|
|
||||||
e(2);
|
|
||||||
|
|
||||||
err = posix_spawn(&pid, "../t84_h_spawn", NULL, NULL, args1, NULL);
|
|
||||||
if (err != 0 || pid < 1)
|
|
||||||
e(3);
|
|
||||||
waitpid(pid, &status, 0);
|
|
||||||
if (! (WIFEXITED(status) && WEXITSTATUS(status) == 1))
|
|
||||||
e(4);
|
|
||||||
|
|
||||||
err = posix_spawn(&pid, "../t84_h_spawn", NULL, NULL, args7, NULL);
|
|
||||||
if (err != 0 || pid < 1)
|
|
||||||
e(5);
|
|
||||||
waitpid(pid, &status, 0);
|
|
||||||
if (! (WIFEXITED(status) && WEXITSTATUS(status) == 7))
|
|
||||||
e(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* test spawn attributes */
|
|
||||||
static void
|
|
||||||
test_posix_spawnattr(void)
|
|
||||||
{
|
|
||||||
int pid, status, err, pfd[2];
|
|
||||||
char helper_arg[128];
|
|
||||||
char * const args[] = { "t84_h_spawnattr", helper_arg, NULL };
|
|
||||||
sigset_t sig;
|
|
||||||
posix_spawnattr_t attr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create a pipe to controll the child
|
|
||||||
*/
|
|
||||||
err = pipe(pfd);
|
|
||||||
if (err != 0)
|
|
||||||
e(1);
|
|
||||||
sprintf(helper_arg, "%d", pfd[0]);
|
|
||||||
|
|
||||||
posix_spawnattr_init(&attr);
|
|
||||||
|
|
||||||
sigemptyset(&sig);
|
|
||||||
sigaddset(&sig, SIGUSR1);
|
|
||||||
|
|
||||||
posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSCHEDULER |
|
|
||||||
POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETPGROUP |
|
|
||||||
POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF |
|
|
||||||
POSIX_SPAWN_SETSIGDEF);
|
|
||||||
posix_spawnattr_setpgroup(&attr, 0);
|
|
||||||
#if 0
|
|
||||||
posix_spawnattr_setschedparam(&attr, &sp);
|
|
||||||
posix_spawnattr_setschedpolicy(&attr, scheduler);
|
|
||||||
#endif
|
|
||||||
posix_spawnattr_setsigmask(&attr, &sig);
|
|
||||||
posix_spawnattr_setsigdefault(&attr, &sig);
|
|
||||||
|
|
||||||
err = posix_spawn(&pid, "../t84_h_spawnattr", NULL, &attr, args, NULL);
|
|
||||||
if (err != 0)
|
|
||||||
e(2);
|
|
||||||
|
|
||||||
/* ready, let child go */
|
|
||||||
write(pfd[1], "q", 1);
|
|
||||||
close(pfd[0]);
|
|
||||||
close(pfd[1]);
|
|
||||||
|
|
||||||
/* wait and check result from child */
|
|
||||||
waitpid(pid, &status, 0);
|
|
||||||
if (! (WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS))
|
|
||||||
e(3);
|
|
||||||
|
|
||||||
posix_spawnattr_destroy(&attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tests a simple posix_spawn executing /bin/ls with file actions */
|
|
||||||
static void
|
|
||||||
test_posix_spawn_file_actions(void)
|
|
||||||
{
|
|
||||||
char * const args[] = { "ls", "-la", NULL };
|
|
||||||
int err;
|
|
||||||
posix_spawn_file_actions_t file_actions;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Just do a bunch of random operations which should leave console
|
|
||||||
* output intact.
|
|
||||||
*/
|
|
||||||
posix_spawn_file_actions_init(&file_actions);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 3);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 4);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 6);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 5);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 3);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 4);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 6);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 5);
|
|
||||||
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 0);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 2);
|
|
||||||
posix_spawn_file_actions_addopen(&file_actions, 0, "/dev/null",
|
|
||||||
O_RDONLY, 0);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 2);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 1);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 2, 1);
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "/bin/ls", &file_actions, NULL, args, NULL);
|
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
|
||||||
|
|
||||||
if (err != 0)
|
|
||||||
e(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* tests failures with file actions */
|
|
||||||
static void
|
|
||||||
test_posix_spawn_file_actions_failures(void)
|
|
||||||
{
|
|
||||||
char * const args[] = { "ls", "-la", NULL };
|
|
||||||
int err, i;
|
|
||||||
posix_spawn_file_actions_t file_actions;
|
|
||||||
|
|
||||||
/* Test bogus open */
|
|
||||||
posix_spawn_file_actions_init(&file_actions);
|
|
||||||
posix_spawn_file_actions_addclose(&file_actions, 0);
|
|
||||||
posix_spawn_file_actions_addopen(&file_actions, 0, "t84_h_nonexist",
|
|
||||||
O_RDONLY, 0);
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "/bin/ls", &file_actions, NULL, args, NULL);
|
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
|
||||||
|
|
||||||
if (err == 0)
|
|
||||||
e(1);
|
|
||||||
|
|
||||||
/* Test bogus dup2 */
|
|
||||||
for (i = 3; i < 10; i++) {
|
|
||||||
posix_spawn_file_actions_init(&file_actions);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, i, i+1);
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "/bin/ls", &file_actions, NULL, args,
|
|
||||||
NULL);
|
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
|
||||||
|
|
||||||
if (err == 0)
|
|
||||||
e(i-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Test bogus exec with dup2 (to mess with the pipe error reporting in
|
|
||||||
* posix_spawn.c)
|
|
||||||
*/
|
|
||||||
posix_spawn_file_actions_init(&file_actions);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 3);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 4);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 6);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 5);
|
|
||||||
posix_spawn_file_actions_adddup2(&file_actions, 1, 7);
|
|
||||||
|
|
||||||
err = posix_spawn(NULL, "t84_h_nonexist", &file_actions, NULL, args,
|
|
||||||
NULL);
|
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
|
||||||
|
|
||||||
if (err == 0)
|
|
||||||
e(9);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
start(84);
|
|
||||||
|
|
||||||
subtest = 1;
|
|
||||||
fd = sink_stdout();
|
|
||||||
test_posix_spawn_ls();
|
|
||||||
test_posix_spawnp_ls();
|
|
||||||
restore_stdout(fd);
|
|
||||||
|
|
||||||
test_posix_spawn_missing();
|
|
||||||
test_posix_spawn_nonexec();
|
|
||||||
|
|
||||||
subtest = 2;
|
|
||||||
test_posix_spawn_child();
|
|
||||||
|
|
||||||
subtest = 3;
|
|
||||||
test_posix_spawnattr();
|
|
||||||
subtest = 4;
|
|
||||||
fd = sink_stdout();
|
|
||||||
test_posix_spawn_file_actions();
|
|
||||||
restore_stdout(fd);
|
|
||||||
subtest = 5;
|
|
||||||
test_posix_spawn_file_actions_failures();
|
|
||||||
|
|
||||||
/* TODO: Write/port more tests */
|
|
||||||
|
|
||||||
quit();
|
|
||||||
|
|
||||||
/* Not reached */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
3662
minix/tests/test87.c
3662
minix/tests/test87.c
File diff suppressed because it is too large
Load Diff
3011
minix/tests/test88.c
3011
minix/tests/test88.c
File diff suppressed because it is too large
Load Diff
4185
minix/tests/test90.c
4185
minix/tests/test90.c
File diff suppressed because it is too large
Load Diff
1735
minix/tests/test92.c
1735
minix/tests/test92.c
File diff suppressed because it is too large
Load Diff
2650
minix/tests/test94.c
2650
minix/tests/test94.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,232 +0,0 @@
|
||||||
|
|
||||||
#include "inc.h"
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
static char ioctlbuf[IOCPARM_MASK];
|
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char *(*name)(unsigned long);
|
|
||||||
int (*arg)(struct trace_proc *, unsigned long, void *, int);
|
|
||||||
int is_svrctl;
|
|
||||||
} ioctl_table[] = {
|
|
||||||
{ block_ioctl_name, block_ioctl_arg, FALSE },
|
|
||||||
{ char_ioctl_name, char_ioctl_arg, FALSE },
|
|
||||||
{ net_ioctl_name, net_ioctl_arg, FALSE },
|
|
||||||
{ svrctl_name, svrctl_arg, TRUE },
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print an IOCTL request code, and save certain values in the corresponding
|
|
||||||
* process structure in order to be able to print the IOCTL argument.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
put_ioctl_req(struct trace_proc * proc, const char * name, unsigned long req,
|
|
||||||
int is_svrctl)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
size_t size;
|
|
||||||
unsigned int i, group, cmd;
|
|
||||||
int r, w, big;
|
|
||||||
|
|
||||||
proc->ioctl_index = -1;
|
|
||||||
|
|
||||||
if (valuesonly > 1) {
|
|
||||||
put_value(proc, name, "0x%lx", req);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lookups are bruteforce across the IOCTL submodules; they're all
|
|
||||||
* checked. We could use the group letter but that would create more
|
|
||||||
* issues than it solves. Our hope is that at least the compiler is
|
|
||||||
* smart about looking up particular codes in each switch statement,
|
|
||||||
* although in the worst case, it's a full O(n) lookup.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < COUNT(ioctl_table); i++) {
|
|
||||||
/* IOCTLs and SVRCTLs are considered different name spaces. */
|
|
||||||
if (ioctl_table[i].is_svrctl != is_svrctl)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((text = ioctl_table[i].name(req)) != NULL) {
|
|
||||||
proc->ioctl_index = i;
|
|
||||||
|
|
||||||
if (valuesonly)
|
|
||||||
break;
|
|
||||||
|
|
||||||
put_field(proc, name, text);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
r = _MINIX_IOCTL_IOR(req);
|
|
||||||
w = _MINIX_IOCTL_IOW(req);
|
|
||||||
big = _MINIX_IOCTL_BIG(req);
|
|
||||||
size = (size_t)(big ? _MINIX_IOCTL_SIZE_BIG(req) : IOCPARM_LEN(req));
|
|
||||||
group = big ? 0 : IOCGROUP(req);
|
|
||||||
cmd = req & 0xff; /* shockingly there is no macro for this.. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Not sure why an entire bit is wasted on IOC_VOID (legacy reasons?),
|
|
||||||
* but since the redundancy is there, we might as well check whether
|
|
||||||
* this is a valid IOCTL request. Also, we expect the group to be a
|
|
||||||
* printable character. If either check fails, print just a number.
|
|
||||||
*/
|
|
||||||
if (((req & IOC_VOID) && (r || w || big || size > 0)) ||
|
|
||||||
(!(req & IOC_VOID) && ((!r && !w) || size == 0)) ||
|
|
||||||
(!big && (group < 32 || group > 127))) {
|
|
||||||
put_value(proc, name, "0x%lx", req);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (big) {
|
|
||||||
/* For big IOCTLs, "R" becomes before "W" (old MINIX style). */
|
|
||||||
put_value(proc, name, "_IO%s%s_BIG(%u,%zu)",
|
|
||||||
r ? "R" : "", w ? "W" : "", cmd, size);
|
|
||||||
} else if (IOCGROUP(req) >= 32 && IOCGROUP(req) < 127) {
|
|
||||||
/* For normal IOCTLs, "W" comes before "R" (NetBSD style). */
|
|
||||||
put_value(proc, name, "_IO%s%s('%c',%u,%zu)",
|
|
||||||
w ? "W" : "", r ? "R" : "", group, cmd, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print the supplied (out) part of an IOCTL argument, as applicable. For
|
|
||||||
* efficiency reasons, this function assumes that put_ioctl_req() has been
|
|
||||||
* called for the corresponding IOCTL already, so that the necessary fields in
|
|
||||||
* the given proc structure are set as expected.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
put_ioctl_arg_out(struct trace_proc * proc, const char * name,
|
|
||||||
unsigned long req, vir_bytes addr, int is_svrctl)
|
|
||||||
{
|
|
||||||
size_t size;
|
|
||||||
int dir, all;
|
|
||||||
|
|
||||||
dir = (_MINIX_IOCTL_IOW(req) ? IF_OUT : 0) |
|
|
||||||
(_MINIX_IOCTL_IOR(req) ? IF_IN : 0);
|
|
||||||
|
|
||||||
if (dir == 0) {
|
|
||||||
proc->ioctl_index = -1; /* no argument to print at all */
|
|
||||||
|
|
||||||
return CT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No support for printing big-IOCTL contents just yet. */
|
|
||||||
if (valuesonly > 1 || _MINIX_IOCTL_BIG(req) ||
|
|
||||||
proc->ioctl_index == -1) {
|
|
||||||
put_ptr(proc, name, addr);
|
|
||||||
|
|
||||||
return CT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(proc->ioctl_index >= 0);
|
|
||||||
assert((unsigned int)proc->ioctl_index < COUNT(ioctl_table));
|
|
||||||
assert(ioctl_table[proc->ioctl_index].is_svrctl == is_svrctl);
|
|
||||||
|
|
||||||
proc->ioctl_flags =
|
|
||||||
ioctl_table[proc->ioctl_index].arg(proc, req, NULL, dir);
|
|
||||||
|
|
||||||
if (proc->ioctl_flags == 0) { /* no argument printing for this IOCTL */
|
|
||||||
put_ptr(proc, name, addr);
|
|
||||||
|
|
||||||
proc->ioctl_index = -1; /* forget about the IOCTL handler */
|
|
||||||
|
|
||||||
return CT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this triggers, the IOCTL handler returns a direction that is not
|
|
||||||
* part of the actual IOCTL, and the handler should be fixed.
|
|
||||||
*/
|
|
||||||
if (proc->ioctl_flags & ~dir) {
|
|
||||||
output_flush(); /* show the IOCTL name for debugging */
|
|
||||||
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(proc->ioctl_flags & IF_OUT))
|
|
||||||
return CT_NOTDONE;
|
|
||||||
|
|
||||||
size = IOCPARM_LEN(req);
|
|
||||||
|
|
||||||
if (size > sizeof(ioctlbuf) ||
|
|
||||||
mem_get_data(proc->pid, addr, ioctlbuf, size) < 0) {
|
|
||||||
put_ptr(proc, name, addr);
|
|
||||||
|
|
||||||
/* There's no harm in trying the _in side later anyhow.. */
|
|
||||||
return CT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
put_open(proc, name, 0, "{", ", ");
|
|
||||||
|
|
||||||
all = ioctl_table[proc->ioctl_index].arg(proc, req, ioctlbuf, IF_OUT);
|
|
||||||
|
|
||||||
if (!all)
|
|
||||||
put_field(proc, NULL, "..");
|
|
||||||
|
|
||||||
put_close(proc, "}");
|
|
||||||
|
|
||||||
return CT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print the returned (in) part of an IOCTL argument, as applicable. This
|
|
||||||
* function assumes that it is preceded by a call to put_ioctl_arg_out for this
|
|
||||||
* process.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
put_ioctl_arg_in(struct trace_proc * proc, const char * name, int failed,
|
|
||||||
unsigned long req, vir_bytes addr, int is_svrctl)
|
|
||||||
{
|
|
||||||
size_t size;
|
|
||||||
int all;
|
|
||||||
|
|
||||||
if (valuesonly > 1 || _MINIX_IOCTL_BIG(req) ||
|
|
||||||
proc->ioctl_index == -1) {
|
|
||||||
put_result(proc);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(proc->ioctl_index >= 0);
|
|
||||||
assert((unsigned int)proc->ioctl_index < COUNT(ioctl_table));
|
|
||||||
assert(ioctl_table[proc->ioctl_index].is_svrctl == is_svrctl);
|
|
||||||
assert(proc->ioctl_flags != 0);
|
|
||||||
|
|
||||||
if (proc->ioctl_flags & IF_OUT)
|
|
||||||
put_result(proc);
|
|
||||||
if (!(proc->ioctl_flags & IF_IN))
|
|
||||||
return;
|
|
||||||
|
|
||||||
size = IOCPARM_LEN(req);
|
|
||||||
|
|
||||||
if (failed || size > sizeof(ioctlbuf) ||
|
|
||||||
mem_get_data(proc->pid, addr, ioctlbuf, size) < 0) {
|
|
||||||
if (!(proc->ioctl_flags & IF_OUT)) {
|
|
||||||
put_ptr(proc, name, addr);
|
|
||||||
put_equals(proc);
|
|
||||||
put_result(proc);
|
|
||||||
} else if (!failed)
|
|
||||||
put_field(proc, NULL, "{..}");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
put_open(proc, name, 0, "{", ", ");
|
|
||||||
|
|
||||||
all = ioctl_table[proc->ioctl_index].arg(proc, req, ioctlbuf, IF_IN);
|
|
||||||
|
|
||||||
if (!all)
|
|
||||||
put_field(proc, NULL, "..");
|
|
||||||
|
|
||||||
put_close(proc, "}");
|
|
||||||
|
|
||||||
if (!(proc->ioctl_flags & IF_OUT)) {
|
|
||||||
put_equals(proc);
|
|
||||||
put_result(proc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user