code:
/*	$OpenBSD: mmu.c,v 1.4 2013/03/21 21:51:00 deraadt Exp $	*/
/*	$NetBSD: mmu.c,v 1.8 2008/04/28 20:23:36 martin Exp $	*/

/*-
 * Copyright (c) 2003 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Paul Kranenburg.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
 */

#include <sys/param.h>
#include <lib/libsa/stand.h>
#include <machine/ctlreg.h>
#include <machine/idprom.h>
#include <machine/pte.h>
#include <sparc/sparc/asm.h>
#include <sparc/stand/common/promdev.h>

static int sun4_mmu3l;	/* sun4 3-lvl MMU */
static int rcookie;	/* sun4 3-lvl MMU region resource */
static int scookie;	/* sun4/sun4c MMU segment resource */
static int obmem;	/* SRMMU on-board memory space */

static int pmap_map4(vaddr_t va, paddr_t pa, psize_t size);
static int pmap_extract4(vaddr_t va, paddr_t *ppa);
static int pmap_map_srmmu(vaddr_t va, paddr_t pa, psize_t size);
static int pmap_extract_srmmu(vaddr_t va, paddr_t *ppa);

int (*pmap_map)(vaddr_t va, paddr_t pa, psize_t size);
int (*pmap_extract)(vaddr_t va, paddr_t *ppa);

#ifndef CPU_SUN4D
#define	CPU_ISSUN4D	0
#endif

int
mmu_init(void)
{
	if (CPU_ISSUN4 || CPU_ISSUN4C) {
		pmap_map = pmap_map4;
		pmap_extract = pmap_extract4;
		if (CPU_ISSUN4) {
			/* Find out if we're on a 3-lvl sun4 MMU. */
			struct idprom *idp = prom_getidprom();
			if (idp->id_machine == ID_SUN4_400)
				sun4_mmu3l = 1;
		}
		/*
		 * XXX - we just guess which MMU cookies are free:
		 *	 region 0 maps [0-16MB]
		 *	 segment 0-16 map [0-4MB]
		 *	 the PROM mappings use high-valued cookies.
		 */
		rcookie = 2;
		scookie = 17;
	} else if (CPU_ISSUN4M || CPU_ISSUN4D) {
		char buf[32];
		pmap_map = pmap_map_srmmu;
		pmap_extract = pmap_extract_srmmu;
		snprintf(buf, sizeof buf, "obmem %lx L!", (u_long)&obmem);
		prom_interpret(buf);
	} else
		return (ENOTSUP);

	return (0);
}

/*
 * SUN4 & SUN4C VM routines.
 * Limited functionality wrt. MMU resource management.
 */

#define getpte4(va)		lda(va, ASI_PTE)
#define setpte4(va, pte)	sta(va, ASI_PTE, pte)

int
pmap_map4(vaddr_t va, paddr_t pa, psize_t size)
{
	u_int n = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
	u_int pte;

	if (sun4_mmu3l)
		setregmap((va & -NBPRG), rcookie++);

#ifdef DEBUG
	printf("Mapping %lx -> %lx (%d pages)\n", va, pa, n);
#endif
	setsegmap((va & -NBPSG), ++scookie);
	while (n--) {
		pte = PG_S | PG_V | PG_W | PG_NC | ((pa >> PAGE_SHIFT) & PG_PFNUM);
		setpte4(va, pte);
		va += PAGE_SIZE;
		pa += PAGE_SIZE;
		if ((va & (NBPSG - 1)) == 0) {
#ifdef DEBUG
	printf("%d ", scookie);
#endif
			setsegmap(va, ++scookie);
		}
	}
#ifdef DEBUG
	printf("\n");
#endif
	return (0);
}

int
pmap_extract4(vaddr_t va, paddr_t *ppa)
{
	u_int pte;

	va &= -PAGE_SIZE;
	pte = getpte4(va);
	if ((pte & PG_V) == 0)
		return (EFAULT);

	*ppa = (pte & PG_PFNUM) << PAGE_SHIFT;
	return (0);
}

/*
 * SRMMU VM routines.
 * We use the PROM's Forth services to do all the hard work.
 */
int
pmap_map_srmmu(vaddr_t va, paddr_t pa, psize_t size)
{
	char buf[64];

	snprintf(buf, sizeof buf, "%lx %x %lx %lx map-pages",
	    pa, obmem, va, size);

#ifdef DEBUG
	printf("Mapping kernel: %s\n", buf);
#endif

	prom_interpret(buf);
	return (0);
}

int
pmap_extract_srmmu(vaddr_t va, paddr_t *ppa)
{
	char buf[32];
	u_int pte;

	va &= -PAGE_SIZE;
	snprintf(buf, sizeof buf, "%lx pgmap@ %lx L!", va, (u_long)&pte);
	prom_interpret(buf);
	if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE)
		return (EFAULT);

	*ppa = (pte & SRMMU_PPNMASK) << SRMMU_PPNPASHIFT;
	return (0);
}


code:
/*	$OpenBSD: net.c,v 1.4 2014/08/21 14:24:08 mpi 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 <lib/libsa/stand.h>
#include <lib/libsa/nfs.h>
#include <lib/libsa/net.h>
#include <lib/libsa/netif.h>
#include <lib/libsa/bootparam.h>

#include "promdev.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(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);
}

void
net_close(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(void)
{

#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;
}

license: unknown


code:
/*	$OpenBSD: netif_sun.c,v 1.5 2014/11/19 19:41:25 miod 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 <net/if.h>

#include <netinet/in.h>
#include <netinet/if_ether.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;

	/* 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;
}


code:
/*	$OpenBSD: promdev.c,v 1.17 2015/01/11 18:10:33 miod 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(struct open_file *);
int	obp_strategy(void *, int, daddr32_t, size_t, void *, size_t *);
ssize_t	obp_xmit(struct promdata *, void *, size_t);
ssize_t	obp_recv(struct promdata *, void *, size_t);
int	prom0_close(struct open_file *);
int	prom0_strategy(void *, int, daddr32_t, size_t, void *, size_t *);
void	prom0_iclose(struct saioreq *);
int	prom0_iopen(struct promdata *);
ssize_t	prom0_xmit(struct promdata *, void *, size_t);
ssize_t	prom0_recv(struct promdata *, void *, size_t);

static char	*prom_mapin(u_long, int, int);

int	prom_findnode(int, const char *);
int	prom_findroot(void);
int	prom_firstchild(int);
int	getdevtype(int, char *);
int	prom_getprop(int, char *, void *, int);
int	prom_getproplen(int, char *);
char	*prom_getpropstring(int, char *);
int	prom_nextsibling(int);

static void	prom0_fake(void);

extern struct fs_ops file_system_nfs[];
extern struct fs_ops file_system_cd9660[];
extern struct fs_ops file_system_ufs[];

int
prom_open(struct open_file *f, ...)
{
	return 0;
}

int
prom_ioctl(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;

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;
	daddr32_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 (*)(int, char *, size_t))promvec->pv_v2devops.v2_read :
		    (u_int (*)(int, char *, size_t))promvec->pv_v2devops.v2_write))
		    (fd, buf, size);
	} else {
		int n = (*((flag == F_READ) ?
		    (u_int (*)(int, int, daddr32_t, void *))promvec->pv_v0devops.v0_rbdev :
		    (u_int (*)(int, int, daddr32_t, void *))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;
	daddr32_t	dblk;
	size_t	size;
	void	*buf;
	size_t	*rsize;
{
	struct promdata	*pd = devdata;
	struct saioreq	*si;
	struct om_boottable *ops;
	struct devinfo *dip;
	char *dmabuf;
	int si_flag;
	size_t	xcnt, total, chunk;
	int rc = 0;

	si = pd->si;
	ops = si->si_boottab;
	dip = ops->b_devinfo;

#ifdef DEBUG_PROM
	printf("prom_strategy: size=%d dblk=%d\n", size, dblk);
#endif

	dmabuf = dvma_mapin(buf, size);

	/*
	 * Clamp I/O to the maximum DMA transfer size supported by the PROM,
	 * if necessary. Note that we need to round down to a block boundary
	 * as the value is not necessarily a power of two (8216 has been
	 * seen with PROM rev 1.3.)
	 */
	if (dip->d_dmabytes != 0)
		chunk = dbtob(btodb(dip->d_dmabytes));
	else
		chunk = size;

	total = 0;
	while (size != 0) {
		if (size < chunk)
			chunk = size;

		si->si_bn = dblk;
		si->si_ma = dmabuf;
		si->si_cc = chunk;

		si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE;
		xcnt = (*ops->b_strategy)(si, si_flag);

#ifdef DEBUG_PROM
		printf("disk_strategy: xcnt = %x\n", xcnt);
#endif

		if (xcnt <= 0) {
			rc = EIO;
			break;
		}

		total += xcnt;
		if (xcnt != chunk)
			break;

		size -= chunk;
		dmabuf += chunk;
		dblk += btodb(chunk);
	}

	dvma_mapout(dmabuf, size);

	*rsize = total;
	return rc;
}

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 {
                /* SUN4 PROM: must turn off local echo */
                struct om_vector *oldpvec = (struct om_vector *)PROM_BASE;
                int saveecho = 0;

                if (CPU_ISSUN4) {
                        saveecho = *(oldpvec->echo);
                        *(oldpvec->echo) = 0;
                }
                c = (*promvec->pv_getchar)();
                if (CPU_ISSUN4)
                        *(oldpvec->echo) = saveecho;
	}

	if (c == '\r')
		c = '\n';
	return (c);
}

int
cngetc(void)
{
	return getchar();
}

int
peekchar(void)
{
	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(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(void)
{
	register int ticks = getticks();
	return ((time_t)(ticks / hz));
}

int
getticks(void)
{
	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);
}

struct idprom *
prom_getidprom()
{
	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);
		}

		return &sun4_idprom;
	} else
		return NULL;
}

void
prom_getether(int fd, u_char *ea)
{
	if (cputyp == CPU_SUN4) {
		struct idprom *idp = prom_getidprom();
		bcopy(idp->id_ether, ea, 6);
	} else if (promvec->pv_romvec_vers <= 2) {
		(void)(*promvec->pv_enaddr)(fd, (char *)ea);
	} else {
		char buf[64];
		snprintf(buf, sizeof 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_BYTE },
	{ "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 = prom_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
prom_findnode(int first, const char *name)
{
	int node;

	for (node = first; node != 0; node = prom_nextsibling(node))
		if (strcmp(prom_getpropstring(node, "name"), name) == 0)
			return (node);
	return (0);
}

int
prom_findroot()
{
	static int rootnode;
	int node;

	if ((node = rootnode) == 0 && (node = prom_nextsibling(0)) == 0)
		panic("no PROM root device");
	rootnode = node;
	return (node);
}

int
prom_firstchild(int node)
{
	return promvec->pv_nodeops->no_child(node);
}

int
prom_getprop(int node, char *name, void *buf, 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);
}

int
prom_getproplen(int node, char *name)
{
	return promvec->pv_nodeops->no_proplen(node, name);
}

/*
 * 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 *
prom_getpropstring(int node, char *name)
{
	register int len;
	static char stringbuf[64];

	len = prom_getprop(node, name, (void *)stringbuf, sizeof stringbuf - 1);
	if (len == -1)
		len = 0;
	stringbuf[len] = '\0';	/* usually unnecessary */
	return (stringbuf);
}

int
prom_nextsibling(int node)
{
	return (promvec->pv_nodeops->no_nextnode(node));
}

void
prom_interpret(char *s)
{
	if (promvec->pv_romvec_vers < 2)
		promvec->pv_fortheval.v0_eval(strlen(s), s);
	else
		promvec->pv_fortheval.v2_eval(s);
}

int
prom_makememarr(struct memarr *ap, u_int xmax, int which)
{
	struct v0mlist *mp;
	int node, n;
	char *prop;

	if (which != MEMARR_AVAILPHYS && which != MEMARR_TOTALPHYS)
		panic("makememarr");

	if (CPU_ISSUN4) {
		struct om_vector *oldpvec = (struct om_vector *)PROM_BASE;
		if (ap != NULL && xmax != 0) {
			ap[0].addr_hi = 0;
			ap[0].addr_lo = 0;
			ap[0].len = which == MEMARR_AVAILPHYS ?
			    *oldpvec->memoryAvail : *oldpvec->memorySize;
		}
		return 1;
	}

	switch (n = promvec->pv_romvec_vers) {
	case 0:
		/*
		 * Version 0 PROMs use a linked list to describe these
		 * guys.
		 */
		mp = which == MEMARR_AVAILPHYS ?
		    *promvec->pv_v0mem.v0_physavail :
		    *promvec->pv_v0mem.v0_phystot;

		for (n = 0; mp != NULL; mp = mp->next, n++) {
			if (ap == NULL || n >= xmax)
				continue;
			ap->addr_hi = 0;
			ap->addr_lo = (u_int)mp->addr;
			ap->len = mp->nbytes;
			ap++;
		}
		break;
	default:
		printf("makememarr: hope version %d PROM is like version 2\n",
		    n);
		/* FALLTHROUGH */
	case 3:
	case 2:
		/*
		 * Version 2 PROMs use a property array to describe them.
		 */
		if ((node = prom_findnode(prom_firstchild(prom_findroot()),
		    "memory")) == 0)
			panic("makememarr: cannot find \"memory\" node");
		prop = which == MEMARR_AVAILPHYS ? "available" : "reg";
		n = prom_getproplen(node, prop) / sizeof(struct memarr);
		if (ap != NULL) {
			if (prom_getprop(node, prop, ap,
			    xmax * sizeof(struct memarr)) <= 0)
				panic("makememarr: cannot get property");
		}
		break;
	}

	if (n <= 0)
		panic("makememarr: no memory found");
	return (n);
}
#endif /* BOOTXX */

void
prom_init()
{
	char	*cp, *dp;
#ifndef BOOTXX
	char	*ap;
	int node;
#endif

	if (cputyp == CPU_SUN4) {
		prom0_fake();
		dvma_init();
#ifdef BOOTXX
		pgshift = SUN4_PGSHIFT;
		nbpg = 1 << pgshift;
		pgofset = nbpg - 1;
#endif
	}

	if (promvec->pv_romvec_vers >= 2) {
#ifndef BOOTXX
		static char filestore[16];
#endif

		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 == '-') {
		while (*ap) {
			switch (*ap++) {
			case 'a':
				prom_boothow |= RB_ASKNAME;
				break;
			case 'c':
				prom_boothow |= RB_CONFIG;
				break;
			case 'd':
				prom_boothow |= RB_KDB;
				debug = 1;
				break;
			case 's':
				prom_boothow |= RB_SINGLE;
				break;
			}
		}
	}
#endif

#ifndef BOOTXX
	/*
	 * Find out what type of machine we're running on.
	 *
	 * This process is actually started in srt0.S, which has discovered
	 * the minimal set of machine specific parameters for the 1st-level
	 * boot program (bootxx) to run. The CPU type is either CPU_SUN4 or
	 * CPU_SUN4C at this point; we need to figure out the exact cpu type
	 * and our page size.
	 */

	if (cputyp == CPU_SUN4) {
		pgshift = SUN4_PGSHIFT;
	} else {
		/*
		 * We are either SUN4C, SUN4D, SUN4E or SUN4M.
		 * Use the PROM `compatible' property to determine which.
		 * Absence of the `compatible' property means either sun4c
		 * or sun4e; these can be told apart by checking for the
		 * page size.
		 */

		node = prom_findroot();
		cp = prom_getpropstring(node, "compatible");
		if (*cp == '\0' || strcmp(cp, "sun4c") == 0) {
			char tmpstr[24];

			snprintf(tmpstr, sizeof tmpstr, "pagesize %x l!",
			    (u_long)&nbpg);
			prom_interpret(tmpstr);
			if (nbpg == 1 << SUN4_PGSHIFT) {
				pgshift = SUN4_PGSHIFT;
				/* if netbooted, PROM won't output a cr */
				printf("\n");
			} else
				pgshift = SUN4CM_PGSHIFT;
			/* note that we don't bother telling 4e apart from 4c */
			cputyp = CPU_SUN4C;
		} else if (strcmp(cp, "sun4m") == 0) {
			cputyp = CPU_SUN4M;
			pgshift = SUN4CM_PGSHIFT;
#ifdef CPU_SUN4D
		} else if (strcmp(cp, "sun4d") == 0) {
			cputyp = CPU_SUN4D;
			pgshift = SUN4CM_PGSHIFT;
#endif
		} else
			panic("Unknown CPU type (compatible=`%s')", cp);
	}

	nbpg = 1 << pgshift;
	pgofset = nbpg - 1;
#endif
}

/*
 * 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

	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 & ~PAGE_MASK));
#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 int 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*PAGE_SIZE))
		panic("prom_mapin: length=%d", length);

	for (i = 0; i < prom_mapinfo_cnt; i++)
		if (prom_mapinfo[i].maptype == maptype)
			goto found;
	panic("prom_mapin: invalid maptype %d", 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 >> PAGE_SHIFT) & PG_PFNUM);

	va = prom_devmap;
	do {
		setpte(va, pte);
		va += PAGE_SIZE;
		pte += 1;
		length -= PAGE_SIZE;
	} while (length > 0);
	return ((char *)(prom_devmap | (pa & PAGE_MASK)));
}

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;
}


code:
/*	$OpenBSD: promdev.h,v 1.5 2011/04/14 18:27:49 miod 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 */
	ssize_t	(*xmit)(struct promdata *, void *, size_t);
	ssize_t	(*recv)(struct promdata *, void *, size_t);
};

#define PROM_LOADADDR	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;

void	prom_init(void);
void	prom_getether(int, u_char *);
struct idprom *prom_getidprom(void);
void	prom_interpret(char *);
int	prom_makememarr(struct memarr *, u_int, int);

/* Note: dvma_*() routines are for "oldmon" machines only */
void	dvma_init(void);
char	*dvma_mapin(char *, size_t);
char	*dvma_mapout(char *, size_t);
char	*dvma_alloc(int);
void	dvma_free(char *, int);

int	getticks(void);

int	mmu_init(void);
extern int	(*pmap_map)(vaddr_t, paddr_t, psize_t);
extern int	(*pmap_extract)(vaddr_t, paddr_t *);

int	net_open(struct promdata *);
void	net_close(struct promdata *);
int	net_mountroot(void);

/*
 * 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)


code:
/*	$OpenBSD: srt0.S,v 1.4 2010/07/06 20:41:06 miod 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>
#include <machine/asm.h>

#define	CCFSZ	96

	.file	"str0.s"

	.data
	.global	_C_LABEL(cputyp), _C_LABEL(nbpg), _C_LABEL(pgofset)
	.global _C_LABEL(pgshift)
_C_LABEL(cputyp):
	.word	CPU_SUN4C
_C_LABEL(nbpg):
	.word	1
_C_LABEL(pgofset):
	.word	1
_C_LABEL(pgshift):
	.word	1

	.text
	.globl	start

start:
	/*
	 * Set up a stack.
	 */
	set	start, %o1
	save	%o1, -CCFSZ, %sp

	/*
	 * Find which address we are at.
	 */
1:	call	2f
	 sethi	%hi(1b), %l0
2:	or	%l0, %lo(1b), %l0
	cmp	%l0, %o7		! %o7 contains actual address of 1b
	beq	4f			! already there, no need to relocate
	 nop

	/*
	 * Relocate.
	 */
	add	%o7, (start-1b), %l0
	set	start, %l1
	set	_C_LABEL(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     _C_LABEL(edata), %o0	! bzero(edata, end - edata)
	set     _C_LABEL(end), %o1
	/* note: bzero() expanded inline for compactness */
	subcc	%o1, %o0, %o1
	bz	2f			! in case there is no BSS

	srl	%o1, 2, %o1		! assume edata and end are aligned
1:
	st	%g0, [%o0]		! while (n--)
	subcc	%o1, 1, %o1		!	*p++ = 0;
	bnz	1b
	 add	%o0, 4, %o0
2:

	/*
	 * 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(_C_LABEL(cputyp)), %o0
	set	0x4000, %g7
	cmp	%i0, %g7
	beq	5f
	 nop

	/*
	 * Save address of PROM vector (passed in %i0).
	 */
	sethi	%hi(_C_LABEL(promvec)), %o1
	st	%i0, [%o1 + %lo(_C_LABEL(promvec))]

	mov	CPU_SUN4C, %g4
	b,a	6f

5:
	mov	CPU_SUN4, %g4

6:
	st	%g4, [%o0 + %lo(_C_LABEL(cputyp))]
	call	_C_LABEL(main)
	 mov	%i0, %o0

	ret
	 restore


code:
/*	$OpenBSD: version.c,v 1.12 2015/05/19 20:42:11 miod 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.
 *	2.1	Bumped RELOC
 *	2.2	ELF support added.
 *	2.3	Bumped RELOC
 *	2.4	Support for larger kernels and fragmented memory layouts.
 *	2.5	sun4e support
 *	2.6	Support for larger kernels when booting from tape, and avoid
 *		stomping on PROM data below 4MB on sun4c
 *	2.7	/etc/random.seed support
 *	2.8	Fix network boot broken on some PROM by the 2.7 changes
 *	2.9	Cope with DMA transfer size limits of old sun4 PROMs
 *	2.10	Allocate more memory beyond the kernel image on sun4d/sun4m
 *		systems to allow for larger kernel page tables
 *	2.11	Only attempt to load /etc/random.seed after a successful
 *		kernel load, and never if booting from tape. This works
 *		around sun4e PROM 1.6, which apparently gets confused by
 *		open() - close() sequences without any I/O in between.
 */

char *version = "2.11";


code: src/sys/arch/sparc/stand/installboot


code:
#	$OpenBSD: Makefile,v 1.8 2013/10/30 18:04:47 deraadt Exp $

MAN=	installboot.8

MANSUBDIR=sparc
LDSTATIC=-static

.if ${MACHINE} == "sparc"
SRCS=	installboot.c nlist.c
PROG=	installboot
.else
NOPROG=
.endif

BINDIR=	/usr/sbin

.include <bsd.prog.mk>


code:
/*	$OpenBSD: installboot.c,v 1.10 2014/07/12 19:01:49 tedu Exp $	*/
/*	$NetBSD: installboot.c,v 1.1 1997/06/01 03:39:45 mrg 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 <sys/param.h>
#include <sys/mount.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#include <ufs/ffs/fs.h>
#include <err.h>
#include <a.out.h>
#include <fcntl.h>
#include <nlist.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int	verbose, nowrite, hflag;
char	*boot, *proto, *dev;

struct nlist nl[] = {
#define X_BLOCKTABLE	0
	{"_block_table"},
#define X_BLOCKCOUNT	1
	{"_block_count"},
#define X_BLOCKSIZE	2
	{"_block_size"},
	{NULL}
};
daddr32_t	*block_table;		/* block number array in prototype image */
int32_t	*block_count_p;		/* size of this array */
int32_t	*block_size_p;		/* filesystem block size */
int32_t	max_block_count;

char	*karch;
char	cpumodel[130];

int	isofsblk = 0;
int	isofseblk = 0;

char		*loadprotoblocks(char *, long *);
int		loadblocknums(char *, int);
static void	devread(int, void *, daddr32_t, size_t, char *);
static void	usage(void);
int 		main(int, char *[]);

static void
usage()
{
	fprintf(stderr,
		"usage: installboot [-hnv] [-a karch] [-s isofsblk -e isofseblk] boot bootxx rawdev\n");
	exit(1);
}

int
main(argc, argv)
	int argc;
	char *argv[];
{
	int	c;
	int	devfd;
	char	*protostore;
	long	protosize;
	int	mib[2];
	size_t	size;

	while ((c = getopt(argc, argv, "a:vnhs:e:")) != -1) {
		switch (c) {
		case 'a':
			karch = optarg;
			break;
		case 'h':	/* Note: for backwards compatibility */
			/* Don't strip a.out header */
			hflag = 1;
			break;
		case 'n':
			/* Do not actually write the bootblock to disk */
			nowrite = 1;
			break;
		case 'v':
			/* Chat */
			verbose = 1;
			break;
		case 's':
			isofsblk = atoi(optarg);
			break;
		case 'e':
			isofseblk = atoi(optarg);
			break;
		default:
			usage();
		}
	}

	if (argc - optind < 3) {
		usage();
	}

	boot = argv[optind];
	proto = argv[optind + 1];
	dev = argv[optind + 2];

	if (karch == NULL) {
		mib[0] = CTL_HW;
		mib[1] = HW_MODEL;
		size = sizeof(cpumodel);
		if (sysctl(mib, 2, cpumodel, &size, NULL, 0) == -1)
			err(1, "sysctl");

		if (size < 5 || strncmp(cpumodel, "SUN-4", 5) != 0) /*XXX*/
			/* Assume a sun4c/sun4m */
			karch = "sun4c";
		else
			karch = "sun4";
	}

	if (verbose) {
		printf("boot: %s\n", boot);
		printf("proto: %s\n", proto);
		printf("device: %s\n", dev);
		printf("architecture: %s\n", karch);
	}

	if (strcmp(karch, "sun4") == 0) {
		hflag = 0;
	} else if (strcmp(karch, "sun4c") == 0) {
		hflag = 1;
	} else if (strcmp(karch, "sun4m") == 0) {
		hflag = 1;
	} else
		errx(1, "Unsupported architecture");

	/* Load proto blocks into core */
	if ((protostore = loadprotoblocks(proto, &protosize)) == NULL)
		exit(1);

	/* Open and check raw disk device */
	if ((devfd = open(dev, O_RDONLY, 0)) < 0)
		err(1, "open: %s", dev);

	/* Extract and load block numbers */
	if (loadblocknums(boot, devfd) != 0)
		exit(1);

	(void)close(devfd);

	if (nowrite)
		return 0;

	/* Write patched proto bootblocks into the superblock */
	if (protosize > SBSIZE - DEV_BSIZE)
		errx(1, "proto bootblocks too big");

	if ((devfd = open(dev, O_RDWR, 0)) < 0)
		err(1, "open: %s", dev);

	if (lseek(devfd, DEV_BSIZE, SEEK_SET) != DEV_BSIZE)
		err(1, "lseek bootstrap");

	/* Sync filesystems (to clean in-memory superblock?) */
	sync();

	if (write(devfd, protostore, protosize) != protosize)
		err(1, "write bootstrap");
	(void)close(devfd);
	return 0;
}

char *
loadprotoblocks(fname, size)
	char *fname;
	long *size;
{
	int	fd, sz;
	char	*bp;
	struct	stat statbuf;
	struct	exec *hp;
	long	off;

	/* Locate block number array in proto file */
	if (nlist(fname, nl) != 0) {
		warnx("nlist: %s: symbols not found", fname);
		return NULL;
	}
	if (nl[X_BLOCKTABLE].n_type != N_DATA + N_EXT) {
		warnx("nlist: %s: wrong type", nl[X_BLOCKTABLE].n_un.n_name);
		return NULL;
	}
	if (nl[X_BLOCKCOUNT].n_type != N_DATA + N_EXT) {
		warnx("nlist: %s: wrong type", nl[X_BLOCKCOUNT].n_un.n_name);
		return NULL;
	}
	if (nl[X_BLOCKSIZE].n_type != N_DATA + N_EXT) {
		warnx("nlist: %s: wrong type", nl[X_BLOCKSIZE].n_un.n_name);
		return NULL;
	}

	if ((fd = open(fname, O_RDONLY)) < 0) {
		warn("open: %s", fname);
		return NULL;
	}
	if (fstat(fd, &statbuf) != 0) {
		warn("fstat: %s", fname);
		close(fd);
		return NULL;
	}
	if (statbuf.st_size == 0) {
		warn("%s is empty", fname);
		close(fd);
		return NULL;
	}

	if ((bp = calloc(roundup(statbuf.st_size, DEV_BSIZE), 1)) == NULL) {
		warnx("malloc: %s: no memory", fname);
		close(fd);
		return NULL;
	}
	if (read(fd, bp, statbuf.st_size) != statbuf.st_size) {
		warn("read: %s", fname);
		free(bp);
		close(fd);
		return NULL;
	}
	close(fd);

	hp = (struct exec *)bp;
	sz = (hflag ? sizeof(*hp) : 0) + hp->a_text + hp->a_data;
	sz = roundup(sz, DEV_BSIZE);

	/* Calculate the symbols' location within the proto file */
	off = N_DATOFF(*hp) - N_DATADDR(*hp) - (hp->a_entry - N_TXTADDR(*hp));
	block_table = (daddr32_t *) (bp + nl[X_BLOCKTABLE].n_value + off);
	block_count_p = (int32_t *)(bp + nl[X_BLOCKCOUNT].n_value + off);
	block_size_p = (int32_t *) (bp + nl[X_BLOCKSIZE].n_value + off);
	if ((int)block_table & 3) {
		warn("%s: invalid address: block_table = %x",
		     fname, block_table);
		free(bp);
		close(fd);
		return NULL;
	}
	if ((int)block_count_p & 3) {
		warn("%s: invalid address: block_count_p = %x",
		     fname, block_count_p);
		free(bp);
		close(fd);
		return NULL;
	}
	if ((int)block_size_p & 3) {
		warn("%s: invalid address: block_size_p = %x",
		     fname, block_size_p);
		free(bp);
		close(fd);
		return NULL;
	}
	max_block_count = *block_count_p;

	if (verbose) {
		printf("%s: entry point %#x\n", fname, hp->a_entry);
		printf("%s: a.out header %s\n", fname,
			hflag?"left on":"stripped off");
		printf("proto bootblock size %ld\n", sz);
		printf("room for %d filesystem blocks at %#x\n",
			max_block_count, nl[X_BLOCKTABLE].n_value);
	}

	/*
	 * We convert the a.out header in-vitro into something that
	 * Sun PROMs understand.
	 * Old-style (sun4) ROMs do not expect a header at all, so
	 * we turn the first two words into code that gets us past
	 * the 32-byte header where the actual code begins. In assembly
	 * speak:
	 *	.word	MAGIC		! a NOP
	 *	ba,a	start		!
	 *	.skip	24		! pad
	 * start:
	 */

#define SUN_MAGIC	0x01030107
#define SUN4_BASTART	0x30800007	/* i.e.: ba,a `start' */
	*((int *)bp) = SUN_MAGIC;
	*((int *)bp + 1) = SUN4_BASTART;

	*size = sz;
	return (hflag ? bp : (bp + sizeof(struct exec)));
}

static void
devread(fd, buf, blk, size, msg)
	int	fd;
	void	*buf;
	daddr32_t	blk;
	size_t	size;
	char	*msg;
{
	if (lseek(fd, dbtob(blk), SEEK_SET) != dbtob(blk))
		err(1, "%s: devread: lseek", msg);

	if (read(fd, buf, size) != size)
		err(1, "%s: devread: read", msg);
}

static char sblock[SBSIZE];

int
loadblocknums(boot, devfd)
char	*boot;
int	devfd;
{
	int		i, fd;
	struct	stat	statbuf;
	struct	statfs	statfsbuf;
	struct fs	*fs;
	char		*buf;
	daddr32_t		blk, *ap;
	struct ufs1_dinode	*ip;
	int		ndb;

	/*
	 * Open 2nd-level boot program and record the block numbers
	 * it occupies on the filesystem represented by `devfd'.
	 */
	if ((fd = open(boot, O_RDONLY)) < 0)
		err(1, "open: %s", boot);

	if (fstatfs(fd, &statfsbuf) != 0)
		err(1, "statfs: %s", boot);

	if (isofsblk) {
		int i;

		*block_size_p = 512;
		*block_count_p = (isofseblk - isofsblk + 1) * (2048/512);
		if (*block_count_p > max_block_count)
			errx(1, "%s: Too many blocks", boot);
		if (verbose)
			printf("%s: %d block numbers: ", boot, *block_count_p);
		for (i = 0; i < *block_count_p; i++) {
			blk = (isofsblk * (2048/512)) + i;
			block_table[i] = blk;
			if (verbose)
				printf("%d ", blk);
		}
		if (verbose)
			printf("\n");
		return 0;
	}

	if (strncmp(statfsbuf.f_fstypename, "ffs", MFSNAMELEN) &&
	    strncmp(statfsbuf.f_fstypename, "ufs", MFSNAMELEN)) {
		errx(1, "%s: must be on an FFS filesystem", boot);
	}

	if (fsync(fd) != 0)
		err(1, "fsync: %s", boot);

	if (fstat(fd, &statbuf) != 0)
		err(1, "fstat: %s", boot);

	close(fd);

	/* Read superblock */
	devread(devfd, sblock, btodb(SBOFF), SBSIZE, "superblock");
	fs = (struct fs *)sblock;

	/* Read inode */
	if ((buf = malloc(fs->fs_bsize)) == NULL)
		errx(1, "No memory for filesystem block");

	blk = fsbtodb(fs, ino_to_fsba(fs, statbuf.st_ino));
	devread(devfd, buf, blk, fs->fs_bsize, "inode");
	ip = (struct ufs1_dinode *)(buf) + ino_to_fsbo(fs, statbuf.st_ino);

	/*
	 * Register filesystem block size.
	 */
	*block_size_p = fs->fs_bsize;

	/*
	 * Get the block numbers; we don't handle fragments
	 */
	ndb = howmany(ip->di_size, fs->fs_bsize);
	if (ndb > max_block_count)
		errx(1, "%s: Too many blocks", boot);

	/*
	 * Register block count.
	 */
	*block_count_p = ndb;

	if (verbose)
		printf("%s: block numbers: ", boot);
	ap = ip->di_db;
	for (i = 0; i < NDADDR && *ap && ndb; i++, ap++, ndb--) {
		blk = fsbtodb(fs, *ap);
		block_table[i] = blk;
		if (verbose)
			printf("%d ", blk);
	}
	if (verbose)
		printf("\n");

	if (ndb == 0)
		return 0;

	/*
	 * Just one level of indirections; there isn't much room
	 * for more in the 1st-level bootblocks anyway.
	 */
	if (verbose)
		printf("%s: block numbers (indirect): ", boot);
	blk = ip->di_ib[0];
	devread(devfd, buf, blk, fs->fs_bsize, "indirect block");
	ap = (daddr32_t *)buf;
	for (; i < NINDIR(fs) && *ap && ndb; i++, ap++, ndb--) {
		blk = fsbtodb(fs, *ap);
		block_table[i] = blk;
		if (verbose)
			printf("%d ", blk);
	}
	if (verbose)
		printf("\n");

	if (ndb)
		errx(1, "%s: Too many blocks", boot);
	return 0;
}


code:
/*	$OpenBSD: nlist.c,v 1.3 2014/07/12 19:01:49 tedu Exp $ */
/*
 * Copyright (c) 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/types.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <a.out.h>		/* pulls in nlist.h */

#define	ISLAST(p)	(p->n_un.n_name == 0 || p->n_un.n_name[0] == 0)

int
__aout_fdnlist(int fd, struct nlist *list)
{
	struct nlist *p, *s;
	char *strtab;
	off_t symoff, stroff;
	u_long symsize;
	int nent, cc;
	int strsize, usemalloc = 0;
	struct nlist nbuf[1024];
	struct exec exec;

	if (pread(fd, &exec, sizeof(exec), (off_t)0) != sizeof(exec) ||
	    N_BADMAG(exec) || exec.a_syms == 0)
		return (-1);

	stroff = N_STROFF(exec);
	symoff = N_SYMOFF(exec);
	symsize = exec.a_syms;

	/* Read in the size of the string table. */
	if (pread(fd, (void *)&strsize, sizeof(strsize), stroff) !=
	    sizeof(strsize))
		return (-1);
	else
		stroff += sizeof(strsize);

	/*
	 * Read in the string table.  We try mmap, but that will fail
	 * for /dev/ksyms so fall back on malloc.  Since OpenBSD's malloc(3)
	 * returns memory to the system on free this does not cause bloat.
	 */
	strsize -= sizeof(strsize);
	strtab = mmap(NULL, (size_t)strsize, PROT_READ, MAP_SHARED|MAP_FILE,
	    fd, stroff);
	if (strtab == MAP_FAILED) {
		usemalloc = 1;
		if ((strtab = (char *)malloc(strsize)) == NULL)
			return (-1);
		errno = EIO;
		if (pread(fd, strtab, strsize, stroff) != strsize) {
			nent = -1;
			goto aout_done;
		}
	}

	/*
	 * clean out any left-over information for all valid entries.
	 * Type and value defined to be 0 if not found; historical
	 * versions cleared other and desc as well.  Also figure out
	 * the largest string length so don't read any more of the
	 * string table than we have to.
	 *
	 * XXX clearing anything other than n_type and n_value violates
	 * the semantics given in the man page.
	 */
	nent = 0;
	for (p = list; !ISLAST(p); ++p) {
		p->n_type = 0;
		p->n_other = 0;
		p->n_desc = 0;
		p->n_value = 0;
		++nent;
	}

	while (symsize > 0) {
		cc = MIN(symsize, sizeof(nbuf));
		if (pread(fd, nbuf, cc, symoff) != cc)
			break;
		symsize -= cc;
		symoff += cc;
		for (s = nbuf; cc > 0; ++s, cc -= sizeof(*s)) {
			char *sname = strtab + s->n_un.n_strx - sizeof(int);

			if (s->n_un.n_strx == 0 || (s->n_type & N_STAB) != 0)
				continue;
			for (p = list; !ISLAST(p); p++) {
				char *pname = p->n_un.n_name;

				if (*sname != '_' && *pname == '_')
					pname++;
				if (!strcmp(sname, pname)) {
					p->n_value = s->n_value;
					p->n_type = s->n_type;
					p->n_desc = s->n_desc;
					p->n_other = s->n_other;
					if (--nent <= 0)
						break;
				}
			}
		}
	}
aout_done:
	if (usemalloc)
		free(strtab);
	else
		munmap(strtab, strsize);
	return (nent);
}

int
nlist(const char *name, struct nlist *list)
{
	int fd, n;

	fd = open(name, O_RDONLY, 0);
	if (fd < 0)
		return (-1);
	n = __aout_fdnlist(fd, list);
	(void)close(fd);
	return (n);
}


code:
/Makefile/1.9/Wed Nov 19 20:01:36 2014//TOPENBSD_5_8_BASE
D

path: sys/arch/sparc/stand/libsa/CVS/Entries


path: sys/arch/sparc/stand/libsa/CVS/Tag


code:
#	$OpenBSD: Makefile,v 1.9 2014/11/19 20:01:36 miod Exp $

LIB=	sa

.PATH:	${.CURDIR}/../../../../lib/libsa

CFLAGS= -fno-pie -O2 -D_STANDALONE -D__INTERNAL_LIBSA_CREAD \
	-I${.CURDIR} -I${.CURDIR}/../include -I${.CURDIR}/../.. \
	-I${.CURDIR}/../../.. -I${.CURDIR}/../../../.. \
	-I${.CURDIR}/../../../../lib/libsa

# stand routines
SRCS=	alloc.c exit.c getfile.c gets.c globals.c \
	memcmp.c memcpy.c memset.c printf.c snprintf.c strerror.c strncpy.c

# io routines
SRCS+=	close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \
	open.c read.c stat.c write.c cread.c

# network routines
SRCS+=	arp.c ether.c in_cksum.c net.c netif.c netudp.c rpc.c

# network info services
SRCS+=	bootp.c bootparam.c rarp.c

# boot filesystems
SRCS+=	ufs.c nfs.c cd9660.c

${OBJS}:	${.CURDIR}/../Makefile.inc

NOPROFILE=
NOPIC=

install:

.include <bsd.lib.mk>

path: sys/arch/sparc/stand/libsa/Makefile


code:
/Makefile/1.5/Sun Sep  2 23:23:51 2012//TOPENBSD_5_8_BASE
D

path: sys/arch/sparc/stand/libz/CVS/Entries


path: sys/arch/sparc/stand/libz/CVS/Tag


code:
#	$OpenBSD: Makefile,v 1.5 2012/09/02 23:23:51 pascal Exp $

S=${.CURDIR}/../../../..
ZDST=${.OBJDIR}
CFLAGS+=-fno-pie

.PATH: ${S}/lib/libz

.include "${S}/lib/libz/Makefile"

path: sys/arch/sparc/stand/libz/Makefile


code:
/Makefile/1.8/Sun Dec  8 14:46:39 2013//TOPENBSD_5_8_BASE
D/compile////
D/conf////
D/dev////
D/fpu////
D/include////
D/sparc64////
D/stand////


code:
#	$OpenBSD: Makefile,v 1.8 2013/12/08 14:46:39 espie Exp $

S=	${.CURDIR}/../..
KFILE=	GENERIC
.if exists(conf/GENERIC.MP)
KFILE=	GENERIC.MP
.endif
TDIRS=	${_arch} include fpu
TAGS=	${.CURDIR}/tags

NOPROG=
NOMAN=
NOOBJ=
SUBDIR=	stand

# config the fattest kernel we can find into a temporary dir
# to create a Makefile.  Then use make to pull some variables
# out and push them into the sub-shell to expand the paths,
# and finally run ctags.
tags::
	TDIR=`mktemp -d /tmp/_tagXXXXXXXXXX` || exit 1; \
	eval "S=${S}" && \
	config -s ${S} -b $${TDIR} ${.CURDIR}/conf/${KFILE} && \
	eval "_arch=\"`make -V _arch -f $${TDIR}/Makefile`\"" && \
	eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \
	eval "_machdir=\$S/arch/$${_mach}" && \
	eval "_archdir=\$S/arch/$${_arch}" && \
	eval "HFILES=\"`find $S \( -path $S/'arch' -o -path $S/stand -o -path $S/lib/libsa -o -path $S'/lib/libkern/arch' \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_mach} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \
	eval "SFILES=\"`make -V SFILES -f $${TDIR}/Makefile`\"" && \
	eval "CFILES=\"`make -V CFILES -f $${TDIR}/Makefile`\"" && \
	eval "AFILES=\"`make -V AFILES -f $${TDIR}/Makefile`\"" && \
	ctags -wd -f ${TAGS} $${CFILES} $${HFILES} && \
	egrep "^[_A-Z]*ENTRY[_A-Z]*\(.*\)" $${SFILES} $${AFILES} | \
	    sed "s;\\([^:]*\\):\\([^(]*\\)(\\([^, )]*\\)\\(.*\\);\\3	\\1	/^\\2(\\3\\4$$/;" \
	    >> ${TAGS} && \
	sort -o ${TAGS} ${TAGS} && \
	rm -rf $${TDIR}

links:
	-for i in conf ${TDIRS}; do \
	    (cd $$i && rm -f tags; ln -s tags tags); done

obj:	_SUBDIRUSE

.include <bsd.prog.mk>


code:
GENERIC
GENERIC.MP
RAMDISK
RAMDISKU1
RAMDISKU5


code:
/.cvsignore/1.6/Wed Oct 10 17:05:43 2007//TOPENBSD_5_8_BASE
D


code:
#	$OpenBSD: GENERIC,v 1.299 2015/04/16 09:09:49 mpi Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
#
# For further information on hardware support for this architecture, see
# the intro(4) man page.  For further information about kernel options
# for this architecture, see the options(4) man page.  For an explanation
# of each device driver in this file see the section 4 man page for the
# device.

machine		sparc64
include		"../../../conf/GENERIC"
maxusers	64			# estimated number of users

option		SUN4US
option		SUN4V

option		PCIVERBOSE
option		USER_PCICONF		# user-space PCI configuration
option		APERTURE
option		USBVERBOSE

option		WSEMUL_SUN	# provide sun terminal emulation; required
option		WSEMUL_NO_VT100	# do not provide vt100 terminal emulation
option		WSEMUL_DUMB
option		WSDISPLAY_COMPAT_RAWKBD	# provide raw scancodes; needed for X11

config		bsd	swap generic

# Main bus and CPU .. all systems.
mainbus0 at root
cpu0	at mainbus0
ssm*	at mainbus0
cpu0	at ssm?
cmp*	at mainbus0
cmp*	at ssm?
cpu0	at cmp?
core*	at cmp?
cpu0	at core?

# Bus types found on SPARC systems.
sbus*	at mainbus0
central0 at mainbus0
fhc0	at central0
fhc*	at mainbus0
upa0	at mainbus0
psycho*	at mainbus0
pci*	at psycho?
schizo*	at mainbus0
schizo*	at ssm?
pci*	at schizo?
pyro*	at mainbus0
pci*	at pyro?
vpci*	at mainbus0
pci*	at vpci?
pci*	at ppb?
ppb*	at pci?
ebus*	at mainbus0
ebus*	at pci?
vbus0	at mainbus0
sbbc*	at pci?
cbus*	at vbus?

# PCI Ethernet
hme*	at pci?			# Sun Happy Meal 10/100
gem*	at pci?			# Sun GEM 10/100/Gigabit
cas*	at pci?			# Sun Cassini 100/Gigabit
nep*	at pci?			# Sun Neptune ethernet
ti*	at pci?			# Alteon Tigon 1Gb ethernet
skc*	at pci?			# SysKonnect GEnesis 984x
sk*	at skc?			#  each port of above
mskc*	at pci?			# Marvell Yukon-2
msk*	at mskc?		#  each port of above
fxp*	at pci?			# EtherExpress 10/100B ethernet
xl*	at pci?			# 3C9xx ethernet
xl*	at cardbus?		# 3C9xx ethernet
pcn*	at pci?			# AMD PCnet-PCI Ethernet
de*	at pci?			# DC21X4X-based ethernet
dc*	at pci?			# 21143, "tulip" clone ethernet
dc*	at cardbus?		# 21143, "tulip" clone ethernet
ne*	at pci?			# NE2000-compat ethernet cards
epic*	at pci?			# SMC EPIC/100 ethernet
em*	at pci?			# Intel Pro/1000 ethernet
#ixgb*	at pci?			# Intel Pro/10Gb ethernet
ix*	at pci?			# Intel 82598EB 10Gb ethernet
myx*	at pci?			# Myricom Myri-10G 10Gb ethernet
bge*	at pci?			# Broadcom BCM570x (aka Tigon3)
bnx*	at pci?			# Broadcom BCM5706/5708 GigE
stge*	at pci?			# Sundance TC9021 GigE
rl*	at pci?			# Realtek 81[23]9 ethernet
vr*	at pci?			# VIA Rhine ethernet
re*	at pci?			# Realtek 8169/8169S/8110S
re*	at cardbus?		# Realtek 8169/8169S/8110S
thtc*	at pci?			# Tehuti Networks 10Gb ethernet
tht*	at thtc?
jme*	at pci?			# JMicron JMC250/JMC260 Ethernet

ath*	at pci?			# Atheros AR5k (802.11a/b/g)
ath*	at cardbus?		# Atheros AR5k (802.11a/b/g)
athn*	at pci?			# Atheros AR9k (802.11a/g/n)
athn*	at cardbus?		# Atheros AR9k (802.11a/g/n)
pgt*	at pci?			# Prism54 (only full-mac varients)
acx*	at pci?			# TI ACX100/ACX111 (802.11b/g)
acx*	at cardbus?		# TI ACX100/ACX111 (802.11b/g)
ral*	at pci?			# Ralink RT2500/RT2501/RT2600
ral*	at cardbus?		# Ralink RT2500/RT2501/RT2600
malo*	at pci?			# Marvell Libertas
malo*	at cardbus?		# Marvell Libertas
malo*	at pcmcia?		# Marvell 88W8385

# PCI SCSI
ahc*	at pci?			# Adaptec 2940 SCSI controllers
siop*	at pci?			# NCR 538XX SCSI controllers
qlw*	at pci?			# QLogic ISP SCSI
qla*	at pci?			# QLogic ISP 2[123]xx FibreChannel
qle*	at pci?			# QLogic ISP 2[45]xx FibreChannel
pcscp*	at pci?			# AMD 53c974 PCscsi-PCI SCSI
mpi*	at pci?			# LSI Logic Fusion MPT Message Passing Interface
mpii*	at pci?			# LSI Message Passing Interface II
arc*	at pci?			# Areca RAID Controllers
jmb*	at pci?			# JMicron JMB36x controllers
ahci*	at jmb? flags 0x0000	# flags 0x0001 to force SATA 1 (1.5Gb/s)
pciide*	at jmb?
ahci*	at pci? flags 0x0000	# AHCI SATA controllers
				# flags 0x0001 to force SATA 1 (1.5Gb/s)
sili*	at pci?			# Silicon Image 3124/3132/3531 SATA controllers

# PCI crypto
hifn*	at pci?			# Hifn 7751/7811/7951
ubsec*	at pci?			# Broadcom 580[125]/582[012]

# PCI sound
auacer*	at pci?			# Acer Labs M5455
autri*	at pci? flags 0x0000	# Trident 4D WAVE
cmpci*  at pci?			# C-Media CMI8338/8738
eap*	at pci?			# Ensoniq AudioPCI S5016
emu*	at pci?			# SB Live!
eso*	at pci?			# ESS Solo-1 PCI AudioDrive

puc*	at pci?			# PCI "universal" comm device
com*	at puc?
#lpt*	at puc?

# Sound support
audio*	at auacer?
audio*	at audioce?
audio*	at audiocs?
audio*	at autri?
audio*	at cmpci?
audio*	at eap?
audio*	at emu?
audio*	at eso?

# MIDI support
midi*	at autri?
midi*	at eap?

# USB Controllers
ohci*	at pci?			# Open Host Controller
ohci*	at cardbus?
uhci*	at pci?			# Universal Host Controller (Intel)
ehci*	at pci?			# Enhanced Host Controller
ehci*	at cardbus?
xhci*	at pci?			# eXtensible Host Controller

# USB bus support
usb*	at ohci?
usb*	at uhci?
usb*	at ehci?
usb*	at xhci?

# USB devices
uhub*	at usb?			# USB Hubs
uhub*	at uhub?		# USB Hubs
ualea*	at uhub?		# Araneus Alea II TRNG
umodem*	at uhub?		# USB Modems/Serial
ucom*	at umodem?
uvisor*	at uhub?		# Handspring Visor
ucom*	at uvisor?
uvscom*	at uhub?		# SUNTAC Slipper U VS-10U serial
ucom*	at uvscom?
ubsa*	at uhub?		# Belkin serial adapter
ucom*	at ubsa?
uftdi*	at uhub?		# FTDI FT8U100AX serial adapter
ucom*	at uftdi?
uplcom* at uhub?		# I/O DATA USB-RSAQ2 serial adapter
ucom*	at uplcom?
umct*	at uhub?		# MCT USB-RS232 serial adapter
ucom*	at umct?
uslcom*	at uhub?		# Silicon Laboratories CP210x serial
ucom*	at uslcom?
uark*	at uhub?		# Arkmicro ARK3116 serial
ucom*	at uark?
uipaq*	at uhub?		# iPAQ serial adapter
ucom*	at uipaq?
uchcom*	at uhub?		# WinChipHead CH341/340 serial
ucom*	at uchcom?
uaudio* at uhub?		# USB Audio
audio*	at uaudio?
umidi*	at uhub?		# USB MIDI
midi*	at umidi?
ulpt*	at uhub?		# USB Printers
umass*	at uhub?		# USB Mass Storage devices
uhidev*	at uhub?		# Human Interface Devices
ums*	at uhidev?		# USB mouse
wsmouse* at ums? mux 0
ukbd*	at uhidev?		# USB keyboard
wskbd*	at ukbd? mux 1
ucycom*	at uhidev?		# Cypress serial
ucom*	at ucycom?
uslhcom* at uhidev?		# Silicon Labs CP2110 USB HID UART
ucom*	at uslhcom?
uhid*	at uhidev?		# USB generic HID support
upd*	at uhidev?		# USB Power Devices sensors
aue*	at uhub?		# ADMtek AN986 Pegasus Ethernet
atu*	at uhub?		# Atmel AT76c50x based 802.11b
axe*	at uhub?		# ASIX Electronics AX88172 USB Ethernet
axen*	at uhub?		# ASIX Electronics AX88179 USB Ethernet
cue*	at uhub?		# CATC USB-EL1201A based Ethernet
kue*	at uhub?		# Kawasaki KL5KUSB101B based Ethernet
smsc*	at uhub?		# SMSC LAN95xx Ethernet
cdce*	at uhub?		# CDC Ethernet
urndis*	at uhub?		# Remote NDIS devices
udav*	at uhub?		# Davicom DM9601 based Ethernet
mos*	at uhub?		# MOSCHIP MCS7730/7830 10/100 Ethernet
upl*	at uhub?		# Prolific PL2301/PL2302 host-to-host `network'
ugl*	at uhub?		# Genesys Logic GL620USB-A host-to-host `network'
ural*	at uhub?		# Ralink RT2500USB
uath*	at uhub?		# Atheros AR5005UG/AR5005UX
rsu*	at uhub?		# Realtek RTL8188SU/RTL8191SU/RTL8192SU
urtwn*	at uhub?		# Realtek RTL8188CU/RTL8192CU
rum*	at uhub?		# Ralink RT2501USB/RT2601USB
run*	at uhub?		# Ralink RT2700U/RT2800U/RT3000U
athn*	at uhub?		# Atheros AR9002U
zyd*	at uhub?		# Zydas ZD1211
url*	at uhub?		# Realtek RTL8150L based adapters
wi*	at uhub?		# WaveLAN IEEE 802.11DS
udsbr*	at uhub?		# D-Link DSB-R100 radio
radio*	at udsbr?		# USB radio
ugen*	at uhub?		# USB Generic driver
udcf*	at uhub?		# Gude Expert mouseCLOCK
umbg*	at uhub?		# Meinberg Funkuhren USB5131
uthum*	at uhidev?		# TEMPerHUM sensor
ugold*	at uhidev?		# gold TEMPer sensor
utwitch* at uhidev?		# UYUREX BBU sensor
uow*	at uhub?		# Maxim/Dallas DS2490 1-Wire adapter
onewire* at uow?

# USB Video
uvideo* at uhub?
video*  at uvideo?

# CardBus bus support
cardbus* at cardslot?
pcmcia*	at cardslot?
cbb*	at pci?
cardslot* at cbb?

#### Standard system devices -- all required for a given architecture

auxio*	at ebus?
auxio*	at sbus?
beep*	at ebus?
beeper*	at ebus?
power*	at ebus?

# SAB82532 based serial ports
sab*	at ebus?
sabtty* at sab?

# NS16550 based serial ports
com*	at ebus?
comkbd*	at ebus?
wskbd* at comkbd? mux 1
comms*	at ebus?
wsmouse* at comms? mux 0

# Z8530 based serial ports
zs*	at sbus?
zs*	at fhc?
zstty*	at zs?
zskbd*	at zs?
wskbd*	at zskbd? mux 1
zsms*	at zs?
wsmouse* at zsms? mux 0

# i8042 based serial ports (PS/2 ports)
pckbc*	at ebus?			# controller
pckbd*	at pckbc?			#  ps2 keyboard
wskbd*	at pckbd? mux 1			#   generic keyboard layer
pms*	at pckbc?			#  ps2 mouse
wsmouse* at pms? mux 0			#   generic mouse

audioce*	at ebus?		# ebus cs4231

# parallel ports
bpp*	at sbus?
lpt*	at ebus?

bbc*	at ebus?
led*	at ebus?
lom*	at ebus?
pmc*	at ebus?
ppm*	at ebus?
wbsd*	at ebus?
sdmmc*	at wbsd?

# performance counters
uperf*	at ebus?
uperf*	at sbus?

## PROM console driver -- if all else fails
pcons0	at mainbus0			# PROM console
wsdisplay* at pcons?

## Mostek/DS1287 clocks
clock*	at sbus?
clock*	at ebus?
rtc*	at ebus?
clock0	at fhc?
clkbrd*	at fhc?
#environ* at fhc?

## PROM clock -- if all else failse
prtc0	at mainbus0

## Timer chip found on (some) sun4u systems.
timer*	at mainbus0

# Virtual devices for sun4v systems.
vcons0	at vbus?
vrtc0	at vbus?
vrng0	at vbus?
vdsk*	at cbus?
vnet*	at cbus?
vcc*	at cbus?
vcctty*	at vcc?
vds*	at cbus?
vdsp*	at vds?
vsw*	at cbus?
vnet*	at vsw?
vldc*	at cbus?
vldcp*	at vldc?

## Lance Ethernet - AMD7990
le*		at sbus?
ledma*		at sbus?
le*		at ledma?
lebuffer*	at sbus?
le*		at lebuffer?

# Quad-ethernet glue device, and sub-devices
qec*		at sbus?
qe*		at qec?
be*		at qec?

hme*		at sbus?
ti*		at sbus?
gem*		at sbus?

# Magma serial/parallel port devices
magma*		at sbus?
mtty*		at magma?
mbpp*		at magma?

# Magma serial/parallel port devices
spif*		at sbus?
stty*		at spif?
sbpp*		at spif?

pciide*	at pci? flags 0x0000
wd*	at pciide? flags 0x0a00
atapiscsi* at pciide?

wdc*	at pcmcia?
wd*	at wdc? flags 0x0000

#
# Note the flags on the esp entries below, that work around
# deficiencies in the current driver:
#	bits 0-7:  disable disconnect/reselect for the corresponding target
#	bits 8-15: disable synch negotiation for target [bit-8]
#	Note: targets 4-7 have disconnect/reselect enabled on the premise
#	      that tape devices normally have one of these targets. Tape
#	      devices should be allowed to disconnect for the SCSI bus
#	      to operate acceptably.
#
dma*	at sbus?				# SBus
esp*	at dma?					# SBus
esp*	at sbus?
qlw*	at sbus?
qla*	at sbus?

# SCSI bus layer.  SCSI devices attach to the SCSI bus, which attaches
# to the underlying hardware controller.

# These entries find devices on all SCSI busses and assign
# unit numers dynamically.
scsibus*	at scsi?
sd*		at scsibus?		# SCSI disks
st*		at scsibus?		# SCSI tapes
cd*		at scsibus?		# SCSI CD-ROMs
ch*		at scsibus?		# SCSI changer devices
safte*		at scsibus?		# SCSI accessed fault-tolerant encl
ses*		at scsibus?		# SCSI enclosure services
uk*		at scsibus?		# unknown SCSI devices

mpath0		at root
emc*		at scsibus?
hds*		at scsibus?
rdac*		at scsibus?
sym*		at scsibus?

# Media Independent Interface (mii) drivers
acphy*	at mii?				# Altima AC101 PHYs
exphy*	at mii?				# 3Com internal PHYs
bmtphy*	at mii?				# Broadcom 10/100 PHYs
brgphy*	at mii?				# Broadcom Gigabit PHYs
eephy*	at mii?				# Marvell 88E1000 series PHY
xmphy*	at mii?				# XaQti XMAC-II PHYs
nsphy*	at mii?				# NS and compatible PHYs
nsphyter*	at mii?			# NS and compatible PHYs
qsphy*	at mii?				# Quality Semi QS6612 PHYs
luphy*	at mii?				# Lucent LU6612 PHY
sqphy*	at mii?				# Seeq 8x220 PHYs
dcphy*	at mii?				# Digital clone PHYs
amphy*	at mii?				# AMD AM79c873 PHYs
icsphy*	at mii?				# ICS 1890 PHYs
iophy*	at mii?				# Intel 82553 PHYs
inphy*	at mii?				# Intel 82555 PHYs
lxtphy*	at mii?				# Level1 LXT970 PHYs
rlphy*	at mii?				# Realtek 8139 internal PHYs
urlphy*	at mii?				# Realtek RTL8150L internal PHY
rgephy*	at mii?				# Realtek 8169S/8110S PHY
gentbi*	at mii?				# Generic 1000BASE-X ten-bit PHY
nsgphy*	at mii?				# NS gigabit PHYs
tqphy*	at mii?				# TDK 78Q212x PHYs
jmphy*	at mii?				# JMicron JMP202/JMP211 PHYs
ipgphy*	at mii?				# IC Plus IP1000A PHYs
ukphy*	at mii?				# Unknown PHYs

# sensors
pcfiic*	at ebus?
iic*	at pcfiic?
alipm*	at pci?
iic*	at alipm?
mbg*	at pci?				# Meinberg Funkuhren radio clocks

adc*	at iic?				# Analog Devices AD7416/AD7417/7418
admtemp* at iic?			# Analog Devices ADM1021
admlc*	at iic?				# Analog Devices ADM1024
admtm*	at iic?				# Analog Devices ADM1025
admtmp*	at iic?				# Analog Devices ADM1030
admtt*	at iic?				# Analog Devices ADM1031
adt*	at iic?				# Analog Devices ADT7460
lm*	at iic?				# LM78/79 and clones
lmenv*	at iic?				# National Semiconductor LM87
lmtemp*	at iic?				# NS LM75/LM77 temperature sensor
maxds*	at iic?				# Maxim DS1631
maxtmp*	at iic?				# Maxim MAX6642/MAX6690
pcfadc*	at iic?				# Philips PCF8591
ecadc*	at iic?				# SUNW,envctrl temperature sensors
spdmem* at iic?				# SPD memory eeproms
tda*	at iic?				# Philips TDA8444

# Framebuffers
agten*		at sbus?		# Fujitsu AG-10e framebuffer
wsdisplay*	at agten?
bwtwo*		at sbus?		# bwtwo monochrome framebuffer
wsdisplay*	at bwtwo?
cgsix*		at sbus?		# cgsix 8-bit accelerated framebuffer
wsdisplay*	at cgsix?
cgthree*	at sbus?		# cgthree 8-bit framebuffer
wsdisplay*	at cgthree?
cgtwelve*	at sbus?		# cgtwelve 24-bit color framebuffer
wsdisplay*	at cgtwelve?
creator*	at mainbus0		# Creator3D/Elite3D framebuffers
creator*	at upa0
wsdisplay*	at creator?
gfxp*		at pci?			# PGX32 framebuffer
wsdisplay*	at gfxp?
ifb*		at pci?			# Expert3D/XVR-500 framebuffers
wsdisplay*	at ifb?
machfb*		at pci?			# PGX/PGX64 framebuffers
wsdisplay*	at machfb?
mgx*		at sbus?		# SMS MGX/MGXPlus framebuffer
wsdisplay*	at mgx?
radeonfb*	at pci?			# XVR-100/300 framebuffer
wsdisplay*	at radeonfb?
raptor*		at pci?			# Raptor framebuffer
wsdisplay*	at raptor?
rfx*		at sbus?		# RasterFlex framebuffer series
wsdisplay*	at rfx?
tvtwo*		at sbus?		# Parallax XVideo/PowerVideo framebuffer
wsdisplay*	at tvtwo?
vgafb*		at pci?			# PCI display (except for Expert3D)
wsdisplay*	at vgafb?
vigra*		at sbus?		# Viagra framebuffer series
wsdisplay*	at vigra?
zx*		at sbus?		# Sun Leo (ZX) framebuffer
wsdisplay*	at zx?

radeondrm*	at pci?			# ATI Radeon DRM driver
drm*		at radeondrm?
wsdisplay*	at radeondrm?

audiocs*	at sbus?

asio*		at sbus?		# Aurora 210SJ
com*		at asio?
apio*		at sbus?		# Aurora 210SJ
lpt*		at apio?

stp*		at sbus?		# STP4020
pcmcia*		at stp?
com*		at pcmcia?		# PCMCIA modems/serial ports
ep*		at pcmcia?		# PCMCIA based 3C5xx ethernet
ne*		at pcmcia?		# PCMCIA based NE2000 ethernet
wi*		at pci?			# WaveLAN IEEE 802.11DS
wi*		at pcmcia?		# WaveLAN IEEE 802.11DS

# ``XBox'' SBus Expansion
xbox*		at sbus?
sbus*		at xbox?

# Floppy controller and drive
fdc*	at sbus?
#fdc*	at ebus?
fd*	at fdc?

# 1-Wire devices
option ONEWIREVERBOSE
owid*	at onewire?			# ID
owsbm*	at onewire?			# Smart Battery Monitor
owtemp* at onewire?			# Temperature
owctr*	at onewire?			# Counter device

pseudo-device	hotplug	1		# devices hot plugging
pseudo-device	wsmux	2		# mouse & keyboard multiplexor


code:
#	$OpenBSD: GENERIC.MP,v 1.4 2008/07/12 14:26:07 kettenis Exp $

include "arch/sparc64/conf/GENERIC"

option	MULTIPROCESSOR
#option	MP_LOCKDEBUG

cpu*	at mainbus?
cpu*	at ssm?
cpu*	at cmp?
cpu*	at core?


code:
#	$OpenBSD: Makefile.sparc64,v 1.72 2015/01/13 01:12:50 deraadt Exp $

# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
#
# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
# DEBUG is set to -g by config if debugging is requested (config -g).
# PROF is set to -pg by config if profiling is requested (config -p).

.include <bsd.own.mk>

SIZE?=	size
STRIP?=	strip

# source tree is located via $S relative to the compilation directory
.ifndef S
S!=	cd ../../../..; pwd
.endif

_machdir?=	$S/arch/${_mach}
_archdir?=	$S/arch/${_arch}

INCLUDES=	-nostdinc -I$S -I. -I$S/arch
CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP
CWARNFLAGS=	-Werror -Wall -Wimplicit-function-declaration \
		-Wno-main -Wno-uninitialized \
		-Wframe-larger-than=2047

CMACHFLAGS=	-Wa,-Av9b, -mno-fpu
CMACHFLAGS+=	-fno-builtin-printf -fno-builtin-snprintf \
		-fno-builtin-vsnprintf -fno-builtin-log \
		-fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS}
.if ${IDENT:M-DNO_PROPOLICE}
CMACHFLAGS+=	-fno-stack-protector
.endif

COPTS?=		-O2
CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
LDSCRIPT=	${_machdir}/conf/ld.script
LINKFLAGS=	-n -T ${LDSCRIPT} --warn-common -nopie

.if ${IDENT:M-DDDB_STRUCT}
DB_STRUCTINFO=	db_structinfo.h
.else
DB_STRUCTINFO=
.endif

HOSTCC?=	${CC}
HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
HOSTED_CFLAGS=	${CFLAGS}
HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<

NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<

%OBJS

%CFILES

%SFILES

# load lines for config "xxx" will be emitted as:
# xxx: ${SYSTEM_DEP} swapxxx.o
#	${SYSTEM_LD_HEAD}
#	${SYSTEM_LD} swapxxx.o
#	${SYSTEM_LD_TAIL}
SYSTEM_HEAD=	locore.o param.o ioconf.o
SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS}
SYSTEM_DEP=	Makefile ${SYSTEM_OBJ} ${LDSCRIPT}
SYSTEM_LD_HEAD=	@rm -f $@
SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@

DEBUG?=
.if ${DEBUG} == "-g"
LINKFLAGS+=	-X
STRIPFLAGS=	-g -x
SYSTEM_LD_TAIL+=; \
		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
.else
LINKFLAGS+=	-S -x
.endif

%LOAD

# cc's -MD puts the source and output paths in the dependency file;
# since those are temp files here we need to fix it up.  It also
# puts the file in /tmp, so we use -MF to put it in the current
# directory as assym.P and then generate assym.d from it with a
# good target name
assym.h: $S/kern/genassym.sh Makefile \
	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
	sed '1s/.*/assym.h: \\/' assym.P > assym.d
	sort -u assym.h.tmp > assym.h

param.c: $S/conf/param.c
	rm -f param.c
	cp $S/conf/param.c .

param.o: param.c Makefile
	${NORMAL_C}

mcount.o: $S/lib/libkern/mcount.c Makefile
	${NORMAL_C_NOP}

ioconf.o: ioconf.c
	${NORMAL_C}

vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
	sh $S/conf/newvers.sh
	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c

clean::
	rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
	    [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}

lint:
	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
	    ${CFILES} ioconf.c param.c | \
	    grep -v 'static function .* unused'

depend:
	@touch $@

tags:
	@echo "see $S/kern/Makefile for tags"

db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl
	${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
	objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
	rm -f db_structinfo.o

locore.o: ${_machdir}/${_mach}/locore.s assym.h
hvcall.o in_cksum.o mutex.o: assym.h

# The install target can be redefined by putting a
# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
MACHINE_NAME!=  uname -n
install: install-kernel-${MACHINE_NAME}
.if !target(install-kernel-${MACHINE_NAME}})
install-kernel-${MACHINE_NAME}:
	cmp -s bsd /bsd || ln -f /bsd /obsd
	cp bsd /nbsd
	mv /nbsd /bsd
.endif

# pull in the dependency information
.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
 ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
.endif
.ifnmake clean
. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
.  if exists(${o:R}.d)
.   include "${o:R}.d"
.  elif exists($o)
    .PHONY: $o
.  endif
. endfor
.endif

%RULES


code:
#	$OpenBSD: RAMDISK,v 1.118 2015/07/17 22:52:29 tedu Exp $

machine		sparc64
maxusers	4

option		TIMEZONE=0
option		DST=0
option		SMALL_KERNEL
option		NO_PROPOLICE
option		BOOT_CONFIG

option		RAMDISK_HOOKS
option		MINIROOTSIZE=6144

option		PCIVERBOSE

option		FFS
option		FFS2
option		NFSCLIENT
option		CD9660
option		MSDOSFS
option		UDF
option		INET6
option		CRYPTO

option		WSEMUL_SUN	# provide sun terminal emulation; required
option		WSEMUL_NO_VT100	# do not provide vt100 terminal emulation
option		WSEMUL_DUMB

option		SUN4US
option		SUN4V

config		bsd root on rd0a

mainbus0	at root
cpu0		at mainbus0
ssm*		at mainbus0
cpu0		at ssm?
cmp*		at mainbus0
cpu0		at cmp?
core*		at cmp?
cpu0		at core?

sbus*		at mainbus0
upa0		at mainbus0
central0	at mainbus0
fhc0		at central0
fhc*		at mainbus0
psycho*		at mainbus0
pci*		at psycho?
schizo*		at mainbus0
schizo*		at ssm?
pci*		at schizo?
pyro*		at mainbus0
pci*		at pyro?
vpci*		at mainbus0
pci*		at vpci?
pci*		at ppb?
ppb*		at pci?
ebus*		at mainbus0
ebus*		at pci?
vbus0		at mainbus0
sbbc*		at pci?
cbus*		at vbus?

cardbus*	at cardslot?
pcmcia*		at cardslot?
cbb*		at pci?
cardslot*	at cbb?

ath*		at pci?			# Atheros AR5k (802.11a/b/g)
ath*		at cardbus?		# Atheros AR5k (802.11a/b/g)
athn*		at pci?			# Atheros AR9k (802.11a/g/n)
athn*		at cardbus?		# Atheros AR9k (802.11a/g/n)
ral*		at pci?			# Ralink RT2500/RT2501/RT2600
ral*		at cardbus?		# Ralink RT2500/RT2501/RT2600
com*		at pcmcia?		# PCMCIA modems/serial ports
ep*		at pcmcia?		# PCMCIA based 3C5xx ethernet
ne*		at pcmcia?		# PCMCIA based NE2000 ethernet
wi*		at pci?			# WaveLAN IEEE 802.11DS
wi*		at pcmcia?		# WaveLAN IEEE 802.11DS

hme*		at pci?			# Sun Happy Meal 10/100
gem*		at pci?			# Sun GEM 10/100/Gigabit
cas*		at pci?			# Sun Cassini 100/Gigabit
ti*		at pci?			# Alteon Tigon 1Gb ethernet
skc*		at pci?			# SysKonnect GEnesis 984x
sk*		at skc?			#  each port of above
mskc*		at pci?			# Marvell Yukon-2
msk*		at mskc?		#  each port of above
fxp*		at pci?			# EtherExpress 10/100B ethernet
xl*		at pci?			# 3C9xx ethernet
xl*		at cardbus?		# 3C9xx ethernet
pcn*		at pci?			# AMD PCnet-PCI Ethernet
de*		at pci?			# DC21X4X-based ethernet
dc*		at pci?			# 21143, "tulip" clone ethernet
dc*		at cardbus?		# 21143, "tulip" clone ethernet
ne*		at pci?			# NE2000-compat ethernet cards
epic*		at pci?			# SMC EPIC/100 ethernet
em*		at pci?			# Intel Pro/1000 ethernet
ix*		at pci?			# Intel 82598EB 10Gb ethernet
bge*		at pci?			# Broadcom BCM570x (aka Tigon3)
bnx*		at pci?			# Broadcom BCM5706/5708 GigE
stge*		at pci?			# Sundance TC9021 GigE
rl*		at pci?			# Realtek 81[23]9 ethernet
vr*		at pci?			# VIA Rhine ethernet
re*		at pci?			# Realtek 8169/8169S/8110S
re*		at cardbus?		# Realtek 8169/8169S/8110S
jme*		at pci?			# JMicron JMC250/JMC260 Ethernet

auxio*		at ebus?
auxio*		at sbus?
clock*		at sbus?		# Mostek clock
clock*		at ebus?
clock0		at fhc?
rtc*		at ebus?		# DS1287/M5819 clock
timer*		at mainbus0		# Timer chip

vcons0		at vbus?
vrtc0		at vbus?
vrng0		at vbus?
vdsk*		at cbus?
vnet*		at cbus?

le*		at sbus?
ledma*		at sbus?
le*		at ledma?
lebuffer*	at sbus?
le*		at lebuffer?

qec*		at sbus?
qe*		at qec?
be*		at qec?

hme*		at sbus?
ti*		at sbus?
gem*		at sbus?

pciide*		at pci? flags 0x0000
wd*		at pciide? flags 0x0a00
atapiscsi*	at pciide?

# The flags on the esp entries below work around deficiencies in the driver:
#	bits 0-7:  disable disconnect/reselect for the corresponding target
#	bits 8-15: disable synch negotiation for target [bit-8]
#	Note: targets 4-7 have disconnect/reselect enabled on the premise
#	      that tape devices normally have one of these targets. Tape
#	      devices should be allowed to disconnect for the SCSI bus
#	      to operate acceptably.
dma*		at sbus?		# SBus
esp*		at dma?			# SBus
esp*		at sbus?
qla*		at sbus?
qlw*		at sbus?
softraid0	at root

ahc*		at pci?
siop*		at pci?
qlw*		at pci?
qla*		at pci?
option		QLE_NOFIRMWARE
qle*		at pci?
mpi*		at pci?
mpii*		at pci?
sili*		at pci?
arc*		at pci?
jmb*		at pci?
ahci*		at jmb?
pciide*		at jmb?
ahci*		at pci?

scsibus*	at scsi?
sd*		at scsibus?		# SCSI disks
cd*		at scsibus?		# SCSI CD-ROMs

acphy*		at mii?			# Altima AC101 PHYs
exphy*		at mii?			# 3Com internal PHYs
bmtphy*		at mii?			# Broadcom 10/100 PHYs
brgphy*		at mii?			# Broadcom Gigabit PHYs
eephy*		at mii?			# Marvell 88E1000 series PHY
xmphy*		at mii?			# XaQti XMAC-II PHYs
nsphy*		at mii?			# NS and compatible PHYs
nsphyter*	at mii?			# NS and compatible PHYs
qsphy*		at mii?			# Quality Semi QS6612 PHYs
luphy*		at mii?			# Lucent LU6612 PHY
sqphy*		at mii?			# Seeq 8x220 PHYs
dcphy*		at mii?			# Digital clone PHYs
amphy*		at mii?			# AMD AM79c873 PHYs
icsphy*		at mii?			# ICS 1890 PHYs
iophy*		at mii?			# Intel 82553 PHYs
inphy*		at mii?			# Intel 82555 PHYs
lxtphy*		at mii?			# Level1 LXT970 PHYs
rlphy*		at mii?			# Realtek 8139 internal PHYs
urlphy*		at mii?			# Realtek RTL8150L internal PHY
rgephy*		at mii?			# Realtek 8169S/8110S PHY
gentbi*		at mii?			# Generic 1000BASE-X ten-bit PHY
nsgphy*		at mii?			# NS gigabit PHYs
jmphy*		at mii?			# JMicron JMP202/JMP211 PHYs
ipgphy*		at mii?			# IC Plus IP1000A PHYs
ukphy*		at mii?			# Unknown PHYs

ohci*		at pci?
ohci*		at cardbus?
uhci*		at pci?
ehci*		at pci?
ehci*		at cardbus?
xhci*		at pci?
usb*		at ohci?
usb*		at uhci?
usb*		at ehci?
usb*		at xhci?

uhub*		at usb?
uhub*		at uhub?
uhidev*		at uhub?		# Human Interface Devices
ukbd*		at uhidev?		# USB keyboard
wskbd*		at ukbd?
umass*		at uhub?
aue*		at uhub?		# ADMtek AN986 Pegasus Ethernet
axe*		at uhub?		# ASIX Electronics AX88172 USB Ethernet
axen*		at uhub?		# ASIX Electronics AX88179 USB Ethernet
cue*		at uhub?		# CATC USB-EL1201A based Ethernet
kue*		at uhub?		# Kawasaki KL5KUSB101B based Ethernet
smsc*		at uhub?		# SMSC LAN95xx Ethernet
cdce*		at uhub?		# CDC Ethernet
udav*		at uhub?		# Davicom DM9601 based Ethernet
mos*		at uhub?		# MOSCHIP MCS7730/7830 10/100 Ethernet
ural*		at uhub?		# Ralink RT2500USB
rum*		at uhub?		# Ralink RT2501USB/RT2601USB
url*		at uhub?		# Realtek RTL8150L based adapters

sab*		at ebus?
sabtty*		at sab?
com*		at ebus?
comkbd*		at ebus?
wskbd*		at comkbd?

zs*		at sbus?
zs*		at fhc?
zstty*		at zs?
zskbd*		at zs?
wskbd*		at zskbd?

pckbc*		at ebus?		# controller
pckbd*		at pckbc?		#  ps2 keyboard
wskbd*		at pckbd?		#   generic keyboard layer

agten*		at sbus?		# Fujitsu AG-10e framebuffer
wsdisplay*	at agten?
bwtwo*		at sbus?		# bwtwo monochrome framebuffer
wsdisplay*	at bwtwo?
cgsix*		at sbus?		# cgsix 8-bit accelerated framebuffer
wsdisplay*	at cgsix?
cgthree*	at sbus?		# cgthree 8-bit framebuffer
wsdisplay*	at cgthree?
cgtwelve*	at sbus?		# cgtwelve 24-bit color framebuffer
wsdisplay*	at cgtwelve?
creator*	at mainbus0		# Creator3D/Elite3D framebuffers
creator*	at upa0
wsdisplay*	at creator?
gfxp*		at pci?			# PGX32 framebuffer
wsdisplay*	at gfxp?
ifb*		at pci?			# Expert3D/XVR-500 framebuffers
wsdisplay*	at ifb?
machfb*		at pci?			# PGX/PGX64 framebuffers
wsdisplay*	at machfb?
mgx*		at sbus?		# SMS MGX/MGXPlus framebuffer
wsdisplay*	at mgx?
radeonfb*	at pci?			# XVR-100 framebuffer
wsdisplay*	at radeonfb?
raptor*		at pci?			# Raptor framebuffer
wsdisplay*	at raptor?
rfx*		at sbus?		# RasterFlex framebuffer series
wsdisplay*	at rfx?
tvtwo*		at sbus?		# Parallax XVideo/PowerVideo framebuffer
wsdisplay*	at tvtwo?
vgafb*		at pci?			# PCI display
wsdisplay*	at vgafb?
vigra*		at sbus?		# Viagra framebuffer series
wsdisplay*	at vigra?
zx*		at sbus?		# Sun Leo (ZX) framebuffer
wsdisplay*	at zx?

xbox*		at sbus?
sbus*		at xbox?

prtc0		at mainbus0
pcons0		at mainbus0
wsdisplay*	at pcons?

pseudo-device	rd 1
pseudo-device	loop 1
pseudo-device	bpfilter 1
pseudo-device	vlan
pseudo-device	bio 1


code:
#	$OpenBSD: RAMDISKU1,v 1.23 2015/07/17 22:52:29 tedu Exp $

machine		sparc64
maxusers	4

option		TIMEZONE=0
option		DST=0
option		SMALL_KERNEL
option		NO_PROPOLICE
option		BOOT_CONFIG

option		RAMDISK_HOOKS
option		MINIROOTSIZE=6144

option		FFS

option		WSEMUL_SUN	# provide sun terminal emulation; required
option		WSEMUL_NO_VT100	# do not provide vt100 terminal emulation

config		bsd root on rd0a

mainbus0	at root
cpu0		at mainbus0

sbus*		at mainbus0				# Ultra 1
clock*		at sbus?				# Mostek clock
timer*		at mainbus0				# Timer chip

le*		at sbus?			# Lance Ethernet - AMD7990
ledma*		at sbus?
le*		at ledma?
lebuffer*	at sbus?
le*		at lebuffer?
hme*		at sbus?
gem*		at sbus?

# The flags on the esp entries below work around deficiencies in the driver:
#	bits 0-7:  disable disconnect/reselect for the corresponding target
#	bits 8-15: disable synch negotiation for target [bit-8]
#	Note: targets 4-7 have disconnect/reselect enabled on the premise
#	      that tape devices normally have one of these targets. Tape
#	      devices should be allowed to disconnect for the SCSI bus
#	      to operate acceptably.
dma*		at sbus?
esp*		at dma?
esp*		at sbus?

scsibus*	at scsi?
sd*		at scsibus?
#cd*		at scsibus?

nsphy*		at mii?			# NS and compatible PHYs
qsphy*		at mii?			# Quality Semi QS6612 PHYs
ukphy*		at mii?			# Unknown PHYs

zs*		at sbus?
zstty*		at zs?
zskbd*		at zs?
wskbd*		at zskbd?

agten*		at sbus?		# Fujitsu AG-10e framebuffer
wsdisplay*	at agten?
bwtwo*		at sbus?		# bwtwo monochrome framebuffer
wsdisplay*	at bwtwo?
cgsix*		at sbus?		# cgsix 8-bit accelerated framebuffer
wsdisplay*	at cgsix?
cgthree*	at sbus?		# cgthree 8-bit framebuffer
wsdisplay*	at cgthree?
cgtwelve*	at sbus?		# cgtwelve 24-bit color framebuffer
wsdisplay*	at cgtwelve?
creator*	at mainbus0		# Creator3D/Elite3D framebuffers
wsdisplay*	at creator?
mgx*		at sbus?		# SMS MGX/MGXPlus framebuffer
wsdisplay*	at mgx?
rfx*		at sbus?		# RasterFlex framebuffer series
wsdisplay*	at rfx?
tvtwo*		at sbus?		# Parallax XVideo/PowerVideo framebuffer
wsdisplay*	at tvtwo?
vigra*		at sbus?		# Viagra framebuffer series
wsdisplay*	at vigra?
zx*		at sbus?		# Sun Leo (ZX) framebuffer
wsdisplay*	at zx?

xbox*		at sbus?
sbus*		at xbox?

pcons0		at mainbus0		# PROM console

pseudo-device	rd 1
pseudo-device	loop 1


code:
#	$OpenBSD: RAMDISKU5,v 1.20 2015/07/17 22:52:29 tedu Exp $

machine		sparc64
maxusers	4

option		TIMEZONE=0
option		DST=0

option		SMALL_KERNEL
option		NO_PROPOLICE
option		BOOT_CONFIG

option		RAMDISK_HOOKS
option		MINIROOTSIZE=6144

option		FFS

option		WSEMUL_SUN	# provide sun terminal emulation; required
option		WSEMUL_NO_VT100	# do not provide vt100 terminal emulation

config		bsd root on rd0a

mainbus0	at root
cpu0		at mainbus0

upa0		at mainbus0
schizo*		at mainbus0
pci*		at schizo?
psycho*		at mainbus0
pci*		at psycho?		# Ultra 5
pci*		at ppb?
ppb*		at pci?
ebus*		at pci?

hme*		at pci?
gem*		at pci?

auxio*		at ebus?
clock*		at ebus?

pcons0		at mainbus0		# PROM console

timer*		at mainbus0		# Timer chip (some systems)

pciide*		at pci? flags 0x0000
wd*		at pciide? flags 0x0a00
atapiscsi*	at pciide?

siop*		at pci?

scsibus*	at scsi?
sd*		at scsibus?
#cd*		at scsibus?

nsphy*		at mii?			# NS and compatible PHYs
qsphy*		at mii?			# Quality Semi QS6612 PHYs
ukphy*		at mii?			# Unknown PHYs

ohci*		at pci ?
uhci*		at pci?
usb*		at ohci?
usb*		at uhci?

uhub*		at usb?
uhub*		at uhub?
uhidev*		at uhub?		# Human Interface Devices
ukbd*		at uhidev?		# USB Keyboard
wskbd*		at ukbd?

sab*		at ebus?
sabtty*		at sab?
com*		at ebus?
comkbd*		at ebus?
wskbd*		at comkbd?

pckbc*		at ebus?		# controller
pckbd*		at pckbc?		#  ps2 keyboard
wskbd*		at pckbd?		#    generic keyboard layer

creator*	at upa0			# Creator3D/Elite3D framebuffers
wsdisplay*	at creator?
gfxp*		at pci?			# PGX32 framebuffer
wsdisplay*	at gfxp?
machfb*		at pci?			# PGX/PGX64 framebuffers
wsdisplay*	at machfb?
raptor*		at pci?			# Raptor framebuffer
wsdisplay*	at raptor?
vgafb*		at pci?
wsdisplay*	at vgafb?

pseudo-device	rd 1
pseudo-device	loop 1