diff options
author | 2012-12-31 21:35:32 +0000 | |
---|---|---|
committer | 2012-12-31 21:35:32 +0000 | |
commit | 4d1e1d302c49e5938348e695c367ddb7d81e862d (patch) | |
tree | 82fff59f7189a937604c1b422ddcca10a9c9aacf | |
parent | Put the #ifdef SOCKBUF_DEBUG around sbcheck() into a SBCHECK macro. (diff) | |
download | wireguard-openbsd-4d1e1d302c49e5938348e695c367ddb7d81e862d.tar.xz wireguard-openbsd-4d1e1d302c49e5938348e695c367ddb7d81e862d.zip |
Switch mvme68k boot blocks to use the MI libsa loadfile routines to load
kernel images, instead of their own; gives us the ability to load ELF kernels
for free.
Fix many warnings, and generally make the code closer to the current mvme88k
boot blocks to help diffability.
Rewrite bugcrt and bugexec() as a short assembly shim around a
compiler-independent C block; this will allow compilers other than gcc2 to be
used, and removes the need for bugcrt to be compiled without optimization.
Crank all bootblocks versions.
45 files changed, 524 insertions, 525 deletions
diff --git a/sys/arch/mvme68k/include/loadfile_machdep.h b/sys/arch/mvme68k/include/loadfile_machdep.h new file mode 100644 index 00000000000..7f265583687 --- /dev/null +++ b/sys/arch/mvme68k/include/loadfile_machdep.h @@ -0,0 +1,49 @@ +/* $OpenBSD: loadfile_machdep.h,v 1.1 2012/12/31 21:35:32 miod Exp $ */ + +/*- + * Copyright (c) 1999 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. + * + * 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. + */ + +#define BOOT_AOUT +#define BOOT_ELF + +#define LOAD_KERNEL LOAD_ALL +#define COUNT_KERNEL COUNT_ALL + +#define LOADADDR(a) (((u_long)(a)) + offset) +#define ALIGNENTRY(a) ((u_long)(a) & ~0x0fff) +#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c)) +#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c)) +#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c)) +#define WARN(a) (void)(printf a, \ + printf((errno ? ": %s\n" : "\n"), \ + strerror(errno))) +#define PROGRESS(a) (void) printf a +#define ALLOC(a) alloc(a) +#define FREE(a, b) free(a, b) +#define OKMAGIC(a) ((a) == ZMAGIC) diff --git a/sys/arch/mvme68k/include/prom.h b/sys/arch/mvme68k/include/prom.h index efdc324a244..8f730145181 100644 --- a/sys/arch/mvme68k/include/prom.h +++ b/sys/arch/mvme68k/include/prom.h @@ -1,4 +1,4 @@ -/* $OpenBSD: prom.h,v 1.12 2012/07/05 04:23:33 guenther Exp $ */ +/* $OpenBSD: prom.h,v 1.13 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -171,16 +171,16 @@ struct mvmeprom_args { MVMEPROM_GETRES(ret); \ return (!(ret & 0x4)); /* return a 'status' */ -#define MVMEPROM_REG_DEVLUN "d0" -#define MVMEPROM_REG_CTRLLUN "d1" -#define MVMEPROM_REG_FLAGS "d4" -#define MVMEPROM_REG_CTRLADDR "a0" -#define MVMEPROM_REG_ENTRY "a1" -#define MVMEPROM_REG_CONFBLK "a2" -#define MVMEPROM_REG_NBARGSTART "a3" -#define MVMEPROM_REG_NBARGEND "a4" -#define MVMEPROM_REG_ARGSTART "a5" -#define MVMEPROM_REG_ARGEND "a6" +#define MVMEPROM_REG_DEVLUN d0 +#define MVMEPROM_REG_CTRLLUN d1 +#define MVMEPROM_REG_FLAGS d4 +#define MVMEPROM_REG_CTRLADDR a0 +#define MVMEPROM_REG_ENTRY a1 +#define MVMEPROM_REG_CONFBLK a2 +#define MVMEPROM_REG_NBARGSTART a3 +#define MVMEPROM_REG_NBARGEND a4 +#define MVMEPROM_REG_ARGSTART a5 +#define MVMEPROM_REG_ARGEND a6 #ifndef RB_NOSYM #define RB_NOSYM 0x4000 diff --git a/sys/arch/mvme68k/stand/Makefile.inc b/sys/arch/mvme68k/stand/Makefile.inc index 95ad8cc0e50..025757c6c45 100644 --- a/sys/arch/mvme68k/stand/Makefile.inc +++ b/sys/arch/mvme68k/stand/Makefile.inc @@ -1,8 +1,13 @@ -# $OpenBSD: Makefile.inc,v 1.8 2012/11/04 13:36:47 miod Exp $ +# $OpenBSD: Makefile.inc,v 1.9 2012/12/31 21:35:32 miod Exp $ MDEC_DIR?=/usr/mdec -CFLAGS+= -fno-stack-protector +CFLAGS+=-Wall -Werror -fno-stack-protector +#CFLAGS+=-fno-builtin-printf -fno-builtin-putchar -fno-builtin-vprintf +CFLAGS+=-DHEAP_START=${HEAP_START} # Load addresses for first and second stage bootstraps -STAGE1_RELOC=0x100000 -STAGE2_RELOC=0x6F0000 +STAGE1_RELOC= 0x00100000 +STAGE2_RELOC= 0x006f0000 + +# Base of the heap (ethernet buffers will be allocated below it) +HEAP_START= 0x00800000 diff --git a/sys/arch/mvme68k/stand/bootsd/Makefile b/sys/arch/mvme68k/stand/bootsd/Makefile index 982201bd85a..1ee41e0b103 100644 --- a/sys/arch/mvme68k/stand/bootsd/Makefile +++ b/sys/arch/mvme68k/stand/bootsd/Makefile @@ -1,5 +1,5 @@ # from: @(#)Makefile 8.1 (Berkeley) 6/10/93 -# $OpenBSD: Makefile,v 1.17 2012/08/21 14:46:19 pascal Exp $ +# $OpenBSD: Makefile,v 1.18 2012/12/31 21:35:32 miod Exp $ S= ${.CURDIR}/../../../.. DEFS= @@ -26,10 +26,10 @@ ALL= ${BOOTS} all: ${ALL} -bootsd: ${OBJS} ${BUGCRT} ${LIBS} +bootsd: ${BUGCRT} ${OBJS} ${LIBS} ${LD} ${LDFLAGS} -o $@ \ - ${BUGCRT} ${OBJS} ${LIBS} `cc -print-libgcc-file-name` -#${SRTOBJ} + ${BUGCRT} ${OBJS} ${LIBS} `cc -print-libgcc-file-name` + install: install ${INSTALL_STRIP} -c -m 555 -g bin -o bin ${BOOTS} ${DESTDIR}${MDEC_DIR} diff --git a/sys/arch/mvme68k/stand/bootsd/boot.c b/sys/arch/mvme68k/stand/bootsd/boot.c index 68baed9d3e9..91429b968d1 100644 --- a/sys/arch/mvme68k/stand/bootsd/boot.c +++ b/sys/arch/mvme68k/stand/bootsd/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.11 2003/06/02 23:27:51 millert Exp $ */ +/* $OpenBSD: boot.c,v 1.12 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: boot.c,v 1.2 1995/09/23 03:42:52 gwr Exp $ */ /*- @@ -49,7 +49,7 @@ int main() { char *cp, *file; - int io, flag, ret; + int flag, ret; int ask = 0; printf(">> OpenBSD MVME%x bootsd [%s]\n", bugargs.cputyp, version); diff --git a/sys/arch/mvme68k/stand/bootsd/version.c b/sys/arch/mvme68k/stand/bootsd/version.c index 220319b1bb6..b3e70faf756 100644 --- a/sys/arch/mvme68k/stand/bootsd/version.c +++ b/sys/arch/mvme68k/stand/bootsd/version.c @@ -1,8 +1,7 @@ -/* $OpenBSD: version.c,v 1.8 1998/08/18 04:17:08 smurph Exp $ */ +/* $OpenBSD: version.c,v 1.9 2012/12/31 21:35:32 miod Exp $ */ /* - * make a random change to this file when you want the bootblock - * revision to increase. like change this q to an x, or something. + * 1.9 kernel loaded with loadfile, a.out and ELF formats */ -char *version = "$Revision: 1.8 $"; +char *version = "1.9"; diff --git a/sys/arch/mvme68k/stand/bootst/Makefile b/sys/arch/mvme68k/stand/bootst/Makefile index 906d1d50478..0329c56399e 100644 --- a/sys/arch/mvme68k/stand/bootst/Makefile +++ b/sys/arch/mvme68k/stand/bootst/Makefile @@ -1,13 +1,14 @@ # from: @(#)Makefile 8.1 (Berkeley) 6/10/93 -# $OpenBSD: Makefile,v 1.13 2012/08/21 14:46:19 pascal Exp $ +# $OpenBSD: Makefile,v 1.14 2012/12/31 21:35:32 miod Exp $ SIZE?= size S= ${.CURDIR}/../../../.. -DEFS= +DEFS= -DSTANDALONE -DCOMPAT_NOLABEL INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \ -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa CFLAGS+=-O2 ${INCPATH} ${DEFS} ${COPTS} +LDFLAGS=-s -N -T ${STAGE2_RELOC} NOPIE= CLEANFILES+=stboot bootst bootst.bug @@ -28,9 +29,9 @@ ALL= ${BOOTS} all: ${ALL} -bootst.bug: ${OBJS} ${BUGCRT} ${LIBS} - ${LD} -s -N -T ${STAGE2_RELOC} ${BUGCRT} ${OBJS} ${LIBS} \ - `cc -print-libgcc-file-name` -o $@ +bootst.bug: ${BUGCRT} ${OBJS} ${LIBS} + ${LD} ${LDFLAGS} -o $@ \ + ${BUGCRT} ${OBJS} ${LIBS} `cc -print-libgcc-file-name` @${SIZE} bootst.bug bootst stboot: bootst.bug ${WRTVID} diff --git a/sys/arch/mvme68k/stand/bootst/boot.c b/sys/arch/mvme68k/stand/bootst/boot.c index 8c74d3d0a16..3afb55f4ad8 100644 --- a/sys/arch/mvme68k/stand/bootst/boot.c +++ b/sys/arch/mvme68k/stand/bootst/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.3 2003/06/02 23:27:51 millert Exp $ */ +/* $OpenBSD: boot.c,v 1.4 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: boot.c,v 1.2 1995/10/17 22:58:14 gwr Exp $ */ /*- @@ -40,33 +40,31 @@ #include "stand.h" #include "libsa.h" -int debug; -int errno; - -extern char *version; -char defname[32] = "2"; -char line[80]; - +extern char *version; +extern int errno; +int main() { - char *cp, *file; - int io, flag; + static char dnm[32] = "2"; + char line[80]; + char *filename; + int bflag = 0; printf(">> OpenBSD MVME%x tapeboot [%s]\n", bugargs.cputyp, version); - parse_args(&file, &flag); - file = defname; /* override */ + parse_args(&filename, &bflag); + filename = dnm; /* override */ - if (flag & RB_ASKNAME) { - printf("tapeboot: segment? [%s] ", defname); + if (bflag & RB_ASKNAME) { + printf("tapeboot: segment? [%s] ", dnm); gets(line); if (line[0]) - file = line; + filename = line; } - exec_mvme(file, flag); + exec_mvme(filename, bflag); - printf("tapeboot: %s: %s\n", file, strerror(errno)); + printf("tapeboot: %s: %s\n", filename, strerror(errno)); return(0); } diff --git a/sys/arch/mvme68k/stand/bootst/conf.c b/sys/arch/mvme68k/stand/bootst/conf.c index 0a812a1e98a..0e1576c6822 100644 --- a/sys/arch/mvme68k/stand/bootst/conf.c +++ b/sys/arch/mvme68k/stand/bootst/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.2 2001/07/04 08:06:53 niklas Exp $ */ +/* $OpenBSD: conf.c,v 1.3 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: conf.c,v 1.2 1995/10/17 22:58:17 gwr Exp $ */ #include <stand.h> @@ -11,11 +11,9 @@ struct fs_ops file_system[] = { rawfs_write, rawfs_seek, rawfs_stat, }, }; -int nfsys = 1; +int nfsys = sizeof(file_system) / sizeof(file_system[0]); struct devsw devsw[] = { { "tape", tape_strategy, tape_open, tape_close, tape_ioctl }, }; -int ndevs = 1; - -int debug; +int ndevs = sizeof(devsw) / sizeof(devsw[0]); diff --git a/sys/arch/mvme68k/stand/bootst/dev_tape.c b/sys/arch/mvme68k/stand/bootst/dev_tape.c index 9ea5166c83a..8f3e97c090c 100644 --- a/sys/arch/mvme68k/stand/bootst/dev_tape.c +++ b/sys/arch/mvme68k/stand/bootst/dev_tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_tape.c,v 1.4 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: dev_tape.c,v 1.5 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: dev_tape.c,v 1.2 1995/10/17 22:58:20 gwr Exp $ */ /* @@ -43,9 +43,6 @@ #include "stand.h" #include "libsa.h" - -extern int debug; - struct mvmeprom_dskio tape_ioreq; /* @@ -61,7 +58,6 @@ devopen(f, fname, file) char **file; { struct devsw *dp; - int error; *file = (char *)fname; dp = &devsw[0]; @@ -76,7 +72,7 @@ tape_open(f, fname) struct open_file *f; char *fname; /* partition number, i.e. "1" */ { - int error, part; + int part; struct mvmeprom_dskio *ti; /* @@ -106,7 +102,7 @@ tape_open(f, fname) f->f_devdata = ti; - return (error); + return (0); } int diff --git a/sys/arch/mvme68k/stand/bootst/rawfs.c b/sys/arch/mvme68k/stand/bootst/rawfs.c index 0243f66ff33..03beef84567 100644 --- a/sys/arch/mvme68k/stand/bootst/rawfs.c +++ b/sys/arch/mvme68k/stand/bootst/rawfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rawfs.c,v 1.5 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: rawfs.c,v 1.6 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: rawfs.c,v 1.1 1995/10/17 22:58:27 gwr Exp $ */ /* @@ -43,14 +43,12 @@ #include <stand.h> #include <rawfs.h> -extern int debug; - #define RAWFS_BSIZE 512 /* * In-core open file. */ -struct file { +struct cfile { daddr32_t fs_nextblk; /* block number to read next */ int fs_len; /* amount left in f_buf */ char * fs_ptr; /* read pointer into f_buf */ @@ -64,13 +62,13 @@ int rawfs_open(path, f) char *path; struct open_file *f; { - struct file *fs; + struct cfile *fs; /* * The actual PROM driver has already been opened. * Just allocate the I/O buffer, etc. */ - fs = alloc(sizeof(struct file)); + fs = alloc(sizeof(struct cfile)); fs->fs_nextblk = 0; fs->fs_len = 0; fs->fs_ptr = fs->fs_buf; @@ -82,12 +80,12 @@ int rawfs_open(path, f) int rawfs_close(f) struct open_file *f; { - struct file *fs; + struct cfile *fs; - fs = (struct file *) f->f_fsdata; + fs = (struct cfile *) f->f_fsdata; f->f_fsdata = (void *)0; - if (fs != (struct file *)0) + if (fs != (struct cfile *)0) free(fs, sizeof(*fs)); return (0); @@ -99,7 +97,7 @@ int rawfs_read(f, start, size, resid) size_t size; size_t *resid; { - struct file *fs = (struct file *)f->f_fsdata; + struct cfile *fs = (struct cfile *)f->f_fsdata; char *addr = start; int error = 0; size_t csize; @@ -161,16 +159,16 @@ static int rawfs_get_block(f) struct open_file *f; { - struct file *fs; + struct cfile *fs; int error; size_t len; - fs = (struct file *)f->f_fsdata; + fs = (struct cfile *)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); + fs->fs_nextblk, RAWFS_BSIZE, fs->fs_buf, &len); if (!error) { fs->fs_len = len; diff --git a/sys/arch/mvme68k/stand/bootst/version.c b/sys/arch/mvme68k/stand/bootst/version.c index 63e22d21e7b..80a6039abf9 100644 --- a/sys/arch/mvme68k/stand/bootst/version.c +++ b/sys/arch/mvme68k/stand/bootst/version.c @@ -1,8 +1,7 @@ -/* $OpenBSD: version.c,v 1.3 1997/04/22 16:13:40 gvf Exp $ */ +/* $OpenBSD: version.c,v 1.4 2012/12/31 21:35:32 miod Exp $ */ /* - * make a random change to this file when you want the bootblock - * revision to increase. like change this q to an x, or something. + * 1.4 kernel loaded with loadfile, a.out and ELF formats */ -char *version = "$Revision: 1.3 $"; +char *version = "1.4"; diff --git a/sys/arch/mvme68k/stand/bootxx/Makefile b/sys/arch/mvme68k/stand/bootxx/Makefile index 367fe3aa7ce..03e1f8cfa33 100644 --- a/sys/arch/mvme68k/stand/bootxx/Makefile +++ b/sys/arch/mvme68k/stand/bootxx/Makefile @@ -1,8 +1,8 @@ # from: @(#)Makefile 8.1 (Berkeley) 6/10/93 -# $OpenBSD: Makefile,v 1.9 2012/08/21 14:46:19 pascal Exp $ +# $OpenBSD: Makefile,v 1.10 2012/12/31 21:35:32 miod Exp $ S= ${.CURDIR}/../../../.. -DEFS= +DEFS=-DSTAGE2_RELOC=${STAGE2_RELOC} INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \ -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa CFLAGS+=-O2 ${INCPATH} ${DEFS} ${COPTS} @@ -14,7 +14,7 @@ CLEANFILES+=bootxx .include "${S}/arch/mvme68k/stand/libsa/Makefile.inc" .include "${S}/arch/mvme68k/stand/libz/Makefile.inc" -SRCS= bootxx.c conf.c version.c +SRCS= bootxx.c conf.c LIBS= ${LIBSA} ${LIBBUG} ${LIBZ} @@ -26,7 +26,7 @@ ALL= ${BOOTS} all: ${ALL} bootxx: ${OBJS} ${BUGCRT} ${LIBS} - ${LD} -N -T ${STAGE1_RELOC} ${BUGCRT} ${OBJS} ${LIBS} \ + ${LD} -S -N -T ${STAGE1_RELOC} ${BUGCRT} ${OBJS} ${LIBS} \ `cc -print-libgcc-file-name` -o $@ install: diff --git a/sys/arch/mvme68k/stand/bootxx/bootxx.c b/sys/arch/mvme68k/stand/bootxx/bootxx.c index 2050e7710fb..3d694b03537 100644 --- a/sys/arch/mvme68k/stand/bootxx/bootxx.c +++ b/sys/arch/mvme68k/stand/bootxx/bootxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bootxx.c,v 1.8 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: bootxx.c,v 1.9 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: bootxx.c,v 1.5 1995/10/13 21:44:57 gwr Exp $ */ /* @@ -53,8 +53,6 @@ /* * Boot device is derived from ROM provided information. */ -#define LOADADDR 0x6F0000 /* where to load level 2 bootstrap */ - /* (l2 must relocate itself) */ /* This determines the largest boot program we can load. */ #define MAXBLOCKNUM 64 @@ -65,16 +63,46 @@ * in terms of 512-byte blocks. Each non-zero value * will result in a read of block_size bytes. */ -int block_size = 512; /* default */ +size_t block_size = 512; /* default */ int block_count = MAXBLOCKNUM; /* length of table */ daddr32_t block_table[MAXBLOCKNUM] = { 0 }; -extern char *version; +int copyboot(struct open_file *, char *); -static int +int +main() +{ + struct open_file f; + char *addr; + int error; + +#ifdef DEBUG + printf("Boot: bug device: ctrl=%d, dev=%d\n", + bugargs.ctrl_lun, bugargs.dev_lun); +#endif + + f.f_flags = F_RAW; + if (devopen(&f, 0, &addr)) { + printf("bootxx: open failed\n"); + _rtt(); + } + + addr = (char *)STAGE2_RELOC; + error = copyboot(&f, addr); + f.f_dev->dv_close(&f); + if (!error) { + bugexec((u_int *)addr); + } + /* copyboot had a problem... */ + _rtt(); + return (0); +} + +int copyboot(struct open_file *fp, char *addr) { - int n, i, blknum; + size_t n; + int i, blknum; struct exec *x; addr -= sizeof(struct exec); /* assume OMAGIC, verify below */ @@ -112,29 +140,3 @@ copyboot(struct open_file *fp, char *addr) return 0; } - -main(int argc, char *argv[]) -{ - struct open_file f; - char *addr; - int n, error; - - printf("Boot: bug device: ctrl=%d, dev=%d\n", - bugargs.ctrl_lun, bugargs.dev_lun); - printf("\nbootxx: first level bootstrap program [%s]\n\n", version); - - f.f_flags = F_RAW; - if (devopen(&f, 0, &addr)) { - printf("bootxx: open failed\n"); - _rtt(); - } - - addr = (char *)LOADADDR; - error = copyboot(&f, addr); - f.f_dev->dv_close(&f); - if (!error) { - bugexec((void (*)(void))addr + 8); - } - /* copyboot had a problem... */ - _rtt(); -} diff --git a/sys/arch/mvme68k/stand/bootxx/version.c b/sys/arch/mvme68k/stand/bootxx/version.c deleted file mode 100644 index b02c2e17bd2..00000000000 --- a/sys/arch/mvme68k/stand/bootxx/version.c +++ /dev/null @@ -1,8 +0,0 @@ -/* $OpenBSD: version.c,v 1.2 1997/04/22 16:13:41 gvf Exp $ */ - -/* - * make a random change to this file when you want the bootblock - * revision to increase. like change this y to an x, or something. - */ - -char *version = "$Revision: 1.2 $"; diff --git a/sys/arch/mvme68k/stand/bugcrt/Makefile b/sys/arch/mvme68k/stand/bugcrt/Makefile index ca3b4a16be4..9f301468010 100644 --- a/sys/arch/mvme68k/stand/bugcrt/Makefile +++ b/sys/arch/mvme68k/stand/bugcrt/Makefile @@ -1,23 +1,14 @@ -# $OpenBSD: Makefile,v 1.9 2012/08/21 14:46:19 pascal Exp $ -# -# DO NOT OPTMIZE bugcrt (i.e. no "-O2") -# +# $OpenBSD: Makefile,v 1.10 2012/12/31 21:35:32 miod Exp $ S=${.CURDIR}/../../../.. CFLAGS=-I${.CURDIR}/../../include -I${.CURDIR}/../libbug -I${S}/lib/libsa \ -fomit-frame-pointer +AFLAGS+=-D_LOCORE NOPIE= -OBJS=bugcrt.o - -CLEANFILES+=bugcrt.out +OBJS=bugcrt.o bugcrtS.o all: ${OBJS} -bugcrt.o: bugcrt.c - ${COMPILE.c} -c $< - ${LD} -x -r ${.TARGET} -o ${.TARGET}ut - mv ${.TARGET}ut ${.TARGET} - install: lint tags: diff --git a/sys/arch/mvme68k/stand/bugcrt/Makefile.inc b/sys/arch/mvme68k/stand/bugcrt/Makefile.inc index a742cf4924f..1e55f97904d 100644 --- a/sys/arch/mvme68k/stand/bugcrt/Makefile.inc +++ b/sys/arch/mvme68k/stand/bugcrt/Makefile.inc @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile.inc,v 1.3 1997/10/20 00:33:45 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.4 2012/12/31 21:35:32 miod Exp $ BUG_CRT_DIR=${S}/arch/mvme68k/stand/bugcrt BUGCRT_DIR!= cd ${BUG_CRT_DIR}; \ printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx -BUGCRT=${BUGCRT_DIR}/bugcrt.o +BUGCRT=${BUGCRT_DIR}/bugcrtS.o ${BUGCRT_DIR}/bugcrt.o $(BUGCRT): .NOTMAIN __always_make_bugcrt @echo making sure the bugcrt is up to date... diff --git a/sys/arch/mvme68k/stand/bugcrt/bugcrt.c b/sys/arch/mvme68k/stand/bugcrt/bugcrt.c index 4ce5af18bb7..21d97b7fb14 100644 --- a/sys/arch/mvme68k/stand/bugcrt/bugcrt.c +++ b/sys/arch/mvme68k/stand/bugcrt/bugcrt.c @@ -1,4 +1,20 @@ -/* $OpenBSD: bugcrt.c,v 1.5 2003/08/20 00:25:08 deraadt Exp $ */ +/* $OpenBSD: bugcrt.c,v 1.6 2012/12/31 21:35:32 miod Exp $ */ + +/* + * Copyright (c) 2012 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #include <sys/types.h> #include <machine/prom.h> @@ -6,30 +22,26 @@ #include "libbug.h" #include "stand.h" -void __main(void); -void start(void); - -struct mvmeprom_args bugargs = { 1 }; /* not in BSS */ +struct mvmeprom_args bugargs = { .cputyp = -1 }; /* force out of .bss */ - asm (".text"); - asm (".long _start-0x10"); - asm (".long _start"); +void __main(void); +extern void main(void); void -start(void) +bugcrt_start(u_int dev_lun, u_int ctrl_lun, u_int flags, u_int ctrl_addr, + u_int entry, u_int conf_blk, char *arg_start, char *arg_end, + char *nbarg_start, char *nbarg_end) { - register int dev_lun asm (MVMEPROM_REG_DEVLUN); - register int ctrl_lun asm (MVMEPROM_REG_CTRLLUN); - register int flags asm (MVMEPROM_REG_FLAGS); - register int ctrl_addr asm (MVMEPROM_REG_CTRLADDR); - register int entry asm (MVMEPROM_REG_ENTRY); - register int conf_blk asm (MVMEPROM_REG_CONFBLK); - register char *arg_start asm (MVMEPROM_REG_ARGSTART); - register char *arg_end asm (MVMEPROM_REG_ARGEND); - register char *nbarg_start asm (MVMEPROM_REG_NBARGSTART); - register char *nbarg_end asm (MVMEPROM_REG_NBARGEND); extern int edata, end; - struct mvmeprom_brdid *id, *mvmeprom_getbrdid(void); + struct mvmeprom_brdid *id; + +#ifdef DEBUG + printf("BUG parameters: CLUN %x DLUN %x flags %x ctrl_addr %x\n", + dev_lun, ctrl_lun, flags, ctrl_addr); + printf("entry %x conf_blk %x\n", entry, conf_blk); + printf("arg %p %p\n", arg_start, arg_end); + printf("nbarg %p %p\n", nbarg_start, nbarg_end); +#endif bugargs.dev_lun = dev_lun; bugargs.ctrl_lun = ctrl_lun; @@ -41,46 +53,30 @@ start(void) bugargs.arg_end = arg_end; bugargs.nbarg_start = nbarg_start; bugargs.nbarg_end = nbarg_end; - *bugargs.arg_end = 0; bzero(&edata, (int)&end-(int)&edata); + *bugargs.arg_end = 0; id = mvmeprom_getbrdid(); bugargs.cputyp = id->model; main(); - _rtt(); - /* NOTREACHED */ } +extern void bugexec_final(u_int, u_int, u_int, u_int, u_int, u_int, char *, + char *, char *, char *, u_int, u_int); + void -__main(void) +bugexec(u_int *addr) { +#ifdef DEBUG + printf("%s: code %x stack %x\n", __func__, addr[1], addr[0]); +#endif + bugexec_final(bugargs.dev_lun, bugargs.ctrl_lun, bugargs.flags, + bugargs.ctrl_addr, bugargs.entry, bugargs.conf_blk, + bugargs.arg_start, bugargs.arg_end, bugargs.nbarg_start, + bugargs.nbarg_end, addr[1] /* pc */, addr[0] /* sp */); } - void -bugexec(void (*addr)(void)) +__main() { - register int dev_lun asm (MVMEPROM_REG_DEVLUN); - register int ctrl_lun asm (MVMEPROM_REG_CTRLLUN); - register int flags asm (MVMEPROM_REG_FLAGS); - register int ctrl_addr asm (MVMEPROM_REG_CTRLADDR); - register int entry asm (MVMEPROM_REG_ENTRY); - register int conf_blk asm (MVMEPROM_REG_CONFBLK); - register char *arg_start asm (MVMEPROM_REG_ARGSTART); - register char *arg_end asm (MVMEPROM_REG_ARGEND); - - dev_lun = bugargs.dev_lun; - ctrl_lun = bugargs.ctrl_lun; - flags = bugargs.flags; - ctrl_addr = bugargs.ctrl_addr; - entry = bugargs.entry; - conf_blk = bugargs.conf_blk; - arg_start = bugargs.arg_start; - arg_end = bugargs.arg_end; - - (*addr)(); - printf("bugexec: 0x%x returned!\n", addr); - - _rtt(); } - diff --git a/sys/arch/mvme68k/stand/bugcrt/bugcrtS.S b/sys/arch/mvme68k/stand/bugcrt/bugcrtS.S new file mode 100644 index 00000000000..f460f97386d --- /dev/null +++ b/sys/arch/mvme68k/stand/bugcrt/bugcrtS.S @@ -0,0 +1,94 @@ +/* $OpenBSD: bugcrtS.S,v 1.1 2012/12/31 21:35:32 miod Exp $ */ + +/* + * Copyright (c) 2012 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <machine/asm.h> +#include <machine/prom.h> + + .text + +ASLOCAL(__stack_end) + .long _ASM_LABEL(__stack_end) | sp + .long _C_LABEL(start) | pc + +ENTRY(start) + /* + * On entry, d0-d1, d4, a0-a6 contain the BUG incoming parameters. + */ + /* + * Set up stack. This is already done if booted by the BUG, but not + * if invoked from an old bootxx' bugexec(). + */ + leal _ASM_LABEL(__stack_end):l, sp + + /* + * Push arguments on stack. + */ + movl MVMEPROM_REG_NBARGEND, sp@- + movl MVMEPROM_REG_NBARGSTART, sp@- + movl MVMEPROM_REG_ARGEND, sp@- + movl MVMEPROM_REG_ARGSTART, sp@- + movl MVMEPROM_REG_CONFBLK, sp@- + movl MVMEPROM_REG_ENTRY, sp@- + movl MVMEPROM_REG_CTRLADDR, sp@- + movl MVMEPROM_REG_FLAGS, sp@- + movl MVMEPROM_REG_CTRLLUN, sp@- + movl MVMEPROM_REG_DEVLUN, sp@- + + /* + * Invoke the rest of the startup as C code. + */ + bsr _C_LABEL(bugcrt_start) + + bsr _C_LABEL(_rtt) + /* NOTREACHED */ + +ENTRY(bugexec_final) + /* + * Pop arguments to the appropriate registers. + */ + movl sp@(4 * 1), MVMEPROM_REG_DEVLUN + movl sp@(4 * 2), MVMEPROM_REG_CTRLLUN + movl sp@(4 * 3), MVMEPROM_REG_FLAGS + movl sp@(4 * 4), MVMEPROM_REG_CTRLADDR + movl sp@(4 * 5), MVMEPROM_REG_ENTRY + movl sp@(4 * 6), MVMEPROM_REG_CONFBLK + movl sp@(4 * 7), MVMEPROM_REG_ARGSTART + movl sp@(4 * 8), MVMEPROM_REG_ARGEND + movl sp@(4 * 9), MVMEPROM_REG_NBARGSTART + movl sp@(4 * 10), MVMEPROM_REG_NBARGEND + + /* + * Pop return address + */ + movl sp@(4 * 11), d2 + + /* + * Pop stack address + */ + movl sp@(4 * 12), sp + + /* + * Push return address + */ + movl _ASM_LABEL(bugexec_returned), sp@- + movl d2, sp@- + rts + +ASLOCAL(bugexec_returned) + bsr _C_LABEL(_rtt) + /* NOTREACHED */ diff --git a/sys/arch/mvme68k/stand/installboot/installboot.c b/sys/arch/mvme68k/stand/installboot/installboot.c index de66a3885dc..91bb3438e9a 100644 --- a/sys/arch/mvme68k/stand/installboot/installboot.c +++ b/sys/arch/mvme68k/stand/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: installboot.c,v 1.15 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: installboot.c,v 1.16 2012/12/31 21:35:32 miod Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -55,12 +55,12 @@ char cdev[80]; struct nlist nl[] = { #define X_BLOCK_SIZE 0 - {"_block_size"}, + { { "_block_size" } }, #define X_BLOCK_COUNT 1 - {"_block_count"}, + { { "_block_count" } }, #define X_BLOCK_TABLE 2 - {"_block_table"}, - {NULL} + { { "_block_table" } }, + { { NULL } } }; int *block_size_p; /* block size var. in prototype image */ @@ -138,7 +138,7 @@ main(argc, argv) /* XXX - Paranoia: Make sure size is aligned! */ if (protosize & (DEV_BSIZE - 1)) - err(1, "proto bootblock bad size=%d", protosize); + err(1, "proto bootblock bad size=%ld", protosize); /* Open and check raw disk device */ if ((devfd = open(dev, O_RDONLY, 0)) < 0) @@ -250,7 +250,7 @@ loadprotoblocks(fname, size) if (verbose) { printf("%s: entry point %#x\n", fname, eh.a_entry); printf("proto bootblock size %ld\n", *size); - printf("room for %d filesystem blocks at %#x\n", + printf("room for %d filesystem blocks at %#lx\n", maxblocknum, nl[X_BLOCK_TABLE].n_value); } @@ -388,8 +388,6 @@ vid_to_disklabel(char *dkname, char *bootproto) struct mvmedisklabel *pcpul; struct stat sb; unsigned int exe_addr; - unsigned short exe_addr_u; - unsigned short exe_addr_l; pcpul = (struct mvmedisklabel *)malloc(sizeof(struct mvmedisklabel)); bzero(pcpul, sizeof(struct mvmedisklabel)); diff --git a/sys/arch/mvme68k/stand/libbug/libbug.h b/sys/arch/mvme68k/stand/libbug/libbug.h index cf9ea220121..87f9c802e5f 100644 --- a/sys/arch/mvme68k/stand/libbug/libbug.h +++ b/sys/arch/mvme68k/stand/libbug/libbug.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libbug.h,v 1.4 2003/08/20 00:25:59 deraadt Exp $ */ +/* $OpenBSD: libbug.h,v 1.5 2012/12/31 21:35:32 miod Exp $ */ /* * prototypes and such. note that get/put char are in stand.h @@ -20,4 +20,4 @@ void mvmeprom_rtc_rd(struct mvmeprom_time *); extern struct mvmeprom_args bugargs; -void bugexec(void (*)(void)); +void bugexec(u_int *); diff --git a/sys/arch/mvme68k/stand/libsa/Makefile b/sys/arch/mvme68k/stand/libsa/Makefile index 97edc04ff9e..3bcbb664c9b 100644 --- a/sys/arch/mvme68k/stand/libsa/Makefile +++ b/sys/arch/mvme68k/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.22 2012/08/21 14:46:19 pascal Exp $ +# $OpenBSD: Makefile,v 1.23 2012/12/31 21:35:32 miod Exp $ LIB=sa @@ -13,12 +13,16 @@ S=${.CURDIR}/../../../.. SRCS+= bugdev.c clock.c parse_args.c exec_mvme.c -.PATH: $S/lib/libsa -SRCS+= alloc.c memcpy.c exit.c getfile.c gets.c globals.c printf.c \ - strerror.c memset.c memcmp.c strncpy.c strcmp.c strlen.c \ - snprintf.c close.c closeall.c dev.c dkcksum.c lseek.c open.c \ - nullfs.c read.c fstat.c ufs.c cread.c -SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c nfs.c rarp.c bootparam.c +.PATH: ${S}/lib/libsa +SRCS+= alloc.c memcpy.c exit.c getfile.c gets.c globals.c \ + printf.c strerror.c memset.c memcmp.c strncpy.c strcmp.c strlen.c \ + strlcpy.c strlcat.c snprintf.c \ + close.c closeall.c dev.c dkcksum.c \ + lseek.c open.c nullfs.c read.c fstat.c \ + ufs.c cread.c +SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c nfs.c \ + rarp.c bootparam.c +SRCS+= loadfile.c .PATH: ${S}/lib/libkern SRCS+= ashrdi3.c muldi3.c @@ -27,7 +31,8 @@ SRCS+= ashrdi3.c muldi3.c # -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG #DEFS= -DCOMPAT_UFS -DEFS= -D__INTERNAL_LIBSA_CREAD +DEFS= -D__INTERNAL_LIBSA_CREAD -D_STANDALONE +#DEFS+=-DNETIF_DEBUG INCL= -I${.CURDIR} -I${.CURDIR}/../libbug -I${S}/lib/libsa -I${S} CFLAGS+= ${XCFLAGS} -O2 ${COPTS} ${DEFS} ${DBG} ${INCL} diff --git a/sys/arch/mvme68k/stand/libsa/bugdev.c b/sys/arch/mvme68k/stand/libsa/bugdev.c index 03200d54e41..2ff54801db1 100644 --- a/sys/arch/mvme68k/stand/libsa/bugdev.c +++ b/sys/arch/mvme68k/stand/libsa/bugdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bugdev.c,v 1.7 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: bugdev.c,v 1.8 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -53,7 +53,8 @@ int devopen(struct open_file *f, const char *fname, char **file) { register struct bugsc_softc *pp = &bugsc_softc[0]; - int error, i, dn = 0, pn = 0; + size_t i; + int error, pn = 0; char *dev, *cp; static char iobuf[MAXBSIZE]; struct disklabel sdlabel; @@ -102,7 +103,7 @@ bugscstrategy(void *devdata, int func, daddr32_t dblk, size_t size, void *buf, { struct mvmeprom_dskio dio; register struct bugsc_softc *pp = (struct bugsc_softc *)devdata; - daddr32_t blk = dblk + pp->poff; + daddr32_t blk = dblk + pp->poff; twiddle(); @@ -122,7 +123,7 @@ bugscstrategy(void *devdata, int func, daddr32_t dblk, size_t size, void *buf, *rsize = dio.blk_cnt * BUG_BLOCK_SIZE; #ifdef DEBUG -printf("rsize %d status %x\n", *rsize, dio.status); + printf("rsize %d status %x\n", *rsize, dio.status); #endif if (dio.status) @@ -131,7 +132,7 @@ printf("rsize %d status %x\n", *rsize, dio.status); } int -bugscopen(struct open_file *f) +bugscopen(struct open_file *f, ...) { #ifdef DEBUG printf("bugscopen:\n"); diff --git a/sys/arch/mvme68k/stand/libsa/clock.c b/sys/arch/mvme68k/stand/libsa/clock.c index b0d66b22da9..cc9720d517e 100644 --- a/sys/arch/mvme68k/stand/libsa/clock.c +++ b/sys/arch/mvme68k/stand/libsa/clock.c @@ -1,19 +1,12 @@ -/* $OpenBSD: clock.c,v 1.4 2003/08/20 00:26:00 deraadt Exp $ */ +/* $OpenBSD: clock.c,v 1.5 2012/12/31 21:35:32 miod Exp $ */ #include <sys/types.h> +#include <sys/time.h> #include <machine/prom.h> #include "stand.h" #include "libsa.h" -/* - * BCD to decimal and decimal to BCD. - */ -#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) -#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) - -#define SECDAY (24 * 60 * 60) -#define SECYR (SECDAY * 365) #define LEAPYEAR(y) (((y) & 3) == 0) #define YEAR0 68 diff --git a/sys/arch/mvme68k/stand/libsa/exec_mvme.c b/sys/arch/mvme68k/stand/libsa/exec_mvme.c index 0f4c52a45ec..99c965832e0 100644 --- a/sys/arch/mvme68k/stand/libsa/exec_mvme.c +++ b/sys/arch/mvme68k/stand/libsa/exec_mvme.c @@ -1,5 +1,5 @@ -/* $OpenBSD: exec_mvme.c,v 1.8 2004/11/11 21:44:40 miod Exp $ */ -/* $NetBSD: exec_sun.c,v 1.5 1996/01/29 23:41:06 gwr Exp $ */ +/* $OpenBSD: exec_mvme.c,v 1.9 2012/12/31 21:35:32 miod Exp $ */ + /*- * Copyright (c) 1982, 1986, 1990, 1993 @@ -35,157 +35,43 @@ #include <sys/param.h> #include <sys/reboot.h> #include <machine/prom.h> -#include <a.out.h> #include "stand.h" #include "libsa.h" +#include <lib/libsa/loadfile.h> + /*ARGSUSED*/ void exec_mvme(file, flag) - char *file; - int flag; + char *file; + int flag; { - char *loadaddr; - register int io; - struct exec x; - int cc, magic; - void (*entry)(int, u_int, int, int, int, void *); - register char *cp; - register int *ip; - -#ifdef DEBUG - printf("exec_mvme: file=%s flag=0x%x\n", file, flag); -#endif - - io = open(file, 0); - if (io < 0) + u_long marks[MARK_MAX]; + int options; + int rc; + void (*entry)(int, int, int, int, int, int); + struct mvmeprom_brdid *id; + + id = mvmeprom_getbrdid(); + options = LOAD_KERNEL | COUNT_KERNEL; + if ((flag & RB_NOSYM) != 0) + options &= ~(LOAD_SYM | COUNT_SYM); + + marks[MARK_START] = 0; + rc = loadfile(file, marks, options); + if (rc != 0) return; - /* - * Read in the exec header, and validate it. - */ - if (read(io, (char *)&x, sizeof(x)) != sizeof(x)) - goto shread; - if (N_BADMAG(x)) { - errno = EFTYPE; - goto closeout; - } - - /* - * note: on the mvme ports, the kernel is linked in such a way that - * its entry point is the first item in .text, and thus a_entry can - * be used to determine both the load address and the entry point. - * (also note that we make use of the fact that the kernel will live - * in a VA == PA range of memory ... otherwise we would take - * loadaddr as a parameter and let the kernel relocate itself!) - * - * note that ZMAGIC files included the a.out header in the text area - * so we must mask that off (has no effect on the other formats) - */ - loadaddr = (void *)(x.a_entry & ~sizeof(x)); - - cp = loadaddr; - magic = N_GETMAGIC(x); - if (magic == ZMAGIC) - cp += sizeof(x); - entry = (void (*)(int, u_int, int, int, int, void *))cp; - - /* - * Leave a copy of the exec header before the text. - * The sun3 kernel uses this to verify that the - * symbols were loaded by this boot program. - */ - bcopy(&x, cp - sizeof(x), sizeof(x)); - - /* - * Read in the text segment. - */ - printf("%d", x.a_text); - cc = x.a_text; - if (magic == ZMAGIC) - cc = cc - sizeof(x); /* a.out header part of text in zmagic */ - if (read(io, cp, cc) != cc) - goto shread; - cp += cc; - - /* - * NMAGIC may have a gap between text and data. - */ - if (magic == NMAGIC) { - register int mask = N_PAGSIZ(x) - 1; - while ((int)cp & mask) - *cp++ = 0; - } - - /* - * Read in the data segment. - */ - printf("+%d", x.a_data); - if (read(io, cp, x.a_data) != x.a_data) - goto shread; - cp += x.a_data; - - /* - * Zero out the BSS section. - * (Kernel doesn't care, but do it anyway.) - */ - printf("+%d", x.a_bss); - cc = x.a_bss; - while ((int)cp & 3) { - *cp++ = 0; - --cc; - } - ip = (int *)cp; - cp += cc; - while ((char *)ip < cp) - *ip++ = 0; - - /* - * Read in the symbol table and strings. - * (Always set the symtab size word.) - */ - *ip++ = x.a_syms; - cp = (char *) ip; - - if (x.a_syms > 0 && (flag & RB_NOSYM) == 0) { - - /* Symbol table and string table length word. */ - cc = x.a_syms; - printf("+[%d", cc); - cc += sizeof(int); /* strtab length too */ - if (read(io, cp, cc) != cc) - goto shread; - cp += x.a_syms; - ip = (int *)cp; /* points to strtab length */ - cp += sizeof(int); - - /* String table. Length word includes itself. */ - cc = *ip; - printf("+%d]", cc); - cc -= sizeof(int); - if (cc <= 0) - goto shread; - if (read(io, cp, cc) != cc) - goto shread; - cp += cc; - } - printf("=0x%x\n", cp - loadaddr); - close(io); - - printf("Start @ 0x%x ...\n", (int)entry); + printf("Start @ 0x%lx\n", marks[MARK_START]); + printf("Controller Address 0x%x\n", bugargs.ctrl_addr); if (flag & RB_HALT) _rtt(); - (*entry)(flag, bugargs.ctrl_addr, bugargs.ctrl_lun, - bugargs.dev_lun, 0, cp); - printf("exec: kernel returned!\n"); - return; + entry = (void(*)(int, int, int, int, int, int))marks[MARK_START]; + (*entry)(flag, bugargs.ctrl_addr, bugargs.ctrl_lun, bugargs.dev_lun, + 0 /* bootpart */, marks[MARK_END]); -shread: - printf("exec: short read\n"); - errno = EIO; -closeout: - close(io); + printf("exec: kernel returned!\n"); return; } diff --git a/sys/arch/mvme68k/stand/libsa/libsa.h b/sys/arch/mvme68k/stand/libsa/libsa.h index 99473844a35..226e0e95db2 100644 --- a/sys/arch/mvme68k/stand/libsa/libsa.h +++ b/sys/arch/mvme68k/stand/libsa/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.7 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: libsa.h,v 1.8 2012/12/31 21:35:32 miod Exp $ */ /* * libsa prototypes @@ -7,7 +7,7 @@ #include "libbug.h" /* bugdev.c */ -int bugscopen(struct open_file *); +int bugscopen(struct open_file *, ...); int bugscclose(struct open_file *); int bugscioctl(struct open_file *, u_long, void *); int bugscstrategy(void *, int, daddr32_t, size_t, void *, size_t *); diff --git a/sys/arch/mvme68k/stand/libsa/parse_args.c b/sys/arch/mvme68k/stand/libsa/parse_args.c index 8af53693eb6..d88d5332df5 100644 --- a/sys/arch/mvme68k/stand/libsa/parse_args.c +++ b/sys/arch/mvme68k/stand/libsa/parse_args.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_args.c,v 1.7 2008/03/23 17:05:41 deraadt Exp $ */ +/* $OpenBSD: parse_args.c,v 1.8 2012/12/31 21:35:32 miod Exp $ */ /*- * Copyright (c) 1995 Theo de Raadt @@ -43,10 +43,10 @@ struct flags { { 'a', RB_ASKNAME }, { 'b', RB_HALT }, { 'c', RB_CONFIG }, - { 'y', RB_NOSYM }, { 'd', RB_KDB }, { 'm', RB_MINIROOT }, { 's', RB_SINGLE }, + { 'y', RB_NOSYM } }; int @@ -62,7 +62,7 @@ int *flagp; if (bugargs.arg_start != bugargs.arg_end) { ptr = bugargs.arg_start; - while (c = *ptr) { + while ((c = *ptr) != '\0') { while (c == ' ') c = *++ptr; if (c == '\0') diff --git a/sys/arch/mvme68k/stand/netboot/Makefile b/sys/arch/mvme68k/stand/netboot/Makefile index deac2566471..deae9ff665f 100644 --- a/sys/arch/mvme68k/stand/netboot/Makefile +++ b/sys/arch/mvme68k/stand/netboot/Makefile @@ -1,13 +1,14 @@ -# $OpenBSD: Makefile,v 1.16 2012/08/21 14:46:19 pascal Exp $ +# $OpenBSD: Makefile,v 1.17 2012/12/31 21:35:32 miod Exp $ SIZE?= size +STRIP?= strip S= ${.CURDIR}/../../../.. -DEFS= -DSUN_BOOTPARAMS -DRELOC=${STAGE2_RELOC} +DEFS= -DSUN_BOOTPARAMS +#-DNETIF_DEBUG INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \ -I${S} -I${S}/lib/libsa -CFLAGS+= -O2 ${DEFS} ${INCPATH} ${COPTS} -CFLAGS+=-DSTAGE2_RELOC=${STAGE2_RELOC} +CFLAGS+=-O2 ${DEFS} ${INCPATH} ${COPTS} CLEANFILES+=netboot netboot.bin .include "${S}/arch/mvme68k/stand/bugcrt/Makefile.inc" @@ -19,17 +20,18 @@ SRCS= boot.c conf.c version.c devopen.c dev_net.c SRCS+= if_ie.c if_le.c OBJS= ${SRCS:S/.c/.o/g} LIBS= ${LIBSA} ${LIBBUG} ${LIBZ} -LDFLAGS+= -nostdlib -s -N -T ${STAGE2_RELOC} +LDFLAGS+= -s -N -T ${STAGE2_RELOC} NOPIE= all: netboot.bin -netboot: ${OBJS} ${BUGCRT} ${LIBS} +netboot: ${SRTOBJ} ${BUGCRT} ${OBJS} ${LIBS} ${LD} ${LDFLAGS} -o $@ \ - ${SRTOBJ} ${BUGCRT} ${OBJS} ${LIBS} `cc -print-libgcc-file-name` + ${SRTOBJ} ${BUGCRT} ${OBJS} ${LIBS} `cc -print-libgcc-file-name` @${SIZE} $@ netboot.bin: netboot + ${STRIP} netboot dd ibs=32 skip=1 if=netboot of=$@ install: diff --git a/sys/arch/mvme68k/stand/netboot/boot.c b/sys/arch/mvme68k/stand/netboot/boot.c index db882f8ddb8..d29740b1fc7 100644 --- a/sys/arch/mvme68k/stand/netboot/boot.c +++ b/sys/arch/mvme68k/stand/netboot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.10 2003/08/20 00:26:00 deraadt Exp $ */ +/* $OpenBSD: boot.c,v 1.11 2012/12/31 21:35:32 miod Exp $ */ /*- * Copyright (c) 1995 Theo de Raadt @@ -62,20 +62,17 @@ #include "stand.h" #include "libsa.h" -/* - * Boot device is derived from ROM provided information. - */ -#define LOADADDR 0x10000 - extern char *version; -char line[80]; +char line[80]; -main(int argc, char *argv[]) +int +main() { char *cp, *file; int ask = 0, howto, ret; printf(">> OpenBSD MVME%x netboot [%s]\n", bugargs.cputyp, version); + /* cycle in the correct args */ bugargs.arg_start = bugargs.nbarg_start; bugargs.arg_end = bugargs.nbarg_end; @@ -104,4 +101,6 @@ main(int argc, char *argv[]) printf("boot: %s: %s\n", file, strerror(errno)); ask = 1; } + _rtt(); + return (0); } diff --git a/sys/arch/mvme68k/stand/netboot/conf.c b/sys/arch/mvme68k/stand/netboot/conf.c index 8c05fb02141..28f8b2b3073 100644 --- a/sys/arch/mvme68k/stand/netboot/conf.c +++ b/sys/arch/mvme68k/stand/netboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.5 2003/08/20 00:26:00 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.6 2012/12/31 21:35:32 miod Exp $ */ #include <sys/types.h> #include <netinet/in.h> @@ -6,7 +6,7 @@ #include <stand.h> #include <nfs.h> -#include "dev_net.h" +#include <dev_net.h> struct fs_ops file_system[] = { { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, @@ -14,9 +14,7 @@ struct fs_ops file_system[] = { int nfsys = sizeof(file_system) / sizeof(file_system[0]); struct devsw devsw[] = { - { "net", net_strategy, (int (*)(struct open_file *, ...))net_open, - net_close, net_ioctl - }, + { "net", net_strategy, net_open, net_close, net_ioctl }, }; int ndevs = sizeof(devsw) / sizeof(devsw[0]); diff --git a/sys/arch/mvme68k/stand/netboot/dev_net.c b/sys/arch/mvme68k/stand/netboot/dev_net.c index 27ddf254540..f947fef2178 100644 --- a/sys/arch/mvme68k/stand/netboot/dev_net.c +++ b/sys/arch/mvme68k/stand/netboot/dev_net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_net.c,v 1.9 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: dev_net.c,v 1.10 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -63,7 +63,7 @@ #include "netif.h" #include "config.h" #include "bootparam.h" -#include "dev_net.h" +#include "nfs.h" extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ @@ -73,7 +73,56 @@ char rootpath[FNAME_SIZE]; int netdev_sock = -1; static int open_count; -static int +int net_mountroot(struct open_file *, char *); + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + */ +int +net_open(struct open_file *f, char *devname) +{ + int error = 0; + + /* On first open, do netif open, mount, etc. */ + if (open_count == 0) { + /* Find network interface. */ + if ((netdev_sock = netif_open(devname)) < 0) + return (error=ENXIO); + if ((error = net_mountroot(f, devname)) != 0) + return (error); + } + open_count++; + f->f_devdata = nfs_root_node; + return (error); +} + +int +net_close(struct open_file *f) +{ + /* On last close, do netif close, etc. */ + if (open_count > 0) + if (--open_count == 0) + netif_close(netdev_sock); + f->f_devdata = NULL; + return (0); +} + +int +net_ioctl(struct open_file *f, u_long cmd, void *data) +{ + return EIO; +} + +int +net_strategy(void *devdata, int rw, daddr32_t blk, size_t size, void *buf, + size_t *rsize) +{ + return EIO; +} + + +int net_mountroot(struct open_file *f, char *devname) { int error; @@ -162,49 +211,3 @@ machdep_common_ether(u_char *ether) ether[5] = ea[5]; } } - -/* - * Called by devopen after it sets f->f_dev to our devsw entry. - * This opens the low-level device and sets f->f_devdata. - */ -int -net_open(struct open_file *f, char *devname) -{ - int error = 0; - - /* On first open, do netif open, mount, etc. */ - if (open_count == 0) { - /* Find network interface. */ - if ((netdev_sock = netif_open(devname)) < 0) - return (error=ENXIO); - if ((error = net_mountroot(f, devname)) != 0) - return (error); - } - open_count++; - f->f_devdata = nfs_root_node; - return (error); -} - -int -net_close(struct open_file *f) -{ - /* On last close, do netif close, etc. */ - if (open_count > 0) - if (--open_count == 0) - netif_close(netdev_sock); - f->f_devdata = NULL; -} - -int -net_ioctl(struct open_file *f, u_long cmd, void *data) -{ - return EIO; -} - -int -net_strategy(void *devdata, int rw, daddr32_t blk, size_t size, void *buf, - size_t *rsize) -{ - return EIO; -} - diff --git a/sys/arch/mvme68k/stand/netboot/dev_net.h b/sys/arch/mvme68k/stand/netboot/dev_net.h index fd374dd6bd1..648a99e084d 100644 --- a/sys/arch/mvme68k/stand/netboot/dev_net.h +++ b/sys/arch/mvme68k/stand/netboot/dev_net.h @@ -1,6 +1,6 @@ -/* $OpenBSD: dev_net.h,v 1.5 2011/03/13 00:13:53 deraadt Exp $ */ +/* $OpenBSD: dev_net.h,v 1.6 2012/12/31 21:35:32 miod Exp $ */ -int net_open(struct open_file *, char *); +int net_open(struct open_file *, ...); int net_close(struct open_file *); int net_ioctl(struct open_file *, u_long, void *); int net_strategy(void *, int, daddr32_t, size_t, void *, size_t *); diff --git a/sys/arch/mvme68k/stand/netboot/devopen.c b/sys/arch/mvme68k/stand/netboot/devopen.c index ebc264f105f..a4b7f7e93ba 100644 --- a/sys/arch/mvme68k/stand/netboot/devopen.c +++ b/sys/arch/mvme68k/stand/netboot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.2 2002/03/14 03:15:56 millert Exp $ */ +/* $OpenBSD: devopen.c,v 1.3 2012/12/31 21:35:32 miod Exp $ */ #include <sys/param.h> #include <stand.h> @@ -20,7 +20,6 @@ devopen(f, fname, file) char **file; { struct devsw *dp; - char *cp, *path, *devname; int error; *file = (char *)fname; diff --git a/sys/arch/mvme68k/stand/netboot/if_ie.c b/sys/arch/mvme68k/stand/netboot/if_ie.c index 0fb27fbe9a7..b647214f9b6 100644 --- a/sys/arch/mvme68k/stand/netboot/if_ie.c +++ b/sys/arch/mvme68k/stand/netboot/if_ie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ie.c,v 1.13 2009/02/17 18:42:06 miod Exp $ */ +/* $OpenBSD: if_ie.c,v 1.14 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -45,6 +45,7 @@ #include "libsa.h" #include "netif.h" #include "config.h" +#include "net.h" #include "i82586.h" #include "if_iereg.h" @@ -61,6 +62,7 @@ int ie_poll(struct iodesc *, void *, int); int ie_probe(struct netif *, void *); int ie_put(struct iodesc *, void *, size_t); void ie_reset(struct netif *, u_char *); +extern void machdep_common_ether(u_char *); struct netif_stats ie_stats; @@ -156,7 +158,7 @@ ie_reset(struct netif *nif, u_char *myea) { volatile struct iereg *ier = ie_softc.sc_reg; struct iemem *iem = ie_softc.sc_mem; - int timo = 10000, stat, i; + int timo = 10000, i; volatile int t; u_int a; @@ -281,13 +283,11 @@ ie_poll(struct iodesc *desc, void *pkt, int len) { volatile struct iereg *ier = ie_softc.sc_reg; struct iemem *iem = ie_softc.sc_mem; - u_char *p = pkt; static int slot; int length = 0; - u_int a; u_short status; - asm(".word 0xf518\n"); + asm(".word 0xf518\n"); /* pflusha */ status = iem->im_rfd[slot].ie_fd_status; if (status & IE_FD_BUSY) return (0); @@ -347,8 +347,6 @@ ie_put(struct iodesc *desc, void *pkt, size_t len) volatile struct iereg *ier = ie_softc.sc_reg; struct iemem *iem = ie_softc.sc_mem; u_char *p = pkt; - int timo = 10000, stat, i; - volatile int t; u_int a; int xx = 0; @@ -388,7 +386,7 @@ ie_put(struct iodesc *desc, void *pkt, size_t len) ier->ie_attention = 1; /* chan attention! */ if (ie_debug) { - printf("ie%d: send %d to %x:%x:%x:%x:%x:%x\n", + printf("ie%d: send %ld to %x:%x:%x:%x:%x:%x\n", desc->io_netif->nif_unit, len, p[0], p[1], p[2], p[3], p[4], p[5]); } @@ -422,8 +420,8 @@ ie_init(struct iodesc *desc, void *machdep_hint) bzero(&ie_softc, sizeof(ie_softc)); ie_softc.sc_reg = (struct iereg *) ie_config[desc->io_netif->nif_unit].phys_addr; - /* use 64KB below our code as buffers */ - ie_softc.sc_mem = (struct iemem *)(STAGE2_RELOC - 0x10000); + /* use 64KB below HEAP as buffers */ + ie_softc.sc_mem = (struct iemem *)(HEAP_START - 0x10000); ie_reset(desc->io_netif, desc->myea); printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname, nif->nif_unit, ether_sprintf(desc->myea)); diff --git a/sys/arch/mvme68k/stand/netboot/if_le.c b/sys/arch/mvme68k/stand/netboot/if_le.c index 083eb8f1b89..523273c2424 100644 --- a/sys/arch/mvme68k/stand/netboot/if_le.c +++ b/sys/arch/mvme68k/stand/netboot/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.11 2009/02/17 18:42:06 miod Exp $ */ +/* $OpenBSD: if_le.c,v 1.12 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -66,6 +66,7 @@ #include "libsa.h" #include "netif.h" #include "config.h" +#include "net.h" #include "if_lereg.h" @@ -80,6 +81,7 @@ int le_poll(struct iodesc *, void *, int); int le_probe(struct netif *, void *); int le_put(struct iodesc *, void *, size_t); void le_reset(struct netif *, u_char *); +extern void machdep_common_ether(u_char *); struct netif_stats le_stats; @@ -191,7 +193,7 @@ le_reset(nif, myea) struct lereg1 *ler1 = le_softc.sc_r1; struct lereg2 *ler2 = le_softc.sc_r2; unsigned int a; - int timo = 100000, stat, i; + int timo = 100000, stat = 0, i; if (le_debug) printf("le%d: le_reset called\n", nif->nif_unit); @@ -335,7 +337,7 @@ le_put(desc, pkt, len) volatile struct lereg1 *ler1 = le_softc.sc_r1; volatile struct lereg2 *ler2 = le_softc.sc_r2; volatile struct letmd *tmd; - int timo = 100000, stat, i; + int timo = 100000, stat = 0; unsigned int a; ler1->ler1_rap = LE_CSR0; @@ -392,7 +394,7 @@ le_put(desc, pkt, len) return -1; } if (le_debug) { - printf("le%d: le_put() successful: sent %d\n", + printf("le%d: le_put() successful: sent %ld\n", desc->io_netif->nif_unit, len); printf("le%d: le_put(): tmd1_bits: %x tmd3: %x\n", desc->io_netif->nif_unit, @@ -435,7 +437,7 @@ le_init(desc, machdep_hint) bzero(&le_softc, sizeof(le_softc)); le_softc.sc_r1 = (struct lereg1 *) le_config[desc->io_netif->nif_unit].phys_addr; - le_softc.sc_r2 = (struct lereg2 *)(STAGE2_RELOC - LEMEMSIZE); + le_softc.sc_r2 = (struct lereg2 *)(HEAP_START - LEMEMSIZE); le_reset(desc->io_netif, desc->myea); printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname, nif->nif_unit, ether_sprintf(desc->myea)); diff --git a/sys/arch/mvme68k/stand/netboot/version.c b/sys/arch/mvme68k/stand/netboot/version.c index 5cf3b3e5745..be48e05d4e1 100644 --- a/sys/arch/mvme68k/stand/netboot/version.c +++ b/sys/arch/mvme68k/stand/netboot/version.c @@ -1,8 +1,7 @@ -/* $OpenBSD: version.c,v 1.7 2009/02/17 18:42:45 miod Exp $ */ +/* $OpenBSD: version.c,v 1.8 2012/12/31 21:35:32 miod Exp $ */ /* - * make a random change to this file when you want the bootblock - * revision to increase. like change this q to an x, or something. + * 1.8 kernel loaded with loadfile, a.out and ELF formats */ -char *version = "$Revision: 1.7 $"; +char *version = "1.8"; diff --git a/sys/arch/mvme68k/stand/prtvid/prtvid.c b/sys/arch/mvme68k/stand/prtvid/prtvid.c index 640803c738d..22b496b443c 100644 --- a/sys/arch/mvme68k/stand/prtvid/prtvid.c +++ b/sys/arch/mvme68k/stand/prtvid/prtvid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prtvid.c,v 1.7 2007/06/17 00:28:56 deraadt Exp $ */ +/* $OpenBSD: prtvid.c,v 1.8 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn <drahn@openbsd.org> @@ -20,6 +20,8 @@ #include <sys/disklabel.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #define __DBINTERFACE_PRIVATE #include <db.h> @@ -67,78 +69,80 @@ main(int argc, char *argv[]) if (BYTE_ORDER != BIG_ENDIAN) swabvid(cdl); - printf("vid_id %s %x\n", cdl->vid_id, + printf("vid_id %s %lx\n", cdl->vid_id, (char *)&(cdl->vid_id[4]) - (char *)cdl); - printf("vid_oss %x %x\n", cdl->vid_oss, + printf("vid_oss %x %lx\n", cdl->vid_oss, (char *)&(cdl->vid_oss) - (char *)cdl); - printf("vid_osl %x %x\n", cdl->vid_osl, + printf("vid_osl %x %lx\n", cdl->vid_osl, (char *)&(cdl->vid_osl) - (char *)cdl); - printf("vid_osa_u %x %x\n", cdl->vid_osa_u, + printf("vid_osa_u %x %lx\n", cdl->vid_osa_u, (char *)&(cdl->vid_osa_u) - (char *)cdl); - printf("vid_osa_l %x %x\n", cdl->vid_osa_l, + printf("vid_osa_l %x %lx\n", cdl->vid_osa_l, (char *)&(cdl->vid_osa_l) - (char *)cdl); - printf("vid_vd %x\n", + printf("vid_vd %lx\n", (char *)&(cdl->vid_vd) - (char *)cdl); - printf("vid_cas %x %x\n", cdl->vid_cas, + printf("vid_cas %x %lx\n", cdl->vid_cas, (char *)&(cdl->vid_cas) - (char *)cdl); - printf("vid_cal %x %x\n", cdl->vid_cal, + printf("vid_cal %x %lx\n", cdl->vid_cal, (char *)&(cdl->vid_cal) - (char *)cdl); - printf("vid_moto %s %x\n", cdl->vid_mot, + printf("vid_moto %s %lx\n", cdl->vid_mot, (char *)&(cdl->vid_mot[0]) - (char *)cdl); if (BYTE_ORDER != BIG_ENDIAN) swabcfg(cdl); - printf("cfg_atm %x %x\n", cdl->cfg_atm, + printf("cfg_atm %x %lx\n", cdl->cfg_atm, (char *)&(cdl->cfg_atm) - (char *)(cdl)); - printf("cfg_prm %x %x\n", cdl->cfg_prm, + printf("cfg_prm %x %lx\n", cdl->cfg_prm, (char *)&(cdl->cfg_prm) - (char *)(cdl)); - printf("cfg_atw %x %x\n", cdl->cfg_atw, + printf("cfg_atw %x %lx\n", cdl->cfg_atw, (char *)&(cdl->cfg_atw) - (char *)(cdl)); - printf("cfg_rec %x %x\n",(long)cdl->cfg_rec, + printf("cfg_rec %lx %lx\n",(long)cdl->cfg_rec, (char *)&(cdl->cfg_rec) - (char *)(cdl)); - printf("cfg_spt %x %x\n", cdl->cfg_spt, + printf("cfg_spt %x %lx\n", cdl->cfg_spt, (char *)&(cdl->cfg_spt) - (char *)(cdl)); - printf("cfg_hds %x %x\n", cdl->cfg_hds, + printf("cfg_hds %x %lx\n", cdl->cfg_hds, (char *)&(cdl->cfg_hds) - (char *)(cdl)); - printf("cfg_trk %x %x\n", cdl->cfg_trk, + printf("cfg_trk %x %lx\n", cdl->cfg_trk, (char *)&(cdl->cfg_trk) - (char *)(cdl)); - printf("cfg_ilv %x %x\n", cdl->cfg_ilv, + printf("cfg_ilv %x %lx\n", cdl->cfg_ilv, (char *)&(cdl->cfg_ilv) - (char *)(cdl)); - printf("cfg_sof %x %x\n", cdl->cfg_sof, + printf("cfg_sof %x %lx\n", cdl->cfg_sof, (char *)&(cdl->cfg_sof) - (char *)(cdl)); - printf("cfg_psm %x %x\n", cdl->cfg_psm, + printf("cfg_psm %x %lx\n", cdl->cfg_psm, (char *)&(cdl->cfg_psm) - (char *)(cdl)); - printf("cfg_shd %x %x\n", cdl->cfg_shd, + printf("cfg_shd %x %lx\n", cdl->cfg_shd, (char *)&(cdl->cfg_shd) - (char *)(cdl)); - printf("cfg_pcom %x %x\n", cdl->cfg_pcom, + printf("cfg_pcom %x %lx\n", cdl->cfg_pcom, (char *)&(cdl->cfg_pcom) - (char *)(cdl)); - printf("cfg_ssr %x %x\n", cdl->cfg_ssr, + printf("cfg_ssr %x %lx\n", cdl->cfg_ssr, (char *)&(cdl->cfg_ssr) - (char *)(cdl)); - printf("cfg_rwcc %x %x\n", cdl->cfg_rwcc, + printf("cfg_rwcc %x %lx\n", cdl->cfg_rwcc, (char *)&(cdl->cfg_rwcc) - (char *)(cdl)); - printf("cfg_ecc %x %x\n", cdl->cfg_ecc, + printf("cfg_ecc %x %lx\n", cdl->cfg_ecc, (char *)&(cdl->cfg_ecc) - (char *)(cdl)); - printf("cfg_eatm %x %x\n", cdl->cfg_eatm, + printf("cfg_eatm %x %lx\n", cdl->cfg_eatm, (char *)&(cdl->cfg_eatm) - (char *)(cdl)); - printf("cfg_eprm %x %x\n", cdl->cfg_eprm, + printf("cfg_eprm %x %lx\n", cdl->cfg_eprm, (char *)&(cdl->cfg_eprm) - (char *)(cdl)); - printf("cfg_eatw %x %x\n", cdl->cfg_eatw, + printf("cfg_eatw %x %lx\n", cdl->cfg_eatw, (char *)&(cdl->cfg_eatw) - (char *)(cdl)); - printf("cfg_gpb1 %x %x\n", cdl->cfg_gpb1, + printf("cfg_gpb1 %x %lx\n", cdl->cfg_gpb1, (char *)&(cdl->cfg_gpb1) - (char *)(cdl)); - printf("cfg_gpb2 %x %x\n", cdl->cfg_gpb2, + printf("cfg_gpb2 %x %lx\n", cdl->cfg_gpb2, (char *)&(cdl->cfg_gpb2) - (char *)(cdl)); - printf("cfg_gpb3 %x %x\n", cdl->cfg_gpb3, + printf("cfg_gpb3 %x %lx\n", cdl->cfg_gpb3, (char *)&(cdl->cfg_gpb3) - (char *)(cdl)); - printf("cfg_gpb4 %x %x\n", cdl->cfg_gpb4, + printf("cfg_gpb4 %x %lx\n", cdl->cfg_gpb4, (char *)&(cdl->cfg_gpb4) - (char *)(cdl)); - printf("cfg_ssc %x %x\n", cdl->cfg_ssc, + printf("cfg_ssc %x %lx\n", cdl->cfg_ssc, (char *)&(cdl->cfg_ssc) - (char *)(cdl)); - printf("cfg_runit %x %x\n", cdl->cfg_runit, + printf("cfg_runit %x %lx\n", cdl->cfg_runit, (char *)&(cdl->cfg_runit) - (char *)(cdl)); - printf("cfg_rsvc1 %x %x\n", cdl->cfg_rsvc1, + printf("cfg_rsvc1 %x %lx\n", cdl->cfg_rsvc1, (char *)&(cdl->cfg_rsvc1) - (char *)(cdl)); - printf("cfg_rsvc2 %x %x\n", cdl->cfg_rsvc2, + printf("cfg_rsvc2 %x %lx\n", cdl->cfg_rsvc2, (char *)&(cdl->cfg_rsvc2) - (char *)(cdl)); + + return 0; } diff --git a/sys/arch/mvme68k/stand/sboot/Makefile b/sys/arch/mvme68k/stand/sboot/Makefile index f0b5d605a50..396c6c8110a 100644 --- a/sys/arch/mvme68k/stand/sboot/Makefile +++ b/sys/arch/mvme68k/stand/sboot/Makefile @@ -1,10 +1,11 @@ -# $OpenBSD: Makefile,v 1.11 2012/11/04 13:36:47 miod Exp $ +# $OpenBSD: Makefile,v 1.12 2012/12/31 21:35:32 miod Exp $ S= ${.CURDIR}/../../../.. INCL?= -I${.CURDIR} -I${.CURDIR}/../libsa -I${S}/lib/libsa -I${S} HOSTCFLAGS?= ${CFLAGS} +CFLAGS+=-D_STANDALONE CFLAGS+=-DSTAGE2_RELOC=${STAGE2_RELOC} -COPTS+= ${DEFS} ${INCL} +COPTS?= ${DEFS} ${INCL} .include "${S}/arch/mvme68k/stand/libbug/Makefile.inc" .include "${S}/arch/mvme68k/stand/libsa/Makefile.inc" diff --git a/sys/arch/mvme68k/stand/sboot/clock.c b/sys/arch/mvme68k/stand/sboot/clock.c index 3ce004677d0..d9a1b040c2e 100644 --- a/sys/arch/mvme68k/stand/sboot/clock.c +++ b/sys/arch/mvme68k/stand/sboot/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.8 2012/12/05 23:20:13 deraadt Exp $ */ +/* $OpenBSD: clock.c,v 1.9 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1992, 1993 @@ -47,32 +47,25 @@ */ #include <sys/types.h> +#include <sys/time.h> #include "sboot.h" #include "clockreg.h" static struct clockreg *clockreg = (struct clockreg *) CLOCK_ADDR; -/* - * BCD to decimal and decimal to BCD. - */ -#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) -#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) - -#define SECDAY (24 * 60 * 60) -#define SECYR (SECDAY * 365) #define LEAPYEAR(y) (((y) & 3) == 0) /* * This code is defunct after 2068. * Will Unix still be here then?? */ -const short dayyr[12] = +const unsigned short dayyr[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; -static u_long +static unsigned long chiptotime(int sec, int min, int hour, int day, int mon, int year) { - register int days, yr; + int days, yr; sec = FROMBCD(sec); min = FROMBCD(min); @@ -99,10 +92,10 @@ chiptotime(int sec, int min, int hour, int day, int mon, int year) /* * Set up the system's time, given a `reasonable' time value. */ -u_long -ttime(void) +unsigned long +ttime() { - register struct clockreg *cl = clockreg; + struct clockreg *cl = clockreg; int sec, min, hour, day, mon, year; cl->cl_csr |= CLK_READ; /* enable read (stop time) */ diff --git a/sys/arch/mvme68k/stand/sboot/etherfun.c b/sys/arch/mvme68k/stand/sboot/etherfun.c index 1857f1e245d..991f1f8efd3 100644 --- a/sys/arch/mvme68k/stand/sboot/etherfun.c +++ b/sys/arch/mvme68k/stand/sboot/etherfun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: etherfun.c,v 1.8 2012/12/05 23:20:13 deraadt Exp $ */ +/* $OpenBSD: etherfun.c,v 1.9 2012/12/31 21:35:32 miod Exp $ */ /* * @@ -104,7 +104,7 @@ do_send_tftp(int mesgtype) if (mesgtype == 0) { tot = tftp_r + (sizeof(MSG) - 1); - myport = (u_short) ttime(); + myport = (u_short)ttime(); if (myport < 1000) myport += 1000; servport = FTP_PORT; /* to start */ diff --git a/sys/arch/mvme68k/stand/sboot/if_le.c b/sys/arch/mvme68k/stand/sboot/if_le.c index 6ec1e04063a..2d502bbfb57 100644 --- a/sys/arch/mvme68k/stand/sboot/if_le.c +++ b/sys/arch/mvme68k/stand/sboot/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.8 2012/12/05 23:20:13 deraadt Exp $ */ +/* $OpenBSD: if_le.c,v 1.9 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -66,7 +66,7 @@ struct { int next_tmd; } le_softc; -static void +void le_error(char *str, struct lereg1 *ler1) { /* ler1->ler1_rap = LE_CSRO done in caller */ @@ -86,13 +86,13 @@ le_error(char *str, struct lereg1 *ler1) } } -static void +void le_reset(u_char *myea) { struct lereg1 *ler1 = le_softc.sc_r1; struct lereg2 *ler2 = le_softc.sc_r2; unsigned int a; - int timo = 100000, stat, i; + int timo = 100000, stat = 0, i; ler1->ler1_rap = LE_CSR0; ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */ @@ -161,7 +161,7 @@ le_reset(u_char *myea) ler1->ler1_rdp = LE_C0_STRT; } -static int +int le_poll(void *pkt, int len) { struct lereg1 *ler1 = le_softc.sc_r1; @@ -218,7 +218,7 @@ le_put(u_char *pkt, size_t len) struct lereg1 *ler1 = le_softc.sc_r1; struct lereg2 *ler2 = le_softc.sc_r2; struct letmd *tmd; - int timo = 100000, stat, i; + int timo = 100000, stat = 0; unsigned int a; ler1->ler1_rap = LE_CSR0; @@ -305,7 +305,6 @@ le_get(u_char *pkt, size_t len, u_long timeout) void le_init(void) { - caddr_t addr; int *ea = (int *) LANCE_ADDR; u_long *eram = (u_long *) ERAM_ADDR; u_long e = *ea; diff --git a/sys/arch/mvme68k/stand/sboot/sboot.c b/sys/arch/mvme68k/stand/sboot/sboot.c index 7ee1d6e7bc6..e5d042bd8a3 100644 --- a/sys/arch/mvme68k/stand/sboot/sboot.c +++ b/sys/arch/mvme68k/stand/sboot/sboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sboot.c,v 1.11 2012/12/05 23:20:13 deraadt Exp $ */ +/* $OpenBSD: sboot.c,v 1.12 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -55,6 +55,7 @@ */ #include <sys/types.h> +#include "stand.h" #include "sboot.h" int diff --git a/sys/arch/mvme68k/stand/sboot/sboot.h b/sys/arch/mvme68k/stand/sboot/sboot.h index 45422ac74b5..320d69a11d8 100644 --- a/sys/arch/mvme68k/stand/sboot/sboot.h +++ b/sys/arch/mvme68k/stand/sboot/sboot.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sboot.h,v 1.9 2012/11/04 13:36:47 miod Exp $ */ +/* $OpenBSD: sboot.h,v 1.10 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Charles D. Cranor and Seth Widoff @@ -35,10 +35,9 @@ * sboot.h: stuff for MVME147's serial line boot */ -extern caddr_t end; +void go(unsigned int, const char *, const char *); /* console */ -void puts(char *); char *ngets(char *, int); /* sboot */ diff --git a/sys/arch/mvme68k/stand/sboot/srec.c b/sys/arch/mvme68k/stand/sboot/srec.c index 92d0d3b78f9..7e7050c4650 100644 --- a/sys/arch/mvme68k/stand/sboot/srec.c +++ b/sys/arch/mvme68k/stand/sboot/srec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: srec.c,v 1.6 2012/11/04 13:34:51 miod Exp $ */ +/* $OpenBSD: srec.c,v 1.7 2012/12/31 21:35:32 miod Exp $ */ /* * Public domain, believed to be by Mike Price. @@ -8,6 +8,8 @@ #include <unistd.h> #include <stdio.h> #include <stdint.h> +#include <stdlib.h> +#include <string.h> #include <ctype.h> size_t get32(char *, size_t); diff --git a/sys/arch/mvme68k/stand/wrtvid/wrtvid.c b/sys/arch/mvme68k/stand/wrtvid/wrtvid.c index d187203e4ba..887c7cdeeac 100644 --- a/sys/arch/mvme68k/stand/wrtvid/wrtvid.c +++ b/sys/arch/mvme68k/stand/wrtvid/wrtvid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wrtvid.c,v 1.7 2007/06/17 00:28:56 deraadt Exp $ */ +/* $OpenBSD: wrtvid.c,v 1.8 2012/12/31 21:35:32 miod Exp $ */ /* * Copyright (c) 1995 Dale Rahn <drahn@openbsd.org> @@ -22,6 +22,8 @@ #include <fcntl.h> #include <unistd.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #define __DBINTERFACE_PRIVATE #include <db.h> @@ -82,11 +84,8 @@ main(int argc, char *argv[]) int tape_vid; int tape_exe; unsigned int exe_addr; - unsigned short exe_addr_u; - unsigned short exe_addr_l; char *filename; char fileext[256]; - char filebase[256]; if (argc == 0) filename = "a.out"; |