diff options
author | Steve Murphree <smurph@cvs.openbsd.org> | 1998-08-22 08:08:29 +0000 |
---|---|---|
committer | Steve Murphree <smurph@cvs.openbsd.org> | 1998-08-22 08:08:29 +0000 |
commit | 87c23604fb0b6fa5748345906074855d5a034bb6 (patch) | |
tree | 44f9ada4f85b68e43a4d4ce670e43cb994ccbcc4 /sys | |
parent | 1f67073b7df408627e13f1256030ac64be67f76a (diff) |
New libsa.
Diffstat (limited to 'sys')
21 files changed, 397 insertions, 1327 deletions
diff --git a/sys/arch/mvme88k/stand/libsa/Makefile b/sys/arch/mvme88k/stand/libsa/Makefile index 8aa02095e63..96a743a069b 100644 --- a/sys/arch/mvme88k/stand/libsa/Makefile +++ b/sys/arch/mvme88k/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.1 1997/03/03 19:30:35 rahnds Exp $ +# $OpenBSD: Makefile,v 1.2 1998/08/22 08:07:49 smurph Exp $ LIB=sa @@ -12,35 +12,34 @@ S=${.CURDIR}/../../../.. DIR_SA=$S/lib/libsa DIR_KERN=$S/lib/libkern -SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \ - bootparam.c rarp.c +SRC_net= arp.c ether.c in_cksum.c net.c netif.c rpc.c nfs.c \ + rarp.c bootparam.c +SRC_sa= alloc.c memcpy.c exit.c getfile.c gets.c globals.c \ + printf.c strerror.c memset.c memcmp.c strncpy.c strcmp.c strlen.c \ + close.c closeall.c dev.c dkcksum.c \ + lseek.c open.c nullfs.c read.c fstat.c \ + ufs.c cread.c -#SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \ -# printf.c read.c strerror.c ufs.c globals.c lseek.c \ -# closeall.c dev.c dkcksum.c nullfs.c fstat.c +SRC_kern= ashrdi3.c bzero.c -SRC_sa = alloc.c bcopy.c close.c getfile.c open.c \ - printf.c read.c strerror.c ufs.c globals.c lseek.c \ - dev.c +SRC_mvme= exec_mvme.c -SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c +SRC_here= bugdev.c clock.c parse_args.c -SRC_here= clock.c devopen.c dvma.c \ - gets.c panic.c \ - promboot.c promcons.c - -SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_here} +SRCS= ${SRC_net} ${SRC_sa} ${SRC_mvme} ${SRC_here} ${SRC_kern} # DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \ # -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG #DEFS= -DCOMPAT_UFS -INCL= -I. -I${S}/lib/libsa -I${S} +DEFS= -D__INTERNAL_LIBSA_CREAD +#-DNETIF_DEBUG +INCL= -I${.CURDIR} -I${.CURDIR}/../libbug -I${S}/lib/libsa -I${S} COPTS= #-fno-defer-pop -CFLAGS= ${COPTS} ${DEFS} ${DBG} ${INCL} +CFLAGS+= ${XCFLAGS} -O2 ${COPTS} ${DEFS} ${DBG} ${INCL} -.PATH: ${DIR_SA} ${DIR_KERN} ../../sun3 +.PATH: ${DIR_SA} ${DIR_KERN} all: libsa.a SRT0.o SRT1.o diff --git a/sys/arch/mvme88k/stand/libsa/Makefile.inc b/sys/arch/mvme88k/stand/libsa/Makefile.inc index c402951fa76..ff00fc33b62 100644 --- a/sys/arch/mvme88k/stand/libsa/Makefile.inc +++ b/sys/arch/mvme88k/stand/libsa/Makefile.inc @@ -1,12 +1,15 @@ -LIB_SA_DIR=${S}/arch/${MACHINE}/stand/libsa +# $OpenBSD: Makefile.inc,v 1.2 1998/08/22 08:07:51 smurph Exp $ + +LIB_SA_DIR=${S}/arch/mvme88k/stand/libsa LIBSA_DIR!= cd ${LIB_SA_DIR}; \ printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx LIBSA=${LIBSA_DIR}/libsa.a +SRTOBJ?= ${LIBSA_DIR}/SRT0.o $(LIBSA): .NOTMAIN __always_make_libsa @echo making sure the libsa is up to date... - @(cd ${LIB_SA_DIR}; ${MAKE}) + @(cd ${LIB_SA_DIR}; ${MAKE} "XCFLAGS=${CFLAGS}") __always_make_libsa: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/libsa/bug.c b/sys/arch/mvme88k/stand/libsa/bug.c deleted file mode 100644 index e0ac46017bf..00000000000 --- a/sys/arch/mvme88k/stand/libsa/bug.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 1995 Theo de Raadt - * 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 Theo de Raadt - * 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. - * - * bug routines -- assumes that the necessary sections of memory - * are preserved. - */ -#include <sys/types.h> -#include <machine/prom.h> - -#define MVMEPROM_CALL(x) \ - asm volatile (__CONCAT("trap #15; .short ", __STRING(x)) ) - -/* returns 0 if no characters ready to read */ -int -mvmeprom_instat() -{ - u_short ret; - - MVMEPROM_CALL(MVMEPROM_INSTAT); - asm volatile ("movew ccr,%0": "=d" (ret)); - return (!(ret & 0x4)); -} - -void -mvmeprom_outstr(start, end) - char *start, *end; -{ - asm volatile ("movl %0, sp@-" : "=a" (start)); - asm volatile ("movl %0, sp@-" : "=a" (end)); - MVMEPROM_CALL(MVMEPROM_OUTSTR); -} - -void -mvmeprom_outln(start, end) - char *start, *end; -{ - asm volatile ("movl %0, sp@-" : "=a" (start)); - asm volatile ("movl %0, sp@-" : "=a" (end)); - MVMEPROM_CALL(MVMEPROM_OUTSTRCRLF); -} - -/* returns 0: success, nonzero: error */ -int -mvmeprom_diskrd(arg) - struct mvmeprom_dskio *arg; -{ - int ret; - - asm volatile ("movel %0, sp@-"::"d" (arg)); - MVMEPROM_CALL(MVMEPROM_DSKRD); - asm volatile ("movew ccr,%0": "=d" (ret)); - return (!(ret & 0x4)); -} - -/* returns 0: success, nonzero: error */ -int -mvmeprom_diskwr(arg) - struct mvmeprom_dskio *arg; -{ - int ret; - - asm volatile ("movel %0, sp@-"::"d" (arg)); - MVMEPROM_CALL(MVMEPROM_DSKWR); - asm volatile ("movew ccr,%0": "=d" (ret)); - return (!(ret & 0x4)); -} - -#ifdef NOTYET -mvmeprom_diskcfig() {} -mvmeprom_diskfmt(){} -mvmeprom_diskctrl(){} -#endif - -/* BUG - timing routine */ -void -mvmeprom_delay(msec) - int msec; -{ - asm volatile ("movel %0,sp@-" : :"d" (msec)); - MVMEPROM_CALL(MVMEPROM_DELAY); -} - -/* BUG - return to bug routine */ -void -mvmeprom_return() -{ - MVMEPROM_CALL(MVMEPROM_EXIT); - /*NOTREACHED*/ -} - -/* BUG - query board routines */ -struct mvmeprom_brdid * -mvmeprom_getbrdid() -{ - struct mvmeprom_brdid *id; - - asm volatile ("clrl sp@-"); - MVMEPROM_CALL(MVMEPROM_GETBRDID); - asm volatile ("movel sp@+,%0": "=d" (id):); - return (id); -} - -void -mvmeprom_rtc_rd(ptime) - struct mvmeprom_time *ptime; -{ - asm volatile ("movel %0,sp@-" : :"a" (ptime)); - MVMEPROM_CALL(MVMEPROM_RTC_RD); -} diff --git a/sys/arch/mvme88k/stand/libsa/bugdev.c b/sys/arch/mvme88k/stand/libsa/bugdev.c new file mode 100644 index 00000000000..6de4b615a60 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/bugdev.c @@ -0,0 +1,238 @@ +/* $OpenBSD: bugdev.c,v 1.1 1998/08/22 08:07:55 smurph Exp $ */ + +/* + * Copyright (c) 1993 Paul Kranenburg + * 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 Paul Kranenburg. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS 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 <sys/param.h> +#include <sys/disklabel.h> +#include <machine/prom.h> + +#include "stand.h" +#include "libsa.h" + +void cputobsdlabel __P((struct disklabel *lp, struct cpu_disklabel *clp)); + +int errno; + +struct bugsc_softc { + int fd; /* Prom file descriptor */ + int poff; /* Partition offset */ + int psize; /* Partition size */ + short ctrl; + short dev; +} bugsc_softc[1]; + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + register struct bugsc_softc *pp = &bugsc_softc[0]; + int error, i, dn = 0, pn = 0; + char *dev, *cp; + static char iobuf[MAXBSIZE]; + struct disklabel sdlabel; + + dev = bugargs.arg_start; + + /* + * Extract partition # from boot device string. + */ + for (cp = dev; *cp; cp++) /* void */; + while (*cp != '/' && cp > dev) { + if (*cp == ':') + pn = *(cp+1) - 'a'; + --cp; + } + + pp->fd = bugscopen(f); + + if (pp->fd < 0) { + printf("Can't open device `%s'\n", dev); + return (ENXIO); + } + error = bugscstrategy(pp, F_READ, LABELSECTOR, DEV_BSIZE, iobuf, &i); + if (error) + return (error); + if (i != DEV_BSIZE) + return (EINVAL); + + cputobsdlabel(&sdlabel, (struct cpu_disklabel *)iobuf); + pp->poff = sdlabel.d_partitions[pn].p_offset; + pp->psize = sdlabel.d_partitions[pn].p_size; + + f->f_dev = devsw; + f->f_devdata = (void *)pp; + *file = (char *)fname; + return (0); +} + +/* silly block scale factor */ +#define BUG_BLOCK_SIZE 256 +#define BUG_SCALE (512/BUG_BLOCK_SIZE) +int +bugscstrategy(devdata, func, dblk, size, buf, rsize) + void *devdata; + int func; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + struct mvmeprom_dskio dio; + register struct bugsc_softc *pp = (struct bugsc_softc *)devdata; + daddr_t blk = dblk + pp->poff; + + twiddle(); + + dio.ctrl_lun = pp->ctrl; + dio.dev_lun = pp->dev; + dio.status = 0; + dio.pbuffer = buf; + dio.blk_num = blk * BUG_SCALE; + dio.blk_cnt = size / BUG_BLOCK_SIZE; /* assumed size in bytes */ + dio.flag = 0; + dio.addr_mod = 0; +#ifdef DEBUG + printf("bugscstrategy: size=%d blk=%d buf=%x\n", size, blk, buf); + printf("ctrl %d dev %d\n", dio.ctrl_lun, dio.dev_lun); +#endif + mvmeprom_diskrd(&dio); + + *rsize = dio.blk_cnt * BUG_BLOCK_SIZE; +#ifdef DEBUG +printf("rsize %d status %x\n", *rsize, dio.status); +#endif + + if (dio.status) + return (EIO); + return (0); +} + +int +bugscopen(f) + struct open_file *f; +{ +#ifdef DEBUG + printf("bugscopen:\n"); +#endif + + f->f_devdata = (void *)bugsc_softc; + bugsc_softc[0].ctrl = (short)bugargs.ctrl_lun; + bugsc_softc[0].dev = (short)bugargs.dev_lun; +#ifdef DEBUG + printf("using mvmebug ctrl %d dev %d\n", + bugsc_softc[0].ctrl, bugsc_softc[0].dev); +#endif + return (0); +} + +int +bugscclose(f) + struct open_file *f; +{ + return (EIO); +} + +int +bugscioctl(f, cmd, data) + struct open_file *f; + u_long cmd; + void *data; +{ + return (EIO); +} + +void +cputobsdlabel(lp, clp) + struct disklabel *lp; + struct cpu_disklabel *clp; +{ + int i; + + lp->d_magic = clp->magic1; + lp->d_type = clp->type; + lp->d_subtype = clp->subtype; + bcopy(clp->vid_vd, lp->d_typename, 16); + bcopy(clp->packname, lp->d_packname, 16); + lp->d_secsize = clp->cfg_psm; + lp->d_nsectors = clp->cfg_spt; + lp->d_ncylinders = clp->cfg_trk; /* trk is really num of cyl! */ + lp->d_ntracks = clp->cfg_hds; + + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_sparespertrack = clp->sparespertrack; + lp->d_sparespercyl = clp->sparespercyl; + lp->d_acylinders = clp->acylinders; + lp->d_rpm = clp->rpm; + lp->d_interleave = clp->cfg_ilv; + lp->d_trackskew = clp->cfg_sof; + lp->d_cylskew = clp->cylskew; + lp->d_headswitch = clp->headswitch; + + /* this silly table is for winchester drives */ + switch (clp->cfg_ssr) { + case 0: + lp->d_trkseek = 0; + break; + case 1: + lp->d_trkseek = 6; + break; + case 2: + lp->d_trkseek = 10; + break; + case 3: + lp->d_trkseek = 15; + break; + case 4: + lp->d_trkseek = 20; + break; + default: + lp->d_trkseek = 0; + break; + } + lp->d_flags = clp->flags; + for (i = 0; i < NDDATA; i++) + lp->d_drivedata[i] = clp->drivedata[i]; + for (i = 0; i < NSPARE; i++) + lp->d_spare[i] = clp->spare[i]; + lp->d_magic2 = clp->magic2; + lp->d_checksum = clp->checksum; + lp->d_npartitions = clp->partitions; + lp->d_bbsize = clp->bbsize; + lp->d_sbsize = clp->sbsize; + bcopy(clp->vid_4, &(lp->d_partitions[0]),sizeof (struct partition) * 4); + bcopy(clp->cfg_4, &(lp->d_partitions[4]), sizeof (struct partition) + * ((MAXPARTITIONS < 16) ? (MAXPARTITIONS - 4) : 12)); +} diff --git a/sys/arch/mvme88k/stand/libsa/clock.h b/sys/arch/mvme88k/stand/libsa/clock.h deleted file mode 100644 index d61bc9b03b8..00000000000 --- a/sys/arch/mvme88k/stand/libsa/clock.h +++ /dev/null @@ -1,6 +0,0 @@ - -extern int hz; - -time_t getsecs(); -int getticks(); - diff --git a/sys/arch/mvme88k/stand/libsa/clockreg.h b/sys/arch/mvme88k/stand/libsa/clockreg.h deleted file mode 100644 index 7eb7eba2b81..00000000000 --- a/sys/arch/mvme88k/stand/libsa/clockreg.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $Id: clockreg.h,v 1.1 1997/03/03 19:30:37 rahnds Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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, Lawrence Berkeley Laboratory. - * - * 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. - * - * @(#)clockreg.h 8.1 (Berkeley) 6/11/93 - */ - -/* - * Mostek MK48T02 clock. - */ -struct clockreg { - volatile u_char cl_csr; /* control register */ - volatile u_char cl_sec; /* seconds (0..59; BCD) */ - volatile u_char cl_min; /* minutes (0..59; BCD) */ - volatile u_char cl_hour;/* hour (0..23; BCD) */ - volatile u_char cl_wday;/* weekday (1..7) */ - volatile u_char cl_mday;/* day in month (1..31; BCD) */ - volatile u_char cl_month; /* month (1..12; BCD) */ - volatile u_char cl_year;/* year (0..99; BCD) */ -}; -/* bits in cl_csr */ -#define CLK_WRITE 0x80 /* want to write */ -#define CLK_READ 0x40 /* want to read (freeze clock) */ - -/* - * Sun chose the year `68' as their base count, so that - * cl_year==0 means 1968. - */ -#define YEAR0 68 - -#define CLOCK_ADDR_147 (0xfffe07f8) /* PA of clock */ -#define CLOCK_ADDR_16x (0xfffc1ff8) /* PA of clock */ diff --git a/sys/arch/mvme88k/stand/libsa/dev_disk.c b/sys/arch/mvme88k/stand/libsa/dev_disk.c deleted file mode 100644 index 65c1db4ac64..00000000000 --- a/sys/arch/mvme88k/stand/libsa/dev_disk.c +++ /dev/null @@ -1,132 +0,0 @@ -/* $Id: dev_disk.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ - -/* - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This module implements a "raw device" interface suitable for - * use by the stand-alone I/O library UFS file-system code, and - * possibly for direct access (i.e. boot from tape). - * - * The implementation is deceptively simple because it uses the - * drivers provided by the Sun PROM monitor. Note that only the - * PROM driver used to load the boot program is available here. - */ - -#include <sys/types.h> -#include <machine/mon.h> -#include <machine/saio.h> - -#include "stand.h" - -#include "dvma.h" -#include "promdev.h" - -int -disk_open(f, devname) - struct open_file *f; - char *devname; /* Device part of file name (or NULL). */ -{ - struct saioreq *sip; - int error; - -#ifdef DEBUG_PROM - printf("disk_open: %s\n", devname); -#endif - - if ((error = prom_iopen(&sip)) != 0) - return (error); - - f->f_devdata = sip; - return 0; -} - -int -disk_close(f) - struct open_file *f; -{ - struct saioreq *sip; - - sip = f->f_devdata; - prom_iclose(sip); - f->f_devdata = NULL; - return 0; -} - -int -disk_strategy(devdata, flag, dblk, size, buf, rsize) - void *devdata; - int flag; - daddr_t dblk; - u_int size; - char *buf; - u_int *rsize; -{ - struct saioreq *si; - struct boottab *ops; - char *dmabuf; - int si_flag, xcnt; - - si = devdata; - ops = si->si_boottab; - -#ifdef DEBUG_PROM - printf("disk_strategy: size=%d dblk=%d\n", size, dblk); -#else - twiddle(); -#endif - - dmabuf = dvma_mapin(buf, size); - - si->si_bn = dblk; - si->si_ma = dmabuf; - si->si_cc = size; - - si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE; - xcnt = (*ops->b_strategy)(si, si_flag); - dvma_mapout(dmabuf, size); - -#ifdef DEBUG_PROM - printf("disk_strategy: xcnt = %x\n", xcnt); -#endif - - if (xcnt <= 0) - return (EIO); - - *rsize = xcnt; - return (0); -} - -int -disk_ioctl() -{ - return EIO; -} - diff --git a/sys/arch/mvme88k/stand/libsa/dev_disk.h b/sys/arch/mvme88k/stand/libsa/dev_disk.h deleted file mode 100644 index 9f05f74bd82..00000000000 --- a/sys/arch/mvme88k/stand/libsa/dev_disk.h +++ /dev/null @@ -1,6 +0,0 @@ - -int disk_open __P((struct open_file *, ...)); -int disk_close __P((struct open_file *)); -int disk_strategy __P((void *, int, daddr_t, u_int, char *, u_int *)); -int disk_ioctl(); - diff --git a/sys/arch/mvme88k/stand/libsa/devopen.c b/sys/arch/mvme88k/stand/libsa/devopen.c deleted file mode 100644 index 92c083983cb..00000000000 --- a/sys/arch/mvme88k/stand/libsa/devopen.c +++ /dev/null @@ -1,32 +0,0 @@ - -#include <sys/param.h> -#include <stand.h> -#include "promboot.h" - -/* - * Open the device named by the combined device/file name - * given as the "fname" arg, something like: "sd()bsd" - * - * However, Sun PROMs don't really let you choose which - * device you will talk to. You can only open the device - * that was used to load the boot program. Therefore, we - * do not accept a "device" part in the "fname" string. - * Pass the PROM device name to open in case it needs it. - */ -int -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **file; -{ - struct devsw *dp; - char *cp, *path, *devname; - int error; - - *file = (char*)fname; - dp = &devsw[0]; - f->f_dev = dp; - error = (*dp->dv_open)(f, prom_bootdev); - - return (error); -} diff --git a/sys/arch/mvme88k/stand/libsa/dvma.c b/sys/arch/mvme88k/stand/libsa/dvma.c deleted file mode 100644 index 11526106c2a..00000000000 --- a/sys/arch/mvme88k/stand/libsa/dvma.c +++ /dev/null @@ -1,68 +0,0 @@ - -/* - * The easiest way to deal with the need for DVMA mappings is - * to just map the first four megabytes of RAM into DVMA space. - * That way, dvma_mapin can just compute the DVMA alias address, - * and dvma_mapout does nothing. - */ - -#include <sys/param.h> - -#define DVMA_BASE 0x00000000 -#define DVMA_MASK 0x00ffFFff -#define DVMA_MAPLEN 0x400000 /* 4 MB */ - -void -dvma_init() -{ -#if 0 - int segva, sme; - - for (segva = 0; segva < DVMA_MAPLEN; segva += NBSG) { - sme = get_segmap(segva); - set_segmap((DVMA_BASE | segva), sme); - } -#endif -} - -/* Convert a local address to a DVMA address. */ -char * -dvma_mapin(char *addr, int len) -{ - int va = (int)addr; - - va |= DVMA_BASE; - return ((char *) va); -} - -/* Convert a DVMA address to a local address. */ -char * -dvma_mapout(char *dmabuf, int len) -{ - if (dmabuf < (char*)DVMA_BASE) - panic("dvma_mapout"); - return (dmabuf - DVMA_BASE); -} - -extern char *alloc(int len); -char * -dvma_alloc(int len) -{ - char *mem; - - mem = alloc(len); - if (!mem) - return(mem); - return(dvma_mapin(mem, len)); -} - -extern void free(void *ptr, int len); -void -dvma_free(char *dvma, int len) -{ - char *mem; - - mem = dvma_mapout(dvma, len); - if (mem) - free(mem, len); -} diff --git a/sys/arch/mvme88k/stand/libsa/dvma.h b/sys/arch/mvme88k/stand/libsa/dvma.h deleted file mode 100644 index 2b8be37cbe0..00000000000 --- a/sys/arch/mvme88k/stand/libsa/dvma.h +++ /dev/null @@ -1,6 +0,0 @@ - -char * dvma_mapin(char *pkt, int len); -void dvma_mapout(char *dmabuf, int len); - -char * dvma_alloc(int len); - diff --git a/sys/arch/mvme88k/stand/libsa/exec_sun.c b/sys/arch/mvme88k/stand/libsa/exec_mvme.c index 5708b413541..4038238b1bc 100644 --- a/sys/arch/mvme88k/stand/libsa/exec_sun.c +++ b/sys/arch/mvme88k/stand/libsa/exec_mvme.c @@ -1,35 +1,6 @@ -/* $Id: exec_sun.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ +/* $NetBSD: exec_sun.c,v 1.5 1996/01/29 23:41:06 gwr Exp $ */ /*- - * Copyright (c) 1995 Theo de Raadt - * 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 Theo de Raadt - * 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. - * * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -66,35 +37,46 @@ #include <sys/param.h> #include <sys/reboot.h> +#include <machine/prom.h> #include <a.out.h> #include "stand.h" - -extern int debug; - -extern u_int bootdev; - +#include "libsa.h" + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +#define RB_NOSYM 0x400 /*ARGSUSED*/ -exec_sun(file, loadaddr, howto) +void +exec_mvme(file, flag) char *file; - char *loadaddr; - int howto; + int flag; { + char *loadaddr; register int io; struct exec x; int cc, magic; void (*entry)(); register char *cp; register int *ip; - int textlen; #ifdef DEBUG - printf("exec_sun: file=%s loadaddr=0x%x\n", file, loadaddr); + printf("exec_mvme: file=%s flag=0x%x\n", file, flag); #endif io = open(file, 0); if (io < 0) - return(-1); + return; /* * Read in the exec header, and validate it. @@ -106,13 +88,23 @@ exec_sun(file, loadaddr, howto) goto closeout; } + /* + * note: on the mvme ports, the kernel is linked in such a way that + * its entry point is the first item in .text, and thus a_entry can + * be used to determine both the load address and the entry point. + * (also note that we make use of the fact that the kernel will live + * in a VA == PA range of memory ... otherwise we would take + * loadaddr as a parameter and let the kernel relocate itself!) + * + * note that ZMAGIC files included the a.out header in the text area + * so we must mask that off (has no effect on the other formats + */ + loadaddr = (void *)(x.a_entry & ~sizeof(x)); + cp = loadaddr; - textlen = x.a_text; magic = N_GETMAGIC(x); - if (magic == ZMAGIC) { + if (magic == ZMAGIC) cp += sizeof(x); - textlen -= sizeof(x); - } entry = (void (*)())cp; /* @@ -125,10 +117,13 @@ exec_sun(file, loadaddr, howto) /* * Read in the text segment. */ - printf("%x", x.a_text); - if (read(io, cp, textlen) != textlen) + printf("%d", x.a_text); + cc = x.a_text; + if (magic == ZMAGIC) + cc = cc - sizeof(x); /* a.out header part of text in zmagic */ + if (read(io, cp, cc) != cc) goto shread; - cp += textlen; + cp += cc; /* * NMAGIC may have a gap between text and data. @@ -142,24 +137,24 @@ exec_sun(file, loadaddr, howto) /* * Read in the data segment. */ - printf("+%x", x.a_data); + printf("+%d", x.a_data); if (read(io, cp, x.a_data) != x.a_data) goto shread; cp += x.a_data; /* * Zero out the BSS section. - * (Kernel does not do it itself) + * (Kernel doesn't care, but do it anyway.) */ - printf("+%x", x.a_bss); + printf("+%d", x.a_bss); cc = x.a_bss; while ((int)cp & 3) { *cp++ = 0; --cc; } - ip = (int *)cp; + ip = (int*)cp; cp += cc; - while ((char *)ip < cp) + while ((char*)ip < cp) *ip++ = 0; /* @@ -167,23 +162,23 @@ exec_sun(file, loadaddr, howto) * (Always set the symtab size word.) */ *ip++ = x.a_syms; - cp = (char *)ip; + cp = (char*) ip; - if (x.a_syms > 0) { + if (x.a_syms > 0 && (flag & RB_NOSYM) == 0) { /* Symbol table and string table length word. */ cc = x.a_syms; - printf("+[%x", cc); + printf("+[%d", cc); cc += sizeof(int); /* strtab length too */ if (read(io, cp, cc) != cc) goto shread; cp += x.a_syms; - ip = (int *)cp; /* points to strtab length */ + ip = (int*)cp; /* points to strtab length */ cp += sizeof(int); /* String table. Length word includes itself. */ cc = *ip; - printf("+%x]", cc); + printf("+%d]", cc); cc -= sizeof(int); if (cc <= 0) goto shread; @@ -191,22 +186,19 @@ exec_sun(file, loadaddr, howto) goto shread; cp += cc; } - printf("=%x\n", cp - loadaddr); + printf("=0x%x\n", cp - loadaddr); close(io); - if (debug) { - printf("Debug mode - enter c to continue\n"); - asm(" trap #0"); - } - - printf("Starting program at 0x%x\n", (int)entry); - (*entry)(howto, bootdev, cp, 0, 0); - panic("exec returned"); + printf("Start @ 0x%x ...\n", (int)entry); +/* (addr)(flag, 0, kernel.esym, kernel.smini, kernel.emini);*/ + (*entry)(flag, bugargs.ctrl_addr, cp, kernel.smini, kernel.emini); + printf("exec: kernel returned!\n"); + return; shread: printf("exec: short read\n"); errno = EIO; closeout: close(io); - return(-1); + return; } diff --git a/sys/arch/mvme88k/stand/libsa/gets.c b/sys/arch/mvme88k/stand/libsa/gets.c deleted file mode 100644 index 071acc0d9fa..00000000000 --- a/sys/arch/mvme88k/stand/libsa/gets.c +++ /dev/null @@ -1,141 +0,0 @@ -/* $Id: gets.c,v 1.1 1997/03/03 19:30:35 rahnds Exp $ */ - -/*- - * Copyright (c) 1995 Theo de Raadt - * 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 Theo de Raadt - * 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. - * - * 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" - -/* - * This implementation assumes that getchar() does echo, because - * on some machines, it is hard to keep echo from being done. - * Those that need it can do echo in their getchar() function. - * - * Yes, the code below will echo CR, DEL, and other control chars, - * but sending CR or DEL here is harmless. All the other editing - * characters will be followed by a newline, so it doesn't matter. - * (Most terminals will not show them anyway.) - */ - -void -gets(buf) - char *buf; -{ - register int c; - register char *lp; - -top: - lp = buf; - - for (;;) { - c = getchar() & 0177; - - putchar(c); - - switch (c) { - - default: - *lp++ = c; - continue; - - case '\177': - putchar('\b'); - /* fall through */ - case '\b': - putchar(' '); - putchar('\b'); - /* fall through */ - case '#': - if (lp > buf) - lp--; - continue; - - /* - * This is not very useful in a boot program. - * (It costs you 52 bytes on m68k, gcc -O3). - */ - case 'r'&037: { - register char *p; - putchar('\n'); - for (p = buf; p < lp; ++p) - putchar(*p); - continue; - } - - case '@': - case 'u'&037: - case 'w'&037: - putchar('\n'); - goto top; - - case '\r': - putchar('\n'); - /* fall through */ - case '\n': - *lp = '\0'; - return; - - } /* switch */ - } - /*NOTREACHED*/ -} diff --git a/sys/arch/mvme88k/stand/libsa/libsa.h b/sys/arch/mvme88k/stand/libsa/libsa.h new file mode 100644 index 00000000000..eff5fd7988e --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/libsa.h @@ -0,0 +1,18 @@ +/* + * libsa prototypes + */ + +#include "libbug.h" + +/* bugdev.c */ +int bugscopen __P((struct open_file *, ...)); +int bugscclose __P((struct open_file *)); +int bugscioctl __P((struct open_file *, u_long, void *)); +int bugscstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); + +/* exec_mvme.c */ +void exec_mvme __P((char *, int)); + +/* parse_args.c */ +int parse_args __P((char **, int *)); + diff --git a/sys/arch/mvme88k/stand/libsa/netif_sun.c b/sys/arch/mvme88k/stand/libsa/netif_sun.c deleted file mode 100644 index 5201318a14a..00000000000 --- a/sys/arch/mvme88k/stand/libsa/netif_sun.c +++ /dev/null @@ -1,284 +0,0 @@ -/* $Id: netif_sun.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ - -/* - * Copyright (c) 1995 Gordon W. Ross - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * 4. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Gordon W. Ross - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * The Sun PROM has a fairly general set of network drivers, - * so it is easiest to just replace the netif module with - * this adaptation to the PROM network interface. - */ - -#include <sys/param.h> -#include <sys/socket.h> -#include <string.h> -#include <time.h> - -#include <net/if.h> - -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <netinet/in_systm.h> - -#include <machine/control.h> -#include <machine/idprom.h> -#include <machine/mon.h> -#include <machine/saio.h> - -#include "stand.h" -#include "net.h" -#include "netif.h" - -#include "clock.h" -#include "dvma.h" -#include "promdev.h" - -static struct netif netif_prom; - -#ifdef NETIF_DEBUG -int netif_debug; -#endif - -struct iodesc sockets[SOPEN_MAX]; - -struct iodesc * -socktodesc(sock) - int sock; -{ - if (sock != 0) { - return(NULL); - } - return (sockets); -} - -int -netif_open(machdep_hint) - void *machdep_hint; -{ - struct saioreq *si; - struct iodesc *io; - int fd, error; - - /* find a free socket */ - io = sockets; - if (io->io_netif) { -#ifdef DEBUG - printf("netif_open: device busy\n"); -#endif - return (-1); - } - bzero(io, sizeof(*io)); - - /* - * Note: Sun PROMs will do RARP on open, but does not tell - * you the IP address it gets, so it is just noise to us... - */ - if ((error = prom_iopen(&si)) != 0) { -#ifdef DEBUG - printf("netif_open: prom_iopen, error=%d\n", error); -#endif - return (-1); - } - if (si->si_sif == NULL) { -#ifdef DEBUG - printf("netif_open: not a network device\n"); -#endif - prom_iclose(si); - return (-1); - } - - netif_prom.devdata = si; - io->io_netif = &netif_prom; - - /* Put our ethernet address in io->myea */ - sun3_getether(io->myea); - - return(0); -} - -int -netif_close(fd) - int fd; -{ - struct iodesc *io; - struct netif *ni; - - if (fd != 0) { - errno = EBADF; - return(-1); - } - - io = sockets; - ni = io->io_netif; - if (ni != NULL) { - prom_iclose(ni->devdata); - ni->devdata = NULL; - io->io_netif = NULL; - } - return(0); -} - -/* - * Send a packet. The ether header is already there. - * Return the length sent (or -1 on error). - */ -int -netif_put(desc, pkt, len) - struct iodesc *desc; - void *pkt; - int len; -{ - struct saioreq *si; - struct saif *sif; - char *dmabuf; - int rv, sendlen; - -#ifdef NETIF_DEBUG - if (netif_debug) { - struct ether_header *eh; - - printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", - desc, pkt, len); - eh = pkt; - printf("dst: %s ", ether_sprintf(eh->ether_dhost)); - printf("src: %s ", ether_sprintf(eh->ether_shost)); - printf("type: 0x%x\n", eh->ether_type & 0xFFFF); - } -#endif - - si = desc->io_netif->devdata; - sif = si->si_sif; - sendlen = len; - if (sendlen < 60) { - sendlen = 60; -#ifdef NETIF_DEBUG - printf("netif_put: length padded to %d\n", sendlen); -#endif - } - -#ifdef PARANOID - if (sif == NULL) - panic("netif_put: no saif ptr\n"); -#endif - - dmabuf = dvma_mapin(pkt, sendlen); - rv = sif->sif_xmit(si->si_devdata, dmabuf, sendlen); - dvma_mapout(dmabuf, sendlen); - -#ifdef NETIF_DEBUG - if (netif_debug) - printf("netif_put: xmit returned %d\n", rv); -#endif - if (rv == 0) rv = len; - else rv = -1; - - return rv; -} - -/* - * Receive a packet, including the ether header. - * Return the total length received (or -1 on error). - */ -int -netif_get(desc, pkt, maxlen, timo) - struct iodesc *desc; - void *pkt; - int maxlen; - time_t timo; -{ - struct saioreq *si; - struct saif *sif; - char *dmabuf; - int tick0, tmo_ticks; - int len; - -#ifdef NETIF_DEBUG - if (netif_debug) - printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n", - pkt, maxlen, timo); -#endif - - si = desc->io_netif->devdata; - sif = si->si_sif; - -#ifdef PARANOID - if (sif == NULL) - panic("netif_get: no saif ptr\n"); -#endif - - tmo_ticks = timo * hz; - tick0 = getticks(); - - dmabuf = dvma_mapin(pkt, maxlen); - do len = sif->sif_poll(si->si_devdata, dmabuf); - while ((len == 0) && ((getticks() - tick0) < tmo_ticks)); - dvma_mapout(dmabuf, maxlen); - -#ifdef NETIF_DEBUG - if (netif_debug) - printf("netif_get: received len=%d\n", len); -#endif - - if (len < 12) - return -1; - -#ifdef NETIF_DEBUG - if (netif_debug) { - struct ether_header *eh = pkt; - - printf("dst: %s ", ether_sprintf(eh->ether_dhost)); - printf("src: %s ", ether_sprintf(eh->ether_shost)); - printf("type: 0x%x\n", eh->ether_type & 0xFFFF); - } -#endif - - return len; -} - -static struct idprom sun3_idprom; - -sun3_getether(ea) - u_char *ea; -{ - u_char *src, *dst; - int len, x; - - if (sun3_idprom.idp_format == 0) { - dst = (char*)&sun3_idprom; - src = (char*)IDPROM_BASE; - len = IDPROM_SIZE; - do { - x = get_control_byte(src++); - *dst++ = x; - } while (--len > 0); - } - MACPY(sun3_idprom.idp_etheraddr, ea); -} - diff --git a/sys/arch/mvme88k/stand/libsa/panic.c b/sys/arch/mvme88k/stand/libsa/panic.c deleted file mode 100644 index f7c83a6d8e7..00000000000 --- a/sys/arch/mvme88k/stand/libsa/panic.c +++ /dev/null @@ -1,31 +0,0 @@ - -#include <stdarg.h> -#include "stand.h" - -extern volatile void abort(); -extern int _estack[]; - -__dead void -panic(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - printf(fmt, ap); - printf("\n"); - va_end(ap); - stackdump(0); - abort(); -} - -stackdump(dummy) - int dummy; -{ - int *ip; - - printf("stackdump:\n"); - for (ip = &dummy; ip < _estack; ip += 4) { - printf("%x: %x %x %x %x\n", - (int)ip, ip[0], ip[1], ip[2], ip[3]); - } -} diff --git a/sys/arch/mvme88k/stand/libsa/promboot.c b/sys/arch/mvme88k/stand/libsa/parse_args.c index fc4aea53e82..217894cb89e 100644 --- a/sys/arch/mvme88k/stand/libsa/promboot.c +++ b/sys/arch/mvme88k/stand/libsa/parse_args.c @@ -1,9 +1,8 @@ -/* $Id: promboot.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ +/* $OpenBSD: parse_args.c,v 1.1 1998/08/22 08:08:21 smurph Exp $ */ -/* +/*- * Copyright (c) 1995 Theo de Raadt - * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -14,8 +13,9 @@ * 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 Theo de Raadt - * 4. The name of the Author may not be used to endorse or promote products + * This product includes software developed under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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 @@ -29,65 +29,71 @@ * 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 <sys/param.h> #include <sys/reboot.h> +#include <machine/prom.h> +#include <a.out.h> + #include "stand.h" -#include "promboot.h" +#include "libsa.h" -char prom_bootdev[32]; -char prom_bootfile[32]; -int prom_boothow; -int debug; +#define KERNEL_NAME "bsd" +#define RB_NOSYM 0x400 -void -prom_get_boot_info() -{ - char c, *src, *dst; - extern int devlun, ctrlun; - extern char *oparg, *opargend; +struct flags { + char c; + short bit; +} bf[] = { + { 'a', RB_ASKNAME }, + { 'b', RB_HALT }, + { 'c', RB_CONFIG }, + { 'y', RB_NOSYM }, + { 'd', RB_KDB }, + { 'm', RB_MINIROOT }, + { 'r', RB_DFLTROOT }, + { 's', RB_SINGLE }, +}; -#ifdef DEBUG - printf("prom_get_boot_info\n"); -#endif +int +parse_args(filep, flagp) - /* Get kernel filename */ - src = oparg; - while (src && (*src == ' ' || *src == '\t')) - src++; +char **filep; +int *flagp; - dst = prom_bootfile; - if (src && *src != '-') { - while (src && *src) { - if (*src == ' ' || *src == '\t') - break; - *dst++ = *src++; - } - } - *dst = '\0'; +{ + char *name = KERNEL_NAME, *ptr; + int i, howto = 0; + char c; - /* Get boothowto flags */ - while (src && (*src == ' ' || *src == '\t')) - src++; - if (src && (*src == '-')) { - while (*src) { - switch (*src++) { - case 'a': - prom_boothow |= RB_ASKNAME; - break; - case 's': - prom_boothow |= RB_SINGLE; - break; - case 'd': - prom_boothow |= RB_KDB; - debug = 1; - break; + if (bugargs.arg_start != bugargs.arg_end) { + ptr = bugargs.arg_start; + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (c == '\0') + return (0); + if (c != '-') { + name = ptr; + while ((c = *++ptr) && c != ' ') + ; + if (c) + *ptr++ = 0; + continue; + } + while ((c = *++ptr) && c != ' ') { + if (c == 'q') + return (1); + for (i = 0; i < sizeof(bf)/sizeof(bf[0]); i++) + if (bf[i].c == c) { + howto |= bf[i].bit; + } } } } -#ifdef DEBUG - printf("promboot: device=\"%s\" file=\"%s\" how=0x%x\n", - prom_bootdev, prom_bootfile, prom_boothow); -#endif + *flagp = howto; + *filep = name; + return (0); } diff --git a/sys/arch/mvme88k/stand/libsa/promboot.h b/sys/arch/mvme88k/stand/libsa/promboot.h deleted file mode 100644 index 86b5aace21c..00000000000 --- a/sys/arch/mvme88k/stand/libsa/promboot.h +++ /dev/null @@ -1,5 +0,0 @@ - -extern char prom_bootdev[]; -extern char prom_bootfile[]; -extern int prom_boothow; - diff --git a/sys/arch/mvme88k/stand/libsa/promcons.c b/sys/arch/mvme88k/stand/libsa/promcons.c deleted file mode 100644 index 77ece569969..00000000000 --- a/sys/arch/mvme88k/stand/libsa/promcons.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $Id: promcons.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ - -/* - * Copyright (c) 1996 Nivas Madhur - * Copyright (c) 1995 Theo de Raadt - * 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 Theo de Raadt - * 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 <sys/types.h> - -int -getchar() -{ - char c; - - __asm volatile("or r9, r0, 0\n - tb0 0, r0, 496\n - st.b r2, %0" : "=m" (c)); - return (c); -} - -peekchar() -{ - int have = 0; - - __asm volatile("or r9, r0, 1\n - tb0 0, r0, 496\n - bb1 2, r2, 1f\n - or r2,r0, 1\n - st r2, %0\n1:" : "=m" (have) :); - return (have); -} - -void -putchar(c) - int c; -{ - if (c == '\n') - putchar('\r'); - __asm volatile("or r9, r0, 0x20\n - or r2, r0, %0\n - tb0 0, r0, 496\n" : : "r" (c)); -} - diff --git a/sys/arch/mvme88k/stand/libsa/promdev.c b/sys/arch/mvme88k/stand/libsa/promdev.c deleted file mode 100644 index 7ba01390c31..00000000000 --- a/sys/arch/mvme88k/stand/libsa/promdev.c +++ /dev/null @@ -1,193 +0,0 @@ -/* $Id: promdev.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ - -/* - * Copyright (c) 1995 Gordon W. Ross - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS 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 <sys/param.h> -#include <machine/mon.h> -#include <machine/pte.h> -#include <machine/saio.h> - -#include <dvma.h> -#include <stand.h> - -struct saioreq prom_si; -static int promdev_inuse; - -static char * -prom_mapin(u_long physaddr, int length, int maptype); - -int -prom_iopen(void **devdatap) -{ - struct bootparam *bp; - struct boottab *ops; - struct devinfo *dip; - struct saioreq *si; - char *p; - int error; - - if (promdev_inuse) - return(EMFILE); - - bp = *romp->bootParam; - ops = bp->bootDevice; - dip = ops->b_devinfo; - -#ifdef DEBUG_PROM - printf("Boot device type: %s\n", ops->b_desc); -#endif - - dvma_init(); - - si = &prom_si; - bzero((caddr_t)si, sizeof(*si)); - si->si_boottab = ops; - si->si_ctlr = bp->ctlrNum; - si->si_unit = bp->unitNum; - si->si_boff = bp->partNum; - - if (si->si_ctlr > dip->d_stdcount) { - printf("Invalid controller number\n"); - return(ENXIO); - } - - if (dip->d_devbytes) { - si->si_devaddr = prom_mapin(dip->d_stdaddrs[si->si_ctlr], - dip->d_devbytes, dip->d_devtype); -#ifdef DEBUG_PROM - printf("prom_iopen: devaddr=0x%x pte=0x%x\n", - si->si_devaddr, get_pte(si->si_devaddr)); -#endif - } - - if (dip->d_dmabytes) { - si->si_dmaaddr = dvma_alloc(dip->d_dmabytes); -#ifdef DEBUG_PROM - printf("prom_iopen: dmaaddr=0x%x\n", si->si_dmaaddr); -#endif - } - - /* OK, call the PROM device open routine. */ - error = (*ops->b_open)(si); - if (error != 0) { - printf("prom_iopen: \"%s\" error=%d\n", - ops->b_desc, error); - return (ENXIO); - } -#ifdef DEBUG_PROM - printf("prom_iopen: succeeded, error=%d\n", error); -#endif - - *devdatap = si; - promdev_inuse++; - return (0); -} - -void -prom_iclose(void *devdata) -{ - struct boottab *ops; - struct devinfo *dip; - struct saioreq *si; - - if (promdev_inuse == 0) - return; - - si = devdata; - ops = si->si_boottab; - dip = ops->b_devinfo; - - (*ops->b_close)(si); - - if (si->si_dmaaddr) { - dvma_free(si->si_dmaaddr, dip->d_dmabytes); - si->si_dmaaddr = NULL; - } - - promdev_inuse = 0; -} - -struct mapinfo { - int maptype; - int pgtype; - int base; -}; - -static struct mapinfo -prom_mapinfo[] = { - { MAP_MAINMEM, PGT_OBMEM, 0 }, - { MAP_OBIO, PGT_OBIO, 0 }, - { MAP_MBMEM, PGT_OBMEM, 0 }, /* XXX - Sun2 Multibus? */ - { MAP_MBIO, PGT_OBIO, 0 }, /* XXX - Sun2 Multibus? */ - { MAP_VME16A16D, PGT_VME_D16, 0xFFFF0000 }, - { MAP_VME16A32D, PGT_VME_D32, 0xFFFF0000 }, - { MAP_VME24A16D, PGT_VME_D16, 0xFF000000 }, - { MAP_VME24A32D, PGT_VME_D32, 0xFF000000 }, - { MAP_VME32A16D, PGT_VME_D16, 0 }, - { MAP_VME32A32D, PGT_VME_D32, 0 }, -}; -static prom_mapinfo_cnt = sizeof(prom_mapinfo) / sizeof(prom_mapinfo[0]); - -/* The virtual address we will use for PROM device mappings. */ -static int prom_devmap = MONSHORTSEG; - -static char * -prom_mapin(physaddr, length, maptype) - u_long physaddr; - int length, maptype; -{ - int i, pa, pte, va; - - if (length > (4*NBPG)) - panic("prom_mapin: length=%d\n", length); - - for (i = 0; i < prom_mapinfo_cnt; i++) - if (prom_mapinfo[i].maptype == maptype) - goto found; - panic("prom_mapin: invalid maptype %d\n", maptype); -found: - - pte = prom_mapinfo[i].pgtype; - pte |= PG_PERM; - pa = prom_mapinfo[i].base; - pa += physaddr; - pte |= PA_PGNUM(pa); - - va = prom_devmap; - do { - set_pte(va, pte); - va += NBPG; - pte += 1; - length -= NBPG; - } while (length > 0); - return ((char*)prom_devmap); -} diff --git a/sys/arch/mvme88k/stand/libsa/promdev.h b/sys/arch/mvme88k/stand/libsa/promdev.h deleted file mode 100644 index e3ae5ba2d7c..00000000000 --- a/sys/arch/mvme88k/stand/libsa/promdev.h +++ /dev/null @@ -1,4 +0,0 @@ - -int prom_iopen(struct saioreq **sipp); -void prom_iclose(struct saioreq *sip); - |