diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 1997-05-11 16:17:57 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 1997-05-11 16:17:57 +0000 |
commit | 7ca343aa7ca2c7d3146dd87dd7845b6d261fa505 (patch) | |
tree | 701a6a6de8038a80d9d7f880b4a5827a60b30802 /sys | |
parent | 03246f32eb4aa4c396840499bbfb8d22619ab092 (diff) |
Boot block for the wgrisc!
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/wgrisc/stand/Makefile | 37 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/Makefile.inc | 23 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/Makefile | 29 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/boot.c (renamed from sys/arch/wgrisc/stand/boot.c) | 95 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/conf.c (renamed from sys/arch/wgrisc/stand/conf.c) | 25 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/filesystem.c (renamed from sys/arch/wgrisc/stand/filesystem.c) | 4 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/ld.script | 74 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/sd.c (renamed from sys/arch/wgrisc/stand/rz.c) | 104 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/boot/start.S | 130 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/Makefile | 28 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/devopen.c | 28 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/getenv.c | 34 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/libsa/gets.c | 80 | ||||
-rw-r--r-- | sys/arch/wgrisc/stand/start.S | 129 |
14 files changed, 523 insertions, 297 deletions
diff --git a/sys/arch/wgrisc/stand/Makefile b/sys/arch/wgrisc/stand/Makefile index a7dd6383200..9cef7d5d895 100644 --- a/sys/arch/wgrisc/stand/Makefile +++ b/sys/arch/wgrisc/stand/Makefile @@ -9,28 +9,23 @@ STAND= ../../stand RELOC= 80200000 S= ../../.. +INCLUDES= -I. -I$S/arch -I$S -I$S/lib/libsa +CPPFLAGS= ${INCLUDES} ${IDENT} -D_KERNEL -Dwgrisc +CDIAGFLAGS= -Werror -Wall -Wno-uninitialized -Wno-format + DEFS= -DSTANDALONE -DDEBUG -CFLAGS= -O2 ${INCPATH} ${DEFS} +CFLAGS= ${DEBUG} -O2 ${CDIAGFLAGS} -mno-abicalls -mips1 -mcpu=r3000 AFLAGS= -O2 ${INCPATH} ${DEFS} -DLOCORE -.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} -.PATH: ${S}/stand ${S}/lib/libsa - -#INCPATH=-I. -I/sys -INCPATH=-I${.CURDIR} -I${.CURDIR}/../.. -I${S} -I${S}/lib/libsa - ### find out what to use for libkern .include "$S/lib/libkern/Makefile.inc" LIBKERN= ${KERNLIB} -#KERNLIB= ${.CURDIR}/../compile/libkern.a .include "$S/lib/libsa/Makefile.inc" -LIBSA= ${SA_LIB} # not yet: need to write libsa/Makefile.inc first -LIBS= ${.OBJDIR}/libdrive.a ${.CURDIR}/libsa/libsa.a ${KERNLIB} -#LIBS= libdrive.a libsa/libsa.a ../../libkern/obj/libkern.a +LIBS= ${KERNLIB} ${SALIB} DRIVERS= rz.c SRCS= ${DRIVERS} @@ -50,31 +45,21 @@ boot: ${LIBS} #libsa/libsa.a:: # cd libsa; make -${.OBJDIR}/libdrive.a: conf.o ${DRIVERS:.c=.o} +${.OBJDIR}/libdrive.a: ${DRIVERS:.c=.o} ar crv $@ $? ranlib $@ # depend on DEFS -#before other deps on bootconf.o -bootconf.o: conf.o - rm -f bootconf.c - ln -s ${.CURDIR}/conf.c bootconf.c - ${CC} -c ${CFLAGS} -DBOOT bootconf.c - rm -f bootconf.c - # bootable from real disks -boot: start.o boot.o bootconf.o filesystem.o ${LIBS} - /usr/gnu/ld -N -Ttext ${RELOC} -e __start start.o boot.o bootconf.o filesystem.o ${LIBS} -o boot.elf +boot: start.o boot.o filesystem.o ${LIBS} + ld -N -Ttext ${RELOC} -e __start start.o boot.o filesystem.o ${LIBS} -o boot.elf elf2ecoff boot.elf boot start.o: ${.CURDIR}/start.S -# ${CPP} -E ${CFLAGS:M-[ID]*} -DLOCORE ${AINC} ${.IMPSRC} | \ -# ${AS} -o ${.TARGET} - mkboot: ${.CURDIR}/mkboot.c ${CC} ${CFLAGS} -o mkboot ${.CURDIR}/mkboot.c @@ -88,9 +73,5 @@ clean:: install: -depend: ${SRCS} - mkdep ${INCPATH} ${DEFS} ${SRCS} - cd libsa; make depend - .include <bsd.dep.mk> .include <bsd.obj.mk> diff --git a/sys/arch/wgrisc/stand/Makefile.inc b/sys/arch/wgrisc/stand/Makefile.inc new file mode 100644 index 00000000000..5c847e9f9e6 --- /dev/null +++ b/sys/arch/wgrisc/stand/Makefile.inc @@ -0,0 +1,23 @@ +# $OpenBSD: Makefile.inc,v 1.1 1997/05/11 16:17:48 pefo Exp $ + +CPPFLAGS+=-Wall -Werror -I. -Imachine +CPPFLAGS+=-D_STANDALONE -DSTRIPPED +CFLAGS+=-mno-abicalls -mips1 -mcpu=r3000 +START=0x10000 +HEAP_LIMIT=0x50000 +BOOTREL=0x3000 +BOOTMAGIC=0xdeadbeef + +.if exists(${SADIR}/libsa/obj) +LIBSA=${SADIR}/libsa/obj/libsa.a +.else +LIBSA=${SADIR}/libsa/libsa.a +.endif +.if exists(${SADIR}/libz/obj) +LIBZ=${SADIR}/libz/obj/libz.a +.else +LIBZ=${SADIR}/libz/libz.a +.endif + +BINDIR= /usr/mdec + diff --git a/sys/arch/wgrisc/stand/boot/Makefile b/sys/arch/wgrisc/stand/boot/Makefile new file mode 100644 index 00000000000..9979ff28502 --- /dev/null +++ b/sys/arch/wgrisc/stand/boot/Makefile @@ -0,0 +1,29 @@ +# $OpenBSD: Makefile,v 1.1 1997/05/11 16:17:51 pefo Exp $ + +PROG=boot +SADIR=${.CURDIR}/.. +SRCS=start.S boot.c filesystem.c conf.c sd.c +CFLAGS+=$(SACFLAGS) -I${.CURDIR}/../../../../lib/libsa -I${.CURDIR}/../libsa +CFLAGS+=-D__INTERNAL_LIBSA_CREAD + +LD=ld +LDFLAGS+= -T ld.script -x -e __start +LDADD= ${LIBSA} + +all: machine-links boot.bin + +machine-links: + @rm -f machine wgrisc + @ln -fs ${.CURDIR}/../.. wgrisc + @ln -fs ${.CURDIR}/../../include machine + +${PROG}: $(OBJS) $(DPADD) + $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD) + +${PROG}.bin: ${PROG} + cp ${PROG} ${PROG}.tmp + strip -s ${PROG}.tmp + dd if=${PROG}.tmp of=${PROG}.bin bs=4096 skip=1 + rm ${PROG}.tmp + +.include <bsd.prog.mk> diff --git a/sys/arch/wgrisc/stand/boot.c b/sys/arch/wgrisc/stand/boot/boot.c index 170f6f923de..6892d6a6a23 100644 --- a/sys/arch/wgrisc/stand/boot.c +++ b/sys/arch/wgrisc/stand/boot/boot.c @@ -39,12 +39,21 @@ */ #include <sys/param.h> +#include <sys/stat.h> #include <sys/exec.h> +#include <sys/exec_elf.h> #include <stand.h> +#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 **)); +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 @@ -58,57 +67,83 @@ main(argc, argv) int argc; char **argv; { - char *cp; + char *cp = 0; int ask, entry; - int i; ask = 1; - for(i = 0; i < argc; i++) - printf("Arg %d:%s\n",i,argv[i]); - - do { - printf("Boot: "); - 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) { - gets(line); - return 0; + if(strcmp(argv[0], "man") != 0) { + cp = argv[0]; + ask = 0; } + while(1) { + do { + printf("Boot: "); + if (ask) { + gets(line); + cp = line; + argv[0] = cp; + argc = 1; + } else + printf("%s\n", cp); + } while(ask && line[0] == '\0'); - printf("Starting at 0x%x\n\n", entry); - ((void (*)())entry)(argc, argv, 0, 0); + entry = loadfile(cp); + if (entry != -1) { + printf("Starting at 0x%x\n\n", entry); + ((void (*)())entry)(argc, argv, 0, 0); + } + } + return(0); } /* * Open 'filename', read in program and return the entry point or -1 if error. */ +int loadfile(fname) register char *fname; { - struct devices *dp; - int fd, i, n; - struct exec aout; + int fd, i; + Elf32_Ehdr eh; + Elf32_Phdr *ph; + u_long phsize; - if ((fd = open(fname, 0)) < 0) { + if ((fd = oopen(fname, 0)) < 0) { printf("open(%s) failed: %d\n", fname, errno); goto err; } - /* read the exec header */ - i = read(fd, (char *)&aout, sizeof(aout)); + /* read the elf header */ + if(oread(fd, (char *)&eh, sizeof(eh)) != sizeof(eh)) { + goto serr; + } + + phsize = eh.e_phnum * sizeof(Elf32_Phdr); + ph = (Elf32_Phdr *) alloc(phsize); + olseek(fd, eh.e_phoff, 0); + if(oread(fd, (char *)ph, phsize) != phsize) { + goto serr; + } -cerr: - (void) close(fd); + 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) { + goto serr; + } + break; + default: + break; + } + } + (void) oclose(fd); + return(eh.e_entry); +serr: + printf("Read size error\n"); err: printf("Can't boot '%s'\n", fname); + (void) oclose(fd); return (-1); } diff --git a/sys/arch/wgrisc/stand/conf.c b/sys/arch/wgrisc/stand/boot/conf.c index cecbc70b64c..fa2b4cb730c 100644 --- a/sys/arch/wgrisc/stand/conf.c +++ b/sys/arch/wgrisc/stand/boot/conf.c @@ -43,28 +43,17 @@ int errno; extern void nullsys(); -extern int nodev(), noioctl(); +extern int nodev(); +extern int noioctl(); -int rzstrategy(), rzopen(); -#ifdef SMALL -#define rzclose 0 -#else /*!SMALL*/ -int rzclose(); -#endif /*!SMALL*/ - -#define rzioctl noioctl - -#ifndef BOOT -int tzstrategy(), tzopen(), tzclose(); -#endif -#define tzioctl noioctl +int sdstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); +int sdopen __P((struct open_file *, ...)); +int sdclose __P((struct open_file *)); +#define sdioctl noioctl struct devsw devsw[] = { - { "rz", rzstrategy, rzopen, rzclose, rzioctl }, /*0*/ -#ifndef BOOT - { "tz", tzstrategy, tzopen, tzclose, tzioctl }, /*1*/ -#endif + { "sd", sdstrategy, sdopen, sdclose, sdioctl }, /*0*/ }; int ndevs = (sizeof(devsw)/sizeof(devsw[0])); diff --git a/sys/arch/wgrisc/stand/filesystem.c b/sys/arch/wgrisc/stand/boot/filesystem.c index 514e6e809bf..b35709b9ad2 100644 --- a/sys/arch/wgrisc/stand/filesystem.c +++ b/sys/arch/wgrisc/stand/boot/filesystem.c @@ -33,8 +33,8 @@ * filesystem.c */ -#include <lib/libsa/stand.h> -#include <lib/libsa/ufs.h> +#include <stand.h> +#include <ufs.h> struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, diff --git a/sys/arch/wgrisc/stand/boot/ld.script b/sys/arch/wgrisc/stand/boot/ld.script new file mode 100644 index 00000000000..f81b4908653 --- /dev/null +++ b/sys/arch/wgrisc/stand/boot/ld.script @@ -0,0 +1,74 @@ +OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", + "elf32-littlemips") +OUTPUT_ARCH(mips) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0x80200000; + .text : + { + _ftext = . ; + *(.text) + *(.rodata) + *(.rodata1) + *(.reginfo) + *(.init) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0 + _etext = .; + PROVIDE (etext = .); + .fini : { *(.fini) } =0 + .data : + { + _fdata = . ; + *(.data) + CONSTRUCTORS + } + .data1 : { *(.data1) } + .ctors : { *(.ctors) } + .dtors : { *(.dtors) } + _gp = ALIGN(16) + 0x7ff0; + .got : + { + *(.got.plt) *(.got) + } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : { *(.sdata) } + .lit8 : { *(.lit8) } + .lit4 : { *(.lit4) } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + _fbss = .; + .sbss : { *(.sbss) *(.scommon) } + .bss : + { + *(.dynbss) + *(.bss) + *(COMMON) + } + _end = . ; + PROVIDE (end = .); + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the .debug DWARF section are relative to the beginning of the + section so we begin .debug at 0. It's not clear yet what needs to happen + for the others. */ + .debug 0 : { *(.debug) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .line 0 : { *(.line) } + /* These must appear regardless of . */ + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } +} diff --git a/sys/arch/wgrisc/stand/rz.c b/sys/arch/wgrisc/stand/boot/sd.c index 1094aef4705..34f8068e14a 100644 --- a/sys/arch/wgrisc/stand/rz.c +++ b/sys/arch/wgrisc/stand/boot/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rz.c,v 1.6 1995/06/28 10:22:35 jonathan Exp $ */ +/* $NetBSD: sd.c,v 1.6 1995/06/28 10:22:35 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)rz.c 8.1 (Berkeley) 6/10/93 + * @(#)sd.c 8.1 (Berkeley) 6/10/93 */ #include <stdarg.h> @@ -44,7 +44,11 @@ #include <sys/param.h> #include <sys/disklabel.h> -struct rz_softc { +int prom_seek __P((int, long, int)); +int disk_read __P((int, char *, int, int)); +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 */ @@ -53,7 +57,7 @@ struct rz_softc { }; int -rzstrategy(devdata, rw, bn, reqcnt, addr, cnt) +sdstrategy(devdata, rw, bn, reqcnt, addr, cnt) void *devdata; int rw; daddr_t bn; @@ -61,18 +65,14 @@ rzstrategy(devdata, rw, bn, reqcnt, addr, cnt) char *addr; u_int *cnt; /* out: number of bytes transfered */ { - register struct rz_softc *sc = (struct rz_softc *)devdata; - register int part = sc->sc_part; - register struct partition *pp = &sc->sc_label.d_partitions[part]; - register int s; + struct sd_softc *sc = (struct sd_softc *)devdata; + int part = sc->sc_part; + struct partition *pp = &sc->sc_label.d_partitions[part]; + int s; long offset; offset = bn * DEV_BSIZE; -#ifdef DEBUG -/*XXX*/printf("rz:%x %d\n", offset, reqcnt); -#endif - /* * Partial-block transfers not handled. */ @@ -83,28 +83,30 @@ rzstrategy(devdata, rw, bn, reqcnt, addr, cnt) offset += pp->p_offset * DEV_BSIZE; - if (Bios_Seek(sc->sc_fd, &offset, 0) != 0) - return (EIO); - s = Bios_Read(sc->sc_fd, addr, reqcnt, &reqcnt); - if (s != 0) + 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; return (0); } int -rzopen(struct open_file *f, ...) +sdopen(struct open_file *f, ...) { int ctlr, unit, part; - struct rz_softc *sc; + struct sd_softc *sc; struct disklabel *lp; + struct dos_partition dp, *dp2; int i, fd; char *msg; char buf[DEV_BSIZE]; int cnt; - static char device[] = "scsi()disk(0)rdisk()"; + daddr_t labelsector; + static char device[] = "sd(0)"; va_list ap; va_start(ap, f); @@ -112,21 +114,17 @@ rzopen(struct open_file *f, ...) ctlr = va_arg(ap, int); unit = va_arg(ap, int); part = va_arg(ap, int); - if (unit >= 8 || part >= 8) + if (unit >= 7 || part >= 16) return (ENXIO); -#if 0 - device[5] = '0' + unit; -#endif - /* NOTE: only support reads for now */ - i = Bios_Open(device, 0, &fd); - if (i != 0) { - printf("boot init failed error code %d\n", i); + device[3] = unit + '0'; + fd = disk_open(device, 0); + if (fd < 0) { return (ENXIO); } - sc = alloc(sizeof(struct rz_softc)); - bzero(sc, sizeof(struct rz_softc)); + sc = alloc(sizeof(struct sd_softc)); + bzero(sc, sizeof(struct sd_softc)); f->f_devdata = (void *)sc; sc->sc_fd = fd; @@ -134,41 +132,63 @@ rzopen(struct open_file *f, ...) sc->sc_unit = unit; sc->sc_part = part; - /* try to read disk label and partition table information */ lp = &sc->sc_label; lp->d_secsize = DEV_BSIZE; lp->d_secpercyl = 1; lp->d_npartitions = MAXPARTITIONS; lp->d_partitions[part].p_offset = 0; lp->d_partitions[part].p_size = 0x7fffffff; - i = rzstrategy(sc, F_READ, (daddr_t)LABELSECTOR, DEV_BSIZE, buf, &cnt); + + /* 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("rz%d: error reading disk label\n", unit); + printf("sd%d: error reading disk label\n", unit); goto bad; - } else { - msg = getdisklabel(buf, lp); - if (msg) { - printf("rz%d: %s\n", unit, msg); - 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; + } + } + for (dp2=&dp, i=0; i < NDOSPART; i++, dp2++) { + if (dp2->dp_size && dp2->dp_typ == DOSPTYP_386BSD) { + labelsector = dp2->dp_start; + break; } } + + /* 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 rz_softc)); + free(sc, sizeof(struct sd_softc)); #endif return (ENXIO); } return (0); } -#ifndef SMALL -rzclose(f) +int +sdclose(f) struct open_file *f; { - free(f->f_devdata, sizeof(struct rz_softc)); + free(f->f_devdata, sizeof(struct sd_softc)); f->f_devdata = (void *)0; return (0); } -#endif diff --git a/sys/arch/wgrisc/stand/boot/start.S b/sys/arch/wgrisc/stand/boot/start.S new file mode 100644 index 00000000000..70535726c56 --- /dev/null +++ b/sys/arch/wgrisc/stand/boot/start.S @@ -0,0 +1,130 @@ +/* $OpenBSD: start.S,v 1.1 1997/05/11 16:17:54 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. + * + */ + +#define ABICALLS + +#include <machine/regdef.h> +#include <machine/asm.h> + +/* + * Frame required for the debugger (if we have any) + */ +#define START_FRAME ((4 * 4) + 4 + 4) + + .globl __start +__start: + .set noreorder + la gp, _gp + la sp, __start - START_FRAME # Stack below program + sw zero, START_FRAME - 4(sp) # Zero out old ra for debugger + sw zero, START_FRAME - 8(sp) # Zero out old fp for debugger + move s0, a0 # save argc + move s1, a1 # save argv + + la a0, edata # clear BSS + li a1, 0 + la a2, end + jal memset # memset(edata, 0, end - edata) + subu a2, a2, a0 + + move a0, s0 # restore argc + jal main # main(argc, argv) + move a1, s1 # restore argv + + j restart # restart... + nop + +/* dummy routine for gcc2 */ +LEAF(__main) + j ra + nop +END(__main) + +/* + * Boot rom entrypoints. + */ + +#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) + + move a1, sp + li a0, 0 + li a2, 1 + jal prom_read + + lbu v0, 0(sp) + lw ra, STAND_RA_OFFSET(sp) + addu sp, sp, STAND_FRAME_SIZE + jr ra +END(getchar) + +LEAF(putchar) + sb a0, 0(sp) + move a1, sp + li a0, 1 /* Stdout */ + li a2, 1 + b prom_write + +END(putchar) + +LEAF(restart) +END(restart) + +LEAF(panic) +END(panic) + +LEAF(disk_open) + lw v0, BOOTVEC+96 + jr v0 +END(disk_open) + +LEAF(disk_read) + lw v0, BOOTVEC+100 + jr v0 +END(disk_read) + + +LEAF(prom_read) + lw v0, BOOTVEC+0 + jr v0 +END(prom_read) + +LEAF(prom_write) + lw v0, BOOTVEC+4 + jr v0 +END(prom_write) diff --git a/sys/arch/wgrisc/stand/libsa/Makefile b/sys/arch/wgrisc/stand/libsa/Makefile index d147171311d..f0ba65b1c51 100644 --- a/sys/arch/wgrisc/stand/libsa/Makefile +++ b/sys/arch/wgrisc/stand/libsa/Makefile @@ -1,14 +1,26 @@ -# $NetBSD: Makefile,v 1.5 1995/01/18 06:53:51 mellon Exp $ -# @(#)Makefile 8.2 (Berkeley) 2/16/94 +# $OpenBSD: Makefile,v 1.2 1997/05/11 16:17:55 pefo Exp $ LIB= sa -SRCS= alloc.c bcopy.c bzero.c close.c dev.c disklabel.c getfile.c \ - getputchar.c ioctl.c lseek.c open.c printf.c read.c ufs.c write.c \ - devopen.c getenv.c gets.c strcat.c strcmp.c strcpy.c strlen.c -.PATH: ../../../../lib/libsa ../../../../lib/libkern +S=${.CURDIR}/../../../.. +DIR_SA= $S/lib/libsa +DIR_KERN=$S/lib/libkern + +CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD +CFLAGS+=-DSTART=$(START) -DHEAP_LIMIT=$(HEAP_LIMIT) +CFLAGS+=${DEBUGFLAGS} -I${.CURDIR} -I${.CURDIR}/.. +CFLAGS+=-I$(S)/lib/libsa -I$(S) + +SRCS= alloc.c close.c dev.c disklabel.c dkcksum.c getfile.c ioctl.c \ + lseek.c open.c printf.c read.c ufs.c write.c devopen.c getenv.c \ + gets.c memcmp.c memcpy.c memset.c strcat.c strcmp.c strcpy.c strlen.c \ + strncpy.c + +.PATH: ${DIR_SA} ${DIR_KERN} + +all: ${SALIB} + NOPROFILE=noprofile +NOPIC=nopic .include <bsd.lib.mk> - -CFLAGS=-O2 -I../../include -I/sys -DSMALL diff --git a/sys/arch/wgrisc/stand/libsa/devopen.c b/sys/arch/wgrisc/stand/libsa/devopen.c index 79b35f8f595..32eef0c79cd 100644 --- a/sys/arch/wgrisc/stand/libsa/devopen.c +++ b/sys/arch/wgrisc/stand/libsa/devopen.c @@ -44,15 +44,16 @@ * Decode the string 'fname', open the device and return the remaining * file name if any. */ +int devopen(f, fname, file) struct open_file *f; const char *fname; char **file; /* out */ { - register char *cp; - register char *ncp; - register struct devsw *dp; - register int c, i; + const char *cp; + char *ncp; + struct devsw *dp; + int c, i; int ctlr = 0, unit = 0, part = 0; char namebuf[20]; int rc; @@ -60,7 +61,7 @@ devopen(f, fname, file) cp = fname; ncp = namebuf; - /* expect a string like 'rz(0,0,0)vmunix' */ + /* expect a string like 'sd(0,0,0)vmunix' */ while ((c = *cp) != '\0') { if (c == '(') { cp++; @@ -97,32 +98,19 @@ devopen(f, fname, file) cp++; *ncp = '\0'; -#ifdef SMALL - if (strcmp (namebuf, "rz")) { + if (strcmp (namebuf, "sd")) { printf ("Unknown device: %s\n", namebuf); return ENXIO; } dp = devsw; i = 0; -#else - for (dp = devsw, i = 0; i < ndevs; dp++, i++) - if (dp->dv_name && strcmp(namebuf, dp->dv_name) == 0) - goto fnd; - printf("Unknown device '%s'\nKnown devices are:", namebuf); - for (dp = devsw, i = 0; i < ndevs; dp++, i++) - if (dp->dv_name) - printf(" %s", dp->dv_name); - printf("\n"); - return (ENXIO); -fnd: -#endif rc = (dp->dv_open)(f, ctlr, unit, part); if (rc) return (rc); f->f_dev = dp; if (file && *cp != '\0') - *file = cp; + *file = (char *)cp; return (0); } diff --git a/sys/arch/wgrisc/stand/libsa/getenv.c b/sys/arch/wgrisc/stand/libsa/getenv.c index 7e063cd4ad5..e1341b47588 100644 --- a/sys/arch/wgrisc/stand/libsa/getenv.c +++ b/sys/arch/wgrisc/stand/libsa/getenv.c @@ -1,12 +1,8 @@ -/* $NetBSD: getenv.c,v 1.5 1995/01/18 06:53:55 mellon Exp $ */ +/* $OpenBSD: getenv.c,v 1.2 1997/05/11 16:17:55 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 for + * Willowglen Services PTE, by Per Fogelstrom, Opsycon AB. + * 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,11 +30,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)getenv.c 8.1 (Berkeley) 6/10/93 */ - char * getenv(s) char *s; { + return(0); } diff --git a/sys/arch/wgrisc/stand/libsa/gets.c b/sys/arch/wgrisc/stand/libsa/gets.c new file mode 100644 index 00000000000..841dd048915 --- /dev/null +++ b/sys/arch/wgrisc/stand/libsa/gets.c @@ -0,0 +1,80 @@ +/* $OpenBSD: gets.c,v 1.1 1997/05/11 16:17:56 pefo Exp $ */ +/* $NetBSD: gets.c,v 1.5.2.1 1995/10/13 19:54:26 pk Exp $ */ + +/*- + * Copyright (c) 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. 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. + * + * @(#)gets.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +void +gets(buf) + char *buf; +{ + register int c; + register char *lp; + + for (lp = buf;;) + switch (c = getchar() & 0177) { + case '\n': + case '\r': + *lp = '\0'; + return; + case '\b': + case '\177': + if (lp > buf) { + lp--; + putchar('\b'); + putchar(' '); + putchar('\b'); + } + break; + case 'r'&037: { + register char *p; + + putchar('\n'); + for (p = buf; p < lp; ++p) + putchar(*p); + break; + } + case 'u'&037: + case 'w'&037: + lp = buf; + putchar('\n'); + break; + default: + *lp++ = c; + } + /*NOTREACHED*/ +} diff --git a/sys/arch/wgrisc/stand/start.S b/sys/arch/wgrisc/stand/start.S deleted file mode 100644 index 09114a91b7e..00000000000 --- a/sys/arch/wgrisc/stand/start.S +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: start.S,v 1.1 1995/01/18 06:19:01 mellon 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. - * - * 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. - * - */ - -/* - * start.S - - * - * Contains code that is the first executed at boot time. - */ - -#include <machine/regdef.h> -#include <machine/cpu.h> -#include <machine/asm.h> - -/* - * Frame required for the debugger (if we have any) - */ -#define START_FRAME ((4 * 4) + 4 + 4) - - .globl __start -__start: - .set noreorder -#ifdef __GP_SUPPORT__ - la gp, _C_LABEL (_gp) -#endif - la sp, __start - START_FRAME # Stack below program - sw zero, START_FRAME - 4(sp) # Zero out old ra for debugger - sw zero, START_FRAME - 8(sp) # Zero out old fp for debugger - move s0, a0 # save argc - move s1, a1 # save argv - - la a0, _C_LABEL (edata) # clear BSS - la a1, _C_LABEL (end) - jal _C_LABEL(bzero) # bzero(edata, end - edata) - subu a1, a1, a0 - - move a0, s0 # restore argc - jal _C_LABEL(main) # main(argc, argv) - move a1, s1 # restore argv - - j _C_LABEL(Bios_Restart) # restart... - nop - -/* dummy routine for gcc2 */ - .globl _C_LABEL(__main) -_C_LABEL(__main): - j ra - nop - -#define Bios_Call(Name,Offset) \ -LEAF(Name); \ - lw v0,0x80001020; \ - lw v0,Offset(v0); \ - jr v0 ; \ - nop ; \ - END(Name) - -Bios_Call(Bios_Load, 0x00) -Bios_Call(Bios_Invoke, 0x04) -Bios_Call(Bios_Execute, 0x08) -Bios_Call(Bios_Halt, 0x0c) -Bios_Call(Bios_PowerDown, 0x10) -Bios_Call(Bios_Restart, 0x14) -Bios_Call(Bios_Reboot, 0x18) -Bios_Call(Bios_EnterInteractiveMode, 0x1c) -Bios_Call(Bios_Unused1, 0x20) -Bios_Call(Bios_GetPeer, 0x24) -Bios_Call(Bios_GetChild, 0x28) -Bios_Call(Bios_GetParent, 0x2c) -Bios_Call(Bios_GetConfigurationData, 0x30) -Bios_Call(Bios_AddChild, 0x34) -Bios_Call(Bios_DeleteComponent, 0x38) -Bios_Call(Bios_GetComponent, 0x3c) -Bios_Call(Bios_SaveConfiguration, 0x40) -Bios_Call(Bios_GetSystemId, 0x44) -Bios_Call(Bios_GetMemoryDescriptor, 0x48) -Bios_Call(Bios_Unused2, 0x4c) -Bios_Call(Bios_GetTime, 0x50) -Bios_Call(Bios_GetRelativeTime, 0x54) -Bios_Call(Bios_GetDirectoryEntry, 0x58) -Bios_Call(Bios_Open, 0x5c) -Bios_Call(Bios_Close, 0x60) -Bios_Call(Bios_Read, 0x64) -Bios_Call(Bios_GetReadStatus, 0x68) -Bios_Call(Bios_Write, 0x6c) -Bios_Call(Bios_Seek, 0x70) -Bios_Call(Bios_Mount, 0x74) -Bios_Call(Bios_GetEnvironmentVariable, 0x78) -Bios_Call(Bios_SetEnvironmentVariable, 0x7c) -Bios_Call(Bios_GetFileInformation, 0x80) -Bios_Call(Bios_SetFileInformation, 0x84) -Bios_Call(Bios_FlushAllCaches, 0x88) -Bios_Call(Bios_TestUnicodeCharacter, 0x8c) -Bios_Call(Bios_GetDisplayStatus, 0x90) |