summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2013-03-17 23:39:52 +0000
committerattilio <attilio@FreeBSD.org>2013-03-17 23:39:52 +0000
commitd500d6361abe652aef27a2c034835bc2a60155ad (patch)
tree660c72c3a1b0cbf41943fa591b5ed5d1f31c50f6
parenta69d85af8b2642ba2d10b8aa37bc58a3123ec1c6 (diff)
parent960294c20051941b358bdc3d71e05fa682614d6f (diff)
downloadFreeBSD-src-d500d6361abe652aef27a2c034835bc2a60155ad.zip
FreeBSD-src-d500d6361abe652aef27a2c034835bc2a60155ad.tar.gz
MFC
-rw-r--r--ObsoleteFiles.inc1
-rw-r--r--bin/cp/cp.123
-rw-r--r--bin/ls/ls.120
-rw-r--r--bin/mkdir/mkdir.119
-rw-r--r--bin/mv/mv.112
-rw-r--r--bin/ps/ps.16
-rw-r--r--bin/rm/rm.115
-rw-r--r--bin/rmdir/rmdir.114
-rw-r--r--bin/sh/jobs.c7
-rw-r--r--cddl/contrib/opensolaris/cmd/zdb/zdb.c1
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs.82
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool.87
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_main.c5
-rw-r--r--contrib/libc-vis/unvis.337
-rw-r--r--contrib/libc-vis/unvis.c6
-rw-r--r--contrib/libc-vis/vis.3144
-rw-r--r--contrib/libc-vis/vis.c800
-rw-r--r--contrib/libc-vis/vis.h5
-rw-r--r--contrib/tzdata/africa72
-rw-r--r--contrib/tzdata/antarctica6
-rw-r--r--contrib/tzdata/asia48
-rw-r--r--contrib/tzdata/australasia11
-rw-r--r--contrib/tzdata/europe127
-rw-r--r--contrib/tzdata/northamerica56
-rw-r--r--contrib/tzdata/southamerica66
-rw-r--r--contrib/tzdata/zone.tab5
-rw-r--r--contrib/unvis/Makefile6
-rw-r--r--contrib/unvis/unvis.1 (renamed from usr.bin/unvis/unvis.1)39
-rw-r--r--contrib/unvis/unvis.c (renamed from usr.bin/unvis/unvis.c)76
-rw-r--r--contrib/vis/Makefile7
-rw-r--r--contrib/vis/extern.h39
-rw-r--r--contrib/vis/foldit.c (renamed from usr.bin/vis/foldit.c)22
-rw-r--r--contrib/vis/vis.1 (renamed from usr.bin/vis/vis.1)81
-rw-r--r--contrib/vis/vis.c276
-rw-r--r--gnu/lib/libgcc/Makefile6
-rw-r--r--lib/libc/gen/Makefile.inc18
-rw-r--r--lib/libc/gen/Symbol.map2
-rw-r--r--lib/libc/sys/chflags.24
-rw-r--r--lib/libipsec/test-policy.c15
-rw-r--r--lib/libutil/pidfile.c31
-rw-r--r--sbin/ccdconfig/ccdconfig.86
-rw-r--r--sbin/ffsinfo/ffsinfo.84
-rw-r--r--sbin/geom/class/concat/gconcat.84
-rw-r--r--sbin/geom/class/mirror/gmirror.84
-rw-r--r--sbin/geom/class/raid/graid.82
-rw-r--r--sbin/geom/class/stripe/gstripe.84
-rw-r--r--sbin/gvinum/gvinum.89
-rw-r--r--sbin/hastctl/hastctl.812
-rw-r--r--sbin/hastctl/hastctl.c74
-rw-r--r--sbin/hastd/hastd.88
-rw-r--r--sbin/hastd/secondary.c2
-rw-r--r--sbin/hastd/subr.c64
-rw-r--r--sbin/recoverdisk/recoverdisk.c2
-rw-r--r--share/man/man4/Makefile1
-rw-r--r--share/man/man4/ccd.44
-rw-r--r--share/man/man4/geom.437
-rw-r--r--share/man/man4/udp.446
-rw-r--r--share/man/man4/vinum.41166
-rw-r--r--share/misc/bsd-family-tree15
-rw-r--r--sys/amd64/amd64/pmap.c24
-rw-r--r--sys/amd64/vmm/intel/vmx.c7
-rw-r--r--sys/amd64/vmm/vmm.c8
-rw-r--r--sys/amd64/vmm/vmm_stat.c13
-rw-r--r--sys/amd64/vmm/vmm_stat.h27
-rw-r--r--sys/arm/arm/bcopy_page.S4
-rw-r--r--sys/arm/arm/bcopyinout.S5
-rw-r--r--sys/arm/arm/bcopyinout_xscale.S4
-rw-r--r--sys/arm/arm/blockio.S11
-rw-r--r--sys/arm/arm/bus_space_asm_generic.S23
-rw-r--r--sys/arm/arm/copystr.S3
-rw-r--r--sys/arm/arm/cpufunc_asm.S15
-rw-r--r--sys/arm/arm/cpufunc_asm_arm10.S13
-rw-r--r--sys/arm/arm/cpufunc_asm_arm11.S12
-rw-r--r--sys/arm/arm/cpufunc_asm_arm11x6.S9
-rw-r--r--sys/arm/arm/cpufunc_asm_arm7tdmi.S6
-rw-r--r--sys/arm/arm/cpufunc_asm_arm8.S12
-rw-r--r--sys/arm/arm/cpufunc_asm_arm9.S11
-rw-r--r--sys/arm/arm/cpufunc_asm_armv4.S6
-rw-r--r--sys/arm/arm/cpufunc_asm_armv5.S9
-rw-r--r--sys/arm/arm/cpufunc_asm_armv5_ec.S9
-rw-r--r--sys/arm/arm/cpufunc_asm_armv6.S10
-rw-r--r--sys/arm/arm/cpufunc_asm_armv7.S16
-rw-r--r--sys/arm/arm/cpufunc_asm_fa526.S15
-rw-r--r--sys/arm/arm/cpufunc_asm_ixp12x0.S2
-rw-r--r--sys/arm/arm/cpufunc_asm_pj4b.S15
-rw-r--r--sys/arm/arm/cpufunc_asm_sa1.S21
-rw-r--r--sys/arm/arm/cpufunc_asm_sa11x0.S5
-rw-r--r--sys/arm/arm/cpufunc_asm_sheeva.S11
-rw-r--r--sys/arm/arm/cpufunc_asm_xscale.S27
-rw-r--r--sys/arm/arm/cpufunc_asm_xscale_c3.S20
-rw-r--r--sys/arm/arm/db_trace.c23
-rw-r--r--sys/arm/arm/elf_trampoline.c15
-rw-r--r--sys/arm/arm/exception.S11
-rw-r--r--sys/arm/arm/fiq_subr.S2
-rw-r--r--sys/arm/arm/fusu.S14
-rw-r--r--sys/arm/arm/in_cksum_arm.S6
-rw-r--r--sys/arm/arm/irq_dispatch.S1
-rw-r--r--sys/arm/arm/locore.S10
-rw-r--r--sys/arm/arm/pmap-v6.c39
-rw-r--r--sys/arm/arm/pmap.c93
-rw-r--r--sys/arm/arm/setcpsr.S2
-rw-r--r--sys/arm/arm/support.S8
-rw-r--r--sys/arm/arm/swtch.S6
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_sdhci.c116
-rw-r--r--sys/arm/include/asm.h14
-rw-r--r--sys/arm/include/bus.h8
-rw-r--r--sys/arm/include/pmap.h2
-rw-r--r--sys/arm/ti/cpsw/if_cpsw.c2
-rw-r--r--sys/arm/ti/ti_mmchs.c5
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c2
-rw-r--r--sys/compat/ndis/kern_ndis.c8
-rw-r--r--sys/conf/Makefile.arm41
-rw-r--r--sys/conf/NOTES2
-rw-r--r--sys/conf/files4
-rw-r--r--sys/conf/files.arm2
-rw-r--r--sys/dev/acpica/acpi_powerres.c2
-rw-r--r--sys/dev/ath/if_ath.c111
-rw-r--r--sys/dev/ath/if_ath_sysctl.c6
-rw-r--r--sys/dev/ath/if_ath_tx.c11
-rw-r--r--sys/dev/ath/if_athvar.h10
-rw-r--r--sys/dev/puc/pucdata.c20
-rw-r--r--sys/dev/sound/pcm/sndstat.c8
-rw-r--r--sys/fs/cd9660/cd9660_vnops.c2
-rw-r--r--sys/fs/ext2fs/ext2_balloc.c2
-rw-r--r--sys/fs/ext2fs/ext2_vnops.c9
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c4
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c1
-rw-r--r--sys/fs/udf/udf_vnops.c5
-rw-r--r--sys/geom/gate/g_gate.c2
-rw-r--r--sys/i386/i386/pmap.c43
-rw-r--r--sys/i386/xen/pmap.c40
-rw-r--r--sys/ia64/ia64/pmap.c24
-rw-r--r--sys/kern/capabilities.conf2
-rw-r--r--sys/kern/kern_racct.c6
-rw-r--r--sys/kern/subr_trap.c11
-rw-r--r--sys/kern/uipc_mbuf.c109
-rw-r--r--sys/kern/uipc_sockbuf.c4
-rw-r--r--sys/kern/uipc_syscalls.c10
-rw-r--r--sys/kern/vfs_bio.c45
-rw-r--r--sys/kern/vfs_cluster.c26
-rw-r--r--sys/kern/vfs_syscalls.c9
-rw-r--r--sys/kern/vfs_vnops.c45
-rw-r--r--sys/libkern/arm/aeabi_unwind.c58
-rw-r--r--sys/libkern/arm/divsi3.S13
-rw-r--r--sys/libkern/arm/ffs.S2
-rw-r--r--sys/libkern/arm/ldivmod.S2
-rw-r--r--sys/libkern/arm/memcpy.S3
-rw-r--r--sys/libkern/arm/memset.S (renamed from usr.bin/vis/extern.h)37
-rw-r--r--sys/mips/mips/pmap.c45
-rw-r--r--sys/modules/uart/Makefile3
-rw-r--r--sys/net/bridgestp.c4
-rw-r--r--sys/net/if_gre.c3
-rw-r--r--sys/net/rtsock.c19
-rw-r--r--sys/netinet/igmp.c4
-rw-r--r--sys/netinet/ip_carp.c4
-rw-r--r--sys/netinet/ip_input.c2
-rw-r--r--sys/netinet/ip_mroute.c7
-rw-r--r--sys/netinet/ip_options.c4
-rw-r--r--sys/netinet/ip_output.c4
-rw-r--r--sys/netinet/libalias/alias.c16
-rw-r--r--sys/netinet/tcp_output.c22
-rw-r--r--sys/netinet/tcp_subr.c2
-rw-r--r--sys/netinet6/icmp6.c100
-rw-r--r--sys/netinet6/ip6_input.c35
-rw-r--r--sys/netinet6/ip6_mroute.c5
-rw-r--r--sys/netinet6/ip6_output.c47
-rw-r--r--sys/netinet6/mld6.c6
-rw-r--r--sys/netinet6/nd6_nbr.c26
-rw-r--r--sys/netipsec/key.c154
-rw-r--r--sys/netpfil/pf/pf.c2
-rw-r--r--sys/nfs/nfs_common.c4
-rw-r--r--sys/powerpc/aim/mmu_oea.c27
-rw-r--r--sys/powerpc/aim/mmu_oea64.c69
-rw-r--r--sys/powerpc/booke/pmap.c33
-rw-r--r--sys/powerpc/powerpc/mmu_if.m8
-rw-r--r--sys/powerpc/powerpc/pmap_dispatch.c10
-rw-r--r--sys/sparc64/sparc64/pmap.c8
-rw-r--r--sys/sys/buf.h6
-rw-r--r--sys/sys/mbuf.h14
-rw-r--r--sys/sys/vnode.h2
-rw-r--r--sys/ufs/ffs/ffs_balloc.c12
-rw-r--r--sys/ufs/ffs/ffs_vnops.c6
-rw-r--r--sys/ufs/ufs/ufs_vnops.c1
-rw-r--r--sys/vm/pmap.h2
-rw-r--r--sys/vm/vm_kern.c8
-rw-r--r--sys/vm/vnode_pager.c2
-rw-r--r--sys/xdr/xdr_mbuf.c7
-rw-r--r--tools/regression/bin/sh/builtins/wait6.03
-rw-r--r--tools/regression/bin/sh/builtins/wait7.04
-rw-r--r--tools/regression/pjdfstest/tests/misc.sh4
-rw-r--r--tools/regression/security/cap_test/cap_test_capabilities.c63
-rw-r--r--usr.bin/find/find.h2
-rw-r--r--usr.bin/find/function.c47
-rw-r--r--usr.bin/head/head.115
-rw-r--r--usr.bin/renice/renice.812
-rw-r--r--usr.bin/script/script.12
-rw-r--r--usr.bin/tail/tail.113
-rw-r--r--usr.bin/unvis/Makefile2
-rw-r--r--usr.bin/vis/Makefile4
-rw-r--r--usr.bin/vis/vis.c189
-rw-r--r--usr.sbin/ac/ac.820
-rw-r--r--usr.sbin/bhyve/pci_virtio_net.c2
202 files changed, 3436 insertions, 2771 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 59ac7ae..45b72de6 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,7 @@
# xargs -n1 | sort | uniq -d;
# done
+OLD_FILES+=usr/share/man/man4/vinum.4.gz
# 20130311: Ports are no more available via cvsup
OLD_FILES+=usr/share/examples/cvsup/ports-supfile
OLD_FILES+=usr/share/examples/cvsup/refuse
diff --git a/bin/cp/cp.1 b/bin/cp/cp.1
index 8c014b4..169f350 100644
--- a/bin/cp/cp.1
+++ b/bin/cp/cp.1
@@ -32,7 +32,7 @@
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd September 4, 2012
+.Dd March 15, 2013
.Dt CP 1
.Os
.Sh NAME
@@ -251,6 +251,27 @@ signal, the current input and output file and the percentage complete
will be written to the standard output.
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+Make a copy of file
+.Pa foo
+named
+.Pa bar :
+.Pp
+.Dl $ cp foo bar
+.Pp
+Copy a group of files to the
+.Pa /tmp
+directory:
+.Pp
+.Dl $ cp *.txt /tmp
+.Pp
+Copy the directory
+.Pa junk
+and all of its contents (including any subdirectories) to the
+.Pa /tmp
+directory:
+.Pp
+.Dl $ cp -R junk /tmp
.Sh COMPATIBILITY
Historic versions of the
.Nm
diff --git a/bin/ls/ls.1 b/bin/ls/ls.1
index aa4fc18..7c72652 100644
--- a/bin/ls/ls.1
+++ b/bin/ls/ls.1
@@ -32,7 +32,7 @@
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\" $FreeBSD$
.\"
-.Dd November 8, 2012
+.Dd March 15, 2013
.Dt LS 1
.Os
.Sh NAME
@@ -718,6 +718,24 @@ for more information.
.El
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+List the contents of the current working directory in long format:
+.Pp
+.Dl $ ls -l
+.Pp
+In addition to listing the contents of the current working directory in
+long format, show inode numbers, file flags (see
+.Xr chflags 1 ) ,
+and suffix each filename with a symbol representing its file type:
+.Pp
+.Dl $ ls -lioF
+.Pp
+List the files in
+.Pa /var/log ,
+sorting the output such that the mostly recently modified entries are
+printed first:
+.Pp
+.Dl $ ls -lt /var/log
.Sh COMPATIBILITY
The group field is now automatically included in the long listing for
files in order to be compatible with the
diff --git a/bin/mkdir/mkdir.1 b/bin/mkdir/mkdir.1
index 0f8d812..d702348 100644
--- a/bin/mkdir/mkdir.1
+++ b/bin/mkdir/mkdir.1
@@ -32,7 +32,7 @@
.\" @(#)mkdir.1 8.2 (Berkeley) 1/25/94
.\" $FreeBSD$
.\"
-.Dd January 25, 1994
+.Dd March 15, 2013
.Dt MKDIR 1
.Os
.Sh NAME
@@ -87,6 +87,23 @@ Be verbose when creating directories, listing them as they are created.
The user must have write permission in the parent directory.
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+Create a directory named
+.Pa foobar :
+.Pp
+.Dl $ mkdir foobar
+.Pp
+Create a directory named
+.Pa foobar
+and set its file mode to 700:
+.Pp
+.Dl $ mkdir -m 700 foobar
+.Pp
+Create a directory named
+.Pa cow/horse/monkey ,
+creating any non-existent intermediate directories as necessary:
+.Pp
+.Dl $ mkdir -p cow/horse/monkey
.Sh COMPATIBILITY
The
.Fl v
diff --git a/bin/mv/mv.1 b/bin/mv/mv.1
index 5199f27..298dbf9 100644
--- a/bin/mv/mv.1
+++ b/bin/mv/mv.1
@@ -32,7 +32,7 @@
.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
.\" $FreeBSD$
.\"
-.Dd August 28, 2012
+.Dd March 15, 2013
.Dt MV 1
.Os
.Sh NAME
@@ -155,6 +155,16 @@ rm -rf source_file
.Ed
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+Rename file
+.Pa foo
+to
+.Pa bar ,
+overwriting
+.Pa bar
+if it already exists:
+.Pp
+.Dl $ mv -f foo bar
.Sh COMPATIBILITY
The
.Fl h ,
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 7f69137..1a364f5 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -29,7 +29,7 @@
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd February 7, 2013
+.Dd March 15, 2013
.Dt PS 1
.Os
.Sh NAME
@@ -689,6 +689,10 @@ attempts to automatically determine the terminal width.
.It Pa /boot/kernel/kernel
default system namelist
.El
+.Sh EXAMPLES
+Display information on all system processes:
+.Pp
+.Dl $ ps -auxw
.Sh SEE ALSO
.Xr kill 1 ,
.Xr pgrep 1 ,
diff --git a/bin/rm/rm.1 b/bin/rm/rm.1
index ad81066..3588f38 100644
--- a/bin/rm/rm.1
+++ b/bin/rm/rm.1
@@ -32,7 +32,7 @@
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\" $FreeBSD$
.\"
-.Dd October 31, 2010
+.Dd March 15, 2013
.Dt RM 1
.Os
.Sh NAME
@@ -193,6 +193,19 @@ When
is specified with
.Fl f
the file will be overwritten and removed even if it has hard links.
+.Sh EXAMPLES
+Recursively remove all files contained within the
+.Pa foobar
+directory hierarchy:
+.Pp
+.Dl $ rm -rf foobar
+.Pp
+Either of these commands will remove the file
+.Pa -f :
+.Bd -literal -offset indent
+$ rm -- -f
+$ rm ./-f
+.Ed
.Sh COMPATIBILITY
The
.Nm
diff --git a/bin/rmdir/rmdir.1 b/bin/rmdir/rmdir.1
index 688d144..ededd43 100644
--- a/bin/rmdir/rmdir.1
+++ b/bin/rmdir/rmdir.1
@@ -32,7 +32,7 @@
.\" @(#)rmdir.1 8.1 (Berkeley) 5/31/93
.\" $FreeBSD$
.\"
-.Dd March 21, 2004
+.Dd March 15, 2013
.Dt RMDIR 1
.Os
.Sh NAME
@@ -86,6 +86,18 @@ successfully.
.It Li >0
An error occurred.
.El
+.Sh EXAMPLES
+Remove the directory
+.Pa foobar ,
+if it is empty:
+.Pp
+.Dl $ rmdir foobar
+.Pp
+Remove all directories up to and including
+.Pa cow ,
+stopping at the first non-empty directory (if any):
+.Pp
+.Dl $ rmdir -p cow/horse/monkey
.Sh SEE ALSO
.Xr rm 1
.Sh STANDARDS
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index 5a2790b..a092884 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -458,14 +458,15 @@ freejob(struct job *jp)
int
-waitcmd(int argc, char **argv)
+waitcmd(int argc __unused, char **argv __unused)
{
struct job *job;
int status, retval;
struct job *jp;
- if (argc > 1) {
- job = getjob(argv[1]);
+ nextopt("");
+ if (*argptr != NULL) {
+ job = getjob(*argptr);
} else {
job = NULL;
}
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
index 2f0e658..dd36813 100644
--- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c
+++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
@@ -1225,6 +1225,7 @@ dump_bpobj(bpobj_t *bpo, char *name, int indent)
continue;
}
dump_bpobj(&subbpo, "subobj", indent + 1);
+ bpobj_close(&subbpo);
}
} else {
(void) printf(" %*s: object %llu, %llu blkptrs, %s\n",
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8
index be1cf9c..9c882da 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 10, 2013
+.Dd March 1, 2013
.Dt ZFS 8
.Os
.Sh NAME
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool.8 b/cddl/contrib/opensolaris/cmd/zpool/zpool.8
index 4c82741..715439b 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool.8
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 15, 2012
+.Dd March 14, 2013
.Dt ZPOOL 8
.Os
.Sh NAME
@@ -1608,14 +1608,15 @@ is specified, the command exits after
.Ar count
reports are printed.
.Pp
-If a scrub or resilver is in progress, this command reports the percentage done
-and the estimated time to completion. Both of these are only approximate,
+If a scrub or resilver is in progress, this command reports the percentage
+done and the estimated time to completion. Both of these are only approximate,
because the amount of data in the pool and the other workloads on the system
can change.
.Bl -tag -width indent
.It Fl x
Only display status for pools that are exhibiting errors or are otherwise
unavailable.
+Warnings about pools not using the latest on-disk format will not be included.
.It Fl v
Displays verbose data error information, printing out a complete list of all
data errors since the last complete pool scrub.
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
index dd6c90b..be84a50 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
@@ -4031,7 +4031,10 @@ status_callback(zpool_handle_t *zhp, void *data)
* If we were given 'zpool status -x', only report those pools with
* problems.
*/
- if (reason == ZPOOL_STATUS_OK && cbp->cb_explain) {
+ if (cbp->cb_explain &&
+ (reason == ZPOOL_STATUS_OK ||
+ reason == ZPOOL_STATUS_VERSION_OLDER ||
+ reason == ZPOOL_STATUS_FEAT_DISABLED)) {
if (!cbp->cb_allpools) {
(void) printf(gettext("pool '%s' is healthy\n"),
zpool_get_name(zhp));
diff --git a/contrib/libc-vis/unvis.3 b/contrib/libc-vis/unvis.3
index 472c49d..34ebde6 100644
--- a/contrib/libc-vis/unvis.3
+++ b/contrib/libc-vis/unvis.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: unvis.3,v 1.23 2011/03/17 14:06:29 wiz Exp $
+.\" $NetBSD: unvis.3,v 1.27 2012/12/15 07:34:36 wiz Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 1989, 1991, 1993
@@ -126,15 +126,17 @@ The
function has several return codes that must be handled properly.
They are:
.Bl -tag -width UNVIS_VALIDPUSH
-.It Li \&0 (zero)
+.It Li \&0 No (zero)
Another character is necessary; nothing has been recognized yet.
.It Dv UNVIS_VALID
A valid character has been recognized and is available at the location
-pointed to by cp.
+pointed to by
+.Fa cp .
.It Dv UNVIS_VALIDPUSH
A valid character has been recognized and is available at the location
-pointed to by cp; however, the character currently passed in should
-be passed in again.
+pointed to by
+.Fa cp ;
+however, the character currently passed in should be passed in again.
.It Dv UNVIS_NOCHAR
A valid sequence was detected, but no character was produced.
This return code is necessary to indicate a logical break between characters.
@@ -150,7 +152,7 @@ one more time with flag set to
to extract any remaining character (the character passed in is ignored).
.Pp
The
-.Ar flag
+.Fa flag
argument is also used to specify the encoding style of the source.
If set to
.Dv VIS_HTTPSTYLE
@@ -161,7 +163,8 @@ will decode URI strings as specified in RFC 1808.
If set to
.Dv VIS_HTTP1866 ,
.Fn unvis
-will decode URI strings as specified in RFC 1866.
+will decode entity references and numeric character references
+as specified in RFC 1866.
If set to
.Dv VIS_MIMESTYLE ,
.Fn unvis
@@ -169,7 +172,9 @@ will decode MIME Quoted-Printable strings as specified in RFC 2045.
If set to
.Dv VIS_NOESCAPE ,
.Fn unvis
-will not decode \e quoted characters.
+will not decode
+.Ql \e
+quoted characters.
.Pp
The following code fragment illustrates a proper use of
.Fn unvis .
@@ -204,7 +209,7 @@ The functions
and
.Fn strnunvisx
will return \-1 on error and set
-.Va errno
+.Va errno
to:
.Bl -tag -width Er
.It Bq Er EINVAL
@@ -212,7 +217,7 @@ An invalid escape sequence was detected, or the decoder is in an unknown state.
.El
.Pp
In addition the functions
-.Fn strnunvis
+.Fn strnunvis
and
.Fn strnunvisx
will can also set
@@ -244,4 +249,14 @@ and
functions appeared in
.Nx 6.0
and
-.Fx 10.0 .
+.Fx 9.2 .
+.Sh BUGS
+The names
+.Dv VIS_HTTP1808
+and
+.Dv VIS_HTTP1866
+are wrong.
+Percent-encoding was defined in RFC 1738, the original RFC for URL.
+RFC 1866 defines HTML 2.0, an application of SGML, from which it
+inherits concepts of numeric character references and entity
+references.
diff --git a/contrib/libc-vis/unvis.c b/contrib/libc-vis/unvis.c
index d87812a..9cf112c 100644
--- a/contrib/libc-vis/unvis.c
+++ b/contrib/libc-vis/unvis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.40 2012/12/14 21:31:01 christos Exp $ */
+/* $NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.40 2012/12/14 21:31:01 christos Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__FBSDID("$FreeBSD$");
@@ -90,7 +90,7 @@ __weak_alias(strnunvisx,_strnunvisx)
* RFC 1866
*/
static const struct nv {
- const char name[7];
+ char name[7];
uint8_t value;
} nv[] = {
{ "AElig", 198 }, /* capital AE diphthong (ligature) */
diff --git a/contrib/libc-vis/vis.3 b/contrib/libc-vis/vis.3
index 6f5b15f..9d2cb31 100644
--- a/contrib/libc-vis/vis.3
+++ b/contrib/libc-vis/vis.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: vis.3,v 1.29 2012/12/14 22:55:59 christos Exp $
+.\" $NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 1989, 1991, 1993
@@ -30,7 +30,7 @@
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd December 14, 2012
+.Dd February 19, 2013
.Dt VIS 3
.Os
.Sh NAME
@@ -40,12 +40,14 @@
.Nm strnvis ,
.Nm strvisx ,
.Nm strnvisx ,
+.Nm strenvisx ,
.Nm svis ,
.Nm snvis ,
.Nm strsvis ,
.Nm strsnvis ,
-.Nm strsvisx
-.Nm strsnvisx
+.Nm strsvisx ,
+.Nm strsnvisx ,
+.Nm strsenvisx
.Nd visually encode characters
.Sh LIBRARY
.Lb libc
@@ -63,6 +65,8 @@
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
.Ft int
.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag"
+.Ft int
+.Fn strenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "int *cerr_ptr"
.Ft char *
.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra"
.Ft char *
@@ -75,6 +79,8 @@
.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra"
.Ft int
.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra"
+.Ft int
+.Fn strsenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" "int *cerr_ptr"
.Sh DESCRIPTION
The
.Fn vis
@@ -89,11 +95,11 @@ needs no encoding, it is copied in unaltered.
The string is null terminated, and a pointer to the end of the string is
returned.
The maximum length of any encoding is four
-characters (not including the trailing
+bytes (not including the trailing
.Dv NUL ) ;
thus, when
encoding a set of characters into a buffer, the size of the buffer should
-be four times the number of characters encoded, plus one for the trailing
+be four times the number of bytes encoded, plus one for the trailing
.Dv NUL .
The flag parameter is used for altering the default range of
characters considered for encoding and for altering the visual
@@ -142,16 +148,17 @@ terminate
The size of
.Fa dst
must be four times the number
-of characters encoded from
+of bytes encoded from
.Fa src
(plus one for the
.Dv NUL ) .
Both
-forms return the number of characters in dst (not including
-the trailing
+forms return the number of characters in
+.Fa dst
+(not including the trailing
.Dv NUL ) .
The
-.Dq n
+.Dq Nm n
versions of the functions also take an additional argument
.Fa dlen
that indicates the length of the
@@ -159,7 +166,7 @@ that indicates the length of the
buffer.
If
.Fa dlen
-is not large enough to fix the converted string then the
+is not large enough to fit the converted string then the
.Fn strnvis
and
.Fn strnvisx
@@ -167,6 +174,14 @@ functions return \-1 and set
.Va errno
to
.Dv ENOSPC .
+The
+.Fn strenvisx
+function takes an additional argument,
+.Fa cerr_ptr ,
+that is used to pass in and out a multibyte conversion error flag.
+This is useful when processing single characters at a time when
+it is possible that the locale may be set to something other
+than the locale of the characters in the input data.
.Pp
The functions
.Fn svis ,
@@ -174,16 +189,18 @@ The functions
.Fn strsvis ,
.Fn strsnvis ,
.Fn strsvisx ,
+.Fn strsnvisx ,
and
-.Fn strsnvisx
+.Fn strsenvisx
correspond to
.Fn vis ,
.Fn nvis ,
.Fn strvis ,
.Fn strnvis ,
.Fn strvisx ,
+.Fn strnvisx ,
and
-.Fn strnvisx
+.Fn strenvisx
but have an additional argument
.Fa extra ,
pointing to a
@@ -214,14 +231,13 @@ and
.Fn strnvisx ) ,
and the type of representation used.
By default, all non-graphic characters,
-except space, tab, and newline are encoded.
-(See
-.Xr isgraph 3 . )
+except space, tab, and newline are encoded (see
+.Xr isgraph 3 ) .
The following flags
alter this:
.Bl -tag -width VIS_WHITEX
.It Dv VIS_GLOB
-Also encode magic characters
+Also encode the magic characters
.Ql ( * ,
.Ql \&? ,
.Ql \&[
@@ -243,11 +259,13 @@ Synonym for
\&|
.Dv VIS_NL .
.It Dv VIS_SAFE
-Only encode "unsafe" characters.
+Only encode
+.Dq unsafe
+characters.
Unsafe means control characters which may cause common terminals to perform
unexpected functions.
Currently this form allows space, tab, newline, backspace, bell, and
-return - in addition to all graphic characters - unencoded.
+return \(em in addition to all graphic characters \(em unencoded.
.El
.Pp
(The above flags have no effect for
@@ -287,8 +305,8 @@ Use an
to represent meta characters (characters with the 8th
bit set), and use caret
.Ql ^
-to represent control characters see
-.Pf ( Xr iscntrl 3 ) .
+to represent control characters (see
+.Xr iscntrl 3 ) .
The following formats are used:
.Bl -tag -width xxxxx
.It Dv \e^C
@@ -335,19 +353,20 @@ Use C-style backslash sequences to represent standard non-printable
characters.
The following sequences are used to represent the indicated characters:
.Bd -unfilled -offset indent
-.Li \ea Tn - BEL No (007)
-.Li \eb Tn - BS No (010)
-.Li \ef Tn - NP No (014)
-.Li \en Tn - NL No (012)
-.Li \er Tn - CR No (015)
-.Li \es Tn - SP No (040)
-.Li \et Tn - HT No (011)
-.Li \ev Tn - VT No (013)
-.Li \e0 Tn - NUL No (000)
+.Li \ea Tn \(em BEL No (007)
+.Li \eb Tn \(em BS No (010)
+.Li \ef Tn \(em NP No (014)
+.Li \en Tn \(em NL No (012)
+.Li \er Tn \(em CR No (015)
+.Li \es Tn \(em SP No (040)
+.Li \et Tn \(em HT No (011)
+.Li \ev Tn \(em VT No (013)
+.Li \e0 Tn \(em NUL No (000)
.Ed
.Pp
-When using this format, the nextc parameter is looked at to determine
-if a
+When using this format, the
+.Fa nextc
+parameter is looked at to determine if a
.Dv NUL
character can be encoded as
.Ql \e0
@@ -374,8 +393,8 @@ represents a lower case hexadecimal digit.
.It Dv VIS_MIMESTYLE
Use MIME Quoted-Printable encoding as described in RFC 2045, only don't
break lines and don't handle CRLF.
-The form is:
-.Ql %XX
+The form is
+.Ql =XX
where
.Em X
represents an upper case hexadecimal digit.
@@ -392,6 +411,41 @@ meta characters as
.Ql M-C ) .
With this flag set, the encoding is
ambiguous and non-invertible.
+.Sh MULTIBYTE CHARACTER SUPPORT
+These functions support multibyte character input.
+The encoding conversion is influenced by the setting of the
+.Ev LC_CTYPE
+environment variable which defines the set of characters
+that can be copied without encoding.
+.Pp
+When 8-bit data is present in the input,
+.Ev LC_CTYPE
+must be set to the correct locale or to the C locale.
+If the locales of the data and the conversion are mismatched,
+multibyte character recognition may fail and encoding will be performed
+byte-by-byte instead.
+.Pp
+As noted above,
+.Fa dst
+must be four times the number of bytes processed from
+.Fa src .
+But note that each multibyte character can be up to
+.Dv MB_LEN_MAX
+bytes
+.\" (see
+.\" .Xr multibyte 3 )
+so in terms of multibyte characters,
+.Fa dst
+must be four times
+.Dv MB_LEN_MAX
+times the number of characters processed from
+.Fa src .
+.Sh ENVIRONMENT
+.Bl -tag -width ".Ev LC_CTYPE"
+.It Ev LC_CTYPE
+Specify the locale of the input data.
+Set to C if the input data locale is unknown.
+.El
.Sh ERRORS
The functions
.Fn nvis
@@ -407,11 +461,11 @@ and
.Fn strsnvisx ,
will return \-1 when the
.Fa dlen
-destination buffer length size is not enough to perform the conversion while
+destination buffer size is not enough to perform the conversion while
setting
.Va errno
to:
-.Bl -tag -width Er
+.Bl -tag -width ".Bq Er ENOSPC"
.It Bq Er ENOSPC
The destination buffer size is not large enough to perform the conversion.
.El
@@ -419,18 +473,23 @@ The destination buffer size is not large enough to perform the conversion.
.Xr unvis 1 ,
.Xr vis 1 ,
.Xr glob 3 ,
+.\" .Xr multibyte 3 ,
.Xr unvis 3
.Rs
.%A T. Berners-Lee
.%T Uniform Resource Locators (URL)
-.%O RFC1738
+.%O "RFC 1738"
+.Re
+.Rs
+.%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
+.%O "RFC 2045"
.Re
.Sh HISTORY
The
.Fn vis ,
.Fn strvis ,
and
-.Fa strvisx
+.Fn strvisx
functions first appeared in
.Bx 4.4 .
The
@@ -441,7 +500,7 @@ and
functions appeared in
.Nx 1.5
and
-.Fx 10.0 .
+.Fx 9.2 .
The buffer size limited versions of the functions
.Po Fn nvis ,
.Fn strnvis ,
@@ -451,6 +510,9 @@ The buffer size limited versions of the functions
and
.Fn strsnvisx Pc
appeared in
-.Nx 6.0
and
-.Fx 10.0 .
+.Fx 9.2 .
+Myltibyte character support was added in
+.Nx 7.0
+and
+.Fx 9.2 .
diff --git a/contrib/libc-vis/vis.c b/contrib/libc-vis/vis.c
index 040c28c..2ba6b5b 100644
--- a/contrib/libc-vis/vis.c
+++ b/contrib/libc-vis/vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.45 2012/12/14 21:38:18 christos Exp $ */
+/* $NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,19 +57,23 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.45 2012/12/14 21:38:18 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
+#ifdef __FBSDID
__FBSDID("$FreeBSD$");
+#define _DIAGASSERT(x) assert(x)
+#endif
#include "namespace.h"
#include <sys/types.h>
+#include <sys/param.h>
#include <assert.h>
#include <vis.h>
#include <errno.h>
#include <stdlib.h>
-
-#define _DIAGASSERT(x) assert(x)
+#include <wchar.h>
+#include <wctype.h>
#ifdef __weak_alias
__weak_alias(strvisx,_strvisx)
@@ -81,65 +85,66 @@ __weak_alias(strvisx,_strvisx)
#include <stdio.h>
#include <string.h>
-static char *do_svis(char *, size_t *, int, int, int, const char *);
+/*
+ * The reason for going through the trouble to deal with character encodings
+ * in vis(3), is that we use this to safe encode output of commands. This
+ * safe encoding varies depending on the character set. For example if we
+ * display ps output in French, we don't want to display French characters
+ * as M-foo.
+ */
+
+static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
#undef BELL
-#define BELL '\a'
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
-#define issafe(c) (c == '\b' || c == BELL || c == '\r')
-#define xtoa(c) "0123456789abcdef"[c]
-#define XTOA(c) "0123456789ABCDEF"[c]
-
-#define MAXEXTRAS 9
-
-#define MAKEEXTRALIST(flag, extra, orig_str) \
-do { \
- const char *orig = orig_str; \
- const char *o = orig; \
- char *e; \
- while (*o++) \
- continue; \
- extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
- if (!extra) break; \
- for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
- continue; \
- e--; \
- if (flag & VIS_GLOB) { \
- *e++ = '*'; \
- *e++ = '?'; \
- *e++ = '['; \
- *e++ = '#'; \
- } \
- if (flag & VIS_SP) *e++ = ' '; \
- if (flag & VIS_TAB) *e++ = '\t'; \
- if (flag & VIS_NL) *e++ = '\n'; \
- if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
- *e = '\0'; \
-} while (/*CONSTCOND*/0)
+#define BELL L'\a'
+
+#define iswoctal(c) (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
+#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n')
+#define iswsafe(c) (c == L'\b' || c == BELL || c == L'\r')
+#define xtoa(c) L"0123456789abcdef"[c]
+#define XTOA(c) L"0123456789ABCDEF"[c]
+
+#define MAXEXTRAS 10
+
+#if !HAVE_NBTOOL_CONFIG_H
+#ifndef __NetBSD__
+/*
+ * On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer
+ * integral type and it is probably wrong, since currently the maximum
+ * number of bytes and character needs is 6. Until this is fixed, the
+ * loops below are using sizeof(uint64_t) - 1 instead of MB_LEN_MAX, and
+ * the assertion is commented out.
+ */
+#ifdef __FreeBSD__
+/*
+ * On FreeBSD including <sys/systm.h> for CTASSERT only works in kernel
+ * mode.
+ */
+#ifndef CTASSERT
+#define CTASSERT(x) _CTASSERT(x, __LINE__)
+#define _CTASSERT(x, y) __CTASSERT(x, y)
+#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
+#endif
+#endif /* __FreeBSD__ */
+CTASSERT(MB_LEN_MAX <= sizeof(uint64_t));
+#endif /* !__NetBSD__ */
+#endif
/*
* This is do_hvis, for HTTP style (RFC 1808)
*/
-static char *
-do_hvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
+static wchar_t *
+do_hvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
{
-
- if ((isascii(c) && isalnum(c))
+ if (iswalnum(c)
/* safe */
- || c == '$' || c == '-' || c == '_' || c == '.' || c == '+'
+ || c == L'$' || c == L'-' || c == L'_' || c == L'.' || c == L'+'
/* extra */
- || c == '!' || c == '*' || c == '\'' || c == '(' || c == ')'
- || c == ',') {
- dst = do_svis(dst, dlen, c, flag, nextc, extra);
- } else {
- if (dlen) {
- if (*dlen < 3)
- return NULL;
- *dlen -= 3;
- }
- *dst++ = '%';
+ || c == L'!' || c == L'*' || c == L'\'' || c == L'(' || c == L')'
+ || c == L',')
+ dst = do_svis(dst, c, flags, nextc, extra);
+ else {
+ *dst++ = L'%';
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
*dst++ = xtoa((unsigned int)c & 0xf);
}
@@ -151,312 +156,448 @@ do_hvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
* This is do_mvis, for Quoted-Printable MIME (RFC 2045)
* NB: No handling of long lines or CRLF.
*/
-static char *
-do_mvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
+static wchar_t *
+do_mvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
{
- if ((c != '\n') &&
+ if ((c != L'\n') &&
/* Space at the end of the line */
- ((isspace(c) && (nextc == '\r' || nextc == '\n')) ||
+ ((iswspace(c) && (nextc == L'\r' || nextc == L'\n')) ||
/* Out of range */
- (!isspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) ||
- /* Specific char to be escaped */
- strchr("#$@[\\]^`{|}~", c) != NULL)) {
- if (dlen) {
- if (*dlen < 3)
- return NULL;
- *dlen -= 3;
- }
- *dst++ = '=';
+ (!iswspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) ||
+ /* Specific char to be escaped */
+ wcschr(L"#$@[\\]^`{|}~", c) != NULL)) {
+ *dst++ = L'=';
*dst++ = XTOA(((unsigned int)c >> 4) & 0xf);
*dst++ = XTOA((unsigned int)c & 0xf);
- } else {
- dst = do_svis(dst, dlen, c, flag, nextc, extra);
- }
+ } else
+ dst = do_svis(dst, c, flags, nextc, extra);
return dst;
}
/*
- * This is do_vis, the central code of vis.
- * dst: Pointer to the destination buffer
- * c: Character to encode
- * flag: Flag word
- * nextc: The character following 'c'
- * extra: Pointer to the list of extra characters to be
- * backslash-protected.
+ * Output single byte of multibyte character.
*/
-static char *
-do_svis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
+static wchar_t *
+do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
{
- int isextra;
- size_t odlen = dlen ? *dlen : 0;
-
- isextra = strchr(extra, c) != NULL;
-#define HAVE(x) \
- do { \
- if (dlen) { \
- if (*dlen < (x)) \
- goto out; \
- *dlen -= (x); \
- } \
- } while (/*CONSTCOND*/0)
- if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) ||
- ((flag & VIS_SAFE) && issafe(c)))) {
- HAVE(1);
- *dst++ = c;
- return dst;
- }
- if (flag & VIS_CSTYLE) {
- HAVE(2);
+ if (flags & VIS_CSTYLE) {
switch (c) {
- case '\n':
- *dst++ = '\\'; *dst++ = 'n';
+ case L'\n':
+ *dst++ = L'\\'; *dst++ = L'n';
return dst;
- case '\r':
- *dst++ = '\\'; *dst++ = 'r';
+ case L'\r':
+ *dst++ = L'\\'; *dst++ = L'r';
return dst;
- case '\b':
- *dst++ = '\\'; *dst++ = 'b';
+ case L'\b':
+ *dst++ = L'\\'; *dst++ = L'b';
return dst;
case BELL:
- *dst++ = '\\'; *dst++ = 'a';
+ *dst++ = L'\\'; *dst++ = L'a';
return dst;
- case '\v':
- *dst++ = '\\'; *dst++ = 'v';
+ case L'\v':
+ *dst++ = L'\\'; *dst++ = L'v';
return dst;
- case '\t':
- *dst++ = '\\'; *dst++ = 't';
+ case L'\t':
+ *dst++ = L'\\'; *dst++ = L't';
return dst;
- case '\f':
- *dst++ = '\\'; *dst++ = 'f';
+ case L'\f':
+ *dst++ = L'\\'; *dst++ = L'f';
return dst;
- case ' ':
- *dst++ = '\\'; *dst++ = 's';
+ case L' ':
+ *dst++ = L'\\'; *dst++ = L's';
return dst;
- case '\0':
- *dst++ = '\\'; *dst++ = '0';
- if (isoctal(nextc)) {
- HAVE(2);
- *dst++ = '0';
- *dst++ = '0';
+ case L'\0':
+ *dst++ = L'\\'; *dst++ = L'0';
+ if (iswoctal(nextc)) {
+ *dst++ = L'0';
+ *dst++ = L'0';
}
return dst;
default:
- if (isgraph(c)) {
- *dst++ = '\\'; *dst++ = c;
+ if (iswgraph(c)) {
+ *dst++ = L'\\';
+ *dst++ = c;
return dst;
}
- if (dlen)
- *dlen = odlen;
}
}
- if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
- HAVE(4);
- *dst++ = '\\';
- *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0';
- *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0';
- *dst++ = (c & 07) + '0';
+ if (iswextra || ((c & 0177) == L' ') || (flags & VIS_OCTAL)) {
+ *dst++ = L'\\';
+ *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + L'0';
+ *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + L'0';
+ *dst++ = (c & 07) + L'0';
} else {
- if ((flag & VIS_NOSLASH) == 0) {
- HAVE(1);
- *dst++ = '\\';
- }
+ if ((flags & VIS_NOSLASH) == 0)
+ *dst++ = L'\\';
if (c & 0200) {
- HAVE(1);
- c &= 0177; *dst++ = 'M';
+ c &= 0177;
+ *dst++ = L'M';
}
- if (iscntrl(c)) {
- HAVE(2);
- *dst++ = '^';
+ if (iswcntrl(c)) {
+ *dst++ = L'^';
if (c == 0177)
- *dst++ = '?';
+ *dst++ = L'?';
else
- *dst++ = c + '@';
+ *dst++ = c + L'@';
} else {
- HAVE(2);
- *dst++ = '-'; *dst++ = c;
+ *dst++ = L'-';
+ *dst++ = c;
}
}
+
return dst;
-out:
- *dlen = odlen;
- return NULL;
}
-typedef char *(*visfun_t)(char *, size_t *, int, int, int, const char *);
+/*
+ * This is do_vis, the central code of vis.
+ * dst: Pointer to the destination buffer
+ * c: Character to encode
+ * flags: Flags word
+ * nextc: The character following 'c'
+ * extra: Pointer to the list of extra characters to be
+ * backslash-protected.
+ */
+static wchar_t *
+do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
+{
+ int iswextra, i, shft;
+ uint64_t bmsk, wmsk;
+
+ iswextra = wcschr(extra, c) != NULL;
+ if (!iswextra && (iswgraph(c) || iswwhite(c) ||
+ ((flags & VIS_SAFE) && iswsafe(c)))) {
+ *dst++ = c;
+ return dst;
+ }
+
+ /* See comment in istrsenvisx() output loop, below. */
+ wmsk = 0;
+ for (i = sizeof(wmsk) - 1; i >= 0; i--) {
+ shft = i * NBBY;
+ bmsk = (uint64_t)0xffLL << shft;
+ wmsk |= bmsk;
+ if ((c & wmsk) || i == 0)
+ dst = do_mbyte(dst, (wint_t)(
+ (uint64_t)(c & bmsk) >> shft),
+ flags, nextc, iswextra);
+ }
+
+ return dst;
+}
+
+typedef wchar_t *(*visfun_t)(wchar_t *, wint_t, int, wint_t, const wchar_t *);
/*
* Return the appropriate encoding function depending on the flags given.
*/
static visfun_t
-getvisfun(int flag)
+getvisfun(int flags)
{
- if (flag & VIS_HTTPSTYLE)
+ if (flags & VIS_HTTPSTYLE)
return do_hvis;
- if (flag & VIS_MIMESTYLE)
+ if (flags & VIS_MIMESTYLE)
return do_mvis;
return do_svis;
}
/*
- * isnvis - visually encode characters, also encoding the characters
- * pointed to by `extra'
+ * Expand list of extra characters to not visually encode.
*/
-static char *
-isnvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
+static wchar_t *
+makeextralist(int flags, const char *src)
{
- char *nextra = NULL;
- visfun_t f;
+ wchar_t *dst, *d;
+ size_t len;
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(extra != NULL);
- MAKEEXTRALIST(flag, nextra, extra);
- if (!nextra) {
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return NULL;
- }
- *dst = '\0'; /* can't create nextra, return "" */
- return dst;
- }
- f = getvisfun(flag);
- dst = (*f)(dst, dlen, c, flag, nextc, nextra);
- free(nextra);
- if (dst == NULL || (dlen && *dlen == 0)) {
- errno = ENOSPC;
+ len = strlen(src);
+ if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
return NULL;
+
+ if (mbstowcs(dst, src, len) == (size_t)-1) {
+ size_t i;
+ for (i = 0; i < len; i++)
+ dst[i] = (wint_t)(u_char)src[i];
+ d = dst + len;
+ } else
+ d = dst + wcslen(dst);
+
+ if (flags & VIS_GLOB) {
+ *d++ = L'*';
+ *d++ = L'?';
+ *d++ = L'[';
+ *d++ = L'#';
}
- *dst = '\0';
- return dst;
-}
-char *
-svis(char *dst, int c, int flag, int nextc, const char *extra)
-{
- return isnvis(dst, NULL, c, flag, nextc, extra);
-}
+ if (flags & VIS_SP) *d++ = L' ';
+ if (flags & VIS_TAB) *d++ = L'\t';
+ if (flags & VIS_NL) *d++ = L'\n';
+ if ((flags & VIS_NOSLASH) == 0) *d++ = L'\\';
+ *d = L'\0';
-char *
-snvis(char *dst, size_t dlen, int c, int flag, int nextc, const char *extra)
-{
- return isnvis(dst, &dlen, c, flag, nextc, extra);
+ return dst;
}
-
/*
- * strsvis, strsvisx - visually encode characters from src into dst
- *
- * Extra is a pointer to a \0-terminated list of characters to
- * be encoded, too. These functions are useful e. g. to
- * encode strings in such a way so that they are not interpreted
- * by a shell.
- *
- * Dst must be 4 times the size of src to account for possible
- * expansion. The length of dst, not including the trailing NULL,
- * is returned.
- *
- * Strsvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
+ * istrsenvisx()
+ * The main internal function.
+ * All user-visible functions call this one.
*/
static int
-istrsnvis(char *dst, size_t *dlen, const char *csrc, int flag, const char *extra)
+istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
+ int flags, const char *mbextra, int *cerr_ptr)
{
- int c;
- char *start;
- char *nextra = NULL;
- const unsigned char *src = (const unsigned char *)csrc;
+ wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
+ size_t len, olen;
+ uint64_t bmsk, wmsk;
+ wint_t c;
visfun_t f;
-
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(src != NULL);
- _DIAGASSERT(extra != NULL);
- MAKEEXTRALIST(flag, nextra, extra);
- if (!nextra) {
- *dst = '\0'; /* can't create nextra, return "" */
- return 0;
+ int clen = 0, cerr = 0, error = -1, i, shft;
+ ssize_t mbslength, maxolen;
+
+ _DIAGASSERT(mbdst != NULL);
+ _DIAGASSERT(mbsrc != NULL);
+ _DIAGASSERT(mbextra != NULL);
+
+ /*
+ * Input (mbsrc) is a char string considered to be multibyte
+ * characters. The input loop will read this string pulling
+ * one character, possibly multiple bytes, from mbsrc and
+ * converting each to wchar_t in src.
+ *
+ * The vis conversion will be done using the wide char
+ * wchar_t string.
+ *
+ * This will then be converted back to a multibyte string to
+ * return to the caller.
+ */
+
+ /* Allocate space for the wide char strings */
+ psrc = pdst = extra = NULL;
+ if (!mblength)
+ mblength = strlen(mbsrc);
+ if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
+ return -1;
+ if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
+ goto out;
+ dst = pdst;
+ src = psrc;
+
+ /* Use caller's multibyte conversion error flag. */
+ if (cerr_ptr)
+ cerr = *cerr_ptr;
+
+ /*
+ * Input loop.
+ * Handle up to mblength characters (not bytes). We do not
+ * stop at NULs because we may be processing a block of data
+ * that includes NULs.
+ */
+ mbslength = (ssize_t)mblength;
+ /*
+ * When inputing a single character, must also read in the
+ * next character for nextc, the look-ahead character.
+ */
+ if (mbslength == 1)
+ mbslength++;
+ while (mbslength > 0) {
+ /* Convert one multibyte character to wchar_t. */
+ if (!cerr)
+ clen = mbtowc(src, mbsrc, MB_LEN_MAX);
+ if (cerr || clen < 0) {
+ /* Conversion error, process as a byte instead. */
+ *src = (wint_t)(u_char)*mbsrc;
+ clen = 1;
+ cerr = 1;
+ }
+ if (clen == 0)
+ /*
+ * NUL in input gives 0 return value. process
+ * as single NUL byte and keep going.
+ */
+ clen = 1;
+ /* Advance buffer character pointer. */
+ src++;
+ /* Advance input pointer by number of bytes read. */
+ mbsrc += clen;
+ /* Decrement input byte count. */
+ mbslength -= clen;
+ }
+ len = src - psrc;
+ src = psrc;
+ /*
+ * In the single character input case, we will have actually
+ * processed two characters, c and nextc. Reset len back to
+ * just a single character.
+ */
+ if (mblength < len)
+ len = mblength;
+
+ /* Convert extra argument to list of characters for this mode. */
+ extra = makeextralist(flags, mbextra);
+ if (!extra) {
+ if (dlen && *dlen == 0) {
+ errno = ENOSPC;
+ goto out;
+ }
+ *mbdst = '\0'; /* can't create extra, return "" */
+ error = 0;
+ goto out;
}
- f = getvisfun(flag);
- for (start = dst; (c = *src++) != '\0'; /* empty */) {
- dst = (*f)(dst, dlen, c, flag, *src, nextra);
+
+ /* Look up which processing function to call. */
+ f = getvisfun(flags);
+
+ /*
+ * Main processing loop.
+ * Call do_Xvis processing function one character at a time
+ * with next character available for look-ahead.
+ */
+ for (start = dst; len > 0; len--) {
+ c = *src++;
+ dst = (*f)(dst, c, flags, len >= 1 ? *src : L'\0', extra);
if (dst == NULL) {
errno = ENOSPC;
- return -1;
+ goto out;
}
}
- free(nextra);
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return -1;
+
+ /* Terminate the string in the buffer. */
+ *dst = L'\0';
+
+ /*
+ * Output loop.
+ * Convert wchar_t string back to multibyte output string.
+ * If we have hit a multi-byte conversion error on input,
+ * output byte-by-byte here. Else use wctomb().
+ */
+ len = wcslen(start);
+ maxolen = dlen ? *dlen : (wcslen(start) * MB_LEN_MAX + 1);
+ olen = 0;
+ for (dst = start; len > 0; len--) {
+ if (!cerr)
+ clen = wctomb(mbdst, *dst);
+ if (cerr || clen < 0) {
+ /*
+ * Conversion error, process as a byte(s) instead.
+ * Examine each byte and higher-order bytes for
+ * data. E.g.,
+ * 0x000000000000a264 -> a2 64
+ * 0x000000001f00a264 -> 1f 00 a2 64
+ */
+ clen = 0;
+ wmsk = 0;
+ for (i = sizeof(wmsk) - 1; i >= 0; i--) {
+ shft = i * NBBY;
+ bmsk = (uint64_t)0xffLL << shft;
+ wmsk |= bmsk;
+ if ((*dst & wmsk) || i == 0)
+ mbdst[clen++] = (char)(
+ (uint64_t)(*dst & bmsk) >>
+ shft);
+ }
+ cerr = 1;
+ }
+ /* If this character would exceed our output limit, stop. */
+ if (olen + clen > (size_t)maxolen)
+ break;
+ /* Advance output pointer by number of bytes written. */
+ mbdst += clen;
+ /* Advance buffer character pointer. */
+ dst++;
+ /* Incrment output character count. */
+ olen += clen;
}
- *dst = '\0';
- return (int)(dst - start);
+
+ /* Terminate the output string. */
+ *mbdst = '\0';
+
+ /* Pass conversion error flag out. */
+ if (cerr_ptr)
+ *cerr_ptr = cerr;
+
+ free(extra);
+ free(pdst);
+ free(psrc);
+
+ return (int)olen;
+out:
+ free(extra);
+ free(pdst);
+ free(psrc);
+ return error;
}
+#endif
-int
-strsvis(char *dst, const char *csrc, int flag, const char *extra)
+#if !HAVE_SVIS
+/*
+ * The "svis" variants all take an "extra" arg that is a pointer
+ * to a NUL-terminated list of characters to be encoded, too.
+ * These functions are useful e. g. to encode strings in such a
+ * way so that they are not interpreted by a shell.
+ */
+
+char *
+svis(char *mbdst, int c, int flags, int nextc, const char *mbextra)
{
- return istrsnvis(dst, NULL, csrc, flag, extra);
+ char cc[2];
+ int ret;
+
+ cc[0] = c;
+ cc[1] = nextc;
+
+ ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL);
+ if (ret < 0)
+ return NULL;
+ return mbdst + ret;
}
-int
-strsnvis(char *dst, size_t dlen, const char *csrc, int flag, const char *extra)
+char *
+snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra)
{
- return istrsnvis(dst, &dlen, csrc, flag, extra);
+ char cc[2];
+ int ret;
+
+ cc[0] = c;
+ cc[1] = nextc;
+
+ ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL);
+ if (ret < 0)
+ return NULL;
+ return mbdst + ret;
}
-static int
-istrsnvisx(char *dst, size_t *dlen, const char *csrc, size_t len, int flag,
- const char *extra)
+int
+strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
- unsigned char c;
- char *start;
- char *nextra = NULL;
- const unsigned char *src = (const unsigned char *)csrc;
- visfun_t f;
+ return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, mbextra, NULL);
+}
- _DIAGASSERT(dst != NULL);
- _DIAGASSERT(src != NULL);
- _DIAGASSERT(extra != NULL);
- MAKEEXTRALIST(flag, nextra, extra);
- if (! nextra) {
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return -1;
- }
- *dst = '\0'; /* can't create nextra, return "" */
- return 0;
- }
+int
+strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
+{
+ return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, mbextra, NULL);
+}
- f = getvisfun(flag);
- for (start = dst; len > 0; len--) {
- c = *src++;
- dst = (*f)(dst, dlen, c, flag, len > 1 ? *src : '\0', nextra);
- if (dst == NULL) {
- errno = ENOSPC;
- return -1;
- }
- }
- free(nextra);
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return -1;
- }
- *dst = '\0';
- return (int)(dst - start);
+int
+strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra)
+{
+ return istrsenvisx(mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
}
int
-strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
+strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
+ const char *mbextra)
{
- return istrsnvisx(dst, NULL, csrc, len, flag, extra);
+ return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
}
int
-strsnvisx(char *dst, size_t dlen, const char *csrc, size_t len, int flag,
- const char *extra)
+strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
+ const char *mbextra, int *cerr_ptr)
{
- return istrsnvisx(dst, &dlen, csrc, len, flag, extra);
+ return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
}
#endif
@@ -464,120 +605,83 @@ strsnvisx(char *dst, size_t dlen, const char *csrc, size_t len, int flag,
/*
* vis - visually encode characters
*/
-static char *
-invis(char *dst, size_t *dlen, int c, int flag, int nextc)
+char *
+vis(char *mbdst, int c, int flags, int nextc)
{
- char *extra = NULL;
- unsigned char uc = (unsigned char)c;
- visfun_t f;
+ char cc[2];
+ int ret;
- _DIAGASSERT(dst != NULL);
+ cc[0] = c;
+ cc[1] = nextc;
- MAKEEXTRALIST(flag, extra, "");
- if (! extra) {
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return NULL;
- }
- *dst = '\0'; /* can't create extra, return "" */
- return dst;
- }
- f = getvisfun(flag);
- dst = (*f)(dst, dlen, uc, flag, nextc, extra);
- free(extra);
- if (dst == NULL || (dlen && *dlen == 0)) {
- errno = ENOSPC;
+ ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
+ if (ret < 0)
return NULL;
- }
- *dst = '\0';
- return dst;
+ return mbdst + ret;
}
char *
-vis(char *dst, int c, int flag, int nextc)
+nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
{
- return invis(dst, NULL, c, flag, nextc);
-}
+ char cc[2];
+ int ret;
-char *
-nvis(char *dst, size_t dlen, int c, int flag, int nextc)
-{
- return invis(dst, &dlen, c, flag, nextc);
-}
+ cc[0] = c;
+ cc[1] = nextc;
+ ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL);
+ if (ret < 0)
+ return NULL;
+ return mbdst + ret;
+}
/*
- * strvis, strvisx - visually encode characters from src into dst
+ * strvis - visually encode characters from src into dst
*
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
* is returned.
- *
- * Strvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
*/
-static int
-istrnvis(char *dst, size_t *dlen, const char *src, int flag)
-{
- char *extra = NULL;
- int rv;
-
- MAKEEXTRALIST(flag, extra, "");
- if (!extra) {
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return -1;
- }
- *dst = '\0'; /* can't create extra, return "" */
- return 0;
- }
- rv = istrsnvis(dst, dlen, src, flag, extra);
- free(extra);
- return rv;
-}
int
-strvis(char *dst, const char *src, int flag)
+strvis(char *mbdst, const char *mbsrc, int flags)
{
- return istrnvis(dst, NULL, src, flag);
+ return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, "", NULL);
}
int
-strnvis(char *dst, size_t dlen, const char *src, int flag)
+strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
- return istrnvis(dst, &dlen, src, flag);
+ return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, "", NULL);
}
-static int
-istrnvisx(char *dst, size_t *dlen, const char *src, size_t len, int flag)
-{
- char *extra = NULL;
- int rv;
+/*
+ * strvisx - visually encode characters from src into dst
+ *
+ * Dst must be 4 times the size of src to account for possible
+ * expansion. The length of dst, not including the trailing NULL,
+ * is returned.
+ *
+ * Strvisx encodes exactly len characters from src into dst.
+ * This is useful for encoding a block of data.
+ */
- MAKEEXTRALIST(flag, extra, "");
- if (!extra) {
- if (dlen && *dlen == 0) {
- errno = ENOSPC;
- return -1;
- }
- *dst = '\0'; /* can't create extra, return "" */
- return 0;
- }
- rv = istrsnvisx(dst, dlen, src, len, flag, extra);
- free(extra);
- return rv;
+int
+strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
+{
+ return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL);
}
int
-strvisx(char *dst, const char *src, size_t len, int flag)
+strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
{
- return istrnvisx(dst, NULL, src, len, flag);
+ return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL);
}
int
-strnvisx(char *dst, size_t dlen, const char *src, size_t len, int flag)
+strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
+ int *cerr_ptr)
{
- return istrnvisx(dst, &dlen, src, len, flag);
+ return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
}
-
#endif
diff --git a/contrib/libc-vis/vis.h b/contrib/libc-vis/vis.h
index cd7680e..beb029c 100644
--- a/contrib/libc-vis/vis.h
+++ b/contrib/libc-vis/vis.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.20 2012/12/14 21:36:59 christos Exp $ */
+/* $NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $ */
/* $FreeBSD$ */
/*-
@@ -96,9 +96,12 @@ int strsnvis(char *, size_t, const char *, int, const char *);
int strvisx(char *, const char *, size_t, int);
int strnvisx(char *, size_t, const char *, size_t, int);
+int strenvisx(char *, size_t, const char *, size_t, int, int *);
int strsvisx(char *, const char *, size_t, int, const char *);
int strsnvisx(char *, size_t, const char *, size_t, int, const char *);
+int strsenvisx(char *, size_t, const char *, size_t , int, const char *,
+ int *);
int strunvis(char *, const char *);
int strnunvis(char *, size_t, const char *);
diff --git a/contrib/tzdata/africa b/contrib/tzdata/africa
index 54c7a1e..5f4f8eb 100644
--- a/contrib/tzdata/africa
+++ b/contrib/tzdata/africa
@@ -6,7 +6,7 @@
# go ahead and edit the file (and please send any changes to
# tz@iana.org for general use in the future).
-# From Paul Eggert (2006-03-22):
+# From Paul Eggert (2013-02-21):
#
# A good source for time zone historical data outside the U.S. is
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
@@ -25,6 +25,10 @@
# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
# I found in the UCLA library.
#
+# For data circa 1899, a common source is:
+# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
+# <http://www.jstor.org/stable/1774359>.
+#
# A reliable and entertaining source about time zones is
# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
#
@@ -116,8 +120,12 @@ Zone Africa/Porto-Novo 0:10:28 - LMT 1912
1:00 - WAT
# Botswana
+# From Paul Eggert (2013-02-21):
+# Milne says they were regulated by the Cape Town Signal in 1899;
+# assume they switched to 2:00 when Cape Town did.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Gaborone 1:43:40 - LMT 1885
+ 1:30 - SAST 1903 Mar
2:00 - CAT 1943 Sep 19 2:00
2:00 1:00 CAST 1944 Mar 19 2:00
2:00 - CAT
@@ -189,6 +197,11 @@ Zone Africa/Djibouti 2:52:36 - LMT 1911 Jul
# Egypt
+# Milne says Cairo used 2:05:08.9, the local mean time of the Abbasizeh
+# observatory; round to nearest. Milne also says that the official time for
+# Egypt was mean noon at the Great Pyramid, 2:04:30.5, but apparently this
+# did not apply to Cairo, Alexandria, or Port Said.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Egypt 1940 only - Jul 15 0:00 1:00 S
Rule Egypt 1940 only - Oct 1 0:00 0 -
@@ -329,7 +342,7 @@ Rule Egypt 2010 only - Sep 10 0:00 1:00 S
Rule Egypt 2010 only - Sep lastThu 23:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Cairo 2:05:00 - LMT 1900 Oct
+Zone Africa/Cairo 2:05:09 - LMT 1900 Oct
2:00 Egypt EE%sT
# Equatorial Guinea
@@ -833,6 +846,41 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou
# 3:00 am Friday, July 20, 2012 and will again be advanced by 60 minutes
# August 20, 2012 from 2:00 am.
+# From Paul Eggert (2013-03-06):
+# Morocco's daylight-saving transitions due to Ramadan seem to be
+# announced a bit in advance. On 2012-07-11 the Moroccan government
+# announced that year's Ramadan daylight-saving transitions would be
+# 2012-07-20 and 2012-08-20; see
+# <http://www.mmsp.gov.ma/fr/actualites.aspx?id=288>.
+#
+# To estimate what the Moroccan government will do in future years,
+# transition dates for 2013 through 2021 were determined by running
+# the following program under GNU Emacs 24.3:
+#
+# (let ((islamic-year 1434))
+# (while (< islamic-year 1444)
+# (let ((a
+# (calendar-gregorian-from-absolute
+# (calendar-islamic-to-absolute (list 9 1 islamic-year))))
+# (b
+# (calendar-gregorian-from-absolute
+# (calendar-islamic-to-absolute (list 10 1 islamic-year)))))
+# (insert
+# (format
+# (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t %2d\t 3:00\t0\t-\n"
+# "Rule\tMorocco\t%d\tonly\t-\t%s\t %2d\t 2:00\t1:00\tS\n")
+# (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
+# (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
+# (setq islamic-year (+ 1 islamic-year))))
+#
+# with the results hand-edited for 2020-2022, when the normal spring-forward
+# date falls during the estimated Ramadan.
+#
+# From 2023 through 2038 Ramadan is not predicted to overlap with
+# daylight saving time. Starting in 2039 there will be overlap again,
+# but 32-bit time_t values roll around in 2038 so for now do not worry
+# about dates after 2038.
+
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Morocco 1939 only - Sep 12 0:00 1:00 S
@@ -858,10 +906,28 @@ Rule Morocco 2010 only - May 2 0:00 1:00 S
Rule Morocco 2010 only - Aug 8 0:00 0 -
Rule Morocco 2011 only - Apr 3 0:00 1:00 S
Rule Morocco 2011 only - Jul 31 0 0 -
-Rule Morocco 2012 max - Apr lastSun 2:00 1:00 S
+Rule Morocco 2012 2019 - Apr lastSun 2:00 1:00 S
Rule Morocco 2012 max - Sep lastSun 3:00 0 -
Rule Morocco 2012 only - Jul 20 3:00 0 -
Rule Morocco 2012 only - Aug 20 2:00 1:00 S
+Rule Morocco 2013 only - Jul 9 3:00 0 -
+Rule Morocco 2013 only - Aug 8 2:00 1:00 S
+Rule Morocco 2014 only - Jun 29 3:00 0 -
+Rule Morocco 2014 only - Jul 29 2:00 1:00 S
+Rule Morocco 2015 only - Jun 18 3:00 0 -
+Rule Morocco 2015 only - Jul 18 2:00 1:00 S
+Rule Morocco 2016 only - Jun 7 3:00 0 -
+Rule Morocco 2016 only - Jul 7 2:00 1:00 S
+Rule Morocco 2017 only - May 27 3:00 0 -
+Rule Morocco 2017 only - Jun 26 2:00 1:00 S
+Rule Morocco 2018 only - May 16 3:00 0 -
+Rule Morocco 2018 only - Jun 15 2:00 1:00 S
+Rule Morocco 2019 only - May 6 3:00 0 -
+Rule Morocco 2019 only - Jun 5 2:00 1:00 S
+Rule Morocco 2020 only - May 24 2:00 1:00 S
+Rule Morocco 2021 only - May 13 2:00 1:00 S
+Rule Morocco 2022 only - May 3 2:00 1:00 S
+Rule Morocco 2023 max - Apr lastSun 2:00 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
diff --git a/contrib/tzdata/antarctica b/contrib/tzdata/antarctica
index f55cbde..d55924b 100644
--- a/contrib/tzdata/antarctica
+++ b/contrib/tzdata/antarctica
@@ -50,10 +50,8 @@ Rule ChileAQ 2009 only - Mar Sun>=9 3:00u 0 -
Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 -
Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 -
Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule ChileAQ 2012 only - Apr Sun>=23 3:00u 0 -
-Rule ChileAQ 2012 only - Sep Sun>=2 4:00u 1:00 S
-Rule ChileAQ 2013 max - Mar Sun>=9 3:00u 0 -
-Rule ChileAQ 2013 max - Oct Sun>=9 4:00u 1:00 S
+Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 -
+Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S
# These rules are stolen from the `australasia' file.
Rule AusAQ 1917 only - Jan 1 0:01 1:00 -
diff --git a/contrib/tzdata/asia b/contrib/tzdata/asia
index d5562c8..1f09fa3 100644
--- a/contrib/tzdata/asia
+++ b/contrib/tzdata/asia
@@ -6,7 +6,7 @@
# go ahead and edit the file (and please send any changes to
# tz@iana.org for general use in the future).
-# From Paul Eggert (2006-03-22):
+# From Paul Eggert (2013-02-21):
#
# A good source for time zone historical data outside the U.S. is
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
@@ -25,6 +25,10 @@
# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
# I found in the UCLA library.
#
+# For data circa 1899, a common source is:
+# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
+# <http://www.jstor.org/stable/1774359>.
+#
# A reliable and entertaining source about time zones is
# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
#
@@ -279,9 +283,12 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Bandar Seri Begawan
8:00 - BNT
# Burma / Myanmar
+
+# Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon.
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Rangoon 6:24:40 - LMT 1880 # or Yangon
- 6:24:36 - RMT 1920 # Rangoon Mean Time?
+ 6:24:40 - RMT 1920 # Rangoon Mean Time?
6:30 - BURT 1942 May # Burma Time
9:00 - JST 1945 May 3
6:30 - MMT # Myanmar Time
@@ -384,7 +391,8 @@ Zone Asia/Harbin 8:26:44 - LMT 1928 # or Haerbin
8:00 PRC C%sT
# Zhongyuan Time ("Central plain Time")
# most of China
-Zone Asia/Shanghai 8:05:52 - LMT 1928
+# Milne gives 8:05:56.7; round to nearest.
+Zone Asia/Shanghai 8:05:57 - LMT 1928
8:00 Shang C%sT 1949
8:00 PRC C%sT
# Long-shu Time (probably due to Long and Shu being two names of that area)
@@ -481,6 +489,10 @@ Zone Asia/Kashgar 5:03:56 - LMT 1928 # or Kashi or Kaxgar
8:00 PRC C%sT
+# Hong Kong (Xianggang)
+
+# Milne gives 7:36:41.7; round this.
+
# From Lee Yiu Chung (2009-10-24):
# I found there are some mistakes for the...DST rule for Hong
# Kong. [According] to the DST record from Hong Kong Observatory (actually,
@@ -547,7 +559,6 @@ Zone Asia/Kashgar 5:03:56 - LMT 1928 # or Kashi or Kaxgar
# The Japanese surrender of Hong Kong was signed 1945-09-15.
# For lack of anything better, use start of those days as the transition times.
-# Hong Kong (Xianggang)
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule HK 1941 only - Apr 1 3:30 1:00 S
Rule HK 1941 only - Sep 30 3:30 0 -
@@ -569,7 +580,7 @@ Rule HK 1973 only - Dec 30 3:30 1:00 S
Rule HK 1979 only - May Sun>=8 3:30 1:00 S
Rule HK 1979 only - Oct Sun>=16 3:30 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Hong_Kong 7:36:36 - LMT 1904 Oct 30
+Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30
8:00 HK HK%sT 1941 Dec 25
9:00 - JST 1945 Sep 15
8:00 HK HK%sT
@@ -646,6 +657,9 @@ Zone Asia/Macau 7:34:20 - LMT 1912
###############################################################################
# Cyprus
+#
+# Milne says the Eastern Telegraph Company used 2:14:00. Stick with LMT.
+#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Cyprus 1975 only - Apr 13 0:00 1:00 S
Rule Cyprus 1975 only - Oct 12 0:00 0 -
@@ -1804,8 +1818,11 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920
5:45 - NPT # Nepal Time
# Oman
+
+# Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory.
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Muscat 3:54:20 - LMT 1920
+Zone Asia/Muscat 3:54:24 - LMT 1920
4:00 - GST
# Pakistan
@@ -2400,6 +2417,13 @@ Zone Asia/Singapore 6:55:25 - LMT 1901 Jan 1
# no information
# Sri Lanka
+
+# From Paul Eggert (2013-02-21):
+# Milne says "Madras mean time use from May 1, 1898. Prior to this Colombo
+# mean time, 5h. 4m. 21.9s. F., was used." But 5:04:21.9 differs considerably
+# from Colombo's meridian 5:19:24, so for now ignore Milne and stick with
+# Shanks and Pottenger.
+
# From Paul Eggert (1996-09-03):
# "Sri Lanka advances clock by an hour to avoid blackout"
# (www.virtual-pc.com/lankaweb/news/items/240596-2.html, 1996-05-24,
@@ -2699,6 +2723,12 @@ Zone Asia/Tashkent 4:37:12 - LMT 1924 May 2
# Vietnam
+# From Paul Eggert (2013-02-21):
+# Milne gives 7:16:56 for the meridian of Saigon in 1899, as being
+# used in Lower Laos, Cambodia, and Annam. But this is quite a ways
+# from Saigon's location. For now, ignore this and stick with Shanks
+# and Pottenger.
+
# From Arthur David Olson (2008-03-18):
# The English-language name of Vietnam's most populous city is "Ho Chi Min City";
# we use Ho_Chi_Minh below to avoid a name of more than 14 characters.
@@ -2712,6 +2742,10 @@ Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jun 9
7:00 - ICT
# Yemen
+
+# Milne says 2:59:54 was the meridian of the saluting battery at Aden,
+# and that Yemen was at 1:55:56, the meridian of the Hagia Sophia.
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Aden 3:00:48 - LMT 1950
+Zone Asia/Aden 2:59:54 - LMT 1950
3:00 - AST
diff --git a/contrib/tzdata/australasia b/contrib/tzdata/australasia
index bef6f20..58df73d 100644
--- a/contrib/tzdata/australasia
+++ b/contrib/tzdata/australasia
@@ -246,6 +246,9 @@ Zone Indian/Cocos 6:27:40 - LMT 1900
6:30 - CCT # Cocos Islands Time
# Fiji
+
+# Milne gives 11:55:44 for Suva.
+
# From Alexander Krivenyshev (2009-11-10):
# According to Fiji Broadcasting Corporation, Fiji plans to re-introduce DST
# from November 29th 2009 to April 25th 2010.
@@ -339,7 +342,7 @@ Rule Fiji 2010 max - Oct Sun>=18 2:00 1:00 S
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
Rule Fiji 2012 max - Jan Sun>=18 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Pacific/Fiji 11:53:40 - LMT 1915 Oct 26 # Suva
+Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva
12:00 Fiji FJ%sT # Fiji Time
# French Polynesia
@@ -782,7 +785,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
# go ahead and edit the file (and please send any changes to
# tz@iana.org for general use in the future).
-# From Paul Eggert (2006-03-22):
+# From Paul Eggert (2013-02-21):
# A good source for time zone historical data outside the U.S. is
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
# San Diego: ACS Publications, Inc. (2003).
@@ -800,6 +803,10 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
# I found in the UCLA library.
#
+# For data circa 1899, a common source is:
+# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
+# <http://www.jstor.org/stable/1774359>.
+#
# A reliable and entertaining source about time zones is
# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
#
diff --git a/contrib/tzdata/europe b/contrib/tzdata/europe
index ad9816c..5081a52 100644
--- a/contrib/tzdata/europe
+++ b/contrib/tzdata/europe
@@ -30,6 +30,12 @@
# William Willett, The Waste of Daylight, 19th edition
# </a> (1914-03)
#
+# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
+# <http://www.jstor.org/stable/1774359>. He writes:
+# "It is requested that corrections and additions to these tables
+# may be sent to Mr. John Milne, Royal Geographical Society,
+# Savile Row, London." Nowadays please email them to tz@iana.org.
+#
# Brazil's Departamento Servico da Hora (DSH),
# <a href="http://pcdsh01.on.br/HISTHV.htm">
# History of Summer Time
@@ -666,6 +672,8 @@ Zone Europe/Andorra 0:06:04 - LMT 1901
# Austria
+# Milne says Vienna time was 1:05:21.
+
# From Paul Eggert (2006-03-22): Shanks & Pottenger give 1918-06-16 and
# 1945-11-18, but the Austrian Federal Office of Metrology and
# Surveying (BEV) gives 1918-09-16 and for Vienna gives the "alleged"
@@ -683,7 +691,7 @@ Rule Austria 1948 only - Apr 18 2:00s 1:00 S
Rule Austria 1980 only - Apr 6 0:00 1:00 S
Rule Austria 1980 only - Sep 28 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Europe/Vienna 1:05:20 - LMT 1893 Apr
+Zone Europe/Vienna 1:05:21 - LMT 1893 Apr
1:00 C-Eur CE%sT 1920
1:00 Austria CE%sT 1940 Apr 1 2:00s
1:00 C-Eur CE%sT 1945 Apr 2 2:00s
@@ -1239,6 +1247,21 @@ Zone Europe/Berlin 0:53:28 - LMT 1893 Apr
1:00 Germany CE%sT 1980
1:00 EU CE%sT
+# From Tobias Conradi (2011-09-12):
+# Busingen <http://www.buesingen.de>, surrounded by the Swiss canton
+# Schaffhausen, did not start observing DST in 1980 as the rest of DE
+# (West Germany at that time) and DD (East Germany at that time) did.
+# DD merged into DE, the area is currently covered by code DE in ISO 3166-1,
+# which in turn is covered by the zone Europe/Berlin.
+#
+# Source for the time in Busingen 1980:
+# http://www.srf.ch/player/video?id=c012c029-03b7-4c2b-9164-aa5902cd58d3
+
+# From Arthur David Olson (2012-03-03):
+# Busingen and Zurich have shared clocks since 1970.
+
+Link Europe/Zurich Europe/Busingen
+
# Georgia
# Please see the "asia" file for Asia/Tbilisi.
# Herodotus (Histories, IV.45) says Georgia north of the Phasis (now Rioni)
@@ -2043,6 +2066,70 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct
# Russia
+# From Alexander Krivenyshev (2011-09-15):
+# Based on last Russian Government Decree # 725 on August 31, 2011
+# (Government document
+# <a href="http://www.government.ru/gov/results/16355/print/">
+# http://www.government.ru/gov/results/16355/print/
+# </a>
+# in Russian)
+# there are few corrections have to be made for some Russian time zones...
+# All updated Russian Time Zones were placed in table and translated to English
+# by WorldTimeZone.com at the link below:
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_russia36.htm">
+# http://www.worldtimezone.com/dst_news/dst_news_russia36.htm
+# </a>
+
+# From Sanjeev Gupta (2011-09-27):
+# Scans of [Decree #23 of January 8, 1992] are available at:
+# <a href="http://government.consultant.ru/page.aspx?1223966">
+# http://government.consultant.ru/page.aspx?1223966
+# They are in Cyrillic letters (presumably Russian).
+
+# From Arthur David Olson (2012-05-09):
+# Regarding the instant when clocks in time-zone-shifting parts of Russia
+# changed in September 2011:
+#
+# One source is
+# < a href="http://government.ru/gov/results/16355/>
+# http://government.ru/gov/results/16355/
+# </a>
+# which, according to translate.google.com, begins "Decree of August 31,
+# 2011 No 725" and contains no other dates or "effective date" information.
+#
+# Another source is
+# <a href="http://www.rg.ru/2011/09/06/chas-zona-dok.html">
+# http://www.rg.ru/2011/09/06/chas-zona-dok.html
+# </a>
+# which, according to translate.google.com, begins "Resolution of the
+# Government of the Russian Federation on August 31, 2011 N 725" and also
+# contains "Date first official publication: September 6, 2011 Posted on:
+# in the 'RG' - Federal Issue number 5573 September 6, 2011" but which
+# does not contain any "effective date" information.
+#
+# Another source is
+# <a href="http://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7">
+# http://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7
+# </a>
+# which, in note 8, contains "Resolution #725 of August 31, 2011...
+# Effective as of after 7 days following the day of the official publication"
+# but which does not contain any reference to September 6, 2011.
+#
+# The Wikipedia article refers to
+# <a href="http://base.consultant.ru/cons/cgi/online.cgi?req=doc;base=LAW;n=118896">
+# http://base.consultant.ru/cons/cgi/online.cgi?req=doc;base=LAW;n=118896
+# </a>
+# which seems to copy the text of the government.ru page.
+#
+# Tobias Conradi combines Wikipedia's
+# "as of after 7 days following the day of the official publication"
+# with www.rg.ru's "Date of first official publication: September 6, 2011" to get
+# September 13, 2011 as the cutover date (unusually, a Tuesday, as Tobias Conradi notes).
+#
+# None of the sources indicates a time of day for changing clocks.
+#
+# Go with 2011-09-13 0:00s.
+
# From Paul Eggert (2006-03-22):
# Except for Moscow after 1919-07-01, I invented the time zone abbreviations.
# Moscow time zone abbreviations after 1919-07-01, and Moscow rules after 1991,
@@ -2270,14 +2357,32 @@ Zone Asia/Yakutsk 8:38:40 - LMT 1919 Dec 15
# [parts of] Respublika Sakha (Yakutiya).
# From Oscar van Vlijmen (2009-11-29):
-# The Sakha districts are: Bulunskij, Verkhoyanskij, Tomponskij, Ust'-Majskij,
-# Ust'-Yanskij.
+# The Sakha districts are: Bulunskij, Verkhoyanskij, ... Ust'-Yanskij.
Zone Asia/Vladivostok 8:47:44 - LMT 1922 Nov 15
9:00 - VLAT 1930 Jun 21 # Vladivostok Time
10:00 Russia VLA%sT 1991 Mar 31 2:00s
9:00 Russia VLA%sST 1992 Jan 19 2:00s
10:00 Russia VLA%sT 2011 Mar 27 2:00s
11:00 - VLAT
+
+# From Arthur David Olson (2012-05-09):
+# Tomponskij and Ust'-Majskij switched from Vladivostok time to Yakutsk time
+# in 2011.
+#
+# From Paul Eggert (2012-11-25):
+# Shanks and Pottenger (2003) has Khandyga on Yakutsk time.
+# Make a wild guess that it switched to Vladivostok time in 2004.
+# This transition is no doubt wrong, but we have no better info.
+#
+Zone Asia/Khandyga 9:02:13 - LMT 1919 Dec 15
+ 8:00 - YAKT 1930 Jun 21 # Yakutsk Time
+ 9:00 Russia YAK%sT 1991 Mar 31 2:00s
+ 8:00 Russia YAK%sT 1992 Jan 19 2:00s
+ 9:00 Russia YAK%sT 2004
+ 10:00 Russia VLA%sT 2011 Mar 27 2:00s
+ 11:00 - VLAT 2011 Sep 13 0:00s # Decree 725?
+ 10:00 - YAKT
+
#
# Sakhalinskaya oblast'.
# The Zone name should be Yuzhno-Sakhalinsk, but that's too long.
@@ -2296,14 +2401,26 @@ Zone Asia/Sakhalin 9:30:48 - LMT 1905 Aug 23
# From Oscar van Vlijmen (2009-11-29):
# The Sakha districts are: Abyjskij, Allaikhovskij, Verkhhhnekolymskij, Momskij,
-# Nizhnekolymskij, Ojmyakonskij, Srednekolymskij.
+# Nizhnekolymskij, ... Srednekolymskij.
Zone Asia/Magadan 10:03:12 - LMT 1924 May 2
10:00 - MAGT 1930 Jun 21 # Magadan Time
11:00 Russia MAG%sT 1991 Mar 31 2:00s
10:00 Russia MAG%sT 1992 Jan 19 2:00s
11:00 Russia MAG%sT 2011 Mar 27 2:00s
12:00 - MAGT
-#
+
+# From Arthur David Olson (2012-05-09):
+# Ojmyakonskij and the Kuril Islands switched from
+# Magadan time to Vladivostok time in 2011.
+Zone Asia/Ust-Nera 9:32:54 - LMT 1919 Dec 15
+ 8:00 - YAKT 1930 Jun 21 # Yakutsk Time
+ 9:00 Russia YAKT 1981 Apr 1
+ 11:00 Russia MAG%sT 1991 Mar 31 2:00s
+ 10:00 Russia MAG%sT 1992 Jan 19 2:00s
+ 11:00 Russia MAG%sT 2011 Mar 27 2:00s
+ 12:00 - MAGT 2011 Sep 13 0:00s # Decree 725?
+ 11:00 - VLAT
+
# From Oscar van Vlijmen (2001-08-25): [This region consists of]
# Kamchatskaya oblast', Koryakskij avtonomnyj okrug.
#
diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica
index 772d7a4..1964903 100644
--- a/contrib/tzdata/northamerica
+++ b/contrib/tzdata/northamerica
@@ -1019,6 +1019,9 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00
# William Willett, The Waste of Daylight, 19th edition
# </a> (1914-03)
#
+# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
+# <http://www.jstor.org/stable/1774359>.
+#
# See the `europe' file for Greenland.
# Canada
@@ -2554,6 +2557,8 @@ Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
# Bahamas
#
+# For 1899 Milne gives -5:09:29.5; round that.
+#
# From Sue Williams (2006-12-07):
# The Bahamas announced about a month ago that they plan to change their DST
# rules to sync with the U.S. starting in 2007....
@@ -2563,11 +2568,14 @@ Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
Rule Bahamas 1964 1975 - Oct lastSun 2:00 0 S
Rule Bahamas 1964 1975 - Apr lastSun 2:00 1:00 D
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Nassau -5:09:24 - LMT 1912 Mar 2
+Zone America/Nassau -5:09:30 - LMT 1912 Mar 2
-5:00 Bahamas E%sT 1976
-5:00 US E%sT
# Barbados
+
+# For 1899 Milne gives -3:58:29.2; round that.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Barb 1977 only - Jun 12 2:00 1:00 D
Rule Barb 1977 1978 - Oct Sun>=1 2:00 0 S
@@ -2575,8 +2583,8 @@ Rule Barb 1978 1980 - Apr Sun>=15 2:00 1:00 D
Rule Barb 1979 only - Sep 30 2:00 0 S
Rule Barb 1980 only - Sep 25 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Barbados -3:58:28 - LMT 1924 # Bridgetown
- -3:58:28 - BMT 1932 # Bridgetown Mean Time
+Zone America/Barbados -3:58:29 - LMT 1924 # Bridgetown
+ -3:58:29 - BMT 1932 # Bridgetown Mean Time
-4:00 Barb A%sT
# Belize
@@ -2594,6 +2602,9 @@ Zone America/Belize -5:52:48 - LMT 1912 Apr
# Bermuda
+# For 1899 Milne gives -4:19:18.3 as the meridian of the clock tower,
+# Bermuda dockyard, Ireland I; round that.
+
# From Dan Jones, reporting in The Royal Gazette (2006-06-26):
# Next year, however, clocks in the US will go forward on the second Sunday
@@ -2603,7 +2614,7 @@ Zone America/Belize -5:52:48 - LMT 1912 Apr
# http://www.theroyalgazette.com/apps/pbcs.dll/article?AID=/20060529/NEWS/105290135
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Atlantic/Bermuda -4:19:04 - LMT 1930 Jan 1 2:00 # Hamilton
+Zone Atlantic/Bermuda -4:19:18 - LMT 1930 Jan 1 2:00 # Hamilton
-4:00 - AST 1974 Apr 28 2:00
-4:00 Bahamas A%sT 1976
-4:00 US A%sT
@@ -2615,6 +2626,9 @@ Zone America/Cayman -5:25:32 - LMT 1890 # Georgetown
-5:00 - EST
# Costa Rica
+
+# Milne gives -5:36:13.3 as San Jose mean time; round to nearest.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule CR 1979 1980 - Feb lastSun 0:00 1:00 D
Rule CR 1979 1980 - Jun Sun>=1 0:00 0 S
@@ -2625,14 +2639,19 @@ Rule CR 1991 only - Jul 1 0:00 0 S
Rule CR 1992 only - Mar 15 0:00 0 S
# There are too many San Joses elsewhere, so we'll use `Costa Rica'.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Costa_Rica -5:36:20 - LMT 1890 # San Jose
- -5:36:20 - SJMT 1921 Jan 15 # San Jose Mean Time
+Zone America/Costa_Rica -5:36:13 - LMT 1890 # San Jose
+ -5:36:13 - SJMT 1921 Jan 15 # San Jose Mean Time
-6:00 CR C%sT
# Coco
# no information; probably like America/Costa_Rica
# Cuba
+# From Paul Eggert (2013-02-21):
+# Milne gives -5:28:50.45 for the observatory at Havana, -5:29:23.57
+# for the port, and -5:30 for meteorological observations.
+# For now, stick with Shanks & Pottenger.
+
# From Arthur David Olson (1999-03-29):
# The 1999-03-28 exhibition baseball game held in Havana, Cuba, between
# the Cuban National Team and the Baltimore Orioles was carried live on
@@ -2981,24 +3000,21 @@ Zone America/Guatemala -6:02:04 - LMT 1918 Oct 5
# apparently using the same start and end date as USA/Canada.
# So this means they have already changed their time.
#
-# (Sources in French):
-# <a href="http://www.alterpresse.org/spip.php?article12510">
# http://www.alterpresse.org/spip.php?article12510
-# </a>
-# <a href="http://radiovision2000haiti.net/home/?p=13253">
# http://radiovision2000haiti.net/home/?p=13253
-# </a>
#
-# Our coverage:
-# <a href="http://www.timeanddate.com/news/time/haiti-dst-2012.html">
-# http://www.timeanddate.com/news/time/haiti-dst-2012.html
-# </a>
-
# From Arthur David Olson (2012-03-11):
# The alterpresse.org source seems to show a US-style leap from 2:00 a.m. to
# 3:00 a.m. rather than the traditional Haitian jump at midnight.
-# Assume a US-style fall back as well XXX.
-# Do not yet assume that the change carries forward past 2012 XXX.
+# Assume a US-style fall back as well.
+
+# From Steffen Thorsen (2013-03-10):
+# It appears that Haiti is observing DST this year as well, same rules
+# as US/Canada. They did it last year as well, and it looks like they
+# are going to observe DST every year now...
+#
+# http://radiovision2000haiti.net/public/haiti-avis-changement-dheure-dimanche/
+# http://www.canalplushaiti.net/?p=6714
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Haiti 1983 only - May 8 0:00 1:00 D
@@ -3010,8 +3026,8 @@ Rule Haiti 1988 1997 - Apr Sun>=1 1:00s 1:00 D
Rule Haiti 1988 1997 - Oct lastSun 1:00s 0 S
Rule Haiti 2005 2006 - Apr Sun>=1 0:00 1:00 D
Rule Haiti 2005 2006 - Oct lastSun 0:00 0 S
-Rule Haiti 2012 only - Mar Sun>=8 2:00 1:00 D
-Rule Haiti 2012 only - Nov Sun>=1 2:00 0 S
+Rule Haiti 2012 max - Mar Sun>=8 2:00 1:00 D
+Rule Haiti 2012 max - Nov Sun>=1 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Port-au-Prince -4:49:20 - LMT 1890
-4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT
diff --git a/contrib/tzdata/southamerica b/contrib/tzdata/southamerica
index 3301a43..9ef8b82 100644
--- a/contrib/tzdata/southamerica
+++ b/contrib/tzdata/southamerica
@@ -11,6 +11,10 @@
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
# San Diego: ACS Publications, Inc. (2003).
#
+# For data circa 1899, a common source is:
+# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
+# <http://www.jstor.org/stable/1774359>.
+#
# Gwillim Law writes that a good source
# for recent time zone data is the International Air Transport
# Association's Standard Schedules Information Manual (IATA SSIM),
@@ -381,21 +385,11 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S
# <a/>
# is the official page for the Province Government).
#
-# There's also a note in only one of the major national papers (La Nación) at
-# <a href="http://www.lanacion.com.ar/nota.asp?nota_id=1107912">
+# There's also a note in only one of the major national papers ...
# http://www.lanacion.com.ar/nota.asp?nota_id=1107912
-# </a>
-#
-# The press release says:
-# (...) anunció que el próximo domingo a las 00:00 los puntanos deberán
-# atrasar una hora sus relojes.
#
-# A partir de entonces, San Luis establecerá el huso horario propio de
-# la Provincia. De esta manera, durante el periodo del calendario anual
-# 2009, el cambio horario quedará comprendido entre las 00:00 del tercer
-# domingo de marzo y las 24:00 del segundo sábado de octubre.
-# Quick&dirty translation
-# (...) announced that next Sunday, at 00:00, Puntanos (the San Luis
+# The press release says [quick and dirty translation]:
+# ... announced that next Sunday, at 00:00, Puntanos (the San Luis
# inhabitants) will have to turn back one hour their clocks
#
# Since then, San Luis will establish its own Province timezone. Thus,
@@ -457,6 +451,9 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S
# rules...San Luis is still using "Western ARgentina Time" and it got
# stuck on Summer daylight savings time even though the summer is over.
+# From Paul Eggert (2013-02-21):
+# Milne says Cordoba time was -4:16:48.2. Round to the nearest second.
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
#
# Buenos Aires (BA), Capital Federal (CF),
@@ -812,9 +809,9 @@ Zone America/La_Paz -4:32:36 - LMT 1890
# From Guilherme Bernardes Rodrigues (2011-10-07):
# There is news in the media, however there is still no decree about it.
-# I just send a e-mail to Zulmira Brandão at
+# I just send a e-mail to Zulmira Brandao at
# <a href="http://pcdsh01.on.br/">http://pcdsh01.on.br/</a> the
-# oficial agency about time in Brazil, and she confirmed that the old rule is
+# official agency about time in Brazil, and she confirmed that the old rule is
# still in force.
# From Guilherme Bernardes Rodrigues (2011-10-14)
@@ -1243,9 +1240,13 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
# b. Saturday, September 1, 2012, clocks should go forward 60 minutes; that is,
# at 23:59:59, instead of passing to 0:00, the time should be adjusted to be
# 01:00 on September 2.
-#
-# Note that...this is yet another "temporary" change that will be reevaluated
-# AGAIN in 2013.
+
+# From Steffen Thorsen (2013-02-15):
+# According to several news sources, Chile has extended DST this year,
+# they will end DST later and start DST earlier than planned. They
+# hope to save energy. The new end date is 2013-04-28 00:00 and new
+# start date is 2013-09-08 00:00....
+# http://www.gob.cl/informa/2013/02/15/gobierno-anuncia-fechas-de-cambio-de-hora-para-el-ano-2013.htm
# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
# 'antarctica' file.
@@ -1288,10 +1289,8 @@ Rule Chile 2009 only - Mar Sun>=9 3:00u 0 -
Rule Chile 2010 only - Apr Sun>=1 3:00u 0 -
Rule Chile 2011 only - May Sun>=2 3:00u 0 -
Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule Chile 2012 only - Apr Sun>=23 3:00u 0 -
-Rule Chile 2012 only - Sep Sun>=2 4:00u 1:00 S
-Rule Chile 2013 max - Mar Sun>=9 3:00u 0 -
-Rule Chile 2013 max - Oct Sun>=9 4:00u 1:00 S
+Rule Chile 2012 max - Apr Sun>=23 3:00u 0 -
+Rule Chile 2012 max - Sep Sun>=2 4:00u 1:00 S
# IATA SSIM anomalies: (1992-02) says 1992-03-14;
# (1996-09) says 1998-03-08. Ignore these.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1313,17 +1312,23 @@ Zone Pacific/Easter -7:17:44 - LMT 1890
# San Felix, and Antarctic bases, are like America/Santiago.
# Colombia
+
+# Milne gives 4:56:16.4 for Bogota time in 1899; round to nearest. He writes,
+# "A variation of fifteen minutes in the public clocks of Bogota is not rare."
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule CO 1992 only - May 3 0:00 1:00 S
Rule CO 1993 only - Apr 4 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Bogota -4:56:20 - LMT 1884 Mar 13
- -4:56:20 - BMT 1914 Nov 23 # Bogota Mean Time
+Zone America/Bogota -4:56:16 - LMT 1884 Mar 13
+ -4:56:16 - BMT 1914 Nov 23 # Bogota Mean Time
-5:00 CO CO%sT # Colombia Time
# Malpelo, Providencia, San Andres
# no information; probably like America/Bogota
# Curacao
+
+# Milne gives 4:35:46.9 for Curacao mean time; round to nearest.
#
# From Paul Eggert (2006-03-22):
# Shanks & Pottenger say that The Bottom and Philipsburg have been at
@@ -1340,7 +1345,7 @@ Zone America/Bogota -4:56:20 - LMT 1884 Mar 13
# though, as far as we know.
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Curacao -4:35:44 - LMT 1912 Feb 12 # Willemstad
+Zone America/Curacao -4:35:47 - LMT 1912 Feb 12 # Willemstad
-4:30 - ANT 1965 # Netherlands Antilles Time
-4:00 - AST
@@ -1354,6 +1359,8 @@ Link America/Curacao America/Kralendijk # Bonaire, Sint Estatius and Saba
# Ecuador
#
+# Milne says the Sentral and South American Telegraph Company used -5:24:15.
+#
# From Paul Eggert (2007-03-04):
# Apparently Ecuador had a failed experiment with DST in 1992.
# <http://midena.gov.ec/content/view/1261/208/> (2007-02-27) and
@@ -1560,6 +1567,15 @@ Rule Para 2005 2009 - Mar Sun>=8 0:00 0 -
# ...
Rule Para 2010 max - Oct Sun>=1 0:00 1:00 S
Rule Para 2010 max - Apr Sun>=8 0:00 0 -
+#
+# From Steffen Thorsen (2013-03-07):
+# Paraguay will end DST on 2013-03-24 00:00....
+# They do not tell if this will be a permanent change or just this year....
+# http://www.ande.gov.py/interna.php?id=1075
+#
+# From Paul Eggert (2013-03-07):
+# For now, assume it's just this year.
+Rule Para 2013 only - Mar 24 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Asuncion -3:50:40 - LMT 1890
diff --git a/contrib/tzdata/zone.tab b/contrib/tzdata/zone.tab
index 97e3ea6..fd05b9c 100644
--- a/contrib/tzdata/zone.tab
+++ b/contrib/tzdata/zone.tab
@@ -159,7 +159,8 @@ CW +1211-06900 America/Curacao
CX -1025+10543 Indian/Christmas
CY +3510+03322 Asia/Nicosia
CZ +5005+01426 Europe/Prague
-DE +5230+01322 Europe/Berlin
+DE +5230+01322 Europe/Berlin most locations
+DE +4742+00841 Europe/Busingen Busingen
DJ +1136+04309 Africa/Djibouti
DK +5540+01235 Europe/Copenhagen
DM +1518-06124 America/Dominica
@@ -341,8 +342,10 @@ RU +5345+08707 Asia/Novokuznetsk Moscow+03 - Novokuznetsk
RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River
RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal
RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River
+RU +623923+1353314 Asia/Khandyga Moscow+06 - Tomponsky, Ust-Maysky
RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River
RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island
+RU +643337+1431336 Asia/Ust-Nera Moscow+07 - Oymyakonsky
RU +5934+15048 Asia/Magadan Moscow+08 - Magadan
RU +5301+15839 Asia/Kamchatka Moscow+08 - Kamchatka
RU +6445+17729 Asia/Anadyr Moscow+08 - Bering Sea
diff --git a/contrib/unvis/Makefile b/contrib/unvis/Makefile
new file mode 100644
index 0000000..677e61d
--- /dev/null
+++ b/contrib/unvis/Makefile
@@ -0,0 +1,6 @@
+# $NetBSD: Makefile,v 1.3 1994/12/06 07:36:07 jtc Exp $
+# @(#)Makefile 8.1 (Berkeley) 6/6/93
+
+PROG= unvis
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/unvis/unvis.1 b/contrib/unvis/unvis.1
index e40d8df..5c84671 100644
--- a/usr.bin/unvis/unvis.1
+++ b/contrib/unvis/unvis.1
@@ -1,3 +1,5 @@
+.\" $NetBSD: unvis.1,v 1.10 2012/12/15 02:08:13 uwe Exp $
+.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,7 +11,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -26,9 +28,8 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)unvis.1 8.1 (Berkeley) 6/6/93
-.\" $FreeBSD$
.\"
-.Dd June 6, 1993
+.Dd November 27, 2010
.Dt UNVIS 1
.Os
.Sh NAME
@@ -36,14 +37,38 @@
.Nd "revert a visual representation of data back to original form"
.Sh SYNOPSIS
.Nm
-.Op Ar
+.Op Fl e
+.Op Fl Hh | Fl m
+.Op Ar file ...
.Sh DESCRIPTION
-The
.Nm
-utility is the inverse function of
+is the inverse function of
.Xr vis 1 .
It reverts
a visual representation of data back to its original form on standard output.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl e
+Don't decode \e escaped sequences.
+.It Fl H
+Decode entity references and numeric character references from RFC 1866.
+.Pq Dv VIS_HTTP1866
+.It Fl h
+Decode using the URI encoding from RFC 1808.
+.Pq Dv VIS_HTTP1808
+.It Fl m
+Decode using mime style.
+.Pq Dv VIS_MIMESTYLE
+.El
+.Pp
+Mixing
+.Fl h
+or
+.Fl H
+with
+.Fl m
+is not supported.
.Sh SEE ALSO
.Xr vis 1 ,
.Xr unvis 3 ,
@@ -51,5 +76,5 @@ a visual representation of data back to its original form on standard output.
.Sh HISTORY
The
.Nm
-command appeared in
+command appears in
.Bx 4.4 .
diff --git a/usr.bin/unvis/unvis.c b/contrib/unvis/unvis.c
index 0ae054b..d854a37 100644
--- a/usr.bin/unvis/unvis.c
+++ b/contrib/unvis/unvis.c
@@ -1,3 +1,5 @@
+/* $NetBSD: unvis.c,v 1.13 2010/11/27 19:46:25 christos Exp $ */
+
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -10,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -27,18 +29,17 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1989, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
+__RCSID("$NetBSD: unvis.c,v 1.13 2010/11/27 19:46:25 christos Exp $");
#endif /* not lint */
#include <err.h>
@@ -47,46 +48,64 @@ static const char rcsid[] =
#include <unistd.h>
#include <vis.h>
-void process(FILE *, const char *);
-static void usage(void);
+static void process(FILE *, const char *, int);
int
main(int argc, char *argv[])
{
FILE *fp;
- int ch;
+ int ch, eflags = 0;
- while ((ch = getopt(argc, argv, "")) != -1)
+ setprogname(argv[0]);
+ while ((ch = getopt(argc, argv, "eHhm")) != -1)
switch((char)ch) {
+ case 'e':
+ eflags |= VIS_NOESCAPE;
+ break;
+ case 'H':
+ eflags |= VIS_HTTP1866;
+ break;
+ case 'h':
+ eflags |= VIS_HTTP1808;
+ break;
+ case 'm':
+ eflags |= VIS_MIMESTYLE;
+ break;
case '?':
default:
- usage();
+ (void)fprintf(stderr,
+ "Usage: %s [-e] [-Hh | -m] [file...]\n",
+ getprogname());
+ return EXIT_FAILURE;
}
argc -= optind;
argv += optind;
+ switch (eflags & (VIS_HTTP1808|VIS_HTTP1866|VIS_MIMESTYLE)) {
+ case VIS_HTTP1808|VIS_MIMESTYLE:
+ case VIS_HTTP1866|VIS_MIMESTYLE:
+ case VIS_HTTP1808|VIS_HTTP1866|VIS_MIMESTYLE:
+ errx(EXIT_FAILURE, "Can't mix -m with -h and/or -H");
+ /*NOTREACHED*/
+ default:
+ break;
+ }
+
if (*argv)
while (*argv) {
- if ((fp=fopen(*argv, "r")) != NULL)
- process(fp, *argv);
+ if ((fp = fopen(*argv, "r")) != NULL)
+ process(fp, *argv, eflags);
else
warn("%s", *argv);
argv++;
}
else
- process(stdin, "<stdin>");
- exit(0);
+ process(stdin, "<stdin>", eflags);
+ return EXIT_SUCCESS;
}
static void
-usage(void)
-{
- fprintf(stderr, "usage: unvis [file ...]\n");
- exit(1);
-}
-
-void
-process(FILE *fp, const char *filename)
+process(FILE *fp, const char *filename, int eflags)
{
int offset = 0, c, ret;
int state = 0;
@@ -95,12 +114,12 @@ process(FILE *fp, const char *filename)
while ((c = getc(fp)) != EOF) {
offset++;
again:
- switch(ret = unvis(&outc, (char)c, &state, 0)) {
+ switch(ret = unvis(&outc, (char)c, &state, eflags)) {
case UNVIS_VALID:
- putchar(outc);
+ (void)putchar(outc);
break;
case UNVIS_VALIDPUSH:
- putchar(outc);
+ (void)putchar(outc);
goto again;
case UNVIS_SYNBAD:
warnx("%s: offset: %d: can't decode", filename, offset);
@@ -111,8 +130,9 @@ process(FILE *fp, const char *filename)
break;
default:
errx(1, "bad return value (%d), can't happen", ret);
+ /* NOTREACHED */
}
}
- if (unvis(&outc, (char)0, &state, UNVIS_END) == UNVIS_VALID)
- putchar(outc);
+ if (unvis(&outc, (char)0, &state, eflags | UNVIS_END) == UNVIS_VALID)
+ (void)putchar(outc);
}
diff --git a/contrib/vis/Makefile b/contrib/vis/Makefile
new file mode 100644
index 0000000..696b62a
--- /dev/null
+++ b/contrib/vis/Makefile
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.3 1994/11/17 07:55:57 jtc Exp $
+# @(#)Makefile 8.1 (Berkeley) 6/6/93
+
+PROG= vis
+SRCS= vis.c foldit.c
+
+.include <bsd.prog.mk>
diff --git a/contrib/vis/extern.h b/contrib/vis/extern.h
new file mode 100644
index 0000000..49b6f15
--- /dev/null
+++ b/contrib/vis/extern.h
@@ -0,0 +1,39 @@
+/* $NetBSD: extern.h,v 1.1 2009/02/10 23:06:31 christos Exp $ */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.
+ */
+
+int foldit(const char *, int, int, int);
diff --git a/usr.bin/vis/foldit.c b/contrib/vis/foldit.c
index b3cbec3..789b14c 100644
--- a/usr.bin/vis/foldit.c
+++ b/contrib/vis/foldit.c
@@ -1,3 +1,5 @@
+/* $NetBSD: foldit.c,v 1.7 2009/02/10 23:06:31 christos Exp $ */
+
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -10,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -28,21 +30,21 @@
*/
#include <sys/cdefs.h>
-
-__FBSDID("$FreeBSD$");
-
#ifndef lint
-static const char sccsid[] = "@(#)foldit.c 8.1 (Berkeley) 6/6/93";
+#if 0
+static char sccsid[] = "@(#)foldit.c 8.1 (Berkeley) 6/6/93";
#endif
+__RCSID("$NetBSD: foldit.c,v 1.7 2009/02/10 23:06:31 christos Exp $");
+#endif /* not lint */
#include <stdio.h>
-
+#include <vis.h>
#include "extern.h"
int
-foldit(char *chunk, int col, int max)
+foldit(const char *chunk, int col, int max, int flags)
{
- char *cp;
+ const char *cp;
/*
* Keep track of column position. Insert hidden newline
@@ -66,10 +68,10 @@ again:
col++;
}
if (col > (max - 2)) {
- printf("\\\n");
+ printf(flags & VIS_MIMESTYLE ? "=\n" : "\\\n");
col = 0;
goto again;
- }
+ }
cp++;
}
return (col);
diff --git a/usr.bin/vis/vis.1 b/contrib/vis/vis.1
index 7851218..1b0b5edf 100644
--- a/usr.bin/vis/vis.1
+++ b/contrib/vis/vis.1
@@ -1,3 +1,5 @@
+.\" $NetBSD: vis.1,v 1.17 2013/02/14 14:00:00 christos Exp $
+.\"
.\" Copyright (c) 1989, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,7 +11,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -26,9 +28,8 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)vis.1 8.4 (Berkeley) 4/19/94
-.\" $FreeBSD$
.\"
-.Dd June 25, 2004
+.Dd February 13, 2013
.Dt VIS 1
.Os
.Sh NAME
@@ -36,13 +37,13 @@
.Nd display non-printable characters in a visual format
.Sh SYNOPSIS
.Nm
-.Op Fl cbflnostw
+.Op Fl bcfhlmnostw
+.Op Fl e Ar extra
.Op Fl F Ar foldwidth
-.Op Ar
+.Op Ar file ...
.Sh DESCRIPTION
-The
.Nm
-utility is a filter for converting non-printable characters
+is a filter for converting non-printable characters
into a visual representation.
It differs from
.Ql cat -v
@@ -55,7 +56,7 @@ various visual formats is given in
.Xr vis 3 .
.Pp
The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width Ds
.It Fl b
Turns off prepending of backslash before up-arrow control sequences
and meta characters, and disables the doubling of backslashes.
@@ -64,32 +65,43 @@ produces output which is neither invertible or precise, but does
represent a minimum of change to the input.
It is similar to
.Dq Li cat -v .
+.Pq Dv VIS_NOSLASH
.It Fl c
Request a format which displays a small subset of the
non-printable characters using C-style backslash sequences.
-.It Fl F
+.Pq Dv VIS_CSTYLE
+.It Fl e Ar extra
+Also encode characters in
+.Ar extra ,
+per
+.Xr svis 3 .
+.It Fl F Ar foldwidth
Causes
.Nm
-to fold output lines to
-.Ar foldwidth
-columns (default 80), like
+to fold output lines to foldwidth columns (default 80), like
.Xr fold 1 ,
except
-that a hidden newline sequence is used (which is removed
+that a hidden newline sequence is used, (which is removed
when inverting the file back to its original form with
.Xr unvis 1 ) .
If the last character in the encoded file does not end in a newline,
a hidden newline sequence is appended to the output.
This makes
the output usable with various editors and other utilities which
-typically do not work with partial lines.
+typically don't work with partial lines.
.It Fl f
Same as
.Fl F .
+.It Fl h
+Encode using the URI encoding from RFC 1808.
+.Pq Dv VIS_HTTPSTYLE
.It Fl l
Mark newlines with the visible sequence
.Ql \e$ ,
followed by the newline.
+.It Fl m
+Encode using the MIME Quoted-Printable encoding from RFC 2045.
+.Pq Dv VIS_MIMESTYLE
.It Fl n
Turns off any encoding, except for the fact that backslashes are
still doubled and hidden newline sequences inserted if
@@ -105,34 +117,53 @@ becomes like
an invertible version of the
.Xr fold 1
utility.
-That is, the output
-can be unfolded by running the output through
+That is, the output can be unfolded by running the output through
.Xr unvis 1 .
.It Fl o
Request a format which displays non-printable characters as
an octal number, \eddd.
+.Pq Dv VIS_OCTAL
.It Fl s
Only characters considered unsafe to send to a terminal are encoded.
This flag allows backspace, bell, and carriage return in addition
to the default space, tab and newline.
+.Pq Dv VIS_SAFE
.It Fl t
Tabs are also encoded.
+.Pq Dv VIS_TAB
.It Fl w
White space (space-tab-newline) is also encoded.
+.Pq Dv VIS_WHITE
.El
+.Sh MULTIBYTE CHARACTER SUPPORT
+.Nm
+supports multibyte character input.
+The encoding conversion is influenced by the setting of the
+.Ev LC_CTYPE
+environment variable which defines the set of characters that can be
+copied without encoding.
+.Pp
+When 8-bit data is present in the input,
+.Ev LC_CTYPE
+must be set to the correct locale or to the C locale.
+If the locales of the data and the conversion are mismatched, multibyte
+character recognition may fail and encoding will be performed byte-by-byte
+instead.
+.Sh ENVIRONMENT
+.Bl -tag -width ".Ev LC_CTYPE"
+.It Ev LC_CTYPE
+Specify the locale of the input data.
+Set to C if the input data locale is unknown.
.Sh SEE ALSO
.Xr unvis 1 ,
+.Xr svis 3 ,
.Xr vis 3
.Sh HISTORY
The
.Nm
-command appeared in
+command appears in
.Bx 4.4 .
-.Sh BUGS
-Due to limitations in the underlying
-.Xr vis 3
-function, the
-.Nm
-utility
-does not recognize multibyte characters, and thus may consider them to be
-non-printable when they are in fact printable (and vice versa).
+Myltibyte character support was added in
+.Nx 6.1
+and
+.Fx 9.2 .
diff --git a/contrib/vis/vis.c b/contrib/vis/vis.c
new file mode 100644
index 0000000..1509c81
--- /dev/null
+++ b/contrib/vis/vis.c
@@ -0,0 +1,276 @@
+/* $NetBSD: vis.c,v 1.22 2013/02/20 17:04:45 christos Exp $ */
+
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1989, 1993\
+ The Regents of the University of California. All rights reserved.");
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93";
+#endif
+__RCSID("$NetBSD: vis.c,v 1.22 2013/02/20 17:04:45 christos Exp $");
+#endif /* not lint */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <wchar.h>
+#include <limits.h>
+#include <unistd.h>
+#include <err.h>
+#include <vis.h>
+
+#include "extern.h"
+
+static int eflags, fold, foldwidth = 80, none, markeol;
+#ifdef DEBUG
+int debug;
+#endif
+static const char *extra = "";
+
+static void process(FILE *);
+
+int
+main(int argc, char *argv[])
+{
+ FILE *fp;
+ int ch;
+ int rval;
+
+ while ((ch = getopt(argc, argv, "bcde:F:fhlmnostw")) != -1)
+ switch((char)ch) {
+ case 'b':
+ eflags |= VIS_NOSLASH;
+ break;
+ case 'c':
+ eflags |= VIS_CSTYLE;
+ break;
+#ifdef DEBUG
+ case 'd':
+ debug++;
+ break;
+#endif
+ case 'e':
+ extra = optarg;
+ break;
+ case 'F':
+ if ((foldwidth = atoi(optarg)) < 5) {
+ errx(1, "can't fold lines to less than 5 cols");
+ /* NOTREACHED */
+ }
+ markeol++;
+ break;
+ case 'f':
+ fold++; /* fold output lines to 80 cols */
+ break; /* using hidden newline */
+ case 'h':
+ eflags |= VIS_HTTPSTYLE;
+ break;
+ case 'l':
+ markeol++; /* mark end of line with \$ */
+ break;
+ case 'm':
+ eflags |= VIS_MIMESTYLE;
+ if (foldwidth == 80)
+ foldwidth = 76;
+ break;
+ case 'n':
+ none++;
+ break;
+ case 'o':
+ eflags |= VIS_OCTAL;
+ break;
+ case 's':
+ eflags |= VIS_SAFE;
+ break;
+ case 't':
+ eflags |= VIS_TAB;
+ break;
+ case 'w':
+ eflags |= VIS_WHITE;
+ break;
+ case '?':
+ default:
+ (void)fprintf(stderr,
+ "Usage: %s [-bcfhlmnostw] [-e extra]"
+ " [-F foldwidth] [file ...]\n", getprogname());
+ return 1;
+ }
+
+ if ((eflags & (VIS_HTTPSTYLE|VIS_MIMESTYLE)) ==
+ (VIS_HTTPSTYLE|VIS_MIMESTYLE))
+ errx(1, "Can't specify -m and -h at the same time");
+
+ argc -= optind;
+ argv += optind;
+
+ rval = 0;
+
+ if (*argv)
+ while (*argv) {
+ if ((fp = fopen(*argv, "r")) != NULL) {
+ process(fp);
+ (void)fclose(fp);
+ } else {
+ warn("%s", *argv);
+ rval = 1;
+ }
+ argv++;
+ }
+ else
+ process(stdin);
+ return rval;
+}
+
+static void
+process(FILE *fp)
+{
+ static int col = 0;
+ static char nul[] = "\0";
+ char *cp = nul + 1; /* so *(cp-1) starts out != '\n' */
+ wint_t c, c1, rachar;
+ char mbibuff[2 * MB_LEN_MAX + 1]; /* max space for 2 wchars */
+ char buff[4 * MB_LEN_MAX + 1]; /* max encoding length for one char */
+ int mbilen, cerr = 0, raerr = 0;
+
+ /*
+ * The input stream is considered to be multibyte characters.
+ * The input loop will read this data inputing one character,
+ * possibly multiple bytes, at a time and converting each to
+ * a wide character wchar_t.
+ *
+ * The vis(3) functions, however, require single either bytes
+ * or a multibyte string as their arguments. So we convert
+ * our input wchar_t and the following look-ahead wchar_t to
+ * a multibyte string for processing by vis(3).
+ */
+
+ /* Read one multibyte character, store as wchar_t */
+ c = getwc(fp);
+ if (c == WEOF && errno == EILSEQ) {
+ /* Error in multibyte data. Read one byte. */
+ c = (wint_t)getc(fp);
+ cerr = 1;
+ }
+ while (c != WEOF) {
+ /* Clear multibyte input buffer. */
+ memset(mbibuff, 0, sizeof(mbibuff));
+ /* Read-ahead next multibyte character. */
+ if (!cerr)
+ rachar = getwc(fp);
+ if (cerr || (rachar == WEOF && errno == EILSEQ)) {
+ /* Error in multibyte data. Read one byte. */
+ rachar = (wint_t)getc(fp);
+ raerr = 1;
+ }
+ if (none) {
+ /* Handle -n flag. */
+ cp = buff;
+ *cp++ = c;
+ if (c == '\\')
+ *cp++ = '\\';
+ *cp = '\0';
+ } else if (markeol && c == '\n') {
+ /* Handle -l flag. */
+ cp = buff;
+ if ((eflags & VIS_NOSLASH) == 0)
+ *cp++ = '\\';
+ *cp++ = '$';
+ *cp++ = '\n';
+ *cp = '\0';
+ } else {
+ /*
+ * Convert character using vis(3) library.
+ * At this point we will process one character.
+ * But we must pass the vis(3) library this
+ * character plus the next one because the next
+ * one is used as a look-ahead to decide how to
+ * encode this one under certain circumstances.
+ *
+ * Since our characters may be multibyte, e.g.,
+ * in the UTF-8 locale, we cannot use vis() and
+ * svis() which require byte input, so we must
+ * create a multibyte string and use strvisx().
+ */
+ /* Treat EOF as a NUL char. */
+ c1 = rachar;
+ if (c1 == WEOF)
+ c1 = L'\0';
+ /*
+ * If we hit a multibyte conversion error above,
+ * insert byte directly into string buff because
+ * wctomb() will fail. Else convert wchar_t to
+ * multibyte using wctomb().
+ */
+ if (cerr) {
+ *mbibuff = (char)c;
+ mbilen = 1;
+ } else
+ mbilen = wctomb(mbibuff, c);
+ /* Same for look-ahead character. */
+ if (raerr)
+ mbibuff[mbilen] = (char)c1;
+ else
+ wctomb(mbibuff + mbilen, c1);
+ /* Perform encoding on just first character. */
+ (void) strsenvisx(buff, 4 * MB_LEN_MAX, mbibuff,
+ 1, eflags, extra, &cerr);
+ }
+
+ cp = buff;
+ if (fold) {
+#ifdef DEBUG
+ if (debug)
+ (void)printf("<%02d,", col);
+#endif
+ col = foldit(cp, col, foldwidth, eflags);
+#ifdef DEBUG
+ if (debug)
+ (void)printf("%02d>", col);
+#endif
+ }
+ do {
+ (void)putchar(*cp);
+ } while (*++cp);
+ c = rachar;
+ cerr = raerr;
+ }
+ /*
+ * terminate partial line with a hidden newline
+ */
+ if (fold && *(cp - 1) != '\n')
+ (void)printf(eflags & VIS_MIMESTYLE ? "=\n" : "\\\n");
+}
diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile
index 73d9213..a06daa7 100644
--- a/gnu/lib/libgcc/Makefile
+++ b/gnu/lib/libgcc/Makefile
@@ -123,10 +123,10 @@ CFLAGS+= -fheinous-gnu-extensions
LIB1ASMSRC = lib1funcs.asm
LIB1ASMFUNCS = _dvmd_tls _bb_init_func
.if ${MK_ARM_EABI} != "no"
-LIB1ASMFUNCS+= _addsubdf3 _addsubsf3 _cmpdf2 _cmpsf2 _fixdfsi _fixsfsi \
- _fixunsdfsi _fixunsdfsi _muldivdf3 _muldivsf3 _udivsi3
-
LIB2ADDEH = unwind-arm.c libunwind.S pr-support.c unwind-c.c
+# Some compilers generate __aeabi_ functions libgcc_s is missing
+DPADD+= ${LIBGCC}
+LDADD+= -lgcc
.else
LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c
.endif
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 6cfda08..fac1e43 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -491,6 +491,20 @@ MLINKS+=ttyname.3 isatty.3 \
MLINKS+=tzset.3 tzsetwall.3
MLINKS+=unvis.3 strunvis.3 \
unvis.3 strunvisx.3
-MLINKS+=vis.3 strvis.3 \
- vis.3 strvisx.3
+MLINKS+=vis.3 nvis.3 \
+ vis.3 snvis.3 \
+ vis.3 strenvisx.3 \
+ vis.3 strnunvis.3 \
+ vis.3 strnunvisx.3 \
+ vis.3 strnvis.3 \
+ vis.3 strnvisx.3 \
+ vis.3 strsenvisx.3 \
+ vis.3 strsnvis.3 \
+ vis.3 strsnvisx.3 \
+ vis.3 strsvis.3 \
+ vis.3 strsvisx.3 \
+ vis.3 strvis.3 \
+ vis.3 strvisx.3 \
+ vis.3 svis.3
+
MLINKS+=wordexp.3 wordfree.3
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 4cbf07c..2438951 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -391,10 +391,12 @@ FBSD_1.3 {
pwcache_userdb;
pwcache_groupdb;
snvis;
+ strenvisx;
strnunvis;
strnunvisx;
strnvis;
strnvisx;
+ strsenvisx;
strsnvis;
strsnvisx;
strsvis;
diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2
index 59979a3..ab8af51 100644
--- a/lib/libc/sys/chflags.2
+++ b/lib/libc/sys/chflags.2
@@ -232,3 +232,7 @@ and
.Fn fchflags
system calls first appeared in
.Bx 4.4 .
+The
+.Fn lchflags
+system call first appeared in
+.Fx 5.0 .
diff --git a/lib/libipsec/test-policy.c b/lib/libipsec/test-policy.c
index c1dfc79..a24a0b41 100644
--- a/lib/libipsec/test-policy.c
+++ b/lib/libipsec/test-policy.c
@@ -75,14 +75,13 @@ struct req_t {
{ 1, "out ipsec ah/transport esp/use" },
{ 1, "in ipsec ah/transport esp/tunnel" },
{ 0, "in ipsec ah/transport esp/tunnel/::1-::1" },
-{ 0, "in ipsec
- ah / transport
- esp / tunnel / ::1-::2" },
-{ 0, "out ipsec
- ah/transport/::1-::2 esp/tunnel/::3-::4/use ah/transport/::5-::6/require
- ah/transport/::1-::2 esp/tunnel/::3-::4/use ah/transport/::5-::6/require
- ah/transport/::1-::2 esp/tunnel/::3-::4/use ah/transport/::5-::6/require
- " },
+{ 0, "in ipsec\n"
+ "ah / transport\n"
+ "esp / tunnel / ::1-::2" },
+{ 0, "out ipsec\n"
+ "ah/transport/::1-::2 esp/tunnel/::3-::4/use ah/transport/::5-::6/require\n"
+ "ah/transport/::1-::2 esp/tunnel/::3-::4/use ah/transport/::5-::6/require\n"
+ "ah/transport/::1-::2 esp/tunnel/::3-::4/use ah/transport/::5-::6/require\n" },
{ 0, "out ipsec esp/transport/fec0::10-fec0::11/use" },
};
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index bca0315..7949e9e 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -126,20 +126,25 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
fd = flopen(pfh->pf_path,
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode);
if (fd == -1) {
- if (errno == EWOULDBLOCK && pidptr != NULL) {
- count = 20;
- rqtp.tv_sec = 0;
- rqtp.tv_nsec = 5000000;
- for (;;) {
- errno = pidfile_read(pfh->pf_path, pidptr);
- if (errno != EAGAIN || --count == 0)
- break;
- nanosleep(&rqtp, 0);
- }
- if (errno == EAGAIN)
- *pidptr = -1;
- if (errno == 0 || errno == EAGAIN)
+ if (errno == EWOULDBLOCK) {
+ if (pidptr == NULL) {
errno = EEXIST;
+ } else {
+ count = 20;
+ rqtp.tv_sec = 0;
+ rqtp.tv_nsec = 5000000;
+ for (;;) {
+ errno = pidfile_read(pfh->pf_path,
+ pidptr);
+ if (errno != EAGAIN || --count == 0)
+ break;
+ nanosleep(&rqtp, 0);
+ }
+ if (errno == EAGAIN)
+ *pidptr = -1;
+ if (errno == 0 || errno == EAGAIN)
+ errno = EEXIST;
+ }
}
free(pfh);
return (NULL);
diff --git a/sbin/ccdconfig/ccdconfig.8 b/sbin/ccdconfig/ccdconfig.8
index cc29f71..99a1762 100644
--- a/sbin/ccdconfig/ccdconfig.8
+++ b/sbin/ccdconfig/ccdconfig.8
@@ -234,14 +234,14 @@ RAID controllers (see GENERIC),
or software RAID systems such as
.Xr geom 8
and
-.Xr vinum 8 .
+.Xr gvinum 8 .
.Sh SEE ALSO
.Xr dd 1 ,
.Xr ccd 4 ,
.Xr disklabel 8 ,
.Xr fdisk 8 ,
-.Xr rc 8 ,
-.Xr vinum 8
+.Xr gvinum 8 ,
+.Xr rc 8
.Sh HISTORY
The
.Nm
diff --git a/sbin/ffsinfo/ffsinfo.8 b/sbin/ffsinfo/ffsinfo.8
index aacf428..9753cf7 100644
--- a/sbin/ffsinfo/ffsinfo.8
+++ b/sbin/ffsinfo/ffsinfo.8
@@ -125,9 +125,9 @@ with all available information.
.Xr dumpfs 8 ,
.Xr fsck 8 ,
.Xr growfs 8 ,
+.Xr gvinum 8 ,
.Xr newfs 8 ,
-.Xr tunefs 8 ,
-.Xr vinum 8
+.Xr tunefs 8
.Sh HISTORY
The
.Nm
diff --git a/sbin/geom/class/concat/gconcat.8 b/sbin/geom/class/concat/gconcat.8
index 2e1b79d..b797a1c 100644
--- a/sbin/geom/class/concat/gconcat.8
+++ b/sbin/geom/class/concat/gconcat.8
@@ -183,11 +183,11 @@ growfs /dev/concat/data
.Xr loader.conf 5 ,
.Xr geom 8 ,
.Xr growfs 8 ,
+.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr sysctl 8 ,
-.Xr umount 8 ,
-.Xr vinum 8
+.Xr umount 8
.Sh HISTORY
The
.Nm
diff --git a/sbin/geom/class/mirror/gmirror.8 b/sbin/geom/class/mirror/gmirror.8
index baaa827..58ff8af 100644
--- a/sbin/geom/class/mirror/gmirror.8
+++ b/sbin/geom/class/mirror/gmirror.8
@@ -340,11 +340,11 @@ there.
.Xr geom 4 ,
.Xr dumpon 8 ,
.Xr geom 8 ,
+.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr savecore 8 ,
-.Xr umount 8 ,
-.Xr vinum 8
+.Xr umount 8
.Sh HISTORY
The
.Nm
diff --git a/sbin/geom/class/raid/graid.8 b/sbin/geom/class/raid/graid.8
index 4af4125..22763bd 100644
--- a/sbin/geom/class/raid/graid.8
+++ b/sbin/geom/class/raid/graid.8
@@ -314,7 +314,7 @@ Exit status is 0 on success, and non-zero if the command fails.
.Sh SEE ALSO
.Xr geom 4 ,
.Xr geom 8 ,
-.Xr vinum 8
+.Xr gvinum 8
.Sh HISTORY
The
.Nm
diff --git a/sbin/geom/class/stripe/gstripe.8 b/sbin/geom/class/stripe/gstripe.8
index ee70184..b53e83f 100644
--- a/sbin/geom/class/stripe/gstripe.8
+++ b/sbin/geom/class/stripe/gstripe.8
@@ -232,11 +232,11 @@ for
.Xr atacontrol 8 ,
.Xr ccdconfig 8 ,
.Xr geom 8 ,
+.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr sysctl 8 ,
-.Xr umount 8 ,
-.Xr vinum 8
+.Xr umount 8
.Sh HISTORY
The
.Nm
diff --git a/sbin/gvinum/gvinum.8 b/sbin/gvinum/gvinum.8
index 4753d79..5d36276 100644
--- a/sbin/gvinum/gvinum.8
+++ b/sbin/gvinum/gvinum.8
@@ -388,7 +388,10 @@ documentation were added by
.An "Chris Jones"
through the 2005 Google Summer
of Code program.
-.Ic a partial rewrite of gvinum was done by "Lukas Ertl" and "Ulf Lilleengen"
+A partial rewrite of gvinum was done by
+.An "Lukas Ertl"
+and
+.An "Ulf Lilleengen"
through the 2007 Google Summer of Code program.
The documentation have been updated to reflect the new functionality.
.Sh AUTHORS
@@ -419,9 +422,9 @@ This may leave data unprotected and is perhaps unwise.
Currently,
.Nm
does not yet fully implement all of the functions found in
-.Xr vinum 4 .
+.Nm vinum .
Specifically, the following commands from
-.Xr vinum 4
+.Nm vinum
are not supported:
.Bl -tag -width indent
.It Ic debug
diff --git a/sbin/hastctl/hastctl.8 b/sbin/hastctl/hastctl.8
index 9266fc0..bdca80d 100644
--- a/sbin/hastctl/hastctl.8
+++ b/sbin/hastctl/hastctl.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 10, 2011
+.Dd March 14, 2013
.Dt HASTCTL 8
.Os
.Sh NAME
@@ -49,6 +49,11 @@
.Aq init | primary | secondary
.Ar all | name ...
.Nm
+.Cm list
+.Op Fl d
+.Op Fl c Ar config
+.Op Ar all | name ...
+.Nm
.Cm status
.Op Fl d
.Op Fl c Ar config
@@ -139,8 +144,11 @@ GEOM provider
.Pa /dev/hast/<name>
will not be created on secondary node.
.El
+.It Cm list
+Present verbose status of the configured resources.
.It Cm status
-Present status of the configured resources.
+Present terse (and more easy machine-parseable) status of the configured
+resources.
.It Cm dump
Dump metadata stored on local component for the configured resources.
.El
diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c
index 3dfde03..883a298 100644
--- a/sbin/hastctl/hastctl.c
+++ b/sbin/hastctl/hastctl.c
@@ -31,21 +31,11 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
-#include <sys/disk.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
#include <libutil.h>
-#include <limits.h>
-#include <signal.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <sysexits.h>
#include <unistd.h>
#include <activemap.h>
@@ -70,7 +60,8 @@ enum {
CMD_CREATE,
CMD_ROLE,
CMD_STATUS,
- CMD_DUMP
+ CMD_DUMP,
+ CMD_LIST
};
static __dead2 void
@@ -85,6 +76,9 @@ usage(void)
" %s role [-d] [-c config] <init | primary | secondary> all | name ...\n",
getprogname());
fprintf(stderr,
+ " %s list [-d] [-c config] [all | name ...]\n",
+ getprogname());
+ fprintf(stderr,
" %s status [-d] [-c config] [all | name ...]\n",
getprogname());
fprintf(stderr,
@@ -297,7 +291,7 @@ control_set_role(struct nv *nv, const char *newrole)
}
static int
-control_status(struct nv *nv)
+control_list(struct nv *nv)
{
unsigned int ii;
const char *str;
@@ -361,6 +355,43 @@ control_status(struct nv *nv)
return (ret);
}
+static int
+control_status(struct nv *nv)
+{
+ unsigned int ii;
+ const char *str;
+ int error, hprinted, ret;
+
+ hprinted = 0;
+ ret = 0;
+
+ for (ii = 0; ; ii++) {
+ str = nv_get_string(nv, "resource%u", ii);
+ if (str == NULL)
+ break;
+ if (!hprinted) {
+ printf("Name\tStatus\t Role\t\tComponents\n");
+ hprinted = 1;
+ }
+ printf("%s\t", str);
+ error = nv_get_int16(nv, "error%u", ii);
+ if (error != 0) {
+ if (ret == 0)
+ ret = error;
+ printf("ERR%d\n", error);
+ continue;
+ }
+ str = nv_get_string(nv, "status%u", ii);
+ printf("%-9s", (str != NULL) ? str : "-");
+ printf("%-15s", nv_get_string(nv, "role%u", ii));
+ printf("%s\t",
+ nv_get_string(nv, "localpath%u", ii));
+ printf("%s\n",
+ nv_get_string(nv, "remoteaddr%u", ii));
+ }
+ return (ret);
+}
+
int
main(int argc, char *argv[])
{
@@ -381,6 +412,9 @@ main(int argc, char *argv[])
} else if (strcmp(argv[1], "role") == 0) {
cmd = CMD_ROLE;
optstr = "c:dh";
+ } else if (strcmp(argv[1], "list") == 0) {
+ cmd = CMD_LIST;
+ optstr = "c:dh";
} else if (strcmp(argv[1], "status") == 0) {
cmd = CMD_STATUS;
optstr = "c:dh";
@@ -469,8 +503,19 @@ main(int argc, char *argv[])
for (ii = 0; ii < argc - 1; ii++)
nv_add_string(nv, argv[ii + 1], "resource%d", ii);
break;
+ case CMD_LIST:
+ /* Obtain verbose status of the given resources. */
+ nv = nv_alloc();
+ nv_add_uint8(nv, HASTCTL_CMD_STATUS, "cmd");
+ if (argc == 0)
+ nv_add_string(nv, "all", "resource%d", 0);
+ else {
+ for (ii = 0; ii < argc; ii++)
+ nv_add_string(nv, argv[ii], "resource%d", ii);
+ }
+ break;
case CMD_STATUS:
- /* Obtain status of the given resources. */
+ /* Obtain brief status of the given resources. */
nv = nv_alloc();
nv_add_uint8(nv, HASTCTL_CMD_STATUS, "cmd");
if (argc == 0)
@@ -524,6 +569,9 @@ main(int argc, char *argv[])
case CMD_ROLE:
error = control_set_role(nv, argv[0]);
break;
+ case CMD_LIST:
+ error = control_list(nv);
+ break;
case CMD_STATUS:
error = control_status(nv);
break;
diff --git a/sbin/hastd/hastd.8 b/sbin/hastd/hastd.8
index 457b837..b614f36 100644
--- a/sbin/hastd/hastd.8
+++ b/sbin/hastd/hastd.8
@@ -51,7 +51,7 @@ Only one machine (cluster node) can actively use storage provided by
This machine is called primary.
The
.Nm
-daemon operates on block level, which makes it transparent for file
+daemon operates on block level, which makes it transparent to file
systems and applications.
.Pp
There is one main
@@ -68,7 +68,7 @@ The exact format is:
hastd: <resource name> (<role>)
.Ed
.Pp
-When (and only when)
+If (and only if)
.Nm
operates in primary role for the given resource, corresponding
.Pa /dev/hast/<name>
@@ -77,8 +77,8 @@ File systems and applications can use this provider to send I/O
requests to.
Every write, delete and flush operation
.Dv ( BIO_WRITE , BIO_DELETE , BIO_FLUSH )
-is send to local component and synchronously replicated
-to the remote (secondary) node if it is available.
+is send to local component and replicated to the remote (secondary) node if it
+is available.
Read operations
.Dv ( BIO_READ )
are handled locally unless I/O error occurs or local version of the data
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index febdc05..c0c67c6 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -582,7 +582,7 @@ requnpack(struct hast_resource *res, struct hio *hio, struct nv *nv)
hio->hio_error = EINVAL;
goto end;
}
- if (hio->hio_length > MAXPHYS) {
+ if (hio->hio_cmd != HIO_DELETE && hio->hio_length > MAXPHYS) {
pjdlog_error("Data length is too large (%ju > %ju).",
(uintmax_t)hio->hio_length, (uintmax_t)MAXPHYS);
hio->hio_error = EINVAL;
diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c
index ae6f984..440061e 100644
--- a/sbin/hastd/subr.c
+++ b/sbin/hastd/subr.c
@@ -31,14 +31,15 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#ifdef HAVE_CAPSICUM
-#include <sys/capability.h>
-#endif
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/ioctl.h>
#include <sys/jail.h>
#include <sys/stat.h>
+#ifdef HAVE_CAPSICUM
+#include <sys/capability.h>
+#include <geom/gate/g_gate.h>
+#endif
#include <errno.h>
#include <fcntl.h>
@@ -224,22 +225,53 @@ drop_privs(const struct hast_resource *res)
return (-1);
}
- /*
- * Until capsicum doesn't allow ioctl(2) we cannot use it to sandbox
- * primary and secondary worker processes, as primary uses GGATE
- * ioctls and secondary uses ioctls to handle BIO_DELETE and BIO_FLUSH.
- * For now capsicum is only used to sandbox hastctl.
- */
#ifdef HAVE_CAPSICUM
- if (res == NULL) {
- capsicum = (cap_enter() == 0);
- if (!capsicum) {
- pjdlog_common(LOG_DEBUG, 1, errno,
- "Unable to sandbox using capsicum");
+ capsicum = (cap_enter() == 0);
+ if (!capsicum) {
+ pjdlog_common(LOG_DEBUG, 1, errno,
+ "Unable to sandbox using capsicum");
+ } else if (res != NULL) {
+ static const unsigned long geomcmds[] = {
+ DIOCGDELETE,
+ DIOCGFLUSH
+ };
+
+ PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY ||
+ res->hr_role == HAST_ROLE_SECONDARY);
+
+ if (cap_rights_limit(res->hr_localfd,
+ CAP_FLOCK | CAP_IOCTL | CAP_PREAD | CAP_PWRITE) == -1) {
+ pjdlog_errno(LOG_ERR,
+ "Unable to limit capability rights on local descriptor");
+ }
+ if (cap_ioctls_limit(res->hr_localfd, geomcmds,
+ sizeof(geomcmds) / sizeof(geomcmds[0])) == -1) {
+ pjdlog_errno(LOG_ERR,
+ "Unable to limit allowed GEOM ioctls");
}
- } else
+
+ if (res->hr_role == HAST_ROLE_PRIMARY) {
+ static const unsigned long ggatecmds[] = {
+ G_GATE_CMD_MODIFY,
+ G_GATE_CMD_START,
+ G_GATE_CMD_DONE,
+ G_GATE_CMD_DESTROY
+ };
+
+ if (cap_rights_limit(res->hr_ggatefd, CAP_IOCTL) == -1) {
+ pjdlog_errno(LOG_ERR,
+ "Unable to limit capability rights to CAP_IOCTL on ggate descriptor");
+ }
+ if (cap_ioctls_limit(res->hr_ggatefd, ggatecmds,
+ sizeof(ggatecmds) / sizeof(ggatecmds[0])) == -1) {
+ pjdlog_errno(LOG_ERR,
+ "Unable to limit allowed ggate ioctls");
+ }
+ }
+ }
+#else
+ capsicum = false;
#endif
- capsicum = false;
/*
* Better be sure that everything succeeded.
diff --git a/sbin/recoverdisk/recoverdisk.c b/sbin/recoverdisk/recoverdisk.c
index caa8ebd..af0d88e 100644
--- a/sbin/recoverdisk/recoverdisk.c
+++ b/sbin/recoverdisk/recoverdisk.c
@@ -156,7 +156,7 @@ main(int argc, char * const argv[])
int error, state;
u_char *buf;
u_int sectorsize;
- u_int stripesize;
+ off_t stripesize;
time_t t1, t2;
struct stat sb;
u_int n, snapshot = 60;
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index cdd7474..bd67533 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -525,7 +525,6 @@ MAN= aac.4 \
vge.4 \
viapm.4 \
${_viawd.4} \
- vinum.4 \
${_virtio.4} \
${_virtio_balloon.4} \
${_virtio_blk.4} \
diff --git a/share/man/man4/ccd.4 b/share/man/man4/ccd.4
index 8da0e36..4c95fb8 100644
--- a/share/man/man4/ccd.4
+++ b/share/man/man4/ccd.4
@@ -279,9 +279,9 @@ device special files
.Xr config 8 ,
.Xr disklabel 8 ,
.Xr fsck 8 ,
+.Xr gvinum 8 ,
.Xr mount 8 ,
-.Xr newfs 8 ,
-.Xr vinum 8
+.Xr newfs 8
.Sh HISTORY
The concatenated disk driver was originally written at the University of
Utah.
diff --git a/share/man/man4/geom.4 b/share/man/man4/geom.4
index 0a1b24e..4606676 100644
--- a/share/man/man4/geom.4
+++ b/share/man/man4/geom.4
@@ -34,12 +34,47 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 25, 2006
+.Dd March 14, 2013
.Dt GEOM 4
.Os
.Sh NAME
.Nm GEOM
.Nd "modular disk I/O request transformation framework"
+.Sh SYNOPSIS
+.Cd options GEOM_AES
+.Cd options GEOM_BDE
+.Cd options GEOM_BSD
+.Cd options GEOM_CACHE
+.Cd options GEOM_CONCAT
+.Cd options GEOM_ELI
+.Cd options GEOM_FOX
+.Cd options GEOM_GATE
+.Cd options GEOM_JOURNAL
+.Cd options GEOM_LABEL
+.Cd options GEOM_LINUX_LVM
+.Cd options GEOM_MBR
+.Cd options GEOM_MIRROR
+.Cd options GEOM_MULTIPATH
+.Cd options GEOM_NOP
+.Cd options GEOM_PART_APM
+.Cd options GEOM_PART_BSD
+.Cd options GEOM_PART_EBR
+.Cd options GEOM_PART_EBR_COMPAT
+.Cd options GEOM_PART_GPT
+.Cd options GEOM_PART_LDM
+.Cd options GEOM_PART_MBR
+.Cd options GEOM_PART_PC98
+.Cd options GEOM_PART_VTOC8
+.Cd options GEOM_PC98
+.Cd options GEOM_RAID
+.Cd options GEOM_RAID3
+.Cd options GEOM_SHSEC
+.Cd options GEOM_STRIPE
+.Cd options GEOM_SUNLABEL
+.Cd options GEOM_UZIP
+.Cd options GEOM_VIRSTOR
+.Cd options GEOM_VOL
+.Cd options GEOM_ZERO
.Sh DESCRIPTION
The
.Nm
diff --git a/share/man/man4/udp.4 b/share/man/man4/udp.4
index 03d6db2..1092f5a 100644
--- a/share/man/man4/udp.4
+++ b/share/man/man4/udp.4
@@ -103,29 +103,6 @@ transport level may be used with
.Tn UDP ;
see
.Xr ip 4 .
-.Sh ERRORS
-A socket operation may fail with one of the following errors returned:
-.Bl -tag -width Er
-.It Bq Er EISCONN
-when trying to establish a connection on a socket which
-already has one, or when trying to send a datagram with the destination
-address specified and the socket is already connected;
-.It Bq Er ENOTCONN
-when trying to send a datagram, but
-no destination address is specified, and the socket has not been
-connected;
-.It Bq Er ENOBUFS
-when the system runs out of memory for
-an internal data structure;
-.It Bq Er EADDRINUSE
-when an attempt
-is made to create a socket with a port which has already been
-allocated;
-.It Bq Er EADDRNOTAVAIL
-when an attempt is made to create a
-socket with a network address for which no network interface
-exists.
-.El
.Sh MIB VARIABLES
The
.Nm
@@ -154,6 +131,29 @@ listening, do not return an ICMP port unreachable message.
See
.Xr blackhole 4 . )
.El
+.Sh ERRORS
+A socket operation may fail with one of the following errors returned:
+.Bl -tag -width Er
+.It Bq Er EISCONN
+when trying to establish a connection on a socket which
+already has one, or when trying to send a datagram with the destination
+address specified and the socket is already connected;
+.It Bq Er ENOTCONN
+when trying to send a datagram, but
+no destination address is specified, and the socket has not been
+connected;
+.It Bq Er ENOBUFS
+when the system runs out of memory for
+an internal data structure;
+.It Bq Er EADDRINUSE
+when an attempt
+is made to create a socket with a port which has already been
+allocated;
+.It Bq Er EADDRNOTAVAIL
+when an attempt is made to create a
+socket with a network address for which no network interface
+exists.
+.El
.Sh SEE ALSO
.Xr getsockopt 2 ,
.Xr recv 2 ,
diff --git a/share/man/man4/vinum.4 b/share/man/man4/vinum.4
deleted file mode 100644
index a007ad6..0000000
--- a/share/man/man4/vinum.4
+++ /dev/null
@@ -1,1166 +0,0 @@
-.\" Hey, Emacs, edit this file in -*- nroff-fill -*- mode
-.\"-
-.\" Copyright (c) 1997, 1998, 2003
-.\" Nan Yang Computer Services Limited. All rights reserved.
-.\"
-.\" This software is distributed under the so-called ``Berkeley
-.\" License'':
-.\"
-.\" 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 Nan Yang Computer
-.\" Services Limited.
-.\" 4. Neither the name of the Company 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 ``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 company or contributors be liable for any
-.\" direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute
-.\" goods or services; loss of use, data, or profits; or business
-.\" interruption) however caused and on any theory of liability, whether
-.\" in contract, strict liability, or tort (including negligence or
-.\" otherwise) arising in any way out of the use of this software, even if
-.\" advised of the possibility of such damage.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd March 13, 2013
-.Dt VINUM 4
-.Os
-.Sh NAME
-.Nm vinum
-.Nd Logical Volume Manager
-.Sh SYNOPSIS
-.Cd "device vinum"
-.Sh DESCRIPTION
-.Nm
-is a logical volume manager inspired by, but not derived from, the Veritas
-Volume Manager.
-It provides the following features:
-.Bl -bullet
-.It
-It provides device-independent logical disks, called
-.Em volumes .
-Volumes are
-not restricted to the size of any disk on the system.
-.It
-The volumes consist of one or more
-.Em plexes ,
-each of which contain the
-entire address space of a volume.
-This represents an implementation of RAID-1
-(mirroring).
-Multiple plexes can also be used for:
-.\" XXX What about sparse plexes? Do we want them?
-.Bl -bullet
-.It
-Increased read throughput.
-.Nm
-will read data from the least active disk, so if a volume has plexes on multiple
-disks, more data can be read in parallel.
-.Nm
-reads data from only one plex, but it writes data to all plexes.
-.It
-Increased reliability.
-By storing plexes on different disks, data will remain
-available even if one of the plexes becomes unavailable.
-In comparison with a
-RAID-5 plex (see below), using multiple plexes requires more storage space, but
-gives better performance, particularly in the case of a drive failure.
-.It
-Additional plexes can be used for on-line data reorganization.
-By attaching an
-additional plex and subsequently detaching one of the older plexes, data can be
-moved on-line without compromising access.
-.It
-An additional plex can be used to obtain a consistent dump of a file system.
-By
-attaching an additional plex and detaching at a specific time, the detached plex
-becomes an accurate snapshot of the file system at the time of detachment.
-.\" Make sure to flush!
-.El
-.It
-Each plex consists of one or more logical disk slices, called
-.Em subdisks .
-Subdisks are defined as a contiguous block of physical disk storage.
-A plex may
-consist of any reasonable number of subdisks (in other words, the real limit is
-not the number, but other factors, such as memory and performance, associated
-with maintaining a large number of subdisks).
-.It
-A number of mappings between subdisks and plexes are available:
-.Bl -bullet
-.It
-.Em "Concatenated plexes"
-consist of one or more subdisks, each of which
-is mapped to a contiguous part of the plex address space.
-.It
-.Em "Striped plexes"
-consist of two or more subdisks of equal size.
-The file
-address space is mapped in
-.Em stripes ,
-integral fractions of the subdisk
-size.
-Consecutive plex address space is mapped to stripes in each subdisk in
-turn.
-.if t \{\
-.ig
-.\" FIXME
-.br
-.ne 1.5i
-.PS
-move right 2i
-down
-SD0: box
-SD1: box
-SD2: box
-
-"plex 0" at SD0.n+(0,.2)
-"subdisk 0" rjust at SD0.w-(.2,0)
-"subdisk 1" rjust at SD1.w-(.2,0)
-"subdisk 2" rjust at SD2.w-(.2,0)
-.PE
-..
-.\}
-The subdisks of a striped plex must all be the same size.
-.It
-.Em "RAID-5 plexes"
-require at least three equal-sized subdisks.
-They
-resemble striped plexes, except that in each stripe, one subdisk stores parity
-information.
-This subdisk changes in each stripe: in the first stripe, it is the
-first subdisk, in the second it is the second subdisk, etc.
-In the event of a
-single disk failure,
-.Nm
-will recover the data based on the information stored on the remaining subdisks.
-This mapping is particularly suited to read-intensive access.
-The subdisks of a
-RAID-5 plex must all be the same size.
-.\" Make sure to flush!
-.El
-.It
-.Em Drives
-are the lowest level of the storage hierarchy.
-They represent disk special
-devices.
-.It
-.Nm
-offers automatic startup.
-Unlike
-.Ux
-file systems,
-.Nm
-volumes contain all the configuration information needed to ensure that they are
-started correctly when the subsystem is enabled.
-This is also a significant
-advantage over the Veritas\(tm File System.
-This feature regards the presence
-of the volumes.
-It does not mean that the volumes will be mounted
-automatically, since the standard startup procedures with
-.Pa /etc/fstab
-perform this function.
-.El
-.Sh KERNEL CONFIGURATION
-.Nm
-is currently supplied as a KLD module, and does not require
-configuration.
-As with other KLDs, it is absolutely necessary to match the KLD
-to the version of the operating system.
-Failure to do so will cause
-.Nm
-to issue an error message and terminate.
-.Pp
-It is possible to configure
-.Nm
-in the kernel, but this is not recommended.
-To do so, add this line to the
-kernel configuration file:
-.Pp
-.D1 Cd "device vinum"
-.Ss Debug Options
-The current version of
-.Nm ,
-both the kernel module and the user program
-.Xr gvinum 8 ,
-include significant debugging support.
-It is not recommended to remove
-this support at the moment, but if you do you must remove it from both the
-kernel and the user components.
-To do this, edit the files
-.Pa /usr/src/sbin/vinum/Makefile
-and
-.Pa /usr/src/sys/modules/vinum/Makefile
-and edit the
-.Va CFLAGS
-variable to remove the
-.Li -DVINUMDEBUG
-option.
-If you have
-configured
-.Nm
-into the kernel, either specify the line
-.Pp
-.D1 Cd "options VINUMDEBUG"
-.Pp
-in the kernel configuration file or remove the
-.Li -DVINUMDEBUG
-option from
-.Pa /usr/src/sbin/vinum/Makefile
-as described above.
-.Pp
-If the
-.Va VINUMDEBUG
-variables do not match,
-.Xr gvinum 8
-will fail with a message
-explaining the problem and what to do to correct it.
-.Ss Other Options
-.Cd "options VINUM_AUTOSTART"
-.Pp
-Make
-.Nm
-automatically scan all available disks at attach time.
-This is a deprecated way that is primarily intended for environments
-that do not want to rely on kernel environment variables set by
-.Xr loader 8 .
-.Pp
-.Nm
-was previously available in two versions: a freely available version which did
-not contain RAID-5 functionality, and a full version including RAID-5
-functionality, which was available only from Cybernet Systems Inc.
-The present
-version of
-.Nm
-includes the RAID-5 functionality.
-.Sh RUNNING VINUM
-.Nm
-is part of the base
-.Fx
-system.
-It does not require installation.
-To start it, start the
-.Xr gvinum 8
-program, which will load the KLD if it is not already present.
-Before using
-.Nm ,
-it must be configured.
-See
-.Xr gvinum 8
-for information on how to create a
-.Nm
-configuration.
-.Pp
-Normally, you start a configured version of
-.Nm
-at boot time.
-Set the variable
-.Va start_vinum
-in
-.Pa /etc/rc.conf
-to
-.Dq Li YES
-to start
-.Nm
-at boot time.
-(See
-.Xr rc.conf 5
-for more details.)
-.Pp
-If
-.Nm
-is loaded as a KLD (the recommended way), the
-.Nm vinum Cm stop
-command will unload it
-(see
-.Xr gvinum 8 ) .
-You can also do this with the
-.Xr kldunload 8
-command.
-.Pp
-The KLD can only be unloaded when idle, in other words when no volumes are
-mounted and no other instances of the
-.Xr gvinum 8
-program are active.
-Unloading the KLD does not harm the data in the volumes.
-.Ss Configuring and Starting Objects
-Use the
-.Xr gvinum 8
-utility to configure and start
-.Nm
-objects.
-.Sh AUTOMATIC STARTUP
-The
-.Nm
-subsystem can be automatically started at attach time.
-There are two kernel environment variables that can be set in
-.Xr loader.conf 5
-to accomplish this.
-.Bl -tag -width ".Va vinum.autostart" -offset indent
-.It Va vinum.autostart
-If this variable is set (to any value), the attach function will attempt
-to scan all available disks for valid
-.Nm
-configuration records.
-This is the preferred way if automatic startup is desired.
-.Pp
-Example:
-.Dl vinum.autostart="YES"
-.It Va vinum.drives
-Alternatively, this variable can enumerate a list of disk devices
-to scan for configuration records.
-Note that only the
-.Dq bare
-device names need to be given, since
-.Nm
-will automatically scan all possible slices and partitions.
-.Pp
-Example:
-.Dl vinum.drives="da0 da1"
-.El
-.Pp
-If automatic startup is used, it is not necessary to set the
-.Va start_vinum
-variable of
-.Xr rc.conf 5 .
-Note that if
-.Nm
-is to supply to the volume for the root file system, it is necessary
-to start the subsystem early.
-This can be achieved by specifying
-.Pp
-.Dl vinum_load="YES"
-.Pp
-in
-.Xr loader.conf 5 .
-.Sh IOCTL CALLS
-.Xr ioctl 2
-calls are intended for the use of the
-.Xr gvinum 8
-configuration program only.
-They are described in the header file
-.Pa /sys/dev/vinum/vinumio.h .
-.Ss Disk Labels
-Conventional disk special devices have a
-.Em "disk label"
-in the second sector of the device.
-This disk label describes the layout of the partitions within
-the device.
-.Nm
-does not subdivide volumes, so volumes do not contain a physical disk label.
-For convenience,
-.Nm
-implements the ioctl calls
-.Dv DIOCGDINFO
-(get disk label),
-.Dv DIOCGPART
-(get partition information),
-.Dv DIOCWDINFO
-(write partition information) and
-.Dv DIOCSDINFO
-(set partition information).
-.Dv DIOCGDINFO
-and
-.Dv DIOCGPART
-refer to an internal
-representation of the disk label which is not present on the volume.
-As a
-result, the
-.Fl r
-option of
-.Xr disklabel 8 ,
-which reads the
-.Dq "raw disk" ,
-will fail.
-.Pp
-In general,
-.Xr disklabel 8
-serves no useful purpose on a
-.Nm
-volume.
-If you run it, it will show you
-three partitions,
-.Ql a ,
-.Ql b
-and
-.Ql c ,
-all the same except for the
-.Va fstype ,
-for example:
-.Bd -literal
-3 partitions:
-# size offset fstype [fsize bsize bps/cpg]
- a: 2048 0 4.2BSD 1024 8192 0 # (Cyl. 0 - 0)
- b: 2048 0 swap # (Cyl. 0 - 0)
- c: 2048 0 unused 0 0 # (Cyl. 0 - 0)
-.Ed
-.Pp
-.Nm
-ignores the
-.Dv DIOCWDINFO
-and
-.Dv DIOCSDINFO
-ioctls, since there is nothing to change.
-As a result, any attempt to modify the disk label will be silently ignored.
-.Sh MAKING FILE SYSTEMS
-Since
-.Nm
-volumes do not contain partitions, the names do not need to conform to the
-standard rules for naming disk partitions.
-For a physical disk partition, the
-last letter of the device name specifies the partition identifier (a to h).
-.Nm
-volumes need not conform to this convention, but if they do not,
-.Xr newfs 8
-will complain that it cannot determine the partition.
-To solve this problem,
-use the
-.Fl v
-flag to
-.Xr newfs 8 .
-For example, if you have a volume
-.Pa concat ,
-use the following command to create a UFS file system on it:
-.Pp
-.Dl "newfs -v /dev/vinum/concat"
-.Sh OBJECT NAMING
-.Nm
-assigns default names to plexes and subdisks, although they may be overridden.
-We do not recommend overriding the default names.
-Experience with the
-Veritas\(tm
-volume manager, which allows arbitrary naming of objects, has shown that this
-flexibility does not bring a significant advantage, and it can cause confusion.
-.Pp
-Names may contain any non-blank character, but it is recommended to restrict
-them to letters, digits and the underscore characters.
-The names of volumes,
-plexes and subdisks may be up to 64 characters long, and the names of drives may
-up to 32 characters long.
-When choosing volume and plex names, bear in mind
-that automatically generated plex and subdisk names are longer than the name
-from which they are derived.
-.Bl -bullet
-.It
-When
-.Nm
-creates or deletes objects, it creates a directory
-.Pa /dev/vinum ,
-in which it makes device entries for each volume it finds.
-It also creates
-subdirectories,
-.Pa /dev/vinum/plex
-and
-.Pa /dev/vinum/sd ,
-in which it stores device entries for plexes and subdisks.
-In addition, it creates two more directories,
-.Pa /dev/vinum/vol
-and
-.Pa /dev/vinum/drive ,
-in which it stores hierarchical information for volumes and drives.
-.It
-In addition,
-.Nm
-creates three super-devices,
-.Pa /dev/vinum/control ,
-.Pa /dev/vinum/Control
-and
-.Pa /dev/vinum/controld .
-.Pa /dev/vinum/control
-is used by
-.Xr gvinum 8
-when it has been compiled without the
-.Dv VINUMDEBUG
-option,
-.Pa /dev/vinum/Control
-is used by
-.Xr gvinum 8
-when it has been compiled with the
-.Dv VINUMDEBUG
-option, and
-.Pa /dev/vinum/controld
-is used by the
-.Nm
-daemon.
-The two control devices for
-.Xr gvinum 8
-are used to synchronize the debug status of kernel and user modules.
-.It
-Unlike
-.Ux
-drives,
-.Nm
-volumes are not subdivided into partitions, and thus do not contain a disk
-label.
-Unfortunately, this confuses a number of utilities, notably
-.Xr newfs 8 ,
-which normally tries to interpret the last letter of a
-.Nm
-volume name as a partition identifier.
-If you use a volume name which does not
-end in the letters
-.Ql a
-to
-.Ql c ,
-you must use the
-.Fl v
-flag to
-.Xr newfs 8
-in order to tell it to ignore this convention.
-.\"
-.It
-Plexes do not need to be assigned explicit names.
-By default, a plex name is
-the name of the volume followed by the letters
-.Pa .p
-and the number of the
-plex.
-For example, the plexes of volume
-.Pa vol3
-are called
-.Pa vol3.p0 , vol3.p1
-and so on.
-These names can be overridden, but it is not recommended.
-.It
-Like plexes, subdisks are assigned names automatically, and explicit naming is
-discouraged.
-A subdisk name is the name of the plex followed by the letters
-.Pa .s
-and a number identifying the subdisk.
-For example, the subdisks of
-plex
-.Pa vol3.p0
-are called
-.Pa vol3.p0.s0 , vol3.p0.s1
-and so on.
-.It
-By contrast,
-.Em drives
-must be named.
-This makes it possible to move a drive to a different location
-and still recognize it automatically.
-Drive names may be up to 32 characters
-long.
-.El
-.Ss Example
-Assume the
-.Nm
-objects described in the section
-.Sx "CONFIGURATION FILE"
-in
-.Xr gvinum 8 .
-The directory
-.Pa /dev/vinum
-looks like:
-.Bd -literal -offset indent
-# ls -lR /dev/vinum
-total 5
-brwxr-xr-- 1 root wheel 25, 2 Mar 30 16:08 concat
-brwx------ 1 root wheel 25, 0x40000000 Mar 30 16:08 control
-brwx------ 1 root wheel 25, 0x40000001 Mar 30 16:08 controld
-drwxrwxrwx 2 root wheel 512 Mar 30 16:08 drive
-drwxrwxrwx 2 root wheel 512 Mar 30 16:08 plex
-drwxrwxrwx 2 root wheel 512 Mar 30 16:08 rvol
-drwxrwxrwx 2 root wheel 512 Mar 30 16:08 sd
-brwxr-xr-- 1 root wheel 25, 3 Mar 30 16:08 strcon
-brwxr-xr-- 1 root wheel 25, 1 Mar 30 16:08 stripe
-brwxr-xr-- 1 root wheel 25, 0 Mar 30 16:08 tinyvol
-drwxrwxrwx 7 root wheel 512 Mar 30 16:08 vol
-brwxr-xr-- 1 root wheel 25, 4 Mar 30 16:08 vol5
-
-/dev/vinum/drive:
-total 0
-brw-r----- 1 root operator 4, 15 Oct 21 16:51 drive2
-brw-r----- 1 root operator 4, 31 Oct 21 16:51 drive4
-
-/dev/vinum/plex:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x10000002 Mar 30 16:08 concat.p0
-brwxr-xr-- 1 root wheel 25, 0x10010002 Mar 30 16:08 concat.p1
-brwxr-xr-- 1 root wheel 25, 0x10000003 Mar 30 16:08 strcon.p0
-brwxr-xr-- 1 root wheel 25, 0x10010003 Mar 30 16:08 strcon.p1
-brwxr-xr-- 1 root wheel 25, 0x10000001 Mar 30 16:08 stripe.p0
-brwxr-xr-- 1 root wheel 25, 0x10000000 Mar 30 16:08 tinyvol.p0
-brwxr-xr-- 1 root wheel 25, 0x10000004 Mar 30 16:08 vol5.p0
-brwxr-xr-- 1 root wheel 25, 0x10010004 Mar 30 16:08 vol5.p1
-
-/dev/vinum/sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20000002 Mar 30 16:08 concat.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100002 Mar 30 16:08 concat.p0.s1
-brwxr-xr-- 1 root wheel 25, 0x20010002 Mar 30 16:08 concat.p1.s0
-brwxr-xr-- 1 root wheel 25, 0x20000003 Mar 30 16:08 strcon.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100003 Mar 30 16:08 strcon.p0.s1
-brwxr-xr-- 1 root wheel 25, 0x20010003 Mar 30 16:08 strcon.p1.s0
-brwxr-xr-- 1 root wheel 25, 0x20110003 Mar 30 16:08 strcon.p1.s1
-brwxr-xr-- 1 root wheel 25, 0x20000001 Mar 30 16:08 stripe.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100001 Mar 30 16:08 stripe.p0.s1
-brwxr-xr-- 1 root wheel 25, 0x20000000 Mar 30 16:08 tinyvol.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100000 Mar 30 16:08 tinyvol.p0.s1
-brwxr-xr-- 1 root wheel 25, 0x20000004 Mar 30 16:08 vol5.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100004 Mar 30 16:08 vol5.p0.s1
-brwxr-xr-- 1 root wheel 25, 0x20010004 Mar 30 16:08 vol5.p1.s0
-brwxr-xr-- 1 root wheel 25, 0x20110004 Mar 30 16:08 vol5.p1.s1
-
-/dev/vinum/vol:
-total 5
-brwxr-xr-- 1 root wheel 25, 2 Mar 30 16:08 concat
-drwxr-xr-x 4 root wheel 512 Mar 30 16:08 concat.plex
-brwxr-xr-- 1 root wheel 25, 3 Mar 30 16:08 strcon
-drwxr-xr-x 4 root wheel 512 Mar 30 16:08 strcon.plex
-brwxr-xr-- 1 root wheel 25, 1 Mar 30 16:08 stripe
-drwxr-xr-x 3 root wheel 512 Mar 30 16:08 stripe.plex
-brwxr-xr-- 1 root wheel 25, 0 Mar 30 16:08 tinyvol
-drwxr-xr-x 3 root wheel 512 Mar 30 16:08 tinyvol.plex
-brwxr-xr-- 1 root wheel 25, 4 Mar 30 16:08 vol5
-drwxr-xr-x 4 root wheel 512 Mar 30 16:08 vol5.plex
-
-/dev/vinum/vol/concat.plex:
-total 2
-brwxr-xr-- 1 root wheel 25, 0x10000002 Mar 30 16:08 concat.p0
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 concat.p0.sd
-brwxr-xr-- 1 root wheel 25, 0x10010002 Mar 30 16:08 concat.p1
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 concat.p1.sd
-
-/dev/vinum/vol/concat.plex/concat.p0.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20000002 Mar 30 16:08 concat.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100002 Mar 30 16:08 concat.p0.s1
-
-/dev/vinum/vol/concat.plex/concat.p1.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20010002 Mar 30 16:08 concat.p1.s0
-
-/dev/vinum/vol/strcon.plex:
-total 2
-brwxr-xr-- 1 root wheel 25, 0x10000003 Mar 30 16:08 strcon.p0
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 strcon.p0.sd
-brwxr-xr-- 1 root wheel 25, 0x10010003 Mar 30 16:08 strcon.p1
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 strcon.p1.sd
-
-/dev/vinum/vol/strcon.plex/strcon.p0.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20000003 Mar 30 16:08 strcon.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100003 Mar 30 16:08 strcon.p0.s1
-
-/dev/vinum/vol/strcon.plex/strcon.p1.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20010003 Mar 30 16:08 strcon.p1.s0
-brwxr-xr-- 1 root wheel 25, 0x20110003 Mar 30 16:08 strcon.p1.s1
-
-/dev/vinum/vol/stripe.plex:
-total 1
-brwxr-xr-- 1 root wheel 25, 0x10000001 Mar 30 16:08 stripe.p0
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 stripe.p0.sd
-
-/dev/vinum/vol/stripe.plex/stripe.p0.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20000001 Mar 30 16:08 stripe.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100001 Mar 30 16:08 stripe.p0.s1
-
-/dev/vinum/vol/tinyvol.plex:
-total 1
-brwxr-xr-- 1 root wheel 25, 0x10000000 Mar 30 16:08 tinyvol.p0
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 tinyvol.p0.sd
-
-/dev/vinum/vol/tinyvol.plex/tinyvol.p0.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20000000 Mar 30 16:08 tinyvol.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100000 Mar 30 16:08 tinyvol.p0.s1
-
-/dev/vinum/vol/vol5.plex:
-total 2
-brwxr-xr-- 1 root wheel 25, 0x10000004 Mar 30 16:08 vol5.p0
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 vol5.p0.sd
-brwxr-xr-- 1 root wheel 25, 0x10010004 Mar 30 16:08 vol5.p1
-drwxr-xr-x 2 root wheel 512 Mar 30 16:08 vol5.p1.sd
-
-/dev/vinum/vol/vol5.plex/vol5.p0.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20000004 Mar 30 16:08 vol5.p0.s0
-brwxr-xr-- 1 root wheel 25, 0x20100004 Mar 30 16:08 vol5.p0.s1
-
-/dev/vinum/vol/vol5.plex/vol5.p1.sd:
-total 0
-brwxr-xr-- 1 root wheel 25, 0x20010004 Mar 30 16:08 vol5.p1.s0
-brwxr-xr-- 1 root wheel 25, 0x20110004 Mar 30 16:08 vol5.p1.s1
-.Ed
-.Pp
-In the case of unattached plexes and subdisks, the naming is reversed.
-Subdisks
-are named after the disk on which they are located, and plexes are named after
-the subdisk.
-.\" XXX
-.Bf -symbolic
-This mapping is still to be determined.
-.Ef
-.Ss Object States
-Each
-.Nm
-object has a
-.Em state
-associated with it.
-.Nm
-uses this state to determine the handling of the object.
-.Ss Volume States
-Volumes may have the following states:
-.Bl -hang -width 14n
-.It Em down
-The volume is completely inaccessible.
-.It Em up
-The volume is up and at least partially functional.
-Not all plexes may be
-available.
-.El
-.Ss "Plex States"
-Plexes may have the following states:
-.Bl -hang -width 14n
-.It Em referenced
-A plex entry which has been referenced as part of a volume, but which is
-currently not known.
-.It Em faulty
-A plex which has gone completely down because of I/O errors.
-.It Em down
-A plex which has been taken down by the administrator.
-.It Em initializing
-A plex which is being initialized.
-.El
-.Pp
-The remaining states represent plexes which are at least partially up.
-.Bl -hang -width 14n
-.It Em corrupt
-A plex entry which is at least partially up.
-Not all subdisks are available,
-and an inconsistency has occurred.
-If no other plex is uncorrupted, the volume
-is no longer consistent.
-.It Em degraded
-A RAID-5 plex entry which is accessible, but one subdisk is down, requiring
-recovery for many I/O requests.
-.It Em flaky
-A plex which is really up, but which has a reborn subdisk which we do not
-completely trust, and which we do not want to read if we can avoid it.
-.It Em up
-A plex entry which is completely up.
-All subdisks are up.
-.El
-.Ss "Subdisk States"
-Subdisks can have the following states:
-.Bl -hang -width 14n
-.It Em empty
-A subdisk entry which has been created completely.
-All fields are correct, and
-the disk has been updated, but the on the disk is not valid.
-.It Em referenced
-A subdisk entry which has been referenced as part of a plex, but which is
-currently not known.
-.It Em initializing
-A subdisk entry which has been created completely and which is currently being
-initialized.
-.El
-.Pp
-The following states represent invalid data.
-.Bl -hang -width 14n
-.It Em obsolete
-A subdisk entry which has been created completely.
-All fields are correct, the
-config on disk has been updated, and the data was valid, but since then the
-drive has been taken down, and as a result updates have been missed.
-.It Em stale
-A subdisk entry which has been created completely.
-All fields are correct, the
-disk has been updated, and the data was valid, but since then the drive has been
-crashed and updates have been lost.
-.El
-.Pp
-The following states represent valid, inaccessible data.
-.Bl -hang -width 14n
-.It Em crashed
-A subdisk entry which has been created completely.
-All fields are correct, the
-disk has been updated, and the data was valid, but since then the drive has gone
-down.
-No attempt has been made to write to the subdisk since the crash, so the
-data is valid.
-.It Em down
-A subdisk entry which was up, which contained valid data, and which was taken
-down by the administrator.
-The data is valid.
-.It Em reviving
-The subdisk is currently in the process of being revived.
-We can write but not
-read.
-.El
-.Pp
-The following states represent accessible subdisks with valid data.
-.Bl -hang -width 14n
-.It Em reborn
-A subdisk entry which has been created completely.
-All fields are correct, the
-disk has been updated, and the data was valid, but since then the drive has gone
-down and up again.
-No updates were lost, but it is possible that the subdisk
-has been damaged.
-We will not read from this subdisk if we have a choice.
-If this
-is the only subdisk which covers this address space in the plex, we set its
-state to up under these circumstances, so this status implies that there is
-another subdisk to fulfill the request.
-.It Em up
-A subdisk entry which has been created completely.
-All fields are correct, the
-disk has been updated, and the data is valid.
-.El
-.Ss "Drive States"
-Drives can have the following states:
-.Bl -hang -width 14n
-.It Em referenced
-At least one subdisk refers to the drive, but it is not currently accessible to
-the system.
-No device name is known.
-.It Em down
-The drive is not accessible.
-.It Em up
-The drive is up and running.
-.El
-.Sh SEE ALSO
-.Xr loader.conf 5 ,
-.Xr disklabel 8 ,
-.Xr gvinum 8 ,
-.Xr loader 8 ,
-.Xr newfs 8
-.Sh HISTORY
-.Nm
-first appeared in
-.Fx 3.0 .
-The RAID-5 component of
-.Nm
-was developed by Cybernet Inc.\&
-.Pq Pa http://www.cybernet.com/ ,
-for its NetMAX product.
-.Sh AUTHORS
-.An Greg Lehey Aq grog@lemis.com .
-.Sh BUGS
-The configuration mechanism is not yet
-fully functional.
-If you have difficulties, please look at the section
-.Sx "DEBUGGING PROBLEMS WITH VINUM"
-before reporting problems.
-.Pp
-Kernels with the
-.Nm
-device appear to work, but are not supported.
-If you have trouble with
-this configuration, please first replace the kernel with a
-.No non- Ns Nm
-kernel and test with the KLD module.
-.Pp
-Detection of differences between the version of the kernel and the KLD is not
-yet implemented.
-.Pp
-Some problems have been
-reported with
-.Nm
-in combination with soft updates, but these are not reproducible on all
-systems.
-If you are planning to use
-.Nm
-in a production environment, please test carefully.
-.Sh DEBUGGING PROBLEMS WITH VINUM
-Solving problems with
-.Nm
-can be a difficult affair.
-This section suggests some approaches.
-.Ss Configuration problems
-It is relatively easy (too easy) to run into problems with the
-.Nm
-configuration.
-If you do, the first thing you should do is stop configuration
-updates:
-.Pp
-.Dl "vinum setdaemon 4"
-.Pp
-This will stop updates and any further corruption of the on-disk configuration.
-.Pp
-Next, look at the on-disk configuration, using a Bourne-style shell:
-.Bd -literal
-rm -f log
-for i in /dev/da0s1h /dev/da1s1h /dev/da2s1h /dev/da3s1h; do
- (dd if=$i skip=8 count=6|tr -d '\e000-\e011\e200-\e377'; echo) >> log
-done
-.Ed
-.Pp
-The names of the devices are the names of all
-.Nm
-slices.
-The file
-.Pa log
-should then contain something like this:
-.Bd -literal
-.if t .ps -3
-.if t .vs -3
-IN VINOpanic.lemis.comdrive1}6E7~^K6T^Yfoovolume obj state up
-volume src state up
-volume raid state down
-volume r state down
-volume foo state up
-plex name obj.p0 state corrupt org concat vol obj
-plex name obj.p1 state corrupt org striped 128b vol obj
-plex name src.p0 state corrupt org striped 128b vol src
-plex name src.p1 state up org concat vol src
-plex name raid.p0 state faulty org disorg vol raid
-plex name r.p0 state faulty org disorg vol r
-plex name foo.p0 state up org concat vol foo
-plex name foo.p1 state faulty org concat vol foo
-sd name obj.p0.s0 drive drive2 plex obj.p0 state reborn len 409600b driveoffset 265b plexoffset 0b
-sd name obj.p0.s1 drive drive4 plex obj.p0 state up len 409600b driveoffset 265b plexoffset 409600b
-sd name obj.p1.s0 drive drive1 plex obj.p1 state up len 204800b driveoffset 265b plexoffset 0b
-sd name obj.p1.s1 drive drive2 plex obj.p1 state reborn len 204800b driveoffset 409865b plexoffset 128b
-sd name obj.p1.s2 drive drive3 plex obj.p1 state up len 204800b driveoffset 265b plexoffset 256b
-sd name obj.p1.s3 drive drive4 plex obj.p1 state up len 204800b driveoffset 409865b plexoffset 384b
-.if t .vs
-.if t .ps
-.Ed
-.Pp
-The first line contains the
-.Nm
-label and must start with the text
-.Dq Li "IN VINO" .
-It also contains the name of the system.
-The exact definition is contained in
-.Pa /usr/src/sys/dev/vinum/vinumvar.h .
-The saved configuration starts in the middle of the line with the text
-.Dq Li "volume obj state up"
-and starts in sector 9 of the disk.
-The rest of the output shows the remainder of the on-disk configuration.
-It
-may be necessary to increase the
-.Cm count
-argument of
-.Xr dd 1
-in order to see the complete configuration.
-.Pp
-The configuration on all disks should be the same.
-If this is not the case,
-please report the problem with the exact contents of the file
-.Pa log .
-There is probably little that can be done to recover the on-disk configuration,
-but if you keep a copy of the files used to create the objects, you should be
-able to re-create them.
-The
-.Ic create
-command does not change the subdisk data, so this will not cause data
-corruption.
-You may need to use the
-.Ic resetconfig
-command if you have this kind of trouble.
-.Ss Kernel Panics
-In order to analyse a panic which you suspect comes from
-.Nm
-you will need to build a debug kernel.
-See the online handbook at
-.Pa /usr/share/doc/en/books/developers-handbook/kerneldebug.html
-(if installed) or
-.Pa http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/developers-\%handbook/kerneldebug.html
-for more details of how to do this.
-.Pp
-Perform the following steps to analyse a
-.Nm
-problem:
-.Bl -enum
-.It
-Copy the following files to the directory in which you will be
-performing the analysis, typically
-.Pa /var/crash :
-.Pp
-.Bl -bullet -compact
-.It
-.Pa /usr/src/sys/modules/vinum/.gdbinit.crash ,
-.It
-.Pa /usr/src/sys/modules/vinum/.gdbinit.kernel ,
-.It
-.Pa /usr/src/sys/modules/vinum/.gdbinit.serial ,
-.It
-.Pa /usr/src/sys/modules/vinum/.gdbinit.vinum
-and
-.It
-.Pa /usr/src/sys/modules/vinum/.gdbinit.vinum.paths
-.El
-.It
-Make sure that you build the
-.Nm
-module with debugging information.
-The standard
-.Pa Makefile
-builds a module with debugging symbols by default.
-If the version of
-.Nm
-in
-.Pa /boot/kernel
-does not contain symbols, you will not get an error message, but the stack trace
-will not show the symbols.
-Check the module before starting
-.Xr gdb 1 :
-.Bd -literal
-$ file /boot/kernel/vinum.ko
-/boot/kernel/vinum.ko: ELF 32-bit LSB shared object, Intel 80386,
- version 1 (FreeBSD), not stripped
-.Ed
-.Pp
-If the output shows that
-.Pa /boot/kernel/vinum.ko
-is stripped, you will have to find a version which is not.
-Usually this will be
-either in
-.Pa /usr/obj/sys/modules/vinum/vinum.ko
-(if you have built
-.Nm
-with a
-.Dq Li "make world" )
-or
-.Pa /usr/src/sys/modules/vinum/vinum.ko
-(if you have built
-.Nm
-in this directory).
-Modify the file
-.Pa .gdbinit.vinum.paths
-accordingly.
-.It
-Either take a dump or use remote serial
-.Xr gdb 1
-to analyse the problem.
-To analyse a dump, say
-.Pa /var/crash/vmcore.5 ,
-link
-.Pa /var/crash/.gdbinit.crash
-to
-.Pa /var/crash/.gdbinit
-and enter:
-.Bd -literal -offset indent
-cd /var/crash
-gdb -k kernel.debug vmcore.5
-.Ed
-.Pp
-This example assumes that you have installed the correct debug kernel at
-.Pa /var/crash/kernel.debug .
-If not, substitute the correct name of the debug kernel.
-.Pp
-To perform remote serial debugging,
-link
-.Pa /var/crash/.gdbinit.serial
-to
-.Pa /var/crash/.gdbinit
-and enter
-.Bd -literal -offset indent
-cd /var/crash
-gdb -k kernel.debug
-.Ed
-.Pp
-In this case, the
-.Pa .gdbinit
-file performs the functions necessary to establish connection.
-The remote
-machine must already be in debug mode: enter the kernel debugger and select
-.Ic gdb
-(see
-.Xr ddb 4
-for more details).
-The serial
-.Pa .gdbinit
-file expects the serial connection to run at 38400 bits per second; if you run
-at a different speed, edit the file accordingly (look for the
-.Va remotebaud
-specification).
-.Pp
-The following example shows a remote debugging session using the
-.Ic debug
-command of
-.Xr gvinum 8 :
-.Bd -literal
-.if t .ps -3
-.if t .vs -3
-GDB 4.16 (i386-unknown-freebsd), Copyright 1996 Free Software Foundation, Inc.
-Debugger (msg=0xf1093174 "vinum debug") at ../../i386/i386/db_interface.c:318
-318 in_Debugger = 0;
-#1 0xf108d9bc in vinumioctl (dev=0x40001900, cmd=0xc008464b, data=0xf6dedee0 "",
- flag=0x3, p=0xf68b7940) at
- /usr/src/sys/modules/Vinum/../../dev/Vinum/vinumioctl.c:102
-102 Debugger ("vinum debug");
-(kgdb) bt
-#0 Debugger (msg=0xf0f661ac "vinum debug") at ../../i386/i386/db_interface.c:318
-#1 0xf0f60a7c in vinumioctl (dev=0x40001900, cmd=0xc008464b, data=0xf6923ed0 "",
- flag=0x3, p=0xf688e6c0) at
- /usr/src/sys/modules/vinum/../../dev/vinum/vinumioctl.c:109
-#2 0xf01833b7 in spec_ioctl (ap=0xf6923e0c) at ../../miscfs/specfs/spec_vnops.c:424
-#3 0xf0182cc9 in spec_vnoperate (ap=0xf6923e0c) at ../../miscfs/specfs/spec_vnops.c:129
-#4 0xf01eb3c1 in ufs_vnoperatespec (ap=0xf6923e0c) at ../../ufs/ufs/ufs_vnops.c:2312
-#5 0xf017dbb1 in vn_ioctl (fp=0xf1007ec0, com=0xc008464b, data=0xf6923ed0 "",
- p=0xf688e6c0) at vnode_if.h:395
-#6 0xf015dce0 in ioctl (p=0xf688e6c0, uap=0xf6923f84) at ../../kern/sys_generic.c:473
-#7 0xf0214c0b in syscall (frame={tf_es = 0x27, tf_ds = 0x27, tf_edi = 0xefbfcff8,
- tf_esi = 0x1, tf_ebp = 0xefbfcf90, tf_isp = 0xf6923fd4, tf_ebx = 0x2,
- tf_edx = 0x804b614, tf_ecx = 0x8085d10, tf_eax = 0x36, tf_trapno = 0x7,
- tf_err = 0x2, tf_eip = 0x8060a34, tf_cs = 0x1f, tf_eflags = 0x286,
- tf_esp = 0xefbfcf78, tf_ss = 0x27}) at ../../i386/i386/trap.c:1100
-#8 0xf020a1fc in Xint0x80_syscall ()
-#9 0x804832d in ?? ()
-#10 0x80482ad in ?? ()
-#11 0x80480e9 in ?? ()
-.if t .vs
-.if t .ps
-.Ed
-.Pp
-When entering from the debugger, it is important that the source of frame 1
-(listed by the
-.Pa .gdbinit
-file at the top of the example) contains the text
-.Dq Li "Debugger (\*[q]vinum debug\*[q]);" .
-.Pp
-This is an indication that the address specifications are correct.
-If you get
-some other output, your symbols and the kernel module are out of sync, and the
-trace will be meaningless.
-.El
-.Pp
-For an initial investigation, the most important information is the output of
-the
-.Ic bt
-(backtrace) command above.
-.Ss Reporting Problems with Vinum
-If you find any bugs in
-.Nm ,
-please report them to
-.An Greg Lehey Aq grog@lemis.com .
-Supply the following
-information:
-.Bl -bullet
-.It
-The output of the
-.Nm vinum Cm list
-command
-(see
-.Xr gvinum 8 ) .
-.It
-Any messages printed in
-.Pa /var/log/messages .
-All such messages will be identified by the text
-.Dq Li vinum
-at the beginning.
-.It
-If you have a panic, a stack trace as described above.
-.El
diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree
index 7d4df68..47a41bd 100644
--- a/share/misc/bsd-family-tree
+++ b/share/misc/bsd-family-tree
@@ -252,12 +252,14 @@ FreeBSD 5.2 | | | |
| | | | OpenBSD 5.0 |
*--FreeBSD | | | | |
| 9.0 | | | | DragonFly 3.0.1
- | v FreeBSD | | | |
- | 8.3 | | OpenBSD 5.1 |
- | Mac OS X | | |
- | 10.8 | | |
- | | NetBSD 6.0 | |
- | | | OpenBSD 5.2 DragonFly 3.2.1
+ | | FreeBSD | | | |
+ | | 8.3 | | OpenBSD 5.1 |
+ | | Mac OS X | | |
+ | | 10.8 | | |
+ | | | NetBSD 6.0 | |
+ | | | | OpenBSD 5.2 DragonFly 3.2.1
+ | FreeBSD | | | |
+ | 9.1 | | | |
| | | | |
FreeBSD 10 -current | NetBSD -current OpenBSD -current |
| | | | |
@@ -555,6 +557,7 @@ Mac OS X 10.8 2012-07-25 [APL]
NetBSD 6.0 2012-10-17 [NBD]
OpenBSD 5.2 2012-11-01 [OBD]
DragonFly 3.2.1 2012-11-02 [DFB]
+FreeBSD 9.1 2012-12-30 [FBD]
Bibliography
------------------------
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 324fc69..55d2cff 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -4235,6 +4235,30 @@ pmap_copy_page(vm_page_t msrc, vm_page_t mdst)
pagecopy((void *)src, (void *)dst);
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ void *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ a_cp = (char *)PHYS_TO_DMAP(ma[a_offset >> PAGE_SHIFT]->
+ phys_addr) + a_pg_offset;
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ b_cp = (char *)PHYS_TO_DMAP(mb[b_offset >> PAGE_SHIFT]->
+ phys_addr) + b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+}
+
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
index 287ac8c..8db79ce 100644
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -153,10 +153,7 @@ static int cap_unrestricted_guest;
static int cap_monitor_trap;
/* statistics */
-static VMM_STAT_DEFINE(VCPU_MIGRATIONS, "vcpu migration across host cpus");
-static VMM_STAT_DEFINE(VMEXIT_EXTINT, "vm exits due to external interrupt");
-static VMM_STAT_DEFINE(VMEXIT_HLT_IGNORED, "number of times hlt was ignored");
-static VMM_STAT_DEFINE(VMEXIT_HLT, "number of times hlt was intercepted");
+static VMM_STAT_INTEL(VMEXIT_HLT_IGNORED, "number of times hlt was ignored");
#ifdef KTR
static const char *
@@ -1216,6 +1213,8 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_exit *vmexit)
qual = vmexit->u.vmx.exit_qualification;
vmexit->exitcode = VM_EXITCODE_BOGUS;
+ vmm_stat_incr(vmx->vm, vcpu, VMEXIT_COUNT, 1);
+
switch (vmexit->u.vmx.exit_reason) {
case EXIT_REASON_CR_ACCESS:
handled = vmx_emulate_cr_access(vmx, vcpu, qual);
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index 85d277e..1de4470 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -139,7 +139,7 @@ static MALLOC_DEFINE(M_VM, "vm", "vm");
CTASSERT(VMM_MSR_NUM <= 64); /* msr_mask can keep track of up to 64 msrs */
/* statistics */
-static VMM_STAT_DEFINE(VCPU_TOTAL_RUNTIME, "vcpu total runtime");
+static VMM_STAT(VCPU_TOTAL_RUNTIME, "vcpu total runtime");
static void
vcpu_cleanup(struct vcpu *vcpu)
@@ -612,7 +612,7 @@ save_guest_fpustate(struct vcpu *vcpu)
fpu_start_emulating();
}
-static VMM_STAT_DEFINE(VCPU_IDLE_TICKS, "number of ticks vcpu was idle");
+static VMM_STAT(VCPU_IDLE_TICKS, "number of ticks vcpu was idle");
int
vm_run(struct vm *vm, struct vm_run *vmrun)
@@ -717,7 +717,7 @@ vm_inject_event(struct vm *vm, int vcpuid, int type,
return (VMINJECT(vm->cookie, vcpuid, type, vector, code, code_valid));
}
-static VMM_STAT_DEFINE(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu");
+static VMM_STAT(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu");
int
vm_inject_nmi(struct vm *vm, int vcpuid)
@@ -937,7 +937,7 @@ vm_set_x2apic_state(struct vm *vm, int vcpuid, enum x2apic_state state)
if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
return (EINVAL);
- if (state < 0 || state >= X2APIC_STATE_LAST)
+ if (state >= X2APIC_STATE_LAST)
return (EINVAL);
vm->vcpu[vcpuid].x2apic_state = state;
diff --git a/sys/amd64/vmm/vmm_stat.c b/sys/amd64/vmm/vmm_stat.c
index ae60979..ae156ee 100644
--- a/sys/amd64/vmm/vmm_stat.c
+++ b/sys/amd64/vmm/vmm_stat.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/smp.h>
#include <machine/vmm.h>
+#include "vmm_util.h"
#include "vmm_stat.h"
static int vstnum;
@@ -52,6 +53,12 @@ vmm_stat_init(void *arg)
if (vst->desc == NULL)
return;
+ if (vst->scope == VMM_STAT_SCOPE_INTEL && !vmm_is_intel())
+ return;
+
+ if (vst->scope == VMM_STAT_SCOPE_AMD && !vmm_is_amd())
+ return;
+
if (vstnum >= MAX_VMM_STAT_TYPES) {
printf("Cannot accomodate vmm stat type \"%s\"!\n", vst->desc);
return;
@@ -102,3 +109,9 @@ vmm_stat_desc(int index)
else
return (NULL);
}
+
+/* global statistics */
+VMM_STAT(VCPU_MIGRATIONS, "vcpu migration across host cpus");
+VMM_STAT(VMEXIT_COUNT, "total number of vm exits");
+VMM_STAT(VMEXIT_EXTINT, "vm exits due to external interrupt");
+VMM_STAT(VMEXIT_HLT, "number of times hlt was intercepted");
diff --git a/sys/amd64/vmm/vmm_stat.h b/sys/amd64/vmm/vmm_stat.h
index 7c075a6..a1c0967 100644
--- a/sys/amd64/vmm/vmm_stat.h
+++ b/sys/amd64/vmm/vmm_stat.h
@@ -36,19 +36,36 @@ struct vm;
#define MAX_VMM_STAT_TYPES 64 /* arbitrary */
+enum vmm_stat_scope {
+ VMM_STAT_SCOPE_ANY,
+ VMM_STAT_SCOPE_INTEL, /* Intel VMX specific statistic */
+ VMM_STAT_SCOPE_AMD, /* AMD SVM specific statistic */
+};
+
struct vmm_stat_type {
- const char *desc; /* description of statistic */
int index; /* position in the stats buffer */
+ const char *desc; /* description of statistic */
+ enum vmm_stat_scope scope;
};
void vmm_stat_init(void *arg);
-#define VMM_STAT_DEFINE(type, desc) \
+#define VMM_STAT_DEFINE(type, desc, scope) \
struct vmm_stat_type type[1] = { \
- { desc, -1 } \
+ { -1, desc, scope } \
}; \
SYSINIT(type##_stat, SI_SUB_KLD, SI_ORDER_ANY, vmm_stat_init, type)
+#define VMM_STAT_DECLARE(type) \
+ extern struct vmm_stat_type type[1]
+
+#define VMM_STAT(type, desc) \
+ VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_ANY)
+#define VMM_STAT_INTEL(type, desc) \
+ VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_INTEL)
+#define VMM_STAT_AMD(type, desc) \
+ VMM_STAT_DEFINE(type, desc, VMM_STAT_SCOPE_AMD)
+
void *vmm_stat_alloc(void);
void vmm_stat_free(void *vp);
@@ -68,4 +85,8 @@ vmm_stat_incr(struct vm *vm, int vcpu, struct vmm_stat_type *vst, uint64_t x)
#endif
}
+VMM_STAT_DECLARE(VCPU_MIGRATIONS);
+VMM_STAT_DECLARE(VMEXIT_COUNT);
+VMM_STAT_DECLARE(VMEXIT_EXTINT);
+VMM_STAT_DECLARE(VMEXIT_HLT);
#endif
diff --git a/sys/arm/arm/bcopy_page.S b/sys/arm/arm/bcopy_page.S
index 27921d4..92e38cc 100644
--- a/sys/arm/arm/bcopy_page.S
+++ b/sys/arm/arm/bcopy_page.S
@@ -117,6 +117,7 @@ ENTRY(bcopy_page)
bne 1b
RESTORE_REGS /* ...and return. */
+END(bcopy_page)
/*
* bzero_page(dest)
@@ -178,6 +179,7 @@ ENTRY(bzero_page)
bne 1b
ldmfd sp!, {r4-r8, pc}
+END(bzero_page)
#else /* _ARM_ARCH_5E */
@@ -246,6 +248,7 @@ ENTRY(bcopy_page)
bgt 1b
ldmfd sp!, {r4, r5}
RET
+END(bcopy_page)
/*
* armv5e version of bzero_page
@@ -273,4 +276,5 @@ ENTRY(bzero_page)
subs r1, r1, #128
bne 1b
RET
+END(bzero_page)
#endif /* _ARM_ARCH_5E */
diff --git a/sys/arm/arm/bcopyinout.S b/sys/arm/arm/bcopyinout.S
index 992d0d7..68fdf20 100644
--- a/sys/arm/arm/bcopyinout.S
+++ b/sys/arm/arm/bcopyinout.S
@@ -312,6 +312,7 @@ ENTRY(copyin)
RESTORE_REGS
RET
+END(copyin)
/*
* r0 = kernel space address
@@ -538,6 +539,7 @@ ENTRY(copyout)
RESTORE_REGS
RET
+END(copyout)
#endif
/*
@@ -564,6 +566,7 @@ ENTRY(badaddr_read_1)
mov r0, #0 /* No fault */
1: str ip, [r2, #PCB_ONFAULT]
RET
+END(badaddr_read_1)
/*
* int badaddr_read_2(const uint16_t *src, uint16_t *dest)
@@ -589,6 +592,7 @@ ENTRY(badaddr_read_2)
mov r0, #0 /* No fault */
1: str ip, [r2, #PCB_ONFAULT]
RET
+END(badaddr_read_2)
/*
* int badaddr_read_4(const uint32_t *src, uint32_t *dest)
@@ -614,4 +618,5 @@ ENTRY(badaddr_read_4)
mov r0, #0 /* No fault */
1: str ip, [r2, #PCB_ONFAULT]
RET
+END(badaddr_read_4)
diff --git a/sys/arm/arm/bcopyinout_xscale.S b/sys/arm/arm/bcopyinout_xscale.S
index a2853cc..2cb98d9 100644
--- a/sys/arm/arm/bcopyinout_xscale.S
+++ b/sys/arm/arm/bcopyinout_xscale.S
@@ -492,7 +492,7 @@ ENTRY(copyin)
ldrbt ip, [r0]
strb ip, [r1]
RET
-
+END(copyin)
/*
* r0 = kernel space address
@@ -935,3 +935,5 @@ ENTRY(copyout)
ldrb ip, [r0]
strbt ip, [r1]
RET
+END(copyout)
+
diff --git a/sys/arm/arm/blockio.S b/sys/arm/arm/blockio.S
index 7e750b4..d121f2c 100644
--- a/sys/arm/arm/blockio.S
+++ b/sys/arm/arm/blockio.S
@@ -101,6 +101,7 @@ ENTRY(read_multi_1)
ldrgtb r3, [r0]
strgtb r3, [r1], #1
ldmdb fp, {fp, sp, pc}
+END(read_multi_1)
/*
* Write bytes to an I/O address from a block of memory
@@ -152,6 +153,7 @@ ENTRY(write_multi_1)
ldrgtb r3, [r1], #1
strgtb r3, [r0]
ldmdb fp, {fp, sp, pc}
+END(write_multi_1)
/*
* Reads short ints (16 bits) from an I/O address into a block of memory
@@ -199,7 +201,7 @@ ENTRY(insw)
bgt .Lfastinswloop
RET
-
+END(insw)
/*
* Writes short ints (16 bits) from a block of memory to an I/O address
@@ -260,6 +262,7 @@ ENTRY(outsw)
bgt .Lfastoutswloop
RET
+END(outsw)
/*
* reads short ints (16 bits) from an I/O address into a block of memory
@@ -318,7 +321,7 @@ ENTRY(insw16)
bgt .Linsw16loop
ldmfd sp!, {r4,r5,pc} /* Restore regs and go home */
-
+END(insw16)
/*
* Writes short ints (16 bits) from a block of memory to an I/O address
@@ -385,6 +388,7 @@ ENTRY(outsw16)
bgt .Loutsw16loop
ldmfd sp!, {r4,r5,pc} /* and go home */
+END(outsw16)
/*
* reads short ints (16 bits) from an I/O address into a block of memory
@@ -481,6 +485,7 @@ ENTRY(inswm8)
.Linswm8_l1:
ldmfd sp!, {r4-r9,pc} /* And go home */
+END(inswm8)
/*
* write short ints (16 bits) to an I/O address from a block of memory
@@ -585,3 +590,5 @@ ENTRY(outswm8)
.Loutswm8_l1:
ldmfd sp!, {r4-r8,pc} /* And go home */
+END(outswm8)
+
diff --git a/sys/arm/arm/bus_space_asm_generic.S b/sys/arm/arm/bus_space_asm_generic.S
index 2492474..4aa7197 100644
--- a/sys/arm/arm/bus_space_asm_generic.S
+++ b/sys/arm/arm/bus_space_asm_generic.S
@@ -50,14 +50,17 @@ __FBSDID("$FreeBSD$");
ENTRY(generic_bs_r_1)
ldrb r0, [r1, r2]
RET
+END(generic_bs_r_1)
ENTRY(generic_armv4_bs_r_2)
ldrh r0, [r1, r2]
RET
+END(generic_armv4_bs_r_2)
ENTRY(generic_bs_r_4)
ldr r0, [r1, r2]
RET
+END(generic_bs_r_4)
/*
* write single
@@ -66,14 +69,17 @@ ENTRY(generic_bs_r_4)
ENTRY(generic_bs_w_1)
strb r3, [r1, r2]
RET
+END(generic_bs_w_1)
ENTRY(generic_armv4_bs_w_2)
strh r3, [r1, r2]
RET
+END(generic_armv4_bs_w_2)
ENTRY(generic_bs_w_4)
str r3, [r1, r2]
RET
+END(generic_bs_w_4)
/*
* read multiple
@@ -92,6 +98,7 @@ ENTRY(generic_bs_rm_1)
bne 1b
RET
+END(generic_bs_rm_1)
ENTRY(generic_armv4_bs_rm_2)
add r0, r1, r2
@@ -106,6 +113,7 @@ ENTRY(generic_armv4_bs_rm_2)
bne 1b
RET
+END(generic_armv4_bs_rm_2)
ENTRY(generic_bs_rm_4)
add r0, r1, r2
@@ -120,6 +128,7 @@ ENTRY(generic_bs_rm_4)
bne 1b
RET
+END(generic_bs_rm_4)
/*
* write multiple
@@ -138,6 +147,7 @@ ENTRY(generic_bs_wm_1)
bne 1b
RET
+END(generic_bs_wm_1)
ENTRY(generic_armv4_bs_wm_2)
add r0, r1, r2
@@ -152,6 +162,7 @@ ENTRY(generic_armv4_bs_wm_2)
bne 1b
RET
+END(generic_armv4_bs_wm_2)
ENTRY(generic_bs_wm_4)
add r0, r1, r2
@@ -166,6 +177,7 @@ ENTRY(generic_bs_wm_4)
bne 1b
RET
+END(generic_bs_wm_4)
/*
* read region
@@ -184,6 +196,7 @@ ENTRY(generic_bs_rr_1)
bne 1b
RET
+END(generic_bs_rr_1)
ENTRY(generic_armv4_bs_rr_2)
add r0, r1, r2
@@ -198,6 +211,7 @@ ENTRY(generic_armv4_bs_rr_2)
bne 1b
RET
+END(generic_armv4_bs_rr_2)
ENTRY(generic_bs_rr_4)
add r0, r1, r2
@@ -212,6 +226,7 @@ ENTRY(generic_bs_rr_4)
bne 1b
RET
+END(generic_bs_rr_4)
/*
* write region.
@@ -230,6 +245,7 @@ ENTRY(generic_bs_wr_1)
bne 1b
RET
+END(generic_bs_wr_1)
ENTRY(generic_armv4_bs_wr_2)
add r0, r1, r2
@@ -244,6 +260,7 @@ ENTRY(generic_armv4_bs_wr_2)
bne 1b
RET
+END(generic_armv4_bs_wr_2)
ENTRY(generic_bs_wr_4)
add r0, r1, r2
@@ -258,6 +275,7 @@ ENTRY(generic_bs_wr_4)
bne 1b
RET
+END(generic_bs_wr_4)
/*
* set region
@@ -275,6 +293,7 @@ ENTRY(generic_bs_sr_1)
bne 1b
RET
+END(generic_bs_sr_1)
ENTRY(generic_armv4_bs_sr_2)
add r0, r1, r2
@@ -288,6 +307,7 @@ ENTRY(generic_armv4_bs_sr_2)
bne 1b
RET
+END(generic_armv4_bs_sr_2)
ENTRY(generic_bs_sr_4)
add r0, r1, r2
@@ -301,6 +321,7 @@ ENTRY(generic_bs_sr_4)
bne 1b
RET
+END(generic_bs_sr_4)
/*
* copy region
@@ -335,3 +356,5 @@ ENTRY(generic_armv4_bs_c_2)
bne 3b
RET
+END(generic_armv4_bs_c_2)
+
diff --git a/sys/arm/arm/copystr.S b/sys/arm/arm/copystr.S
index 9eb8682..83b7ec7 100644
--- a/sys/arm/arm/copystr.S
+++ b/sys/arm/arm/copystr.S
@@ -93,6 +93,7 @@ ENTRY(copystr)
ldmfd sp!, {r4-r5} /* stack is 8 byte aligned */
RET
+END(copystr)
#define SAVE_REGS stmfd sp!, {r4-r6}
#define RESTORE_REGS ldmfd sp!, {r4-r6}
@@ -143,6 +144,7 @@ ENTRY(copyinstr)
RESTORE_REGS
RET
+END(copyinstr)
/*
* r0 - kernel space address
@@ -190,6 +192,7 @@ ENTRY(copyoutstr)
RESTORE_REGS
RET
+END(copyoutstr)
/* A fault occurred during the copy */
.Lcopystrfault:
diff --git a/sys/arm/arm/cpufunc_asm.S b/sys/arm/arm/cpufunc_asm.S
index 1709796..eeff722 100644
--- a/sys/arm/arm/cpufunc_asm.S
+++ b/sys/arm/arm/cpufunc_asm.S
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
ENTRY(cpufunc_nullop)
RET
+END(cpufunc_nullop)
/*
* Generic functions to read the internal coprocessor registers
@@ -64,27 +65,32 @@ ENTRY(cpufunc_nullop)
ENTRY(cpufunc_id)
mrc p15, 0, r0, c0, c0, 0
RET
+END(cpufunc_id)
ENTRY(cpufunc_cpuid)
mrc p15, 0, r0, c0, c0, 0
RET
+END(cpufunc_cpuid)
ENTRY(cpu_get_control)
mrc p15, 0, r0, c1, c0, 0
RET
+END(cpu_get_control)
ENTRY(cpu_read_cache_config)
mrc p15, 0, r0, c0, c0, 1
RET
+END(cpu_read_cache_config)
ENTRY(cpufunc_faultstatus)
mrc p15, 0, r0, c5, c0, 0
RET
+END(cpufunc_faultstatus)
ENTRY(cpufunc_faultaddress)
mrc p15, 0, r0, c6, c0, 0
RET
-
+END(cpufunc_faultaddress)
/*
* Generic functions to write the internal coprocessor registers
@@ -101,11 +107,13 @@ ENTRY(cpufunc_faultaddress)
ENTRY(cpufunc_control)
mcr p15, 0, r0, c1, c0, 0
RET
+END(cpufunc_control)
#endif
ENTRY(cpufunc_domains)
mcr p15, 0, r0, c3, c0, 0
RET
+END(cpufunc_domains)
/*
* Generic functions to read/modify/write the internal coprocessor registers
@@ -131,6 +139,8 @@ ENTRY(cpufunc_control)
.Lglou:
.asciz "plop %p\n"
.align 0
+END(cpufunc_control)
+
/*
* other potentially useful software functions are:
* clean D cache entry and flush I cache entry
@@ -157,6 +167,7 @@ ENTRY(get_pc_str_offset)
ldr r0, [sp]
sub r0, r0, r1
ldmdb fp, {fp, sp, pc}
+END(get_pc_str_offset)
/* Allocate and lock a cacheline for the specified address. */
@@ -180,3 +191,5 @@ ENTRY(arm_lock_cache_line)
mcr p15, 0, r1, c9, c2, 0 /* Disable data cache lock mode */
CPWAIT()
RET
+END(arm_lock_cache_line)
+
diff --git a/sys/arm/arm/cpufunc_asm_arm10.S b/sys/arm/arm/cpufunc_asm_arm10.S
index 2ef999c..654219b 100644
--- a/sys/arm/arm/cpufunc_asm_arm10.S
+++ b/sys/arm/arm/cpufunc_asm_arm10.S
@@ -50,6 +50,7 @@ ENTRY(arm10_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
bx lr
+END(arm10_setttb)
/*
* TLB functions
@@ -58,11 +59,12 @@ ENTRY(arm10_tlb_flushID_SE)
mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
bx lr
+END(arm10_tlb_flushID_SE)
ENTRY(arm10_tlb_flushI_SE)
mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
bx lr
-
+END(arm10_tlb_flushI_SE)
/*
* Cache operations. For the entire cache we use the set/index
@@ -90,6 +92,7 @@ ENTRY_NP(arm10_icache_sync_range)
bhi .Larm10_sync_next
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_icache_sync_range)
ENTRY_NP(arm10_icache_sync_all)
.Larm10_icache_sync_all:
@@ -114,6 +117,7 @@ ENTRY_NP(arm10_icache_sync_all)
bhs .Lnext_set /* Next set */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_icache_sync_all)
.Larm10_line_size:
.word _C_LABEL(arm_pdcache_line_size)
@@ -134,6 +138,7 @@ ENTRY(arm10_dcache_wb_range)
bhi .Larm10_wb_next
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_dcache_wb_range)
ENTRY(arm10_dcache_wbinv_range)
ldr ip, .Larm10_line_size
@@ -151,6 +156,7 @@ ENTRY(arm10_dcache_wbinv_range)
bhi .Larm10_wbinv_next
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_dcache_wbinv_range)
/*
* Note, we must not invalidate everything. If the range is too big we
@@ -172,6 +178,7 @@ ENTRY(arm10_dcache_inv_range)
bhi .Larm10_inv_next
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_dcache_inv_range)
ENTRY(arm10_idcache_wbinv_range)
ldr ip, .Larm10_line_size
@@ -190,6 +197,7 @@ ENTRY(arm10_idcache_wbinv_range)
bhi .Larm10_id_wbinv_next
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_idcache_wbinv_range)
ENTRY_NP(arm10_idcache_wbinv_all)
.Larm10_idcache_wbinv_all:
@@ -215,6 +223,8 @@ ENTRY(arm10_dcache_wbinv_all)
bhs .Lnext_set_inv /* Next set */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
bx lr
+END(arm10_idcache_wbinv_all)
+END(arm10_dcache_wbinv_all)
.Larm10_cache_data:
.word _C_LABEL(arm10_dcache_sets_max)
@@ -242,6 +252,7 @@ ENTRY(arm10_context_switch)
nop
nop
bx lr
+END(arm10_context_switch)
.bss
diff --git a/sys/arm/arm/cpufunc_asm_arm11.S b/sys/arm/arm/cpufunc_asm_arm11.S
index b8d8f19..723afc6 100644
--- a/sys/arm/arm/cpufunc_asm_arm11.S
+++ b/sys/arm/arm/cpufunc_asm_arm11.S
@@ -55,6 +55,7 @@ ENTRY(arm11_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
+END(arm11_setttb)
/*
* TLB functions
@@ -64,12 +65,13 @@ ENTRY(arm11_tlb_flushID_SE)
mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
+END(arm11_tlb_flushID_SE)
ENTRY(arm11_tlb_flushI_SE)
mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
-
+END(arm11_tlb_flushI_SE)
/*
* Context switch.
@@ -94,6 +96,7 @@ ENTRY(arm11_context_switch)
nop
nop
RET
+END(arm11_context_switch)
/*
* TLB functions
@@ -102,21 +105,25 @@ ENTRY(arm11_tlb_flushID)
mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(arm11_tlb_flushID)
ENTRY(arm11_tlb_flushI)
mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(arm11_tlb_flushI)
ENTRY(arm11_tlb_flushD)
mcr p15, 0, r0, c8, c6, 0 /* flush D tlb */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(arm11_tlb_flushD)
ENTRY(arm11_tlb_flushD_SE)
mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(arm11_tlb_flushD_SE)
/*
* Other functions
@@ -124,8 +131,11 @@ ENTRY(arm11_tlb_flushD_SE)
ENTRY(arm11_drain_writebuf)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(arm11_drain_writebuf)
ENTRY_NP(arm11_sleep)
mov r0, #0
mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */
RET
+END(arm11_sleep)
+
diff --git a/sys/arm/arm/cpufunc_asm_arm11x6.S b/sys/arm/arm/cpufunc_asm_arm11x6.S
index e223208..6c7eb56 100644
--- a/sys/arm/arm/cpufunc_asm_arm11x6.S
+++ b/sys/arm/arm/cpufunc_asm_arm11x6.S
@@ -124,24 +124,29 @@ ENTRY(arm11x6_setttb)
mcr p15, 0, r1, c8, c7, 0 /* invalidate I+D TLBs */
mcr p15, 0, r1, c7, c10, 4 /* drain write buffer */
RET
+END(arm11x6_setttb)
ENTRY_NP(arm11x6_idcache_wbinv_all)
Flush_D_cache(r0)
Invalidate_I_cache(r0, r1)
RET
+END(arm11x6_idcache_wbinv_all)
ENTRY_NP(arm11x6_dcache_wbinv_all)
Flush_D_cache(r0)
RET
+END(arm11x6_dcache_wbinv_all)
ENTRY_NP(arm11x6_icache_sync_all)
Flush_D_cache(r0)
Invalidate_I_cache(r0, r1)
RET
+END(arm11x6_icache_sync_all)
ENTRY_NP(arm11x6_flush_prefetchbuf)
mcr p15, 0, r0, c7, c5, 4 /* Flush Prefetch Buffer */
RET
+END(arm11x6_flush_prefetchbuf)
ENTRY_NP(arm11x6_icache_sync_range)
add r1, r1, r0
@@ -168,6 +173,7 @@ ENTRY_NP(arm11x6_icache_sync_range)
mcrr p15, 0, r1, r0, c12 /* clean and invalidate D cache range */ /* XXXNH */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(arm11x6_icache_sync_range)
ENTRY_NP(arm11x6_idcache_wbinv_range)
add r1, r1, r0
@@ -194,6 +200,7 @@ ENTRY_NP(arm11x6_idcache_wbinv_range)
mcrr p15, 0, r1, r0, c14 /* clean and invalidate D cache range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(arm11x6_idcache_wbinv_range)
/*
* Preload the cache before issuing the WFI by conditionally disabling the
@@ -216,3 +223,5 @@ ENTRY_NP(arm11x6_sleep)
nop
bne 1b
RET
+END(arm11x6_sleep)
+
diff --git a/sys/arm/arm/cpufunc_asm_arm7tdmi.S b/sys/arm/arm/cpufunc_asm_arm7tdmi.S
index fed6f16..2ac2502 100644
--- a/sys/arm/arm/cpufunc_asm_arm7tdmi.S
+++ b/sys/arm/arm/cpufunc_asm_arm7tdmi.S
@@ -60,6 +60,7 @@ ENTRY(arm7tdmi_setttb)
bl _C_LABEL(arm7tdmi_cache_flushID)
mov pc, r2
+END(arm7tdmi_setttb)
/*
* TLB functions
@@ -68,10 +69,12 @@ ENTRY(arm7tdmi_tlb_flushID)
mov r0, #0
mcr p15, 0, r0, c8, c7, 0
RET
+END(arm7tdmi_tlb_flushID)
ENTRY(arm7tdmi_tlb_flushID_SE)
mcr p15, 0, r0, c8, c7, 1
RET
+END(arm7tdmi_tlb_flushID_SE)
/*
* Cache functions
@@ -86,6 +89,7 @@ ENTRY(arm7tdmi_cache_flushID)
mov r0, r0
RET
+END(arm7tdmi_cache_flushID)
/*
* Context switch.
@@ -98,3 +102,5 @@ ENTRY(arm7tdmi_cache_flushID)
*/
ENTRY(arm7tdmi_context_switch)
b _C_LABEL(arm7tdmi_setttb)
+END(arm7tdmi_context_switch)
+
diff --git a/sys/arm/arm/cpufunc_asm_arm8.S b/sys/arm/arm/cpufunc_asm_arm8.S
index 9f23548..2cb8b11 100644
--- a/sys/arm/arm/cpufunc_asm_arm8.S
+++ b/sys/arm/arm/cpufunc_asm_arm8.S
@@ -58,6 +58,7 @@ ENTRY(arm8_clock_config)
mcr p15, 0, r2, c15, c0, 0 /* Write clock register */
mov r0, r3 /* Return old value */
RET
+END(arm8_clock_config)
/*
* Functions to set the MMU Translation Table Base register
@@ -90,6 +91,7 @@ ENTRY(arm8_setttb)
msr cpsr_all, r3
RET
+END(arm8_setttb)
/*
* TLB functions
@@ -97,10 +99,12 @@ ENTRY(arm8_setttb)
ENTRY(arm8_tlb_flushID)
mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */
RET
+END(arm8_tlb_flushID)
ENTRY(arm8_tlb_flushID_SE)
mcr p15, 0, r0, c8, c7, 1 /* flush I+D tlb single entry */
RET
+END(arm8_tlb_flushID_SE)
/*
* Cache functions
@@ -108,10 +112,12 @@ ENTRY(arm8_tlb_flushID_SE)
ENTRY(arm8_cache_flushID)
mcr p15, 0, r0, c7, c7, 0 /* flush I+D cache */
RET
+END(arm8_cache_flushID)
ENTRY(arm8_cache_flushID_E)
mcr p15, 0, r0, c7, c7, 1 /* flush I+D single entry */
RET
+END(arm8_cache_flushID_E)
ENTRY(arm8_cache_cleanID)
mov r0, #0x00000000
@@ -153,10 +159,12 @@ ENTRY(arm8_cache_cleanID)
bne 1b
RET
+END(arm8_cache_cleanID)
ENTRY(arm8_cache_cleanID_E)
mcr p15, 0, r0, c7, c11, 1 /* clean I+D single entry */
RET
+END(arm8_cache_cleanID_E)
ENTRY(arm8_cache_purgeID)
/*
@@ -232,6 +240,7 @@ ENTRY(arm8_cache_purgeID)
msr cpsr_all, r3
RET
+END(arm8_cache_purgeID)
ENTRY(arm8_cache_purgeID_E)
/*
@@ -253,6 +262,7 @@ ENTRY(arm8_cache_purgeID_E)
mcr p15, 0, r0, c7, c7, 1 /* flush I+D single entry */
msr cpsr_all, r3
RET
+END(arm8_cache_purgeID_E)
/*
* Context switch.
@@ -282,3 +292,5 @@ ENTRY(arm8_context_switch)
mov r0, r0
mov r0, r0
RET
+END(arm8_context_switch)
+
diff --git a/sys/arm/arm/cpufunc_asm_arm9.S b/sys/arm/arm/cpufunc_asm_arm9.S
index ae9fe00..dd29479 100644
--- a/sys/arm/arm/cpufunc_asm_arm9.S
+++ b/sys/arm/arm/cpufunc_asm_arm9.S
@@ -49,6 +49,7 @@ ENTRY(arm9_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
mov pc, lr
+END(arm9_setttb)
/*
* TLB functions
@@ -57,6 +58,7 @@ ENTRY(arm9_tlb_flushID_SE)
mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
mov pc, lr
+END(arm9_tlb_flushID_SE)
/*
* Cache operations. For the entire cache we use the set/index
@@ -83,6 +85,7 @@ ENTRY_NP(arm9_icache_sync_range)
subs r1, r1, ip
bhi .Larm9_sync_next
mov pc, lr
+END(arm9_icache_sync_range)
ENTRY_NP(arm9_icache_sync_all)
.Larm9_icache_sync_all:
@@ -106,6 +109,7 @@ ENTRY_NP(arm9_icache_sync_all)
subs s_max, s_max, s_inc
bhs .Lnext_set /* Next set */
mov pc, lr
+END(arm9_icache_sync_all)
.Larm9_line_size:
.word _C_LABEL(arm_pdcache_line_size)
@@ -125,6 +129,7 @@ ENTRY(arm9_dcache_wb_range)
subs r1, r1, ip
bhi .Larm9_wb_next
mov pc, lr
+END(arm9_dcache_wb_range)
ENTRY(arm9_dcache_wbinv_range)
ldr ip, .Larm9_line_size
@@ -141,6 +146,7 @@ ENTRY(arm9_dcache_wbinv_range)
subs r1, r1, ip
bhi .Larm9_wbinv_next
mov pc, lr
+END(arm9_dcache_wbinv_range)
/*
* Note, we must not invalidate everything. If the range is too big we
@@ -161,6 +167,7 @@ ENTRY(arm9_dcache_inv_range)
subs r1, r1, ip
bhi .Larm9_inv_next
mov pc, lr
+END(arm9_dcache_inv_range)
ENTRY(arm9_idcache_wbinv_range)
ldr ip, .Larm9_line_size
@@ -178,6 +185,7 @@ ENTRY(arm9_idcache_wbinv_range)
subs r1, r1, ip
bhi .Larm9_id_wbinv_next
mov pc, lr
+END(arm9_idcache_wbinv_range)
ENTRY_NP(arm9_idcache_wbinv_all)
.Larm9_idcache_wbinv_all:
@@ -202,6 +210,8 @@ ENTRY(arm9_dcache_wbinv_all)
subs s_max, s_max, s_inc
bhs .Lnext_set_inv /* Next set */
mov pc, lr
+END(arm9_idcache_wbinv_all)
+END(arm9_dcache_wbinv_all)
.Larm9_cache_data:
.word _C_LABEL(arm9_dcache_sets_max)
@@ -229,6 +239,7 @@ ENTRY(arm9_context_switch)
nop
nop
mov pc, lr
+END(arm9_context_switch)
.bss
diff --git a/sys/arm/arm/cpufunc_asm_armv4.S b/sys/arm/arm/cpufunc_asm_armv4.S
index 1b8797d..1123e4a 100644
--- a/sys/arm/arm/cpufunc_asm_armv4.S
+++ b/sys/arm/arm/cpufunc_asm_armv4.S
@@ -46,18 +46,22 @@ __FBSDID("$FreeBSD$");
ENTRY(armv4_tlb_flushID)
mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */
RET
+END(armv4_tlb_flushID)
ENTRY(armv4_tlb_flushI)
mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */
RET
+END(armv4_tlb_flushI)
ENTRY(armv4_tlb_flushD)
mcr p15, 0, r0, c8, c6, 0 /* flush D tlb */
RET
+END(armv4_tlb_flushD)
ENTRY(armv4_tlb_flushD_SE)
mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
RET
+END(armv4_tlb_flushD_SE)
/*
* Other functions
@@ -65,3 +69,5 @@ ENTRY(armv4_tlb_flushD_SE)
ENTRY(armv4_drain_writebuf)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
+END(armv4_drain_writebuf)
+
diff --git a/sys/arm/arm/cpufunc_asm_armv5.S b/sys/arm/arm/cpufunc_asm_armv5.S
index 2faa5f4..94e6b43 100644
--- a/sys/arm/arm/cpufunc_asm_armv5.S
+++ b/sys/arm/arm/cpufunc_asm_armv5.S
@@ -51,6 +51,7 @@ ENTRY(armv5_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
RET
+END(armv5_setttb)
/*
* Cache operations. For the entire cache we use the set/index
@@ -79,6 +80,7 @@ ENTRY_NP(armv5_icache_sync_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_icache_sync_range)
ENTRY_NP(armv5_icache_sync_all)
.Larmv5_icache_sync_all:
@@ -105,6 +107,7 @@ ENTRY_NP(armv5_icache_sync_all)
bpl 1b /* Next set */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_icache_sync_all)
.Larmv5_line_size:
.word _C_LABEL(arm_pdcache_line_size)
@@ -126,6 +129,7 @@ ENTRY(armv5_dcache_wb_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_dcache_wb_range)
ENTRY(armv5_dcache_wbinv_range)
ldr ip, .Larmv5_line_size
@@ -144,6 +148,7 @@ ENTRY(armv5_dcache_wbinv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_dcache_wbinv_range)
/*
* Note, we must not invalidate everything. If the range is too big we
@@ -166,6 +171,7 @@ ENTRY(armv5_dcache_inv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_dcache_inv_range)
ENTRY(armv5_idcache_wbinv_range)
ldr ip, .Larmv5_line_size
@@ -185,6 +191,7 @@ ENTRY(armv5_idcache_wbinv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_idcache_wbinv_range)
ENTRY_NP(armv5_idcache_wbinv_all)
.Larmv5_idcache_wbinv_all:
@@ -212,6 +219,8 @@ ENTRY(armv5_dcache_wbinv_all)
bpl 1b /* Next set */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_idcache_wbinv_all)
+END(armv5_dcache_wbinv_all)
.Larmv5_cache_data:
.word _C_LABEL(armv5_dcache_sets_max)
diff --git a/sys/arm/arm/cpufunc_asm_armv5_ec.S b/sys/arm/arm/cpufunc_asm_armv5_ec.S
index 4012563..a86ac80 100644
--- a/sys/arm/arm/cpufunc_asm_armv5_ec.S
+++ b/sys/arm/arm/cpufunc_asm_armv5_ec.S
@@ -66,6 +66,7 @@ ENTRY(armv5_ec_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
RET
+END(armv5_ec_setttb)
/*
* Cache operations. For the entire cache we use the enhanced cache
@@ -90,6 +91,7 @@ ENTRY_NP(armv5_ec_icache_sync_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_icache_sync_range)
ENTRY_NP(armv5_ec_icache_sync_all)
.Larmv5_ec_icache_sync_all:
@@ -107,6 +109,7 @@ ENTRY_NP(armv5_ec_icache_sync_all)
bne 1b /* More to do? */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_icache_sync_all)
.Larmv5_ec_line_size:
.word _C_LABEL(arm_pdcache_line_size)
@@ -128,6 +131,7 @@ ENTRY(armv5_ec_dcache_wb_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_dcache_wb_range)
ENTRY(armv5_ec_dcache_wbinv_range)
ldr ip, .Larmv5_ec_line_size
@@ -146,6 +150,7 @@ ENTRY(armv5_ec_dcache_wbinv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_dcache_wbinv_range)
/*
* Note, we must not invalidate everything. If the range is too big we
@@ -168,6 +173,7 @@ ENTRY(armv5_ec_dcache_inv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_dcache_inv_range)
ENTRY(armv5_ec_idcache_wbinv_range)
ldr ip, .Larmv5_ec_line_size
@@ -187,6 +193,7 @@ ENTRY(armv5_ec_idcache_wbinv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_idcache_wbinv_range)
ENTRY_NP(armv5_ec_idcache_wbinv_all)
.Larmv5_ec_idcache_wbinv_all:
@@ -197,6 +204,7 @@ ENTRY_NP(armv5_ec_idcache_wbinv_all)
*/
mcr p15, 0, r0, c7, c5, 0 /* Invalidate ICache */
/* Fall through to purge Dcache. */
+END(armv5_ec_idcache_wbinv_all)
ENTRY(armv5_ec_dcache_wbinv_all)
.Larmv5_ec_dcache_wbinv_all:
@@ -204,4 +212,5 @@ ENTRY(armv5_ec_dcache_wbinv_all)
bne 1b /* More to do? */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv5_ec_dcache_wbinv_all)
diff --git a/sys/arm/arm/cpufunc_asm_armv6.S b/sys/arm/arm/cpufunc_asm_armv6.S
index f735754..b8a2d9c 100644
--- a/sys/arm/arm/cpufunc_asm_armv6.S
+++ b/sys/arm/arm/cpufunc_asm_armv6.S
@@ -59,6 +59,7 @@ ENTRY(armv6_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
RET
+END(armv6_setttb)
/*
* Cache operations.
@@ -72,6 +73,7 @@ ENTRY_NP(armv6_icache_sync_range)
mcrr p15, 0, r1, r0, c12 /* clean D cache range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_icache_sync_range)
/* LINTSTUB: void armv6_icache_sync_all(void); */
ENTRY_NP(armv6_icache_sync_all)
@@ -84,6 +86,7 @@ ENTRY_NP(armv6_icache_sync_all)
mcr p15, 0, r0, c7, c10, 0 /* Clean D cache */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_icache_sync_all)
/* LINTSTUB: void armv6_dcache_wb_range(vaddr_t, vsize_t); */
ENTRY(armv6_dcache_wb_range)
@@ -92,6 +95,7 @@ ENTRY(armv6_dcache_wb_range)
mcrr p15, 0, r1, r0, c12 /* clean D cache range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_dcache_wb_range)
/* LINTSTUB: void armv6_dcache_wbinv_range(vaddr_t, vsize_t); */
ENTRY(armv6_dcache_wbinv_range)
@@ -100,6 +104,7 @@ ENTRY(armv6_dcache_wbinv_range)
mcrr p15, 0, r1, r0, c14 /* clean and invaliate D cache range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_dcache_wbinv_range)
/*
* Note, we must not invalidate everything. If the range is too big we
@@ -113,6 +118,7 @@ ENTRY(armv6_dcache_inv_range)
mcrr p15, 0, r1, r0, c6 /* invaliate D cache range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_dcache_inv_range)
/* LINTSTUB: void armv6_idcache_wbinv_range(vaddr_t, vsize_t); */
ENTRY(armv6_idcache_wbinv_range)
@@ -122,6 +128,7 @@ ENTRY(armv6_idcache_wbinv_range)
mcrr p15, 0, r1, r0, c14 /* clean & invaliate D cache range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_idcache_wbinv_range)
/* LINTSTUB: void armv6_idcache_wbinv_all(void); */
ENTRY_NP(armv6_idcache_wbinv_all)
@@ -138,3 +145,6 @@ ENTRY(armv6_dcache_wbinv_all)
mcr p15, 0, r0, c7, c14, 0 /* clean & invalidate D cache */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_idcache_wbinv_all)
+END(armv6_dcache_wbinv_all)
+
diff --git a/sys/arm/arm/cpufunc_asm_armv7.S b/sys/arm/arm/cpufunc_asm_armv7.S
index 58f295c..2b4be85 100644
--- a/sys/arm/arm/cpufunc_asm_armv7.S
+++ b/sys/arm/arm/cpufunc_asm_armv7.S
@@ -78,6 +78,7 @@ ENTRY(armv7_setttb)
dsb
isb
RET
+END(armv7_setttb)
ENTRY(armv7_tlb_flushID)
dsb
@@ -91,6 +92,7 @@ ENTRY(armv7_tlb_flushID)
dsb
isb
mov pc, lr
+END(armv7_tlb_flushID)
ENTRY(armv7_tlb_flushID_SE)
ldr r1, .Lpage_mask
@@ -105,6 +107,7 @@ ENTRY(armv7_tlb_flushID_SE)
dsb
isb
mov pc, lr
+END(armv7_tlb_flushID_SE)
/* Based on algorithm from ARM Architecture Reference Manual */
ENTRY(armv7_dcache_wbinv_all)
@@ -157,6 +160,7 @@ Finished:
dsb
ldmia sp!, {r4, r5, r6, r7, r8, r9}
RET
+END(armv7_dcache_wbinv_all)
ENTRY(armv7_idcache_wbinv_all)
stmdb sp!, {lr}
@@ -170,6 +174,7 @@ ENTRY(armv7_idcache_wbinv_all)
isb
ldmia sp!, {lr}
RET
+END(armv7_idcache_wbinv_all)
/* XXX Temporary set it to 32 for MV cores, however this value should be
* get from Cache Type register
@@ -190,6 +195,7 @@ ENTRY(armv7_dcache_wb_range)
bhi .Larmv7_wb_next
dsb /* data synchronization barrier */
RET
+END(armv7_dcache_wb_range)
ENTRY(armv7_dcache_wbinv_range)
ldr ip, .Larmv7_line_size
@@ -204,6 +210,7 @@ ENTRY(armv7_dcache_wbinv_range)
bhi .Larmv7_wbinv_next
dsb /* data synchronization barrier */
RET
+END(armv7_dcache_wbinv_range)
/*
* Note, we must not invalidate everything. If the range is too big we
@@ -222,6 +229,7 @@ ENTRY(armv7_dcache_inv_range)
bhi .Larmv7_inv_next
dsb /* data synchronization barrier */
RET
+END(armv7_dcache_inv_range)
ENTRY(armv7_idcache_wbinv_range)
ldr ip, .Larmv7_line_size
@@ -238,6 +246,7 @@ ENTRY(armv7_idcache_wbinv_range)
isb /* instruction synchronization barrier */
dsb /* data synchronization barrier */
RET
+END(armv7_idcache_wbinv_range)
ENTRY_NP(armv7_icache_sync_range)
ldr ip, .Larmv7_line_size
@@ -250,11 +259,13 @@ ENTRY_NP(armv7_icache_sync_range)
isb /* instruction synchronization barrier */
dsb /* data synchronization barrier */
RET
+END(armv7_icache_sync_range)
ENTRY(armv7_cpu_sleep)
dsb /* data synchronization barrier */
wfi /* wait for interrupt */
RET
+END(armv7_cpu_sleep)
ENTRY(armv7_context_switch)
dsb
@@ -269,16 +280,19 @@ ENTRY(armv7_context_switch)
dsb
isb
RET
+END(armv7_context_switch)
ENTRY(armv7_drain_writebuf)
dsb
RET
+END(armv7_drain_writebuf)
ENTRY(armv7_sev)
dsb
sev
nop
RET
+END(armv7_sev)
ENTRY(armv7_auxctrl)
mrc p15, 0, r2, c1, c0, 1
@@ -289,3 +303,5 @@ ENTRY(armv7_auxctrl)
mcrne p15, 0, r3, c1, c0, 1
mov r0, r2
RET
+END(armv7_auxctrl)
+
diff --git a/sys/arm/arm/cpufunc_asm_fa526.S b/sys/arm/arm/cpufunc_asm_fa526.S
index d53d29a..55c2f37 100644
--- a/sys/arm/arm/cpufunc_asm_fa526.S
+++ b/sys/arm/arm/cpufunc_asm_fa526.S
@@ -54,6 +54,7 @@ ENTRY(fa526_setttb)
mov r0, r0
mov r0, r0
mov pc, lr
+END(fa526_setttb)
/*
* TLB functions
@@ -61,6 +62,7 @@ ENTRY(fa526_setttb)
ENTRY(fa526_tlb_flushID_SE)
mcr p15, 0, r0, c8, c7, 1 /* flush Utlb single entry */
mov pc, lr
+END(fa526_tlb_flushID_SE)
/*
* TLB functions
@@ -68,6 +70,7 @@ ENTRY(fa526_tlb_flushID_SE)
ENTRY(fa526_tlb_flushI_SE)
mcr p15, 0, r0, c8, c5, 1 /* flush Itlb single entry */
mov pc, lr
+END(fa526_tlb_flushI_SE)
ENTRY(fa526_cpu_sleep)
mov r0, #0
@@ -75,11 +78,13 @@ ENTRY(fa526_cpu_sleep)
nop*/
mcr p15, 0, r0, c7, c0, 4 /* Wait for interrupt*/
mov pc, lr
+END(fa526_cpu_sleep)
ENTRY(fa526_flush_prefetchbuf)
mov r0, #0
mcr p15, 0, r0, c7, c5, 4 /* Pre-fetch flush */
mov pc, lr
+END(fa526_flush_prefetchbuf)
/*
* Cache functions
@@ -90,17 +95,20 @@ ENTRY(fa526_idcache_wbinv_all)
mcr p15, 0, r0, c7, c5, 0 /* invalidate I$ */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(fa526_idcache_wbinv_all)
ENTRY(fa526_icache_sync_all)
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 /* invalidate I$ */
mov pc, lr
+END(fa526_icache_sync_all)
ENTRY(fa526_dcache_wbinv_all)
mov r0, #0
mcr p15, 0, r0, c7, c14, 0 /* clean and invalidate D$ */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(fa526_dcache_wbinv_all)
/*
* Soft functions
@@ -120,6 +128,7 @@ ENTRY(fa526_dcache_wbinv_range)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(fa526_dcache_wbinv_range)
ENTRY(fa526_dcache_wb_range)
cmp r1, #0x4000
@@ -140,6 +149,7 @@ ENTRY(fa526_dcache_wb_range)
3: mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(fa526_dcache_wb_range)
ENTRY(fa526_dcache_inv_range)
and r2, r0, #(CACHELINE_SIZE - 1)
@@ -152,6 +162,7 @@ ENTRY(fa526_dcache_inv_range)
bhi 1b
mov pc, lr
+END(fa526_dcache_inv_range)
ENTRY(fa526_idcache_wbinv_range)
cmp r1, #0x4000
@@ -169,6 +180,7 @@ ENTRY(fa526_idcache_wbinv_range)
2: mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(fa526_idcache_wbinv_range)
ENTRY(fa526_icache_sync_range)
cmp r1, #0x4000
@@ -186,11 +198,13 @@ ENTRY(fa526_icache_sync_range)
2: mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mov pc, lr
+END(fa526_icache_sync_range)
ENTRY(fa526_flush_brnchtgt_E)
mov r0, #0
mcr p15, 0, r0, c7, c5, 6 /* invalidate BTB cache */
mov pc, lr
+END(fa526_flush_brnchtgt_E)
ENTRY(fa526_context_switch)
/*
@@ -210,4 +224,5 @@ ENTRY(fa526_context_switch)
mov r0, r0
mov r0, r0
mov pc, lr
+END(fa526_context_switch)
diff --git a/sys/arm/arm/cpufunc_asm_ixp12x0.S b/sys/arm/arm/cpufunc_asm_ixp12x0.S
index efc5950..481cf0d 100644
--- a/sys/arm/arm/cpufunc_asm_ixp12x0.S
+++ b/sys/arm/arm/cpufunc_asm_ixp12x0.S
@@ -61,10 +61,12 @@ ENTRY(ixp12x0_context_switch)
mov r0, r0
mov r0, r0
RET
+END(ixp12x0_context_switch)
ENTRY(ixp12x0_drain_readbuf)
mcr p15, 0, r0, c9, c0, 0 /* drain read buffer */
RET
+END(ixp12x0_drain_readbuf)
/*
* Information for the IXP12X0 cache clean/purge functions:
diff --git a/sys/arm/arm/cpufunc_asm_pj4b.S b/sys/arm/arm/cpufunc_asm_pj4b.S
index f6890d9..2e325f3 100644
--- a/sys/arm/arm/cpufunc_asm_pj4b.S
+++ b/sys/arm/arm/cpufunc_asm_pj4b.S
@@ -46,6 +46,7 @@ ENTRY(pj4b_setttb)
mcr p15, 0, r0, c2, c0, 0 /* load new TTB */
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
RET
+END(pj4b_setttb)
ENTRY_NP(armv6_icache_sync_all)
/*
@@ -58,6 +59,7 @@ ENTRY_NP(armv6_icache_sync_all)
mcr p15, 0, r0, c7, c10, 0 /* Clean (don't invalidate) DCache */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_icache_sync_all)
ENTRY(pj4b_icache_sync_range)
sub r1, r1, #1
@@ -66,6 +68,7 @@ ENTRY(pj4b_icache_sync_range)
mcrr p15, 0, r1, r0, c12 /* clean DC range */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(pj4b_icache_sync_range)
ENTRY(pj4b_dcache_inv_range)
ldr ip, .Lpj4b_cache_line_size
@@ -84,6 +87,7 @@ ENTRY(pj4b_dcache_inv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(pj4b_dcache_inv_range)
ENTRY(armv6_idcache_wbinv_all)
mov r0, #0
@@ -91,12 +95,14 @@ ENTRY(armv6_idcache_wbinv_all)
mcr p15, 0, r0, c7, c14, 0 /* clean and invalidate DCache */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_idcache_wbinv_all)
ENTRY(armv6_dcache_wbinv_all)
mov r0, #0
mcr p15, 0, r0, c7, c14, 0 /* clean and invalidate DCache */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(armv6_dcache_wbinv_all)
ENTRY(pj4b_idcache_wbinv_range)
ldr ip, .Lpj4b_cache_line_size
@@ -121,6 +127,7 @@ ENTRY(pj4b_idcache_wbinv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(pj4b_idcache_wbinv_range)
ENTRY(pj4b_dcache_wbinv_range)
ldr ip, .Lpj4b_cache_line_size
@@ -144,6 +151,7 @@ ENTRY(pj4b_dcache_wbinv_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(pj4b_dcache_wbinv_range)
ENTRY(pj4b_dcache_wb_range)
ldr ip, .Lpj4b_cache_line_size
@@ -167,22 +175,27 @@ ENTRY(pj4b_dcache_wb_range)
bpl 1b
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(pj4b_dcache_wb_range)
ENTRY(pj4b_drain_readbuf)
mcr p15, 0, r0, c7, c5, 4 /* flush prefetch buffers */
RET
+END(pj4b_drain_readbuf)
ENTRY(pj4b_flush_brnchtgt_all)
mcr p15, 0, r0, c7, c5, 6 /* flush entrie branch target cache */
RET
+END(pj4b_flush_brnchtgt_all)
ENTRY(pj4b_flush_brnchtgt_va)
mcr p15, 0, r0, c7, c5, 7 /* flush branch target cache by VA */
RET
+END(pj4b_flush_brnchtgt_va)
ENTRY(get_core_id)
mrc p15, 0, r0, c0, c0, 5
RET
+END(get_core_id)
ENTRY(pj4b_config)
/* Set Auxiliary Debug Modes Control 2 register */
@@ -200,3 +213,5 @@ ENTRY(pj4b_config)
mcr p15, 0, r0, c1, c0, 1
#endif
RET
+END(pj4b_config)
+
diff --git a/sys/arm/arm/cpufunc_asm_sa1.S b/sys/arm/arm/cpufunc_asm_sa1.S
index 0bdd6e7..99cd4f1 100644
--- a/sys/arm/arm/cpufunc_asm_sa1.S
+++ b/sys/arm/arm/cpufunc_asm_sa1.S
@@ -85,6 +85,8 @@ ENTRY(sa1_setttb)
str r2, [r3]
#endif
RET
+END(getttb)
+END(sa1_setttb)
/*
* TLB functions
@@ -93,6 +95,7 @@ ENTRY(sa1_tlb_flushID_SE)
mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */
RET
+END(sa1_tlb_flushID_SE)
/*
* Cache functions
@@ -100,22 +103,27 @@ ENTRY(sa1_tlb_flushID_SE)
ENTRY(sa1_cache_flushID)
mcr p15, 0, r0, c7, c7, 0 /* flush I+D cache */
RET
+END(sa1_cache_flushID)
ENTRY(sa1_cache_flushI)
mcr p15, 0, r0, c7, c5, 0 /* flush I cache */
RET
+END(sa1_cache_flushI)
ENTRY(sa1_cache_flushD)
mcr p15, 0, r0, c7, c6, 0 /* flush D cache */
RET
+END(sa1_cache_flushD)
ENTRY(sa1_cache_flushD_SE)
mcr p15, 0, r0, c7, c6, 1 /* flush D cache single entry */
RET
+END(sa1_cache_flushD_SE)
ENTRY(sa1_cache_cleanD_E)
mcr p15, 0, r0, c7, c10, 1 /* clean D cache entry */
RET
+END(sa1_cache_cleanD_E)
/*
* Information for the SA-1 cache clean/purge functions:
@@ -196,6 +204,11 @@ ENTRY(sa1_cache_cleanD)
SA1_CACHE_CLEAN_EPILOGUE
RET
+END(sa1_cache_syncI)
+END(sa1_cache_purgeID)
+END(sa1_cache_cleanID)
+END(sa1_cache_purgeD)
+END(sa1_cache_cleanD)
ENTRY(sa1_cache_purgeID_E)
mcr p15, 0, r0, c7, c10, 1 /* clean dcache entry */
@@ -203,12 +216,14 @@ ENTRY(sa1_cache_purgeID_E)
mcr p15, 0, r0, c7, c5, 0 /* flush I cache */
mcr p15, 0, r0, c7, c6, 1 /* flush D cache single entry */
RET
+END(sa1_cache_purgeID_E)
ENTRY(sa1_cache_purgeD_E)
mcr p15, 0, r0, c7, c10, 1 /* clean dcache entry */
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mcr p15, 0, r0, c7, c6, 1 /* flush D cache single entry */
RET
+END(sa1_cache_purgeD_E)
/*
* Soft functions
@@ -231,6 +246,8 @@ ENTRY(sa1_cache_cleanD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
+END(sa1_cache_cleanID_rng)
+END(sa1_cache_cleanD_rng)
ENTRY(sa1_cache_purgeID_rng)
cmp r1, #0x4000
@@ -249,6 +266,7 @@ ENTRY(sa1_cache_purgeID_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mcr p15, 0, r0, c7, c5, 0 /* flush I cache */
RET
+END(sa1_cache_purgeID_rng)
ENTRY(sa1_cache_purgeD_rng)
cmp r1, #0x4000
@@ -266,6 +284,7 @@ ENTRY(sa1_cache_purgeD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
+END(sa1_cache_purgeD_rng)
ENTRY(sa1_cache_syncI_rng)
cmp r1, #0x4000
@@ -284,6 +303,7 @@ ENTRY(sa1_cache_syncI_rng)
mcr p15, 0, r0, c7, c5, 0 /* flush I cache */
RET
+END(sa1_cache_syncI_rng)
/*
* Context switch.
@@ -313,4 +333,5 @@ ENTRY(sa110_context_switch)
mov r0, r0
mov r0, r0
RET
+END(sa110_context_switch)
#endif
diff --git a/sys/arm/arm/cpufunc_asm_sa11x0.S b/sys/arm/arm/cpufunc_asm_sa11x0.S
index ca167c8..17efc8f 100644
--- a/sys/arm/arm/cpufunc_asm_sa11x0.S
+++ b/sys/arm/arm/cpufunc_asm_sa11x0.S
@@ -95,7 +95,7 @@ ENTRY(sa11x0_cpu_sleep)
/* Restore interrupts (which will cause them to be serviced). */
msr cpsr_all, r3
RET
-
+END(sa11x0_cpu_sleep)
/*
* This function is the same as sa110_context_switch for now, the plan
@@ -119,7 +119,10 @@ ENTRY(sa11x0_context_switch)
mov r0, r0
mov r0, r0
RET
+END(sa11x0_context_switch)
ENTRY(sa11x0_drain_readbuf)
mcr p15, 0, r0, c9, c0, 0 /* drain read buffer */
RET
+END(sa11x0_drain_readbuf)
+
diff --git a/sys/arm/arm/cpufunc_asm_sheeva.S b/sys/arm/arm/cpufunc_asm_sheeva.S
index d185547..796f63e 100644
--- a/sys/arm/arm/cpufunc_asm_sheeva.S
+++ b/sys/arm/arm/cpufunc_asm_sheeva.S
@@ -62,6 +62,7 @@ ENTRY(sheeva_setttb)
mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */
RET
+END(sheeva_setttb)
ENTRY(sheeva_dcache_wbinv_range)
str lr, [sp, #-4]!
@@ -104,6 +105,7 @@ ENTRY(sheeva_dcache_wbinv_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_dcache_wbinv_range)
ENTRY(sheeva_idcache_wbinv_range)
str lr, [sp, #-4]!
@@ -155,6 +157,7 @@ ENTRY(sheeva_idcache_wbinv_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_idcache_wbinv_range)
ENTRY(sheeva_dcache_inv_range)
str lr, [sp, #-4]!
@@ -197,6 +200,7 @@ ENTRY(sheeva_dcache_inv_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_dcache_inv_range)
ENTRY(sheeva_dcache_wb_range)
str lr, [sp, #-4]!
@@ -239,6 +243,7 @@ ENTRY(sheeva_dcache_wb_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_dcache_wb_range)
ENTRY(sheeva_l2cache_wbinv_range)
str lr, [sp, #-4]!
@@ -283,6 +288,7 @@ ENTRY(sheeva_l2cache_wbinv_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_l2cache_wbinv_range)
ENTRY(sheeva_l2cache_inv_range)
str lr, [sp, #-4]!
@@ -325,6 +331,7 @@ ENTRY(sheeva_l2cache_inv_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_l2cache_inv_range)
ENTRY(sheeva_l2cache_wb_range)
str lr, [sp, #-4]!
@@ -367,6 +374,7 @@ ENTRY(sheeva_l2cache_wb_range)
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
ldr lr, [sp], #4
RET
+END(sheeva_l2cache_wb_range)
ENTRY(sheeva_l2cache_wbinv_all)
mov r0, #0
@@ -374,6 +382,7 @@ ENTRY(sheeva_l2cache_wbinv_all)
mcr p15, 1, r0, c15, c11, 0 /* Invalidate L2 */
mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */
RET
+END(sheeva_l2cache_wbinv_all)
/* This function modifies register value as follows:
*
@@ -392,10 +401,12 @@ ENTRY(sheeva_control_ext)
mcrne p15, 1, r2, c15, c1, 0 /* Write new control register */
mov r0, r3 /* Return old value */
RET
+END(sheeva_control_ext)
ENTRY(sheeva_cpu_sleep)
mov r0, #0
mcr p15, 0, r0, c7, c10, 4 /* Drain write buffer */
mcr p15, 0, r0, c7, c0, 4 /* Wait for interrupt */
mov pc, lr
+END(sheeva_cpu_sleep)
diff --git a/sys/arm/arm/cpufunc_asm_xscale.S b/sys/arm/arm/cpufunc_asm_xscale.S
index 3601b9a..56008dc 100644
--- a/sys/arm/arm/cpufunc_asm_xscale.S
+++ b/sys/arm/arm/cpufunc_asm_xscale.S
@@ -106,6 +106,7 @@ __FBSDID("$FreeBSD$");
ENTRY(xscale_cpwait)
CPWAIT_AND_RETURN(r0)
+END(xscale_cpwait)
/*
* We need a separate cpu_control() entry point, since we have to
@@ -123,6 +124,7 @@ ENTRY(xscale_control)
mov r0, r3 /* Return old value */
CPWAIT_AND_RETURN(r1)
+END(xscale_control)
/*
* Functions to set the MMU Translation Table Base register
@@ -167,6 +169,7 @@ ENTRY(xscale_setttb)
str r2, [r3]
#endif
RET
+END(xscale_setttb)
/*
* TLB functions
@@ -176,6 +179,7 @@ ENTRY(xscale_tlb_flushID_SE)
mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */
mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */
CPWAIT_AND_RETURN(r0)
+END(xscale_tlb_flushID_SE)
/*
* Cache functions
@@ -183,18 +187,22 @@ ENTRY(xscale_tlb_flushID_SE)
ENTRY(xscale_cache_flushID)
mcr p15, 0, r0, c7, c7, 0 /* flush I+D cache */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_flushID)
ENTRY(xscale_cache_flushI)
mcr p15, 0, r0, c7, c5, 0 /* flush I cache */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_flushI)
ENTRY(xscale_cache_flushD)
mcr p15, 0, r0, c7, c6, 0 /* flush D cache */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_flushD)
ENTRY(xscale_cache_flushI_SE)
mcr p15, 0, r0, c7, c5, 1 /* flush I cache single entry */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_flushI_SE)
ENTRY(xscale_cache_flushD_SE)
/*
@@ -205,10 +213,12 @@ ENTRY(xscale_cache_flushD_SE)
mcr p15, 0, r0, c7, c10, 1
mcr p15, 0, r0, c7, c6, 1 /* flush D cache single entry */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_flushD_SE)
ENTRY(xscale_cache_cleanD_E)
mcr p15, 0, r0, c7, c10, 1 /* clean D cache entry */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_cleanD_E)
/*
* Information for the XScale cache clean/purge functions:
@@ -316,6 +326,11 @@ ENTRY(xscale_cache_cleanD)
XSCALE_CACHE_CLEAN_EPILOGUE
RET
+END(xscale_cache_syncI)
+END(xscale_cache_purgeID)
+END(xscale_cache_cleanID)
+END(xscale_cache_purgeD)
+END(xscale_cache_cleanD)
/*
* Clean the mini-data cache.
@@ -335,6 +350,7 @@ ENTRY(xscale_cache_clean_minidata)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r1)
+END(xscale_cache_clean_minidata)
ENTRY(xscale_cache_purgeID_E)
mcr p15, 0, r0, c7, c10, 1 /* clean D cache entry */
@@ -343,6 +359,7 @@ ENTRY(xscale_cache_purgeID_E)
mcr p15, 0, r0, c7, c5, 1 /* flush I cache single entry */
mcr p15, 0, r0, c7, c6, 1 /* flush D cache single entry */
CPWAIT_AND_RETURN(r1)
+END(xscale_cache_purgeID_E)
ENTRY(xscale_cache_purgeD_E)
mcr p15, 0, r0, c7, c10, 1 /* clean D cache entry */
@@ -350,6 +367,7 @@ ENTRY(xscale_cache_purgeD_E)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
mcr p15, 0, r0, c7, c6, 1 /* flush D cache single entry */
CPWAIT_AND_RETURN(r1)
+END(xscale_cache_purgeD_E)
/*
* Soft functions
@@ -375,6 +393,8 @@ ENTRY(xscale_cache_cleanD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_cleanID_rng)
+END(xscale_cache_cleanD_rng)
ENTRY(xscale_cache_purgeID_rng)
cmp r1, #0x4000
@@ -396,6 +416,7 @@ ENTRY(xscale_cache_purgeID_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_purgeID_rng)
ENTRY(xscale_cache_purgeD_rng)
cmp r1, #0x4000
@@ -416,6 +437,7 @@ ENTRY(xscale_cache_purgeD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_purgeD_rng)
ENTRY(xscale_cache_syncI_rng)
cmp r1, #0x4000
@@ -436,6 +458,7 @@ ENTRY(xscale_cache_syncI_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_syncI_rng)
ENTRY(xscale_cache_flushD_rng)
and r2, r0, #0x1f
@@ -450,6 +473,7 @@ ENTRY(xscale_cache_flushD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscale_cache_flushD_rng)
/*
* Context switch.
@@ -475,6 +499,7 @@ ENTRY(xscale_context_switch)
mcr p15, 0, r0, c8, c7, 0 /* flush the I+D tlb */
CPWAIT_AND_RETURN(r0)
+END(xscale_context_switch)
/*
* xscale_cpu_sleep
@@ -493,3 +518,5 @@ ENTRY(xscale_cpu_sleep)
1:
RET
+END(xscale_cpu_sleep)
+
diff --git a/sys/arm/arm/cpufunc_asm_xscale_c3.S b/sys/arm/arm/cpufunc_asm_xscale_c3.S
index 9a003d0..a0494d5 100644
--- a/sys/arm/arm/cpufunc_asm_xscale_c3.S
+++ b/sys/arm/arm/cpufunc_asm_xscale_c3.S
@@ -168,6 +168,11 @@ ENTRY(xscalec3_cache_cleanD)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
RET
+END(xscalec3_cache_syncI)
+END(xscalec3_cache_purgeID)
+END(xscalec3_cache_cleanID)
+END(xscalec3_cache_purgeD)
+END(xscalec3_cache_cleanD)
ENTRY(xscalec3_cache_purgeID_rng)
@@ -189,6 +194,7 @@ ENTRY(xscalec3_cache_purgeID_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscalec3_cache_purgeID_rng)
ENTRY(xscalec3_cache_syncI_rng)
cmp r1, #0x4000
@@ -209,6 +215,7 @@ ENTRY(xscalec3_cache_syncI_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscalec3_cache_syncI_rng)
ENTRY(xscalec3_cache_purgeD_rng)
@@ -228,6 +235,8 @@ ENTRY(xscalec3_cache_purgeD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
+END(xscalec3_cache_purgeD_rng)
+
ENTRY(xscalec3_cache_cleanID_rng)
ENTRY(xscalec3_cache_cleanD_rng)
@@ -248,7 +257,8 @@ ENTRY(xscalec3_cache_cleanD_rng)
mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */
CPWAIT_AND_RETURN(r0)
-
+END(xscalec3_cache_cleanID_rng)
+END(xscalec3_cache_cleanD_rng)
ENTRY(xscalec3_l2cache_purge)
/* Clean-up the L2 cache */
@@ -271,6 +281,7 @@ ENTRY(xscalec3_l2cache_purge)
CPWAIT(r0)
mcr p15, 0, r0, c7, c10, 5 /* Data memory barrier */
RET
+END(xscalec3_l2cache_purge)
ENTRY(xscalec3_l2cache_clean_rng)
mcr p15, 0, r0, c7, c10, 5 /* Data memory barrier */
@@ -291,6 +302,7 @@ ENTRY(xscalec3_l2cache_clean_rng)
mcr p15, 0, r0, c7, c10, 5
CPWAIT_AND_RETURN(r0)
+END(xscalec3_l2cache_clean_rng)
ENTRY(xscalec3_l2cache_purge_rng)
@@ -310,6 +322,7 @@ ENTRY(xscalec3_l2cache_purge_rng)
mcr p15, 0, r0, c7, c10, 5
CPWAIT_AND_RETURN(r0)
+END(xscalec3_l2cache_purge_rng)
ENTRY(xscalec3_l2cache_flush_rng)
mcr p15, 0, r0, c7, c10, 5 /* Data memory barrier */
@@ -325,6 +338,8 @@ ENTRY(xscalec3_l2cache_flush_rng)
mcr p15, 0, r0, c7, c10, 4 @ data write barrier
mcr p15, 0, r0, c7, c10, 5
CPWAIT_AND_RETURN(r0)
+END(xscalec3_l2cache_flush_rng)
+
/*
* Functions to set the MMU Translation Table Base register
*
@@ -368,6 +383,7 @@ ENTRY(xscalec3_setttb)
str r2, [r3]
#endif
RET
+END(xscalec3_setttb)
/*
* Context switch.
@@ -395,3 +411,5 @@ ENTRY(xscalec3_context_switch)
mcr p15, 0, r0, c8, c7, 0 /* flush the I+D tlb */
CPWAIT_AND_RETURN(r0)
+END(xscalec3_context_switch)
+
diff --git a/sys/arm/arm/db_trace.c b/sys/arm/arm/db_trace.c
index f921cfd..90ac0b1 100644
--- a/sys/arm/arm/db_trace.c
+++ b/sys/arm/arm/db_trace.c
@@ -126,29 +126,6 @@ struct unwind_state {
uint16_t update_mask;
};
-/* We need to provide these but never use them */
-void __aeabi_unwind_cpp_pr0(void);
-void __aeabi_unwind_cpp_pr1(void);
-void __aeabi_unwind_cpp_pr2(void);
-
-void
-__aeabi_unwind_cpp_pr0(void)
-{
- panic("__aeabi_unwind_cpp_pr0");
-}
-
-void
-__aeabi_unwind_cpp_pr1(void)
-{
- panic("__aeabi_unwind_cpp_pr1");
-}
-
-void
-__aeabi_unwind_cpp_pr2(void)
-{
- panic("__aeabi_unwind_cpp_pr2");
-}
-
/* Expand a 31-bit signed value to a 32-bit signed value */
static __inline int32_t
db_expand_prel31(uint32_t prel31)
diff --git a/sys/arm/arm/elf_trampoline.c b/sys/arm/arm/elf_trampoline.c
index 31e8bc5..fe03adf 100644
--- a/sys/arm/arm/elf_trampoline.c
+++ b/sys/arm/arm/elf_trampoline.c
@@ -701,3 +701,18 @@ __start(void)
do_call(dst, kernel, dst + (unsigned int)(&func_end) -
(unsigned int)(&load_kernel) + 800, sp);
}
+
+#ifdef __ARM_EABI__
+/* We need to provide these functions but never call them */
+void __aeabi_unwind_cpp_pr0(void);
+void __aeabi_unwind_cpp_pr1(void);
+void __aeabi_unwind_cpp_pr2(void);
+
+__strong_reference(__aeabi_unwind_cpp_pr0, __aeabi_unwind_cpp_pr1);
+__strong_reference(__aeabi_unwind_cpp_pr0, __aeabi_unwind_cpp_pr2);
+void
+__aeabi_unwind_cpp_pr0(void)
+{
+}
+#endif
+
diff --git a/sys/arm/arm/exception.S b/sys/arm/arm/exception.S
index b2ce47b..2ff0840 100644
--- a/sys/arm/arm/exception.S
+++ b/sys/arm/arm/exception.S
@@ -70,6 +70,7 @@ ASENTRY_NP(reset_entry)
Lreset_panicmsg:
.asciz "Reset vector called, LR = 0x%08x"
.balign 4
+END(reset_entry)
/*
* swi_entry
@@ -77,8 +78,7 @@ Lreset_panicmsg:
* Handler for the Software Interrupt exception.
*/
ASENTRY_NP(swi_entry)
- .fnstart
- .cantunwind /* Don't unwind past here */
+ STOP_UNWINDING /* Don't unwind past here */
PUSHFRAME
@@ -91,7 +91,7 @@ ASENTRY_NP(swi_entry)
DO_AST
PULLFRAME
movs pc, lr /* Exit */
- .fnend
+END(swi_entry)
/*
* prefetch_abort_entry:
@@ -128,6 +128,7 @@ abortprefetch:
abortprefetchmsg:
.asciz "abortprefetch"
.align 0
+END(prefetch_abort_entry)
/*
* data_abort_entry:
@@ -163,6 +164,7 @@ abortdata:
abortdatamsg:
.asciz "abortdata"
.align 0
+END(data_abort_entry)
/*
* address_exception_entry:
@@ -183,6 +185,7 @@ ASENTRY_NP(address_exception_entry)
Laddress_exception_msg:
.asciz "Address Exception CPSR=0x%08x SPSR=0x%08x LR=0x%08x\n"
.balign 4
+END(address_exception_entry)
/*
* General exception exit handler
@@ -224,6 +227,7 @@ ASENTRY_NP(undefined_entry)
Lundefined_handler_indirection:
.word Lundefined_handler_indirection_data
+END(undefined_entry)
/*
* assembly bounce code for calling the kernel
@@ -254,3 +258,4 @@ Lundefined_handler_indirection_data:
.global _C_LABEL(undefined_handler_address)
_C_LABEL(undefined_handler_address):
.word _C_LABEL(undefinedinstruction_bounce)
+END(undefinedinstruction_bounce)
diff --git a/sys/arm/arm/fiq_subr.S b/sys/arm/arm/fiq_subr.S
index 4cde665..7f510b2 100644
--- a/sys/arm/arm/fiq_subr.S
+++ b/sys/arm/arm/fiq_subr.S
@@ -74,6 +74,7 @@ ENTRY(fiq_getregs)
BACK_TO_SVC_MODE
RET
+END(fiq_getregs)
/*
* fiq_setregs:
@@ -88,6 +89,7 @@ ENTRY(fiq_setregs)
BACK_TO_SVC_MODE
RET
+END(fiq_setregs)
/*
* fiq_nullhandler:
diff --git a/sys/arm/arm/fusu.S b/sys/arm/arm/fusu.S
index edf1a63..443ca21 100644
--- a/sys/arm/arm/fusu.S
+++ b/sys/arm/arm/fusu.S
@@ -76,6 +76,8 @@ ENTRY(casuword)
mov r1, #0x00000000
str r1, [r3, #PCB_ONFAULT]
RET
+END(casuword32)
+END(casuword)
/*
* Handle faults from casuword. Clean up and return -1.
@@ -87,6 +89,7 @@ ENTRY(casuword)
mvn r0, #0x00000000
ldmfd sp!, {r4, r5}
RET
+
/*
* fuword(caddr_t uaddr);
* Fetch an int from the user's address space.
@@ -111,6 +114,8 @@ ENTRY(fuword)
str r1, [r2, #PCB_ONFAULT]
mov r0, r3
RET
+END(fuword32)
+END(fuword)
/*
* fusword(caddr_t uaddr);
@@ -139,6 +144,7 @@ ENTRY(fusword)
mov r1, #0x00000000
str r1, [r2, #PCB_ONFAULT]
RET
+END(fusword)
/*
* fuswintr(caddr_t uaddr);
@@ -175,6 +181,7 @@ ENTRY(fuswintr)
mov r1, #0x00000000
str r1, [r2, #PCB_ONFAULT]
RET
+END(fuswintr)
Lblock_userspace_access:
.word _C_LABEL(block_userspace_access)
@@ -209,6 +216,7 @@ ENTRY(fubyte)
str r1, [r2, #PCB_ONFAULT]
mov r0, r3
RET
+END(fubyte)
/*
* Handle faults from [fs]u*(). Clean up and return -1.
@@ -272,6 +280,8 @@ ENTRY(suword)
mov r0, #0x00000000
str r0, [r2, #PCB_ONFAULT]
RET
+END(suword32)
+END(suword)
/*
* suswintr(caddr_t uaddr, short x);
@@ -309,6 +319,7 @@ ENTRY(suswintr)
mov r0, #0x00000000
str r0, [r2, #PCB_ONFAULT]
RET
+END(suswintr)
/*
* susword(caddr_t uaddr, short x);
@@ -339,6 +350,7 @@ ENTRY(susword)
mov r0, #0x00000000
str r0, [r2, #PCB_ONFAULT]
RET
+END(susword)
/*
* subyte(caddr_t uaddr, char x);
@@ -362,3 +374,5 @@ ENTRY(subyte)
mov r0, #0x00000000
str r0, [r2, #PCB_ONFAULT]
RET
+END(subyte)
+
diff --git a/sys/arm/arm/in_cksum_arm.S b/sys/arm/arm/in_cksum_arm.S
index 3646c64..6305caf 100644
--- a/sys/arm/arm/in_cksum_arm.S
+++ b/sys/arm/arm/in_cksum_arm.S
@@ -90,13 +90,15 @@ ENTRY(in_cksum)
and r0, r0, r1
eor r0, r0, r1
ldmfd sp!, {r4-r11,pc}
-
+END(in_cksum)
ENTRY(do_cksum)
stmfd sp!, {r4-r7, lr}
bl L_cksumdata
mov r0, r2
ldmfd sp!, {r4-r7, pc}
+END(do_cksum)
+
/*
* The main in*_cksum() workhorse...
*
@@ -337,3 +339,5 @@ ASENTRY_NP(L_cksumdata)
adds r2, r2, r3
adc r2, r2, #0x00
RET
+END(L_cksumdata)
+
diff --git a/sys/arm/arm/irq_dispatch.S b/sys/arm/arm/irq_dispatch.S
index 6e510dd..823091d 100644
--- a/sys/arm/arm/irq_dispatch.S
+++ b/sys/arm/arm/irq_dispatch.S
@@ -97,6 +97,7 @@ ASENTRY_NP(irq_entry)
DO_AST
PULLFRAMEFROMSVCANDEXIT
movs pc, lr /* Exit */
+END(irq_entry)
.data
.align 0
diff --git a/sys/arm/arm/locore.S b/sys/arm/arm/locore.S
index 37e88fe..51fd5c1 100644
--- a/sys/arm/arm/locore.S
+++ b/sys/arm/arm/locore.S
@@ -242,6 +242,9 @@ Lstartup_pagetable:
Lstartup_pagetable_secondary:
.word temp_pagetable
#endif
+END(btext)
+END(_start)
+
mmu_init_table:
/* fill all table VA==PA */
/* map SDRAM VA==PA, WT cacheable */
@@ -324,6 +327,7 @@ ASENTRY_NP(mptramp)
Lpmureg:
.word 0xd0022124
+END(mptramp)
ASENTRY_NP(mpentry)
@@ -408,6 +412,7 @@ mpvirt_done:
.Lmpreturned:
.asciz "main() returned"
.align 0
+END(mpentry)
#endif
ENTRY_NP(cpu_halt)
@@ -461,6 +466,7 @@ ENTRY_NP(cpu_halt)
*/
.Lcpu_reset_needs_v4_MMU_disable:
.word _C_LABEL(cpu_reset_needs_v4_MMU_disable)
+END(cpu_halt)
/*
@@ -470,11 +476,13 @@ ENTRY(setjmp)
stmia r0, {r4-r14}
mov r0, #0x00000000
RET
+END(setjmp)
ENTRY(longjmp)
ldmia r0, {r4-r14}
mov r0, #0x00000001
RET
+END(longjmp)
.data
.global _C_LABEL(esym)
@@ -482,6 +490,7 @@ _C_LABEL(esym): .word _C_LABEL(end)
ENTRY_NP(abort)
b _C_LABEL(abort)
+END(abort)
ENTRY_NP(sigcode)
mov r0, sp
@@ -517,4 +526,5 @@ ENTRY_NP(sigcode)
.global szsigcode
szsigcode:
.long esigcode-sigcode
+END(sigcode)
/* End of locore.S */
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 2affa3e..0083f29 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -3313,6 +3313,45 @@ pmap_copy_page_generic(vm_paddr_t src, vm_paddr_t dst)
}
void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ vm_page_t a_pg, b_pg;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ mtx_lock(&cmtx);
+ while (xfersize > 0) {
+ a_pg = ma[a_offset >> PAGE_SHIFT];
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ b_pg = mb[b_offset >> PAGE_SHIFT];
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ *csrc_pte = L2_S_PROTO | VM_PAGE_TO_PHYS(a_pg) |
+ pte_l2_s_cache_mode;
+ pmap_set_prot(csrc_pte, VM_PROT_READ, 0);
+ PTE_SYNC(csrc_pte);
+ *cdst_pte = L2_S_PROTO | VM_PAGE_TO_PHYS(b_pg) |
+ pte_l2_s_cache_mode;
+ pmap_set_prot(cdst_pte, VM_PROT_READ | VM_PROT_WRITE, 0);
+ PTE_SYNC(cdst_pte);
+ cpu_tlb_flushD_SE(csrcp);
+ cpu_tlb_flushD_SE(cdstp);
+ cpu_cpwait();
+ bcopy((char *)csrcp + a_pg_offset, (char *)cdstp + b_pg_offset,
+ cnt);
+ cpu_idcache_wbinv_range(cdstp + b_pg_offset, cnt);
+ pmap_l2cache_wbinv_range(cdstp + b_pg_offset,
+ VM_PAGE_TO_PHYS(b_pg) + b_pg_offset, cnt);
+ xfersize -= cnt;
+ a_offset += cnt;
+ b_offset += cnt;
+ }
+ mtx_unlock(&cmtx);
+}
+
+void
pmap_copy_page(vm_page_t src, vm_page_t dst)
{
diff --git a/sys/arm/arm/pmap.c b/sys/arm/arm/pmap.c
index 7070cb2..c18783b 100644
--- a/sys/arm/arm/pmap.c
+++ b/sys/arm/arm/pmap.c
@@ -258,6 +258,9 @@ pt_entry_t pte_l1_c_proto;
pt_entry_t pte_l2_s_proto;
void (*pmap_copy_page_func)(vm_paddr_t, vm_paddr_t);
+void (*pmap_copy_page_offs_func)(vm_paddr_t a_phys,
+ vm_offset_t a_offs, vm_paddr_t b_phys, vm_offset_t b_offs,
+ int cnt);
void (*pmap_zero_page_func)(vm_paddr_t, int, int);
struct msgbuf *msgbufp = 0;
@@ -400,6 +403,13 @@ static vm_paddr_t pmap_kernel_l2ptp_phys;
static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0;
static struct rwlock pvh_global_lock;
+void pmap_copy_page_offs_generic(vm_paddr_t a_phys, vm_offset_t a_offs,
+ vm_paddr_t b_phys, vm_offset_t b_offs, int cnt);
+#if ARM_MMU_XSCALE == 1
+void pmap_copy_page_offs_xscale(vm_paddr_t a_phys, vm_offset_t a_offs,
+ vm_paddr_t b_phys, vm_offset_t b_offs, int cnt);
+#endif
+
/*
* This list exists for the benefit of pmap_map_chunk(). It keeps track
* of the kernel L2 tables during bootstrap, so that pmap_map_chunk() can
@@ -484,6 +494,7 @@ pmap_pte_init_generic(void)
pte_l2_s_proto = L2_S_PROTO_generic;
pmap_copy_page_func = pmap_copy_page_generic;
+ pmap_copy_page_offs_func = pmap_copy_page_offs_generic;
pmap_zero_page_func = pmap_zero_page_generic;
}
@@ -660,6 +671,7 @@ pmap_pte_init_xscale(void)
#ifdef CPU_XSCALE_CORE3
pmap_copy_page_func = pmap_copy_page_generic;
+ pmap_copy_page_offs_func = pmap_copy_page_offs_generic;
pmap_zero_page_func = pmap_zero_page_generic;
xscale_use_minidata = 0;
/* Make sure it is L2-cachable */
@@ -672,6 +684,7 @@ pmap_pte_init_xscale(void)
#else
pmap_copy_page_func = pmap_copy_page_xscale;
+ pmap_copy_page_offs_func = pmap_copy_page_offs_xscale;
pmap_zero_page_func = pmap_zero_page_xscale;
#endif
@@ -4300,6 +4313,29 @@ pmap_copy_page_generic(vm_paddr_t src, vm_paddr_t dst)
cpu_l2cache_inv_range(csrcp, PAGE_SIZE);
cpu_l2cache_wbinv_range(cdstp, PAGE_SIZE);
}
+
+void
+pmap_copy_page_offs_generic(vm_paddr_t a_phys, vm_offset_t a_offs,
+ vm_paddr_t b_phys, vm_offset_t b_offs, int cnt)
+{
+
+ mtx_lock(&cmtx);
+ *csrc_pte = L2_S_PROTO | a_phys |
+ L2_S_PROT(PTE_KERNEL, VM_PROT_READ) | pte_l2_s_cache_mode;
+ PTE_SYNC(csrc_pte);
+ *cdst_pte = L2_S_PROTO | b_phys |
+ L2_S_PROT(PTE_KERNEL, VM_PROT_WRITE) | pte_l2_s_cache_mode;
+ PTE_SYNC(cdst_pte);
+ cpu_tlb_flushD_SE(csrcp);
+ cpu_tlb_flushD_SE(cdstp);
+ cpu_cpwait();
+ bcopy((char *)csrcp + a_offs, (char *)cdstp + b_offs, cnt);
+ mtx_unlock(&cmtx);
+ cpu_dcache_inv_range(csrcp + a_offs, cnt);
+ cpu_dcache_wbinv_range(cdstp + b_offs, cnt);
+ cpu_l2cache_inv_range(csrcp + a_offs, cnt);
+ cpu_l2cache_wbinv_range(cdstp + b_offs, cnt);
+}
#endif /* (ARM_MMU_GENERIC + ARM_MMU_SA1) != 0 */
#if ARM_MMU_XSCALE == 1
@@ -4344,6 +4380,28 @@ pmap_copy_page_xscale(vm_paddr_t src, vm_paddr_t dst)
mtx_unlock(&cmtx);
xscale_cache_clean_minidata();
}
+
+void
+pmap_copy_page_offs_xscale(vm_paddr_t a_phys, vm_offset_t a_offs,
+ vm_paddr_t b_phys, vm_offset_t b_offs, int cnt)
+{
+
+ mtx_lock(&cmtx);
+ *csrc_pte = L2_S_PROTO | a_phys |
+ L2_S_PROT(PTE_KERNEL, VM_PROT_READ) |
+ L2_C | L2_XSCALE_T_TEX(TEX_XSCALE_X);
+ PTE_SYNC(csrc_pte);
+ *cdst_pte = L2_S_PROTO | b_phys |
+ L2_S_PROT(PTE_KERNEL, VM_PROT_WRITE) |
+ L2_C | L2_XSCALE_T_TEX(TEX_XSCALE_X);
+ PTE_SYNC(cdst_pte);
+ cpu_tlb_flushD_SE(csrcp);
+ cpu_tlb_flushD_SE(cdstp);
+ cpu_cpwait();
+ bcopy((char *)csrcp + a_offs, (char *)cdstp + b_offs, cnt);
+ mtx_unlock(&cmtx);
+ xscale_cache_clean_minidata();
+}
#endif /* ARM_MMU_XSCALE == 1 */
void
@@ -4370,8 +4428,41 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
#endif
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ vm_page_t a_pg, b_pg;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+#ifdef ARM_USE_SMALL_ALLOC
+ vm_offset_t a_va, b_va;
+#endif
-
+ cpu_dcache_wbinv_all();
+ cpu_l2cache_wbinv_all();
+ while (xfersize > 0) {
+ a_pg = ma[a_offset >> PAGE_SHIFT];
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ b_pg = mb[b_offset >> PAGE_SHIFT];
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+#ifdef ARM_USE_SMALL_ALLOC
+ a_va = arm_ptovirt(VM_PAGE_TO_PHYS(a_pg)) + a_pg_offset;
+ b_va = arm_ptovirt(VM_PAGE_TO_PHYS(b_pg)) + b_pg_offset;
+ bcopy((char *)a_va, (char *)b_va, cnt);
+ cpu_dcache_wbinv_range(b_va, cnt);
+ cpu_l2cache_wbinv_range(b_va, cnt);
+#else
+ pmap_copy_page_offs_func(VM_PAGE_TO_PHYS(a_pg), a_pg_offset,
+ VM_PAGE_TO_PHYS(b_pg), b_pg_offset, cnt);
+#endif
+ xfersize -= cnt;
+ a_offset += cnt;
+ b_offset += cnt;
+ }
+}
/*
* this routine returns true if a physical page resides
diff --git a/sys/arm/arm/setcpsr.S b/sys/arm/arm/setcpsr.S
index 4597d53..ac86ba3 100644
--- a/sys/arm/arm/setcpsr.S
+++ b/sys/arm/arm/setcpsr.S
@@ -66,6 +66,7 @@ ENTRY_NP(SetCPSR)
mov r0, r3 /* Return the old CPSR */
RET
+END(SetCPSR)
/* Gets the CPSR register
@@ -77,4 +78,5 @@ ENTRY_NP(GetCPSR)
mrs r0, cpsr /* Get the CPSR */
RET
+END(GetCPSR)
diff --git a/sys/arm/arm/support.S b/sys/arm/arm/support.S
index d4c6fb4..0c117a9 100644
--- a/sys/arm/arm/support.S
+++ b/sys/arm/arm/support.S
@@ -277,6 +277,8 @@ do_memset:
strgeb r3, [ip], #0x01 /* Set another byte */
strgtb r3, [ip] /* and a third */
RET /* Exit */
+END(bzero)
+END(memset)
ENTRY(bcmp)
mov ip, r0
@@ -386,6 +388,7 @@ ENTRY(bcmp)
RETne /* Return if mismatch on #4 */
sub r0, r3, r2 /* r0 = b1#5 - b2#5 */
RET
+END(bcmp)
ENTRY(bcopy)
/* switch the source and destination registers */
@@ -929,6 +932,8 @@ ENTRY(memmove)
.Lmemmove_bsrcul1l4:
add r1, r1, #1
b .Lmemmove_bl4
+END(bcopy)
+END(memmove)
#if !defined(_ARM_ARCH_5E)
ENTRY(memcpy)
@@ -1164,6 +1169,8 @@ ENTRY(memcpy)
.Lmemcpy_srcul3l4:
sub r1, r1, #1
b .Lmemcpy_l4
+END(memcpy)
+
#else
/* LINTSTUB: Func: void *memcpy(void *dst, const void *src, size_t len) */
ENTRY(memcpy)
@@ -2932,6 +2939,7 @@ ENTRY(memcpy)
strh r2, [r0, #0x09]
strb r1, [r0, #0x0b]
RET
+END(memcpy)
#endif /* _ARM_ARCH_5E */
#ifdef GPROF
diff --git a/sys/arm/arm/swtch.S b/sys/arm/arm/swtch.S
index 4257557..f10b8f9 100644
--- a/sys/arm/arm/swtch.S
+++ b/sys/arm/arm/swtch.S
@@ -213,6 +213,7 @@ ENTRY(cpu_throw)
add sp, sp, #4;
ldmfd sp!, {r4-r7, pc}
+END(cpu_throw)
ENTRY(cpu_switch)
stmfd sp!, {r4-r7, lr}
@@ -502,6 +503,8 @@ ENTRY(cpu_switch)
.Lswitch_panic_str:
.asciz "cpu_switch: sched_qs empty with non-zero sched_whichqs!\n"
#endif
+END(cpu_switch)
+
ENTRY(savectx)
stmfd sp!, {r4-r7, lr}
sub sp, sp, #4
@@ -534,6 +537,7 @@ ENTRY(savectx)
#endif /* ARM_VFP_SUPPORT */
add sp, sp, #4;
ldmfd sp!, {r4-r7, pc}
+END(savectx)
ENTRY(fork_trampoline)
mov r1, r5
@@ -551,3 +555,5 @@ ENTRY(fork_trampoline)
movs pc, lr /* Exit */
AST_LOCALS
+END(fork_trampoline)
+
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
index 3512954..f4a2de6 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
@@ -122,9 +122,7 @@ struct bcm_sdhci_softc {
int sc_dma_ch;
bus_dma_tag_t sc_dma_tag;
bus_dmamap_t sc_dma_map;
- void *sc_dma_buffer;
- vm_paddr_t sc_dma_buffer_phys;
- vm_paddr_t sc_sdhci_buffer_phys;;
+ vm_paddr_t sc_sdhci_buffer_phys;
};
static int bcm_sdhci_probe(device_t);
@@ -171,9 +169,6 @@ bcm_sdhci_attach(device_t dev)
phandle_t node;
pcell_t cell;
int default_freq;
- void *buffer;
- vm_paddr_t buffer_phys;
- void *va;
sc->sc_dev = dev;
sc->sc_req = NULL;
@@ -210,7 +205,7 @@ bcm_sdhci_attach(device_t dev)
goto fail;
}
- if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
+ if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
NULL, bcm_sdhci_intr, sc, &sc->sc_intrhand))
{
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
@@ -243,7 +238,7 @@ bcm_sdhci_attach(device_t dev)
bcm_dma_setup_intr(sc->sc_dma_ch, bcm_sdhci_dma_intr, sc);
- /* Allocate DMA buffers */
+ /* Allocate bus_dma resources. */
err = bus_dma_tag_create(bus_get_dma_tag(dev),
1, 0, BUS_SPACE_MAXADDR_32BIT,
BUS_SPACE_MAXADDR, NULL, NULL,
@@ -256,37 +251,14 @@ bcm_sdhci_attach(device_t dev)
goto fail;
}
- err = bus_dmamem_alloc(sc->sc_dma_tag, &buffer,
- BUS_DMA_WAITOK | BUS_DMA_COHERENT| BUS_DMA_ZERO,
- &sc->sc_dma_map);
-
- if (err) {
- device_printf(dev, "cannot allocate DMA memory\n");
- goto fail;
- }
-
- err = bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, buffer,
- BCM_SDHCI_BUFFER_SIZE, bcm_dmamap_cb, &buffer_phys,
- BUS_DMA_WAITOK);
+ err = bus_dmamap_create(sc->sc_dma_tag, 0, &sc->sc_dma_map);
if (err) {
- device_printf(dev, "cannot load DMA memory\n");
- goto fail;
- }
-
- /*
- * Sanity check: two least bits of address should be zero
- */
- if ((uintptr_t)buffer & 3) {
- device_printf(dev,
- "DMA address is not word-aligned\n");
+ device_printf(dev, "bus_dmamap_create failed\n");
goto fail;
}
- sc->sc_dma_buffer = buffer;
- sc->sc_dma_buffer_phys = buffer_phys;
- va = (void*)rman_get_start(sc->sc_mem_res);
- sc->sc_sdhci_buffer_phys =
- pmap_kextract((vm_offset_t)va) + SDHCI_BUFFER;
+ sc->sc_sdhci_buffer_phys = BUS_SPACE_PHYSADDR(sc->sc_mem_res,
+ SDHCI_BUFFER);
bus_generic_probe(dev);
bus_generic_attach(dev);
@@ -447,27 +419,23 @@ bcm_sdhci_dma_intr(int ch, void *arg)
struct bcm_sdhci_softc *sc = (struct bcm_sdhci_softc *)arg;
struct sdhci_slot *slot = &sc->sc_slot;
uint32_t reg, mask;
- void *buffer;
+ bus_addr_t pmem;
+ vm_paddr_t pdst, psrc;
size_t len;
- int left;
+ int left, sync_op;
mtx_lock(&slot->mtx);
- /* copy DMA buffer to VA if READ */
len = bcm_dma_length(sc->sc_dma_ch);
if (slot->curcmd->data->flags & MMC_DATA_READ) {
- bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map,
- BUS_DMASYNC_POSTREAD);
-
+ sync_op = BUS_DMASYNC_POSTREAD;
mask = SDHCI_INT_DATA_AVAIL;
- /* all dma data in single or contiguous page */
- buffer = (uint8_t*)(slot->curcmd->data->data) + slot->offset;
- memcpy(buffer, sc->sc_dma_buffer, len);
} else {
- bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map,
- BUS_DMASYNC_POSTWRITE);
+ sync_op = BUS_DMASYNC_POSTWRITE;
mask = SDHCI_INT_SPACE_AVAIL;
}
+ bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map, sync_op);
+ bus_dmamap_unload(sc->sc_dma_tag, sc->sc_dma_map);
slot->offset += len;
sc->sc_dma_inuse = 0;
@@ -501,27 +469,22 @@ bcm_sdhci_dma_intr(int ch, void *arg)
SDHCI_INT_STATUS, mask);
/* continue next DMA transfer */
+ bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map,
+ (uint8_t *)slot->curcmd->data->data +
+ slot->offset, left, bcm_dmamap_cb, &pmem, 0);
if (slot->curcmd->data->flags & MMC_DATA_READ) {
- bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map,
- BUS_DMASYNC_PREREAD);
-
- /* DMA start */
- if (bcm_dma_start(sc->sc_dma_ch,
- sc->sc_sdhci_buffer_phys,
- sc->sc_dma_buffer_phys, left) != 0)
- device_printf(sc->sc_dev, "failed DMA start\n");
+ psrc = sc->sc_sdhci_buffer_phys;
+ pdst = pmem;
+ sync_op = BUS_DMASYNC_PREREAD;
} else {
- buffer = (char*)slot->curcmd->data->data + slot->offset;
- memcpy(sc->sc_dma_buffer, buffer, left);
-
- bus_dmamap_sync(sc->sc_dma_tag,
- sc->sc_dma_map, BUS_DMASYNC_PREWRITE);
-
- /* DMA start */
- if (bcm_dma_start(sc->sc_dma_ch,
- sc->sc_dma_buffer_phys,
- sc->sc_sdhci_buffer_phys, left) != 0)
- device_printf(sc->sc_dev, "failed DMA start\n");
+ psrc = pmem;
+ pdst = sc->sc_sdhci_buffer_phys;
+ sync_op = BUS_DMASYNC_PREWRITE;
+ }
+ bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map, sync_op);
+ if (bcm_dma_start(sc->sc_dma_ch, psrc, pdst, left)) {
+ /* XXX stop xfer, other error recovery? */
+ device_printf(sc->sc_dev, "failed DMA start\n");
}
} else {
/* wait for next data by INT */
@@ -542,6 +505,7 @@ bcm_sdhci_read_dma(struct sdhci_slot *slot)
{
struct bcm_sdhci_softc *sc = device_get_softc(slot->bus);
size_t left;
+ bus_addr_t paddr;
if (sc->sc_dma_inuse) {
device_printf(sc->sc_dev, "DMA in use\n");
@@ -562,12 +526,16 @@ bcm_sdhci_read_dma(struct sdhci_slot *slot)
BCM_DMA_INC_ADDR,
(left & 0xf) ? BCM_DMA_32BIT : BCM_DMA_128BIT);
+ bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map,
+ (uint8_t *)slot->curcmd->data->data + slot->offset, left,
+ bcm_dmamap_cb, &paddr, 0);
+
bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map,
BUS_DMASYNC_PREREAD);
/* DMA start */
if (bcm_dma_start(sc->sc_dma_ch, sc->sc_sdhci_buffer_phys,
- sc->sc_dma_buffer_phys, left) != 0)
+ paddr, left) != 0)
device_printf(sc->sc_dev, "failed DMA start\n");
}
@@ -575,8 +543,8 @@ static void
bcm_sdhci_write_dma(struct sdhci_slot *slot)
{
struct bcm_sdhci_softc *sc = device_get_softc(slot->bus);
- char *buffer;
size_t left;
+ bus_addr_t paddr;
if (sc->sc_dma_inuse) {
device_printf(sc->sc_dev, "DMA in use\n");
@@ -591,8 +559,9 @@ bcm_sdhci_write_dma(struct sdhci_slot *slot)
KASSERT((left & 3) == 0,
("%s: len = %d, not word-aligned", __func__, left));
- buffer = (char*)slot->curcmd->data->data + slot->offset;
- memcpy(sc->sc_dma_buffer, buffer, left);
+ bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map,
+ (uint8_t *)slot->curcmd->data->data + slot->offset, left,
+ bcm_dmamap_cb, &paddr, 0);
bcm_dma_setup_src(sc->sc_dma_ch, BCM_DMA_DREQ_NONE,
BCM_DMA_INC_ADDR,
@@ -604,7 +573,7 @@ bcm_sdhci_write_dma(struct sdhci_slot *slot)
BUS_DMASYNC_PREWRITE);
/* DMA start */
- if (bcm_dma_start(sc->sc_dma_ch, sc->sc_dma_buffer_phys,
+ if (bcm_dma_start(sc->sc_dma_ch, paddr,
sc->sc_sdhci_buffer_phys, left) != 0)
device_printf(sc->sc_dev, "failed DMA start\n");
}
@@ -614,11 +583,16 @@ bcm_sdhci_will_handle_transfer(device_t dev, struct sdhci_slot *slot)
{
size_t left;
- /* Do not use DMA for transfers less then block size */
+ /*
+ * Do not use DMA for transfers less than block size or with a length
+ * that is not a multiple of four.
+ */
left = min(BCM_DMA_BLOCK_SIZE,
slot->curcmd->data->len - slot->offset);
if (left < BCM_DMA_BLOCK_SIZE)
return (0);
+ if (left & 0x03)
+ return (0);
return (1);
}
diff --git a/sys/arm/include/asm.h b/sys/arm/include/asm.h
index 3ae25b8..81f67a3 100644
--- a/sys/arm/include/asm.h
+++ b/sys/arm/include/asm.h
@@ -66,6 +66,16 @@
# define _ALIGN_TEXT .align 0
#endif
+#ifdef __ARM_EABI__
+#define STOP_UNWINDING .cantunwind
+#define _FNSTART .fnstart
+#define _FNEND .fnend
+#else
+#define STOP_UNWINDING
+#define _FNSTART
+#define _FNEND
+#endif
+
/*
* gas/arm uses @ as a single comment character and thus cannot be used here
* Instead it recognised the # instead of an @ symbols in .type directives
@@ -76,7 +86,9 @@
#define _ASM_TYPE_OBJECT #object
#define GLOBAL(X) .globl x
#define _ENTRY(x) \
- .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
+ .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: _FNSTART
+
+#define END(x) .size x, . - x; _FNEND
#ifdef GPROF
# define _PROF_PROLOGUE \
diff --git a/sys/arm/include/bus.h b/sys/arm/include/bus.h
index cabf1f7..ce8f5ad 100644
--- a/sys/arm/include/bus.h
+++ b/sys/arm/include/bus.h
@@ -725,4 +725,12 @@ bs_c_8_proto(f);
#include <machine/bus_dma.h>
+/*
+ * Get the physical address of a bus space memory-mapped resource.
+ * Doing this as a macro is a temporary solution until a more robust fix is
+ * designed. It also serves to mark the locations needing that fix.
+ */
+#define BUS_SPACE_PHYSADDR(res, offs) \
+ (vtophys(rman_get_start(res)+(offs)))
+
#endif /* _MACHINE_BUS_H_ */
diff --git a/sys/arm/include/pmap.h b/sys/arm/include/pmap.h
index 523499f..7c8d073 100644
--- a/sys/arm/include/pmap.h
+++ b/sys/arm/include/pmap.h
@@ -533,6 +533,8 @@ extern pt_entry_t pte_l1_c_proto;
extern pt_entry_t pte_l2_s_proto;
extern void (*pmap_copy_page_func)(vm_paddr_t, vm_paddr_t);
+extern void (*pmap_copy_page_offs_func)(vm_paddr_t a_phys,
+ vm_offset_t a_offs, vm_paddr_t b_phys, vm_offset_t b_offs, int cnt);
extern void (*pmap_zero_page_func)(vm_paddr_t, int, int);
#if (ARM_MMU_GENERIC + ARM_MMU_V6 + ARM_MMU_V7 + ARM_MMU_SA1) != 0 || defined(CPU_XSCALE_81342)
diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index 93702df..4b01a74 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -327,7 +327,7 @@ cpsw_debugf(const char *fmt, ...)
#define cpsw_cpdma_bd_offset(i) (CPSW_CPPI_RAM_OFFSET + ((i)*16))
#define cpsw_cpdma_bd_paddr(sc, slot) \
- (slot->bd_offset + vtophys(rman_get_start(sc->res[0])))
+ BUS_SPACE_PHYSADDR(sc->res[0], slot->bd_offset)
#define cpsw_cpdma_read_bd(sc, slot, val) \
bus_read_region_4(sc->res[0], slot->bd_offset, (uint32_t *) val, 4)
#define cpsw_cpdma_write_bd(sc, slot, val) \
diff --git a/sys/arm/ti/ti_mmchs.c b/sys/arm/ti/ti_mmchs.c
index cf9dc21..76ecc58 100644
--- a/sys/arm/ti/ti_mmchs.c
+++ b/sys/arm/ti/ti_mmchs.c
@@ -1584,7 +1584,6 @@ static int
ti_mmchs_activate(device_t dev)
{
struct ti_mmchs_softc *sc = device_get_softc(dev);
- unsigned long addr;
int rid;
int err;
@@ -1630,8 +1629,8 @@ ti_mmchs_activate(device_t dev)
panic("Unknown OMAP device\n");
/* Get the physical address of the MMC data register, needed for DMA */
- addr = vtophys(rman_get_start(sc->sc_mem_res));
- sc->sc_data_reg_paddr = addr + sc->sc_reg_off + MMCHS_DATA;
+ sc->sc_data_reg_paddr = BUS_SPACE_PHYSADDR(sc->sc_mem_res,
+ sc->sc_reg_off + MMCHS_DATA);
/* Set the initial power state to off */
sc->sc_cur_power_mode = power_off;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
index dc64682..a8916d2 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
@@ -271,7 +271,7 @@ uint64_t zfs_deadman_synctime = 1000ULL;
TUNABLE_QUAD("vfs.zfs.deadman_synctime", &zfs_deadman_synctime);
SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime, CTLFLAG_RDTUN,
&zfs_deadman_synctime, 0,
- "Stalled ZFS I/O expiration time in units of vfs.zfs.txg_synctime_ms");
+ "Stalled ZFS I/O expiration time in units of vfs.zfs.txg.synctime_ms");
/*
* Default value of -1 for zfs_deadman_enabled is resolved in
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index e094997..71b4b80 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -656,13 +656,9 @@ ndis_ptom(m0, p)
for (buf = priv->npp_head; buf != NULL; buf = buf->mdl_next) {
if (buf == priv->npp_head)
-#ifdef MT_HEADER
- MGETHDR(m, M_NOWAIT, MT_HEADER);
-#else
- MGETHDR(m, M_NOWAIT, MT_DATA);
-#endif
+ m = m_gethdr(M_NOWAIT, MT_DATA);
else
- MGET(m, M_NOWAIT, MT_DATA);
+ m = m_get(M_NOWAIT, MT_DATA);
if (m == NULL) {
m_freem(*m0);
*m0 = NULL;
diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm
index 8e3b82e..8348e2a 100644
--- a/sys/conf/Makefile.arm
+++ b/sys/conf/Makefile.arm
@@ -44,7 +44,9 @@ CFLAGS += -mno-thumb-interwork
.endif
.if empty(DDB_ENABLED)
+.if !defined(WITH_ARM_EABI) && ${COMPILER_TYPE} != "clang"
CFLAGS += -mno-apcs-frame
+.endif
.elif defined(WITH_ARM_EABI)
CFLAGS += -funwind-tables
.if ${COMPILER_TYPE} == "clang"
@@ -82,44 +84,43 @@ ${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h
sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
- ldscript.$M.tramp.noheader
+ ldscript.$M.tramp.noheader
echo "#include <machine/asm.h>" >tmphack.S
echo "ENTRY(_start)" >>tmphack.S
echo "bl _startC" >>tmphack.S
${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
- -g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
+ -g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
eval $$(stat -s ${KERNEL_KO}.tmp) && \
- echo "#define KERNSIZE $$st_size" >>opt_kernname.h
+ echo "#define KERNSIZE $$st_size" >>opt_kernname.h
${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
- tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
- ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp
+ tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
+ ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp
${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \
- ldscript.$M.tramp.noheader \
- tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
- ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
+ ldscript.$M.tramp.noheader \
+ tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
+ ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
- ${KERNEL_KO}.tramp.bin
+ ${KERNEL_KO}.tramp.bin
${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp
- echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" \
- >opt_kernname.h
+ echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" >opt_kernname.h
eval $$(stat -s ${KERNEL_KO}.tmp) && \
- echo "#define KERNSIZE $$st_size" >>opt_kernname.h
+ echo "#define KERNSIZE $$st_size" >>opt_kernname.h
gzip -f9 ${KERNEL_KO}.tmp
eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
- echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
+ echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
${CC} -O2 -ffreestanding -DKZIP -I. -I$S -c $S/kern/inflate.c -o \
inflate-tramp.o
${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
- -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
- $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
+ -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
+ $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \
- ldscript.$M.tramp.noheader \
- -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
- $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
+ ldscript.$M.tramp.noheader \
+ -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
+ $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
- ${KERNEL_KO}.gz.tramp.bin
+ ${KERNEL_KO}.gz.tramp.bin
rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
- inflate-tramp.o tmphack.S
+ inflate-tramp.o tmphack.S
MKMODULESENV+= MACHINE=${MACHINE}
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 27c3380..5a5000c 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -986,7 +986,7 @@ options DUMMYNET
# See zero_copy(9) for more details.
# XXX: The COW based send mechanism is not safe and may result in
# kernel crashes.
-# XXX: None of the current NIC drivers support disposeable pages.
+# XXX: None of the current NIC drivers support disposable pages.
options SOCKET_SEND_COW
options SOCKET_RECV_PFLIP
diff --git a/sys/conf/files b/sys/conf/files
index b0d772e..04e66a1 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -55,9 +55,9 @@ aic79xx_reg_print.o optional ahd pci ahd_reg_pretty_print \
# from the specified source (DTS) file: <platform>.dts -> <platform>.dtb
#
fdt_dtb_file optional fdt \
- compile-with "if [ -f $S/boot/fdt/dts/${FDT_DTS_FILE} ]; then dtc -O dtb -o `echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 -p 1024 $S/boot/fdt/dts/${FDT_DTS_FILE}; fi" \
+ compile-with "if [ -f $S/boot/fdt/dts/${FDT_DTS_FILE} ]; then dtc -O dtb -o ${FDT_DTS_FILE:R}.dtb -b 0 -p 1024 $S/boot/fdt/dts/${FDT_DTS_FILE}; fi" \
no-obj no-implicit-rule before-depend \
- clean "`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb"
+ clean "${FDT_DTS_FILE:R}.dtb"
fdt_static_dtb.h optional fdt fdt_dtb_static \
compile-with "sh $S/tools/fdt/make_dtbh.sh ${FDT_DTS_FILE} ." \
no-obj no-implicit-rule before-depend \
diff --git a/sys/conf/files.arm b/sys/conf/files.arm
index 33ec0fb..f9e0be8 100644
--- a/sys/conf/files.arm
+++ b/sys/conf/files.arm
@@ -72,11 +72,13 @@ font.h optional sc \
clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8"
kern/subr_busdma_bufalloc.c standard
kern/subr_dummy_vdso_tc.c standard
+libkern/arm/aeabi_unwind.c standard
libkern/arm/divsi3.S standard
libkern/arm/ffs.S standard
libkern/arm/ldivmod.S standard
libkern/arm/ldivmod_helper.c standard
libkern/arm/memcpy.S standard
+libkern/arm/memset.S standard
libkern/arm/muldi3.c standard
libkern/ashldi3.c standard
libkern/ashrdi3.c standard
diff --git a/sys/dev/acpica/acpi_powerres.c b/sys/dev/acpica/acpi_powerres.c
index ba08286..aa343a6 100644
--- a/sys/dev/acpica/acpi_powerres.c
+++ b/sys/dev/acpica/acpi_powerres.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
* resource, and only deactivate it when there are no powered devices.
*
* Note that this only manages resources for known devices. There is an
- * ugly case where we may turn of power to a device which is in use because
+ * ugly case where we may turn off power to a device which is in use because
* we don't know that it depends on a given resource. We should perhaps
* try to be smarter about this, but a more complete solution would involve
* scanning all of the ACPI namespace to find devices we're not currently
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 11ecd1a..7601f2f 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -3750,39 +3750,6 @@ ath_tx_update_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni,
}
/*
- * Update the busy status of the last frame on the free list.
- * When doing TDMA, the busy flag tracks whether the hardware
- * currently points to this buffer or not, and thus gated DMA
- * may restart by re-reading the last descriptor in this
- * buffer.
- *
- * This should be called in the completion function once one
- * of the buffers has been used.
- */
-static void
-ath_tx_update_busy(struct ath_softc *sc)
-{
- struct ath_buf *last;
-
- /*
- * Since the last frame may still be marked
- * as ATH_BUF_BUSY, unmark it here before
- * finishing the frame processing.
- * Since we've completed a frame (aggregate
- * or otherwise), the hardware has moved on
- * and is no longer referencing the previous
- * descriptor.
- */
- ATH_TXBUF_LOCK_ASSERT(sc);
- last = TAILQ_LAST(&sc->sc_txbuf_mgmt, ath_bufhead_s);
- if (last != NULL)
- last->bf_flags &= ~ATH_BUF_BUSY;
- last = TAILQ_LAST(&sc->sc_txbuf, ath_bufhead_s);
- if (last != NULL)
- last->bf_flags &= ~ATH_BUF_BUSY;
-}
-
-/*
* Process the completion of the given buffer.
*
* This calls the rate control update and then the buffer completion.
@@ -3901,7 +3868,6 @@ ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq, int dosched)
break;
}
ATH_TXQ_REMOVE(txq, bf, bf_list);
-#ifdef IEEE80211_SUPPORT_TDMA
if (txq->axq_depth > 0) {
/*
* More frames follow. Mark the buffer busy
@@ -3914,9 +3880,6 @@ ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq, int dosched)
*/
bf->bf_last->bf_flags |= ATH_BUF_BUSY;
} else
-#else
- if (txq->axq_depth == 0)
-#endif
txq->axq_link = NULL;
if (bf->bf_state.bfs_aggr)
txq->axq_aggr_depth--;
@@ -4188,6 +4151,50 @@ ath_returnbuf_head(struct ath_softc *sc, struct ath_buf *bf)
}
/*
+ * Free the holding buffer if it exists
+ */
+static void
+ath_txq_freeholdingbuf(struct ath_softc *sc, struct ath_txq *txq)
+{
+ ATH_TXBUF_LOCK_ASSERT(sc);
+
+ if (txq->axq_holdingbf == NULL)
+ return;
+
+ txq->axq_holdingbf->bf_flags &= ~ATH_BUF_BUSY;
+ ath_returnbuf_tail(sc, txq->axq_holdingbf);
+ txq->axq_holdingbf = NULL;
+}
+
+/*
+ * Add this buffer to the holding queue, freeing the previous
+ * one if it exists.
+ */
+static void
+ath_txq_addholdingbuf(struct ath_softc *sc, struct ath_buf *bf)
+{
+ struct ath_txq *txq;
+
+ ATH_TXBUF_LOCK_ASSERT(sc);
+
+ /* XXX assert ATH_BUF_BUSY is set */
+
+ /* XXX assert the tx queue is under the max number */
+ if (bf->bf_state.bfs_tx_queue > HAL_NUM_TX_QUEUES) {
+ device_printf(sc->sc_dev, "%s: bf=%p: invalid tx queue (%d)\n",
+ __func__,
+ bf,
+ bf->bf_state.bfs_tx_queue);
+ bf->bf_flags &= ~ATH_BUF_BUSY;
+ ath_returnbuf_tail(sc, bf);
+ return;
+ }
+ txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue];
+ ath_txq_freeholdingbuf(sc, txq);
+ txq->axq_holdingbf = bf;
+}
+
+/*
* Return a buffer to the pool and update the 'busy' flag on the
* previous 'tail' entry.
*
@@ -4207,8 +4214,20 @@ ath_freebuf(struct ath_softc *sc, struct ath_buf *bf)
KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__));
KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__));
+ /*
+ * If this buffer is busy, push it onto the holding queue
+ */
+ if (bf->bf_flags & ATH_BUF_BUSY) {
+ ATH_TXBUF_LOCK(sc);
+ ath_txq_addholdingbuf(sc, bf);
+ ATH_TXBUF_UNLOCK(sc);
+ return;
+ }
+
+ /*
+ * Not a busy buffer, so free normally
+ */
ATH_TXBUF_LOCK(sc);
- ath_tx_update_busy(sc);
ath_returnbuf_tail(sc, bf);
ATH_TXBUF_UNLOCK(sc);
}
@@ -4261,15 +4280,6 @@ ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq)
* NB: this assumes output has been stopped and
* we do not need to block ath_tx_proc
*/
- ATH_TXBUF_LOCK(sc);
- bf = TAILQ_LAST(&sc->sc_txbuf, ath_bufhead_s);
- if (bf != NULL)
- bf->bf_flags &= ~ATH_BUF_BUSY;
- bf = TAILQ_LAST(&sc->sc_txbuf_mgmt, ath_bufhead_s);
- if (bf != NULL)
- bf->bf_flags &= ~ATH_BUF_BUSY;
- ATH_TXBUF_UNLOCK(sc);
-
for (ix = 0;; ix++) {
ATH_TX_LOCK(sc);
bf = TAILQ_FIRST(&txq->axq_q);
@@ -4331,6 +4341,13 @@ ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq)
}
/*
+ * Free the holding buffer if it exists
+ */
+ ATH_TXBUF_LOCK(sc);
+ ath_txq_freeholdingbuf(sc, txq);
+ ATH_TXBUF_UNLOCK(sc);
+
+ /*
* Drain software queued frames which are on
* active TIDs.
*/
diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c
index bbd1fe8..f1c794e 100644
--- a/sys/dev/ath/if_ath_sysctl.c
+++ b/sys/dev/ath/if_ath_sysctl.c
@@ -361,11 +361,13 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS)
for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
if (ATH_TXQ_SETUP(sc, i)) {
- printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d, axq_fifo_depth=%d\n",
+ printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d, "
+ "axq_fifo_depth=%d, holdingbf=%p\n",
i,
sc->sc_txq[i].axq_depth,
sc->sc_txq[i].axq_aggr_depth,
- sc->sc_txq[i].axq_fifo_depth);
+ sc->sc_txq[i].axq_fifo_depth,
+ sc->sc_txq[i].axq_holdingbf);
}
}
diff --git a/sys/dev/ath/if_ath_tx.c b/sys/dev/ath/if_ath_tx.c
index 33318ea..c7b0fc1 100644
--- a/sys/dev/ath/if_ath_tx.c
+++ b/sys/dev/ath/if_ath_tx.c
@@ -3757,7 +3757,6 @@ ath_tx_tid_cleanup(struct ath_softc *sc, struct ath_node *an, int tid)
if (bf->bf_state.bfs_isretried) {
bf_next = TAILQ_NEXT(bf, bf_list);
ATH_TID_REMOVE(atid, bf, bf_list);
- atid->axq_depth--;
if (bf->bf_state.bfs_dobaw) {
ath_tx_update_baw(sc, an, atid, bf);
if (! bf->bf_state.bfs_addedbaw)
@@ -4140,11 +4139,10 @@ ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf_first)
int tid = bf_first->bf_state.bfs_tid;
struct ath_tid *atid = &an->an_tid[tid];
- bf = bf_first;
-
ATH_TX_LOCK(sc);
/* update incomp */
+ bf = bf_first;
while (bf) {
atid->incomp--;
bf = bf->bf_next;
@@ -4160,12 +4158,17 @@ ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf_first)
/* Send BAR if required */
/* XXX why would we send a BAR when transitioning to non-aggregation? */
+ /*
+ * XXX TODO: we should likely just tear down the BAR state here,
+ * rather than sending a BAR.
+ */
if (ath_tx_tid_bar_tx_ready(sc, atid))
ath_tx_tid_bar_tx(sc, atid);
ATH_TX_UNLOCK(sc);
/* Handle frame completion */
+ bf = bf_first;
while (bf) {
bf_next = bf->bf_next;
ath_tx_default_comp(sc, bf, 1);
@@ -4176,8 +4179,6 @@ ath_tx_comp_cleanup_aggr(struct ath_softc *sc, struct ath_buf *bf_first)
/*
* Handle completion of an set of aggregate frames.
*
- * XXX for now, simply complete each sub-frame.
- *
* Note: the completion handler is the last descriptor in the aggregate,
* not the last descriptor in the first frame.
*/
diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h
index 06cffb6..d3e4aa30 100644
--- a/sys/dev/ath/if_athvar.h
+++ b/sys/dev/ath/if_athvar.h
@@ -329,6 +329,16 @@ struct ath_txq {
u_int axq_intrcnt; /* interrupt count */
u_int32_t *axq_link; /* link ptr in last TX desc */
TAILQ_HEAD(axq_q_s, ath_buf) axq_q; /* transmit queue */
+ /*
+ * XXX the holdingbf field is protected by the TXBUF lock
+ * for now, NOT the TX lock.
+ *
+ * Architecturally, it would likely be better to move
+ * the holdingbf field to a separate array in ath_softc
+ * just to highlight that it's not protected by the normal
+ * TX path lock.
+ */
+ struct ath_buf *axq_holdingbf; /* holding TX buffer */
char axq_name[12]; /* e.g. "ath0_txq4" */
/* Per-TID traffic queue for software -> hardware TX */
diff --git a/sys/dev/puc/pucdata.c b/sys/dev/puc/pucdata.c
index 6d933e8..d82f031 100644
--- a/sys/dev/puc/pucdata.c
+++ b/sys/dev/puc/pucdata.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
static puc_config_f puc_config_amc;
static puc_config_f puc_config_diva;
static puc_config_f puc_config_exar;
+static puc_config_f puc_config_exar_pcie;
static puc_config_f puc_config_icbook;
static puc_config_f puc_config_moxa;
static puc_config_f puc_config_oxford_pcie;
@@ -630,6 +631,14 @@ const struct puc_cfg puc_pci_devices[] = {
PUC_PORT_8S, 0x10, 0, -1,
},
+ /* The XR17V358 uses the 125MHz PCIe clock as its reference clock. */
+ { 0x13a8, 0x0358, 0xffff, 0,
+ "Exar XR17V358",
+ 125000000,
+ PUC_PORT_8S, 0x10, 0, -1,
+ .config_function = puc_config_exar_pcie
+ },
+
{ 0x13fe, 0x1600, 0x1602, 0x0002,
"Advantech PCI-1602",
DEFAULT_RCLK * 8,
@@ -1186,6 +1195,17 @@ puc_config_exar(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
}
static int
+puc_config_exar_pcie(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
+ intptr_t *res)
+{
+ if (cmd == PUC_CFG_GET_OFS) {
+ *res = port * 0x400;
+ return (0);
+ }
+ return (ENXIO);
+}
+
+static int
puc_config_icbook(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
intptr_t *res)
{
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 7171065..c11eaa3 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -345,8 +345,12 @@ sndstat_prepare(struct sbuf *s)
struct snddev_info *d;
int i, j;
- sbuf_printf(s, "FreeBSD Audio Driver (newpcm: %ubit %d/%s)\n",
- (u_int)sizeof(intpcm32_t) << 3, SND_DRV_VERSION, MACHINE_ARCH);
+ if (snd_verbose > 0) {
+ sbuf_printf(s, "FreeBSD Audio Driver (%ubit %d/%s)\n",
+ (u_int)sizeof(intpcm32_t) << 3, SND_DRV_VERSION,
+ MACHINE_ARCH);
+ }
+
if (SLIST_EMPTY(&sndstat_devlist)) {
sbuf_printf(s, "No devices installed.\n");
sbuf_finish(s);
diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c
index 21ee0fc..47d4f75 100644
--- a/sys/fs/cd9660/cd9660_vnops.c
+++ b/sys/fs/cd9660/cd9660_vnops.c
@@ -329,7 +329,7 @@ cd9660_read(ap)
if (lblktosize(imp, rablock) < ip->i_size)
error = cluster_read(vp, (off_t)ip->i_size,
lbn, size, NOCRED, uio->uio_resid,
- (ap->a_ioflag >> 16), &bp);
+ (ap->a_ioflag >> 16), 0, &bp);
else
error = bread(vp, lbn, size, NOCRED, &bp);
} else {
diff --git a/sys/fs/ext2fs/ext2_balloc.c b/sys/fs/ext2fs/ext2_balloc.c
index 1c0cc0e..88ad710 100644
--- a/sys/fs/ext2fs/ext2_balloc.c
+++ b/sys/fs/ext2fs/ext2_balloc.c
@@ -276,7 +276,7 @@ ext2_balloc(struct inode *ip, int32_t lbn, int size, struct ucred *cred,
if (seqcount && (vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
error = cluster_read(vp, ip->i_size, lbn,
(int)fs->e2fs_bsize, NOCRED,
- MAXBSIZE, seqcount, &nbp);
+ MAXBSIZE, seqcount, 0, &nbp);
} else {
error = bread(vp, lbn, (int)fs->e2fs_bsize, NOCRED, &nbp);
}
diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c
index 1c0b7a1..77eb74b 100644
--- a/sys/fs/ext2fs/ext2_vnops.c
+++ b/sys/fs/ext2fs/ext2_vnops.c
@@ -1618,10 +1618,11 @@ ext2_read(struct vop_read_args *ap)
if (lblktosize(fs, nextlbn) >= ip->i_size)
error = bread(vp, lbn, size, NOCRED, &bp);
- else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0)
+ else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
error = cluster_read(vp, ip->i_size, lbn, size,
- NOCRED, blkoffset + uio->uio_resid, seqcount, &bp);
- else if (seqcount > 1) {
+ NOCRED, blkoffset + uio->uio_resid, seqcount,
+ 0, &bp);
+ } else if (seqcount > 1) {
int nextsize = blksize(fs, ip, nextlbn);
error = breadn(vp, lbn,
size, &nextlbn, &nextsize, 1, NOCRED, &bp);
@@ -1831,7 +1832,7 @@ ext2_write(struct vop_write_args *ap)
} else if (xfersize + blkoffset == fs->e2fs_fsize) {
if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
bp->b_flags |= B_CLUSTEROK;
- cluster_write(vp, bp, ip->i_size, seqcount);
+ cluster_write(vp, bp, ip->i_size, seqcount, 0);
} else {
bawrite(bp);
}
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 8e045cb..213ae81 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -600,7 +600,7 @@ msdosfs_read(ap)
error = bread(vp, lbn, blsize, NOCRED, &bp);
} else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
error = cluster_read(vp, dep->de_FileSize, lbn, blsize,
- NOCRED, on + uio->uio_resid, seqcount, &bp);
+ NOCRED, on + uio->uio_resid, seqcount, 0, &bp);
} else if (seqcount > 1) {
rasize = blsize;
error = breadn(vp, lbn,
@@ -820,7 +820,7 @@ msdosfs_write(ap)
else if (n + croffset == pmp->pm_bpcluster) {
if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0)
cluster_write(vp, bp, dep->de_FileSize,
- seqcount);
+ seqcount, 0);
else
bawrite(bp);
} else
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index 54c95ff..156fd43 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -1297,6 +1297,7 @@ tmpfs_rename(struct vop_rename_args *v)
cache_purge(fvp);
if (tvp != NULL)
cache_purge(tvp);
+ cache_purge_negative(tdvp);
error = 0;
diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c
index b1a3b1d..abe073e 100644
--- a/sys/fs/udf/udf_vnops.c
+++ b/sys/fs/udf/udf_vnops.c
@@ -478,8 +478,9 @@ udf_read(struct vop_read_args *ap)
rablock = lbn + 1;
if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
if (lblktosize(udfmp, rablock) < fsize) {
- error = cluster_read(vp, fsize, lbn, size, NOCRED,
- uio->uio_resid, (ap->a_ioflag >> 16), &bp);
+ error = cluster_read(vp, fsize, lbn, size,
+ NOCRED, uio->uio_resid,
+ (ap->a_ioflag >> 16), 0, &bp);
} else {
error = bread(vp, lbn, size, NOCRED, &bp);
}
diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c
index d1ddd40..c44993a 100644
--- a/sys/geom/gate/g_gate.c
+++ b/sys/geom/gate/g_gate.c
@@ -813,7 +813,7 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct threa
}
}
ggio->gctl_cmd = bp->bio_cmd;
- if ((bp->bio_cmd == BIO_DELETE || bp->bio_cmd == BIO_WRITE) &&
+ if (bp->bio_cmd == BIO_WRITE &&
bp->bio_length > ggio->gctl_length) {
mtx_unlock(&sc->sc_queue_mtx);
ggio->gctl_length = bp->bio_length;
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index ba63e21..6499986 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -4205,6 +4205,49 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
mtx_unlock(&sysmaps->lock);
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ struct sysmaps *sysmaps;
+ vm_page_t a_pg, b_pg;
+ char *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
+ mtx_lock(&sysmaps->lock);
+ if (*sysmaps->CMAP1 != 0)
+ panic("pmap_copy_pages: CMAP1 busy");
+ if (*sysmaps->CMAP2 != 0)
+ panic("pmap_copy_pages: CMAP2 busy");
+ sched_pin();
+ while (xfersize > 0) {
+ invlpg((u_int)sysmaps->CADDR1);
+ invlpg((u_int)sysmaps->CADDR2);
+ a_pg = ma[a_offset >> PAGE_SHIFT];
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ b_pg = mb[b_offset >> PAGE_SHIFT];
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ *sysmaps->CMAP1 = PG_V | VM_PAGE_TO_PHYS(a_pg) | PG_A |
+ pmap_cache_bits(b_pg->md.pat_mode, 0);
+ *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(b_pg) | PG_A |
+ PG_M | pmap_cache_bits(b_pg->md.pat_mode, 0);
+ a_cp = sysmaps->CADDR1 + a_pg_offset;
+ b_cp = sysmaps->CADDR2 + b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+ *sysmaps->CMAP1 = 0;
+ *sysmaps->CMAP2 = 0;
+ sched_unpin();
+ mtx_unlock(&sysmaps->lock);
+}
+
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c
index 3c7c3f5..0f7a80f 100644
--- a/sys/i386/xen/pmap.c
+++ b/sys/i386/xen/pmap.c
@@ -3448,6 +3448,46 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
mtx_unlock(&sysmaps->lock);
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ struct sysmaps *sysmaps;
+ vm_page_t a_pg, b_pg;
+ char *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
+ mtx_lock(&sysmaps->lock);
+ if (*sysmaps->CMAP1 != 0)
+ panic("pmap_copy_pages: CMAP1 busy");
+ if (*sysmaps->CMAP2 != 0)
+ panic("pmap_copy_pages: CMAP2 busy");
+ sched_pin();
+ while (xfersize > 0) {
+ a_pg = ma[a_offset >> PAGE_SHIFT];
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ b_pg = mb[b_offset >> PAGE_SHIFT];
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ PT_SET_MA(sysmaps->CADDR1, PG_V | VM_PAGE_TO_MACH(a_pg) | PG_A);
+ PT_SET_MA(sysmaps->CADDR2, PG_V | PG_RW |
+ VM_PAGE_TO_MACH(b_pg) | PG_A | PG_M);
+ a_cp = sysmaps->CADDR1 + a_pg_offset;
+ b_cp = sysmaps->CADDR2 + b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+ PT_SET_MA(sysmaps->CADDR1, 0);
+ PT_SET_MA(sysmaps->CADDR2, 0);
+ sched_unpin();
+ mtx_unlock(&sysmaps->lock);
+}
+
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c
index 1dff1f9..3256600 100644
--- a/sys/ia64/ia64/pmap.c
+++ b/sys/ia64/ia64/pmap.c
@@ -2014,6 +2014,30 @@ pmap_copy_page(vm_page_t msrc, vm_page_t mdst)
bcopy(src, dst, PAGE_SIZE);
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ void *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ a_cp = (char *)pmap_page_to_va(ma[a_offset >> PAGE_SHIFT]) +
+ a_pg_offset;
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ b_cp = (char *)pmap_page_to_va(mb[b_offset >> PAGE_SHIFT]) +
+ b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+}
+
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
diff --git a/sys/kern/capabilities.conf b/sys/kern/capabilities.conf
index 71c22bf..be01c9d 100644
--- a/sys/kern/capabilities.conf
+++ b/sys/kern/capabilities.conf
@@ -446,9 +446,9 @@ olio_listio
## Operations relative to directory capabilities.
##
faccessat
-fstatat
fchmodat
fchownat
+fstatat
futimesat
linkat
mkdirat
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index bf8141c..d31c832 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -1033,6 +1033,7 @@ racct_proc_throttle(struct proc *p)
p->p_throttled = 1;
FOREACH_THREAD_IN_PROC(p, td) {
+ thread_lock(td);
switch (td->td_state) {
case TDS_RUNQ:
/*
@@ -1041,27 +1042,24 @@ racct_proc_throttle(struct proc *p)
* TDF_NEEDRESCHED for the thread, so that once it is
* running, it is taken off the cpu as soon as possible.
*/
- thread_lock(td);
td->td_flags |= TDF_NEEDRESCHED;
- thread_unlock(td);
break;
case TDS_RUNNING:
/*
* If the thread is running, we request a context
* switch for it by setting the TDF_NEEDRESCHED flag.
*/
- thread_lock(td);
td->td_flags |= TDF_NEEDRESCHED;
#ifdef SMP
cpuid = td->td_oncpu;
if ((cpuid != NOCPU) && (td != curthread))
ipi_cpu(cpuid, IPI_AST);
#endif
- thread_unlock(td);
break;
default:
break;
}
+ thread_unlock(td);
}
}
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 1f24e88..11a4bc4 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -100,9 +100,6 @@ void
userret(struct thread *td, struct trapframe *frame)
{
struct proc *p = td->td_proc;
-#ifdef RACCT
- int sig;
-#endif
CTR3(KTR_SYSC, "userret: thread %p (pid %d, %s)", td, p->p_pid,
td->td_name);
@@ -175,12 +172,8 @@ userret(struct thread *td, struct trapframe *frame)
#endif
#ifdef RACCT
PROC_LOCK(p);
- while (p->p_throttled == 1) {
- sig = msleep(p->p_racct, &p->p_mtx, PCATCH | PBDRY, "racct",
- hz);
- if ((sig == EINTR) || (sig == ERESTART))
- break;
- }
+ while (p->p_throttled == 1)
+ msleep(p->p_racct, &p->p_mtx, 0, "racct", 0);
PROC_UNLOCK(p);
#endif
}
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index e962670..ea4fd80 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -92,7 +92,6 @@ m_get2(int size, int how, short type, int flags)
{
struct mb_args args;
struct mbuf *m, *n;
- uma_zone_t zone;
args.flags = flags;
args.type = type;
@@ -101,24 +100,15 @@ m_get2(int size, int how, short type, int flags)
return (uma_zalloc_arg(zone_mbuf, &args, how));
if (size <= MCLBYTES)
return (uma_zalloc_arg(zone_pack, &args, how));
- if (size > MJUM16BYTES)
+
+ if (size > MJUMPAGESIZE)
return (NULL);
m = uma_zalloc_arg(zone_mbuf, &args, how);
if (m == NULL)
return (NULL);
-#if MJUMPAGESIZE != MCLBYTES
- if (size <= MJUMPAGESIZE)
- zone = zone_jumbop;
- else
-#endif
- if (size <= MJUM9BYTES)
- zone = zone_jumbo9;
- else
- zone = zone_jumbo16;
-
- n = uma_zalloc_arg(zone, m, how);
+ n = uma_zalloc_arg(zone_jumbop, m, how);
if (n == NULL) {
uma_zfree(zone_mbuf, m);
return (NULL);
@@ -405,7 +395,7 @@ m_demote(struct mbuf *m0, int all)
m_freem(m->m_nextpkt);
m->m_nextpkt = NULL;
}
- m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_FREELIST|M_NOFREE);
+ m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_NOFREE);
}
}
@@ -540,8 +530,8 @@ m_dup_pkthdr(struct mbuf *to, struct mbuf *from, int how)
#if 0
/*
* The mbuf allocator only initializes the pkthdr
- * when the mbuf is allocated with MGETHDR. Many users
- * (e.g. m_copy*, m_prepend) use MGET and then
+ * when the mbuf is allocated with m_gethdr(). Many users
+ * (e.g. m_copy*, m_prepend) use m_get() and then
* smash the pkthdr as needed causing these
* assertions to trip. For now just disable them.
*/
@@ -573,15 +563,15 @@ m_prepend(struct mbuf *m, int len, int how)
struct mbuf *mn;
if (m->m_flags & M_PKTHDR)
- MGETHDR(mn, how, m->m_type);
+ mn = m_gethdr(how, m->m_type);
else
- MGET(mn, how, m->m_type);
+ mn = m_get(how, m->m_type);
if (mn == NULL) {
m_freem(m);
return (NULL);
}
if (m->m_flags & M_PKTHDR)
- M_MOVE_PKTHDR(mn, m);
+ m_move_pkthdr(mn, m);
mn->m_next = m;
m = mn;
if(m->m_flags & M_PKTHDR) {
@@ -631,9 +621,9 @@ m_copym(struct mbuf *m, int off0, int len, int wait)
break;
}
if (copyhdr)
- MGETHDR(n, wait, m->m_type);
+ n = m_gethdr(wait, m->m_type);
else
- MGET(n, wait, m->m_type);
+ n = m_get(wait, m->m_type);
*np = n;
if (n == NULL)
goto nospace;
@@ -832,7 +822,7 @@ m_copypacket(struct mbuf *m, int how)
struct mbuf *top, *n, *o;
MBUF_CHECKSLEEP(how);
- MGET(n, how, m->m_type);
+ n = m_get(how, m->m_type);
top = n;
if (n == NULL)
goto nospace;
@@ -850,7 +840,7 @@ m_copypacket(struct mbuf *m, int how)
m = m->m_next;
while (m) {
- MGET(o, how, m->m_type);
+ o = m_get(how, m->m_type);
if (o == NULL)
goto nospace;
@@ -1106,12 +1096,11 @@ m_pullup(struct mbuf *n, int len)
} else {
if (len > MHLEN)
goto bad;
- MGET(m, M_NOWAIT, n->m_type);
+ m = m_get(M_NOWAIT, n->m_type);
if (m == NULL)
goto bad;
- m->m_len = 0;
if (n->m_flags & M_PKTHDR)
- M_MOVE_PKTHDR(m, n);
+ m_move_pkthdr(m, n);
}
space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
do {
@@ -1154,12 +1143,11 @@ m_copyup(struct mbuf *n, int len, int dstoff)
if (len > (MHLEN - dstoff))
goto bad;
- MGET(m, M_NOWAIT, n->m_type);
+ m = m_get(M_NOWAIT, n->m_type);
if (m == NULL)
goto bad;
- m->m_len = 0;
if (n->m_flags & M_PKTHDR)
- M_MOVE_PKTHDR(m, n);
+ m_move_pkthdr(m, n);
m->m_data += dstoff;
space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
do {
@@ -1210,7 +1198,7 @@ m_split(struct mbuf *m0, int len0, int wait)
return (NULL);
remain = m->m_len - len;
if (m0->m_flags & M_PKTHDR) {
- MGETHDR(n, wait, m0->m_type);
+ n = m_gethdr(wait, m0->m_type);
if (n == NULL)
return (NULL);
n->m_pkthdr.rcvif = m0->m_pkthdr.rcvif;
@@ -1236,7 +1224,7 @@ m_split(struct mbuf *m0, int len0, int wait)
m->m_next = NULL;
return (n);
} else {
- MGET(n, wait, m->m_type);
+ n = m_get(wait, m->m_type);
if (n == NULL)
return (NULL);
M_ALIGN(n, remain);
@@ -1889,14 +1877,22 @@ m_mbuftouio(struct uio *uio, struct mbuf *m, int len)
void
m_align(struct mbuf *m, int len)
{
+#ifdef INVARIANTS
+ const char *msg = "%s: not a virgin mbuf";
+#endif
int adjust;
- if (m->m_flags & M_EXT)
+ if (m->m_flags & M_EXT) {
+ KASSERT(m->m_data == m->m_ext.ext_buf, (msg, __func__));
adjust = m->m_ext.ext_size - len;
- else if (m->m_flags & M_PKTHDR)
+ } else if (m->m_flags & M_PKTHDR) {
+ KASSERT(m->m_data == m->m_pktdat, (msg, __func__));
adjust = MHLEN - len;
- else
+ } else {
+ KASSERT(m->m_data == m->m_dat, (msg, __func__));
adjust = MLEN - len;
+ }
+
m->m_data += adjust &~ (sizeof(long)-1);
}
@@ -1978,43 +1974,18 @@ m_unshare(struct mbuf *m0, int how)
}
/*
- * Allocate new space to hold the copy...
- */
- /* XXX why can M_PKTHDR be set past the first mbuf? */
- if (mprev == NULL && (m->m_flags & M_PKTHDR)) {
- /*
- * NB: if a packet header is present we must
- * allocate the mbuf separately from any cluster
- * because M_MOVE_PKTHDR will smash the data
- * pointer and drop the M_EXT marker.
- */
- MGETHDR(n, how, m->m_type);
- if (n == NULL) {
- m_freem(m0);
- return (NULL);
- }
- M_MOVE_PKTHDR(n, m);
- MCLGET(n, how);
- if ((n->m_flags & M_EXT) == 0) {
- m_free(n);
- m_freem(m0);
- return (NULL);
- }
- } else {
- n = m_getcl(how, m->m_type, m->m_flags);
- if (n == NULL) {
- m_freem(m0);
- return (NULL);
- }
- }
- /*
- * ... and copy the data. We deal with jumbo mbufs
- * (i.e. m_len > MCLBYTES) by splitting them into
- * clusters. We could just malloc a buffer and make
- * it external but too many device drivers don't know
- * how to break up the non-contiguous memory when
+ * Allocate new space to hold the copy and copy the data.
+ * We deal with jumbo mbufs (i.e. m_len > MCLBYTES) by
+ * splitting them into clusters. We could just malloc a
+ * buffer and make it external but too many device drivers
+ * don't know how to break up the non-contiguous memory when
* doing DMA.
*/
+ n = m_getcl(how, m->m_type, m->m_flags);
+ if (n == NULL) {
+ m_freem(m0);
+ return (NULL);
+ }
len = m->m_len;
off = 0;
mfirst = n;
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 6325840..93c96bf 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -644,8 +644,8 @@ sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
if (asa->sa_len > MLEN)
return (0);
#endif
- MGET(m, M_NOWAIT, MT_SONAME);
- if (m == 0)
+ m = m_get(M_NOWAIT, MT_SONAME);
+ if (m == NULL)
return (0);
m->m_len = asa->sa_len;
bcopy(asa, mtod(m, caddr_t), asa->sa_len);
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 4827cab..3a2f032 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1701,18 +1701,16 @@ sockargs(mp, buf, buflen, type)
struct mbuf *m;
int error;
- if ((u_int)buflen > MLEN) {
+ if (buflen > MLEN) {
#ifdef COMPAT_OLDSOCK
- if (type == MT_SONAME && (u_int)buflen <= 112)
+ if (type == MT_SONAME && buflen <= 112)
buflen = MLEN; /* unix domain compat. hack */
else
#endif
- if ((u_int)buflen > MCLBYTES)
+ if (buflen > MCLBYTES)
return (EINVAL);
}
- m = m_get(M_WAITOK, type);
- if ((u_int)buflen > MLEN)
- MCLGET(m, M_WAITOK);
+ m = m_get2(buflen, M_WAITOK, type, 0);
m->m_len = buflen;
error = copyin(buf, mtod(m, caddr_t), (u_int)buflen);
if (error)
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 6d110ab..d20c829 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -830,9 +830,8 @@ breada(struct vnode * vp, daddr_t * rablkno, int * rabsize,
* getblk(). Also starts asynchronous I/O on read-ahead blocks.
*/
int
-breadn_flags(struct vnode * vp, daddr_t blkno, int size,
- daddr_t * rablkno, int *rabsize, int cnt,
- struct ucred * cred, int flags, struct buf **bpp)
+breadn_flags(struct vnode *vp, daddr_t blkno, int size, daddr_t *rablkno,
+ int *rabsize, int cnt, struct ucred *cred, int flags, struct buf **bpp)
{
struct buf *bp;
int rv = 0, readwait = 0;
@@ -1794,8 +1793,9 @@ vfs_bio_awrite(struct buf *bp)
*/
if (ncl != 1) {
BUF_UNLOCK(bp);
- nwritten = cluster_wbuild(vp, size, lblkno - j, ncl);
- return nwritten;
+ nwritten = cluster_wbuild(vp, size, lblkno - j, ncl,
+ 0);
+ return (nwritten);
}
}
bremfree(bp);
@@ -1808,7 +1808,7 @@ vfs_bio_awrite(struct buf *bp)
nwritten = bp->b_bufsize;
(void) bwrite(bp);
- return nwritten;
+ return (nwritten);
}
/*
@@ -2630,7 +2630,7 @@ vfs_setdirty_locked_object(struct buf *bp)
* prior to issuing the READ. biodone() will *not* clear B_INVAL.
*/
struct buf *
-getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo,
+getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo,
int flags)
{
struct buf *bp;
@@ -2708,9 +2708,8 @@ loop:
}
/*
- * check for size inconsistancies for non-VMIO case.
+ * check for size inconsistencies for non-VMIO case.
*/
-
if (bp->b_bcount != size) {
if ((bp->b_flags & B_VMIO) == 0 ||
(size > bp->b_kvasize)) {
@@ -3712,8 +3711,7 @@ vfs_bio_set_valid(struct buf *bp, int base, int size)
void
vfs_bio_clrbuf(struct buf *bp)
{
- int i, j, mask;
- caddr_t sa, ea;
+ int i, j, mask, sa, ea, slide;
if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) {
clrbuf(bp);
@@ -3731,30 +3729,33 @@ vfs_bio_clrbuf(struct buf *bp)
if ((bp->b_pages[0]->valid & mask) == mask)
goto unlock;
if ((bp->b_pages[0]->valid & mask) == 0) {
- bzero(bp->b_data, bp->b_bufsize);
+ pmap_zero_page_area(bp->b_pages[0], 0, bp->b_bufsize);
bp->b_pages[0]->valid |= mask;
goto unlock;
}
}
- ea = sa = bp->b_data;
- for(i = 0; i < bp->b_npages; i++, sa = ea) {
- ea = (caddr_t)trunc_page((vm_offset_t)sa + PAGE_SIZE);
- ea = (caddr_t)(vm_offset_t)ulmin(
- (u_long)(vm_offset_t)ea,
- (u_long)(vm_offset_t)bp->b_data + bp->b_bufsize);
+ sa = bp->b_offset & PAGE_MASK;
+ slide = 0;
+ for (i = 0; i < bp->b_npages; i++, sa = 0) {
+ slide = imin(slide + PAGE_SIZE, bp->b_offset + bp->b_bufsize);
+ ea = slide & PAGE_MASK;
+ if (ea == 0)
+ ea = PAGE_SIZE;
if (bp->b_pages[i] == bogus_page)
continue;
- j = ((vm_offset_t)sa & PAGE_MASK) / DEV_BSIZE;
+ j = sa / DEV_BSIZE;
mask = ((1 << ((ea - sa) / DEV_BSIZE)) - 1) << j;
VM_OBJECT_ASSERT_WLOCKED(bp->b_pages[i]->object);
if ((bp->b_pages[i]->valid & mask) == mask)
continue;
if ((bp->b_pages[i]->valid & mask) == 0)
- bzero(sa, ea - sa);
+ pmap_zero_page_area(bp->b_pages[i], sa, ea - sa);
else {
for (; sa < ea; sa += DEV_BSIZE, j++) {
- if ((bp->b_pages[i]->valid & (1 << j)) == 0)
- bzero(sa, DEV_BSIZE);
+ if ((bp->b_pages[i]->valid & (1 << j)) == 0) {
+ pmap_zero_page_area(bp->b_pages[i],
+ sa, DEV_BSIZE);
+ }
}
}
bp->b_pages[i]->valid |= mask;
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index 70937a2..28aa4ff 100644
--- a/sys/kern/vfs_cluster.c
+++ b/sys/kern/vfs_cluster.c
@@ -84,15 +84,9 @@ extern vm_page_t bogus_page;
* cluster_read replaces bread.
*/
int
-cluster_read(vp, filesize, lblkno, size, cred, totread, seqcount, bpp)
- struct vnode *vp;
- u_quad_t filesize;
- daddr_t lblkno;
- long size;
- struct ucred *cred;
- long totread;
- int seqcount;
- struct buf **bpp;
+cluster_read(struct vnode *vp, u_quad_t filesize, daddr_t lblkno, long size,
+ struct ucred *cred, long totread, int seqcount, int gbflags,
+ struct buf **bpp)
{
struct buf *bp, *rbp, *reqbp;
struct bufobj *bo;
@@ -569,14 +563,14 @@ cluster_wbuild_wb(struct vnode *vp, long size, daddr_t start_lbn, int len)
{
int r = 0;
- switch(write_behind) {
+ switch (write_behind) {
case 2:
if (start_lbn < len)
break;
start_lbn -= len;
/* FALLTHROUGH */
case 1:
- r = cluster_wbuild(vp, size, start_lbn, len);
+ r = cluster_wbuild(vp, size, start_lbn, len, 0);
/* FALLTHROUGH */
default:
/* FALLTHROUGH */
@@ -596,7 +590,8 @@ cluster_wbuild_wb(struct vnode *vp, long size, daddr_t start_lbn, int len)
* 4. end of a cluster - asynchronously write cluster
*/
void
-cluster_write(struct vnode *vp, struct buf *bp, u_quad_t filesize, int seqcount)
+cluster_write(struct vnode *vp, struct buf *bp, u_quad_t filesize, int seqcount,
+ int gbflags)
{
daddr_t lbn;
int maxclen, cursize;
@@ -742,11 +737,8 @@ cluster_write(struct vnode *vp, struct buf *bp, u_quad_t filesize, int seqcount)
* the current block (if last_bp == NULL).
*/
int
-cluster_wbuild(vp, size, start_lbn, len)
- struct vnode *vp;
- long size;
- daddr_t start_lbn;
- int len;
+cluster_wbuild(struct vnode *vp, long size, daddr_t start_lbn, int len,
+ int gbflags)
{
struct buf *bp, *tbp;
struct bufobj *bo;
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index fc78235..1c361bd 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -445,7 +445,7 @@ sys_getfsstat(td, uap)
/*
* If (bufsize > 0 && bufseg == UIO_SYSSPACE)
- * The caller is responsible for freeing memory which will be allocated
+ * The caller is responsible for freeing memory which will be allocated
* in '*buf'.
*/
int
@@ -971,7 +971,7 @@ flags_to_rights(int flags)
/* FALLTHROUGH */
case O_WRONLY:
rights |= CAP_WRITE;
- if (!(flags & O_APPEND))
+ if (!(flags & (O_APPEND | O_TRUNC)))
rights |= CAP_SEEK;
break;
}
@@ -2843,7 +2843,6 @@ sys_lchmod(td, uap)
uap->mode, AT_SYMLINK_NOFOLLOW));
}
-
int
kern_fchmodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
mode_t mode, int flag)
@@ -2854,7 +2853,7 @@ kern_fchmodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
AUDIT_ARG_MODE(mode);
follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
- NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg, path, fd,
+ NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg, path, fd,
CAP_FCHMOD, td);
if ((error = namei(&nd)) != 0)
return (error);
@@ -4679,7 +4678,7 @@ kern_posix_fadvise(struct thread *td, int fd, off_t offset, off_t len,
new = fa;
fp->f_advice = NULL;
} else if (offset <= fa->fa_start &&
- end >= fa->fa_start)
+ end >= fa->fa_start)
fa->fa_start = end + 1;
else if (offset <= fa->fa_end && end >= fa->fa_end)
fa->fa_end = offset - 1;
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index d367340..c8f832f 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -7,6 +7,12 @@
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
+ * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
+ * Copyright (c) 2013 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -1122,6 +1128,45 @@ vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio)
return (error);
}
+int
+vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
+ struct uio *uio)
+{
+ struct thread *td;
+ vm_offset_t iov_base;
+ int cnt, pgadv;
+
+ td = curthread;
+ if ((td->td_pflags & TDP_UIOHELD) == 0 ||
+ uio->uio_segflg != UIO_USERSPACE)
+ return (uiomove_fromphys(ma, offset, xfersize, uio));
+
+ KASSERT(uio->uio_iovcnt == 1, ("uio_iovcnt %d", uio->uio_iovcnt));
+ cnt = xfersize > uio->uio_resid ? uio->uio_resid : xfersize;
+ iov_base = (vm_offset_t)uio->uio_iov->iov_base;
+ switch (uio->uio_rw) {
+ case UIO_WRITE:
+ pmap_copy_pages(td->td_ma, iov_base & PAGE_MASK, ma,
+ offset, cnt);
+ break;
+ case UIO_READ:
+ pmap_copy_pages(ma, offset, td->td_ma, iov_base & PAGE_MASK,
+ cnt);
+ break;
+ }
+ pgadv = ((iov_base + cnt) >> PAGE_SHIFT) - (iov_base >> PAGE_SHIFT);
+ td->td_ma += pgadv;
+ KASSERT(td->td_ma_cnt >= pgadv, ("consumed pages %d %d", td->td_ma_cnt,
+ pgadv));
+ td->td_ma_cnt -= pgadv;
+ uio->uio_iov->iov_base = (char *)(iov_base + cnt);
+ uio->uio_iov->iov_len -= cnt;
+ uio->uio_resid -= cnt;
+ uio->uio_offset += cnt;
+ return (0);
+}
+
+
/*
* File table truncate routine.
*/
diff --git a/sys/libkern/arm/aeabi_unwind.c b/sys/libkern/arm/aeabi_unwind.c
new file mode 100644
index 0000000..098e6e6
--- /dev/null
+++ b/sys/libkern/arm/aeabi_unwind.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/systm.h>
+
+#ifdef __ARM_EABI__
+/* We need to provide these functions never call them */
+void __aeabi_unwind_cpp_pr0(void);
+void __aeabi_unwind_cpp_pr1(void);
+void __aeabi_unwind_cpp_pr2(void);
+
+void
+__aeabi_unwind_cpp_pr0(void)
+{
+ panic("__aeabi_unwind_cpp_pr0");
+}
+
+void
+__aeabi_unwind_cpp_pr1(void)
+{
+ panic("__aeabi_unwind_cpp_pr1");
+}
+
+void
+__aeabi_unwind_cpp_pr2(void)
+{
+ panic("__aeabi_unwind_cpp_pr2");
+}
+#endif
+
diff --git a/sys/libkern/arm/divsi3.S b/sys/libkern/arm/divsi3.S
index 700ae37..302f179 100644
--- a/sys/libkern/arm/divsi3.S
+++ b/sys/libkern/arm/divsi3.S
@@ -29,6 +29,7 @@ ENTRY_NP(__umodsi3)
add sp, sp, #4 /* unalign stack */
mov r0, r1
ldmfd sp!, {pc}
+END(__umodsi3)
ENTRY_NP(__modsi3)
stmfd sp!, {lr}
@@ -48,6 +49,7 @@ ENTRY_NP(__modsi3)
mvn r0, #0
#endif
RET
+END(__modsi3)
#ifdef __ARM_EABI__
ENTRY_NP(__aeabi_uidiv)
@@ -74,6 +76,11 @@ ENTRY_NP(__udivsi3)
mov r0, r1
mov r1, #0
RET
+#ifdef __ARM_EABI__
+END(__aeabi_uidiv)
+END(__aeabi_uidivmod)
+#endif
+END(__udivsi3)
#ifdef __ARM_EABI__
ENTRY_NP(__aeabi_idiv)
@@ -393,3 +400,9 @@ ENTRY_NP(__divsi3)
addhs r3, r3, r2
mov r0, r3
RET
+#ifdef __ARM_EABI__
+END(__aeabi_idiv)
+END(__aeabi_idivmod)
+#endif
+END(__divsi3)
+
diff --git a/sys/libkern/arm/ffs.S b/sys/libkern/arm/ffs.S
index ba0af49..a43f2b6 100644
--- a/sys/libkern/arm/ffs.S
+++ b/sys/libkern/arm/ffs.S
@@ -82,3 +82,5 @@ ENTRY(ffs)
rsbne r0, r0, #32
RET
#endif
+END(ffs)
+
diff --git a/sys/libkern/arm/ldivmod.S b/sys/libkern/arm/ldivmod.S
index a88db54..26a3944 100644
--- a/sys/libkern/arm/ldivmod.S
+++ b/sys/libkern/arm/ldivmod.S
@@ -53,6 +53,7 @@ ENTRY_NP(__aeabi_ldivmod)
add sp, sp, #8 /* Move sp to the remainder value */
ldmfd sp!, {r2, r3} /* Load the remainder */
RET
+END(__aeabi_ldivmod)
ENTRY_NP(__aeabi_uldivmod)
sub sp, sp, #8 /* Space for the remainder */
@@ -62,6 +63,7 @@ ENTRY_NP(__aeabi_uldivmod)
add sp, sp, #8 /* Move sp to the remainder value */
ldmfd sp!, {r2, r3} /* Load the remainder */
RET
+END(__aeabi_uldivmod)
#endif
diff --git a/sys/libkern/arm/memcpy.S b/sys/libkern/arm/memcpy.S
index b2997db..9fca8f6 100644
--- a/sys/libkern/arm/memcpy.S
+++ b/sys/libkern/arm/memcpy.S
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andrew Turner
+ * Copyright (C) 2013 Andrew Turner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
ENTRY_NP(__aeabi_memcpy)
b memcpy
+END(__aeabi_memcpy)
#endif
diff --git a/usr.bin/vis/extern.h b/sys/libkern/arm/memset.S
index 683402b..57d2507 100644
--- a/usr.bin/vis/extern.h
+++ b/sys/libkern/arm/memset.S
@@ -1,6 +1,6 @@
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
+/*
+ * Copyright (C) 2013 Andrew Turner
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,14 +10,11 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -26,7 +23,27 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
*/
-extern int foldit(char *, int, int);
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef __ARM_EABI__
+
+/*
+ * This implements
+ * void __aeabi_memset(void *dest, size_t len, int c)
+ * by calling:
+ * void *memset(dest, c, len)
+ *
+ * The arguments are in r0-r2, r3 can be used as a scratch register.
+ */
+ENTRY_NP(__aeabi_memset)
+ mov r3, r2
+ mov r2, r1
+ mov r1, r3
+ b memset
+END(__aeabi_memset)
+
+#endif
+
diff --git a/sys/mips/mips/pmap.c b/sys/mips/mips/pmap.c
index 9e1b812..4fe6ebe 100644
--- a/sys/mips/mips/pmap.c
+++ b/sys/mips/mips/pmap.c
@@ -2576,6 +2576,51 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
}
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+ char *a_cp, *b_cp;
+ vm_page_t a_m, b_m;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ vm_paddr_t a_phys, b_phys;
+ int cnt;
+
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ a_m = ma[a_offset >> PAGE_SHIFT];
+ a_phys = VM_PAGE_TO_PHYS(a_m);
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ b_m = mb[b_offset >> PAGE_SHIFT];
+ b_phys = VM_PAGE_TO_PHYS(b_m);
+ if (MIPS_DIRECT_MAPPABLE(a_phys) &&
+ MIPS_DIRECT_MAPPABLE(b_phys)) {
+ pmap_flush_pvcache(a_m);
+ mips_dcache_wbinv_range_index(
+ MIPS_PHYS_TO_DIRECT(b_phys), PAGE_SIZE);
+ a_cp = (char *)MIPS_PHYS_TO_DIRECT(a_phys) +
+ a_pg_offset;
+ b_cp = (char *)MIPS_PHYS_TO_DIRECT(b_phys) +
+ b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ mips_dcache_wbinv_range((vm_offset_t)b_cp, cnt);
+ } else {
+ a_cp = (char *)pmap_lmem_map2(a_phys, b_phys);
+ b_cp = (char *)a_cp + PAGE_SIZE;
+ a_cp += a_pg_offset;
+ b_cp += b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ mips_dcache_wbinv_range((vm_offset_t)b_cp, cnt);
+ pmap_lmem_unmap();
+ }
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+}
+
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
diff --git a/sys/modules/uart/Makefile b/sys/modules/uart/Makefile
index d8a4869..06b005b 100644
--- a/sys/modules/uart/Makefile
+++ b/sys/modules/uart/Makefile
@@ -4,6 +4,9 @@
.if ${MACHINE_CPUARCH} == "sparc64"
uart_bus_ebus= uart_bus_ebus.c
+.endif
+
+.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "sparc64"
ofw_bus_if= ofw_bus_if.h
.endif
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index 43dd005..07cf219 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -234,7 +234,7 @@ bstp_transmit_tcn(struct bstp_state *bs, struct bstp_port *bp)
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return;
@@ -348,7 +348,7 @@ bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp,
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return;
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 27e58d8..48255b0 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -384,8 +384,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
mob_h.hcrc = gre_in_cksum((u_int16_t *)&mob_h, msiz);
if ((m->m_data - msiz) < m->m_pktdat) {
- /* need new mbuf */
- MGETHDR(m0, M_NOWAIT, MT_DATA);
+ m0 = m_gethdr(M_NOWAIT, MT_DATA);
if (m0 == NULL) {
_IF_DROP(&ifp->if_snd);
m_freem(m);
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 9a08a76..c3781d5 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1118,20 +1118,17 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo)
default:
len = sizeof(struct rt_msghdr);
}
- if (len > MCLBYTES)
- panic("rt_msg1");
- m = m_gethdr(M_NOWAIT, MT_DATA);
- if (m && len > MHLEN) {
- MCLGET(m, M_NOWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- m_free(m);
- m = NULL;
- }
- }
+
+ /* XXXGL: can we use MJUMPAGESIZE cluster here? */
+ KASSERT(len <= MCLBYTES, ("%s: message too big", __func__));
+ if (len > MHLEN)
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ else
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return (m);
+
m->m_pkthdr.len = m->m_len = len;
- m->m_pkthdr.rcvif = NULL;
rtm = mtod(m, struct rt_msghdr *);
bzero((caddr_t)rtm, len);
for (i = 0; i < RTAX_MAX; i++) {
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index e87da5e..fd7eb3c 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -523,7 +523,7 @@ igmp_ra_alloc(void)
struct mbuf *m;
struct ipoption *p;
- MGET(m, M_NOWAIT, MT_DATA);
+ m = m_get(M_WAITOK, MT_DATA);
p = mtod(m, struct ipoption *);
p->ipopt_dst.s_addr = INADDR_ANY;
p->ipopt_list[0] = IPOPT_RA; /* Router Alert Option */
@@ -2203,7 +2203,7 @@ igmp_v1v2_queue_report(struct in_multi *inm, const int type)
ifp = inm->inm_ifp;
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return (ENOMEM);
MH_ALIGN(m, sizeof(struct ip) + sizeof(struct igmp));
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index ae3da96..eaff4f6 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -764,7 +764,7 @@ carp_send_ad_locked(struct carp_softc *sc)
if (sc->sc_naddrs) {
struct ip *ip;
- MGETHDR(m, M_NOWAIT, MT_HEADER);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL) {
CARPSTATS_INC(carps_onomem);
goto resched;
@@ -832,7 +832,7 @@ carp_send_ad_locked(struct carp_softc *sc)
if (sc->sc_naddrs6) {
struct ip6_hdr *ip6;
- MGETHDR(m, M_NOWAIT, MT_HEADER);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL) {
CARPSTATS_INC(carps_onomem);
goto resched;
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 555b5d0..1f1122c 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1406,7 +1406,7 @@ ip_forward(struct mbuf *m, int srcrt)
* assume exclusive access to the IP header in `m', so any
* data in a cluster may change before we reach icmp_error().
*/
- MGETHDR(mcopy, M_NOWAIT, m->m_type);
+ mcopy = m_gethdr(M_NOWAIT, m->m_type);
if (mcopy != NULL && !m_dup_pkthdr(mcopy, m, M_NOWAIT)) {
/*
* It's probably ok if the pkthdr dup fails (because
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 6228933..db8238f 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -2083,13 +2083,12 @@ bw_upcalls_send(void)
* Allocate a new mbuf, initialize it with the header and
* the payload for the pending calls.
*/
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL) {
log(LOG_WARNING, "bw_upcalls_send: cannot allocate mbuf\n");
return;
}
- m->m_len = m->m_pkthdr.len = 0;
m_copyback(m, 0, sizeof(struct igmpmsg), (caddr_t)&igmpmsg);
m_copyback(m, sizeof(struct igmpmsg), len, (caddr_t)&V_bw_upcalls[0]);
@@ -2430,7 +2429,7 @@ pim_register_send_upcall(struct ip *ip, struct vif *vifp,
/*
* Add a new mbuf with an upcall header
*/
- MGETHDR(mb_first, M_NOWAIT, MT_DATA);
+ mb_first = m_gethdr(M_NOWAIT, MT_DATA);
if (mb_first == NULL) {
m_freem(mb_copy);
return ENOBUFS;
@@ -2488,7 +2487,7 @@ pim_register_send_rp(struct ip *ip, struct vif *vifp, struct mbuf *mb_copy,
/*
* Add a new mbuf with the encapsulating header
*/
- MGETHDR(mb_first, M_NOWAIT, MT_DATA);
+ mb_first = m_gethdr(M_NOWAIT, MT_DATA);
if (mb_first == NULL) {
m_freem(mb_copy);
return ENOBUFS;
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c
index 239c699..8911992 100644
--- a/sys/netinet/ip_options.c
+++ b/sys/netinet/ip_options.c
@@ -495,12 +495,12 @@ ip_insertoptions(struct mbuf *m, struct mbuf *opt, int *phlen)
if (p->ipopt_dst.s_addr)
ip->ip_dst = p->ipopt_dst;
if (m->m_flags & M_EXT || m->m_data - optlen < m->m_pktdat) {
- MGETHDR(n, M_NOWAIT, MT_DATA);
+ n = m_gethdr(M_NOWAIT, MT_DATA);
if (n == NULL) {
*phlen = 0;
return (m);
}
- M_MOVE_PKTHDR(n, m);
+ m_move_pkthdr(n, m);
n->m_pkthdr.rcvif = NULL;
n->m_pkthdr.len += optlen;
m->m_len -= sizeof(struct ip);
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 166bef5..fd418e9 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -784,7 +784,7 @@ smart_frag_failure:
struct mbuf *m;
int mhlen = sizeof (struct ip);
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL) {
error = ENOBUFS;
IPSTAT_INC(ips_odropped);
@@ -951,7 +951,7 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
error = EMSGSIZE;
break;
}
- MGET(m, sopt->sopt_td ? M_WAITOK : M_NOWAIT, MT_DATA);
+ m = m_get(sopt->sopt_td ? M_WAITOK : M_NOWAIT, MT_DATA);
if (m == NULL) {
error = ENOBUFS;
break;
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c
index 33876c4..8f23699 100644
--- a/sys/netinet/libalias/alias.c
+++ b/sys/netinet/libalias/alias.c
@@ -1749,26 +1749,22 @@ LibAliasUnLoadAllModule(void)
struct mbuf *
m_megapullup(struct mbuf *m, int len) {
struct mbuf *mcl;
-
+
if (len > m->m_pkthdr.len)
goto bad;
-
- /* Do not reallocate packet if it is sequentional,
- * writable and has some extra space for expansion.
- * XXX: Constant 100bytes is completely empirical. */
-#define RESERVE 100
- if (m->m_next == NULL && M_WRITABLE(m) && M_TRAILINGSPACE(m) >= RESERVE)
+
+ if (m->m_next == NULL && M_WRITABLE(m))
return (m);
- mcl = m_get2(len + RESERVE, M_NOWAIT, MT_DATA, M_PKTHDR);
+ mcl = m_get2(len, M_NOWAIT, MT_DATA, M_PKTHDR);
if (mcl == NULL)
goto bad;
-
+ m_align(mcl, len);
m_move_pkthdr(mcl, m);
m_copydata(m, 0, len, mtod(mcl, caddr_t));
mcl->m_len = mcl->m_pkthdr.len = len;
m_freem(m);
-
+
return (mcl);
bad:
m_freem(m);
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index ac7ac31..bcfed8a 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -842,23 +842,19 @@ send:
TCPSTAT_INC(tcps_sndpack);
TCPSTAT_ADD(tcps_sndbyte, len);
}
- MGETHDR(m, M_NOWAIT, MT_DATA);
+#ifdef INET6
+ if (MHLEN < hdrlen + max_linkhdr)
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ else
+#endif
+ m = m_gethdr(M_NOWAIT, MT_DATA);
+
if (m == NULL) {
SOCKBUF_UNLOCK(&so->so_snd);
error = ENOBUFS;
goto out;
}
-#ifdef INET6
- if (MHLEN < hdrlen + max_linkhdr) {
- MCLGET(m, M_NOWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- SOCKBUF_UNLOCK(&so->so_snd);
- m_freem(m);
- error = ENOBUFS;
- goto out;
- }
- }
-#endif
+
m->m_data += max_linkhdr;
m->m_len = hdrlen;
@@ -902,7 +898,7 @@ send:
else
TCPSTAT_INC(tcps_sndwinup);
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL) {
error = ENOBUFS;
goto out;
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 3c9dd34..24e4db2 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1860,7 +1860,7 @@ ipsec_hdrsiz_tcp(struct tcpcb *tp)
if ((tp == NULL) || ((inp = tp->t_inpcb) == NULL))
return (0);
- MGETHDR(m, M_NOWAIT, MT_DATA);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (!m)
return (0);
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 0cd6e5a..8772779 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -578,25 +578,18 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
if ((n->m_flags & M_EXT) != 0
|| n->m_len < off + sizeof(struct icmp6_hdr)) {
struct mbuf *n0 = n;
- const int maxlen = sizeof(*nip6) + sizeof(*nicmp6);
int n0len;
- MGETHDR(n, M_NOWAIT, n0->m_type);
- n0len = n0->m_pkthdr.len; /* save for use below */
- if (n)
- M_MOVE_PKTHDR(n, n0); /* FIB copied. */
- if (n && maxlen >= MHLEN) {
- MCLGET(n, M_NOWAIT);
- if ((n->m_flags & M_EXT) == 0) {
- m_free(n);
- n = NULL;
- }
- }
+ CTASSERT(sizeof(*nip6) + sizeof(*nicmp6) <= MHLEN);
+ n = m_gethdr(M_NOWAIT, n0->m_type);
if (n == NULL) {
/* Give up remote */
m_freem(n0);
break;
}
+
+ m_move_pkthdr(n, n0); /* FIB copied. */
+ n0len = n0->m_pkthdr.len; /* save for use below */
/*
* Copy IPv6 and ICMPv6 only.
*/
@@ -683,7 +676,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
} else {
struct prison *pr;
u_char *p;
- int maxlen, maxhlen, hlen;
+ int maxhlen, hlen;
/*
* XXX: this combination of flags is pointless,
@@ -694,20 +687,14 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
if (code != 0)
goto badcode;
- maxlen = sizeof(*nip6) + sizeof(*nicmp6) + 4;
- if (maxlen >= MCLBYTES) {
+
+ CTASSERT(sizeof(*nip6) + sizeof(*nicmp6) + 4 <= MHLEN);
+ n = m_gethdr(M_NOWAIT, m->m_type);
+ if (n == NULL) {
/* Give up remote */
break;
}
- MGETHDR(n, M_NOWAIT, m->m_type);
- if (n && maxlen > MHLEN) {
- MCLGET(n, M_NOWAIT);
- if ((n->m_flags & M_EXT) == 0) {
- m_free(n);
- n = NULL;
- }
- }
- if (n && !m_dup_pkthdr(n, m, M_NOWAIT)) {
+ if (!m_dup_pkthdr(n, m, M_NOWAIT)) {
/*
* Previous code did a blind M_COPY_PKTHDR
* and said "just for rcvif". If true, then
@@ -718,13 +705,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
m_free(n);
n = NULL;
}
- if (n == NULL) {
- /* Give up remote */
- break;
- }
- n->m_pkthdr.rcvif = NULL;
- n->m_len = 0;
- maxhlen = M_TRAILINGSPACE(n) - maxlen;
+ maxhlen = M_TRAILINGSPACE(n) -
+ (sizeof(*nip6) + sizeof(*nicmp6) + 4);
pr = curthread->td_ucred->cr_prison;
mtx_lock(&pr->pr_mtx);
hlen = strlen(pr->pr_hostname);
@@ -1494,26 +1476,23 @@ ni6_input(struct mbuf *m, int off)
break;
}
- /* allocate an mbuf to reply. */
- MGETHDR(n, M_NOWAIT, m->m_type);
+ /* Allocate an mbuf to reply. */
+ if (replylen > MCLBYTES) {
+ /*
+ * XXX: should we try to allocate more? But MCLBYTES
+ * is probably much larger than IPV6_MMTU...
+ */
+ goto bad;
+ }
+ if (replylen > MHLEN)
+ n = m_getcl(M_NOWAIT, m->m_type, M_PKTHDR);
+ else
+ n = m_gethdr(M_NOWAIT, m->m_type);
if (n == NULL) {
m_freem(m);
return (NULL);
}
- M_MOVE_PKTHDR(n, m); /* just for recvif and FIB */
- if (replylen > MHLEN) {
- if (replylen > MCLBYTES) {
- /*
- * XXX: should we try to allocate more? But MCLBYTES
- * is probably much larger than IPV6_MMTU...
- */
- goto bad;
- }
- MCLGET(n, M_NOWAIT);
- if ((n->m_flags & M_EXT) == 0) {
- goto bad;
- }
- }
+ m_move_pkthdr(n, m); /* just for recvif and FIB */
n->m_pkthdr.len = n->m_len = replylen;
/* copy mbuf header and IPv6 + Node Information base headers */
@@ -1608,16 +1587,13 @@ ni6_nametodns(const char *name, int namelen, int old)
else
len = MCLBYTES;
- /* because MAXHOSTNAMELEN is usually 256, we use cluster mbuf */
- MGET(m, M_NOWAIT, MT_DATA);
- if (m && len > MLEN) {
- MCLGET(m, M_NOWAIT);
- if ((m->m_flags & M_EXT) == 0)
- goto fail;
- }
- if (!m)
+ /* Because MAXHOSTNAMELEN is usually 256, we use cluster mbuf. */
+ if (len > MLEN)
+ m = m_getcl(M_NOWAIT, MT_DATA, 0);
+ else
+ m = m_get(M_NOWAIT, MT_DATA);
+ if (m == NULL)
goto fail;
- m->m_next = NULL;
if (old) {
m->m_len = len;
@@ -2063,7 +2039,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
*/
if ((m->m_flags & M_EXT) && m->m_next == NULL &&
m->m_len <= MHLEN) {
- MGET(n, M_NOWAIT, m->m_type);
+ n = m_get(M_NOWAIT, m->m_type);
if (n != NULL) {
if (m_dup_pkthdr(n, m, M_NOWAIT)) {
bcopy(m->m_data, n->m_data,
@@ -2113,7 +2089,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
m->m_len <= MHLEN) {
struct mbuf *n;
- MGET(n, M_NOWAIT, m->m_type);
+ n = m_get(M_NOWAIT, m->m_type);
if (n != NULL) {
if (m_dup_pkthdr(n, m, M_NOWAIT)) {
bcopy(m->m_data, n->m_data, m->m_len);
@@ -2592,14 +2568,10 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
#if IPV6_MMTU >= MCLBYTES
# error assumption failed about IPV6_MMTU and MCLBYTES
#endif
- MGETHDR(m, M_NOWAIT, MT_HEADER);
- if (m && IPV6_MMTU >= MHLEN)
- MCLGET(m, M_NOWAIT);
- if (!m)
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ if (m == NULL)
goto fail;
M_SETFIB(m, rt->rt_fibnum);
- m->m_pkthdr.rcvif = NULL;
- m->m_len = 0;
maxlen = M_TRAILINGSPACE(m);
maxlen = min(IPV6_MMTU, maxlen);
/* just for safety */
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 45c4ff6..e037737 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -497,21 +497,16 @@ ip6_input(struct mbuf *m)
if (m && m->m_next != NULL && m->m_pkthdr.len < MCLBYTES) {
struct mbuf *n;
- MGETHDR(n, M_NOWAIT, MT_HEADER);
- if (n)
- M_MOVE_PKTHDR(n, m);
- if (n && n->m_pkthdr.len > MHLEN) {
- MCLGET(n, M_NOWAIT);
- if ((n->m_flags & M_EXT) == 0) {
- m_freem(n);
- n = NULL;
- }
- }
+ if (m->m_pkthdr.len > MHLEN)
+ n = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ else
+ n = m_gethdr(M_NOWAIT, MT_DATA);
if (n == NULL) {
m_freem(m);
return; /* ENOBUFS */
}
+ m_move_pkthdr(n, m);
m_copydata(m, 0, n->m_pkthdr.len, mtod(n, caddr_t));
n->m_len = n->m_pkthdr.len;
m_freem(m);
@@ -1667,22 +1662,12 @@ ip6_pullexthdr(struct mbuf *m, size_t off, int nxt)
else
elen = (ip6e.ip6e_len + 1) << 3;
- MGET(n, M_NOWAIT, MT_DATA);
- if (n && elen >= MLEN) {
- MCLGET(n, M_NOWAIT);
- if ((n->m_flags & M_EXT) == 0) {
- m_free(n);
- n = NULL;
- }
- }
- if (!n)
- return NULL;
-
- n->m_len = 0;
- if (elen >= M_TRAILINGSPACE(n)) {
- m_free(n);
+ if (elen > MLEN)
+ n = m_getcl(M_NOWAIT, MT_DATA, 0);
+ else
+ n = m_get(M_NOWAIT, MT_DATA);
+ if (n == NULL)
return NULL;
- }
m_copydata(m, off, elen, mtod(n, caddr_t));
n->m_len = elen;
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index a221110..aeeb644 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -1698,11 +1698,10 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
#endif
++pim6stat.pim6s_snd_registers;
- /* Make a copy of the packet to send to the user level process */
- MGETHDR(mm, M_NOWAIT, MT_HEADER);
+ /* Make a copy of the packet to send to the user level process. */
+ mm = m_gethdr(M_NOWAIT, MT_DATA);
if (mm == NULL)
return (ENOBUFS);
- mm->m_pkthdr.rcvif = NULL;
mm->m_data += max_linkhdr;
mm->m_len = sizeof(struct ip6_hdr);
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 5e8c11f..e5042d2 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -774,9 +774,7 @@ again:
/*
* XXX: ip6_mforward expects that rcvif is NULL
* when it is called from the originating path.
- * However, it is not always the case, since
- * some versions of MGETHDR() does not
- * initialize the field.
+ * However, it may not always be the case.
*/
m->m_pkthdr.rcvif = NULL;
if (ip6_mforward(ip6, ifp, m) != 0) {
@@ -1122,13 +1120,12 @@ passout:
*/
m0 = m;
for (off = hlen; off < tlen; off += len) {
- MGETHDR(m, M_NOWAIT, MT_HEADER);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (!m) {
error = ENOBUFS;
V_ip6stat.ip6s_odropped++;
goto sendorfree;
}
- m->m_pkthdr.rcvif = NULL;
m->m_flags = m0->m_flags & M_COPYFLAGS; /* incl. FIB */
*mnext = m;
mnext = &m->m_nextpkt;
@@ -1222,17 +1219,12 @@ ip6_copyexthdr(struct mbuf **mp, caddr_t hdr, int hlen)
if (hlen > MCLBYTES)
return (ENOBUFS); /* XXX */
- MGET(m, M_NOWAIT, MT_DATA);
- if (!m)
+ if (hlen > MLEN)
+ m = m_getcl(M_NOWAIT, MT_DATA, 0);
+ else
+ m = m_get(M_NOWAIT, MT_DATA);
+ if (m == NULL)
return (ENOBUFS);
-
- if (hlen > MLEN) {
- MCLGET(m, M_NOWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- m_free(m);
- return (ENOBUFS);
- }
- }
m->m_len = hlen;
if (hdr)
bcopy(hdr, mtod(m, caddr_t), hlen);
@@ -1260,8 +1252,8 @@ ip6_insert_jumboopt(struct ip6_exthdrs *exthdrs, u_int32_t plen)
* Otherwise, use it to store the options.
*/
if (exthdrs->ip6e_hbh == 0) {
- MGET(mopt, M_NOWAIT, MT_DATA);
- if (mopt == 0)
+ mopt = m_get(M_NOWAIT, MT_DATA);
+ if (mopt == NULL)
return (ENOBUFS);
mopt->m_len = JUMBOOPTLEN;
optbuf = mtod(mopt, u_char *);
@@ -1292,15 +1284,8 @@ ip6_insert_jumboopt(struct ip6_exthdrs *exthdrs, u_int32_t plen)
* As a consequence, we must always prepare a cluster
* at this point.
*/
- MGET(n, M_NOWAIT, MT_DATA);
- if (n) {
- MCLGET(n, M_NOWAIT);
- if ((n->m_flags & M_EXT) == 0) {
- m_freem(n);
- n = NULL;
- }
- }
- if (!n)
+ n = m_getcl(M_NOWAIT, MT_DATA, 0);
+ if (n == NULL)
return (ENOBUFS);
n->m_len = oldoptlen + JUMBOOPTLEN;
bcopy(mtod(mopt, caddr_t), mtod(n, caddr_t),
@@ -1369,8 +1354,8 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int hlen,
/* allocate a new mbuf for the fragment header */
struct mbuf *mfrg;
- MGET(mfrg, M_NOWAIT, MT_DATA);
- if (mfrg == 0)
+ mfrg = m_get(M_NOWAIT, MT_DATA);
+ if (mfrg == NULL)
return (ENOBUFS);
mfrg->m_len = sizeof(struct ip6_frag);
*frghdrp = mtod(mfrg, struct ip6_frag *);
@@ -3045,12 +3030,12 @@ ip6_splithdr(struct mbuf *m, struct ip6_exthdrs *exthdrs)
ip6 = mtod(m, struct ip6_hdr *);
if (m->m_len > sizeof(*ip6)) {
- MGETHDR(mh, M_NOWAIT, MT_HEADER);
- if (mh == 0) {
+ mh = m_gethdr(M_NOWAIT, MT_DATA);
+ if (mh == NULL) {
m_freem(m);
return ENOBUFS;
}
- M_MOVE_PKTHDR(mh, m);
+ m_move_pkthdr(mh, m);
MH_ALIGN(mh, sizeof(*ip6));
m->m_len -= sizeof(*ip6);
m->m_data += sizeof(*ip6);
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 0d9e300..560e8d6 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -1799,13 +1799,13 @@ mld_v1_transmit_report(struct in6_multi *in6m, const int type)
ia = in6ifa_ifpforlinklocal(ifp, IN6_IFF_NOTREADY|IN6_IFF_ANYCAST);
/* ia may be NULL if link-local address is tentative. */
- MGETHDR(mh, M_NOWAIT, MT_HEADER);
+ mh = m_gethdr(M_NOWAIT, MT_DATA);
if (mh == NULL) {
if (ia != NULL)
ifa_free(&ia->ia_ifa);
return (ENOMEM);
}
- MGET(md, M_NOWAIT, MT_DATA);
+ md = m_get(M_NOWAIT, MT_DATA);
if (md == NULL) {
m_free(mh);
if (ia != NULL)
@@ -3173,7 +3173,7 @@ mld_v2_encap_report(struct ifnet *ifp, struct mbuf *m)
if (ia == NULL)
CTR1(KTR_MLD, "%s: warning: ia is NULL", __func__);
- MGETHDR(mh, M_NOWAIT, MT_HEADER);
+ mh = m_gethdr(M_NOWAIT, MT_DATA);
if (mh == NULL) {
if (ia != NULL)
ifa_free(&ia->ia_ifa);
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 7fe75bf..532c9b8 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -419,17 +419,12 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
return;
}
- MGETHDR(m, M_NOWAIT, MT_DATA);
- if (m && max_linkhdr + maxlen >= MHLEN) {
- MCLGET(m, M_NOWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- m_free(m);
- m = NULL;
- }
- }
+ if (max_linkhdr + maxlen > MHLEN)
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ else
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return;
- m->m_pkthdr.rcvif = NULL;
bzero(&ro, sizeof(ro));
@@ -997,17 +992,12 @@ nd6_na_output_fib(struct ifnet *ifp, const struct in6_addr *daddr6_0,
return;
}
- MGETHDR(m, M_NOWAIT, MT_DATA);
- if (m && max_linkhdr + maxlen >= MHLEN) {
- MCLGET(m, M_NOWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- m_free(m);
- m = NULL;
- }
- }
+ if (max_linkhdr + maxlen > MHLEN)
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ else
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL)
return;
- m->m_pkthdr.rcvif = NULL;
M_SETFIB(m, fibnum);
if (IN6_IS_ADDR_MULTICAST(&daddr6)) {
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
index a4b7ecb..67afed2 100644
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -547,7 +547,6 @@ static const char *key_getfqdn __P((void));
static const char *key_getuserfqdn __P((void));
#endif
static void key_sa_chgstate __P((struct secasvar *, u_int8_t));
-static struct mbuf *key_alloc_mbuf __P((int));
static __inline void
sa_initref(struct secasvar *sav)
@@ -1634,15 +1633,11 @@ key_sp2msg(sp)
tlen = key_getspreqmsglen(sp);
- m = key_alloc_mbuf(tlen);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
- return NULL;
- }
-
+ m = m_get2(tlen, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
+ return (NULL);
+ m_align(m, tlen);
m->m_len = tlen;
- m->m_next = NULL;
xpl = mtod(m, struct sadb_x_policy *);
bzero(xpl, tlen);
@@ -1732,12 +1727,11 @@ key_gather_mbuf(m, mhp, ndeep, nitem, va_alist)
mtod(n, caddr_t));
} else if (i < ndeep) {
len = mhp->extlen[idx];
- n = key_alloc_mbuf(len);
- if (!n || n->m_next) { /*XXX*/
- if (n)
- m_freem(n);
+ n = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (n == NULL)
goto fail;
- }
+ m_align(n, len);
+ n->m_len = len;
m_copydata(m, mhp->extoff[idx], mhp->extlen[idx],
mtod(n, caddr_t));
} else {
@@ -2602,13 +2596,13 @@ key_spdexpire(sp)
/* create lifetime extension (current and hard) */
len = PFKEY_ALIGN8(sizeof(*lt)) * 2;
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL) {
error = ENOBUFS;
goto fail;
}
+ m_align(m, len);
+ m->m_len = len;
bzero(mtod(m, caddr_t), len);
lt = mtod(m, struct sadb_lifetime *);
lt->sadb_lifetime_len = PFKEY_UNIT64(sizeof(struct sadb_lifetime));
@@ -3602,15 +3596,12 @@ key_setsadbsa(sav)
int len;
len = PFKEY_ALIGN8(sizeof(struct sadb_sa));
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
- return NULL;
- }
-
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
+ return (NULL);
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_sa *);
-
bzero(p, len);
p->sadb_sa_len = PFKEY_UNIT64(len);
p->sadb_sa_exttype = SADB_EXT_SA;
@@ -3636,13 +3627,11 @@ key_setsadbaddr(u_int16_t exttype, const struct sockaddr *saddr, u_int8_t prefix
len = PFKEY_ALIGN8(sizeof(struct sadb_address)) +
PFKEY_ALIGN8(saddr->sa_len);
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
- return NULL;
- }
-
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
+ return (NULL);
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_address *);
bzero(p, len);
@@ -3682,13 +3671,11 @@ key_setsadbxsa2(u_int8_t mode, u_int32_t seq, u_int32_t reqid)
size_t len;
len = PFKEY_ALIGN8(sizeof(struct sadb_x_sa2));
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
- return NULL;
- }
-
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
+ return (NULL);
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_x_sa2 *);
bzero(p, len);
@@ -3716,13 +3703,11 @@ key_setsadbxtype(u_int16_t type)
len = PFKEY_ALIGN8(sizeof(struct sadb_x_nat_t_type));
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
return (NULL);
- }
-
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_x_nat_t_type *);
bzero(p, len);
@@ -3745,13 +3730,11 @@ key_setsadbxport(u_int16_t port, u_int16_t type)
len = PFKEY_ALIGN8(sizeof(struct sadb_x_nat_t_port));
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
return (NULL);
- }
-
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_x_nat_t_port *);
bzero(p, len);
@@ -3822,13 +3805,11 @@ key_setsadbxpolicy(u_int16_t type, u_int8_t dir, u_int32_t id)
size_t len;
len = PFKEY_ALIGN8(sizeof(struct sadb_x_policy));
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
- return NULL;
- }
-
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL)
+ return (NULL);
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_x_policy *);
bzero(p, len);
@@ -6951,13 +6932,13 @@ key_expire(struct secasvar *sav)
/* create lifetime extension (current and soft) */
len = PFKEY_ALIGN8(sizeof(*lt)) * 2;
- m = key_alloc_mbuf(len);
- if (!m || m->m_next) { /*XXX*/
- if (m)
- m_freem(m);
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
+ if (m == NULL) {
error = ENOBUFS;
goto fail;
}
+ m_align(m, len);
+ m->m_len = len;
bzero(mtod(m, caddr_t), len);
lt = mtod(m, struct sadb_lifetime *);
lt->sadb_lifetime_len = PFKEY_UNIT64(sizeof(struct sadb_lifetime));
@@ -7959,45 +7940,6 @@ key_sa_stir_iv(sav)
key_randomfill(sav->iv, sav->ivlen);
}
-/* XXX too much? */
-static struct mbuf *
-key_alloc_mbuf(l)
- int l;
-{
- struct mbuf *m = NULL, *n;
- int len, t;
-
- len = l;
- while (len > 0) {
- MGET(n, M_NOWAIT, MT_DATA);
- if (n && len > MLEN)
- MCLGET(n, M_NOWAIT);
- if (!n) {
- m_freem(m);
- return NULL;
- }
-
- n->m_next = NULL;
- n->m_len = 0;
- n->m_len = M_TRAILINGSPACE(n);
- /* use the bottom of mbuf, hoping we can prepend afterwards */
- if (n->m_len > len) {
- t = (n->m_len - len) & ~(sizeof(long) - 1);
- n->m_data += t;
- n->m_len = len;
- }
-
- len -= n->m_len;
-
- if (m)
- m_cat(m, n);
- else
- m = n;
- }
-
- return m;
-}
-
/*
* Take one of the kernel's security keys and convert it into a PF_KEY
* structure within an mbuf, suitable for sending up to a waiting
@@ -8022,9 +7964,11 @@ key_setkey(struct seckey *src, u_int16_t exttype)
return NULL;
len = PFKEY_ALIGN8(sizeof(struct sadb_key) + _KEYLEN(src));
- m = key_alloc_mbuf(len);
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
if (m == NULL)
return NULL;
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_key *);
bzero(p, len);
p->sadb_key_len = PFKEY_UNIT64(len);
@@ -8059,9 +8003,11 @@ key_setlifetime(struct seclifetime *src, u_int16_t exttype)
if (src == NULL)
return NULL;
- m = key_alloc_mbuf(len);
+ m = m_get2(len, M_NOWAIT, MT_DATA, 0);
if (m == NULL)
return m;
+ m_align(m, len);
+ m->m_len = len;
p = mtod(m, struct sadb_lifetime *);
bzero(p, len);
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 6667d7a..168ad5c 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -2168,7 +2168,7 @@ pf_send_tcp(struct mbuf *replyto, const struct pf_rule *r, sa_family_t af,
pfse = malloc(sizeof(*pfse), M_PFTEMP, M_NOWAIT);
if (pfse == NULL)
return;
- m = m_gethdr(M_NOWAIT, MT_HEADER);
+ m = m_gethdr(M_NOWAIT, MT_DATA);
if (m == NULL) {
free(pfse, M_PFTEMP);
return;
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c
index 83e7125..ad9e7a1 100644
--- a/sys/nfs/nfs_common.c
+++ b/sys/nfs/nfs_common.c
@@ -192,7 +192,7 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, int how)
} else if (siz > MHLEN) {
panic("nfs S too big");
} else {
- MGET(mp2, how, MT_DATA);
+ mp2 = m_get(how, MT_DATA);
if (mp2 == NULL)
return (NULL);
mp2->m_len = siz;
@@ -266,7 +266,7 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos)
void *ret;
if (s > M_TRAILINGSPACE(*mb)) {
- MGET(mb2, M_WAITOK, MT_DATA);
+ mb2 = m_get(M_WAITOK, MT_DATA);
if (s > MLEN)
panic("build > MLEN");
(*mb)->m_next = mb2;
diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c
index 6a339ca..ddd22ae 100644
--- a/sys/powerpc/aim/mmu_oea.c
+++ b/sys/powerpc/aim/mmu_oea.c
@@ -275,6 +275,8 @@ void moea_change_wiring(mmu_t, pmap_t, vm_offset_t, boolean_t);
void moea_clear_modify(mmu_t, vm_page_t);
void moea_clear_reference(mmu_t, vm_page_t);
void moea_copy_page(mmu_t, vm_page_t, vm_page_t);
+void moea_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize);
void moea_enter(mmu_t, pmap_t, vm_offset_t, vm_page_t, vm_prot_t, boolean_t);
void moea_enter_object(mmu_t, pmap_t, vm_offset_t, vm_offset_t, vm_page_t,
vm_prot_t);
@@ -320,6 +322,7 @@ static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_clear_modify, moea_clear_modify),
MMUMETHOD(mmu_clear_reference, moea_clear_reference),
MMUMETHOD(mmu_copy_page, moea_copy_page),
+ MMUMETHOD(mmu_copy_pages, moea_copy_pages),
MMUMETHOD(mmu_enter, moea_enter),
MMUMETHOD(mmu_enter_object, moea_enter_object),
MMUMETHOD(mmu_enter_quick, moea_enter_quick),
@@ -1043,6 +1046,30 @@ moea_copy_page(mmu_t mmu, vm_page_t msrc, vm_page_t mdst)
bcopy((void *)src, (void *)dst, PAGE_SIZE);
}
+void
+moea_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize)
+{
+ void *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ a_cp = (char *)VM_PAGE_TO_PHYS(ma[a_offset >> PAGE_SHIFT]) +
+ a_pg_offset;
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ b_cp = (char *)VM_PAGE_TO_PHYS(mb[b_offset >> PAGE_SHIFT]) +
+ b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+}
+
/*
* Zero a page of physical memory by temporarily mapping it into the tlb.
*/
diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index 14b88f0..90466e8a 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -290,6 +290,8 @@ void moea64_change_wiring(mmu_t, pmap_t, vm_offset_t, boolean_t);
void moea64_clear_modify(mmu_t, vm_page_t);
void moea64_clear_reference(mmu_t, vm_page_t);
void moea64_copy_page(mmu_t, vm_page_t, vm_page_t);
+void moea64_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize);
void moea64_enter(mmu_t, pmap_t, vm_offset_t, vm_page_t, vm_prot_t, boolean_t);
void moea64_enter_object(mmu_t, pmap_t, vm_offset_t, vm_offset_t, vm_page_t,
vm_prot_t);
@@ -334,6 +336,7 @@ static mmu_method_t moea64_methods[] = {
MMUMETHOD(mmu_clear_modify, moea64_clear_modify),
MMUMETHOD(mmu_clear_reference, moea64_clear_reference),
MMUMETHOD(mmu_copy_page, moea64_copy_page),
+ MMUMETHOD(mmu_copy_pages, moea64_copy_pages),
MMUMETHOD(mmu_enter, moea64_enter),
MMUMETHOD(mmu_enter_object, moea64_enter_object),
MMUMETHOD(mmu_enter_quick, moea64_enter_quick),
@@ -1104,6 +1107,72 @@ moea64_copy_page(mmu_t mmu, vm_page_t msrc, vm_page_t mdst)
}
}
+static inline void
+moea64_copy_pages_dmap(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize)
+{
+ void *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ a_cp = (char *)VM_PAGE_TO_PHYS(ma[a_offset >> PAGE_SHIFT]) +
+ a_pg_offset;
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ b_cp = (char *)VM_PAGE_TO_PHYS(mb[b_offset >> PAGE_SHIFT]) +
+ b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+}
+
+static inline void
+moea64_copy_pages_nodmap(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize)
+{
+ void *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ mtx_lock(&moea64_scratchpage_mtx);
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ moea64_set_scratchpage_pa(mmu, 0,
+ VM_PAGE_TO_PHYS(ma[a_offset >> PAGE_SHIFT]));
+ a_cp = (char *)moea64_scratchpage_va[0] + a_pg_offset;
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ moea64_set_scratchpage_pa(mmu, 1,
+ VM_PAGE_TO_PHYS(mb[b_offset >> PAGE_SHIFT]));
+ b_cp = (char *)moea64_scratchpage_va[1] + b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+ mtx_unlock(&moea64_scratchpage_mtx);
+}
+
+void
+moea64_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize)
+{
+
+ if (hw_direct_map) {
+ moea64_copy_pages_dmap(mmu, ma, a_offset, mb, b_offset,
+ xfersize);
+ } else {
+ moea64_copy_pages_nodmap(mmu, ma, a_offset, mb, b_offset,
+ xfersize);
+ }
+}
+
void
moea64_zero_page_area(mmu_t mmu, vm_page_t m, int off, int size)
{
diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c
index 343b046..b9f4838 100644
--- a/sys/powerpc/booke/pmap.c
+++ b/sys/powerpc/booke/pmap.c
@@ -274,6 +274,8 @@ static void mmu_booke_clear_reference(mmu_t, vm_page_t);
static void mmu_booke_copy(mmu_t, pmap_t, pmap_t, vm_offset_t,
vm_size_t, vm_offset_t);
static void mmu_booke_copy_page(mmu_t, vm_page_t, vm_page_t);
+static void mmu_booke_copy_pages(mmu_t, vm_page_t *,
+ vm_offset_t, vm_page_t *, vm_offset_t, int);
static void mmu_booke_enter(mmu_t, pmap_t, vm_offset_t, vm_page_t,
vm_prot_t, boolean_t);
static void mmu_booke_enter_object(mmu_t, pmap_t, vm_offset_t, vm_offset_t,
@@ -334,6 +336,7 @@ static mmu_method_t mmu_booke_methods[] = {
MMUMETHOD(mmu_clear_reference, mmu_booke_clear_reference),
MMUMETHOD(mmu_copy, mmu_booke_copy),
MMUMETHOD(mmu_copy_page, mmu_booke_copy_page),
+ MMUMETHOD(mmu_copy_pages, mmu_booke_copy_pages),
MMUMETHOD(mmu_enter, mmu_booke_enter),
MMUMETHOD(mmu_enter_object, mmu_booke_enter_object),
MMUMETHOD(mmu_enter_quick, mmu_booke_enter_quick),
@@ -2136,6 +2139,36 @@ mmu_booke_copy_page(mmu_t mmu, vm_page_t sm, vm_page_t dm)
mtx_unlock(&copy_page_mutex);
}
+static inline void
+mmu_booke_copy_pages(mmu_t mmu, vm_page_t *ma, vm_offset_t a_offset,
+ vm_page_t *mb, vm_offset_t b_offset, int xfersize)
+{
+ void *a_cp, *b_cp;
+ vm_offset_t a_pg_offset, b_pg_offset;
+ int cnt;
+
+ mtx_lock(&copy_page_mutex);
+ while (xfersize > 0) {
+ a_pg_offset = a_offset & PAGE_MASK;
+ cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
+ mmu_booke_kenter(mmu, copy_page_src_va,
+ VM_PAGE_TO_PHYS(ma[a_offset >> PAGE_SHIFT]));
+ a_cp = (char *)copy_page_src_va + a_pg_offset;
+ b_pg_offset = b_offset & PAGE_MASK;
+ cnt = min(cnt, PAGE_SIZE - b_pg_offset);
+ mmu_booke_kenter(mmu, copy_page_dst_va,
+ VM_PAGE_TO_PHYS(mb[b_offset >> PAGE_SHIFT]));
+ b_cp = (char *)copy_page_dst_va + b_pg_offset;
+ bcopy(a_cp, b_cp, cnt);
+ mmu_booke_kremove(mmu, copy_page_dst_va);
+ mmu_booke_kremove(mmu, copy_page_src_va);
+ a_offset += cnt;
+ b_offset += cnt;
+ xfersize -= cnt;
+ }
+ mtx_unlock(&copy_page_mutex);
+}
+
/*
* mmu_booke_zero_page_idle zeros the specified hardware page by mapping it
* into virtual memory and using bzero to clear its contents. This is intended
diff --git a/sys/powerpc/powerpc/mmu_if.m b/sys/powerpc/powerpc/mmu_if.m
index 8cd6e52..0382bd8 100644
--- a/sys/powerpc/powerpc/mmu_if.m
+++ b/sys/powerpc/powerpc/mmu_if.m
@@ -215,6 +215,14 @@ METHOD void copy_page {
vm_page_t _dst;
};
+METHOD void copy_pages {
+ mmu_t _mmu;
+ vm_page_t *_ma;
+ vm_offset_t _a_offset;
+ vm_page_t *_mb;
+ vm_offset_t _b_offset;
+ int _xfersize;
+};
/**
* @brief Create a mapping between a virtual/physical address pair in the
diff --git a/sys/powerpc/powerpc/pmap_dispatch.c b/sys/powerpc/powerpc/pmap_dispatch.c
index c919196..42f1a39 100644
--- a/sys/powerpc/powerpc/pmap_dispatch.c
+++ b/sys/powerpc/powerpc/pmap_dispatch.c
@@ -133,6 +133,16 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
}
void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+
+ CTR6(KTR_PMAP, "%s(%p, %#x, %p, %#x, %#x)", __func__, ma,
+ a_offset, mb, b_offset, xfersize);
+ MMU_COPY_PAGES(mmu_obj, ma, a_offset, mb, b_offset, xfersize);
+}
+
+void
pmap_enter(pmap_t pmap, vm_offset_t va, vm_prot_t access, vm_page_t p,
vm_prot_t prot, boolean_t wired)
{
diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c
index 8bfc454..97a085a 100644
--- a/sys/sparc64/sparc64/pmap.c
+++ b/sys/sparc64/sparc64/pmap.c
@@ -1918,6 +1918,14 @@ pmap_copy_page(vm_page_t msrc, vm_page_t mdst)
}
}
+void
+pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
+ vm_offset_t b_offset, int xfersize)
+{
+
+ panic("pmap_copy_pages: not implemented");
+}
+
/*
* Returns true if the pmap's pv is one of the first
* 16 pvs linked to from this page. This count may
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 672ef5a..2261b56 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -508,9 +508,9 @@ void bufdone_finish(struct buf *);
void bd_speedup(void);
int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
- struct ucred *, long, int, struct buf **);
-int cluster_wbuild(struct vnode *, long, daddr_t, int);
-void cluster_write(struct vnode *, struct buf *, u_quad_t, int);
+ struct ucred *, long, int, int, struct buf **);
+int cluster_wbuild(struct vnode *, long, daddr_t, int, int);
+void cluster_write(struct vnode *, struct buf *, u_quad_t, int, int);
void vfs_bio_set_valid(struct buf *, int base, int size);
void vfs_bio_clrbuf(struct buf *);
void vfs_busy_pages(struct buf *, int clear_modify);
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index a4b0f71..ec10bc6 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -195,7 +195,7 @@ struct mbuf {
#define M_FIRSTFRAG 0x00001000 /* packet is first fragment */
#define M_LASTFRAG 0x00002000 /* packet is last fragment */
#define M_SKIP_FIREWALL 0x00004000 /* skip firewall processing */
-#define M_FREELIST 0x00008000 /* mbuf is on the free list */
+ /* 0x00008000 free */
#define M_VLANTAG 0x00010000 /* ether_vtag is valid */
#define M_PROMISC 0x00020000 /* packet was not for us */
#define M_NOFREE 0x00040000 /* do not free mbuf, embedded in cluster */
@@ -708,6 +708,18 @@ m_last(struct mbuf *m)
} while (0)
/*
+ * As above, for mbuf with external storage.
+ */
+#define MEXT_ALIGN(m, len) do { \
+ KASSERT((m)->m_flags & M_EXT, \
+ ("%s: MEXT_ALIGN not an M_EXT mbuf", __func__)); \
+ KASSERT((m)->m_data == (m)->m_ext.ext_buf, \
+ ("%s: MEXT_ALIGN not a virgin mbuf", __func__)); \
+ (m)->m_data += ((m)->m_ext.ext_size - (len)) & \
+ ~(sizeof(long) - 1); \
+} while (0)
+
+/*
* Compute the amount of space available before the current start of data in
* an mbuf.
*
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 0696edd..bc16acf 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -693,6 +693,8 @@ int vn_vget_ino(struct vnode *vp, ino_t ino, int lkflags,
struct vnode **rvp);
int vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio);
+int vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,
+ struct uio *uio);
#define vn_rangelock_unlock(vp, cookie) \
rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp))
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index 0e29be87f..a5e99d9 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -418,7 +418,7 @@ retry:
if (seqcount && (vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
error = cluster_read(vp, ip->i_size, lbn,
(int)fs->fs_bsize, NOCRED,
- MAXBSIZE, seqcount, &nbp);
+ MAXBSIZE, seqcount, 0, &nbp);
} else {
error = bread(vp, lbn, (int)fs->fs_bsize, NOCRED, &nbp);
}
@@ -679,9 +679,9 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
if (osize < fs->fs_bsize && osize > 0) {
UFS_LOCK(ump);
error = ffs_realloccg(ip, nb, dp->di_db[nb],
- ffs_blkpref_ufs2(ip, lastlbn, (int)nb,
- &dp->di_db[0]), osize, (int)fs->fs_bsize,
- flags, cred, &bp);
+ ffs_blkpref_ufs2(ip, lastlbn, (int)nb,
+ &dp->di_db[0]), osize, (int)fs->fs_bsize,
+ flags, cred, &bp);
if (error)
return (error);
if (DOINGSOFTDEP(vp))
@@ -733,7 +733,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
UFS_LOCK(ump);
error = ffs_realloccg(ip, lbn, dp->di_db[lbn],
ffs_blkpref_ufs2(ip, lbn, (int)lbn,
- &dp->di_db[0]), osize, nsize, flags,
+ &dp->di_db[0]), osize, nsize, flags,
cred, &bp);
if (error)
return (error);
@@ -966,7 +966,7 @@ retry:
if (seqcount && (vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
error = cluster_read(vp, ip->i_size, lbn,
(int)fs->fs_bsize, NOCRED,
- MAXBSIZE, seqcount, &nbp);
+ MAXBSIZE, seqcount, 0, &nbp);
} else {
error = bread(vp, lbn, (int)fs->fs_bsize, NOCRED, &nbp);
}
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index c065187..c310ece 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -519,7 +519,8 @@ ffs_read(ap)
* doing sequential access.
*/
error = cluster_read(vp, ip->i_size, lbn,
- size, NOCRED, blkoffset + uio->uio_resid, seqcount, &bp);
+ size, NOCRED, blkoffset + uio->uio_resid,
+ seqcount, 0, &bp);
} else if (seqcount > 1) {
/*
* If we are NOT allowed to cluster, then
@@ -784,7 +785,8 @@ ffs_write(ap)
} else if (xfersize + blkoffset == fs->fs_bsize) {
if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
bp->b_flags |= B_CLUSTEROK;
- cluster_write(vp, bp, ip->i_size, seqcount);
+ cluster_write(vp, bp, ip->i_size, seqcount,
+ 0);
} else {
bawrite(bp);
}
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index f69b1f9..574c59c 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1554,6 +1554,7 @@ relock:
cache_purge(fvp);
if (tvp)
cache_purge(tvp);
+ cache_purge_negative(tdvp);
unlockout:
vput(fdvp);
diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h
index d06c22b..c64a549 100644
--- a/sys/vm/pmap.h
+++ b/sys/vm/pmap.h
@@ -108,6 +108,8 @@ void pmap_clear_modify(vm_page_t m);
void pmap_clear_reference(vm_page_t m);
void pmap_copy(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t);
void pmap_copy_page(vm_page_t, vm_page_t);
+void pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset,
+ vm_page_t mb[], vm_offset_t b_offset, int xfersize);
void pmap_enter(pmap_t, vm_offset_t, vm_prot_t, vm_page_t,
vm_prot_t, boolean_t);
void pmap_enter_object(pmap_t pmap, vm_offset_t start,
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index 9f602b7..64a2ebb 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -85,11 +85,11 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <vm/uma.h>
-vm_map_t kernel_map=0;
-vm_map_t kmem_map=0;
-vm_map_t exec_map=0;
+vm_map_t kernel_map;
+vm_map_t kmem_map;
+vm_map_t exec_map;
vm_map_t pipe_map;
-vm_map_t buffer_map=0;
+vm_map_t buffer_map;
const void *zero_region;
CTASSERT((ZERO_REGION_SIZE & PAGE_MASK) == 0);
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 5e331ee..a0340af 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -900,7 +900,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
}
bp = getpbuf(&vnode_pbuf_freecnt);
- kva = (vm_offset_t) bp->b_data;
+ kva = (vm_offset_t)bp->b_data;
/*
* and map the pages to be read into the kva
diff --git a/sys/xdr/xdr_mbuf.c b/sys/xdr/xdr_mbuf.c
index b2394bc..690c2d2 100644
--- a/sys/xdr/xdr_mbuf.c
+++ b/sys/xdr/xdr_mbuf.c
@@ -123,7 +123,7 @@ xdrmbuf_getall(XDR *xdrs)
if (m)
m_adj(m, xdrs->x_handy);
else
- MGET(m, M_WAITOK, MT_DATA);
+ m = m_get(M_WAITOK, MT_DATA);
return (m);
}
@@ -228,9 +228,10 @@ xdrmbuf_putbytes(XDR *xdrs, const char *addr, u_int len)
if (xdrs->x_handy == m->m_len && M_TRAILINGSPACE(m) == 0) {
if (!m->m_next) {
- MGET(n, M_WAITOK, m->m_type);
if (m->m_flags & M_EXT)
- MCLGET(n, M_WAITOK);
+ n = m_getcl(M_WAITOK, m->m_type, 0);
+ else
+ n = m_get(M_WAITOK, m->m_type);
m->m_next = n;
}
m = m->m_next;
diff --git a/tools/regression/bin/sh/builtins/wait6.0 b/tools/regression/bin/sh/builtins/wait6.0
new file mode 100644
index 0000000..20e3c68
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/wait6.0
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+wait --
diff --git a/tools/regression/bin/sh/builtins/wait7.0 b/tools/regression/bin/sh/builtins/wait7.0
new file mode 100644
index 0000000..0fb092f
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/wait7.0
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+: &
+wait -- $!
diff --git a/tools/regression/pjdfstest/tests/misc.sh b/tools/regression/pjdfstest/tests/misc.sh
index 0d3ce35..8978b5f 100644
--- a/tools/regression/pjdfstest/tests/misc.sh
+++ b/tools/regression/pjdfstest/tests/misc.sh
@@ -89,7 +89,7 @@ todo()
namegen()
{
- echo "pjdfstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl md5`"
+ echo "pjdfstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`"
}
namegen_len()
@@ -98,7 +98,7 @@ namegen_len()
name=""
while :; do
- namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | openssl md5`"
+ namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`"
name="${name}${namepart}"
curlen=`printf "%s" "${name}" | wc -c`
[ ${curlen} -lt ${len} ] || break
diff --git a/tools/regression/security/cap_test/cap_test_capabilities.c b/tools/regression/security/cap_test/cap_test_capabilities.c
index b6423f8..9f5dde8 100644
--- a/tools/regression/security/cap_test/cap_test_capabilities.c
+++ b/tools/regression/security/cap_test/cap_test_capabilities.c
@@ -184,19 +184,19 @@ try_file_ops(int filefd, int dirfd, cap_rights_t rights)
MAP_SHARED, fd_cap, 0);
CHECK_MMAP_RESULT(CAP_MMAP_RWX);
- /* TODO: openat(O_APPEND) */
ret = openat(dfd_cap, "cap_create", O_CREAT | O_RDONLY, 0600);
CHECK_RESULT(openat(O_CREATE | O_RDONLY),
CAP_CREATE | CAP_READ | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
CHECK(ret == -1 || unlinkat(dirfd, "cap_create", 0) == 0);
- ret = openat(dfd_cap, "cap_create", O_CREAT | O_WRONLY, 0600);
- CHECK_RESULT(openat(O_CREATE | O_WRONLY),
+ ret = openat(dfd_cap, "cap_create", O_CREAT | O_WRONLY | O_APPEND,
+ 0600);
+ CHECK_RESULT(openat(O_CREATE | O_WRONLY | O_APPEND),
CAP_CREATE | CAP_WRITE | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
CHECK(ret == -1 || unlinkat(dirfd, "cap_create", 0) == 0);
- ret = openat(dfd_cap, "cap_create", O_CREAT | O_RDWR, 0600);
- CHECK_RESULT(openat(O_CREATE | O_RDWR),
+ ret = openat(dfd_cap, "cap_create", O_CREAT | O_RDWR | O_APPEND, 0600);
+ CHECK_RESULT(openat(O_CREATE | O_RDWR | O_APPEND),
CAP_CREATE | CAP_READ | CAP_WRITE | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
CHECK(ret == -1 || unlinkat(dirfd, "cap_create", 0) == 0);
@@ -207,28 +207,28 @@ try_file_ops(int filefd, int dirfd, cap_rights_t rights)
ret = openat(dirfd, "cap_fsync", O_CREAT, 0600);
CHECK(ret >= 0);
CHECK(close(ret) == 0);
- ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_RDONLY, 0600);
+ ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_RDONLY);
CHECK_RESULT(openat(O_FSYNC | O_RDONLY),
CAP_FSYNC | CAP_READ | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
- ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_WRONLY, 0600);
- CHECK_RESULT(openat(O_FSYNC | O_WRONLY),
+ ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_WRONLY | O_APPEND);
+ CHECK_RESULT(openat(O_FSYNC | O_WRONLY | O_APPEND),
CAP_FSYNC | CAP_WRITE | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
- ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_RDWR, 0600);
- CHECK_RESULT(openat(O_FSYNC | O_RDWR),
+ ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_RDWR | O_APPEND);
+ CHECK_RESULT(openat(O_FSYNC | O_RDWR | O_APPEND),
CAP_FSYNC | CAP_READ | CAP_WRITE | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
- ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_RDONLY, 0600);
+ ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_RDONLY);
CHECK_RESULT(openat(O_SYNC | O_RDONLY),
CAP_FSYNC | CAP_READ | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
- ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_WRONLY, 0600);
- CHECK_RESULT(openat(O_SYNC | O_WRONLY),
+ ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_WRONLY | O_APPEND);
+ CHECK_RESULT(openat(O_SYNC | O_WRONLY | O_APPEND),
CAP_FSYNC | CAP_WRITE | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
- ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_RDWR, 0600);
- CHECK_RESULT(openat(O_SYNC | O_RDWR),
+ ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_RDWR | O_APPEND);
+ CHECK_RESULT(openat(O_SYNC | O_RDWR | O_APPEND),
CAP_FSYNC | CAP_READ | CAP_WRITE | CAP_LOOKUP, ret >= 0);
CHECK(ret == -1 || close(ret) == 0);
CHECK(unlinkat(dirfd, "cap_fsync", 0) == 0);
@@ -253,6 +253,39 @@ try_file_ops(int filefd, int dirfd, cap_rights_t rights)
CHECK(ret == -1 || close(ret) == 0);
CHECK(unlinkat(dirfd, "cap_ftruncate", 0) == 0);
+ ret = openat(dfd_cap, "cap_create", O_CREAT | O_WRONLY, 0600);
+ CHECK_RESULT(openat(O_CREATE | O_WRONLY),
+ CAP_CREATE | CAP_WRITE | CAP_SEEK | CAP_LOOKUP, ret >= 0);
+ CHECK(ret == -1 || close(ret) == 0);
+ CHECK(ret == -1 || unlinkat(dirfd, "cap_create", 0) == 0);
+ ret = openat(dfd_cap, "cap_create", O_CREAT | O_RDWR, 0600);
+ CHECK_RESULT(openat(O_CREATE | O_RDWR),
+ CAP_CREATE | CAP_READ | CAP_WRITE | CAP_SEEK | CAP_LOOKUP,
+ ret >= 0);
+ CHECK(ret == -1 || close(ret) == 0);
+ CHECK(ret == -1 || unlinkat(dirfd, "cap_create", 0) == 0);
+
+ ret = openat(dirfd, "cap_fsync", O_CREAT, 0600);
+ CHECK(ret >= 0);
+ CHECK(close(ret) == 0);
+ ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_WRONLY);
+ CHECK_RESULT(openat(O_FSYNC | O_WRONLY),
+ CAP_FSYNC | CAP_WRITE | CAP_SEEK | CAP_LOOKUP, ret >= 0);
+ CHECK(ret == -1 || close(ret) == 0);
+ ret = openat(dfd_cap, "cap_fsync", O_FSYNC | O_RDWR);
+ CHECK_RESULT(openat(O_FSYNC | O_RDWR),
+ CAP_FSYNC | CAP_READ | CAP_WRITE | CAP_SEEK | CAP_LOOKUP, ret >= 0);
+ CHECK(ret == -1 || close(ret) == 0);
+ ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_WRONLY);
+ CHECK_RESULT(openat(O_SYNC | O_WRONLY),
+ CAP_FSYNC | CAP_WRITE | CAP_SEEK | CAP_LOOKUP, ret >= 0);
+ CHECK(ret == -1 || close(ret) == 0);
+ ret = openat(dfd_cap, "cap_fsync", O_SYNC | O_RDWR);
+ CHECK_RESULT(openat(O_SYNC | O_RDWR),
+ CAP_FSYNC | CAP_READ | CAP_WRITE | CAP_SEEK | CAP_LOOKUP, ret >= 0);
+ CHECK(ret == -1 || close(ret) == 0);
+ CHECK(unlinkat(dirfd, "cap_fsync", 0) == 0);
+
/*
* Note: this is not expected to work over NFS.
*/
diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h
index f602707..53cb69f 100644
--- a/usr.bin/find/find.h
+++ b/usr.bin/find/find.h
@@ -88,7 +88,7 @@ typedef struct _plandata {
nlink_t _l_data; /* link count */
short _d_data; /* level depth (-1 to N) */
off_t _o_data; /* file size */
- time_t _t_data; /* time value */
+ struct timespec _t_data; /* time value */
uid_t _u_data; /* uid */
short _mt_data; /* mount flags */
struct _plandata *_p_data[2]; /* PLAN trees */
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 61d61cb..7f16a8f 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -238,7 +238,7 @@ nextarg(OPTION *option, char ***argvp)
*/
#define TIME_CORRECT(p) \
if (((p)->flags & F_ELG_MASK) == F_LESSTHAN) \
- ++((p)->t_data);
+ ++((p)->t_data.tv_sec);
/*
* -[acm]min n functions --
@@ -255,16 +255,16 @@ f_Xmin(PLAN *plan, FTSENT *entry)
{
if (plan->flags & F_TIME_C) {
COMPARE((now - entry->fts_statp->st_ctime +
- 60 - 1) / 60, plan->t_data);
+ 60 - 1) / 60, plan->t_data.tv_sec);
} else if (plan->flags & F_TIME_A) {
COMPARE((now - entry->fts_statp->st_atime +
- 60 - 1) / 60, plan->t_data);
+ 60 - 1) / 60, plan->t_data.tv_sec);
} else if (plan->flags & F_TIME_B) {
COMPARE((now - entry->fts_statp->st_birthtime +
- 60 - 1) / 60, plan->t_data);
+ 60 - 1) / 60, plan->t_data.tv_sec);
} else {
COMPARE((now - entry->fts_statp->st_mtime +
- 60 - 1) / 60, plan->t_data);
+ 60 - 1) / 60, plan->t_data.tv_sec);
}
}
@@ -278,7 +278,8 @@ c_Xmin(OPTION *option, char ***argvp)
ftsoptions &= ~FTS_NOSTAT;
new = palloc(option);
- new->t_data = find_parsenum(new, option->name, nmins, NULL);
+ new->t_data.tv_sec = find_parsenum(new, option->name, nmins, NULL);
+ new->t_data.tv_nsec = 0;
TIME_CORRECT(new);
return new;
}
@@ -309,9 +310,9 @@ f_Xtime(PLAN *plan, FTSENT *entry)
xtime = entry->fts_statp->st_mtime;
if (plan->flags & F_EXACTTIME)
- COMPARE(now - xtime, plan->t_data);
+ COMPARE(now - xtime, plan->t_data.tv_sec);
else
- COMPARE((now - xtime + 86400 - 1) / 86400, plan->t_data);
+ COMPARE((now - xtime + 86400 - 1) / 86400, plan->t_data.tv_sec);
}
PLAN *
@@ -324,7 +325,8 @@ c_Xtime(OPTION *option, char ***argvp)
ftsoptions &= ~FTS_NOSTAT;
new = palloc(option);
- new->t_data = find_parsetime(new, option->name, value);
+ new->t_data.tv_sec = find_parsetime(new, option->name, value);
+ new->t_data.tv_nsec = 0;
if (!(new->flags & F_EXACTTIME))
TIME_CORRECT(new);
return new;
@@ -1152,14 +1154,19 @@ c_name(OPTION *option, char ***argvp)
int
f_newer(PLAN *plan, FTSENT *entry)
{
+ struct timespec ft;
+
if (plan->flags & F_TIME_C)
- return entry->fts_statp->st_ctime > plan->t_data;
+ ft = entry->fts_statp->st_ctim;
else if (plan->flags & F_TIME_A)
- return entry->fts_statp->st_atime > plan->t_data;
+ ft = entry->fts_statp->st_atim;
else if (plan->flags & F_TIME_B)
- return entry->fts_statp->st_birthtime > plan->t_data;
+ ft = entry->fts_statp->st_birthtim;
else
- return entry->fts_statp->st_mtime > plan->t_data;
+ ft = entry->fts_statp->st_mtim;
+ return (ft.tv_sec > plan->t_data.tv_sec ||
+ (ft.tv_sec == plan->t_data.tv_sec &&
+ ft.tv_nsec > plan->t_data.tv_nsec));
}
PLAN *
@@ -1175,20 +1182,22 @@ c_newer(OPTION *option, char ***argvp)
new = palloc(option);
/* compare against what */
if (option->flags & F_TIME2_T) {
- new->t_data = get_date(fn_or_tspec);
- if (new->t_data == (time_t) -1)
+ new->t_data.tv_sec = get_date(fn_or_tspec);
+ if (new->t_data.tv_sec == (time_t) -1)
errx(1, "Can't parse date/time: %s", fn_or_tspec);
+ /* Use the seconds only in the comparison. */
+ new->t_data.tv_nsec = 999999999;
} else {
if (stat(fn_or_tspec, &sb))
err(1, "%s", fn_or_tspec);
if (option->flags & F_TIME2_C)
- new->t_data = sb.st_ctime;
+ new->t_data = sb.st_ctim;
else if (option->flags & F_TIME2_A)
- new->t_data = sb.st_atime;
+ new->t_data = sb.st_atim;
else if (option->flags & F_TIME2_B)
- new->t_data = sb.st_birthtime;
+ new->t_data = sb.st_birthtim;
else
- new->t_data = sb.st_mtime;
+ new->t_data = sb.st_mtim;
}
return new;
}
diff --git a/usr.bin/head/head.1 b/usr.bin/head/head.1
index 0e16477..dd12485 100644
--- a/usr.bin/head/head.1
+++ b/usr.bin/head/head.1
@@ -28,7 +28,7 @@
.\" @(#)head.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd June 6, 1993
+.Dd March 16, 2013
.Dt HEAD 1
.Os
.Sh NAME
@@ -57,6 +57,19 @@ where
is the name of the file.
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+To display the first 500 lines of the file
+.Ar foo :
+.Pp
+.Dl $ head -n 500 foo
+.Pp
+.Nm
+can be used in conjunction with
+.Xr tail 1
+in the following way to, for example, display only line 500 from the file
+.Ar foo :
+.Pp
+.Dl $ head -n 500 foo | tail -n 1
.Sh SEE ALSO
.Xr tail 1
.Sh HISTORY
diff --git a/usr.bin/renice/renice.8 b/usr.bin/renice/renice.8
index d6dfa88..052ef13 100644
--- a/usr.bin/renice/renice.8
+++ b/usr.bin/renice/renice.8
@@ -85,13 +85,6 @@ Reset the
interpretation to be (the default) process ID's.
.El
.Pp
-For example,
-.Pp
-.Dl "renice +1 987 -u daemon root -p 32"
-.Pp
-would change the priority of process ID's 987 and 32, and
-all processes owned by users daemon and root.
-.Pp
Users other than the super-user may only alter the priority of
processes they own,
and can only monotonically increase their ``nice value''
@@ -116,6 +109,11 @@ anything negative (to make things go very fast).
.It Pa /etc/passwd
to map user names to user ID's
.El
+.Sh EXAMPLES
+Change the priority of process ID's 987 and 32, and
+all processes owned by users daemon and root.
+.Pp
+.Dl "renice +1 987 -u daemon root -p 32"
.Sh SEE ALSO
.Xr nice 1 ,
.Xr rtprio 1 ,
diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1
index df5ed24..a142482 100644
--- a/usr.bin/script/script.1
+++ b/usr.bin/script/script.1
@@ -178,7 +178,7 @@ and
options first appeared in
.Nx 2.0
and were ported to
-.Fx 10 .
+.Fx 10.0 .
.Sh BUGS
The
.Nm
diff --git a/usr.bin/tail/tail.1 b/usr.bin/tail/tail.1
index d4ec2f9..35866f5 100644
--- a/usr.bin/tail/tail.1
+++ b/usr.bin/tail/tail.1
@@ -31,7 +31,7 @@
.\" @(#)tail.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd June 5, 2009
+.Dd March 16, 2013
.Dt TAIL 1
.Os
.Sh NAME
@@ -147,6 +147,17 @@ is the name of the file unless
flag is specified.
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+To display the last 500 lines of the file
+.Ar foo :
+.Pp
+.Dl $ tail -n 500 foo
+.Pp
+Keep
+.Pa /var/log/messages
+open, displaying to the standard output anything appended to the file:
+.Pp
+.Dl $ tail -f /var/log/messages
.Sh SEE ALSO
.Xr cat 1 ,
.Xr head 1 ,
diff --git a/usr.bin/unvis/Makefile b/usr.bin/unvis/Makefile
index 27fea4b..59528ef 100644
--- a/usr.bin/unvis/Makefile
+++ b/usr.bin/unvis/Makefile
@@ -3,4 +3,6 @@
PROG= unvis
+.PATH: ${.CURDIR}/../../contrib/unvis
+
.include <bsd.prog.mk>
diff --git a/usr.bin/vis/Makefile b/usr.bin/vis/Makefile
index 8f83a14..5d860de 100644
--- a/usr.bin/vis/Makefile
+++ b/usr.bin/vis/Makefile
@@ -1,6 +1,10 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
+# $FreeBSD$
PROG= vis
SRCS= vis.c foldit.c
+.PATH: ${.CURDIR}/../../contrib/vis
+CFLAGS+= -I${.CURDIR}/../../contrib/vis
+
.include <bsd.prog.mk>
diff --git a/usr.bin/vis/vis.c b/usr.bin/vis/vis.c
deleted file mode 100644
index 71b6404..0000000
--- a/usr.bin/vis/vis.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-
-__FBSDID("$FreeBSD$");
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif
-
-#ifndef lint
-static const char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93";
-#endif
-
-#include <err.h>
-#include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <vis.h>
-
-#include "extern.h"
-
-static int eflags, fold, foldwidth = 80, none, markeol;
-#ifdef DEBUG
-static int debug;
-#endif
-
-static void process(FILE *);
-static void usage(void);
-
-int
-main(int argc, char *argv[])
-{
- FILE *fp;
- int ch;
-
- (void) setlocale(LC_CTYPE, "");
-
- while ((ch = getopt(argc, argv, "nwctsobfF:ld")) != -1)
- switch((char)ch) {
- case 'n':
- none++;
- break;
- case 'w':
- eflags |= VIS_WHITE;
- break;
- case 'c':
- eflags |= VIS_CSTYLE;
- break;
- case 't':
- eflags |= VIS_TAB;
- break;
- case 's':
- eflags |= VIS_SAFE;
- break;
- case 'o':
- eflags |= VIS_OCTAL;
- break;
- case 'b':
- eflags |= VIS_NOSLASH;
- break;
- case 'F':
- if ((foldwidth = atoi(optarg))<5)
- errx(1, "can't fold lines to less than 5 cols");
- /*FALLTHROUGH*/
- case 'f':
- fold++; /* fold output lines to 80 cols */
- break; /* using hidden newline */
- case 'l':
- markeol++; /* mark end of line with \$ */
- break;
-#ifdef DEBUG
- case 'd':
- debug++;
- break;
-#endif
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (*argv)
- while (*argv) {
- if ((fp=fopen(*argv, "r")) != NULL)
- process(fp);
- else
- warn("%s", *argv);
- argv++;
- }
- else
- process(stdin);
- exit(0);
-}
-
-
-static void
-usage(void)
-{
-#ifdef DEBUG
- fprintf(stderr, "usage: vis [-cbflnostwd] [-F foldwidth] [file ...]\n");
-#else
- fprintf(stderr, "usage: vis [-cbflnostw] [-F foldwidth] [file ...]\n");
-#endif
- exit(1);
-}
-
-static void
-process(FILE *fp)
-{
- static int col = 0;
- static char dummy[] = "\0";
- char *cp = dummy+1; /* so *(cp-1) starts out != '\n' */
- int c, rachar;
- char buff[5];
-
- c = getc(fp);
- while (c != EOF) {
- rachar = getc(fp);
- if (none) {
- cp = buff;
- *cp++ = c;
- if (c == '\\')
- *cp++ = '\\';
- *cp = '\0';
- } else if (markeol && c == '\n') {
- cp = buff;
- if ((eflags & VIS_NOSLASH) == 0)
- *cp++ = '\\';
- *cp++ = '$';
- *cp++ = '\n';
- *cp = '\0';
- } else
- (void) vis(buff, (char)c, eflags, (char)rachar);
-
- cp = buff;
- if (fold) {
-#ifdef DEBUG
- if (debug)
- printf("<%02d,", col);
-#endif
- col = foldit(cp, col, foldwidth);
-#ifdef DEBUG
- if (debug)
- printf("%02d>", col);
-#endif
- }
- do {
- putchar(*cp);
- } while (*++cp);
- c = rachar;
- }
- /*
- * terminate partial line with a hidden newline
- */
- if (fold && *(cp-1) != '\n')
- printf("\\\n");
-}
diff --git a/usr.sbin/ac/ac.8 b/usr.sbin/ac/ac.8
index 26667d8..954d9f7 100644
--- a/usr.sbin/ac/ac.8
+++ b/usr.sbin/ac/ac.8
@@ -105,17 +105,6 @@ hand.
No login or connect time accounting is performed if
.Pa /var/log/utx.log
does not exist.
-.Pp
-For example,
-.Bd -literal -offset indent
-ac -p -t "ttyd*" > modems
-ac -p -t "!ttyd*" > other
-.Ed
-.Pp
-allows times recorded in
-.Pa modems
-to be charged out at a different rate than
-.Pa other .
.Sh FILES
.Bl -tag -width /var/log/utx.log -compact
.It Pa /var/log/utx.log
@@ -123,6 +112,15 @@ connect time accounting file
.El
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+Allow times recorded in
+.Pa modems
+to be charged out at a different rate than
+.Pa other :
+.Bd -literal -offset indent
+ac -p -t "ttyd*" > modems
+ac -p -t "!ttyd*" > other
+.Ed
.Sh SEE ALSO
.Xr login 1 ,
.Xr getutxent 3 ,
diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c
index 11647d6..7129f6b 100644
--- a/usr.sbin/bhyve/pci_virtio_net.c
+++ b/usr.sbin/bhyve/pci_virtio_net.c
@@ -170,7 +170,7 @@ pci_vtnet_iosize(struct pci_devinst *pi)
static int
hq_num_avail(struct vring_hqueue *hq)
{
- int ndesc;
+ uint16_t ndesc;
/*
* We're just computing (a-b) in GF(216).
OpenPOWER on IntegriCloud