This commit is contained in:
attilio 2013-03-17 23:39:52 +00:00
commit d500d6361a
202 changed files with 3456 additions and 2791 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ,

View File

@ -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 ,

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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",

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 10, 2013
.Dd March 1, 2013
.Dt ZFS 8
.Os
.Sh NAME

View File

@ -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.

View File

@ -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));

View File

@ -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.

View File

@ -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) */

View File

@ -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 .

View File

@ -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 BELL L'\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 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 9
#define MAXEXTRAS 10
#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)
#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,27 +156,97 @@ 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;
}
/*
* Output single byte of multibyte character.
*/
static wchar_t *
do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
{
if (flags & VIS_CSTYLE) {
switch (c) {
case L'\n':
*dst++ = L'\\'; *dst++ = L'n';
return dst;
case L'\r':
*dst++ = L'\\'; *dst++ = L'r';
return dst;
case L'\b':
*dst++ = L'\\'; *dst++ = L'b';
return dst;
case BELL:
*dst++ = L'\\'; *dst++ = L'a';
return dst;
case L'\v':
*dst++ = L'\\'; *dst++ = L'v';
return dst;
case L'\t':
*dst++ = L'\\'; *dst++ = L't';
return dst;
case L'\f':
*dst++ = L'\\'; *dst++ = L'f';
return dst;
case L' ':
*dst++ = L'\\'; *dst++ = L's';
return dst;
case L'\0':
*dst++ = L'\\'; *dst++ = L'0';
if (iswoctal(nextc)) {
*dst++ = L'0';
*dst++ = L'0';
}
return dst;
default:
if (iswgraph(c)) {
*dst++ = L'\\';
*dst++ = c;
return dst;
}
}
}
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 ((flags & VIS_NOSLASH) == 0)
*dst++ = L'\\';
if (c & 0200) {
c &= 0177;
*dst++ = L'M';
}
if (iswcntrl(c)) {
*dst++ = L'^';
if (c == 0177)
*dst++ = L'?';
else
*dst++ = c + L'@';
} else {
*dst++ = L'-';
*dst++ = c;
}
}
return dst;
}
@ -179,284 +254,350 @@ do_mvis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
* This is do_vis, the central code of vis.
* dst: Pointer to the destination buffer
* c: Character to encode
* flag: Flag word
* flags: Flags word
* nextc: The character following 'c'
* extra: Pointer to the list of extra characters to be
* backslash-protected.
*/
static char *
do_svis(char *dst, size_t *dlen, int c, int flag, int nextc, const char *extra)
static wchar_t *
do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
{
int isextra;
size_t odlen = dlen ? *dlen : 0;
int iswextra, i, shft;
uint64_t bmsk, wmsk;
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);
iswextra = wcschr(extra, c) != NULL;
if (!iswextra && (iswgraph(c) || iswwhite(c) ||
((flags & VIS_SAFE) && iswsafe(c)))) {
*dst++ = c;
return dst;
}
if (flag & VIS_CSTYLE) {
HAVE(2);
switch (c) {
case '\n':
*dst++ = '\\'; *dst++ = 'n';
return dst;
case '\r':
*dst++ = '\\'; *dst++ = 'r';
return dst;
case '\b':
*dst++ = '\\'; *dst++ = 'b';
return dst;
case BELL:
*dst++ = '\\'; *dst++ = 'a';
return dst;
case '\v':
*dst++ = '\\'; *dst++ = 'v';
return dst;
case '\t':
*dst++ = '\\'; *dst++ = 't';
return dst;
case '\f':
*dst++ = '\\'; *dst++ = 'f';
return dst;
case ' ':
*dst++ = '\\'; *dst++ = 's';
return dst;
case '\0':
*dst++ = '\\'; *dst++ = '0';
if (isoctal(nextc)) {
HAVE(2);
*dst++ = '0';
*dst++ = '0';
}
return dst;
default:
if (isgraph(c)) {
*dst++ = '\\'; *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';
} else {
if ((flag & VIS_NOSLASH) == 0) {
HAVE(1);
*dst++ = '\\';
}
if (c & 0200) {
HAVE(1);
c &= 0177; *dst++ = 'M';
}
if (iscntrl(c)) {
HAVE(2);
*dst++ = '^';
if (c == 0177)
*dst++ = '?';
else
*dst++ = c + '@';
} else {
HAVE(2);
*dst++ = '-'; *dst++ = c;
}
/* 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;
out:
*dlen = odlen;
return NULL;
}
typedef char *(*visfun_t)(char *, size_t *, int, int, int, const char *);
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';
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';
return dst;
}
char *
svis(char *dst, int c, int flag, int nextc, const char *extra)
{
return isnvis(dst, NULL, c, flag, nextc, extra);
}
char *
snvis(char *dst, size_t dlen, int c, int flag, int nextc, const char *extra)
{
return isnvis(dst, &dlen, c, flag, nextc, extra);
}
/*
* 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;
int clen = 0, cerr = 0, error = -1, i, shft;
ssize_t mbslength, maxolen;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
_DIAGASSERT(extra != NULL);
MAKEEXTRALIST(flag, nextra, extra);
if (!nextra) {
*dst = '\0'; /* can't create nextra, return "" */
return 0;
}
f = getvisfun(flag);
for (start = dst; (c = *src++) != '\0'; /* empty */) {
dst = (*f)(dst, dlen, c, flag, *src, nextra);
if (dst == NULL) {
errno = ENOSPC;
return -1;
}
}
free(nextra);
if (dlen && *dlen == 0) {
errno = ENOSPC;
_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;
}
*dst = '\0';
return (int)(dst - start);
}
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;
int
strsvis(char *dst, const char *csrc, int flag, const char *extra)
{
return istrsnvis(dst, NULL, csrc, flag, extra);
}
int
strsnvis(char *dst, size_t dlen, const char *csrc, int flag, const char *extra)
{
return istrsnvis(dst, &dlen, csrc, flag, extra);
}
static int
istrsnvisx(char *dst, size_t *dlen, const char *csrc, size_t len, int flag,
const char *extra)
{
unsigned char c;
char *start;
char *nextra = NULL;
const unsigned char *src = (const unsigned char *)csrc;
visfun_t f;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
_DIAGASSERT(extra != NULL);
MAKEEXTRALIST(flag, nextra, extra);
if (! nextra) {
/* Convert extra argument to list of characters for this mode. */
extra = makeextralist(flags, mbextra);
if (!extra) {
if (dlen && *dlen == 0) {
errno = ENOSPC;
return -1;
goto out;
}
*dst = '\0'; /* can't create nextra, return "" */
return 0;
*mbdst = '\0'; /* can't create extra, return "" */
error = 0;
goto out;
}
f = getvisfun(flag);
/* 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, dlen, c, flag, len > 1 ? *src : '\0', nextra);
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
#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)
{
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;
}
char *
snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra)
{
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;
}
int
strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
return istrsnvisx(dst, NULL, csrc, len, flag, extra);
return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, mbextra, NULL);
}
int
strsnvisx(char *dst, size_t dlen, const char *csrc, size_t len, int flag,
const char *extra)
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
{
return istrsnvisx(dst, &dlen, csrc, len, flag, extra);
return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, mbextra, NULL);
}
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
strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra)
{
return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
}
int
strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra, int *cerr_ptr)
{
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.
*/
int
strvis(char *mbdst, const char *mbsrc, int flags)
{
return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, "", NULL);
}
int
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, "", NULL);
}
/*
* 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 bytes from src into dst.
* Strvisx encodes exactly len characters 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
strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
{
return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL);
}
int
strvis(char *dst, const char *src, int flag)
strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
{
return istrnvis(dst, NULL, src, flag);
return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL);
}
int
strnvis(char *dst, size_t dlen, const char *src, int flag)
strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
int *cerr_ptr)
{
return istrnvis(dst, &dlen, src, flag);
return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
}
static int
istrnvisx(char *dst, size_t *dlen, const char *src, size_t len, 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 = istrsnvisx(dst, dlen, src, len, flag, extra);
free(extra);
return rv;
}
int
strvisx(char *dst, const char *src, size_t len, int flag)
{
return istrnvisx(dst, NULL, src, len, flag);
}
int
strnvisx(char *dst, size_t dlen, const char *src, size_t len, int flag)
{
return istrnvisx(dst, &dlen, src, len, flag);
}
#endif

View File

@ -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 *);

View File

@ -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

View File

@ -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 -

View File

@ -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

View File

@ -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).
#

View File

@ -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.
#

View File

@ -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

View File

@ -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

View File

@ -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

6
contrib/unvis/Makefile Normal file
View File

@ -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>

View File

@ -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 .

View File

@ -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);
}

7
contrib/vis/Makefile Normal file
View File

@ -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>

39
contrib/vis/extern.h Normal file
View File

@ -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);

View File

@ -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 @@ foldit(char *chunk, int col, int max)
col++;
}
if (col > (max - 2)) {
printf("\\\n");
printf(flags & VIS_MIMESTYLE ? "=\n" : "\\\n");
col = 0;
goto again;
}
}
cp++;
}
return (col);

View File

@ -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 .

276
contrib/vis/vis.c Normal file
View File

@ -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");
}

View File

@ -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

View File

@ -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

View File

@ -391,10 +391,12 @@ FBSD_1.3 {
pwcache_userdb;
pwcache_groupdb;
snvis;
strenvisx;
strnunvis;
strnunvisx;
strnvis;
strnvisx;
strsenvisx;
strsnvis;
strsnvisx;
strsvis;

View File

@ -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 .

View File

@ -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" },
};

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -84,6 +75,9 @@ usage(void)
fprintf(stderr,
" %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());
@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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");
}
} else
if (cap_ioctls_limit(res->hr_localfd, geomcmds,
sizeof(geomcmds) / sizeof(geomcmds[0])) == -1) {
pjdlog_errno(LOG_ERR,
"Unable to limit allowed GEOM ioctls");
}
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.

View File

@ -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;

View File

@ -525,7 +525,6 @@ MAN= aac.4 \
vge.4 \
viapm.4 \
${_viawd.4} \
vinum.4 \
${_virtio.4} \
${_virtio_balloon.4} \
${_virtio_blk.4} \

View File

@ -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.

View File

@ -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

View File

@ -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 ,

File diff suppressed because it is too large Load Diff

View File

@ -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
------------------------

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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");

View File

@ -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

View File

@ -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 */

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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)

View File

@ -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)

View File

@ -97,6 +97,7 @@ ASENTRY_NP(irq_entry)
DO_AST
PULLFRAMEFROMSVCANDEXIT
movs pc, lr /* Exit */
END(irq_entry)
.data
.align 0

View File

@ -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 */

View File

@ -3312,6 +3312,45 @@ pmap_copy_page_generic(vm_paddr_t src, vm_paddr_t dst)
mtx_unlock(&cmtx);
}
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)
{

View File

@ -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

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