diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-26 01:16:48 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-26 01:16:48 +0000 |
commit | c90daa1186258d136f2f45d20dbf698b4daee12c (patch) | |
tree | 79a0532cce031876ebb04319c41814628041c71a | |
parent | 5481a864cda1d6232e8383d11227e2402df106e3 (diff) |
update from netbsd tree
23 files changed, 482 insertions, 187 deletions
diff --git a/sys/arch/sun3/stand/libsa/dev_disk.c b/sys/arch/sun3/stand/libsa/dev_disk.c index ef41efe5f12..a6506ee560b 100644 --- a/sys/arch/sun3/stand/libsa/dev_disk.c +++ b/sys/arch/sun3/stand/libsa/dev_disk.c @@ -1,4 +1,4 @@ -/* $NetBSD: dev_disk.c,v 1.2 1995/10/13 21:45:15 gwr Exp $ */ +/* $NetBSD: dev_disk.c,v 1.3 1995/10/17 23:07:19 gwr Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -115,8 +115,6 @@ disk_strategy(devdata, flag, dblk, size, buf, rsize) #ifdef DEBUG_PROM printf("disk_strategy: size=%d dblk=%d\n", size, dblk); -#else - twiddle(); #endif dmabuf = dvma_mapin(buf, size); diff --git a/sys/arch/sun3/stand/netboot/version.c b/sys/arch/sun3/stand/netboot/version.c index bcfbb74c17b..c8f33eb39c9 100644 --- a/sys/arch/sun3/stand/netboot/version.c +++ b/sys/arch/sun3/stand/netboot/version.c @@ -4,4 +4,4 @@ * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. */ -char *version = "$Revision: 1.1 $"; +char *version = "$Revision: 1.2 $"; diff --git a/sys/arch/sun3/stand/tapeboot/Makefile b/sys/arch/sun3/stand/tapeboot/Makefile index 4e0a3635516..af9e34e5b82 100644 --- a/sys/arch/sun3/stand/tapeboot/Makefile +++ b/sys/arch/sun3/stand/tapeboot/Makefile @@ -1,7 +1,9 @@ -# $NetBSD: Makefile,v 1.1.1.1 1995/10/13 21:27:30 gwr Exp $ +# $NetBSD: Makefile,v 1.2 1995/10/17 22:58:10 gwr Exp $ SA_PROG= tapeboot -SRCS= boot.c conf.c dev_tape.c version.c +SRCS= boot.c conf.c rawfs.c dev_tape.c version.c + +# DEFS= -DDEBUG all: ${SA_PROG}.bin diff --git a/sys/arch/sun3/stand/tapeboot/boot.c b/sys/arch/sun3/stand/tapeboot/boot.c index c6a24287299..db1ae666339 100644 --- a/sys/arch/sun3/stand/tapeboot/boot.c +++ b/sys/arch/sun3/stand/tapeboot/boot.c @@ -1,8 +1,8 @@ -/* $NetBSD: boot.c,v 1.1.1.1 1995/10/13 21:27:30 gwr Exp $ */ +/* $NetBSD: boot.c,v 1.2 1995/10/17 22:58:14 gwr Exp $ */ -/* - * Copyright (c) 1994 Paul Kranenburg - * All rights reserved. +/*- + * Copyright (c) 1982, 1986, 1990, 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 @@ -14,153 +14,70 @@ * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE 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. - */ - -/* - * This is a generic "first-stage" boot program. + * 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. * - * Note that this program has absolutely no filesystem knowledge! - * - * Instead, this uses a table of disk block numbers that are - * filled in by the installboot program such that this program - * can load the "second-stage" boot program. + * @(#)boot.c 8.1 (Berkeley) 6/10/93 */ #include <sys/param.h> #include <sys/reboot.h> -#include <sys/exec.h> #include <machine/mon.h> #include "stand.h" #include "promboot.h" +int debug; +int errno; + /* * Boot device is derived from ROM provided information. */ #define LOADADDR 0x4000 -extern int debug; extern char *version; - +char defname[32] = "1"; char line[80]; -int block_size = 512; - main() { - struct open_file f; - struct bootparam *bp; - void (*entry)(); - char *addr; - int n, error; + char *cp, *file; + int io; printf(">> NetBSD tapeboot [%s]\n", version); prom_get_boot_info(); + file = defname; - /* - * Set the tape file number to the next one, because - * the boot program is first, then the kernel. - */ - bp = *romp->bootParam; - bp->partNum += 1; + cp = prom_bootfile; + if (cp && *cp) + file = cp; for (;;) { if (prom_boothow & RB_ASKNAME) { - printf("tapeboot: segment? [%d] ", bp->partNum); + printf("tapeboot: segment? [1] "); gets(line); - if (('0' <= line[0]) && (line[0] <= '9')) { - bp->partNum = line[0] - '0'; - } - } - - printf("tapeboot: opening segment %d\n", bp->partNum); - f.f_flags = F_RAW; - if ((error = devopen(&f, 0, &addr)) != 0) { - printf("tapeboot: open failed, error=%d\n", error); - goto ask; + if (line[0]) + file = line; } - - addr = (char*)LOADADDR; - error = loadfile(&f, addr); - - printf("tapeboot: close (rewind)...\n"); - f.f_dev->dv_close(&f); - if (error == 0) - break; - - printf("tapeboot: load failed, error=%d\n", error); - ask: + exec_sun(file, LOADADDR); + printf("tapeboot: %s: %s\n", file, strerror(errno)); prom_boothow |= RB_ASKNAME; } - - if (debug) { - printf("Debug mode - enter c to continue..."); - /* This will print "\nAbort at ...\n" */ - asm(" trap #0"); - } - - printf("Starting program at 0x%x\n", (long)addr); - entry = (void (*)())addr; - (*entry)(); } - -int -loadfile(fp, addr) - struct open_file *fp; - char *addr; -{ - char *buf; - int n, blknum; - int error = 0; - /* - * Loading a kernel. It WILL have an a.out header. - * XXX - This assumes OMAGIC format! - */ - addr -= sizeof(struct exec); /* XXX */ - - /* Need to use a buffer that can be mapped into DVMA space. */ - buf = alloc(block_size); - if (!buf) - panic("tapeboot: alloc failed"); - - printf("tapeboot: loading ... "); - /* limit program size to < 2MB */ - for (blknum = 0; blknum < 4096; blknum++) { - - error = (fp->f_dev->dv_strategy)(fp->f_devdata, F_READ, - blknum, block_size, buf, &n); - if (error) { - printf("(error=%d)\n", error); - return EIO; - } - if (n == 0) - break; /* end of tape */ - if (n != block_size) { - printf(" (short read)\n"); - return EIO; - } - - bcopy(buf, addr, block_size); - addr += block_size; - } - - printf("(%d blocks)\n", blknum); - return 0; -} - diff --git a/sys/arch/sun3/stand/tapeboot/conf.c b/sys/arch/sun3/stand/tapeboot/conf.c index a62f7d1f6cb..941ef65a7d4 100644 --- a/sys/arch/sun3/stand/tapeboot/conf.c +++ b/sys/arch/sun3/stand/tapeboot/conf.c @@ -1,8 +1,17 @@ -/* $NetBSD: conf.c,v 1.1.1.1 1995/10/13 21:27:30 gwr Exp $ */ +/* $NetBSD: conf.c,v 1.2 1995/10/17 22:58:17 gwr Exp $ */ #include <stand.h> +#include <rawfs.h> #include <dev_tape.h> +struct fs_ops file_system[] = { + { + rawfs_open, rawfs_close, rawfs_read, + rawfs_write, rawfs_seek, rawfs_stat, + }, +}; +int nfsys = 1; + struct devsw devsw[] = { { "tape", tape_strategy, tape_open, tape_close, tape_ioctl }, }; diff --git a/sys/arch/sun3/stand/tapeboot/dev_tape.c b/sys/arch/sun3/stand/tapeboot/dev_tape.c index 021db6c5fe0..6155817811a 100644 --- a/sys/arch/sun3/stand/tapeboot/dev_tape.c +++ b/sys/arch/sun3/stand/tapeboot/dev_tape.c @@ -1,4 +1,4 @@ -/* $NetBSD: dev_tape.c,v 1.1.1.1 1995/10/13 21:27:30 gwr Exp $ */ +/* $NetBSD: dev_tape.c,v 1.2 1995/10/17 22:58:20 gwr Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -50,39 +50,78 @@ #include "promdev.h" /* #include "dev_tape.h" XXX - needs stdarg.h */ +extern int debug; + struct saioreq tape_ioreq; +/* + * This is a special version of devopen() for tape boot. + * In this version, the file name is a numeric string of + * one digit, which is passed to the device open so it + * can open the appropriate tape segment. + */ int -tape_open(f, devname) +devopen(f, fname, file) struct open_file *f; - char *devname; /* Device part of file name (or NULL). */ + const char *fname; /* normally "1" */ + char **file; +{ + struct devsw *dp; + int error; + + *file = (char*)fname; + dp = &devsw[0]; + f->f_dev = dp; + + /* The following will call tape_open() */ + return (dp->dv_open(f, fname)); +} + +int +tape_open(f, fname) + struct open_file *f; + char *fname; /* partition number, i.e. "1" */ { struct bootparam *bp; struct saioreq *si; - int error; + int error, part; -#ifdef DEBUG_PROM - printf("tape_open: %s\n", devname); +#ifdef DEBUG + printf("tape_open: part=%s\n", fname); #endif /* + * Set the tape segment number to the one indicated + * by the single digit fname passed in above. + */ + if ((fname[0] < '0') && (fname[0] > '9')) { + return ENOENT; + } + part = fname[0] - '0'; + + /* * Setup our part of the saioreq. * (determines what gets opened) */ si = &tape_ioreq; bzero((caddr_t)si, sizeof(*si)); - bp = *romp->bootParam; + bp = *romp->bootParam; si->si_boottab = bp->bootDevice; si->si_ctlr = bp->ctlrNum; si->si_unit = bp->unitNum; - si->si_boff = bp->partNum; + si->si_boff = part; /* default = bp->partNum + 1; */ - if ((error = prom_iopen(si)) != 0) - return (error); + error = prom_iopen(si); - f->f_devdata = si; - return 0; +#ifdef DEBUG + printf("tape_open: prom_iopen returned 0x%x\n", error); +#endif + + if (!error) + f->f_devdata = si; + + return (error); } int @@ -91,6 +130,10 @@ tape_close(f) { struct saioreq *si; +#ifdef DEBUG + printf("tape_close: calling prom_iclose\n"); +#endif + si = f->f_devdata; prom_iclose(si); f->f_devdata = NULL; @@ -114,10 +157,9 @@ tape_strategy(devdata, flag, dblk, size, buf, rsize) si = devdata; ops = si->si_boottab; -#ifdef DEBUG_PROM - printf("tape_strategy: size=%d dblk=%d\n", size, dblk); -#else - twiddle(); +#ifdef DEBUG + if (debug > 1) + printf("tape_strategy: size=%d dblk=%d\n", size, dblk); #endif dmabuf = dvma_mapin(buf, size); @@ -130,8 +172,9 @@ tape_strategy(devdata, flag, dblk, size, buf, rsize) xcnt = (*ops->b_strategy)(si, si_flag); dvma_mapout(dmabuf, size); -#ifdef DEBUG_PROM - printf("tape_strategy: xcnt = %x\n", xcnt); +#ifdef DEBUG + if (debug > 1) + printf("tape_strategy: xcnt = %x\n", xcnt); #endif /* At end of tape, xcnt == 0 (not an error) */ diff --git a/sys/arch/sun3/stand/tapeboot/dev_tape.h b/sys/arch/sun3/stand/tapeboot/dev_tape.h index 0e43954af69..ab794284b82 100644 --- a/sys/arch/sun3/stand/tapeboot/dev_tape.h +++ b/sys/arch/sun3/stand/tapeboot/dev_tape.h @@ -1,4 +1,3 @@ -/* $NetBSD: dev_tape.h,v 1.1.1.1 1995/10/13 21:27:30 gwr Exp $ */ int tape_open __P((struct open_file *, ...)); int tape_close __P((struct open_file *)); diff --git a/sys/arch/sun3/stand/tapeboot/rawfs.c b/sys/arch/sun3/stand/tapeboot/rawfs.c new file mode 100644 index 00000000000..875a534a2b0 --- /dev/null +++ b/sys/arch/sun3/stand/tapeboot/rawfs.c @@ -0,0 +1,201 @@ +/* $NetBSD: rawfs.c,v 1.1 1995/10/17 22:58:27 gwr Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * Raw file system - for stream devices like tapes. + * No random access, only sequential read allowed. + * This exists only to allow upper level code to be + * shielded from the fact that the device must be + * read only with whole block position and size. + */ + +#include <sys/param.h> +#include <stand.h> +#include <rawfs.h> + +extern int debug; + +/* Our devices are generally willing to do 8K transfers. */ +#define RAWFS_BSIZE 0x2000 + +/* + * In-core open file. + */ +struct file { + daddr_t fs_nextblk; /* block number to read next */ + int fs_len; /* amount left in f_buf */ + char * fs_ptr; /* read pointer into f_buf */ + char fs_buf[RAWFS_BSIZE]; +}; + +static int +rawfs_get_block __P((struct open_file *)); + +int rawfs_open(path, f) + char *path; + struct open_file *f; +{ + struct file *fs; + + /* + * The actual PROM driver has already been opened. + * Just allocate the I/O buffer, etc. + */ + fs = alloc(sizeof(struct file)); + fs->fs_nextblk = 0; + fs->fs_len = 0; + fs->fs_ptr = fs->fs_buf; + +#ifdef DEBUG_RAWFS + printf("rawfs_open: fs=0x%x\n", fs); +#endif + + f->f_fsdata = fs; + return (0); +} + +int rawfs_close(f) + struct open_file *f; +{ + struct file *fs; + + fs = (struct file *) f->f_fsdata; + f->f_fsdata = (void *)0; + +#ifdef DEBUG_RAWFS + if (debug) { + printf("rawfs_close: breakpoint...", fs->fs_buf); + __asm (" trap #0"); + } +#endif + + if (fs != (struct file *)0) + free(fs, sizeof(*fs)); + + return (0); +} + +int rawfs_read(f, start, size, resid) + struct open_file *f; + void *start; + u_int size; + u_int *resid; +{ + struct file *fs = (struct file *)f->f_fsdata; + char *addr = start; + int error = 0; + size_t csize; + + while (size != 0) { + + if (fs->fs_len == 0) + if ((error = rawfs_get_block(f)) != 0) + break; + + if (fs->fs_len <= 0) + break; /* EOF */ + + csize = size; + if (csize > fs->fs_len) + csize = fs->fs_len; + + bcopy(fs->fs_ptr, addr, csize); + fs->fs_ptr += csize; + fs->fs_len -= csize; + addr += csize; + size -= csize; + } + if (resid) + *resid = size; + return (error); +} + +int rawfs_write(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; /* out */ +{ +#ifdef DEBUG_RAWFS + panic("rawfs_write"); +#endif + return (EROFS); +} + +off_t rawfs_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ +#ifdef DEBUG_RAWFS + panic("rawfs_seek"); +#endif + return (EFTYPE); +} + +int rawfs_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ +#ifdef DEBUG_RAWFS + panic("rawfs_stat"); +#endif + return (EFTYPE); +} + + +/* + * Read a block from the underlying stream device + * (In our case, a tape drive.) + */ +static int +rawfs_get_block(f) + struct open_file *f; +{ + struct file *fs; + int error, len; + + fs = (struct file *)f->f_fsdata; + fs->fs_ptr = fs->fs_buf; + + twiddle(); + error = f->f_dev->dv_strategy(f->f_devdata, F_READ, + fs->fs_nextblk, RAWFS_BSIZE, fs->fs_buf, &len); + + if (!error) { + fs->fs_len = len; + fs->fs_nextblk += (RAWFS_BSIZE / DEV_BSIZE); + } + + return (error); +} + diff --git a/sys/arch/sun3/stand/tapeboot/rawfs.h b/sys/arch/sun3/stand/tapeboot/rawfs.h new file mode 100644 index 00000000000..b177413a013 --- /dev/null +++ b/sys/arch/sun3/stand/tapeboot/rawfs.h @@ -0,0 +1,15 @@ +/* $NetBSD: rawfs.h,v 1.1 1995/10/17 22:58:29 gwr Exp $ */ + +/* + * Raw file system - for stream devices like tapes. + * No random access, only sequential read allowed. + */ + +int rawfs_open __P((char *path, struct open_file *f)); +int rawfs_close __P((struct open_file *f)); +int rawfs_read __P((struct open_file *f, void *buf, + u_int size, u_int *resid)); +int rawfs_write __P((struct open_file *f, void *buf, + u_int size, u_int *resid)); +off_t rawfs_seek __P((struct open_file *f, off_t offset, int where)); +int rawfs_stat __P((struct open_file *f, struct stat *sb)); diff --git a/sys/arch/sun3/stand/tapeboot/version.c b/sys/arch/sun3/stand/tapeboot/version.c index be75f0869bf..37e2abc14ec 100644 --- a/sys/arch/sun3/stand/tapeboot/version.c +++ b/sys/arch/sun3/stand/tapeboot/version.c @@ -1,7 +1,10 @@ -/* $NetBSD: version.c,v 1.2 1995/10/13 21:33:23 gwr Exp $ */ +/* $NetBSD: version.c,v 1.3 1995/10/17 22:58:32 gwr Exp $ */ /* * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. + * + * Added "rawfs" to do read buffering and ensure that all + * device access stays strictly on block boundaries. */ -char *version = "$Revision: 1.1 $"; +char *version = "$Revision: 1.2 $"; diff --git a/sys/arch/sun3/sun3/db_machdep.c b/sys/arch/sun3/sun3/db_machdep.c index 9b1dcb7db96..f185ef1a961 100644 --- a/sys/arch/sun3/sun3/db_machdep.c +++ b/sys/arch/sun3/sun3/db_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.5 1995/06/27 14:44:49 gwr Exp $ */ +/* $NetBSD: db_machdep.c,v 1.5.2.1 1995/10/23 21:53:16 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -44,6 +44,12 @@ #include <machine/pte.h> +#undef DEBUG + +#ifdef DEBUG +int db_machdep_debug; +#endif + /* * Interface to the debugger for virtual memory read/write. * @@ -52,6 +58,10 @@ * For writes outside the text segment, and all reads, * just do the access -- if it causes a fault, the debugger * will recover with a longjmp to an appropriate place. + * + * ALERT! If you want to access device registers with a + * specific size, then the read/write functions have to + * make sure to do the correct sized pointer access. */ /* @@ -66,10 +76,28 @@ db_read_bytes(addr, size, data) register char *data; { register char *src; + register char incr; + +#ifdef DEBUG + if (db_machdep_debug) + printf("db_read_bytes: addr=0x%x, size=%d\n", addr, size); +#endif + + if (size == 4) { + *((int*)data) = *((int*)addr); + return; + } + + if (size == 2) { + *((short*)data) = *((short*)addr); + return; + } src = (char *)addr; - while (--size >= 0) + while (size > 0) { + --size; *data++ = *src++; + } } /* @@ -117,15 +145,46 @@ db_write_bytes(addr, size, data) char *data; { extern char kernel_text[], etext[] ; - char *dst; + register char *dst = (char *)addr; - dst = (char *)addr; - while (--size >= 0) { - if ((dst >= kernel_text) && (dst < etext)) +#ifdef DEBUG + if (db_machdep_debug) + printf("db_write_bytes: addr=0x%x, size=%d ", addr, size); +#endif + + /* If any part is in kernel text, use db_write_text() */ + if ((dst < etext) && ((dst + size) > kernel_text)) { + /* This is slow, but is only used for breakpoints. */ +#ifdef DEBUG + if (db_machdep_debug) + printf("(in text)\n"); +#endif + while (size > 0) { + --size; db_write_text(dst, *data); - else - *dst = *data; - dst++; data++; + dst++; data++; + } + return; + } + +#ifdef DEBUG + if (db_machdep_debug) + printf("(in data)\n"); +#endif + + if (size == 4) { + *((int*)addr) = *((int*)data); + return; + } + + if (size == 2) { + *((short*)addr) = *((short*)data); + return; + } + + while (size > 0) { + --size; + *dst++ = *data++; } } diff --git a/sys/arch/sun3/sun3/sun3_startup.c b/sys/arch/sun3/sun3/sun3_startup.c index ee97c0db689..d6fa52d8ddd 100644 --- a/sys/arch/sun3/sun3/sun3_startup.c +++ b/sys/arch/sun3/sun3/sun3_startup.c @@ -1,4 +1,4 @@ -/* $NetBSD: sun3_startup.c,v 1.47 1995/09/26 04:02:27 gwr Exp $ */ +/* $NetBSD: sun3_startup.c,v 1.48 1995/10/17 23:16:40 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -204,6 +204,14 @@ void Debugger() } #endif /* DDB */ +/* + * Duplicate all mappings in the current context into + * every other context. We have to let the PROM do the + * actual segmap manipulation because we can only switch + * the MMU context after we are sure that the kernel text + * is identically mapped in all contexts. The PROM can + * do the job using hardware-dependent tricks... + */ void sun3_context_equiv() { unsigned int i, sme; diff --git a/sys/arch/vax/boot/Makefile b/sys/arch/vax/boot/Makefile index b54fa987f1f..dd0f6293780 100644 --- a/sys/arch/vax/boot/Makefile +++ b/sys/arch/vax/boot/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 1995/09/16 13:18:27 ragge Exp $ +# $NetBSD: Makefile,v 1.5 1995/10/20 13:35:44 ragge Exp $ # INCPATH=-I. -I../../.. -I../.. -I../../../lib/libsa @@ -16,7 +16,7 @@ DEVS= autoconf.o hp.o ra.o tmscp.o LIBKERN= ${KERNLIB} .include "$S/lib/libsa/Makefile.inc" -LIBSA= ${SA_LIB} +LIBSA= ${SALIB} all: xxboot boot copy edlabel diff --git a/sys/arch/vax/boot/bootxx.c b/sys/arch/vax/boot/bootxx.c index b2f01417c95..b60d7e7931c 100644 --- a/sys/arch/vax/boot/bootxx.c +++ b/sys/arch/vax/boot/bootxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: bootxx.c,v 1.3 1995/09/16 13:01:06 ragge Exp $ */ +/* $NetBSD: bootxx.c,v 1.4 1995/10/20 13:35:43 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. * All rights reserved. @@ -48,6 +48,7 @@ #include "../include/sid.h" #include "../include/mtpr.h" #include "../include/reg.h" +#include "../include/rpb.h" #define NRSP 0 /* Kludge */ #define NCMD 0 /* Kludge */ @@ -93,7 +94,7 @@ main() is_mvax = 1; cpu_sie = *((int *) 0x20040004) >> 24; cpu_type |= cpu_sie; - rpb = bootregs[11]; + rpb = (struct rpb *)bootregs[11]; bootdev = rpb->devtyp; break; @@ -275,7 +276,7 @@ devopen(f, fname, file) * but it doesn't hurt to always get it. */ if (!is_tmscp) { - msg = getdisklabel(LABELOFFSET + RELOC, &lp); + msg = getdisklabel((void *)LABELOFFSET + RELOC, &lp); if (msg) { printf("getdisklabel: %s\n", msg); } @@ -321,7 +322,7 @@ romstrategy(sc, func, dblk, size, buf, rsize) case 17: /* MSCP */ uda.uda_cmd.mscp_seq.seq_lbn = dblk; uda.uda_cmd.mscp_seq.seq_bytecount = size; - uda.uda_cmd.mscp_seq.seq_buffer = buf; + uda.uda_cmd.mscp_seq.seq_buffer = (int)buf; uda.uda_cmd.mscp_unit = rpb->unit; command(M_OP_READ, 0); break; @@ -340,7 +341,8 @@ romstrategy(sc, func, dblk, size, buf, rsize) for (i = 0 ; i < size/512 ; i++) { uda.uda_cmd.mscp_seq.seq_lbn = 1; uda.uda_cmd.mscp_seq.seq_bytecount = 512; - uda.uda_cmd.mscp_seq.seq_buffer = buf + i * 512; + uda.uda_cmd.mscp_seq.seq_buffer = + (int)buf + i * 512; uda.uda_cmd.mscp_unit = rpb->unit; command(M_OP_READ, 0); } diff --git a/sys/arch/vax/boot/start.s b/sys/arch/vax/boot/start.s index 45a9c56169d..80040a7c2d7 100644 --- a/sys/arch/vax/boot/start.s +++ b/sys/arch/vax/boot/start.s @@ -1,4 +1,4 @@ -/* $NetBSD: start.s,v 1.4 1995/09/16 16:20:21 ragge Exp $ */ +/* $NetBSD: start.s,v 1.5 1995/10/20 13:35:41 ragge Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -43,7 +43,6 @@ #define ASSEMBLER #include "../include/mtpr.h" #include "../include/asm.h" -#include "bootdefs.h" _start: .globl _start # this is the symbolic name for the start # of code to be relocated. We can use this diff --git a/sys/arch/vax/include/macros.h b/sys/arch/vax/include/macros.h index eb2dc2b9fd1..9b1bf44c026 100644 --- a/sys/arch/vax/include/macros.h +++ b/sys/arch/vax/include/macros.h @@ -1,4 +1,4 @@ -/* $NetBSD: macros.h,v 1.4 1995/07/05 08:22:21 ragge Exp $ */ +/* $NetBSD: macros.h,v 1.5 1995/10/20 12:55:06 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -32,7 +32,8 @@ /* All bugs are subject to removal without further notice */ -#if !defined(_VAX_MACROS_H_)&&!defined(ASSEMBLER)&&defined(_VAX_INLINE_) +#if !defined(_VAX_MACROS_H_) && (defined(STANDALONE) || \ + (!defined(ASSEMBLER) && defined(_VAX_INLINE_))) #define _VAX_MACROS_H_ /* Here general macros are supposed to be stored */ diff --git a/sys/arch/vax/include/rpb.h b/sys/arch/vax/include/rpb.h index de7aec72007..7e5e1f02080 100644 --- a/sys/arch/vax/include/rpb.h +++ b/sys/arch/vax/include/rpb.h @@ -1,4 +1,4 @@ -/* $NetBSD: rpb.h,v 1.1 1995/06/05 17:17:59 ragge Exp $ */ +/* $NetBSD: rpb.h,v 1.2 1995/10/20 13:47:27 ragge Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -97,4 +97,6 @@ struct rpb { /* size description */ long vmb_revision; /* 4 VMB revision label */ }; +#ifdef _KERNEL extern struct rpb rpb; +#endif diff --git a/sys/arch/vax/mba/hpreg.h b/sys/arch/vax/mba/hpreg.h index ddf2ed2eed3..3b367afdec1 100644 --- a/sys/arch/vax/mba/hpreg.h +++ b/sys/arch/vax/mba/hpreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: hpreg.h,v 1.2 1995/06/16 15:20:11 ragge Exp $ */ +/* $NetBSD: hpreg.h,v 1.3 1995/10/20 13:43:43 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -55,10 +55,24 @@ struct hp_regs { #define hp_drv hp_regs -#define HPCS_PA 0x13 /* Pack acknowledge */ -#define HPCS_SEEK 0x5 -#define HPCS_READ 0x39 -#define HPCS_DVA 0x800 /* Drive avail, in dual-port config */ +#define HPCS_DVA 4000 /* Drive avail, in dual-port config */ +#define HPCS_WRITE 061 /* Write data */ +#define HPCS_WCHECK 051 /* Write check data */ +#define HPCS_WHEAD 063 /* Write header and data */ +#define HPCS_WCHEAD 053 /* Write check header and data */ +#define HPCS_READ 071 /* Read data */ +#define HPCS_RHEAD 073 /* Read header and data */ +#define HPCS_SEEK 005 /* Just seek */ +#define HPCS_RECAL 007 /* Recalibrate */ +#define HPCS_RTC 017 /* Return to centerline */ +#define HPCS_OFFSET 015 /* Offset */ +#define HPCS_SEARCH 031 /* Search */ +#define HPCS_UNLOAD 003 /* Unload pack (removable) */ +#define HPCS_RELEASE 013 /* Release massbuss port */ +#define HPCS_RPS 021 /* Read-in preset */ +#define HPCS_PA 023 /* Pack acknowledge */ +#define HPCS_DC 011 /* Drive clear */ + #define HPDS_VV 0x40 /* Volume valid, not changed */ #define HPDS_DRY 0x80 /* Drive ready to accept commands */ diff --git a/sys/arch/vax/mba/mbareg.h b/sys/arch/vax/mba/mbareg.h index 79e1acc4eba..77c00757c42 100644 --- a/sys/arch/vax/mba/mbareg.h +++ b/sys/arch/vax/mba/mbareg.h @@ -1,4 +1,4 @@ -/* $NetBSD: mbareg.h,v 1.1 1995/02/13 00:44:03 ragge Exp $ */ +/* $NetBSD: mbareg.h,v 1.2 1995/10/20 13:43:44 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden * All rights reserved. @@ -30,7 +30,14 @@ */ /* mbareg.h - 940320/ragge */ -#include "vax/mba/hpreg.h" + +struct mba_device { + u_int pad1; + u_int md_ds; /* unit status */ + u_int pad2[4]; + u_int md_dt; /* unit type */ + u_int pad3[25]; +}; struct mba_regs { u_int mba_csr; @@ -42,7 +49,7 @@ struct mba_regs { u_int mba_smr; u_int mba_car; u_int utrymme[248]; - struct hp_drv hp_drv[8]; + struct mba_device mba_md[8]; /* unit specific regs */ u_int mba_map[256]; }; @@ -78,3 +85,17 @@ struct mba_regs { #define MBASR_ERR_STAT 0x8 /* Error status */ #define MBASR_NRSTAT 0x2 /* No Response status */ +/* Definitions in mba_device md_ds */ +#define MBADS_DPR 0x100 /* Unit present */ + +/* Definitions in mba_device md_dt */ +#define MBADT_RP04 0x10 +#define MBADT_RP05 0x11 +#define MBADT_RP06 0x12 +#define MBADT_RP07 0x22 +#define MBADT_RM02 0x15 +#define MBADT_RM03 0x14 +#define MBADT_RM05 0x17 +#define MBADT_RM80 0x16 +#define MBADT_DRQ 0x800 /* Dual ported */ +#define MBADT_MOH 0x2000 /* Moving head device */ diff --git a/sys/arch/vax/stand/Makefile b/sys/arch/vax/stand/Makefile index b54fa987f1f..dd0f6293780 100644 --- a/sys/arch/vax/stand/Makefile +++ b/sys/arch/vax/stand/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 1995/09/16 13:18:27 ragge Exp $ +# $NetBSD: Makefile,v 1.5 1995/10/20 13:35:44 ragge Exp $ # INCPATH=-I. -I../../.. -I../.. -I../../../lib/libsa @@ -16,7 +16,7 @@ DEVS= autoconf.o hp.o ra.o tmscp.o LIBKERN= ${KERNLIB} .include "$S/lib/libsa/Makefile.inc" -LIBSA= ${SA_LIB} +LIBSA= ${SALIB} all: xxboot boot copy edlabel diff --git a/sys/arch/vax/stand/bootxx.c b/sys/arch/vax/stand/bootxx.c index b2f01417c95..b60d7e7931c 100644 --- a/sys/arch/vax/stand/bootxx.c +++ b/sys/arch/vax/stand/bootxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: bootxx.c,v 1.3 1995/09/16 13:01:06 ragge Exp $ */ +/* $NetBSD: bootxx.c,v 1.4 1995/10/20 13:35:43 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. * All rights reserved. @@ -48,6 +48,7 @@ #include "../include/sid.h" #include "../include/mtpr.h" #include "../include/reg.h" +#include "../include/rpb.h" #define NRSP 0 /* Kludge */ #define NCMD 0 /* Kludge */ @@ -93,7 +94,7 @@ main() is_mvax = 1; cpu_sie = *((int *) 0x20040004) >> 24; cpu_type |= cpu_sie; - rpb = bootregs[11]; + rpb = (struct rpb *)bootregs[11]; bootdev = rpb->devtyp; break; @@ -275,7 +276,7 @@ devopen(f, fname, file) * but it doesn't hurt to always get it. */ if (!is_tmscp) { - msg = getdisklabel(LABELOFFSET + RELOC, &lp); + msg = getdisklabel((void *)LABELOFFSET + RELOC, &lp); if (msg) { printf("getdisklabel: %s\n", msg); } @@ -321,7 +322,7 @@ romstrategy(sc, func, dblk, size, buf, rsize) case 17: /* MSCP */ uda.uda_cmd.mscp_seq.seq_lbn = dblk; uda.uda_cmd.mscp_seq.seq_bytecount = size; - uda.uda_cmd.mscp_seq.seq_buffer = buf; + uda.uda_cmd.mscp_seq.seq_buffer = (int)buf; uda.uda_cmd.mscp_unit = rpb->unit; command(M_OP_READ, 0); break; @@ -340,7 +341,8 @@ romstrategy(sc, func, dblk, size, buf, rsize) for (i = 0 ; i < size/512 ; i++) { uda.uda_cmd.mscp_seq.seq_lbn = 1; uda.uda_cmd.mscp_seq.seq_bytecount = 512; - uda.uda_cmd.mscp_seq.seq_buffer = buf + i * 512; + uda.uda_cmd.mscp_seq.seq_buffer = + (int)buf + i * 512; uda.uda_cmd.mscp_unit = rpb->unit; command(M_OP_READ, 0); } diff --git a/sys/arch/vax/stand/start.s b/sys/arch/vax/stand/start.s index 45a9c56169d..80040a7c2d7 100644 --- a/sys/arch/vax/stand/start.s +++ b/sys/arch/vax/stand/start.s @@ -1,4 +1,4 @@ -/* $NetBSD: start.s,v 1.4 1995/09/16 16:20:21 ragge Exp $ */ +/* $NetBSD: start.s,v 1.5 1995/10/20 13:35:41 ragge Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -43,7 +43,6 @@ #define ASSEMBLER #include "../include/mtpr.h" #include "../include/asm.h" -#include "bootdefs.h" _start: .globl _start # this is the symbolic name for the start # of code to be relocated. We can use this diff --git a/sys/arch/vax/vax/mscp.h b/sys/arch/vax/vax/mscp.h index 76817ce5984..1f538382277 100644 --- a/sys/arch/vax/vax/mscp.h +++ b/sys/arch/vax/vax/mscp.h @@ -1,4 +1,4 @@ -/* $NetBSD: mscp.h,v 1.2 1994/10/26 08:03:18 cgd Exp $ */ +/* $NetBSD: mscp.h,v 1.3 1995/10/20 13:51:56 ragge Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. @@ -64,6 +64,7 @@ #define M_OP_COMPHD 0x20 /* Compare host data command */ #define M_OP_READ 0x21 /* Read command */ #define M_OP_WRITE 0x22 /* Write command */ +#define M_OP_POS 0x25 /* Positioning command */ #define M_OP_AVAILATTN 0x40 /* Available attention message */ #define M_OP_DUPUNIT 0x41 /* Duplicate unit number attention message */ #define M_OP_ACCPATH 0x42 /* Access path attention message */ |