summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/alpha/gen/rfork_thread.S65
-rw-r--r--lib/libc/gen/setproctitle.c147
-rw-r--r--lib/libc/i386/gen/rfork_thread.S112
-rw-r--r--sys/boot/pc98/boot0.5/Makefile25
-rw-r--r--sys/boot/pc98/boot0.5/boot.s174
-rw-r--r--sys/boot/pc98/boot0.5/start.s58
-rw-r--r--sys/boot/pc98/boot0.5/support.s94
-rw-r--r--sys/boot/pc98/boot0.5/syscons.s253
-rw-r--r--sys/boot/pc98/boot0/Makefile20
-rw-r--r--sys/boot/pc98/boot0/boot0.s108
-rw-r--r--sys/modules/sound/driver/solo/Makefile8
-rw-r--r--sys/vm/phys_pager.c182
-rw-r--r--usr.bin/truncate/truncate.1154
-rw-r--r--usr.sbin/boot98cfg/Makefile6
-rw-r--r--usr.sbin/boot98cfg/boot98cfg.898
-rw-r--r--usr.sbin/boot98cfg/boot98cfg.c255
16 files changed, 1759 insertions, 0 deletions
diff --git a/lib/libc/alpha/gen/rfork_thread.S b/lib/libc/alpha/gen/rfork_thread.S
new file mode 100644
index 000000000000..ff0ed2c5acc2
--- /dev/null
+++ b/lib/libc/alpha/gen/rfork_thread.S
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include "SYS.h"
+#include <sys/syscall.h>
+/* #include <machine/pal.h> */
+
+/*
+ * This is pretty evil and based mostly on examples from other syscall
+ * stubs and code that gcc generated. Correctness is uncertain, but it
+ * seems to work quite happily.
+ */
+LEAF(rfork_thread, 1)
+ br gp,L1 /* XXX profiling */
+L1:
+ LDGP(pv)
+ lda sp,-16(sp)
+ stq ra,0(sp)
+ mov a3,a5
+ CALLSYS_ERROR(rfork)
+ beq v0,$child
+ addl v0,zero,v0
+ ldq ra,0(sp)
+ lda sp,16(sp)
+ RET
+$child:
+ mov a1,sp
+ lda sp,-16(sp)
+ stq zero,0(sp)
+ mov a5,a0
+ mov a2,t12
+ jsr ra,(t12),0
+ ldgp gp,0(ra)
+ mov v0,a0
+#ifdef SYS_exit
+ CALLSYS_NOERROR(exit)
+#else
+ CALLSYS_NOERROR(sys_exit)
+#endif
+END(rfork_thread)
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c
new file mode 100644
index 000000000000..d0f224bff86d
--- /dev/null
+++ b/lib/libc/gen/setproctitle.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 1995 Peter Wemm <peter@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice immediately at the beginning of the file, without modification,
+ * 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. Absolutely no warranty of function or purpose is made by the author
+ * Peter Wemm.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/exec.h>
+#include <sys/sysctl.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/*
+ * Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and
+ * in different locations.
+ * 1: old_ps_strings at the very top of the stack.
+ * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack.
+ * 3: ps_strings at the very top of the stack.
+ * This attempts to support a kernel built in the #2 and #3 era.
+ */
+
+struct old_ps_strings {
+ char *old_ps_argvstr;
+ int old_ps_nargvstr;
+ char *old_ps_envstr;
+ int old_ps_nenvstr;
+};
+#define OLD_PS_STRINGS ((struct old_ps_strings *) \
+ (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings)))
+
+#include <stdarg.h>
+
+#define SPT_BUFSIZE 2048 /* from other parts of sendmail */
+extern char * __progname; /* is this defined in a .h anywhere? */
+
+void
+setproctitle(const char *fmt, ...)
+{
+ static struct ps_strings *ps_strings;
+ static char buf[SPT_BUFSIZE];
+ static char obuf[SPT_BUFSIZE];
+ static char **oargv, *kbuf;
+ static int oargc = -1;
+ static char *nargv[2] = { buf, NULL };
+ char **nargvp;
+ int nargc;
+ va_list ap;
+ size_t len;
+ unsigned long ul_ps_strings;
+ int oid[4];
+
+ va_start(ap, fmt);
+
+ if (fmt) {
+ buf[sizeof(buf) - 1] = '\0';
+
+ if (fmt[0] == '-') {
+ /* skip program name prefix */
+ fmt++;
+ len = 0;
+ } else {
+ /* print program name heading for grep */
+ (void) snprintf(buf, sizeof(buf), "%s: ", __progname);
+ len = strlen(buf);
+ }
+
+ /* print the argument string */
+ (void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
+
+ nargvp = nargv;
+ nargc = 1;
+ kbuf = buf;
+ } else if (*obuf != '\0') {
+ /* Idea from NetBSD - reset the title on fmt == NULL */
+ nargvp = oargv;
+ nargc = oargc;
+ kbuf = obuf;
+ } else
+ /* Nothing to restore */
+ return;
+
+ va_end(ap);
+
+ /* Set the title into the kernel cached command line */
+ oid[0] = CTL_KERN;
+ oid[1] = KERN_PROC;
+ oid[2] = KERN_PROC_ARGS;
+ oid[3] = getpid();
+ sysctl(oid, 4, 0, 0, kbuf, strlen(kbuf) + 1);
+
+ if (ps_strings == NULL) {
+ len = sizeof(ul_ps_strings);
+ if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL,
+ 0) == -1)
+ ul_ps_strings = PS_STRINGS;
+ ps_strings = (struct ps_strings *)ul_ps_strings;
+ }
+
+ /* PS_STRINGS points to zeroed memory on a style #2 kernel */
+ if (ps_strings->ps_argvstr) {
+ /* style #3 */
+ if (oargc == -1) {
+ /* Record our original args */
+ oargc = ps_strings->ps_nargvstr;
+ oargv = ps_strings->ps_argvstr;
+ for (nargc = len = 0; nargc < oargc; nargc++) {
+ snprintf(obuf + len, sizeof(obuf) - len, "%s%s",
+ len ? " " : "", oargv[nargc]);
+ if (len)
+ len++;
+ len += strlen(oargv[nargc]);
+ if (len >= sizeof(obuf))
+ break;
+ }
+ }
+ ps_strings->ps_nargvstr = nargc;
+ ps_strings->ps_argvstr = nargvp;
+ } else {
+ /* style #2 - we can only restore our first arg :-( */
+ if (*obuf == '\0')
+ strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr,
+ sizeof(obuf) - 1);
+ OLD_PS_STRINGS->old_ps_nargvstr = 1;
+ OLD_PS_STRINGS->old_ps_argvstr = nargvp[0];
+ }
+}
diff --git a/lib/libc/i386/gen/rfork_thread.S b/lib/libc/i386/gen/rfork_thread.S
new file mode 100644
index 000000000000..2d63b67c7d0c
--- /dev/null
+++ b/lib/libc/i386/gen/rfork_thread.S
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * With thanks to John Dyson for the original version of this.
+ */
+
+#include <SYS.h>
+
+/*
+ * 8 12 16 20
+ * rfork_thread(flags, stack_addr, start_fnc, start_arg);
+ *
+ * flags: Flags to rfork system call. See rfork(2).
+ * stack_addr: Top of stack for thread.
+ * start_fnc: Address of thread function to call in child.
+ * start_arg: Argument to pass to the thread function in child.
+ */
+
+ENTRY(rfork_thread)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+
+ /*
+ * Push thread info onto the new thread's stack
+ */
+ movl 12(%ebp), %esi # get stack addr
+
+ subl $4, %esi
+ movl 20(%ebp), %eax # get start argument
+ movl %eax, (%esi)
+
+ subl $4, %esi
+ movl 16(%ebp), %eax # get start thread address
+ movl %eax, (%esi)
+
+ /*
+ * Prepare and execute the thread creation syscall
+ */
+ pushl 8(%ebp)
+ pushl $0
+ leal SYS_rfork, %eax
+ KERNCALL
+ jb 2f
+
+ /*
+ * Check to see if we are in the parent or child
+ */
+ cmpl $0, %edx
+ jnz 1f
+ addl $8, %esp
+ popl %esi
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ .p2align 2
+
+ /*
+ * If we are in the child (new thread), then
+ * set-up the call to the internal subroutine. If it
+ * returns, then call __exit.
+ */
+1:
+ movl %esi,%esp
+ popl %eax
+ call *%eax
+ addl $4, %esp
+
+ /*
+ * Exit system call
+ */
+ pushl %eax
+ pushl $0
+#ifdef SYS_exit
+ leal SYS_exit, %eax
+#else
+ leal SYS_sys_exit, %eax
+#endif
+ KERNCALL
+
+ /*
+ * Branch here if the thread creation fails:
+ */
+2:
+ PIC_PROLOGUE
+ jmp PIC_PLT(HIDENAME(cerror))
diff --git a/sys/boot/pc98/boot0.5/Makefile b/sys/boot/pc98/boot0.5/Makefile
new file mode 100644
index 000000000000..c90c0c052d3f
--- /dev/null
+++ b/sys/boot/pc98/boot0.5/Makefile
@@ -0,0 +1,25 @@
+# $FreeBSD$
+
+PROG= boot0.5
+OBJS= start.o boot.o boot0.5.o disk.o selector.o support.o \
+ syscons.o
+NOMAN=
+STRIP=
+BINDIR?= /boot
+BINMODE= 444
+
+ORG= 0x000
+
+# The size of boot0.5 must be 7168 bytes
+boot0.5: boot0.5.bin
+ cat boot0.5.bin /dev/zero | dd of=boot0.5 bs=1 count=7168
+
+boot0.5.bin: boot0.5.out
+ objcopy -S -O binary boot0.5.out ${.TARGET}
+
+boot0.5.out: ${OBJS}
+ ${LD} -N -e start -Ttext ${ORG} -o ${.TARGET} ${OBJS}
+
+CLEANFILES+= boot0.5.out boot0.5.bin
+
+.include <bsd.prog.mk>
diff --git a/sys/boot/pc98/boot0.5/boot.s b/sys/boot/pc98/boot0.5/boot.s
new file mode 100644
index 000000000000..1a3bfc7c8790
--- /dev/null
+++ b/sys/boot/pc98/boot0.5/boot.s
@@ -0,0 +1,174 @@
+# Copyright (c) KATO Takenori, 1999, 2000.
+#
+# All rights reserved. Unpublished rights reserved under the copyright
+# laws of Japan.
+#
+# 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 as
+# the first lines of this file unmodified.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+ .code16
+
+ .text
+ .global boot
+#
+# Read bootstrap program and jump to it.
+#
+boot:
+ # Step 1: Save parameters
+ movw curdevice, %si
+ movb daua(%si), %al
+ movb %al, b_daua
+ shlw %si
+ movw secsize(%si), %ax
+ movw %ax, b_secsize
+
+ movw curpartition, %si
+ movb partnum(%si), %al # %al = real partition number
+ xorb %ah, %ah
+ movw %ax, b_partn # save real parttion number
+ movb $5, %cl
+ shlw %cl, %si # %si = offset to parttable
+ addw $4, %si
+ movb parttable(%si), %al # IPLS
+ movb %al, b_sector
+ incw %si
+ movb parttable(%si), %al # IPLH
+ movb %al, b_head
+ incw %si # IPLC
+ movw parttable(%si), %ax
+ movw %ax, b_cylinder
+
+ # Step 2: Calculate egment address of bootstrap routine
+ movw $0x1d00, %ax
+ movw b_secsize, %cx
+ shrw %cx
+ shrw %cx
+ subw %cx, %ax
+ subw $0x100, %ax
+ movw %ax, b_bootseg
+
+ # Step 3: Read bootstrap code
+ movb $6, %ah
+ movb b_daua, %al
+ movw b_secsize, %bx
+ shlw %bx # 2 sectors
+ movw b_cylinder, %cx
+ movb b_head, %dh
+ movb b_sector, %dl
+ movw b_bootseg, %es
+ xorw %bp, %bp
+ int $0x1b
+ jc boot_error
+
+ # Step 4: Set DA/UA into BIOS work area
+ xorw %ax, %ax
+ movw %ax, %es
+ movw $0x584, %bx # DISK_BOOT
+ movb b_daua, %dl
+ call write_biosparam
+
+ call sc_clean
+ # Step 5: Set registers
+ # %ah: 00
+ # %al: DA/UA
+ # %bx: Sector size * 2
+ # %cx: cylinder number of boot partition
+ # %si: pointer to partition table
+ movw b_partn, %ax
+ movb $5, %cl
+ shl %cl, %ax # %ax = partition number * 32
+ addw b_secsize, %ax
+ movw %ax, %si # %si = pointer to partition table
+ movw b_cylinder, %cx # %cx = cylinder
+ movb b_head, %dh # %dh = head
+ movb b_sector, %dl # %dl = sector
+ movw b_bootseg, %es # %es = boot segment
+ movb b_daua, %al # %al = DA/UA
+ movw b_secsize, %bx
+ shlw %bx # %bx = sector size * 2
+ cli
+ movw %cs:iniss, %ss # Restore stack pointer
+ movw %cs:inisp, %sp
+ push %es # Boot segment
+ xorw %bp, %bp
+ push %bp # 0
+ movw %ax, %di # Save %ax
+ xorw %ax, %ax
+ movw %ax, %ds # %ds = 0
+ movw %di, %ax # Restore %ax
+ xorb %ah, %ah # %ah = 0
+ xorw %di, %di # %di = 0
+ sti
+
+ # Jump to bootstrap code
+ lret
+ # NOTREACHED
+
+boot_error:
+ ret
+
+#
+# Try to boot from default partition.
+#
+ .global trydefault
+trydefault:
+ movw ndevice, %cx
+ xorw %si, %si
+trydefault_loop:
+ movw %si, curdevice
+ push %cx
+ push %si
+ call read_ipl
+ pop %si
+ pop %cx
+ cmpb $0x80, defpartflag
+ jne nodefpart
+ # Default partition is defined.
+ push %cx
+ movw npartition, %cx
+srch_part:
+ movw %cx, %bx
+ decw %bx
+ movb defpartnum, %al # %al = real partition number
+ cmpb partnum(%bx), %al
+ jne not_match
+ movw %bx, curpartition # Store partition number
+ call boot
+not_match:
+ loop srch_part
+ pop %cx
+nodefpart:
+ incw %si
+ loop trydefault_loop
+ ret
+
+ .data
+b_daua: .byte 0 # DA/UA
+b_head: .byte 0 # SYSH
+b_sector: .byte 0 # SYSS
+b_cylinder: .word 0 # SYSC
+b_bootseg: .word 0
+b_secsize: .word 0
+b_partn: .word 0 # Real partition number
diff --git a/sys/boot/pc98/boot0.5/start.s b/sys/boot/pc98/boot0.5/start.s
new file mode 100644
index 000000000000..b4bd9ade3b78
--- /dev/null
+++ b/sys/boot/pc98/boot0.5/start.s
@@ -0,0 +1,58 @@
+# Copyright (c) KATO Takenori, 1999, 2000.
+#
+# All rights reserved. Unpublished rights reserved under the copyright
+# laws of Japan.
+#
+# 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 as
+# the first lines of this file unmodified.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+ .global start
+ .code16
+
+ .text
+start:
+ cli
+ movw %cs, %ax
+ movw %ax, %ds
+ movw %ss, iniss
+ movw %sp, inisp
+ movw %ax, %ss
+ movw $0xfffe, %sp
+ sti
+ xorw %ax, %ax
+ movw %ax, %es
+ call main
+
+ cli
+ movw %cs:iniss, %ss
+ movw %cs:inisp, %sp
+ sti
+ int $0x1e
+ # NOTREACHED
+ lret
+
+ .data
+ .global iniss, inisp
+iniss: .word 0
+inisp: .word 0
diff --git a/sys/boot/pc98/boot0.5/support.s b/sys/boot/pc98/boot0.5/support.s
new file mode 100644
index 000000000000..65f5a9a63209
--- /dev/null
+++ b/sys/boot/pc98/boot0.5/support.s
@@ -0,0 +1,94 @@
+# Copyright (c) KATO Takenori, 1999, 2000.
+#
+# All rights reserved. Unpublished rights reserved under the copyright
+# laws of Japan.
+#
+# 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 as
+# the first lines of this file unmodified.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+ .code16
+
+ .text
+#
+# Wait 1ms
+#
+ .global wait1ms
+wait1ms:
+ push %cx
+ movw $800, %cx
+wait_loop:
+ outb %al, $0x5f
+ loop wait_loop
+ pop %cx
+ ret
+
+#
+# Read one byte from BIOS parameter block
+# %bx offset
+# %dl value
+#
+ .global read_biosparam
+read_biosparam:
+ movb %es:(%bx), %dl
+ ret
+
+#
+# Write one byte to BIOS paramter block
+# %bx offset
+# %dl value
+#
+ .global write_biosparam
+write_biosparam:
+ movb %dl, %es:(%bx)
+ ret
+
+#
+# beep
+#
+ .global beep_on, beep_off, beep
+beep_on:
+ movb $0x17, %ah
+ int $0x18
+ ret
+
+beep_off:
+ movb $0x18, %ah
+ int $0x18
+ ret
+
+beep:
+ push %cx
+ call beep_on
+ movw $100, %cx
+beep_loop1:
+ call wait1ms
+ loop beep_loop1
+ call beep_off
+ movw $50, %cx
+beep_loop2:
+ call wait1ms
+ loop beep_loop2
+ pop %cx
+ ret
diff --git a/sys/boot/pc98/boot0.5/syscons.s b/sys/boot/pc98/boot0.5/syscons.s
new file mode 100644
index 000000000000..150b835f795d
--- /dev/null
+++ b/sys/boot/pc98/boot0.5/syscons.s
@@ -0,0 +1,253 @@
+# Copyright (c) KATO Takenori, 1999, 2000.
+#
+# All rights reserved. Unpublished rights reserved under the copyright
+# laws of Japan.
+#
+# 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 as
+# the first lines of this file unmodified.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+ .code16
+
+ .text
+#
+# %al character code
+# destroyed: %al, %bx
+#
+put_character:
+ movw $0xe000, %bx
+ movb ishireso, %ah
+ orb %ah, %ah
+ jne hireso_ch
+ movw $0xa000, %bx
+hireso_ch:
+ movw %bx, %es
+ xorb %ah, %ah
+ movw curpos, %bx
+ movw %ax, %es:(%bx)
+ xorw %ax, %ax
+ movw %ax, %es
+ ret
+
+#
+# %al attribute
+# destroyed: %ah, %cx
+#
+set_attribute:
+ movw $0xe200, %bx
+ movb ishireso, %ah
+ orb %ah, %ah
+ jne hireso_ch
+ movw $0xa200, %bx
+hireso_attr:
+ movw %bx, %es
+ xorb %ah, %ah
+ movw curpos, %bx
+ movw %ax, %es:(%bx)
+ xorw %bx, %bx
+ movw %bx, %es
+ ret
+
+#
+# Put a character
+# %al: character code
+# destroyed: %ah, %bx, %cx
+#
+ .global sc_putc
+sc_putc:
+ call put_character
+ incw curpos
+ incw curpos
+ cmpw $4000, curpos
+ jng putc_end
+ movw $0, curpos
+putc_end:
+ ret
+
+#
+# Put a null terminated string
+# %di: pointer to string
+# destroyed: %ah, %cx, %di
+#
+ .global sc_puts
+sc_puts:
+ movb (%di), %al
+ orb %al, %al
+ jz puts_end
+ call sc_putc
+ incw %di
+ jmp sc_puts
+puts_end:
+ ret
+
+#
+# Change the current cursor position
+# %cx: X
+# %dx: Y
+# destroyed: %ax, %bx
+#
+ .global sc_goto
+sc_goto:
+ movw %dx, %ax # AX=Y
+ shlw %ax # AX=Y*64
+ shlw %ax
+ shlw %ax
+ shlw %ax
+ shlw %ax
+ shlw %ax
+ movw %dx, %bx # BX=Y
+ shlw %bx # BX=Y*16
+ shlw %bx
+ shlw %bx
+ shlw %bx
+ addw %bx, %ax # AX=Y*64+Y*16=Y*80
+ addw %cx, %ax
+ shlw %ax
+ movw %ax, curpos
+ ret
+
+#
+# Clear screen
+# destroyed: %ax, %bx
+#
+ .global sc_clean
+sc_clean:
+ movb $0x16, %ah
+ movw $0xe120, %dx
+ int $0x18 # KBD/CRT BIOS
+ movw $0, curpos
+ ret
+
+#
+# Set sttribute code
+# %al: attribute
+# %cx: count
+# destroyed: %ax, %bx, %cx
+#
+ .global sc_setattr
+sc_setattr:
+ call set_attribute
+ incw curpos
+ incw curpos
+ loop sc_setattr
+
+#
+# Sense the state of shift key
+# destroyed: %ax
+#
+ .global sc_getshiftkey
+sc_getshiftkey:
+ movb $2, %ah # Sense KB_SHIFT_COD
+ int $0x18 # KBD/CRT BIOS
+ xorb %ah, %ah
+ ret
+
+#
+# Check KBD buffer
+#
+ .global sc_iskeypress
+sc_iskeypress:
+ mov $1, %ah
+ int $0x18 # KBD/CRT BIOS
+ testb $1, %bh
+ jz no_key
+ movw $1, %ax
+ ret
+no_key:
+ xorw %ax, %ax
+ ret
+
+#
+# Read from KBD
+#
+ .global sc_getc
+sc_getc:
+ xorb %ah, %ah
+ int $0x18
+ ret
+
+#
+# Initialize CRT (normal mode)
+#
+init_screen_normal:
+ # Disable graphic screen
+ movb $0x41, %ah
+ int $0x18
+ # Init graphic screen
+ movb $0x42, %al
+ movb $0xc0, %ch
+ int $0x18
+ # 80x25 mode
+ movw $0x0a00, %ax
+ int $0x18
+ ret
+
+#
+# Initialize CRT (hireso mode)
+#
+init_screen_hireso:
+ # Init RAM window
+ movb $8, %al
+ outb %al, $0x91
+ movb $0x0a, %al
+ outb %al, $0x93
+ # 80x31 mode
+ movw $0x0a00, %ax
+ int $0x18
+ ret
+
+#
+# Initialize screen (internal)
+#
+init_screen:
+ movb ishireso, %ah
+ orb %ah, %ah
+ jne hireso_ini
+ call init_screen_normal
+ jmp init_next
+hireso_ini:
+ call init_screen_hireso
+init_next:
+ movb $0x0c, %ah
+ int $0x18
+ # cursor home and off
+ xorw %dx, %dx
+ movb $0x13, %ah
+ int $0x18
+ movb $0x12, %ah
+ int $0x18
+ ret
+
+#
+# Initialize screeen
+#
+ .global sc_init
+sc_init:
+ call init_screen
+ call sc_clean
+ movw $0, curpos
+ ret
+
+ .data
+curpos: .word 0 # Current cursor position
diff --git a/sys/boot/pc98/boot0/Makefile b/sys/boot/pc98/boot0/Makefile
new file mode 100644
index 000000000000..27a2a3ad2a6a
--- /dev/null
+++ b/sys/boot/pc98/boot0/Makefile
@@ -0,0 +1,20 @@
+# $FreeBSD$
+
+PROG= boot0
+OBJS= boot0.o
+NOMAN=
+STRIP=
+BINDIR?= /boot
+BINMODE= 444
+
+ORG= 0x0000
+
+boot0: boot0.out
+ objcopy -S -O binary boot0.out ${.TARGET}
+
+boot0.out: ${OBJS}
+ ${LD} -N -e start -Ttext ${ORG} -o ${.TARGET} ${OBJS}
+
+CLEANFILES+= boot0.out
+
+.include <bsd.prog.mk>
diff --git a/sys/boot/pc98/boot0/boot0.s b/sys/boot/pc98/boot0/boot0.s
new file mode 100644
index 000000000000..508e2521157a
--- /dev/null
+++ b/sys/boot/pc98/boot0/boot0.s
@@ -0,0 +1,108 @@
+# Copyright (c) KATO Takenori, 1999, 2000.
+#
+# All rights reserved. Unpublished rights reserved under the copyright
+# laws of Japan.
+#
+# 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 as
+# the first lines of this file unmodified.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+
+ .globl start
+ .code16
+start:
+ jmp main
+
+ .org 4
+ .ascii "IPL1"
+ .byte 0, 0, 0
+
+ .globl start
+main:
+ xor %ax, %ax
+ mov %ax, %ds
+ mov (0x584), %al # DA/UA
+ mov %al, %ah
+ and $0xf0, %ah
+ cmp $0x90, %ah
+ je fdd
+
+ # hdd
+ mov $6, %ah
+ mov $0x3000, %bx
+ mov %bx, %es
+ mov $0x2000, %bx
+ xor %cx, %cx
+ xor %dx, %dx
+ xor %bp, %bp
+ int $0x1b
+ jc error_hdd
+
+ push %ax
+ mov %es, %ax
+ add $0x40, %ax
+ mov %ax, %es
+ pop %ax
+ push %es
+ push %bp
+ lret
+
+ # fdd
+fdd:
+ xor %di, %di
+fdd_retry:
+ mov $0xd6, %ah
+ mov $0x3000, %bx
+ mov %bx, %es
+ mov $0x2000, %bx
+ mov $0x0200, %cx
+ mov $0x0001, %dx
+ xor %bp, %bp
+ int $0x1b
+ jc error
+ push %ax
+ mov %es, %ax
+ add $0x40, %ax
+ mov %ax, %es
+ pop %ax
+ push %es
+ push %bp
+ lret
+
+error:
+ or %di, %di
+ jnz error_hdd
+ and $0x0f, %al
+ or $0x30, %al
+ jmp fdd_retry
+
+error_hdd:
+ jmp error
+
+ .org 0x1fa
+ .byte 0 # defflag_off
+ .byte 0 # defpart_off
+ .byte 1 # menu version
+ .byte 0
+ .word 0xaa55
diff --git a/sys/modules/sound/driver/solo/Makefile b/sys/modules/sound/driver/solo/Makefile
new file mode 100644
index 000000000000..ee73b7b356a0
--- /dev/null
+++ b/sys/modules/sound/driver/solo/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../../dev/sound/pci
+KMOD = snd_solo
+SRCS = device_if.h bus_if.h isa_if.h pci_if.h
+SRCS += solo.c
+
+.include <bsd.kmod.mk>
diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c
new file mode 100644
index 000000000000..f2980db67598
--- /dev/null
+++ b/sys/vm/phys_pager.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2000 Peter Wemm
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/linker_set.h>
+#include <sys/conf.h>
+#include <sys/mman.h>
+#include <sys/sysctl.h>
+
+#include <vm/vm.h>
+#include <vm/vm_object.h>
+#include <vm/vm_page.h>
+#include <vm/vm_pager.h>
+#include <vm/vm_zone.h>
+
+/* list of device pager objects */
+static struct pagerlst phys_pager_object_list;
+
+static int phys_pager_alloc_lock, phys_pager_alloc_lock_want;
+
+static void
+phys_pager_init(void)
+{
+
+ TAILQ_INIT(&phys_pager_object_list);
+}
+
+static vm_object_t
+phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
+ vm_ooffset_t foff)
+{
+ vm_object_t object;
+
+ /*
+ * Offset should be page aligned.
+ */
+ if (foff & PAGE_MASK)
+ return (NULL);
+
+ size = round_page(size);
+
+ /*
+ * Lock to prevent object creation race condition.
+ */
+ while (phys_pager_alloc_lock) {
+ phys_pager_alloc_lock_want++;
+ tsleep(&phys_pager_alloc_lock, PVM, "ppall", 0);
+ phys_pager_alloc_lock_want--;
+ }
+ phys_pager_alloc_lock = 1;
+
+ /*
+ * Look up pager, creating as necessary.
+ */
+ object = vm_pager_object_lookup(&phys_pager_object_list, handle);
+ if (object == NULL) {
+ /*
+ * Allocate object and associate it with the pager.
+ */
+ object = vm_object_allocate(OBJT_PHYS,
+ OFF_TO_IDX(foff + size));
+ object->handle = handle;
+ TAILQ_INSERT_TAIL(&phys_pager_object_list, object,
+ pager_object_list);
+ } else {
+ /*
+ * Gain a reference to the object.
+ */
+ vm_object_reference(object);
+ if (OFF_TO_IDX(foff + size) > object->size)
+ object->size = OFF_TO_IDX(foff + size);
+ }
+
+ phys_pager_alloc_lock = 0;
+ if (phys_pager_alloc_lock_want)
+ wakeup(&phys_pager_alloc_lock);
+
+ return (object);
+}
+
+static void
+phys_pager_dealloc(vm_object_t object)
+{
+
+ TAILQ_REMOVE(&phys_pager_object_list, object, pager_object_list);
+}
+
+static int
+phys_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage)
+{
+ int i, s;
+
+ s = splvm();
+ /*
+ * Fill as many pages as vm_fault has allocated for us.
+ */
+ for (i = 0; i < count; i++) {
+ if ((m[i]->flags & PG_ZERO) == 0)
+ vm_page_zero_fill(m[i]);
+ vm_page_flag_set(m[i], PG_ZERO);
+ /* Switch off pv_entries */
+ vm_page_unmanage(m[i]);
+ m[i]->valid = VM_PAGE_BITS_ALL;
+ m[i]->dirty = 0;
+ /* The requested page must remain busy, the others not. */
+ if (reqpage != i) {
+ vm_page_flag_clear(m[i], PG_BUSY);
+ m[i]->busy = 0;
+ }
+ }
+ splx(s);
+
+ return (VM_PAGER_OK);
+}
+
+static void
+phys_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync,
+ int *rtvals)
+{
+
+ panic("phys_pager_putpage called");
+}
+
+/*
+ * Implement a pretty aggressive clustered getpages strategy. Hint that
+ * everything in an entire 4MB window should be prefaulted at once.
+ *
+ * XXX 4MB (1024 slots per page table page) is convenient for x86,
+ * but may not be for other arches.
+ */
+#ifndef PHYSCLUSTER
+#define PHYSCLUSTER 1024
+#endif
+static boolean_t
+phys_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
+ int *after)
+{
+ vm_pindex_t base, end;
+
+ base = pindex & (~(PHYSCLUSTER - 1));
+ end = base + (PHYSCLUSTER - 1);
+ if (before != NULL)
+ *before = pindex - base;
+ if (after != NULL)
+ *after = end - pindex;
+ return (TRUE);
+}
+
+struct pagerops physpagerops = {
+ phys_pager_init,
+ phys_pager_alloc,
+ phys_pager_dealloc,
+ phys_pager_getpages,
+ phys_pager_putpages,
+ phys_pager_haspage,
+ NULL
+};
diff --git a/usr.bin/truncate/truncate.1 b/usr.bin/truncate/truncate.1
new file mode 100644
index 000000000000..dc2b69cf4807
--- /dev/null
+++ b/usr.bin/truncate/truncate.1
@@ -0,0 +1,154 @@
+.\"
+.\" Copyright (c) 2000 Sheldon Hearn <sheldonh@FreeBSD.org>.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd Jul 4, 2000
+.Dt TRUNCATE 1
+.Os
+.Sh NAME
+.Nm truncate
+.Nd truncate or extend the length of files
+.Sh SYNOPSIS
+.Nm truncate
+.Op Fl c
+.Bk -words
+.Fl s Xo
+.Sm off
+.Op + | -
+.Ar size
+.Op K | M | G
+.Sm on
+.Xc
+.Ek
+.Ar
+.Nm truncate
+.Op Fl c
+.Bk -words
+.Fl r Ar rfile
+.Ek
+.Ar
+.Sh DESCRIPTION
+The
+.Nm
+utility adjusts the length of each regular file given on the command-line.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl c
+Do not create files if they do not exist.
+The
+.Nm
+utility does not treat this as an error.
+No error messages are displayed
+and the exit value is not affected.
+.It Fl r Ar rfile
+Truncate files to the length of the file
+.Ar rfile .
+.It Fl s Xo
+.Sm off
+.Op + | -
+.Ar size
+.Op K | M | G
+.Sm on
+.Xc
+If the
+.Ar size
+argument is preceded by a plus sign
+.Pq Sq + ,
+files will be extended by this number of bytes.
+If the
+.Ar size
+argument is preceded by a dash
+.Pq Sq - ,
+file lengths will be reduced by no more than this number of bytes,
+to a minimum length of zero bytes.
+Otherwise, the
+.Ar size
+argument specifies an absolute length to which all files
+should be extended or reduced as appropriate.
+.Pp
+The
+.Ar size
+argument may be suffixed with one of
+.Sq K ,
+.Sq M ,
+.Sq G
+to indicate a multiple of
+Kilobytes, Megabytes or Gigabytes
+respectively.
+.El
+.Pp
+Exactly one of the
+.Fl r
+and
+.Fl s
+options must be specified.
+.Pp
+If a file is made smaller, its extra data is lost.
+If a file is made larger,
+it will be extended as if by writing bytes with the value zero.
+If the file does not exist,
+it is created unless the
+.Fl c
+option is specified.
+.Pp
+Note that,
+while truncating a file causes space on disk to be freed,
+extending a file does not cause space to be allocated.
+To extend a file and actually allocate the space,
+it is necessary to explicitly write data to it,
+using (for example) the shell's
+.Ql >>
+redirection syntax, or
+.Xr dd 1 .
+.Sh DIAGNOSTICS
+The
+.Nm
+utility exits 0 on success,
+and >0 if an error occurs.
+If the operation fails for an argument,
+.Nm
+will issue a diagnostic
+and continue processing the remaining arguments.
+.Sh SEE ALSO
+.Xr dd 1 ,
+.Xr touch 1 ,
+.Xr truncate 2
+.Sh STANDARDS
+The
+.Nm
+utility conforms to no known standards.
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Fx 4.2 .
+.Sh AUTHORS
+The
+.Nm
+utility and this manual page were written by
+.An Sheldon Hearn
+.Aq sheldonh@uunet.co.za .
diff --git a/usr.sbin/boot98cfg/Makefile b/usr.sbin/boot98cfg/Makefile
new file mode 100644
index 000000000000..8d9658028249
--- /dev/null
+++ b/usr.sbin/boot98cfg/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+PROG= boot98cfg
+MAN8= boot98cfg.8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/boot98cfg/boot98cfg.8 b/usr.sbin/boot98cfg/boot98cfg.8
new file mode 100644
index 000000000000..628f23aa06d4
--- /dev/null
+++ b/usr.sbin/boot98cfg/boot98cfg.8
@@ -0,0 +1,98 @@
+.\" Copyright (c) KATO Takenori, 2000.
+.\"
+.\" All rights reserved. Unpublished rights reserved under the copyright
+.\" laws of Japan.
+.\"
+.\" 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 as
+.\" the first lines of this file unmodified.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd July 10, 2000
+.Dt BOOT98CFG 8
+.Os
+.Sh NAME
+.Nm boot98cfg
+.Nd HDD boot manager installation utility
+.Sh SYNOPSIS
+.Op Fl B
+.Op Fl i Ar boot0
+.Op Fl m Ar boot0.5
+.Op Fl s Ar secsize
+.Op Fl v Ar version
+.Op Fl f Ar boot0.bak
+.Op Fl F Ar boot0.5.bak
+.Ar disk
+.Sh DESCRIPTION
+On NEC PC-98s,
+.Sq boot loader
+consists of the
+.Sq IPL
+and
+.Sq HDD boot menu.
+The IPL occupies sector 0 of a disk and is followed by the partition
+table. The IPL loads the HDD boot menu that starts from 0x400.
+
+The
+.Nm
+installs and makes backup copy of the IPL and the HDD boot menu; and
+allows changing the version number field in the sector 0.
+
+Note that the format command in NEC's OSs replaces the HDD boot menu
+with its own HDD boot menu when the version number field is smaller
+than that in the format command.
+
+The options are:
+.Bl -tag -width indent
+.It Fl B
+Install the IPL and HDD boot menu. This option causes the IPL and HDD
+boot menu code to be replaced.
+.It Fl i Ar boot0
+Specify which IPL image to use. The default is /boot/boot0.
+.It Fl m Ar boot0.5
+Specify which HDD boot menu image to use. The default is
+/boot/boot0.5.
+.It Fl f Ar boot0.bak
+Specify that a backup copy of the preexisting IPL should be written to
+.Ar boot0.bak .
+This file is created if it does not exist, and truncated if it does.
+.It Fl F Ar boot0.5.bak
+Specify that a backup copy of the preexisting HDD boot menu should be
+written to
+.Ar boot0.5.bak .
+This file is created if it does not exist, and truncated if it does.
+.It Fl v Ar version
+Specify the version number.
+.It Fl s Ar secsize
+Specify the sector size. The default secotor size is 512
+(bytes/sector).
+.El
+.Sh SEE ALSO
+.Xr boot 8 ,
+.Xr fdisk 8 .
+.Sh DIAGNOSTICS
+Exit status is 0 on success and >0 on error.
+.Sh AUTHORS
+.An NOKUBI Hirotaka ,
+.An KATO Takenori
diff --git a/usr.sbin/boot98cfg/boot98cfg.c b/usr.sbin/boot98cfg/boot98cfg.c
new file mode 100644
index 000000000000..85a817d0ac7d
--- /dev/null
+++ b/usr.sbin/boot98cfg/boot98cfg.c
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) KATO Takenori, 2000.
+ *
+ * All rights reserved. Unpublished rights reserved under the copyright
+ * laws of Japan.
+ *
+ * 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 as
+ * the first lines of this file unmodified.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Copyright (c) 1999 Robert Nordier
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define IPLSIZE 512 /* IPL size */
+#define BOOTMENUSIZE 7168 /* Max HDD boot menu size */
+#define BOOTMENUOFF 0x400
+
+static char *mkrdev(char *);
+static void usage(void);
+
+u_char boot0buf[0x2000];
+char ipl[IPLSIZE];
+char menu[BOOTMENUSIZE];
+
+/*
+ * Produce a device path for a "canonical" name, where appropriate.
+ */
+static char *
+mkrdev(char *fname)
+{
+ char buf[MAXPATHLEN];
+ struct stat sb;
+ char *s;
+
+ s = (char *)fname;
+ if (!strchr(fname, '/')) {
+ snprintf(buf, sizeof(buf), "%sr%s", _PATH_DEV, fname);
+ if (stat(buf, &sb))
+ snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
+ if (!(s = strdup(buf)))
+ err(1, NULL);
+ }
+ return s;
+}
+
+static void
+usage(void)
+{
+ fprintf(stderr,
+ "boot98cfg [-B][-i boot0][-m boot0.5][-s secsize][-v version]\n"
+ " [-f ipl.bak][-F menu.bak] disk\n");
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *endptr;
+ char *iplpath = "/boot/boot0", *menupath = "/boot/boot0.5";
+ char *iplbakpath = NULL, *menubakpath = NULL;
+ char *disk;
+ int B_flag = 0;
+ int c;
+ int fd, fd1;
+ int n;
+ int secsize = 512;
+ int v_flag = 0, version;
+
+ while ((c = getopt(argc, argv, "BF:f:i:m:s:v:")) != -1) {
+ switch (c) {
+ case 'B':
+ B_flag = 1;
+ break;
+ case 'F':
+ menubakpath = optarg;
+ break;
+ case 'f':
+ iplbakpath = optarg;
+ break;
+ case 'i':
+ iplpath = optarg;
+ break;
+ case 'm':
+ menupath = optarg;
+ break;
+ case 's':
+ secsize = strtol(optarg, &endptr, 0);
+ if (errno || *optarg == NULL || *endptr)
+ errx(1, "%s: Bad argument to -s option",
+ optarg);
+ switch (secsize) {
+ case 256:
+ case 512:
+ case 1024:
+ case 2048:
+ break;
+ default:
+ errx(1, "%s: unsupported sector size", optarg);
+ break;
+ }
+ break;
+ case 'v':
+ v_flag = 1;
+ version = strtol(optarg, &endptr, 0);
+ if (errno || *optarg == NULL || *endptr ||
+ version < 0 || version > 255)
+ errx(1, "%s: Bad argument to -s option",
+ optarg);
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc != 1)
+ usage();
+ disk = mkrdev(*argv);
+
+ /* Read IPL, partition table and HDD boot menu. */
+ fd = open(disk, O_RDWR);
+ if (fd < 0)
+ err(1, "%s", disk);
+ n = read(fd, boot0buf, 0x2000);
+ if (n != 0x2000)
+ errx(1, "%s: short read", disk);
+ if (!B_flag && !v_flag)
+ close(fd);
+
+ if (iplbakpath != NULL) {
+ fd1 = open(iplbakpath, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ if (fd1 < 0)
+ err(1, "%s", iplbakpath);
+ n = write(fd1, boot0buf, IPLSIZE);
+ if (n == -1)
+ err(1, "%s", iplbakpath);
+ if (n != IPLSIZE)
+ errx(1, "%s: short write", iplbakpath);
+ close(fd1);
+ }
+
+ if (menubakpath != NULL) {
+ fd1 = open(menubakpath, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ if (fd1 < 0)
+ err(1, "%s", menubakpath);
+ n = write(fd1, boot0buf + BOOTMENUOFF, BOOTMENUSIZE);
+ if (n == -1)
+ err(1, "%s", menubakpath);
+ if (n != BOOTMENUSIZE)
+ errx(1, "%s: short write", menubakpath);
+ close(fd1);
+ }
+
+ if (B_flag) {
+ /* Read IPL (boot0). */
+ fd1 = open(iplpath, O_RDONLY);
+ if (fd1 < 0)
+ err(1, "%s", disk);
+ n = read(fd1, ipl, IPLSIZE);
+ if (n < 0)
+ err(1, "%s", iplpath);
+ if (n != IPLSIZE)
+ errx(1, "%s: invalid file", iplpath);
+ close(fd1);
+
+ /* Read HDD boot menu (boot0.5). */
+ fd1 = open(menupath, O_RDONLY);
+ if (fd1 < 0)
+ err(1, "%s", disk);
+ n = read(fd1, menu, BOOTMENUSIZE);
+ if (n < 0)
+ err(1, "%s", menupath);
+ if (n != BOOTMENUSIZE)
+ errx(1, "%s: invalid file", menupath);
+ close(fd1);
+
+ memcpy(boot0buf, ipl, IPLSIZE);
+ memcpy(boot0buf + BOOTMENUOFF, menu, BOOTMENUSIZE);
+ }
+
+ /* Set version number field. */
+ if (v_flag)
+ *(boot0buf + secsize - 4) = (u_char)version;
+
+ if (B_flag || v_flag) {
+ if (lseek(fd, 0, SEEK_SET) == -1 ||
+ (n = write(fd, boot0buf, 0x2000)) < 0 ||
+ close(fd))
+ err(1, "%s", disk);
+ if (n != 0x2000)
+ errx(1, "%s: short write", disk);
+ }
+
+ return 0;
+}