diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-09-17 10:46:26 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-09-17 10:46:26 +0000 |
commit | 6476cf829b28337c9b81bab966bbc4a4abe37982 (patch) | |
tree | 4c6323f69275a5aaa2d1e0a467f4f907e2f47314 /sys/arch/sparc/stand/common | |
parent | 3e5a5259f8fb1b6393dd2cf83fb2c3eeda0ea959 (diff) |
Reorganizaed bootblocks. Builds like hp300 now.
Diffstat (limited to 'sys/arch/sparc/stand/common')
-rw-r--r-- | sys/arch/sparc/stand/common/conf.c | 53 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/dvma.c | 121 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/net.c | 159 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/netif_sun.c | 220 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/promdev.c | 805 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/promdev.h | 85 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/srt0.S | 198 | ||||
-rw-r--r-- | sys/arch/sparc/stand/common/version.c | 45 |
8 files changed, 1686 insertions, 0 deletions
diff --git a/sys/arch/sparc/stand/common/conf.c b/sys/arch/sparc/stand/common/conf.c new file mode 100644 index 00000000000..265a005f850 --- /dev/null +++ b/sys/arch/sparc/stand/common/conf.c @@ -0,0 +1,53 @@ +/* $OpenBSD: conf.c,v 1.1 1997/09/17 10:46:17 downsj Exp $ */ +/* $NetBSD: conf.c,v 1.2 1995/09/18 21:31:45 pk Exp $ */ + +/* + * Copyright (c) 1993 Philip A. Nelson. + * 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 Philip A. Nelson. + * 4. The name of Philip A. Nelson may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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 <lib/libsa/stand.h> +#include <lib/libsa/ufs.h> +#include <netinet/in.h> +#include <lib/libsa/cd9660.h> +#include <lib/libsa/nfs.h> + +struct fs_ops file_system_ufs[] = { + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, +}; +struct fs_ops file_system_cd9660[] = { + { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, + cd9660_stat }, +}; +struct fs_ops file_system_nfs[] = { + { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, +}; +struct fs_ops file_system[2]; +int nfsys = 1; + diff --git a/sys/arch/sparc/stand/common/dvma.c b/sys/arch/sparc/stand/common/dvma.c new file mode 100644 index 00000000000..7e6351baf88 --- /dev/null +++ b/sys/arch/sparc/stand/common/dvma.c @@ -0,0 +1,121 @@ +/* $OpenBSD: dvma.c,v 1.1 1997/09/17 10:46:18 downsj Exp $ */ +/* $NetBSD: dvma.c,v 1.2 1995/09/17 00:50:56 pk 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 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 easiest way to deal with the need for DVMA mappings is + * to just map the entire third megabyte of RAM into DVMA space. + * That way, dvma_mapin can just compute the DVMA alias address, + * and dvma_mapout does nothing. Note that this assumes all + * standalone programs stay in the range SA_MIN_VA .. SA_MAX_VA + */ + +#include <sys/param.h> +#include <machine/pte.h> +#include <machine/ctlreg.h> + +#include <sparc/stand/common/promdev.h> + +#define DVMA_BASE 0xFFF00000 +#define DVMA_MAPLEN 0xE0000 /* 1 MB - 128K (save MONSHORTSEG) */ + +#define SA_MIN_VA (RELOC - 0x40000) /* XXX - magic constant */ +#define SA_MAX_VA (SA_MIN_VA + DVMA_MAPLEN) + +void +dvma_init() +{ + register int segva, dmava; + + dmava = DVMA_BASE; + for (segva = SA_MIN_VA; segva < SA_MAX_VA; segva += NBPSG) { + setsegmap(dmava, getsegmap(segva)); + dmava += NBPSG; + } +} + +/* + * Convert a local address to a DVMA address. + */ +char * +dvma_mapin(char *addr, size_t len) +{ + register int va = (int)addr; + + /* Make sure the address is in the DVMA map. */ + if ((va < SA_MIN_VA) || (va >= SA_MAX_VA)) + panic("dvma_mapin"); + + va += DVMA_BASE - SA_MIN_VA; + + return ((char *)va); +} + +/* + * Convert a DVMA address to a local address. + */ +char * +dvma_mapout(char *addr, size_t len) +{ + int va = (int)addr; + + /* Make sure the address is in the DVMA map. */ + if ((va < DVMA_BASE) || (va >= (DVMA_BASE + DVMA_MAPLEN))) + panic("dvma_mapout"); + + va -= DVMA_BASE - SA_MIN_VA; + + return ((char *)va); +} + +extern char *alloc __P((int)); + +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/sparc/stand/common/net.c b/sys/arch/sparc/stand/common/net.c new file mode 100644 index 00000000000..0c42a5cd596 --- /dev/null +++ b/sys/arch/sparc/stand/common/net.c @@ -0,0 +1,159 @@ +/* $OpenBSD: net.c,v 1.1 1997/09/17 10:46:18 downsj Exp $ */ +/* $NetBSD: net.c,v 1.2 1997/07/22 17:41:07 drochner 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include <sys/param.h> +#include <sys/socket.h> +#include <net/if.h> +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#include <lib/libsa/stand.h> +#include <lib/libsa/net.h> +#include <lib/libsa/netif.h> +#include <lib/libsa/bootparam.h> + +char rootpath[FNAME_SIZE]; + +int netdev_sock = -1; +static int open_count; + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + */ +int +net_open(pd) + struct promdata *pd; +{ + int error = 0; + + /* On first open, do netif open, mount, etc. */ + if (open_count == 0) { + /* Find network interface. */ + if ((netdev_sock = netif_open(pd)) < 0) { + error = errno; + goto bad; + } + if ((error = net_mountroot()) != 0) + goto bad; + } + open_count++; +bad: + return (error); +} + +int +net_close(pd) + struct promdata *pd; +{ + /* On last close, do netif close, etc. */ + if (open_count > 0) + if (--open_count == 0) + netif_close(netdev_sock); +} + +int +net_mountroot() +{ + +#ifdef DEBUG + printf("net_mountroot\n"); +#endif + + /* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + */ + +#ifdef SUN_BOOTPARAMS + /* Get boot info using RARP and Sun bootparams. */ + + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(netdev_sock) == -1) + return errno; + + printf("boot: client IP address: %s\n", inet_ntoa(myip)); + + /* Get our hostname, server IP address. */ + if (bp_whoami(netdev_sock)) + return (errno); + + printf("boot: client name: %s\n", hostname); + + /* Get the root pathname. */ + if (bp_getfile(netdev_sock, "root", &rootip, rootpath)) + return (errno); + +#else + + /* Get boot info using BOOTP way. (RFC951, RFC1048) */ + bootp(netdev_sock); + + printf("Using IP address: %s\n", inet_ntoa(myip)); + + printf("myip: %s (%s)", hostname, inet_ntoa(myip)); + if (gateip) + printf(", gateip: %s", inet_ntoa(gateip)); + if (netmask) + printf(", netmask: %s", intoa(netmask)); + printf("\n"); + +#endif + + printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath); + + /* Get the NFS file handle (mount). */ + if (nfs_mount(netdev_sock, rootip, rootpath) != 0) + return (errno); + return 0; +} diff --git a/sys/arch/sparc/stand/common/netif_sun.c b/sys/arch/sparc/stand/common/netif_sun.c new file mode 100644 index 00000000000..07efcdceea1 --- /dev/null +++ b/sys/arch/sparc/stand/common/netif_sun.c @@ -0,0 +1,220 @@ +/* $OpenBSD: netif_sun.c,v 1.1 1997/09/17 10:46:18 downsj Exp $ */ +/* $NetBSD: netif_sun.c,v 1.2 1995/09/18 21:31:48 pk 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 <lib/libsa/stand.h> +#include <lib/libsa/net.h> +#include <lib/libsa/netif.h> + +#include <sparc/stand/common/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 promdata *pd = machdep_hint; + 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 + errno = ENFILE; + return (-1); + } + bzero(io, sizeof(*io)); + + netif_prom.nif_devdata = pd; + io->io_netif = &netif_prom; + + /* Put our ethernet address in io->myea */ + prom_getether(pd->fd, 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[fd]; + ni = io->io_netif; + if (ni != NULL) { + ni->nif_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). + */ +ssize_t +netif_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + size_t len; +{ + struct promdata *pd; + ssize_t rv; + size_t sendlen; + + pd = (struct promdata *)desc->io_netif->nif_devdata; + +#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 + + sendlen = len; + if (sendlen < 60) { + sendlen = 60; +#ifdef NETIF_DEBUG + printf("netif_put: length padded to %d\n", sendlen); +#endif + } + + rv = (*pd->xmit)(pd, pkt, sendlen); + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_put: xmit returned %d\n", rv); +#endif + + return rv; +} + +/* + * Receive a packet, including the ether header. + * Return the total length received (or -1 on error). + */ +ssize_t +netif_get(desc, pkt, maxlen, timo) + struct iodesc *desc; + void *pkt; + size_t maxlen; + time_t timo; +{ + struct promdata *pd; + int tick0, tmo_ticks; + ssize_t len; + + pd = (struct promdata *)desc->io_netif->nif_devdata; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n", + pkt, maxlen, timo); +#endif + + tmo_ticks = timo * hz; + tick0 = getticks(); + + do { + len = (*pd->recv)(pd, pkt, maxlen); + } while ((len == 0) && ((getticks() - tick0) < tmo_ticks)); + +#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; +} diff --git a/sys/arch/sparc/stand/common/promdev.c b/sys/arch/sparc/stand/common/promdev.c new file mode 100644 index 00000000000..25057863046 --- /dev/null +++ b/sys/arch/sparc/stand/common/promdev.c @@ -0,0 +1,805 @@ +/* $OpenBSD: promdev.c,v 1.1 1997/09/17 10:46:19 downsj Exp $ */ +/* $NetBSD: promdev.c,v 1.16 1995/11/14 15:04:01 pk Exp $ */ + +/* + * Copyright (c) 1993 Paul Kranenburg + * 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. 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. + */ + +/* + * Note: the `#ifndef BOOTXX' in here serve to queeze the code size + * of the 1st-stage boot program. + */ +#include <sys/param.h> +#include <sys/reboot.h> +#include <machine/idprom.h> +#include <machine/oldmon.h> +#include <machine/ctlreg.h> + +#include <lib/libsa/stand.h> + +#include <sparc/stand/common/promdev.h> + +/* u_long _randseed = 1; */ + + +int obp_close __P((struct open_file *)); +int obp_strategy __P((void *, int, daddr_t, size_t, void *, size_t *)); +ssize_t obp_xmit __P((struct promdata *, void *, size_t)); +ssize_t obp_recv __P((struct promdata *, void *, size_t)); +int prom0_close __P((struct open_file *)); +int prom0_strategy __P((void *, int, daddr_t, size_t, void *, size_t *)); +void prom0_iclose __P((struct saioreq *)); +int prom0_iopen __P((struct promdata *)); +ssize_t prom0_xmit __P((struct promdata *, void *, size_t)); +ssize_t prom0_recv __P((struct promdata *, void *, size_t)); + +static char *prom_mapin __P((u_long, int, int)); + +int getdevtype __P((int, char *)); +int getprop __P((int, char *, void *, int)); +char *getpropstring __P((int, char *)); + +static void prom0_fake __P((void)); + +extern struct filesystem file_system_nfs[]; +extern struct filesystem file_system_cd9660[]; +extern struct filesystem file_system_ufs[]; + +int prom_open __P((struct open_file *f, ...)) { return 0; } +int prom_ioctl __P((struct open_file *f, u_long c, void *d)) { return EIO; } + +struct devsw devsw[] = { + { "prom0", prom0_strategy, prom_open, prom0_close, prom_ioctl }, + { "prom", obp_strategy, prom_open, obp_close, prom_ioctl } +}; + +int ndevs = (sizeof(devsw)/sizeof(devsw[0])); + +char *prom_bootdevice; +char *prom_bootfile; +int prom_boothow; + +struct promvec *promvec; +static int saveecho; + +void +prom_init() +{ + register char *ap, *cp, *dp; + + if (cputyp == CPU_SUN4) + prom0_fake(); + + if (promvec->pv_romvec_vers >= 2) { + static char filestore[16]; + + prom_bootdevice = *promvec->pv_v2bootargs.v2_bootpath; + +#ifndef BOOTXX + cp = *promvec->pv_v2bootargs.v2_bootargs; + dp = prom_bootfile = filestore; + while (*cp && *cp != '-') + *dp++ = *cp++; + while (dp > prom_bootfile && *--dp == ' '); + *++dp = '\0'; + ap = cp; +#endif + } else { + static char bootstore[16]; + dp = prom_bootdevice = bootstore; + cp = (*promvec->pv_v0bootargs)->ba_argv[0]; + while (*cp) { + *dp++ = *cp; + if (*cp++ == ')') + break; + } + *dp = '\0'; +#ifndef BOOTXX + prom_bootfile = (*promvec->pv_v0bootargs)->ba_kernel; + ap = (*promvec->pv_v0bootargs)->ba_argv[1]; +#endif + } + +#ifndef BOOTXX + if (ap == NULL || *ap != '-') + return; + + while (*ap) { + switch (*ap++) { + case 'a': + prom_boothow |= RB_ASKNAME; + break; + case 's': + prom_boothow |= RB_SINGLE; + break; + case 'd': + prom_boothow |= RB_KDB; + debug = 1; + break; + } + } +#endif +} + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + int error = 0, fd; + struct promdata *pd; + + pd = (struct promdata *)alloc(sizeof *pd); + + if (cputyp == CPU_SUN4) { + error = prom0_iopen(pd); +#ifndef BOOTXX + pd->xmit = prom0_xmit; + pd->recv = prom0_recv; +#endif + } else { + fd = (promvec->pv_romvec_vers >= 2) + ? (*promvec->pv_v2devops.v2_open)(prom_bootdevice) + : (*promvec->pv_v0devops.v0_open)(prom_bootdevice); + if (fd == 0) { + error = ENXIO; + } else { + pd->fd = fd; +#ifndef BOOTXX + pd->xmit = obp_xmit; + pd->recv = obp_recv; +#endif + } + } + + if (error) { + printf("Can't open device `%s'\n", prom_bootdevice); + return (error); + } + +#ifdef BOOTXX + pd->devtype = DT_BLOCK; +#else /* BOOTXX */ + pd->devtype = getdevtype(fd, prom_bootdevice); + /* Assume type BYTE is a raw device */ + if (pd->devtype != DT_BYTE) + *file = (char *)fname; + + if (pd->devtype == DT_NET) { + bcopy(file_system_nfs, file_system, sizeof(struct fs_ops)); + if ((error = net_open(pd)) != 0) { + printf("Can't open network device `%s'\n", + prom_bootdevice); + return error; + } + } else { + bcopy(file_system_ufs, file_system, sizeof(struct fs_ops)); + bcopy(&file_system_cd9660, file_system + 1, sizeof file_system[0]); + nfsys = 2; + } +#endif /* BOOTXX */ + + f->f_dev = &devsw[cputyp == CPU_SUN4 ? 0 : 1]; + f->f_devdata = (void *)pd; + return 0; +} + +int +obp_strategy(devdata, flag, dblk, size, buf, rsize) + void *devdata; + int flag; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + int error = 0; + struct promdata *pd = (struct promdata *)devdata; + int fd = pd->fd; + +#ifdef DEBUG_PROM + printf("promstrategy: size=%d dblk=%d\n", size, dblk); +#endif + + if (promvec->pv_romvec_vers >= 2) { + if (pd->devtype == DT_BLOCK) + (*promvec->pv_v2devops.v2_seek)(fd, 0, dbtob(dblk)); + + *rsize = (*((flag == F_READ) + ? (u_int (*)())promvec->pv_v2devops.v2_read + : (u_int (*)())promvec->pv_v2devops.v2_write + ))(fd, buf, size); + } else { + int n = (*((flag == F_READ) + ? (u_int (*)())promvec->pv_v0devops.v0_rbdev + : (u_int (*)())promvec->pv_v0devops.v0_wbdev + ))(fd, btodb(size), dblk, buf); + *rsize = dbtob(n); + } + +#ifdef DEBUG_PROM + printf("rsize = %x\n", *rsize); +#endif + return error; +} + +/* + * On old-monitor machines, things work differently. + */ +int +prom0_strategy(devdata, flag, dblk, size, buf, rsize) + void *devdata; + int flag; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + struct promdata *pd = devdata; + struct saioreq *si; + struct om_boottable *ops; + char *dmabuf; + int si_flag; + size_t xcnt; + + si = pd->si; + ops = si->si_boottab; + +#ifdef DEBUG_PROM + printf("prom_strategy: size=%d dblk=%d\n", size, dblk); +#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 +obp_close(f) + struct open_file *f; +{ + struct promdata *pd = f->f_devdata; + register int fd = pd->fd; + +#ifndef BOOTXX + if (pd->devtype == DT_NET) + net_close(pd); +#endif + if (promvec->pv_romvec_vers >= 2) + (void)(*promvec->pv_v2devops.v2_close)(fd); + else + (void)(*promvec->pv_v0devops.v0_close)(fd); + return 0; +} + +int +prom0_close(f) + struct open_file *f; +{ + struct promdata *pd = f->f_devdata; + +#ifndef BOOTXX + if (pd->devtype == DT_NET) + net_close(pd); +#endif + prom0_iclose(pd->si); + pd->si = NULL; + *romp->echo = saveecho; /* Hmm, probably must go somewhere else */ + return 0; +} + +#ifndef BOOTXX +ssize_t +obp_xmit(pd, buf, len) + struct promdata *pd; + void *buf; + size_t len; +{ + return (promvec->pv_romvec_vers >= 2 + ? (*promvec->pv_v2devops.v2_write)(pd->fd, buf, len) + : (*promvec->pv_v0devops.v0_wnet)(pd->fd, len, buf)); +} + +ssize_t +obp_recv(pd, buf, len) + struct promdata *pd; + void *buf; + size_t len; +{ + int n; + + n = (promvec->pv_romvec_vers >= 2 + ? (*promvec->pv_v2devops.v2_read)(pd->fd, buf, len) + : (*promvec->pv_v0devops.v0_rnet)(pd->fd, len, buf)); + return (n == -2 ? 0 : n); +} + +ssize_t +prom0_xmit(pd, buf, len) + struct promdata *pd; + void *buf; + size_t len; +{ + struct saioreq *si; + struct saif *sif; + char *dmabuf; + int rv; + + si = pd->si; + sif = si->si_sif; + if (sif == NULL) { + printf("xmit: not a network device\n"); + return (-1); + } + dmabuf = dvma_mapin(buf, len); + rv = sif->sif_xmit(si->si_devdata, dmabuf, len); + dvma_mapout(dmabuf, len); + + return (ssize_t)(rv ? -1 : len); +} + +ssize_t +prom0_recv(pd, buf, len) + struct promdata *pd; + void *buf; + size_t len; +{ + struct saioreq *si; + struct saif *sif; + char *dmabuf; + int rv; + + si = pd->si; + sif = si->si_sif; + dmabuf = dvma_mapin(buf, len); + rv = sif->sif_poll(si->si_devdata, dmabuf); + dvma_mapout(dmabuf, len); + + return (ssize_t)rv; +} + +int +getchar() +{ + char c; + register int n; + + if (promvec->pv_romvec_vers > 2) + while ((n = (*promvec->pv_v2devops.v2_read) + (*promvec->pv_v2bootargs.v2_fd0, (caddr_t)&c, 1)) != 1); + else + c = (*promvec->pv_getchar)(); + + if (c == '\r') + c = '\n'; + return (c); +} + +int +cngetc() +{ + return getchar(); +} + +int +peekchar() +{ + char c; + register int n; + + if (promvec->pv_romvec_vers > 2) { + n = (*promvec->pv_v2devops.v2_read) + (*promvec->pv_v2bootargs.v2_fd0, (caddr_t)&c, 1); + if (n < 0) + return -1; + } else + c = (*promvec->pv_nbgetchar)(); + + if (c == '\r') + c = '\n'; + return (c); +} +#endif + +static void +pv_putchar(c) + int c; +{ + char c0 = c; + + if (promvec->pv_romvec_vers > 2) + (*promvec->pv_v2devops.v2_write) + (*promvec->pv_v2bootargs.v2_fd1, &c0, 1); + else + (*promvec->pv_putchar)(c); +} + +void +putchar(c) + int c; +{ + + if (c == '\n') + pv_putchar('\r'); + pv_putchar(c); +} + +void +_rtt() +{ + promvec->pv_halt(); +} + +#ifndef BOOTXX +int hz = 1000; + +time_t +getsecs() +{ + register int ticks = getticks(); + return ((time_t)(ticks / hz)); +} + +int +getticks() +{ + if (promvec->pv_romvec_vers >= 2) { + char c; + (void)(*promvec->pv_v2devops.v2_read) + (*promvec->pv_v2bootargs.v2_fd0, (caddr_t)&c, 0); + } else { + (void)(*promvec->pv_nbgetchar)(); + } + return *(promvec->pv_ticks); +} + +void +prom_getether(fd, ea) + u_char *ea; +{ + if (cputyp == CPU_SUN4) { + static struct idprom sun4_idprom; + u_char *src, *dst; + int len, x; + + if (sun4_idprom.id_format == 0) { + dst = (char*)&sun4_idprom; + src = (char*)AC_IDPROM; + len = sizeof(struct idprom); + do { + x = lduba(src++, ASI_CONTROL); + *dst++ = x; + } while (--len > 0); + } + bcopy(sun4_idprom.id_ether, ea, 6); + } else if (promvec->pv_romvec_vers <= 2) { + (void)(*promvec->pv_enaddr)(fd, (char *)ea); + } else { + char buf[64]; + sprintf(buf, "%x mac-address drop swap 6 cmove", ea); + promvec->pv_fortheval.v2_eval(buf); + } +} + + +/* + * A number of well-known devices on sun4s. + */ +static struct dtab { + char *name; + int type; +} dtab[] = { + { "sd", DT_BLOCK }, + { "st", DT_BLOCK }, + { "xd", DT_BLOCK }, + { "xy", DT_BLOCK }, + { "fd", DT_BLOCK }, + { "le", DT_NET }, + { "ie", DT_NET }, + { NULL, 0 } +}; + +int +getdevtype(fd, name) + int fd; + char *name; +{ + if (promvec->pv_romvec_vers >= 2) { + int node = (*promvec->pv_v2devops.v2_fd_phandle)(fd); + char *cp = getpropstring(node, "device_type"); + if (strcmp(cp, "block") == 0) + return DT_BLOCK; + else if (strcmp(cp, "network") == 0) + return DT_NET; + else if (strcmp(cp, "byte") == 0) + return DT_BYTE; + } else { + struct dtab *dp; + for (dp = dtab; dp->name; dp++) { + if (name[0] == dp->name[0] && + name[1] == dp->name[1]) + return dp->type; + } + } + return 0; +} + +/* + * OpenPROM nodes & property routines (from <sparc/autoconf.c>). + */ +int +getprop(node, name, buf, bufsiz) + int node; + char *name; + void *buf; + register int bufsiz; +{ + register struct nodeops *no; + register int len; + + no = promvec->pv_nodeops; + len = no->no_proplen(node, name); + if (len > bufsiz) { + printf("node %x property %s length %d > %d\n", + node, name, len, bufsiz); + return (0); + } + no->no_getprop(node, name, buf); + return (len); +} + +/* + * Return a string property. There is a (small) limit on the length; + * the string is fetched into a static buffer which is overwritten on + * subsequent calls. + */ +char * +getpropstring(node, name) + int node; + char *name; +{ + register int len; + static char stringbuf[64]; + + len = getprop(node, name, (void *)stringbuf, sizeof stringbuf - 1); + if (len == -1) + len = 0; + stringbuf[len] = '\0'; /* usually unnecessary */ + return (stringbuf); +} +#endif /* BOOTXX */ + +/* + * Old monitor routines + */ + +#include <machine/pte.h> + +struct saioreq prom_si; +static int promdev_inuse; + +int +prom0_iopen(pd) + struct promdata *pd; +{ + struct om_bootparam *bp; + struct om_boottable *ops; + struct devinfo *dip; + struct saioreq *si; + int error; + + if (promdev_inuse) + return(EMFILE); + + bp = *romp->bootParam; + ops = bp->bootTable; + dip = ops->b_devinfo; + +#ifdef DEBUG_PROM + printf("Boot device type: %s\n", ops->b_desc); + printf("d_devbytes=%d\n", dip->d_devbytes); + printf("d_dmabytes=%d\n", dip->d_dmabytes); + printf("d_localbytes=%d\n", dip->d_localbytes); + printf("d_stdcount=%d\n", dip->d_stdcount); + printf("d_stdaddrs[%d]=%x\n", bp->ctlrNum, dip->d_stdaddrs[bp->ctlrNum]); + printf("d_devtype=%d\n", dip->d_devtype); + printf("d_maxiobytes=%d\n", dip->d_maxiobytes); +#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, + getpte((u_long)si->si_devaddr & ~PGOFSET)); +#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 + } + + if (dip->d_localbytes) { + si->si_devdata = alloc(dip->d_localbytes); +#ifdef DEBUG_PROM + printf("prom_iopen: devdata=0x%x\n", si->si_devdata); +#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 + + pd->si = si; + promdev_inuse++; + return (0); +} + +void +prom0_iclose(si) + struct saioreq *si; +{ + struct om_boottable *ops; + struct devinfo *dip; + + if (promdev_inuse == 0) + return; + + 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; +} + +static struct mapinfo { + int maptype; + int pgtype; + int base; +} prom_mapinfo[] = { + { MAP_MAINMEM, PG_OBMEM, 0 }, + { MAP_OBIO, PG_OBIO, 0 }, + { MAP_MBMEM, PG_VME16, 0xFF000000 }, + { MAP_MBIO, PG_VME16, 0xFFFF0000 }, + { MAP_VME16A16D, PG_VME16, 0xFFFF0000 }, + { MAP_VME16A32D, PG_VME32, 0xFFFF0000 }, + { MAP_VME24A16D, PG_VME16, 0xFF000000 }, + { MAP_VME24A32D, PG_VME32, 0xFF000000 }, + { MAP_VME32A16D, PG_VME16, 0 }, + { MAP_VME32A32D, PG_VME32, 0 }, +}; +static prom_mapinfo_cnt = sizeof(prom_mapinfo) / sizeof(prom_mapinfo[0]); + +/* The virtual address we will use for PROM device mappings. */ +static u_long 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_V|PG_W|PG_S|PG_NC); + pa = prom_mapinfo[i].base; + pa += physaddr; + pte |= ((pa >> PGSHIFT) & PG_PFNUM); + + va = prom_devmap; + do { + setpte(va, pte); + va += NBPG; + pte += 1; + length -= NBPG; + } while (length > 0); + return ((char*)(prom_devmap | (pa & PGOFSET))); +} + +void +prom0_fake() +{ +static struct promvec promvecstore; + + promvec = &promvecstore; + + promvec->pv_stdin = romp->inSource; + promvec->pv_stdout = romp->outSink; + promvec->pv_putchar = romp->putChar; + promvec->pv_putstr = romp->fbWriteStr; + promvec->pv_nbgetchar = romp->mayGet; + promvec->pv_getchar = romp->getChar; + promvec->pv_romvec_vers = 0; /* eek! */ + promvec->pv_reboot = romp->reBoot; + promvec->pv_abort = romp->abortEntry; + promvec->pv_setctxt = romp->setcxsegmap; + promvec->pv_v0bootargs = (struct v0bootargs **)(romp->bootParam); + promvec->pv_halt = romp->exitToMon; + promvec->pv_ticks = romp->nmiClock; + saveecho = *romp->echo; + *romp->echo = 0; +} diff --git a/sys/arch/sparc/stand/common/promdev.h b/sys/arch/sparc/stand/common/promdev.h new file mode 100644 index 00000000000..8413cde7d18 --- /dev/null +++ b/sys/arch/sparc/stand/common/promdev.h @@ -0,0 +1,85 @@ +/* $OpenBSD: promdev.h,v 1.1 1997/09/17 10:46:19 downsj Exp $ */ +/* $NetBSD: promdev.h,v 1.3 1995/09/18 21:31:50 pk 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 <machine/bsd_openprom.h> + +struct promdata { + int fd; /* Openboot descriptor */ + struct saioreq *si; /* Oldmon IO request */ + int devtype; /* Kind of device we're booting from */ +#define DT_BLOCK 1 +#define DT_NET 2 +#define DT_BYTE 3 + /* Hooks for netif.c */ + int (*xmit) __P((struct promdata *, void *, size_t)); + int (*recv) __P((struct promdata *, void *, size_t)); +}; + +#define LOADADDR ((caddr_t)0x4000) +#define DDB_MAGIC0 ( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('0') ) +#define DDB_MAGIC1 ( ('D'<<24) | ('D'<<16) | ('B'<<8) | ('1') ) +#define DDB_MAGIC DDB_MAGIC0 + +extern struct promvec *promvec; +extern char *prom_bootdevice; +extern char *prom_bootfile; +extern int prom_boothow; +extern int hz; +extern int cputyp, nbpg, pgofset, pgshift; +extern int debug; + +extern void prom_init __P((void)); + +/* Note: dvma_*() routines are for "oldmon" machines only */ +extern char *dvma_mapin __P((char *, size_t)); +extern char *dvma_mapout __P((char *, size_t)); +extern char *dvma_alloc __P((int)); + +/* + * duplicates from pmap.c for mapping device on "oldmon" machines. + */ +#include <sparc/sparc/asm.h> + +#define getcontext() lduba(AC_CONTEXT, ASI_CONTROL) +#define setcontext(c) stba(AC_CONTEXT, ASI_CONTROL, c) +#define getsegmap(va) (cputyp == CPU_SUN4C \ + ? lduba(va, ASI_SEGMAP) \ + : lduha(va, ASI_SEGMAP)) +#define setsegmap(va, pmeg) (cputyp == CPU_SUN4C \ + ? stba(va, ASI_SEGMAP, pmeg) \ + : stha(va, ASI_SEGMAP, pmeg)) +#define getregmap(va) ((unsigned)lduha(va+2, ASI_REGMAP) >> 8) +#define setregmap(va, smeg) stha(va+2, ASI_REGMAP, (smeg << 8)) + +#define getpte(va) lda(va, ASI_PTE) +#define setpte(va, pte) sta(va, ASI_PTE, pte) diff --git a/sys/arch/sparc/stand/common/srt0.S b/sys/arch/sparc/stand/common/srt0.S new file mode 100644 index 00000000000..bd0a039efe1 --- /dev/null +++ b/sys/arch/sparc/stand/common/srt0.S @@ -0,0 +1,198 @@ +/* $OpenBSD: srt0.S,v 1.1 1997/09/17 10:46:20 downsj Exp $ */ +/* $NetBSD: srt0.S,v 1.5.4.2 1996/07/17 01:51:46 jtc Exp $ */ + +/* + * Copyright (c) 1994 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 <machine/param.h> +#include <machine/psl.h> + +#define CCFSZ 96 + + .file "str0.s" + + .data + .global _cputyp, _nbpg, _pgofset, _pgshift +_cputyp: + .word 1 +_nbpg: + .word 1 +_pgofset: + .word 1 +_pgshift: + .word 1 + + .text + .globl start + +start: + /* + * Set up a stack. + */ + set start, %o1 + save %o1, -CCFSZ, %sp + + /* + * Relocate. + */ +1: call 2f + nop +2: add %o7, (start-1b), %l0 + set start, %l1 + set _end, %o0 + sub %o0, %l1, %l2 ! length +3: ld [%l0], %o0 + add %l0, 4, %l0 + st %o0, [%l1] + subcc %l2, 4, %l2 + bg 3b + add %l1, 4, %l1 + + set 4f, %g1 + jmp %g1 + nop + +4: +#ifdef notyet + /* + * Enable traps + */ + wr %g0, 0, %wim ! make sure we can set psr + nop; nop; nop + wr %g0, PSR_S|PSR_PS|PSR_PIL, %psr ! set initial psr + nop; nop; nop + wr %g0, 2, %wim ! set initial %wim (w1 invalid) + + rd %psr, %l0 + wr %l0, PSR_ET, %psr + nop; nop; nop +#endif + + /* + * Clear BSS + */ + set _edata, %o0 ! bzero(edata, end - edata) + set _end, %o1 + call _bzero + sub %o1, %o0, %o1 + + /* + * Enable interrupts, but only above level 11. This enables "L1-A", + * but avoids spurious interrupt bites from most other devices. + */ + rd %psr, %o0 + andn %o0, PSR_PIL, %o0 + wr %o0, 0xb00, %psr ! (11 << 8) + nop; nop; nop + + /* + * Set CPU type that we are running on. + */ + sethi %hi(_cputyp), %o0 + set 0x4000, %g7 + cmp %i0, %g7 + beq 5f + nop + + /* + * Save address of PROM vector (passed in %i0). + */ + sethi %hi(_promvec), %o1 + st %i0, [%o1 + %lo(_promvec)] + + mov CPU_SUN4C, %g4 + mov SUN4CM_PGSHIFT, %g5 + b,a 6f + +5: + mov CPU_SUN4, %g4 + mov SUN4_PGSHIFT, %g5 + +6: + st %g4, [%o0 + %lo(_cputyp)] + sethi %hi(_pgshift), %o0 ! pgshift = log2(nbpg) + st %g5, [%o0 + %lo(_pgshift)] + + mov 1, %o0 ! nbpg = 1 << pgshift + sll %o0, %g5, %g5 + sethi %hi(_nbpg), %o0 ! nbpg = bytes in a page + st %g5, [%o0 + %lo(_nbpg)] + + sub %g5, 1, %g5 + sethi %hi(_pgofset), %o0 ! page offset = bytes in a page - 1 + st %g5, [%o0 + %lo(_pgofset)] + + call _main + mov %i0, %o0 + + ret + restore + + +#ifdef TIGHT + +/* + * XXX - Space saving .div & .rem routines (small & non-negative numbres only) + */ + .align 4 + .global .div, .udiv +! int n = 0; while (a >= b) { a -= b; n++; }; return n; +.div: +.udiv: + cmp %o0, %o1 + bl 2f + mov 0, %o5 +1: + sub %o0, %o1, %o0 + cmp %o0, %o1 + bge 1b + add %o5, 1, %o5 +2: + retl + mov %o5, %o0 + + .align 4 + .global .rem, .urem +! while (a>=b) a -= b; return a; +.rem: +.urem: + cmp %o0, %o1 + bl 2f + nop + sub %o0, %o1, %o0 +1: + cmp %o0, %o1 + bge,a 1b + sub %o0, %o1, %o0 +2: + retl + nop + +#endif /* TIGHT */ diff --git a/sys/arch/sparc/stand/common/version.c b/sys/arch/sparc/stand/common/version.c new file mode 100644 index 00000000000..b5942268cd5 --- /dev/null +++ b/sys/arch/sparc/stand/common/version.c @@ -0,0 +1,45 @@ +/* $OpenBSD: version.c,v 1.1 1997/09/17 10:46:20 downsj Exp $ */ +/* $NetBSD: version.c,v 1.4 1995/09/16 23:20:39 pk 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. + */ + +/* + * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. + * + * 1.1 + * 1.2 get it to work with V0 bootproms. + * 1.3 add oldmon support and network support. + * 1.4 add cd9660 support + * + * 2.0 OpenBSD reorganization. + */ + +char *version = "2.0"; |