summaryrefslogtreecommitdiff
path: root/sys/arch/wgrisc/stand/boot
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/wgrisc/stand/boot')
-rw-r--r--sys/arch/wgrisc/stand/boot/Makefile12
-rw-r--r--sys/arch/wgrisc/stand/boot/boot.c76
-rw-r--r--sys/arch/wgrisc/stand/boot/conf.c37
-rw-r--r--sys/arch/wgrisc/stand/boot/fl.c102
-rw-r--r--sys/arch/wgrisc/stand/boot/sd.c77
-rw-r--r--sys/arch/wgrisc/stand/boot/start.S186
6 files changed, 333 insertions, 157 deletions
diff --git a/sys/arch/wgrisc/stand/boot/Makefile b/sys/arch/wgrisc/stand/boot/Makefile
index 9979ff28502..06c3d12b698 100644
--- a/sys/arch/wgrisc/stand/boot/Makefile
+++ b/sys/arch/wgrisc/stand/boot/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.1 1997/05/11 16:17:51 pefo Exp $
+# $OpenBSD: Makefile,v 1.2 1997/07/21 06:58:11 pefo Exp $
PROG=boot
SADIR=${.CURDIR}/..
-SRCS=start.S boot.c filesystem.c conf.c sd.c
+SRCS=start.S boot.c filesystem.c conf.c sd.c fl.c
CFLAGS+=$(SACFLAGS) -I${.CURDIR}/../../../../lib/libsa -I${.CURDIR}/../libsa
CFLAGS+=-D__INTERNAL_LIBSA_CREAD
@@ -17,13 +17,15 @@ machine-links:
@ln -fs ${.CURDIR}/../.. wgrisc
@ln -fs ${.CURDIR}/../../include machine
-${PROG}: $(OBJS) $(DPADD)
+${PROG}: $(OBJS) $(LDADD)
$(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD)
-${PROG}.bin: ${PROG}
+${PROG}.bin: ${PROG}
cp ${PROG} ${PROG}.tmp
strip -s ${PROG}.tmp
- dd if=${PROG}.tmp of=${PROG}.bin bs=4096 skip=1
+ dd if=${PROG}.tmp of=${PROG}.bin bs=512 skip=8 count=1
+ dd if=/dev/zero of=${PROG}.bin bs=512 seek=1 count=1
+ dd if=${PROG}.tmp of=${PROG}.bin bs=512 skip=9 seek=2 count=14
rm ${PROG}.tmp
.include <bsd.prog.mk>
diff --git a/sys/arch/wgrisc/stand/boot/boot.c b/sys/arch/wgrisc/stand/boot/boot.c
index 6892d6a6a23..2e7cf0742ff 100644
--- a/sys/arch/wgrisc/stand/boot/boot.c
+++ b/sys/arch/wgrisc/stand/boot/boot.c
@@ -1,12 +1,8 @@
-/* $NetBSD: boot.c,v 1.6 1995/06/28 10:22:32 jonathan Exp $ */
+/* $OpenBSD: boot.c,v 1.2 1997/07/21 06:58:12 pefo Exp $ */
/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
+ * Copyright (c) 1997 Per Fogelstrom
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -17,17 +13,16 @@
* 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 product includes software developed under OpenBSD by
+ * Per Fogelstrom.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
*
- * THIS 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
+ * 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
@@ -35,7 +30,6 @@
* 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 <sys/param.h>
@@ -46,29 +40,24 @@
#include <errno.h>
-char line[1024];
void gets __P((char *));
ssize_t read __P((int, void *, size_t));
int close __P((int));
void prom_write __P((int, char *, int));
-int main __P((int, char **));
+void main __P((int, char **));
int loadfile __P((char *));
/*
- * This gets arguments from the PROM, calls other routines to open
- * and load the program to boot, and then transfers execution to that
- * new program.
- * Argv[0] should be something like "rz(0,0,0)vmunix" on a DECstation 3100.
- * Argv[0,1] should be something like "boot 5/rz0/vmunix" on a DECstation 5000.
- * The argument "-a" means vmunix should do an automatic reboot.
*/
-int
+void
main(argc, argv)
int argc;
char **argv;
{
- char *cp = 0;
+static char boot[] = {"Boot:"};
+ char *cp = boot;
int ask, entry;
+ char line[1024];
ask = 1;
@@ -78,23 +67,22 @@ main(argc, argv)
}
while(1) {
do {
- printf("Boot: ");
+ printf("%s\n", cp);
if (ask) {
gets(line);
cp = line;
argv[0] = cp;
argc = 1;
- } else
- printf("%s\n", cp);
+ }
} while(ask && line[0] == '\0');
entry = loadfile(cp);
if (entry != -1) {
- printf("Starting at 0x%x\n\n", entry);
((void (*)())entry)(argc, argv, 0, 0);
}
+ ask = 1;
+ cp = boot;
}
- return(0);
}
/*
@@ -108,9 +96,10 @@ loadfile(fname)
Elf32_Ehdr eh;
Elf32_Phdr *ph;
u_long phsize;
+ char *errs = 0;
if ((fd = oopen(fname, 0)) < 0) {
- printf("open(%s) failed: %d\n", fname, errno);
+ errs="open(%s) err: %d\n";
goto err;
}
@@ -126,24 +115,19 @@ loadfile(fname)
goto serr;
}
- for(i = 0; i < eh.e_phnum; i++) {
- switch (ph[i].p_type) {
- case PT_LOAD:
- olseek(fd, ph[i].p_offset, 0);
- if(oread(fd, (char *)ph[i].p_paddr, ph[i].p_filesz) != ph[i].p_filesz) {
+ for(i = 0; i < eh.e_phnum; i++, ph++) {
+ if(ph->p_type == PT_LOAD) {
+ olseek(fd, ph->p_offset, 0);
+ if(oread(fd, (char *)ph->p_paddr, ph->p_filesz) != ph->p_filesz) {
goto serr;
}
- break;
- default:
- break;
}
}
- (void) oclose(fd);
return(eh.e_entry);
serr:
- printf("Read size error\n");
+ errs = "rd(%s) sz err\n";
err:
- printf("Can't boot '%s'\n", fname);
- (void) oclose(fd);
+ printf(errs, fname, errno);
return (-1);
}
+
diff --git a/sys/arch/wgrisc/stand/boot/conf.c b/sys/arch/wgrisc/stand/boot/conf.c
index fa2b4cb730c..3c991b8edbe 100644
--- a/sys/arch/wgrisc/stand/boot/conf.c
+++ b/sys/arch/wgrisc/stand/boot/conf.c
@@ -1,12 +1,8 @@
-/* $NetBSD: conf.c,v 1.5 1995/01/18 06:53:39 mellon Exp $ */
+/* $OpenBSD: conf.c,v 1.2 1997/07/21 06:58:12 pefo Exp $ */
/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
+ * Copyright (c) 1997 Per Fogelstrom
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -17,17 +13,16 @@
* 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 product includes software developed under OpenBSD by
+ * Per Fogelstrom.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
*
- * THIS 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
+ * 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
@@ -35,9 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)conf.c 8.1 (Berkeley) 6/10/93
*/
-
#include <stand.h>
int errno;
@@ -50,10 +43,16 @@ int sdstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
int sdopen __P((struct open_file *, ...));
int sdclose __P((struct open_file *));
+int flstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+int flopen __P((struct open_file *, ...));
+int flclose __P((struct open_file *));
+
#define sdioctl noioctl
+#define flioctl noioctl
struct devsw devsw[] = {
{ "sd", sdstrategy, sdopen, sdclose, sdioctl }, /*0*/
+ { "fl", flstrategy, flopen, flclose, flioctl }, /*1*/
};
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
diff --git a/sys/arch/wgrisc/stand/boot/fl.c b/sys/arch/wgrisc/stand/boot/fl.c
new file mode 100644
index 00000000000..02459551ff7
--- /dev/null
+++ b/sys/arch/wgrisc/stand/boot/fl.c
@@ -0,0 +1,102 @@
+/* $OpenBSD: fl.c,v 1.1 1997/07/21 06:58:13 pefo Exp $ */
+
+/*
+ * Copyright (c) 1997 Per Fogelstrom
+ *
+ * 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 under OpenBSD by
+ * Per Fogelstrom.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS 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 <stdarg.h>
+
+#include <stand.h>
+#include <sys/param.h>
+
+int prom_seek __P((int, long, int));
+int disk_read __P((int, char *, int, int));
+int disk_open __P((char *, int));
+
+struct fl_softc {
+ int sc_fd; /* PROM file id */
+};
+
+int
+flstrategy(devdata, rw, bn, reqcnt, addr, cnt)
+ void *devdata;
+ int rw;
+ daddr_t bn;
+ u_int reqcnt;
+ char *addr;
+ u_int *cnt; /* out: number of bytes transfered */
+{
+ struct fl_softc *sc = (struct fl_softc *)devdata;
+ int s;
+ long offset;
+
+ offset = bn * DEV_BSIZE;
+
+ s = disk_read(sc->sc_fd, addr, offset, reqcnt);
+ if (s < 0)
+ return (-s);
+ *cnt = s;
+ return (0);
+}
+
+/*
+ * We only deal with flash 0 here. We need to be small.
+ */
+int
+flopen(struct open_file *f, ...)
+{
+ struct fl_softc *sc;
+ int fd;
+ static char device[] = "fl(0)";
+
+ fd = disk_open(device, 0);
+ if (fd < 0) {
+ return (ENXIO);
+ }
+
+ sc = alloc(sizeof(struct fl_softc));
+ f->f_devdata = (void *)sc;
+
+ sc->sc_fd = fd;
+
+ return (0);
+}
+
+int
+flclose(f)
+ struct open_file *f;
+{
+#ifdef FANCY
+ free(f->f_devdata, sizeof(struct fl_softc));
+ f->f_devdata = (void *)0;
+#endif
+ return (0);
+}
diff --git a/sys/arch/wgrisc/stand/boot/sd.c b/sys/arch/wgrisc/stand/boot/sd.c
index 34f8068e14a..dfc9b51317e 100644
--- a/sys/arch/wgrisc/stand/boot/sd.c
+++ b/sys/arch/wgrisc/stand/boot/sd.c
@@ -50,8 +50,6 @@ int disk_open __P((char *, int));
struct sd_softc {
int sc_fd; /* PROM file id */
- int sc_ctlr; /* controller number */
- int sc_unit; /* disk unit number */
int sc_part; /* disk partition number */
struct disklabel sc_label; /* disk label for this disk */
};
@@ -66,30 +64,16 @@ sdstrategy(devdata, rw, bn, reqcnt, addr, cnt)
u_int *cnt; /* out: number of bytes transfered */
{
struct sd_softc *sc = (struct sd_softc *)devdata;
- int part = sc->sc_part;
- struct partition *pp = &sc->sc_label.d_partitions[part];
+ struct partition *pp = &sc->sc_label.d_partitions[sc->sc_part];
int s;
long offset;
- offset = bn * DEV_BSIZE;
-
- /*
- * Partial-block transfers not handled.
- */
- if (reqcnt & (DEV_BSIZE - 1)) {
- *cnt = 0;
- return (EINVAL);
- }
-
- offset += pp->p_offset * DEV_BSIZE;
+ offset = (pp->p_offset + bn) * DEV_BSIZE;
s = disk_read(sc->sc_fd, addr, offset, reqcnt);
-#if 0 /* XXX error code not returned yet... */
- if (s <= 0)
- return (EIO);
-#endif
-
- *cnt = reqcnt;
+ if (s < 0)
+ return (-s);
+ *cnt = s;
return (0);
}
@@ -100,9 +84,8 @@ sdopen(struct open_file *f, ...)
struct sd_softc *sc;
struct disklabel *lp;
- struct dos_partition dp, *dp2;
int i, fd;
- char *msg;
+ char *msg = "rd err";
char buf[DEV_BSIZE];
int cnt;
daddr_t labelsector;
@@ -128,8 +111,6 @@ sdopen(struct open_file *f, ...)
f->f_devdata = (void *)sc;
sc->sc_fd = fd;
- sc->sc_ctlr = ctlr;
- sc->sc_unit = unit;
sc->sc_part = part;
lp = &sc->sc_label;
@@ -137,48 +118,46 @@ sdopen(struct open_file *f, ...)
lp->d_secpercyl = 1;
lp->d_npartitions = MAXPARTITIONS;
lp->d_partitions[part].p_offset = 0;
- lp->d_partitions[part].p_size = 0x7fffffff;
+ lp->d_partitions[part].p_size = 0x7fff0000;
+
+ labelsector = LABELSECTOR;
+#ifdef USE_DOSBBSECTOR
/* First check for any DOS partition table */
i = sdstrategy(sc, F_READ, (daddr_t)DOSBBSECTOR, DEV_BSIZE, buf, &cnt);
- if (i || cnt != DEV_BSIZE) {
- printf("sd%d: error reading disk label\n", unit);
- goto bad;
- }
- labelsector = 0;
- bcopy(buf + DOSPARTOFF, &dp, NDOSPART * sizeof(dp));
- for (dp2=&dp, i=0; i < NDOSPART; i++, dp2++) {
- if (dp2->dp_size && dp2->dp_typ == DOSPTYP_OPENBSD) {
- labelsector = dp2->dp_start;
- break;
+ if (!(i || cnt != DEV_BSIZE)) {
+ struct dos_partition dp, *dp2;
+ bcopy(buf + DOSPARTOFF, &dp, NDOSPART * sizeof(dp));
+ for (dp2=&dp, i=0; i < NDOSPART; i++, dp2++) {
+ if (dp2->dp_size) {
+ if((dp2->dp_typ == DOSPTYP_386BSD) ||
+ (dp2->dp_typ == DOSPTYP_OPENBSD)) {
+ labelsector += dp2->dp_start;
+ break;
+ }
+ }
}
}
- for (dp2=&dp, i=0; i < NDOSPART; i++, dp2++) {
- if (dp2->dp_size && dp2->dp_typ == DOSPTYP_386BSD) {
- labelsector = dp2->dp_start;
- break;
- }
+ else {
+ goto bad;
}
+#endif
/* try to read disk label and partition table information */
- labelsector += LABELSECTOR;
i = sdstrategy(sc, F_READ, (daddr_t)labelsector, DEV_BSIZE, buf, &cnt);
if (i || cnt != DEV_BSIZE) {
- printf("sd%d: error reading disk label\n", unit);
goto bad;
}
msg = getdisklabel(buf, lp);
if (msg) {
- printf("sd%d: %s\n", unit, msg);
goto bad;
}
if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0) {
- bad:
-#ifndef SMALL
- free(sc, sizeof(struct sd_softc));
-#endif
+ msg = "no part";
+bad:
+ printf("sd%d: %s\n", unit, msg);
return (ENXIO);
}
return (0);
@@ -188,7 +167,9 @@ int
sdclose(f)
struct open_file *f;
{
+#ifdef FANCY
free(f->f_devdata, sizeof(struct sd_softc));
f->f_devdata = (void *)0;
+#endif
return (0);
}
diff --git a/sys/arch/wgrisc/stand/boot/start.S b/sys/arch/wgrisc/stand/boot/start.S
index 70535726c56..a3aa0f0ebb9 100644
--- a/sys/arch/wgrisc/stand/boot/start.S
+++ b/sys/arch/wgrisc/stand/boot/start.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: start.S,v 1.1 1997/05/11 16:17:54 pefo Exp $ */
+/* $OpenBSD: start.S,v 1.2 1997/07/21 06:58:13 pefo Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -52,6 +52,11 @@ __start:
move s0, a0 # save argc
move s1, a1 # save argv
+ la a0, __start+512 # Merge together from
+ la a1, __start+1024 # disklabel split.
+ jal memcpy
+ li a2, 8192 - 1024
+
la a0, edata # clear BSS
li a1, 0
la a2, end
@@ -61,15 +66,101 @@ __start:
move a0, s0 # restore argc
jal main # main(argc, argv)
move a1, s1 # restore argv
+/* MAIN NEVER RETURNS */
- j restart # restart...
- nop
-/* dummy routine for gcc2 */
-LEAF(__main)
+/* dummy routines return 0 */
+ .globl getenv
+ .globl __main
+getenv:
+__main:
+ .set noreorder
j ra
+ li v0, 0
+
+ .globl strcmp
+strcmp:
+ .set noreorder
+1:
+ lbu v0, 0(a0)
+ lbu v1, 0(a1)
+ beqz v0, 2f
+ addu a0, a0, 1
+ beq v0, v1, 1b
+ addu a1, a1, 1
+2:
+ jr ra
+ subu v0, v0, v1
+
+ .globl strlen
+strlen:
+ .set noreorder
+ li v0, 0
+1:
+ lbu v1, 0(a0)
+ addu a0, a0, 1
+ bnez v1, 1b
+ addu v0, v0, 1
+
+ jr ra
+ addu v0, v0, -1
+
+ .globl memset
+memset:
+ .set noreorder
+ move v0, a0
+1:
+ beqz a2, 2f
+ addu a2, a2, -1
+
+ sb a1, 0(a0)
+ b 1b
+ addu a0, a0, 1
+2:
+ jr ra
+ nop
+
+ .globl memcpy
+memcpy:
+ .set noreorder
+ beqz a2, 3f
+ move v0, a0
+ sltu v1, a1, a0
+ beqz v1, 1f
+ li a3, 1 /* Forward copy */
+
+ li a3, -1 /* Backwrads copy */
+ addu a0, a2
+ b 2f
+ addu a1, a2
+
+1:
+ lbu v1, 0(a1)
+ addu a2, a2, -1
+ sb v1, 0(a0)
+2:
+ addu a0, a0, a3
+ bnez a2, 1b
+ addu a1, a1, a3
+
+3:
+ jr ra
nop
-END(__main)
+
+ .globl twiddle
+twiddle:
+ .set noreorder
+ la v0, twc+4
+ lw a0, -4(v0)
+ li a1, 7
+ addu a0, a0, 2
+ sw a0, -4(v0)
+ and a1, a0, a1
+ add a1, a1, v0
+
+ li a0, 1 /* Stdout */
+ b prom_write
+ li a2, 2
/*
* Boot rom entrypoints.
@@ -77,54 +168,71 @@ END(__main)
#define BOOTVEC 0xbfc00500 /* Address of boot vector table */
-NON_LEAF(getchar, STAND_FRAME_SIZE, ra)
- .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE)
- subu sp, sp, STAND_FRAME_SIZE
- sw ra, STAND_RA_OFFSET(sp)
+ .globl getchar
+getchar:
+ .set noreorder
+ sw ra, 4(sp)
move a1, sp
li a0, 0
- li a2, 1
jal prom_read
+ li a2, 1
+ lw ra, 4(sp)
lbu v0, 0(sp)
- lw ra, STAND_RA_OFFSET(sp)
- addu sp, sp, STAND_FRAME_SIZE
jr ra
-END(getchar)
+ nop
+
+ .globl disk_open
+disk_open:
+ .set noreorder
+ b __go
+ li v0, 96
-LEAF(putchar)
+ .globl disk_read
+disk_read:
+ .set noreorder
+ b __go
+ li v0, 100
+
+ .globl prom_read
+prom_read:
+ .set noreorder
+ b __go
+ li v0, 0
+
+ .globl putchar
+putchar:
+ .set noreorder
sb a0, 0(sp)
move a1, sp
li a0, 1 /* Stdout */
li a2, 1
- b prom_write
-
-END(putchar)
-
-LEAF(restart)
-END(restart)
+/* -- fall through -- */
+ .globl prom_write
+prom_write:
+ .set noreorder
+ b __go
+ li v0, 4
-LEAF(panic)
-END(panic)
+ .globl printf
+printf:
+ .set noreorder
+ b __go
+ li v0, 20
-LEAF(disk_open)
- lw v0, BOOTVEC+96
- jr v0
-END(disk_open)
+ .globl panic
+panic:
-LEAF(disk_read)
- lw v0, BOOTVEC+100
+__go:
+ .set noreorder
+ lw v0, BOOTVEC(v0)
+ nop
jr v0
-END(disk_read)
+ nop
+ .align 2
+ .globl twc
+twc: .word 0
+tws: .ascii "\\\b-\b/\b-\b"
-LEAF(prom_read)
- lw v0, BOOTVEC+0
- jr v0
-END(prom_read)
-
-LEAF(prom_write)
- lw v0, BOOTVEC+4
- jr v0
-END(prom_write)