From: miod Date: Tue, 10 Jan 2023 17:10:57 +0000 (+0000) Subject: Switch the luna88k boot loader to the MI boot code, to ease future maintainence X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8352e4cbf29a350bf5cbfdf08f7f8c573d9b4847;p=openbsd Switch the luna88k boot loader to the MI boot code, to ease future maintainence of it. Crank version to 0.8. ok aoyama@ --- diff --git a/sys/arch/luna88k/stand/boot/Makefile b/sys/arch/luna88k/stand/boot/Makefile index 0f79a1e1692..b821d77ba8c 100644 --- a/sys/arch/luna88k/stand/boot/Makefile +++ b/sys/arch/luna88k/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2019/12/10 11:28:13 aoyama Exp $ +# $OpenBSD: Makefile,v 1.13 2023/01/10 17:10:57 miod Exp $ # $NetBSD: Makefile,v 1.9 2013/01/22 15:48:40 tsutsui Exp $ # @(#)Makefile 8.2 (Berkeley) 8/15/93 @@ -24,12 +24,9 @@ LINKFORMAT= -static -N -Ttext ${TEXTADDR} -T ${LDSCRIPT} \ SRCS= locore.S SRCS+= init_main.c SRCS+= fault.c setjmp.S -SRCS+= bcd.c SRCS+= devopen.c SRCS+= conf.c -SRCS+= getline.c parse.c -SRCS+= boot.c -SRCS+= cons.c prf.c awaitkey.c +SRCS+= exec.c SRCS+= sio.c SRCS+= bmc.c bmd.c font.c kbd.c SRCS+= sc.c sd.c @@ -44,11 +41,15 @@ PROG= boot ### find out what to use for libkern .PATH: ${S}/lib/libkern SRCS+= memcpy.c memmove.c strlcat.c strlcpy.c strlen.c -SRCS+= muldi3.c negdi2.c ashldi3.c ashrdi3.c +SRCS+= muldi3.c negdi2.c ashldi3.c ashrdi3.c moddi3.c ### find out what to use for libsa .PATH: ${S}/lib/libsa -SRCS+= arc4.c strtol.c +SRCS+= arc4.c ctime.c hexdump.c strtol.c strtoll.c + +### MI boot code +.PATH: ${S}/stand/boot +SRCS+= boot.c cmd.c vars.c SAREL= SADST= ${.CURDIR}/${__objdir} diff --git a/sys/arch/luna88k/stand/boot/awaitkey.c b/sys/arch/luna88k/stand/boot/awaitkey.c deleted file mode 100644 index 990e98cf0e3..00000000000 --- a/sys/arch/luna88k/stand/boot/awaitkey.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $OpenBSD: awaitkey.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ -/* $NetBSD: awaitkey.c,v 1.1 2013/01/21 11:58:12 tsutsui Exp $ */ - -/*- - * Copyright (c) 2013 Izumi Tsutsui. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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. - */ - -#include -#include - -static void print_countdown(const char *, int); - -#define FMTLEN 40 - -static void -print_countdown(const char *pfmt, int n) -{ - int len, i; - char fmtbuf[FMTLEN]; - - len = snprintf(fmtbuf, FMTLEN, pfmt, n); - printf("%s", fmtbuf); - for (i = 0; i < len; i++) - putchar('\b'); -} - -/* - * awaitkey(const char *pfmt, int timeout, int tell) - * - * Wait timeout seconds until any input from stdin. - * print countdown message using "pfmt" if tell is nonzero. - * Requires tgetchar(), which returns 0 if there is no input. - */ -char -awaitkey(const char *pfmt, int timeout, int tell) -{ - uint32_t otick; - char c = 0; - - if (timeout <= 0) - goto out; - - if (tell) - print_countdown(pfmt, timeout); - - otick = getsecs(); - - for (;;) { - c = tgetchar(); - if (c != 0) - break; - if (getsecs() != otick) { - otick = getsecs(); - if (--timeout == 0) - break; - if (tell) - print_countdown(pfmt, timeout); - } - } - - out: - if (tell) { - printf(pfmt, timeout); - printf("\n"); - } - return c; -} diff --git a/sys/arch/luna88k/stand/boot/bcd.c b/sys/arch/luna88k/stand/boot/bcd.c index 3cdc8d8ff84..e69de29bb2d 100644 --- a/sys/arch/luna88k/stand/boot/bcd.c +++ b/sys/arch/luna88k/stand/boot/bcd.c @@ -1,23 +0,0 @@ -/* $OpenBSD: bcd.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ -/* $NetBSD: bcd.c,v 1.1 2006/03/11 15:40:07 kleink Exp $ */ - -/* - * Convert a single byte between (unsigned) packed bcd and binary. - * Public domain. - */ - -#include - -unsigned int -bcdtobin(unsigned int bcd) -{ - - return (((bcd >> 4) & 0x0f) * 10 + (bcd & 0x0f)); -} - -unsigned int -bintobcd(unsigned int bin) -{ - - return ((((bin / 10) << 4) & 0xf0) | (bin % 10)); -} diff --git a/sys/arch/luna88k/stand/boot/bmc.c b/sys/arch/luna88k/stand/boot/bmc.c index f499095a106..51ab37c466e 100644 --- a/sys/arch/luna88k/stand/boot/bmc.c +++ b/sys/arch/luna88k/stand/boot/bmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bmc.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: bmc.c,v 1.2 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: bmc.c,v 1.4 2013/01/21 11:58:12 tsutsui Exp $ */ /* @@ -115,19 +115,24 @@ bmccninit(struct consdev *cp) int bmccngetc(dev_t dev) { - int c; - int unit = 1; + int c, unit = 1, poll = (dev & 0x80) != 0; - _siointr(); - if (RBUF_EMPTY(unit)) - return 0; + siointr(unit); - POP_RBUF(unit, c); + if (poll) { + if (RBUF_EMPTY(unit)) + return 0; + PEEK_RBUF(unit, c); + return c; + } - return(c); -/* - return(siocngetc(dev)); - */ + while (RBUF_EMPTY(unit)) { + DELAY(1); + siointr(unit); + } + + POP_RBUF(unit, c); + return c; } void diff --git a/sys/arch/luna88k/stand/boot/boot.c b/sys/arch/luna88k/stand/boot/boot.c deleted file mode 100644 index 71142096733..00000000000 --- a/sys/arch/luna88k/stand/boot/boot.c +++ /dev/null @@ -1,265 +0,0 @@ -/* $OpenBSD: boot.c,v 1.12 2022/12/31 02:42:01 aoyama Exp $ */ -/* $NetBSD: boot.c,v 1.3 2013/03/05 15:34:53 tsutsui Exp $ */ - -/* - * Copyright (c) 1992 OMRON Corporation. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the 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 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. - * - * @(#)boot.c 8.1 (Berkeley) 6/10/93 - */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)boot.c 8.1 (Berkeley) 6/10/93 - */ - -/* - * boot.c -- boot program - * by A.Fujita, MAR-01-1992 - */ - -#include -#include -#include -#define _KERNEL -#include -#undef _KERNEL - -#include -#include -#include -#include -#include - -int howto; - -int loadrandom(const char *, char *, size_t); -#if 0 -static int get_boot_device(const char *, int *, int *, int *); -#endif - -void (*cpu_boot)(uint32_t, uint32_t, uint32_t, uint32_t); -uint32_t cpu_bootarg1; -uint32_t cpu_bootarg2; -uint32_t cpu_bootarg3; /* set at devopen() */ -uint32_t cpu_bootarg4 = RB_AUTOBOOT; - -char rnddata[BOOTRANDOM_MAX]; -struct rc4_ctx randomctx; - -#if 0 -int -get_boot_device(const char *s, int *devp, int *unitp, int *partp) -{ - const char *p = s; - int unit = 0, part = 0; - - while (*p != '(') { - if (*p == '\0') - goto error; - p++; - } - - p++; - for (; *p != ',' && *p != ')'; p++) { - if (*p == '\0') - goto error; - if (*p >= '0' && *p <= '9') - unit = (unit * 10) + (*p - '0'); - } - - if (*p == ',') - p++; - for (; *p != ')'; p++) { - if (*p == '\0') - goto error; - if (*p >= '0' && *p <= '9') - part = (part * 10) + (*p - '0'); - } - - *devp = 0; /* XXX not yet */ - *unitp = unit; /* XXX should pass SCSI ID, not logical unit number */ - *partp = part; - - return 0; - -error: - return -1; -} -#endif - -int -boot(int argc, char *argv[]) -{ - char *line; - - if (argc < 2) - line = default_file; - else - line = argv[1]; - - printf("Booting %s\n", line); - - return bootunix(line); -} - -int -bootunix(char *line) -{ - int io; -#if 0 - int dev, unit, part; -#endif - uint64_t marks[MARK_MAX]; - char *lparen, *rparen; - char rndpath[MAXPATHLEN]; - static int rnd_loaded = 0; - -#if 0 - if (get_boot_device(line, &dev, &unit, &part) != 0) { - printf("Bad file name %s\n", line); - return ST_ERROR; - } -#endif - - /* - * Try and load randomness from the boot device. - */ - if (rnd_loaded == 0) { - lparen = strchr(line, '('); - if (lparen != NULL) - rparen = strchr(line, ')'); - else - rparen = NULL; - if (rparen != NULL && - rparen + 1 - line < sizeof rndpath) { - rparen++; - memcpy(rndpath, line, rparen - line); - rndpath[rparen - line] = '\0'; - strlcat(rndpath, BOOTRANDOM, sizeof rndpath); - } else - strlcpy(rndpath, BOOTRANDOM, sizeof rndpath); - - rnd_loaded = loadrandom(rndpath, rnddata, sizeof(rnddata)); - if (rnd_loaded == 0) - cpu_bootarg4 |= RB_GOODRANDOM; - } - - rc4_keysetup(&randomctx, rnddata, sizeof rnddata); - rc4_skip(&randomctx, 1536); - - /* Note marks[MARK_START] is passed as an load address offset */ - memset(marks, 0, sizeof(marks)); - - io = loadfile(line, marks, LOAD_KERNEL); - if (io >= 0) { -#ifdef DEBUG - printf("entry = 0x%lx\n", marks[MARK_ENTRY]); - printf("ssym = 0x%lx\n", marks[MARK_SYM]); - printf("esym = 0x%lx\n", marks[MARK_END]); -#endif - - cpu_bootarg1 = BOOT_MAGIC; - cpu_bootarg2 = (uint32_t)marks[MARK_END]; -#ifdef DEBUG - printf("bootarg: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", - cpu_bootarg1, cpu_bootarg2, cpu_bootarg3, cpu_bootarg4); -#endif - cpu_boot = (void (*)(uint32_t, uint32_t, uint32_t, uint32_t)) - (uint32_t)marks[MARK_ENTRY]; - (*cpu_boot)(cpu_bootarg1, cpu_bootarg2, cpu_bootarg3, - cpu_bootarg4); - } - printf("Booting kernel failed. (%s)\n", strerror(errno)); - - return ST_ERROR; -} - -int -loadrandom(const char *name, char *buf, size_t buflen) -{ - struct stat sb; - int fd, error = 0; - - fd = open(name, O_RDONLY); - if (fd == -1) { - if (errno != EPERM) - printf("cannot open %s: %s\n", name, strerror(errno)); - return -1; - } - if (fstat(fd, &sb) == -1) { - error = -1; - goto done; - } - if (read(fd, buf, buflen) != buflen) { - error = -1; - goto done; - } - if (sb.st_mode & S_ISTXT) { - printf("NOTE: random seed is being reused.\n"); - error = -1; - goto done; - } - fchmod(fd, sb.st_mode | S_ISTXT); -done: - close(fd); - return (error); -} diff --git a/sys/arch/luna88k/stand/boot/boot.ldscript b/sys/arch/luna88k/stand/boot/boot.ldscript index 026c530d845..4788136a9a5 100644 --- a/sys/arch/luna88k/stand/boot/boot.ldscript +++ b/sys/arch/luna88k/stand/boot/boot.ldscript @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.ldscript,v 1.2 2013/10/30 18:40:38 miod Exp $ */ +/* $OpenBSD: boot.ldscript,v 1.3 2023/01/10 17:10:57 miod Exp $ */ /* * Copyright (c) 2012 Miodrag Vallat. @@ -17,9 +17,9 @@ */ /* - * This linker script is used to merge .rodata into .text and pad .text to - * a page size. This allows objcopy to correctly be able to convert it to - * an OMAGIC binary, suitable to be booted from the PROM. + * This linker script is used to merge .rodata into .text. This allows + * objcopy to correctly be able to convert it to an OMAGIC binary, suitable + * to be booted from the PROM. */ OUTPUT_FORMAT("elf32-m88k") OUTPUT_ARCH(m88k) diff --git a/sys/arch/luna88k/stand/boot/dev_net.c b/sys/arch/luna88k/stand/boot/dev_net.c index 16f667d60b5..c8f5c825599 100644 --- a/sys/arch/luna88k/stand/boot/dev_net.c +++ b/sys/arch/luna88k/stand/boot/dev_net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_net.c,v 1.5 2021/03/11 11:16:58 jsg Exp $ */ +/* $OpenBSD: dev_net.c,v 1.6 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: dev_net.c,v 1.26 2011/07/17 20:54:52 joerg Exp $ */ /*- @@ -72,7 +72,7 @@ static int netdev_opens; static int net_getparams(int); #ifdef DEBUG -int debug; +extern int debug; #endif /* diff --git a/sys/arch/luna88k/stand/boot/dev_net.h b/sys/arch/luna88k/stand/boot/dev_net.h index c4de3cce4a1..c29862f8f4d 100644 --- a/sys/arch/luna88k/stand/boot/dev_net.h +++ b/sys/arch/luna88k/stand/boot/dev_net.h @@ -1,3 +1,4 @@ +/* $OpenBSD: dev_net.h,v 1.3 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: dev_net.h,v 1.6 2009/01/17 14:00:36 tsutsui Exp $ */ int net_open(struct open_file *, ...); diff --git a/sys/arch/luna88k/stand/boot/devopen.c b/sys/arch/luna88k/stand/boot/devopen.c index c1177c8975e..ee4ae766a4c 100644 --- a/sys/arch/luna88k/stand/boot/devopen.c +++ b/sys/arch/luna88k/stand/boot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.3 2022/10/14 20:53:18 aoyama Exp $ */ +/* $OpenBSD: devopen.c,v 1.4 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: devopen.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $ */ /* @@ -92,14 +92,14 @@ devopen(struct open_file *f, const char *fname, char **file) return ENXIO; #ifdef DEBUG - printf("%s: %s(%d,%d)%s\n", __func__, + printf("%s: %s(%d,%d):%s\n", __func__, devsw[dev].dv_name, unit, part, *file); #endif dp = &devsw[dev]; error = (*dp->dv_open)(f, unit, part); if (error != 0) { #ifdef DEBUG - printf("%s: open %s(%d,%d)%s failed (%s)\n", __func__, + printf("%s: open %s(%d,%d):%s failed (%s)\n", __func__, devsw[dev].dv_name, unit, part, *file, strerror(error)); #endif return error; @@ -120,7 +120,7 @@ devopen(struct open_file *f, const char *fname, char **file) f->f_dev = dp; /* Save boot device information to pass to the kernel */ - cpu_bootarg3 = MAKEBOOTDEV(dev, 0, unit / 10, 6 - unit % 10, part); + bootdev = MAKEBOOTDEV(dev, 0, unit / 10, 6 - unit % 10, part); return 0; } @@ -187,13 +187,15 @@ make_device(const char *str, int *devp, int *unitp, int *partp, char **fname) *unitp = unit; *partp = part; cp++; + if (*cp == ':') + cp++; if (*cp == '\0') *fname = "bsd"; else *fname = (char *)cp; /* XXX */ #ifdef DEBUG - printf("%s: major = %d, unit = %d, part = %d, fname = %s\n", - __func__, major, unit, part, *fname); + printf("%s(%s): major = %d, unit = %d, part = %d, fname = %s\n", + __func__, str, major, unit, part, *fname); #endif return 0; diff --git a/sys/arch/luna88k/stand/boot/exec.c b/sys/arch/luna88k/stand/boot/exec.c new file mode 100644 index 00000000000..4b2b0a9f401 --- /dev/null +++ b/sys/arch/luna88k/stand/boot/exec.c @@ -0,0 +1,108 @@ +/* $OpenBSD: exec.c,v 1.1 2023/01/10 17:10:57 miod Exp $ */ +/* $NetBSD: boot.c,v 1.3 2013/03/05 15:34:53 tsutsui Exp $ */ + +/* + * Copyright (c) 1992 OMRON Corporation. + * + * This code is derived from software contributed to Berkeley by + * OMRON Corporation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the 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 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. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * OMRON Corporation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include +#include + +#include +#include + +#define BOOT_MAGIC 0xf1abde3f + +void (*cpu_boot)(uint32_t, uint32_t, uint32_t, uint32_t); +uint32_t cpu_bootarg1; +uint32_t cpu_bootarg2; +uint32_t cpu_bootarg3; +uint32_t cpu_bootarg4; + +void +run_loadfile(uint64_t *marks, int howto) +{ +#ifdef DEBUG + printf("entry = 0x%lx\n", marks[MARK_ENTRY]); + printf("ssym = 0x%lx\n", marks[MARK_SYM]); + printf("esym = 0x%lx\n", marks[MARK_END]); +#endif + + cpu_bootarg1 = BOOT_MAGIC; + cpu_bootarg2 = (uint32_t)marks[MARK_END]; + cpu_bootarg3 = bootdev; /* set by devopen */ + cpu_bootarg4 = howto; +#ifdef DEBUG + printf("bootarg: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", + cpu_bootarg1, cpu_bootarg2, cpu_bootarg3, howto); +#endif + cpu_boot = (void (*)(uint32_t, uint32_t, uint32_t, uint32_t)) + (uint32_t)marks[MARK_ENTRY]; + (*cpu_boot)(cpu_bootarg1, cpu_bootarg2, cpu_bootarg3, cpu_bootarg4); +} diff --git a/sys/arch/luna88k/stand/boot/getline.c b/sys/arch/luna88k/stand/boot/getline.c deleted file mode 100644 index 7de2a38329b..00000000000 --- a/sys/arch/luna88k/stand/boot/getline.c +++ /dev/null @@ -1,133 +0,0 @@ -/* $OpenBSD: getline.c,v 1.3 2013/10/30 18:22:07 miod Exp $ */ -/* $NetBSD: getline.c,v 1.2 2013/01/20 07:32:45 tsutsui Exp $ */ - -/* - * Copyright (c) 1992 OMRON Corporation. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the 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 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. - * - * @(#)getline.c 8.1 (Berkeley) 6/10/93 - */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)getline.c 8.1 (Berkeley) 6/10/93 - */ - -/* - * getline -- simple getline function - * by A.Fujita, Dec-11-1992 - */ - -#include -#include - -int -getline(const char *prompt, char *buff) -{ - int c; - char *p, *lp = buff; - - printf("%s", prompt); - - for (;;) { - c = getchar() & 0x7f; - - switch (c) { - case '\n': - case '\r': - *lp = '\0'; - putchar('\n'); - goto outloop; - - case '\b': - case 0x7f: - if (lp > buff) { - lp--; - putchar('\b'); - putchar(' '); - putchar('\b'); - } - break; - - case 'r' & 0x1f: - putchar('\n'); - printf("%s", prompt); - for (p = buff; p < lp; ++p) - putchar(*p); - break; - - case 'u' & 0x1f: - case 'w' & 0x1f: - lp = buff; - printf("\n%s", prompt); - break; - - default: - *lp++ = c; - putchar(c); - break; - } - } - - outloop: - *lp = '\0'; - return lp - buff; -} diff --git a/sys/arch/luna88k/stand/boot/getsecs.c b/sys/arch/luna88k/stand/boot/getsecs.c index 39f0fa4a2cc..c61b979b9be 100644 --- a/sys/arch/luna88k/stand/boot/getsecs.c +++ b/sys/arch/luna88k/stand/boot/getsecs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getsecs.c,v 1.3 2013/11/12 13:56:23 aoyama Exp $ */ +/* $OpenBSD: getsecs.c,v 1.4 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: getsecs.c,v 1.1 2013/01/13 14:10:55 tsutsui Exp $ */ /*- @@ -39,6 +39,17 @@ #define _DS_SET(off, data) \ do { *chiptime = (off); *chipdata = (u_int8_t)(data); } while (0) +/* + * Convert a single byte between (unsigned) packed bcd and binary. + * Public domain. + */ +unsigned int +bcdtobin(unsigned int bcd) +{ + + return (((bcd >> 4) & 0x0f) * 10 + (bcd & 0x0f)); +} + time_t getsecs(void) { diff --git a/sys/arch/luna88k/stand/boot/if_le.c b/sys/arch/luna88k/stand/boot/if_le.c index 33334c6bec8..5efc5b4dd48 100644 --- a/sys/arch/luna88k/stand/boot/if_le.c +++ b/sys/arch/luna88k/stand/boot/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.4 2014/08/21 14:24:08 mpi Exp $ */ +/* $OpenBSD: if_le.c,v 1.5 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: if_le.c,v 1.3 2013/01/22 15:48:40 tsutsui Exp $ */ /* @@ -62,6 +62,11 @@ #include #include +#ifdef DEBUG +#include +#include +#include +#endif #include #include diff --git a/sys/arch/luna88k/stand/boot/init_main.c b/sys/arch/luna88k/stand/boot/init_main.c index a1c5e0af5c1..91ecc09f25a 100644 --- a/sys/arch/luna88k/stand/boot/init_main.c +++ b/sys/arch/luna88k/stand/boot/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.9 2022/10/14 20:53:19 aoyama Exp $ */ +/* $OpenBSD: init_main.c,v 1.10 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: init_main.c,v 1.6 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -97,15 +97,14 @@ * rights to redistribute these changes. */ +const char version[] = "0.8"; + #include -#define _KERNEL -#include -#undef _KERNEL #include #include #include -#include -#include +#include + #include "dev_net.h" static void get_fuse_rom_data(void); @@ -115,30 +114,15 @@ static const char *nvram_by_symbol(char *); int cpuspeed; /* for DELAY() macro */ int machtype; -char default_file[64]; -char upgrade_file[64]; + +uint32_t bootdev; uint16_t dipswitch = 0; int nplane; -/* for command parser */ - -#define BUFFSIZE 100 -#define MAXARGS 30 - -char buffer[BUFFSIZE]; - -int argc; -char *argv[MAXARGS]; - -#define BOOT_TIMEOUT 5 -int boot_timeout = BOOT_TIMEOUT; - -static const char prompt[] = "boot> "; - +#ifdef DEBUG int debug; - -int exist(const char *); +#endif /* * FUSE ROM and NVRAM data @@ -162,10 +146,8 @@ struct nvram_t { int main(void) { - int status = ST_NORMAL; - const char *machstr; - const char *nvv; - int unit, part; + extern char *progname; /* boot.c */ + extern int boottimeout; /* boot.c */ /* Determine the machine type from FUSE ROM data. */ get_fuse_rom_data(); @@ -178,97 +160,33 @@ main(void) * Initialize the console before we print anything out. */ if (machtype == LUNA_88K) { - machstr = "LUNA-88K"; + progname = "LUNA-88K BOOT"; cpuspeed = MHZ_25; } else { - machstr = "LUNA-88K2"; + progname = "LUNA-88K2 BOOT"; cpuspeed = MHZ_33; } nplane = get_plane_numbers(); cninit(); - printf("\nOpenBSD/" MACHINE " (%s) boot 0.7\n\n", machstr); - #ifdef SUPPORT_ETHERNET try_bootp = 1; #endif - /* Determine the 'auto-boot' device from NVRAM data */ get_nvram_data(); - nvv = nvram_by_symbol("boot_unit"); - if (nvv != NULL) - unit = (int)strtol(nvv, NULL, 10); - else - unit = 0; - nvv = nvram_by_symbol("boot_partition"); - if (nvv != NULL) - part = (int)strtol(nvv, NULL, 10); - else - part = 0; - - nvv = nvram_by_symbol("boot_device"); - - snprintf(default_file, sizeof(default_file), - "%s(%d,%d)%s", nvv != NULL ? nvv : "sd", unit, part, "bsd"); - snprintf(upgrade_file, sizeof(upgrade_file), - "%s(%d,%d)%s", nvv != NULL ? nvv : "sd", unit, part, "bsd.upgrade"); - - if (exist(upgrade_file)) { - strlcpy(default_file, upgrade_file, sizeof(default_file)); - printf("upgrade detected: switching to %s\n", default_file); + /* disable timeout if requested */ + if ((dipswitch & 0x8000) == 0) { + boottimeout = 0; } - /* auto-boot? (SW1) */ - if ((dipswitch & 0x8000) != 0) { - char c; - - printf("Press return to boot now," - " any other key for boot menu\n"); - printf("booting %s - starting in ", default_file); - c = awaitkey("%d seconds. ", boot_timeout, 1); - if (c == '\r' || c == '\n' || c == 0) { - printf("auto-boot %s\n", default_file); - bootunix(default_file); - } - } - - /* - * Main Loop - */ - - printf("type \"help\" for help.\n"); - - do { - memset(buffer, 0, BUFFSIZE); - if (getline(prompt, buffer) > 0) { - argc = getargs(buffer, argv, sizeof(argv)/sizeof(char *)); - - status = parse(argc, argv); - if (status == ST_NOTFOUND) - printf("unknown command \"%s\"\n", argv[0]); - } - } while (status != ST_EXIT); + boot(0); _rtt(); /* NOTREACHED */ } -/* Check file existence with "device(unit, part)filename" format */ - -int -exist(const char *name) -{ - int fd; - - fd = open(name, O_RDONLY); - if (fd == -1) - return 0; - close(fd); - return 1; -} - int get_plane_numbers(void) { @@ -294,7 +212,7 @@ get_fuse_rom_data(void) fuse_rom_data[i] = (char)((((p->h) >> 24) & 0x000000f0) | (((p->l) >> 28) & 0x0000000f)); - p++; + p++; } } @@ -364,3 +282,60 @@ _rtt(void) for (;;) ; /* NOTREACHED */ } + + +/* + * "machine tty" command to select a different console is not supported, + * console device selection is performed using the DIP switches. + */ + +int +cnspeed(dev_t dev, int sp) +{ + return 9600; +} + +char * +ttyname(int fd) +{ + return "console"; +} + +dev_t +ttydev(char *name) +{ + return NODEV; +} + +/* + * Return the default boot device. + */ +void +devboot(dev_t dev, char *path) +{ + const char *nvv; + int unit, part; + + /* Determine the 'auto-boot' device from NVRAM data */ + nvv = nvram_by_symbol("boot_unit"); + if (nvv != NULL) + unit = (int)strtol(nvv, NULL, 10); + else + unit = 0; + nvv = nvram_by_symbol("boot_partition"); + if (nvv != NULL) + part = (int)strtol(nvv, NULL, 10); + else + part = 0; + + nvv = nvram_by_symbol("boot_device"); + + snprintf(path, BOOTDEVLEN, "%s(%d,%d)", + nvv != NULL ? nvv : "sd", unit, part); +} + +void +machdep() +{ + /* Nothing to do - everything done in main() already */ +} diff --git a/sys/arch/luna88k/stand/boot/kbd.c b/sys/arch/luna88k/stand/boot/kbd.c index e642e405427..1c462c88522 100644 --- a/sys/arch/luna88k/stand/boot/kbd.c +++ b/sys/arch/luna88k/stand/boot/kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: kbd.c,v 1.2 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: kbd.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */ /* @@ -80,7 +80,7 @@ #include #include -struct kbd_keymap kbd_keymap[] = { +const struct kbd_keymap kbd_keymap[] = { { KC_IGNORE, { 0, 0 } }, /* 0 [0x00] */ { KC_IGNORE, { 0, 0 } }, /* 1 [0x01] */ { KC_IGNORE, { 0, 0 } }, /* 2 [0x02] */ diff --git a/sys/arch/luna88k/stand/boot/lance.c b/sys/arch/luna88k/stand/boot/lance.c index 7056c1b0f54..5967f6e1765 100644 --- a/sys/arch/luna88k/stand/boot/lance.c +++ b/sys/arch/luna88k/stand/boot/lance.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lance.c,v 1.3 2021/03/11 11:16:58 jsg Exp $ */ +/* $OpenBSD: lance.c,v 1.4 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: lance.c,v 1.1 2013/01/13 14:10:55 tsutsui Exp $ */ /* @@ -153,7 +153,7 @@ lance_get(void *cookie, void *data, size_t maxlen) rmd = &lemem->lem_rmd[sc->sc_currmd]; if ((rmd->rmd1_bits & LE_R1_OWN) != 0) return -1; - + csr = lereg->ler_rdp; #if 0 if ((csr & LE_C0_ERR) != 0) @@ -304,7 +304,7 @@ lance_do_initialize(struct le_softc *sc) } DELAY(1); } while ((reg & LE_C0_IDON) == 0); - + lereg->ler_rap = LE_CSR0; lereg->ler_rdp = LE_C0_STRT | LE_C0_IDON; diff --git a/sys/arch/luna88k/stand/boot/libsa.h b/sys/arch/luna88k/stand/boot/libsa.h new file mode 100644 index 00000000000..55d12787244 --- /dev/null +++ b/sys/arch/luna88k/stand/boot/libsa.h @@ -0,0 +1,11 @@ +/* $OpenBSD: libsa.h,v 1.1 2023/01/10 17:10:57 miod Exp $ */ + +/* public domain */ + +#include + +#define DEFAULT_KERNEL_ADDRESS 0 + +void devboot(dev_t, char *); +void machdep(void); +void run_loadfile(uint64_t *, int); diff --git a/sys/arch/luna88k/stand/boot/parse.c b/sys/arch/luna88k/stand/boot/parse.c deleted file mode 100644 index ece0e365748..00000000000 --- a/sys/arch/luna88k/stand/boot/parse.c +++ /dev/null @@ -1,161 +0,0 @@ -/* $OpenBSD: parse.c,v 1.1 2013/10/28 22:13:13 miod Exp $ */ -/* $NetBSD: parse.c,v 1.4 2013/01/22 15:48:40 tsutsui Exp $ */ - -/* - * Copyright (c) 1992 OMRON Corporation. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the 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 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. - * - * @(#)parse.c 8.1 (Berkeley) 6/10/93 - */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)parse.c 8.1 (Berkeley) 6/10/93 - */ - -/* - * parse.c -- command parser - * by A.Fujita, JAN-30-1992 - */ - -#include -#include -#include - -static int cmd_help(int, char *[]); - -int -exit_program(int argc, char *argv[]) -{ - return(ST_EXIT); -} - -static const char helpmsg[] = - "commands are:\n" - "boot [device(unit,part)filename]\n" - " (ex. \"boot sd(0,0)bsd\", \"boot le(0,0)obsd\" etc.)\n" - "help\n" - "exit\n" -; - -static int -cmd_help(int argc, char *argv[]) -{ - - printf(helpmsg); - return ST_NORMAL; -} - -struct command_entry { - char *name; - int (*func)(int, char **); -}; - -struct command_entry entries[] = { - { "b", boot }, - { "boot", boot }, - { "exit", exit_program }, - { "help", cmd_help }, - { "quit", exit_program }, - { 0, 0 } -}; - - -int -parse(int argc, char *argv[]) -{ - int i, status = ST_NOTFOUND; - - for (i = 0; entries[i].name != (char *) 0; i++) { - if (!strcmp(argv[0], entries[i].name)) { - status = (*entries[i].func)(argc, argv); - break; - } - } - - return(status); -} - - - -/* - * getargs -- make argument arrays - */ - -int -getargs(char buffer[], char *argv[], int maxargs) -{ - int n = 0; - char *p = buffer; - - argv[n++] = p; - while (*p != '\0') { - if ( *p == ' ' ) { - *p = '\0'; - } else if (p != buffer && *(p-1) == '\0') { - if ( n < maxargs ) - argv[n++] = p; - } - p++; - } - - return(n); -} diff --git a/sys/arch/luna88k/stand/boot/prf.c b/sys/arch/luna88k/stand/boot/prf.c deleted file mode 100644 index e0cf6f3ebf6..00000000000 --- a/sys/arch/luna88k/stand/boot/prf.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: prf.c,v 1.1 2013/10/28 22:13:13 miod Exp $ */ -/* $NetBSD: prf.c,v 1.3 2013/01/22 15:48:40 tsutsui Exp $ */ - -/* - * 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 - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)prf.c 8.1 (Berkeley) 6/10/93 - */ - -#include - -int -getchar(void) -{ - int c; - - while ((c = cngetc()) == 0) - ; - if (c == '\r') - c = '\n'; - else if (c == ('c'&037)) { - panic("^C"); - /* NOTREACHED */ - } - return c; -} - -int -tgetchar(void) -{ - int c; - - if ((c = cngetc()) == 0) - return 0; - - if (c == '\r') - c = '\n'; - else if (c == ('c'&037)) { - panic("^C"); - /* NOTREACHED */ - } - return c; -} - -void -putchar(int c) -{ - cnputc(c); - if (c == '\n') - cnputc('\r'); -} diff --git a/sys/arch/luna88k/stand/boot/rcvbuf.h b/sys/arch/luna88k/stand/boot/rcvbuf.h index 85bcf6d3761..b05154b3172 100644 --- a/sys/arch/luna88k/stand/boot/rcvbuf.h +++ b/sys/arch/luna88k/stand/boot/rcvbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcvbuf.h,v 1.1 2013/10/28 22:13:13 miod Exp $ */ +/* $OpenBSD: rcvbuf.h,v 1.2 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: rcvbuf.h,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */ /* @@ -100,6 +100,11 @@ do { \ rcvbuf[n].rb_pop = &rcvbuf[n].rb_buf[RBUF_SIZE]; \ } while (0) +#define PEEK_RBUF(n, c) \ +do { \ + c= *(rcvbuf[n].rb_pop - 1); \ +} while (0) + #define RBUF_EMPTY(n) (rcvbuf[n].rb_push == rcvbuf[n].rb_pop ? 1: 0) extern struct rcvbuf rcvbuf[]; diff --git a/sys/arch/luna88k/stand/boot/samachdep.h b/sys/arch/luna88k/stand/boot/samachdep.h index 4932ae2a1db..6295c0b8569 100644 --- a/sys/arch/luna88k/stand/boot/samachdep.h +++ b/sys/arch/luna88k/stand/boot/samachdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: samachdep.h,v 1.5 2022/10/14 20:53:19 aoyama Exp $ */ +/* $OpenBSD: samachdep.h,v 1.6 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: samachdep.h,v 1.10 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -47,12 +47,6 @@ typedef struct label_t { void configure(void); void find_devs(void); -/* awaitkey.c */ -char awaitkey(const char *, int, int); - -/* bcd.c */ -unsigned int bcdtobin(unsigned int); - /* bmc.c */ void bmccnprobe(struct consdev *); void bmccninit(struct consdev *); @@ -66,21 +60,15 @@ void bmdadjust(short, short); void bmdclear(void); /* boot.c */ -extern int howto; -int boot(int, char **); -int bootunix(char *); - -extern void (*cpu_boot)(uint32_t, uint32_t, uint32_t, uint32_t); -extern uint32_t cpu_bootarg1; -extern uint32_t cpu_bootarg2; -extern uint32_t cpu_bootarg3; -extern uint32_t cpu_bootarg4; -#define BOOT_MAGIC 0xf1abde3f - -/* cons.c */ -void cninit(void); -int cngetc(void); -void cnputc(int); +extern uint32_t bootdev; + +/* conf.c */ +extern struct fs_ops file_system_disk[]; +extern int nfsys_disk; +extern struct fs_ops file_system_nfs[]; + +/* exec.c */ +void run_loadfile(uint64_t *, int); /* fault.c */ int badaddr(void *, int); @@ -88,9 +76,6 @@ int badaddr(void *, int); /* font.c */ extern const u_short bmdfont[][20]; -/* getline.c */ -int getline(const char *, char *); - /* init_main.c */ extern int cpuspeed; extern int nplane; @@ -111,20 +96,11 @@ int lance_put(void *, void *, size_t); int lance_end(void *); /* locore.S */ -extern u_int bootdev; extern uint16_t dipswitch; extern volatile uint32_t tick; int setjmp(label_t *); void delay(int); -/* prf.c */ -int tgetchar(void); - -/* parse.c */ -int exit_program(int, char **); -int parse(int, char **); -int getargs(char *, char **, int); - /* sc.c */ struct scsi_softc; int scinit(struct scsi_softc *, uint); @@ -140,7 +116,7 @@ int sdopen(struct open_file *, ...); int sdclose(struct open_file *); /* sio.c */ -void _siointr(void); +int siointr(int); void siocnprobe(struct consdev *); void siocninit(struct consdev *); int siocngetc(dev_t); @@ -151,7 +127,3 @@ void sioinit(void); char *readdisklabel(struct scsi_softc *, uint, struct disklabel *); #define DELAY(n) delay(n) - -extern struct fs_ops file_system_disk[]; -extern int nfsys_disk; -extern struct fs_ops file_system_nfs[]; diff --git a/sys/arch/luna88k/stand/boot/sc.c b/sys/arch/luna88k/stand/boot/sc.c index a4719816b8e..76acc532884 100644 --- a/sys/arch/luna88k/stand/boot/sc.c +++ b/sys/arch/luna88k/stand/boot/sc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sc.c,v 1.4 2021/03/11 11:16:58 jsg Exp $ */ +/* $OpenBSD: sc.c,v 1.5 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: sc.c,v 1.4 2013/01/22 15:48:40 tsutsui Exp $ */ /* @@ -72,7 +72,7 @@ */ /* - * sc.c -- SCSI Protocole Controller (SPC) driver + * sc.c -- SCSI Protocol Controller (SPC) driver * remaked by A.Fujita, MAR-11-199 */ diff --git a/sys/arch/luna88k/stand/boot/sio.c b/sys/arch/luna88k/stand/boot/sio.c index 0fc7f40fe97..a67febabfd2 100644 --- a/sys/arch/luna88k/stand/boot/sio.c +++ b/sys/arch/luna88k/stand/boot/sio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */ +/* $OpenBSD: sio.c,v 1.4 2023/01/10 17:10:57 miod Exp $ */ /* $NetBSD: sio.c,v 1.3 2013/01/21 11:58:12 tsutsui Exp $ */ /* @@ -82,7 +82,6 @@ #include #include -static int siointr(int); static int sioreg(int, int); struct rcvbuf rcvbuf[NSIO]; @@ -90,16 +89,6 @@ struct rcvbuf rcvbuf[NSIO]; int sioconsole = -1; struct siodevice *sio_addr[2]; -void -_siointr(void) -{ - int unit; - - for (unit = 0; unit < NSIO; unit++) - while (siointr(unit) != 0) - continue; -} - int siointr(int unit) { @@ -164,15 +153,25 @@ siocninit(struct consdev *cp) int siocngetc(dev_t dev) { - int c, unit = dev; + int c, unit = dev & ~0x80, poll = (dev & 0x80) != 0; - _siointr(); - if (RBUF_EMPTY(unit)) - return 0; + siointr(unit); - POP_RBUF(unit, c); + if (poll) { + if (RBUF_EMPTY(unit)) + return 0; + PEEK_RBUF(unit, c); + return c; - return(c); + } + + while (RBUF_EMPTY(unit)) { + DELAY(1); + siointr(unit); + } + + POP_RBUF(unit, c); + return c; } void