code:
/*	$OpenBSD: process_machdep.c,v 1.12 2014/01/26 17:40:09 miod Exp $	*/
/*	$NetBSD: process_machdep.c,v 1.7 1996/07/11 20:14:21 cgd Exp $	*/

/*-
 * Copyright (c) 1998 Doug Rabson
 * 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.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
 */
/*
 * Copyright (c) 1994 Christopher G. Demetriou
 * 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 Christopher G. Demetriou.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This file may seem a bit stylized, but that so that it's easier to port.
 * Functions to be implemented here are:
 *
 * process_read_regs(proc, regs)
 *	Get the current user-visible register set from the process
 *	and copy it into the regs structure (<machine/reg.h>).
 *	The process is stopped at the time read_regs is called.
 *
 * process_write_regs(proc, regs)
 *	Update the current register set from the passed in regs
 *	structure.  Take care to avoid clobbering special CPU
 *	registers or privileged bits in the PSL.
 *	The process is stopped at the time write_regs is called.
 *
 * process_sstep(proc)
 *	Arrange for the process to trap after executing a single instruction.
 *
 * process_set_pc(proc)
 *	Set the process's program counter.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/vnode.h>
#include <sys/ptrace.h>
#include <machine/reg.h>
#include <machine/frame.h>

#include <alpha/alpha/db_instruction.h>

#define	process_frame(p)	((p)->p_md.md_tf)
#define	process_pcb(p)		(&(p)->p_addr->u_pcb)
#define	process_fpframe(p)	(&(process_pcb(p)->pcb_fp))

int
process_read_regs(p, regs)
	struct proc *p;
	struct reg *regs;
{

	frametoreg(process_frame(p), regs);
	regs->r_regs[R_ZERO] = process_frame(p)->tf_regs[FRAME_PC];
	regs->r_regs[R_SP] = process_pcb(p)->pcb_hw.apcb_usp;
	return (0);
}

int
process_read_fpregs(p, regs)
	struct proc *p;
	struct fpreg *regs;
{

	if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
		fpusave_proc(p, 1);

	bcopy(process_fpframe(p), regs, sizeof(struct fpreg));
	return (0);
}

#ifdef PTRACE

int
process_write_regs(p, regs)
	struct proc *p;
	struct reg *regs;
{

	regtoframe(regs, process_frame(p));
	process_frame(p)->tf_regs[FRAME_PC] = regs->r_regs[R_ZERO];
	process_pcb(p)->pcb_hw.apcb_usp = regs->r_regs[R_SP];
	return (0);
}

int
process_set_pc(p, addr)
	struct proc *p;
	caddr_t addr;
{
	struct trapframe *frame = process_frame(p);

	frame->tf_regs[FRAME_PC] = (u_int64_t)addr;
	return (0);
}

int
process_write_fpregs(p, regs)
	struct proc *p;
	struct fpreg *regs;
{

	if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
		fpusave_proc(p, 0);

	bcopy(regs, process_fpframe(p), sizeof(struct fpreg));
	return (0);
}

/*
 * Single stepping infrastructure.
 */
int ptrace_set_bpt(struct proc *p, struct mdbpt *bpt);
int ptrace_clear_bpt(struct proc *p, struct mdbpt *bpt);
int ptrace_read_int(struct proc *, vaddr_t, u_int32_t *);
int ptrace_write_int(struct proc *, vaddr_t, u_int32_t);
u_int64_t ptrace_read_register(struct proc *p, int regno);

int
ptrace_read_int(struct proc *p, vaddr_t addr, u_int32_t *v)
{
	struct iovec iov;
	struct uio uio;

	iov.iov_base = (caddr_t) v;
	iov.iov_len = sizeof(u_int32_t);
	uio.uio_iov = &iov;
	uio.uio_iovcnt = 1;
	uio.uio_offset = (off_t)addr;
	uio.uio_resid = sizeof(u_int32_t);
	uio.uio_segflg = UIO_SYSSPACE;
	uio.uio_rw = UIO_READ;
	uio.uio_procp = p;
	return process_domem(curproc, p, &uio, PT_READ_I);
}

int
ptrace_write_int(struct proc *p, vaddr_t addr, u_int32_t v)
{
	struct iovec iov;
	struct uio uio;

	iov.iov_base = (caddr_t) &v;
	iov.iov_len = sizeof(u_int32_t);
	uio.uio_iov = &iov;
	uio.uio_iovcnt = 1;
	uio.uio_offset = (off_t)addr;
	uio.uio_resid = sizeof(u_int32_t);
	uio.uio_segflg = UIO_SYSSPACE;
	uio.uio_rw = UIO_WRITE;
	uio.uio_procp = p;
	return process_domem(curproc, p, &uio, PT_WRITE_I);
}

u_int64_t
ptrace_read_register(struct proc *p, int regno)
{
	static int reg_to_frame[32] = {
		FRAME_V0,
		FRAME_T0,
		FRAME_T1,
		FRAME_T2,
		FRAME_T3,
		FRAME_T4,
		FRAME_T5,
		FRAME_T6,
		FRAME_T7,

		FRAME_S0,
		FRAME_S1,
		FRAME_S2,
		FRAME_S3,
		FRAME_S4,
		FRAME_S5,
		FRAME_S6,

		FRAME_A0,
		FRAME_A1,
		FRAME_A2,
		FRAME_A3,
		FRAME_A4,
		FRAME_A5,

		FRAME_T8,
		FRAME_T9,
		FRAME_T10,
		FRAME_T11,
		FRAME_RA,
		FRAME_T12,
		FRAME_AT,
		FRAME_GP,
		FRAME_SP,
		-1,		/* zero */
	};

	if (regno == R_ZERO)
		return 0;

	return p->p_md.md_tf->tf_regs[reg_to_frame[regno]];
}

int
ptrace_clear_bpt(struct proc *p, struct mdbpt *bpt)
{
	return ptrace_write_int(p, bpt->addr, bpt->contents);
}

int
ptrace_set_bpt(struct proc *p, struct mdbpt *bpt)
{
	int error;
	u_int32_t bpins = 0x00000080;
	error = ptrace_read_int(p, bpt->addr, &bpt->contents);
	if (error)
		return error;
	return ptrace_write_int(p, bpt->addr, bpins);
}

int
process_sstep(struct proc *p, int sstep)
{
	int error;
	vaddr_t pc = p->p_md.md_tf->tf_regs[FRAME_PC];
	alpha_instruction ins;
	vaddr_t addr[2];
	int count = 0;

	if (sstep == 0) {
		/* clearing the breakpoint */
		if (p->p_md.md_flags & MDP_STEP2) {
			ptrace_clear_bpt(p, &p->p_md.md_sstep[1]);
			ptrace_clear_bpt(p, &p->p_md.md_sstep[0]);
			p->p_md.md_flags &= ~MDP_STEP2;
		} else if (p->p_md.md_flags & MDP_STEP1) {
			ptrace_clear_bpt(p, &p->p_md.md_sstep[0]);
			p->p_md.md_flags &= ~MDP_STEP1;
		}
		return (0);
	}
#ifdef DIAGNOSTIC
	if (p->p_md.md_flags & (MDP_STEP1|MDP_STEP2))
		panic("process_sstep: step breakpoints not removed");
#endif
	error = ptrace_read_int(p, pc, &ins.bits);
	if (error)
		return (error);

	switch (ins.branch_format.opcode) {
	case op_j:
		/* Jump: target is register value */
		addr[0] = ptrace_read_register(p, ins.jump_format.rb) & ~3;
		count = 1;
		break;

	case op_br:
	case op_fbeq:
	case op_fblt:
	case op_fble:
	case op_bsr:
	case op_fbne:
	case op_fbge:
	case op_fbgt:
	case op_blbc:
	case op_beq:
	case op_blt:
	case op_ble:
	case op_blbs:
	case op_bne:
	case op_bge:
	case op_bgt:
		/* Branch: target is pc+4+4*displacement */
		addr[0] = pc + 4;
		addr[1] = pc + 4 + 4 * ins.branch_format.displacement;
		count = 2;
		break;

	default:
		addr[0] = pc + 4;
		count = 1;
	}

	if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
		fpusave_proc(p, 0);
	p->p_md.md_sstep[0].addr = addr[0];
	error = ptrace_set_bpt(p, &p->p_md.md_sstep[0]);
	if (error)
		return (error);
	if (count == 2) {
		p->p_md.md_sstep[1].addr = addr[1];
		error = ptrace_set_bpt(p, &p->p_md.md_sstep[1]);
		if (error) {
			ptrace_clear_bpt(p, &p->p_md.md_sstep[0]);
			return (error);
		}
		p->p_md.md_flags |= MDP_STEP2;
	} else
		p->p_md.md_flags |= MDP_STEP1;

	return (0);
}

#endif	/* PTRACE */

license: unknown


code:
/* $OpenBSD: prom.c,v 1.16 2014/12/18 10:50:02 dlg Exp $ */
/* $NetBSD: prom.c,v 1.39 2000/03/06 21:36:05 thorpej Exp $ */

/*
 * Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University
 * All Rights Reserved.
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie Mellon
 * the rights to redistribute these changes.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <uvm/uvm_extern.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/mutex.h>

#include <machine/cpu.h>
#include <machine/rpb.h>
#define	ENABLEPROM
#include <machine/prom.h>

#include <dev/cons.h>

/* XXX this is to fake out the console routines, while booting. */
struct consdev promcons = { NULL, NULL, promcngetc, promcnputc,
			    nullcnpollc, NULL, makedev(23,0), 1 };

struct rpb	*hwrpb;
int		alpha_console;

extern struct prom_vec prom_dispatch_v;

struct mutex prom_lock = MUTEX_INITIALIZER(IPL_HIGH);

void	prom_enter(void);
void	prom_leave(void);

#ifdef _PMAP_MAY_USE_PROM_CONSOLE
int		prom_mapped = 1;	/* Is PROM still mapped? */

pt_entry_t	prom_pte, saved_pte[1];	/* XXX */
static pt_entry_t *prom_lev1map(void);

static pt_entry_t *
prom_lev1map()
{
	struct alpha_pcb *apcb;

	/*
	 * Find the level 1 map that we're currently running on.
	 */
	apcb = (struct alpha_pcb *)ALPHA_PHYS_TO_K0SEG(curpcb);

	return ((pt_entry_t *)ALPHA_PHYS_TO_K0SEG(apcb->apcb_ptbr << PGSHIFT));
}
#endif /* _PMAP_MAY_USE_PROM_CONSOLE */

void
init_prom_interface(struct rpb *rpb)
{
	struct crb *c;

	c = (struct crb *)((char *)rpb + rpb->rpb_crb_off);

	prom_dispatch_v.routine_arg = c->crb_v_dispatch;
	prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
}

void
init_bootstrap_console()
{
	char buf[4];

	init_prom_interface(hwrpb);

	prom_getenv(PROM_E_TTY_DEV, buf, 4);
	alpha_console = buf[0] - '0';

	/* XXX fake out the console routines, for now */
	cn_tab = &promcons;
}

#ifdef _PMAP_MAY_USE_PROM_CONSOLE
static void prom_cache_sync(void);
#endif

void
prom_enter(void)
{
	mtx_enter(&prom_lock);

#ifdef _PMAP_MAY_USE_PROM_CONSOLE
	/*
	 * If we have not yet switched out of the PROM's context
	 * (i.e. the first one after alpha_init()), then the PROM
	 * is still mapped, regardless of the `prom_mapped' setting.
	 */
	if (prom_mapped == 0 && curpcb != 0) {
		if (!pmap_uses_prom_console())
			panic("prom_enter");
		{
			pt_entry_t *lev1map;

			lev1map = prom_lev1map();	/* XXX */
			saved_pte[0] = lev1map[0];	/* XXX */
			lev1map[0] = prom_pte;		/* XXX */
		}
		prom_cache_sync();			/* XXX */
	}
#endif
}

void
prom_leave(void)
{
#ifdef _PMAP_MAY_USE_PROM_CONSOLE
	/*
	 * See comment above.
	 */
	if (prom_mapped == 0 && curpcb != 0) {
		if (!pmap_uses_prom_console())
			panic("prom_leave");
		{
			pt_entry_t *lev1map;

			lev1map = prom_lev1map();	/* XXX */
			lev1map[0] = saved_pte[0];	/* XXX */
		}
		prom_cache_sync();			/* XXX */
	}
#endif

	mtx_leave(&prom_lock);
}

#ifdef _PMAP_MAY_USE_PROM_CONSOLE
static void
prom_cache_sync(void)
{
	ALPHA_TBIA();
	alpha_pal_imb();
}
#endif

/*
 * promcnputc:
 *
 * Remap char before passing off to prom.
 *
 * Prom only takes 32 bit addresses. Copy char somewhere prom can
 * find it. This routine will stop working after pmap_rid_of_console
 * is called in alpha_init. This is due to the hard coded address
 * of the console area.
 */
void
promcnputc(dev_t dev, int c)
{
	prom_return_t ret;
	unsigned char *to = (unsigned char *)0x20000000;

	prom_enter();	/* lock and map prom */
	*to = c;

	do {
		ret.bits = prom_putstr(alpha_console, to, 1);
	} while ((ret.u.retval & 1) == 0);

	prom_leave();		/* unmap prom and unlock */
}

/*
 * promcngetc:
 *
 * Wait for the prom to get a real char and pass it back.
 */
int
promcngetc(dev_t dev)
{
	prom_return_t ret;

	for (;;) {
		prom_enter();
		ret.bits = prom_getc(alpha_console);
		prom_leave();
		if (ret.u.status == 0 || ret.u.status == 1)
			return (ret.u.retval);
	}
}

/*
 * promcnlookc:
 *
 * See if prom has a real char and pass it back.
 */
int
promcnlookc(dev_t dev, char *cp)
{
	prom_return_t ret;

	prom_enter();
	ret.bits = prom_getc(alpha_console);
	prom_leave();
	if (ret.u.status == 0 || ret.u.status == 1) {
		*cp = ret.u.retval;
		return 1;
	} else
		return 0;
}

int
prom_getenv(int id, char *buf, int len)
{
	unsigned char *to = (unsigned char *)0x20000000;
	prom_return_t ret;

	prom_enter();
	ret.bits = prom_getenv_disp(id, to, len);
	bcopy(to, buf, len);
	prom_leave();

	if (ret.u.status & 0x4)
		ret.u.retval = 0;
	buf[ret.u.retval] = '\0';

	return (ret.bits);
}

void
prom_halt(int halt)
{
	struct pcs *p;

	/*
	 * Turn off interrupts, for sanity.
	 */
	(void) splhigh();

	/*
	 * Set "boot request" part of the CPU state depending on what
	 * we want to happen when we halt.
	 */
	p = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id);
	p->pcs_flags &= ~(PCS_RC | PCS_HALT_REQ);
	if (halt)
		p->pcs_flags |= PCS_HALT_STAY_HALTED;
	else
		p->pcs_flags |= PCS_HALT_WARM_BOOT;

	/*
	 * Halt the machine.
	 */
	alpha_pal_halt();
}

u_int64_t
hwrpb_checksum()
{
	u_int64_t *p, sum;
	int i;

	for (i = 0, p = (u_int64_t *)hwrpb, sum = 0;
	    i < (offsetof(struct rpb, rpb_checksum) / sizeof (u_int64_t));
	    i++, p++)
		sum += *p;

	return (sum);
}

void
hwrpb_primary_init()
{
	struct pcs *p;

	p = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id);

	/* Initialize the primary's HWPCB and the Virtual Page Table Base. */
	bcopy(&proc0.p_addr->u_pcb.pcb_hw, p->pcs_hwpcb,
	    sizeof proc0.p_addr->u_pcb.pcb_hw);
	hwrpb->rpb_vptb = VPTBASE;

	hwrpb->rpb_checksum = hwrpb_checksum();
}

void
hwrpb_restart_setup()
{
	struct pcs *p;

	/* Clear bootstrap-in-progress flag since we're done bootstrapping */
	p = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id);
	p->pcs_flags &= ~PCS_BIP;

	/* when 'c'ontinuing from console halt, do a dump */
	hwrpb->rpb_rest_term = (u_int64_t)&XentRestart;
	hwrpb->rpb_rest_term_val = 0x1;

	hwrpb->rpb_checksum = hwrpb_checksum();

	p->pcs_flags |= (PCS_RC | PCS_CV);
}

u_int64_t
console_restart(struct trapframe *framep)
{
	struct pcs *p;

	/* Clear restart-capable flag, since we can no longer restart. */
	p = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id);
	p->pcs_flags &= ~PCS_RC;

	/* Fill in the missing frame slots */

	framep->tf_regs[FRAME_PS] = p->pcs_halt_ps;
	framep->tf_regs[FRAME_PC] = p->pcs_halt_pc;
	framep->tf_regs[FRAME_T11] = p->pcs_halt_r25;
	framep->tf_regs[FRAME_RA] = p->pcs_halt_r26;
	framep->tf_regs[FRAME_T12] = p->pcs_halt_r27;

	panic("user requested console halt");

	return (1);
}


code:
/* $OpenBSD: prom_disp.s,v 1.7 2008/01/13 20:59:52 kettenis Exp $ */
/* $NetBSD: prom_disp.s,v 1.8 1997/11/03 04:22:03 ross Exp $ */

/*
 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chris G. Demetriou
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

.file	2 __FILE__
.loc	2 __LINE__

#ifndef _LOCORE
#include <machine/asm.h>
#endif

	.globl	prom_dispatch_v
	.comm	prom_dispatch_v,16

	.text
	.align	4

/*
 * Dispatcher routine.  Implements prom's calling machinery, saves our
 * callee-saved registers as required by C.
 */
#define	D_RA			 (7*8)
#define	D_S0			 (8*8)
#define	D_S1			 (9*8)
#define	D_S2			(10*8)
#define	D_S3			(11*8)
#define	D_S4			(12*8)
#define	D_S5			(13*8)
#define	D_S6			(14*8)
#define	DISPATCH_FRAME_SIZE	(15*8)
#define	DISPATCH_REGS		IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5|IM_S6

NESTED(prom_dispatch, 5, DISPATCH_FRAME_SIZE, ra, DISPATCH_REGS, 0)

	ldgp	gp, 0(pv)

	lda	sp, -DISPATCH_FRAME_SIZE(sp)
	stq	ra, D_RA(sp)
	stq	s0, D_S0(sp)
	stq	s1, D_S1(sp)
	stq	s2, D_S2(sp)
	stq	s3, D_S3(sp)
	stq	s4, D_S4(sp)
	stq	s5, D_S5(sp)
	stq	s6, D_S6(sp)

	/* Lord have mercy because.. I would not. */
#define	STUPID_PROM_IS_32_BITS
#ifdef	STUPID_PROM_IS_32_BITS
	ldah	s0, 0x2000(zero)	/* hack for hack */
	lda	s0, (0x2000-8)(s0)

	stq	sp, 0(s0)
	or	s0, zero, sp
#endif	/* STUPID_PROM_IS_32_BITS */

	lda	pv, prom_dispatch_v
	ldq	v0, 0(pv)		/* routine */
	ldq	pv, 8(pv)		/* routine_arg */

	jsr	ra, (v0)

#ifdef	STUPID_PROM_IS_32_BITS
	ldah	s0, 0x2000(zero)	/* hack for hack */
	lda	s0, (0x2000-8)(s0)

	ldq	sp, 0(s0)
#endif	/* STUPID_PROM_IS_32_BITS */

	ldq	ra, D_RA(sp)
	ldq	s0, D_S0(sp)
	ldq	s1, D_S1(sp)
	ldq	s2, D_S2(sp)
	ldq	s3, D_S3(sp)
	ldq	s4, D_S4(sp)
	ldq	s5, D_S5(sp)
	ldq	s6, D_S6(sp)
	lda	sp, DISPATCH_FRAME_SIZE(sp)
	RET
END(prom_dispatch)

#undef	D_RA
#undef	D_S0
#undef	D_S1
#undef	D_S2
#undef	D_S3
#undef	D_S4
#undef	D_S5
#undef	D_S6
#undef	DISPATCH_FRAME_SIZE
#undef	DISPATCH_REGS


code:
/*	$OpenBSD: promcons.c,v 1.16 2010/07/02 17:27:01 nicm Exp $	*/
/*	$NetBSD: promcons.c,v 1.5 1996/11/13 22:20:55 cgd Exp $	*/

/*
 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chris G. Demetriou
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/selinfo.h>
#include <sys/tty.h>
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/types.h>
#include <sys/device.h>
#include <sys/timeout.h>

#include <dev/cons.h>

#include <machine/rpb.h>
#include <machine/prom.h>

static struct  tty *prom_tty[1];
static struct  timeout prom_to;

void promstart(struct tty *);
void promtimeout(void *);
int promparam(struct tty *, struct termios *);
cdev_decl(prom);
cons_decl(prom);

int
promopen(dev, flag, mode, p)
	dev_t dev;
	int flag, mode;
	struct proc *p;
{
	int unit = minor(dev);
	struct tty *tp;
	int s;
	int error = 0, setuptimeout = 0;

	if (unit >= 1)
		return ENXIO;

	s = spltty();

	if (prom_tty[unit] == NULL) {
		tp = prom_tty[unit] = ttymalloc(0);
	} else
		tp = prom_tty[unit];

	tp->t_oproc = promstart;
	tp->t_param = promparam;
	tp->t_dev = dev;
	if ((tp->t_state & TS_ISOPEN) == 0) {
		tp->t_state |= TS_WOPEN|TS_CARR_ON;
		ttychars(tp);
		tp->t_iflag = TTYDEF_IFLAG;
		tp->t_oflag = TTYDEF_OFLAG;
		tp->t_cflag = TTYDEF_CFLAG|CLOCAL;
		tp->t_lflag = TTYDEF_LFLAG;
		tp->t_ispeed = tp->t_ospeed = 9600;
		ttsetwater(tp);

		setuptimeout = 1;
	} else if (tp->t_state&TS_XCLUDE && suser(p, 0) != 0) {
		splx(s);
		return EBUSY;
	}

	splx(s);

	error = (*linesw[tp->t_line].l_open)(dev, tp, p);
	if (error == 0 && setuptimeout) {
		timeout_set(&prom_to, promtimeout, tp);
		timeout_add(&prom_to, 1);
	}
	return error;
}

int
promclose(dev, flag, mode, p)
	dev_t dev;
	int flag, mode;
	struct proc *p;
{
	int unit = minor(dev);
	struct tty *tp = prom_tty[unit];

	timeout_del(&prom_to);
	(*linesw[tp->t_line].l_close)(tp, flag, p);
	ttyclose(tp);
	return 0;
}

int
promread(dev, uio, flag)
	dev_t dev;
	struct uio *uio;
	int flag;
{
	struct tty *tp = prom_tty[minor(dev)];

	return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
}

int
promwrite(dev, uio, flag)
	dev_t dev;
	struct uio *uio;
	int flag;
{
	struct tty *tp = prom_tty[minor(dev)];

	return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}

int
promioctl(dev, cmd, data, flag, p)
	dev_t dev;
	u_long cmd;
	caddr_t data;
	int flag;
	struct proc *p;
{
	int unit = minor(dev);
	struct tty *tp = prom_tty[unit];
	int error;

	error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
	if (error >= 0)
		return error;
	error = ttioctl(tp, cmd, data, flag, p);
	if (error >= 0)
		return error;

	return ENOTTY;
}

int
promparam(tp, t)
	struct tty *tp;
	struct termios *t;
{

	return 0;
}

void
promstart(tp)
	struct tty *tp;
{
	int s;

	s = spltty();
	if (tp->t_state & (TS_TTSTOP | TS_BUSY))
		goto out;
	ttwakeupwr(tp);
	tp->t_state |= TS_BUSY;
	while (tp->t_outq.c_cc != 0)
		promcnputc(tp->t_dev, getc(&tp->t_outq));
	tp->t_state &= ~TS_BUSY;
out:
	splx(s);
}

/*
 * Stop output on a line.
 */
int
promstop(tp, flag)
	struct tty *tp;
	int flag;
{
	int s;

	s = spltty();
	if (tp->t_state & TS_BUSY)
		if ((tp->t_state & TS_TTSTOP) == 0)
			tp->t_state |= TS_FLUSH;
	splx(s);
	return 0;
}

void
promtimeout(v)
	void *v;
{
	struct tty *tp = v;
	u_char c;

	while (promcnlookc(tp->t_dev, &c)) {
		if (tp->t_state & TS_ISOPEN)
			(*linesw[tp->t_line].l_rint)(c, tp);
	}
	timeout_add(&prom_to, 1);
}

struct tty *
promtty(dev)
	dev_t dev;
{

	if (minor(dev) != 0)
		panic("promtty: bogus");

	return prom_tty[0];
}


code:
/*	$OpenBSD: sys_machdep.c,v 1.7 2008/06/26 05:42:08 ray Exp $	*/
/*	$NetBSD: sys_machdep.c,v 1.14 2002/01/14 00:53:16 thorpej Exp $	*/

/*-
 * Copyright (c) 2000 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Jason R. Thorpe.
 *
 * 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.
 */

/*
 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chris G. Demetriou
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <sys/param.h>
#include <sys/systm.h>
#ifndef NO_IEEE
#include <sys/device.h>
#include <sys/proc.h>
#endif

#include <sys/mount.h>
#include <sys/syscallargs.h>

#ifndef NO_IEEE
#include <machine/fpu.h>
#include <machine/sysarch.h>

#include <dev/pci/pcivar.h>

int
sys_sysarch(struct proc *p, void *v, register_t *retval)
{
	struct sys_sysarch_args /* {
		syscallarg(int) op;
		syscallarg(void *) parms;
	} */ *uap = v;
	int error = 0;

	switch(SCARG(uap, op)) {
	case ALPHA_FPGETMASK:
		*retval = FP_C_TO_OPENBSD_MASK(p->p_md.md_flags);
		break;
	case ALPHA_FPGETSTICKY:
		*retval = FP_C_TO_OPENBSD_FLAG(p->p_md.md_flags);
		break;
	case ALPHA_FPSETMASK:
	case ALPHA_FPSETSTICKY:
	    {
		fp_except m;
		u_int64_t md_flags;
		struct alpha_fp_except_args args;

		error = copyin(SCARG(uap, parms), &args, sizeof args);
		if (error)
			return error;
		m = args.mask;
		md_flags = p->p_md.md_flags;
		switch (SCARG(uap, op)) {
		case ALPHA_FPSETMASK:
			*retval = FP_C_TO_OPENBSD_MASK(md_flags);
			md_flags = SET_FP_C_MASK(md_flags, m);
			break;
		case ALPHA_FPSETSTICKY:
			*retval = FP_C_TO_OPENBSD_FLAG(md_flags);
			md_flags = SET_FP_C_FLAG(md_flags, m);
			break;
		}
		alpha_write_fp_c(p, md_flags);
		break;
	    }
	case ALPHA_GET_FP_C:
	    {
		struct alpha_fp_c_args args;

		args.fp_c = alpha_read_fp_c(p);
		error = copyout(&args, SCARG(uap, parms), sizeof args);
		break;
	    }
	case ALPHA_SET_FP_C:
	    {
		struct alpha_fp_c_args args;

		error = copyin(SCARG(uap, parms), &args, sizeof args);
		if (error)
			return (error);
		if ((args.fp_c >> 63) != 0)
			args.fp_c |= IEEE_INHERIT;
		alpha_write_fp_c(p, args.fp_c);
		break;
	    }

	default:
		error = EINVAL;
		break;
	}

	return (error);
}
#else
int sys_sysarch(struct proc *p, void *v, register_t *retval)
{
	return (ENOSYS);
}
#endif


code:
/* $OpenBSD: trap.c,v 1.80 2015/06/23 12:29:46 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */

/*-
 * Copyright (c) 2000 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
 * NASA Ames Research Center.
 *
 * 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.
 */

/*
 * Copyright (c) 1999 Christopher G. Demetriou.  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 Christopher G. Demetriou
 *	for the NetBSD Project.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chris G. Demetriou
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/user.h>
#include <sys/syscall.h>
#include <sys/syscall_mi.h>
#include <sys/buf.h>
#ifndef NO_IEEE
#include <sys/device.h>
#endif
#include <sys/ptrace.h>

#include <uvm/uvm_extern.h>

#include <machine/cpu.h>
#include <machine/reg.h>
#ifdef DDB
#include <machine/db_machdep.h>
#endif
#include <alpha/alpha/db_instruction.h>

#ifndef SMALL_KERNEL

unsigned long	Sfloat_to_reg(unsigned int);
unsigned int	reg_to_Sfloat(unsigned long);
unsigned long	Tfloat_reg_cvt(unsigned long);
#ifdef FIX_UNALIGNED_VAX_FP
unsigned long	Ffloat_to_reg(unsigned int);
unsigned int	reg_to_Ffloat(unsigned long);
unsigned long	Gfloat_reg_cvt(unsigned long);
#endif

int		unaligned_fixup(unsigned long, unsigned long,
		    unsigned long, struct proc *);
#endif	/* SMALL_KERNEL */

int		handle_opdec(struct proc *p, u_int64_t *ucodep);

#ifndef NO_IEEE
struct device fpevent_use;
struct device fpevent_reuse;
#endif

void	printtrap(const unsigned long, const unsigned long, const unsigned long,
	    const unsigned long, struct trapframe *, int, int);

/*
 * Initialize the trap vectors for the current processor.
 */
void
trap_init()
{

	/*
	 * Point interrupt/exception vectors to our own.
	 */
	alpha_pal_wrent(XentInt, ALPHA_KENTRY_INT);
	alpha_pal_wrent(XentArith, ALPHA_KENTRY_ARITH);
	alpha_pal_wrent(XentMM, ALPHA_KENTRY_MM);
	alpha_pal_wrent(XentIF, ALPHA_KENTRY_IF);
	alpha_pal_wrent(XentUna, ALPHA_KENTRY_UNA);
	alpha_pal_wrent(XentSys, ALPHA_KENTRY_SYS);

	/*
	 * Clear pending machine checks and error reports, and enable
	 * system- and processor-correctable error reporting.
	 */
	alpha_pal_wrmces(alpha_pal_rdmces() &
	    ~(ALPHA_MCES_DSC|ALPHA_MCES_DPC));
}

void
printtrap(const unsigned long a0, const unsigned long a1,
    const unsigned long a2, const unsigned long entry, struct trapframe *framep,
    int isfatal, int user)
{
	char ubuf[64];
	const char *entryname;

	switch (entry) {
	case ALPHA_KENTRY_INT:
		entryname = "interrupt";
		break;
	case ALPHA_KENTRY_ARITH:
		entryname = "arithmetic trap";
		break;
	case ALPHA_KENTRY_MM:
		entryname = "memory management fault";
		break;
	case ALPHA_KENTRY_IF:
		entryname = "instruction fault";
		break;
	case ALPHA_KENTRY_UNA:
		entryname = "unaligned access fault";
		break;
	case ALPHA_KENTRY_SYS:
		entryname = "system call";
		break;
	default:
		snprintf(ubuf, sizeof ubuf, "type %lx", entry);
		entryname = (const char *) ubuf;
		break;
	}

	printf("\n");
	printf("%s %s trap:\n", isfatal? "fatal" : "handled",
	       user ? "user" : "kernel");
	printf("\n");
	printf("    trap entry = 0x%lx (%s)\n", entry, entryname);
	printf("    a0         = 0x%lx\n", a0);
	printf("    a1         = 0x%lx\n", a1);
	printf("    a2         = 0x%lx\n", a2);
	printf("    pc         = 0x%lx\n", framep->tf_regs[FRAME_PC]);
	printf("    ra         = 0x%lx\n", framep->tf_regs[FRAME_RA]);
	printf("    curproc    = %p\n", curproc);
	if (curproc != NULL)
		printf("        pid = %d, comm = %s\n", curproc->p_pid,
		       curproc->p_comm);
	printf("\n");
}

/*
 * Trap is called from locore to handle most types of processor traps.
 * System calls are broken out for efficiency and ASTs are broken out
 * to make the code a bit cleaner and more representative of the
 * Alpha architecture.
 */
/*ARGSUSED*/
void
trap(a0, a1, a2, entry, framep)
	const unsigned long a0, a1, a2, entry;
	struct trapframe *framep;
{
	struct proc *p;
	int i;
	u_int64_t ucode;
	int user;
#if defined(DDB)
	int call_debugger = 1;
#endif
	caddr_t v;
	int typ;
	union sigval sv;
	vm_prot_t ftype;
	unsigned long onfault;

	atomic_add_int(&uvmexp.traps, 1);
	p = curproc;
	ucode = 0;
	v = 0;
	user = (framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0;
	if (user) {
		p->p_md.md_tf = framep;
		refreshcreds(p);
	}

	switch (entry) {
	case ALPHA_KENTRY_UNA:
		/*
		 * If user-land, do whatever fixups, printing, and
		 * signalling is appropriate (based on system-wide
		 * and per-process unaligned-access-handling flags).
		 */
		if (user) {
#ifndef SMALL_KERNEL
			KERNEL_LOCK();
			i = unaligned_fixup(a0, a1, a2, p);
			KERNEL_UNLOCK();
			if (i == 0)
				goto out;
#endif

			ucode = ILL_ILLADR;
			v = (caddr_t)a0;
			break;
		}

		/*
		 * Unaligned access from kernel mode is always an error,
		 * EVEN IF A COPY FAULT HANDLER IS SET!
		 *
		 * It's an error if a copy fault handler is set because
		 * the various routines which do user-initiated copies
		 * do so in a bcopy-like manner.  In other words, the
		 * kernel never assumes that pointers provided by the
		 * user are properly aligned, and so if the kernel
		 * does cause an unaligned access it's a kernel bug.
		 */
		goto dopanic;

	case ALPHA_KENTRY_ARITH:
		/*
		 * Resolve trap shadows, interpret FP ops requiring infinities,
		 * NaNs, or denorms, and maintain FPCR corrections.
		 */
		if (user) {
#ifndef NO_IEEE
			i = alpha_fp_complete(a0, a1, p, &ucode);
			if (i == 0)
				goto out;
#else
			i = SIGFPE;
			ucode = FPE_FLTINV;
#endif
			v = (caddr_t)framep->tf_regs[FRAME_PC];
			break;
		}

		/* Always fatal in kernel.  Should never happen. */
		goto dopanic;

	case ALPHA_KENTRY_IF:
		/*
		 * These are always fatal in kernel, and should never
		 * happen.  (Debugger entry is handled in XentIF.)
		 */
		if (!user) {
#if defined(DDB)
			/*
			 * ...unless a debugger is configured.  It will
			 * inform us if the trap was handled.
			 */
			if (alpha_debug(a0, a1, a2, entry, framep))
				goto out;

			/*
			 * Debugger did NOT handle the trap, don't
			 * call the debugger again!
			 */
			call_debugger = 0;
#endif
			goto dopanic;
		}
		i = 0;
		switch (a0) {
		case ALPHA_IF_CODE_GENTRAP:
			if (framep->tf_regs[FRAME_A0] == -2) { /* weird! */
				i = SIGFPE;
				ucode =  a0;	/* exception summary */
				break;
			}
			/* FALLTHROUGH */
		case ALPHA_IF_CODE_BPT:
		case ALPHA_IF_CODE_BUGCHK:
#ifdef PTRACE
			if (p->p_md.md_flags & (MDP_STEP1|MDP_STEP2)) {
				KERNEL_LOCK();
				process_sstep(p, 0);
				KERNEL_UNLOCK();
				p->p_md.md_tf->tf_regs[FRAME_PC] -= 4;
			}
#endif
			ucode = a0;		/* trap type */
			i = SIGTRAP;
			break;

		case ALPHA_IF_CODE_OPDEC:
			KERNEL_LOCK();
			i = handle_opdec(p, &ucode);
			KERNEL_UNLOCK();
			if (i == 0)
				goto out;
			break;

		case ALPHA_IF_CODE_FEN:
			alpha_enable_fp(p, 0);
			goto out;

		default:
			printf("trap: unknown IF type 0x%lx\n", a0);
			goto dopanic;
		}
		v = (caddr_t)framep->tf_regs[FRAME_PC];
		break;

	case ALPHA_KENTRY_MM:
		switch (a1) {
		case ALPHA_MMCSR_FOR:
		case ALPHA_MMCSR_FOE:
		case ALPHA_MMCSR_FOW:
			KERNEL_LOCK();
			if (pmap_emulate_reference(p, a0, user, a1)) {
				ftype = PROT_EXEC;
				goto do_fault;
			}
			KERNEL_UNLOCK();
			goto out;

		case ALPHA_MMCSR_INVALTRANS:
		case ALPHA_MMCSR_ACCESS:
	    	    {
			vaddr_t va;
			struct vmspace *vm = NULL;
			struct vm_map *map;
			int rv;
			extern struct vm_map *kernel_map;

			switch (a2) {
			case -1:		/* instruction fetch fault */
				ftype = PROT_EXEC;
				break;
			case 0:			/* load instruction */
				ftype = PROT_READ;
				break;
			case 1:			/* store instruction */
				ftype = PROT_READ | PROT_WRITE;
				break;
			}

			KERNEL_LOCK();
do_fault:
			/*
			 * It is only a kernel address space fault iff:
			 *	1. !user and
			 *	2. pcb_onfault not set or
			 *	3. pcb_onfault set but kernel space data fault
			 * The last can occur during an exec() copyin where the
			 * argument space is lazy-allocated.
			 */
			if (!user && (a0 >= VM_MIN_KERNEL_ADDRESS ||
			    p->p_addr->u_pcb.pcb_onfault == 0)) {
				vm = NULL;
				map = kernel_map;
			} else {
				vm = p->p_vmspace;
				map = &vm->vm_map;
			}

			va = trunc_page((vaddr_t)a0);
			onfault = p->p_addr->u_pcb.pcb_onfault;
			p->p_addr->u_pcb.pcb_onfault = 0;
			rv = uvm_fault(map, va, 0, ftype);
			p->p_addr->u_pcb.pcb_onfault = onfault;

			/*
			 * If this was a stack access we keep track of the
			 * maximum accessed stack size.  Also, if vm_fault
			 * gets a protection failure it is due to accessing
			 * the stack region outside the current limit and
			 * we need to reflect that as an access error.
			 */
			if (map != kernel_map &&
			    (caddr_t)va >= vm->vm_maxsaddr) {
				if (rv == 0) {
					uvm_grow(p, va);
				} else if (rv == EACCES)
					rv = EFAULT;
			}
			if (rv == 0) {
				KERNEL_UNLOCK();
				goto out;
			}

			if (!user) {
				/* Check for copyin/copyout fault */
				if (p->p_addr->u_pcb.pcb_onfault != 0) {
					framep->tf_regs[FRAME_PC] =
					    p->p_addr->u_pcb.pcb_onfault;
					KERNEL_UNLOCK();
					goto out;
				}
				KERNEL_UNLOCK();
				goto dopanic;
			}
			KERNEL_UNLOCK();
			ucode = ftype;
			v = (caddr_t)a0;
			typ = SEGV_MAPERR;
			if (rv == ENOMEM) {
				printf("UVM: pid %u (%s), uid %d killed: "
			           "out of swap\n", p->p_pid, p->p_comm,
			           p->p_ucred ? (int)p->p_ucred->cr_uid : -1);
				i = SIGKILL;
			} else {
				i = SIGSEGV;
			}
			break;
		    }

		default:
			printf("trap: unknown MMCSR value 0x%lx\n", a1);
			goto dopanic;
		}
		break;

	default:
		goto dopanic;
	}

#ifdef DEBUG
	printtrap(a0, a1, a2, entry, framep, 1, user);
#endif
	sv.sival_ptr = v;
	KERNEL_LOCK();
	trapsignal(p, i, ucode, typ, sv);
	KERNEL_UNLOCK();
out:
	if (user) {
		/* Do any deferred user pmap operations. */
		PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));

		userret(p);
	}
	return;

dopanic:
	printtrap(a0, a1, a2, entry, framep, 1, user);
	/* XXX dump registers */

#if defined(DDB)
	if (call_debugger && alpha_debug(a0, a1, a2, entry, framep)) {
		/*
		 * The debugger has handled the trap; just return.
		 */
		goto out;
	}
#endif

	panic("trap");
}

/*
 * Process a system call.
 *
 * System calls are strange beasts.  They are passed the syscall number
 * in v0, and the arguments in the registers (as normal).  They return
 * an error flag in a3 (if a3 != 0 on return, the syscall had an error),
 * and the return value (if any) in v0.
 *
 * The assembly stub takes care of moving the call number into a register
 * we can get to, and moves all of the argument registers into their places
 * in the trap frame.  On return, it restores the callee-saved registers,
 * a3, and v0 from the frame before returning to the user process.
 */
void
syscall(code, framep)
	u_int64_t code;
	struct trapframe *framep;
{
	struct sysent *callp;
	struct proc *p;
	int error, numsys;
	u_int64_t opc;
	u_long rval[2];
	u_long args[10];					/* XXX */
	u_int hidden, nargs;

	atomic_add_int(&uvmexp.syscalls, 1);
	p = curproc;
	p->p_md.md_tf = framep;
	opc = framep->tf_regs[FRAME_PC] - 4;

	callp = p->p_p->ps_emul->e_sysent;
	numsys = p->p_p->ps_emul->e_nsysent;

	switch(code) {
	case SYS_syscall:
	case SYS___syscall:
		/*
		 * syscall() and __syscall() are handled the same on
		 * the alpha, as everything is 64-bit aligned, anyway.
		 */
		code = framep->tf_regs[FRAME_A0];
		hidden = 1;
		break;
	default:
		hidden = 0;
	}

	error = 0;
	if (code < numsys)
		callp += code;
	else
		callp += p->p_p->ps_emul->e_nosys;

	nargs = callp->sy_narg + hidden;
	switch (nargs) {
	default:
		if (nargs > 10)		/* XXX */
			panic("syscall: too many args (%d)", nargs);
		if ((error = copyin((caddr_t)(alpha_pal_rdusp()), &args[6],
		    (nargs - 6) * sizeof(u_long))))
			goto bad;
	case 6:
		args[5] = framep->tf_regs[FRAME_A5];
	case 5:
		args[4] = framep->tf_regs[FRAME_A4];
	case 4:
		args[3] = framep->tf_regs[FRAME_A3];
	case 3:
		args[2] = framep->tf_regs[FRAME_A2];
	case 2:
		args[1] = framep->tf_regs[FRAME_A1];
	case 1:
		args[0] = framep->tf_regs[FRAME_A0];
	case 0:
		break;
	}

	rval[0] = 0;
	rval[1] = 0;

	error = mi_syscall(p, code, callp, args + hidden, rval);

	switch (error) {
	case 0:
		framep->tf_regs[FRAME_V0] = rval[0];
		framep->tf_regs[FRAME_A4] = rval[1];
		framep->tf_regs[FRAME_A3] = 0;
		break;
	case ERESTART:
		framep->tf_regs[FRAME_PC] = opc;
		break;
	case EJUSTRETURN:
		break;
	default:
	bad:
		framep->tf_regs[FRAME_V0] = error;
		framep->tf_regs[FRAME_A3] = 1;
		break;
	}

	/* Do any deferred user pmap operations. */
	PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));

	mi_syscall_return(p, code, error, rval);
}

/*
 * Process the tail end of a fork() for the child.
 */
void
child_return(arg)
	void *arg;
{
	struct proc *p = arg;
	struct trapframe *framep = p->p_md.md_tf;

	/*
	 * Return values in the frame set by cpu_fork().
	 */
	framep->tf_regs[FRAME_V0] = 0;
	framep->tf_regs[FRAME_A4] = 0;
	framep->tf_regs[FRAME_A3] = 0;

	KERNEL_UNLOCK();

	/* Do any deferred user pmap operations. */
	PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));

	mi_child_return(p);
}

/*
 * Set the float-point enable for the current process, and return
 * the FPU context to the named process. If check == 0, it is an
 * error for the named process to already be fpcurproc.
 */
void
alpha_enable_fp(struct proc *p, int check)
{
	struct cpu_info *ci = curcpu();
#if defined(MULTIPROCESSOR)
	int s;
#endif

	if (check && ci->ci_fpcurproc == p) {
		alpha_pal_wrfen(1);
		return;
	}
	if (ci->ci_fpcurproc == p)
		panic("trap: fp disabled for fpcurproc == %p", p);

	if (ci->ci_fpcurproc != NULL)
		fpusave_cpu(ci, 1);

	KDASSERT(ci->ci_fpcurproc == NULL);

#if defined(MULTIPROCESSOR)
	if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
		fpusave_proc(p, 1);
#else
	KDASSERT(p->p_addr->u_pcb.pcb_fpcpu == NULL);
#endif

#if defined(MULTIPROCESSOR)
	/* Need to block IPIs */
	s = splipi();
#endif
	p->p_addr->u_pcb.pcb_fpcpu = ci;
	ci->ci_fpcurproc = p;
	atomic_add_int(&uvmexp.fpswtch, 1);

	p->p_md.md_flags |= MDP_FPUSED;
	alpha_pal_wrfen(1);
	restorefpstate(&p->p_addr->u_pcb.pcb_fp);
	alpha_pal_wrfen(0);

#if defined(MULTIPROCESSOR)
	alpha_pal_swpipl(s);
#endif
}

/*
 * Process an asynchronous software trap.
 * This is relatively easy.
 */
void
ast(framep)
	struct trapframe *framep;
{
	struct cpu_info *ci = curcpu();
	struct proc *p = ci->ci_curproc;

	p->p_md.md_tf = framep;
	p->p_md.md_astpending = 0;

#ifdef DIAGNOSTIC
	if ((framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) == 0)
		panic("ast and not user");
#endif

	atomic_add_int(&uvmexp.softs, 1);
	mi_ast(p, ci->ci_want_resched);

	/* Do any deferred user pmap operations. */
	PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));

	userret(p);
}

/*
 * Unaligned access handler.  It's not clear that this can get much slower...
 *
 */

const static int reg_to_framereg[32] = {
	FRAME_V0,	FRAME_T0,	FRAME_T1,	FRAME_T2,
	FRAME_T3,	FRAME_T4,	FRAME_T5,	FRAME_T6,
	FRAME_T7,	FRAME_S0,	FRAME_S1,	FRAME_S2,
	FRAME_S3,	FRAME_S4,	FRAME_S5,	FRAME_S6,
	FRAME_A0,	FRAME_A1,	FRAME_A2,	FRAME_A3,
	FRAME_A4,	FRAME_A5,	FRAME_T8,	FRAME_T9,
	FRAME_T10,	FRAME_T11,	FRAME_RA,	FRAME_T12,
	FRAME_AT,	FRAME_GP,	FRAME_SP,	-1,
};

#define	irp(p, reg)							\
	((reg_to_framereg[(reg)] == -1) ? NULL :			\
	    &(p)->p_md.md_tf->tf_regs[reg_to_framereg[(reg)]])

#ifndef SMALL_KERNEL

#define	frp(p, reg)							\
	(&(p)->p_addr->u_pcb.pcb_fp.fpr_regs[(reg)])

#define	dump_fp_regs()							\
	if (p->p_addr->u_pcb.pcb_fpcpu != NULL)				\
		fpusave_proc(p, 1);

#define	unaligned_load(storage, ptrf, mod)				\
	if (copyin((caddr_t)va, &(storage), sizeof (storage)) != 0) {	\
		p->p_md.md_tf->tf_regs[FRAME_PC] -= 4;			\
		signal = SIGSEGV;					\
		goto out;						\
	}								\
	signal = 0;							\
	if ((regptr = ptrf(p, reg)) != NULL)				\
		*regptr = mod (storage);

#define	unaligned_store(storage, ptrf, mod)				\
	if ((regptr = ptrf(p, reg)) != NULL)				\
		(storage) = mod (*regptr);				\
	else								\
		(storage) = 0;						\
	if (copyout(&(storage), (caddr_t)va, sizeof (storage)) != 0) {	\
		p->p_md.md_tf->tf_regs[FRAME_PC] -= 4;			\
		signal = SIGSEGV;					\
		goto out;						\
	}								\
	signal = 0;

#define	unaligned_load_integer(storage)					\
	unaligned_load(storage, irp, )

#define	unaligned_store_integer(storage)				\
	unaligned_store(storage, irp, )

#define	unaligned_load_floating(storage, mod)				\
	dump_fp_regs();							\
	unaligned_load(storage, frp, mod)

#define	unaligned_store_floating(storage, mod)				\
	dump_fp_regs();							\
	unaligned_store(storage, frp, mod)

unsigned long
Sfloat_to_reg(s)
	unsigned int s;
{
	unsigned long sign, expn, frac;
	unsigned long result;

	sign = (s & 0x80000000) >> 31;
	expn = (s & 0x7f800000) >> 23;
	frac = (s & 0x007fffff) >>  0;

	/* map exponent part, as appropriate. */
	if (expn == 0xff)
		expn = 0x7ff;
	else if ((expn & 0x80) != 0)
		expn = (0x400 | (expn & ~0x80));
	else if ((expn & 0x80) == 0 && expn != 0)
		expn = (0x380 | (expn & ~0x80));

	result = (sign << 63) | (expn << 52) | (frac << 29);
	return (result);
}

unsigned int
reg_to_Sfloat(r)
	unsigned long r;
{
	unsigned long sign, expn, frac;
	unsigned int result;

	sign = (r & 0x8000000000000000) >> 63;
	expn = (r & 0x7ff0000000000000) >> 52;
	frac = (r & 0x000fffffe0000000) >> 29;

	/* map exponent part, as appropriate. */
	expn = (expn & 0x7f) | ((expn & 0x400) != 0 ? 0x80 : 0x00);

	result = (sign << 31) | (expn << 23) | (frac << 0);
	return (result);
}

/*
 * Conversion of T floating datums to and from register format
 * requires no bit reordering whatsoever.
 */
unsigned long
Tfloat_reg_cvt(input)
	unsigned long input;
{

	return (input);
}

#ifdef FIX_UNALIGNED_VAX_FP
unsigned long
Ffloat_to_reg(f)
	unsigned int f;
{
	unsigned long sign, expn, frlo, frhi;
	unsigned long result;

	sign = (f & 0x00008000) >> 15;
	expn = (f & 0x00007f80) >>  7;
	frhi = (f & 0x0000007f) >>  0;
	frlo = (f & 0xffff0000) >> 16;

	/* map exponent part, as appropriate. */
	if ((expn & 0x80) != 0)
		expn = (0x400 | (expn & ~0x80));
	else if ((expn & 0x80) == 0 && expn != 0)
		expn = (0x380 | (expn & ~0x80));

	result = (sign << 63) | (expn << 52) | (frhi << 45) | (frlo << 29);
	return (result);
}

unsigned int
reg_to_Ffloat(r)
	unsigned long r;
{
	unsigned long sign, expn, frhi, frlo;
	unsigned int result;

	sign = (r & 0x8000000000000000) >> 63;
	expn = (r & 0x7ff0000000000000) >> 52;
	frhi = (r & 0x000fe00000000000) >> 45;
	frlo = (r & 0x00001fffe0000000) >> 29;

	/* map exponent part, as appropriate. */
	expn = (expn & 0x7f) | ((expn & 0x400) != 0 ? 0x80 : 0x00);

	result = (sign << 15) | (expn << 7) | (frhi << 0) | (frlo << 16);
	return (result);
}

/*
 * Conversion of G floating datums to and from register format is
 * symmetrical.  Just swap shorts in the quad...
 */
unsigned long
Gfloat_reg_cvt(input)
	unsigned long input;
{
	unsigned long a, b, c, d;
	unsigned long result;

	a = (input & 0x000000000000ffff) >> 0;
	b = (input & 0x00000000ffff0000) >> 16;
	c = (input & 0x0000ffff00000000) >> 32;
	d = (input & 0xffff000000000000) >> 48;

	result = (a << 48) | (b << 32) | (c << 16) | (d << 0);
	return (result);
}
#endif /* FIX_UNALIGNED_VAX_FP */

struct unaligned_fixup_data {
	const char *type;	/* opcode name */
	int fixable;		/* fixable, 0 if fixup not supported */
	int size;		/* size, 0 if unknown */
};

#define	UNKNOWN()	{ "0x%lx", 0, 0 }
#define	FIX_LD(n,s)	{ n, 1, s }
#define	FIX_ST(n,s)	{ n, 1, s }
#define	NOFIX_LD(n,s)	{ n, 0, s }
#define	NOFIX_ST(n,s)	{ n, 0, s }

int
unaligned_fixup(va, opcode, reg, p)
	unsigned long va, opcode, reg;
	struct proc *p;
{
	const struct unaligned_fixup_data tab_unknown[1] = {
		UNKNOWN(),
	};
	const struct unaligned_fixup_data tab_0c[0x02] = {
		FIX_LD("ldwu", 2),	FIX_ST("stw", 2),
	};
	const struct unaligned_fixup_data tab_20[0x10] = {
#ifdef FIX_UNALIGNED_VAX_FP
		FIX_LD("ldf", 4),	FIX_LD("ldg", 8),
#else
		NOFIX_LD("ldf", 4),	NOFIX_LD("ldg", 8),
#endif
		FIX_LD("lds", 4),	FIX_LD("ldt", 8),
#ifdef FIX_UNALIGNED_VAX_FP
		FIX_ST("stf", 4),	FIX_ST("stg", 8),
#else
		NOFIX_ST("stf", 4),	NOFIX_ST("stg", 8),
#endif
		FIX_ST("sts", 4),	FIX_ST("stt", 8),
		FIX_LD("ldl", 4),	FIX_LD("ldq", 8),
		NOFIX_LD("ldl_c", 4),	NOFIX_LD("ldq_c", 8),
		FIX_ST("stl", 4),	FIX_ST("stq", 8),
		NOFIX_ST("stl_c", 4),	NOFIX_ST("stq_c", 8),
	};
	const struct unaligned_fixup_data *selected_tab;
	int doprint, dofix, dosigbus, signal;
	unsigned long *regptr, longdata;
	int intdata;		/* signed to get extension when storing */
	u_int16_t worddata;	/* unsigned to _avoid_ extension */

	/*
	 * Read USP into frame in case it's the register to be modified.
	 * This keeps us from having to check for it in lots of places
	 * later.
	 */
	p->p_md.md_tf->tf_regs[FRAME_SP] = alpha_pal_rdusp();

	/*
	 * Figure out what actions to take.
	 *
	 * XXX In the future, this should have a per-process component
	 * as well.
	 */
	doprint = alpha_unaligned_print;
	dofix = alpha_unaligned_fix;
	dosigbus = alpha_unaligned_sigbus;

	/*
	 * Find out which opcode it is.  Arrange to have the opcode
	 * printed if it's an unknown opcode.
	 */
	if (opcode >= 0x0c && opcode <= 0x0d)
		selected_tab = &tab_0c[opcode - 0x0c];
	else if (opcode >= 0x20 && opcode <= 0x2f)
		selected_tab = &tab_20[opcode - 0x20];
	else
		selected_tab = tab_unknown;

	/*
	 * If we're supposed to be noisy, squawk now.
	 */
	if (doprint) {
		uprintf(
		"pid %u (%s): unaligned access: va=0x%lx pc=0x%lx ra=0x%lx op=",
		    p->p_pid, p->p_comm, va,
		    p->p_md.md_tf->tf_regs[FRAME_PC] - 4,
		    p->p_md.md_tf->tf_regs[FRAME_RA]);
		uprintf(selected_tab->type,opcode);
		uprintf("\n");
	}

	/*
	 * If we should try to fix it and know how, give it a shot.
	 *
	 * We never allow bad data to be unknowingly used by the
	 * user process.  That is, if we decide not to fix up an
	 * access we cause a SIGBUS rather than letting the user
	 * process go on without warning.
	 *
	 * If we're trying to do a fixup, we assume that things
	 * will be botched.  If everything works out OK,
	 * unaligned_{load,store}_* clears the signal flag.
	 */
	signal = SIGBUS;
	if (dofix && selected_tab->fixable) {
		switch (opcode) {
		case 0x0c:			/* ldwu */
			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
			unaligned_load_integer(worddata);
			break;

		case 0x0d:			/* stw */
			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
			unaligned_store_integer(worddata);
			break;

#ifdef FIX_UNALIGNED_VAX_FP
		case 0x20:			/* ldf */
			unaligned_load_floating(intdata, Ffloat_to_reg);
			break;

		case 0x21:			/* ldg */
			unaligned_load_floating(longdata, Gfloat_reg_cvt);
			break;
#endif

		case 0x22:			/* lds */
			unaligned_load_floating(intdata, Sfloat_to_reg);
			break;

		case 0x23:			/* ldt */
			unaligned_load_floating(longdata, Tfloat_reg_cvt);
			break;

#ifdef FIX_UNALIGNED_VAX_FP
		case 0x24:			/* stf */
			unaligned_store_floating(intdata, reg_to_Ffloat);
			break;

		case 0x25:			/* stg */
			unaligned_store_floating(longdata, Gfloat_reg_cvt);
			break;
#endif

		case 0x26:			/* sts */
			unaligned_store_floating(intdata, reg_to_Sfloat);
			break;

		case 0x27:			/* stt */
			unaligned_store_floating(longdata, Tfloat_reg_cvt);
			break;

		case 0x28:			/* ldl */
			unaligned_load_integer(intdata);
			break;

		case 0x29:			/* ldq */
			unaligned_load_integer(longdata);
			break;

		case 0x2c:			/* stl */
			unaligned_store_integer(intdata);
			break;

		case 0x2d:			/* stq */
			unaligned_store_integer(longdata);
			break;

#ifdef DIAGNOSTIC
		default:
			panic("unaligned_fixup: can't get here");
#endif
		}
	}

	/*
	 * Force SIGBUS if requested.
	 */
	if (dosigbus)
		signal = SIGBUS;

out:
	/*
	 * Write back USP.
	 */
	alpha_pal_wrusp(p->p_md.md_tf->tf_regs[FRAME_SP]);

	return (signal);
}

#endif	/* SMALL_KERNEL */

/*
 * Reserved/unimplemented instruction (opDec fault) handler
 *
 * Argument is the process that caused it.  No useful information
 * is passed to the trap handler other than the fault type.  The
 * address of the instruction that caused the fault is 4 less than
 * the PC stored in the trap frame.
 *
 * If the instruction is emulated successfully, this function returns 0.
 * Otherwise, this function returns the signal to deliver to the process,
 * and fills in *ucodep with the code to be delivered.
 */
int
handle_opdec(p, ucodep)
	struct proc *p;
	u_int64_t *ucodep;
{
	alpha_instruction inst;
	register_t *regptr, memaddr;
	u_int64_t inst_pc;
	int sig;

	/*
	 * Read USP into frame in case it's going to be used or modified.
	 * This keeps us from having to check for it in lots of places
	 * later.
	 */
	p->p_md.md_tf->tf_regs[FRAME_SP] = alpha_pal_rdusp();

	inst_pc = memaddr = p->p_md.md_tf->tf_regs[FRAME_PC] - 4;
	if (copyin((caddr_t)inst_pc, &inst, sizeof (inst)) != 0) {
		/*
		 * really, this should never happen, but in case it
		 * does we handle it.
		 */
		printf("WARNING: handle_opdec() couldn't fetch instruction\n");
		goto sigsegv;
	}

	switch (inst.generic_format.opcode) {
	case op_ldbu:
	case op_ldwu:
	case op_stw:
	case op_stb:
		regptr = irp(p, inst.mem_format.rb);
		if (regptr != NULL)
			memaddr = *regptr;
		else
			memaddr = 0;
		memaddr += inst.mem_format.displacement;

		regptr = irp(p, inst.mem_format.ra);

		if (inst.mem_format.opcode == op_ldwu ||
		    inst.mem_format.opcode == op_stw) {
			if (memaddr & 0x01) {
#ifndef SMALL_KERNEL
				sig = unaligned_fixup(memaddr,
				    inst.mem_format.opcode,
				    inst.mem_format.ra, p);
				if (sig)
					goto unaligned_fixup_sig;
#else
				goto sigill;
#endif
				break;
			}
		}

		if (inst.mem_format.opcode == op_ldbu) {
			u_int8_t b;

			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
			if (copyin((caddr_t)memaddr, &b, sizeof (b)) != 0)
				goto sigsegv;
			if (regptr != NULL)
				*regptr = b;
		} else if (inst.mem_format.opcode == op_ldwu) {
			u_int16_t w;

			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
			if (copyin((caddr_t)memaddr, &w, sizeof (w)) != 0)
				goto sigsegv;
			if (regptr != NULL)
				*regptr = w;
		} else if (inst.mem_format.opcode == op_stw) {
			u_int16_t w;

			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
			w = (regptr != NULL) ? *regptr : 0;
			if (copyout(&w, (caddr_t)memaddr, sizeof (w)) != 0)
				goto sigsegv;
		} else if (inst.mem_format.opcode == op_stb) {
			u_int8_t b;

			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
			b = (regptr != NULL) ? *regptr : 0;
			if (copyout(&b, (caddr_t)memaddr, sizeof (b)) != 0)
				goto sigsegv;
		}
		break;

	case op_intmisc:
		if (inst.operate_generic_format.function == op_sextb &&
		    inst.operate_generic_format.ra == 31) {
			int8_t b;

			if (inst.operate_generic_format.is_lit) {
				b = inst.operate_lit_format.literal;
			} else {
				if (inst.operate_reg_format.sbz != 0)
					goto sigill;
				regptr = irp(p, inst.operate_reg_format.rb);
				b = (regptr != NULL) ? *regptr : 0;
			}

			regptr = irp(p, inst.operate_generic_format.rc);
			if (regptr != NULL)
				*regptr = b;
			break;
		}
		if (inst.operate_generic_format.function == op_sextw &&
		    inst.operate_generic_format.ra == 31) {
			int16_t w;

			if (inst.operate_generic_format.is_lit) {
				w = inst.operate_lit_format.literal;
			} else {
				if (inst.operate_reg_format.sbz != 0)
					goto sigill;
				regptr = irp(p, inst.operate_reg_format.rb);
				w = (regptr != NULL) ? *regptr : 0;
			}

			regptr = irp(p, inst.operate_generic_format.rc);
			if (regptr != NULL)
				*regptr = w;
			break;
		}
		goto sigill;

	default:
		goto sigill;
	}

	/*
	 * Write back USP.  Note that in the error cases below,
	 * nothing will have been successfully modified so we don't
	 * have to write it out.
	 */
	alpha_pal_wrusp(p->p_md.md_tf->tf_regs[FRAME_SP]);

	return (0);

sigill:
	*ucodep = ALPHA_IF_CODE_OPDEC;			/* trap type */
	return (SIGILL);

sigsegv:
	sig = SIGSEGV;
	p->p_md.md_tf->tf_regs[FRAME_PC] = inst_pc;	/* re-run instr. */
#ifndef SMALL_KERNEL
unaligned_fixup_sig:
#endif
	*ucodep = memaddr;				/* faulting address */
	return (sig);
}


code:
/* $OpenBSD: vm_machdep.c,v 1.43 2015/05/05 02:13:46 guenther Exp $ */
/* $NetBSD: vm_machdep.c,v 1.55 2000/03/29 03:49:48 simonb Exp $ */

/*
 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chris G. Demetriou
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/user.h>
#include <sys/exec.h>

#include <uvm/uvm_extern.h>

#include <machine/cpu.h>
#include <machine/pmap.h>
#include <machine/reg.h>

/*
 * cpu_exit is called as the last action during exit.
 */
void
cpu_exit(p)
	struct proc *p;
{

	if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
		fpusave_proc(p, 0);

	/*
	 * Deactivate the exiting address space before the vmspace
	 * is freed.  Note that we will continue to run on this
	 * vmspace's context until the switch to idle in switch_exit().
	 */
	pmap_deactivate(p);
	sched_exit(p);
	/* NOTREACHED */
}

/*
 * Finish a fork operation, with process p2 nearly set up.
 * Copy and update the pcb and trap frame, making the child ready to run.
 *
 * Rig the child's kernel stack so that it will start out in
 * switch_trampoline() and call child_return() with p2 as an
 * argument. This causes the newly-created child process to go
 * directly to user level with an apparent return value of 0 from
 * fork(), while the parent process returns normally.
 *
 * p1 is the process being forked;
 *
 * If an alternate user-level stack is requested (with non-zero values
 * in both the stack and stacksize args), set up the user stack pointer
 * accordingly.
 */
void
cpu_fork(p1, p2, stack, stacksize, func, arg)
	struct proc *p1, *p2;
	void *stack;
	size_t stacksize;
	void (*func)(void *);
	void *arg;
{
	struct user *up = p2->p_addr;

	p2->p_md.md_tf = p1->p_md.md_tf;

#ifndef NO_IEEE
	p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_FP_C);
#else
	p2->p_md.md_flags = p1->p_md.md_flags & MDP_FPUSED;
#endif

	/*
	 * Cache the physical address of the pcb, so we can
	 * swap to it easily.
	 */
	p2->p_md.md_pcbpaddr = (void *)vtophys((vaddr_t)&up->u_pcb);

	/*
	 * Copy floating point state from the FP chip to the PCB
	 * if this process has state stored there.
	 */
	if (p1->p_addr->u_pcb.pcb_fpcpu != NULL)
		fpusave_proc(p1, 1);

	/*
	 * Copy pcb and stack from proc p1 to p2.
	 * If specified, give the child a different stack.
	 * We do this as cheaply as possible, copying only the active
	 * part of the stack.  The stack and pcb need to agree;
	 */
	up->u_pcb = p1->p_addr->u_pcb;
	if (stack != NULL)
		up->u_pcb.pcb_hw.apcb_usp = (u_long)stack + stacksize;
	else
		up->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp();

	/*
	 * Arrange for a non-local goto when the new process
	 * is started, to resume here, returning nonzero from setjmp.
	 */
#ifdef DIAGNOSTIC
	/*
	 * If p1 != curproc && p1 == &proc0, we are creating a kernel
	 * thread.
	 */
	if (p1 != curproc && p1 != &proc0)
		panic("cpu_fork: curproc");
	if ((up->u_pcb.pcb_hw.apcb_flags & ALPHA_PCB_FLAGS_FEN) != 0)
		printf("DANGER WILL ROBINSON: FEN SET IN cpu_fork!\n");
#endif

	/*
	 * create the child's kernel stack, from scratch.
	 */
	{
		struct trapframe *p2tf;

		/*
		 * Pick a stack pointer, leaving room for a trapframe;
		 * copy trapframe from parent so return to user mode
		 * will be to right address, with correct registers.
		 */
		p2tf = p2->p_md.md_tf = (struct trapframe *)
		    ((char *)p2->p_addr + USPACE - sizeof(struct trapframe));
		bcopy(p1->p_md.md_tf, p2->p_md.md_tf, sizeof(struct trapframe));

		/*
		 * Set up return-value registers as fork() libc stub expects.
		 */
		p2tf->tf_regs[FRAME_V0] = p1->p_pid;	/* parent's pid */
		p2tf->tf_regs[FRAME_A3] = 0;		/* no error */
		p2tf->tf_regs[FRAME_A4] = 1;		/* is child */

		/*
		 * Arrange for continuation at child_return(), which
		 * will return to exception_return().  Note that the child
		 * process doesn't stay in the kernel for long!
		 */
		up->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)p2tf;
		up->u_pcb.pcb_context[0] = (u_int64_t)func;
		up->u_pcb.pcb_context[1] =
		    (u_int64_t)exception_return;	/* s1: ra */
		up->u_pcb.pcb_context[2] = (u_int64_t)arg;
		up->u_pcb.pcb_context[7] =
		    (u_int64_t)switch_trampoline;	/* ra: assembly magic */
#ifdef MULTIPROCESSOR
		/*
		 * MULTIPROCESSOR kernels will reuse the IPL of the parent
		 * process, and will lower to IPL_NONE in proc_trampoline_mp().
		 */
		up->u_pcb.pcb_context[8] = IPL_SCHED;	/* ps: IPL */
#else
		up->u_pcb.pcb_context[8] = IPL_NONE;	/* ps: IPL */
#endif
	}
}

/*
 * Map a user I/O request into kernel virtual address space.
 * Note: the pages are already locked by uvm_vslock(), so we
 * do not need to pass an access_type to pmap_enter().
 */
void
vmapbuf(bp, len)
	struct buf *bp;
	vsize_t len;
{
	vaddr_t faddr, taddr, off;
	paddr_t pa;
	struct proc *p;

	if ((bp->b_flags & B_PHYS) == 0)
		panic("vmapbuf");
	p = bp->b_proc;
	faddr = trunc_page((vaddr_t)(bp->b_saveaddr = bp->b_data));
	off = (vaddr_t)bp->b_data - faddr;
	len = round_page(off + len);
	taddr = uvm_km_valloc_wait(phys_map, len);
	bp->b_data = (caddr_t)(taddr + off);
	len = atop(len);
	while (len--) {
		if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),
		    faddr, &pa) == FALSE)
			panic("vmapbuf: null page frame");
		pmap_enter(vm_map_pmap(phys_map), taddr, trunc_page(pa),
		    PROT_READ | PROT_WRITE, PMAP_WIRED);
		faddr += PAGE_SIZE;
		taddr += PAGE_SIZE;
	}
	pmap_update(vm_map_pmap(phys_map));
}

/*
 * Unmap a previously-mapped user I/O request.
 */
void
vunmapbuf(bp, len)
	struct buf *bp;
	vsize_t len;
{
	vaddr_t addr, off;

	if ((bp->b_flags & B_PHYS) == 0)
		panic("vunmapbuf");
	addr = trunc_page((vaddr_t)bp->b_data);
	off = (vaddr_t)bp->b_data - addr;
	len = round_page(off + len);
	pmap_remove(vm_map_pmap(phys_map), addr, addr + len);
	pmap_update(vm_map_pmap(phys_map));
	uvm_km_free_wakeup(phys_map, addr, len);
	bp->b_data = bp->b_saveaddr;
	bp->b_saveaddr = NULL;
}


code:
GENERIC
GENERIC.MP
RAMDISK
RAMDISKB
RAMDISKC
RAMDISKBIG


path: sys/arch/alpha/compile/CVS/Entries


code: src/sys/arch/alpha/compile

path: sys/arch/alpha/compile/CVS/Repository


code: src/sys/arch/alpha/conf

path: sys/arch/alpha/conf/CVS/Repository


code:
#	$OpenBSD: GENERIC,v 1.254 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		alpha
include		"../../../conf/GENERIC"
maxusers	80			# estimated number of users

# CPU Support
option		DEC_3000_500	# Flamingo etc:	3000/[4-9]00*
option		DEC_3000_300	# Pelican etc:	3000/300*
option		DEC_2100_A50	# Avanti etc:	AlphaStation 400, 200, etc.
option		DEC_KN20AA	# KN20AA:	AlphaStation 600
option		DEC_KN300	# KN300:	AlphaServer 4100 and 1200
option		DEC_ALPHABOOK1	# AlphaBook1:	Tadpole/DEC AlphaBook
option		DEC_AXPPCI_33	# NoName:	AXPpci33, etc.
option		DEC_EB164	# EB164:	AlphaPC 164
option		DEC_EB64PLUS	# EB64+:	AlphaPC 64, etc.
option		DEC_2000_300	# "Jensen":	2000/300 (DECpc AXP 150)
option		DEC_550		# Miata:	Digital Personal Workstation
option		DEC_1000	# Mikasa etc:	Digital AlphaServer 1000
option		DEC_1000A	# Corelle etc:	Digital AlphaServer 800/1000A
option		DEC_6600	# EV6:		XP1000, 264DP OEM Board
option		API_UP1000	# EV6:		Alpha Processor UP1000

# Misc. options
option		EISAVERBOSE		# recognize "unknown" EISA devices
option		PCIVERBOSE		# recognize "unknown" PCI devices
option		TCVERBOSE		# recognize "unknown" TC devices
option		USBVERBOSE

# Wscons options
option	WSDISPLAY_COMPAT_USL		# VT handling
option	WSDISPLAY_COMPAT_RAWKBD		# provide raw scancodes; needed for X11
option	WSDISPLAY_DEFAULTSCREENS=6	# initial number of text consoles
option	WSDISPLAY_COMPAT_PCVT		# emulate some ioctls; needed for X11

option		APERTURE		# in-kernel aperture driver for XFree86
option		USER_PCICONF		# user-space PCI configuration

config		bsd	swap generic

mainbus0 at	root
cpu0	at	mainbus0

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

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

# 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 Ethernet
udav*	at uhub?			# Davicom DM9601 based Ethernet
upl*	at uhub?			# Prolific PL2301/PL2302 host-to-host `network'
ugl*	at uhub?			# Genesys Logic GL620USB-A host-to-host `network'
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
uath*	at uhub?			# Atheros AR5005UG/AR5005UX
ural*	at uhub?			# Ralink RT2500USB
rum*	at uhub?			# Ralink RT2501USB/RT2601USB
run*	at uhub?			# Ralink RT2700U/RT2800U/RT3000U
uow*	at uhub?			# Maxim/Dallas DS2490 1-Wire adapter
onewire* at uow?
uthum*	at uhidev?			# TEMPerHUM sensor
ugold*	at uhidev?			# gold TEMPer sensor
utwitch* at uhidev?			# yurex BBU sensor

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

# EV6 Tsunami Core Logic
tsc*	at	mainbus0

# TURBOchannel host bus adapter support
tcasic*	at	mainbus0

# MCBUS bus support
mcbus*	at	mainbus0
mcmem*	at	mcbus? mid ?

# TURBOchannel bus support
tc*	at	tcasic?

# TURBOchannel devices
ioasic*	at	tc?
mcclock* at	ioasic?
le*	at	ioasic?
bba0	at	ioasic?
scc0	at	ioasic?
scc1	at	ioasic?
tcds*	at	tc?
asc*	at	tcds?
asc*	at	tc?
#cfb*	at	tc?
#sfb*	at	tc?
le*	at	tc?

# PCI host bus adapter support
apecs*	at	mainbus?
cia*	at	mainbus?
irongate* at	mainbus?
lca*	at	mainbus?
tsp*	at	tsc?
mcpcia*	at	mcbus? mid ?

# PCI bus support
pci*	at	apecs?
pci*	at	cia?
pci*	at	irongate?
pci*	at	lca?
pci*	at	ppb?
pci*	at	tsp?
pci*	at	mcpcia?

# PCI devices
ppb*	at pci?				# PCI-PCI bridges
sio*	at pci?				# Intel PCI-ISA bridge
pceb*	at pci?				# Intel PCI-EISA bridge

cy*	at pci?				# PCI cyclom card

# PCI SCSI devices
ahc*	at pci?				# Adaptec 2940 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
siop*	at pci?				# NCR 53c8xx SCSI
pcscp*	at pci?				# AMD 53c974 PCscsi-PCI SCSI
twe*	at pci?				# 3ware Escalade RAID controllers
mpi*	at pci?				# LSI Logic Message Passing Interface
sili*	at pci?				# Silicon Image 3124/3132/3531 SATA

#UNTESTED: the following drivers are untested.
adw*	at pci?				# AdvanSys ULTRA WIDE SCSI
ciss*	at pci?				# Compaq Smart ARRAY [56]* RAID controllers
gdt*	at pci?				# ICP Vortex GDT RAID controllers
#adv*	at pci?				# AdvanSys 1200A/B and ULTRA SCSI
#ami*	at pci?				# AMI MegaRAID controllers

# Networking devices
pcn*	at pci?				# AMD PCnet-PCI Ethernet
de*	at pci?				# 21x4[012]-based Ethernet
dc*	at pci?				# 21143, "tulip" clone ethernet
ne*	at pci?				# NE2000-compat ethernet cards
fxp*	at pci?				# EtherExpress 10/100B ethernet
ep*	at pci?				# 3COM 3c59x
xl*	at pci?				# 3COM 3c9xx
txp*	at pci?				# 3COM 3CR990
bge*	at pci?				# Broadcom BCM57xx (aka Tigon3)
vge*	at pci?				# VIA VT612x
re*	at pci?				# Realtek 8169/8169S/8110S
stge*	at pci?				# Sundance TC9021 GigE
lge*	at pci?				# Level1 LXT1001 GigE
hme*	at pci?				# Sun Happy Meal
ti*	at pci?				# Alteon Tigon 1Gb ethernet
rl*	at pci?				# Realtek 81[23]9 ethernet
vr*	at pci?				# VIA Rhine ethernet
em*	at pci?				# Intel Pro/1000 ethernet
#ixgb*	at pci?				# Intel Pro/10Gb ethernet
sis*	at pci?				# SiS 900/7016 ethernet
mtd*	at pci?				# Myson MTD800/803/891
epic*	at pci?				# SMC EPIC/100 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
tl*	at pci?				# Compaq Thunderlan ethernet
ste*	at pci?				# Sundance ST201 ethernet
xge*	at pci?				# Neterion Xframe-I/II 10Gb ethernet
sf*	at pci?				# Adaptec AIC-6915 ethernet
wb*	at pci?				# Winbond W89C840F ethernet

# Wireless network cards
acx*	at pci?				# TI ACX100/ACX111 (802.11b/g)
an*	at pci?				# Aironet IEEE 802.11DS
ath*	at pci?				# Atheros AR5k (802.11)
atw*	at pci?				# ADMtek ADM8211 (802.11)
pgt*	at pci?				# Prism54 (only full-mac varients)
ral*	at pci?				# Ralink RT2500/RT2501/RT2600
#rtw*	at pci?				# Realtek 8180
wi*	at pci?				# WaveLAN IEEE 802.11DS
malo*	at pci?				# Marvell Libertas

vga*	at pci?				# PCI VGA graphics
tga*	at pci?				# DEC ZLXp-E[123] graphics

# Media Independent Interface (mii) drivers
eephy*	at mii?				# Marvell PHYs
exphy*	at mii?				# 3Com internal PHYs
inphy*	at mii?				# Intel 82555 PHYs
iophy*	at mii?				# Intel 82553 PHYs
icsphy*	at mii?				# ICS 1890 PHYs
lxtphy*	at mii?				# Level1 LXT970 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
tlphy*	at mii?				# ThunderLAN PHYs
rlphy*	at mii?				# Realtek 8139 internal PHYs
mtdphy*	at mii?				# Myson MTD972 PHYs
dcphy*	at mii?				# Digital Clone PHYs
acphy*	at mii?				# Altima AC101 PHYs
amphy*	at mii?				# AMD 79C873 PHYs
tqphy*	at mii?				# TDK 78Q212x PHYs
bmtphy*	at mii?				# Broadcom 10/100 PHYs
brgphy*	at mii?				# Broadcom Gigabit PHYs
xmphy*	at mii?				# XaQti XMAC-II PHYs
urlphy*	at mii?				# Realtek RTL8150L internal PHY
rgephy*	at mii?				# Realtek 8169S/8110S PHY
ciphy*	at mii?				# Cicada CS8201 10/100/1000 copper PHY
ipgphy*	at mii?				# IC Plus IP1000A PHYs
mlphy*	at mii?				# Micro Linear 6692 PHY
ukphy*	at mii?				# "unknown" PHYs

# sensors
alipm*	at pci? disable
iic*	at alipm?
tsciic*	at tsc?
iic*	at tsciic?

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
spdmem* at iic?				# SPD memory eeproms
sdtemp*	at iic?				# SO-DIMM (JC-42.4) temperature

# ISA/EISA bus support
isa*	at	pceb?
eisa*	at	pceb?
isa*	at	sio?
isadma0	at	isa?
isapnp0	at	isa?

# ISA devices
mcclock* at isa? port 0x70
pcppi*	at isa?				# PC prog. periph. interface
spkr0	at pcppi?			# IBM BASIC emulation
pckbc*	at isa?				# PC keyboard controller
pckbd*	at pckbc?			# PC keyboard (kbd port)
pms*	at pckbc?			# PS/2-style mouse (aux port)
com*	at isa? port 0x3f8 irq 4	# standard serial ports
com*	at isa? port 0x2f8 irq 3
lpt*	at isa? port 0x3bc irq 7	# standard parallel port
vga*	at isa?				# ISA (EISA: XXX) VGA
we0	at isa? port 0x280 iomem 0xd0000 irq 9	# WD/SMC 80x3 ethernet
we1	at isa? port 0x300 iomem 0xcc000 irq 10	#
ec0	at isa? port 0x250 iomem 0xd8000 irq 9	# 3C503 ethernet cards
ne0	at isa? port 0x240 irq 9	# NE[12]000 ethernet cards
ne1	at isa? port 0x300 irq 10	# NE[12]000 ethernet cards
ne2	at isa? port 0x280 irq 9	# NE[12]000 ethernet cards
ep*	at isa?				# 3C509 ethernet cards
ep*	at isapnp?			# 3C509 ethernet cards
#wss*	at isa? port 0x530 irq 9 drq 0	# Windows Sound System
lc0	at isa? port 0x200		# DEC EtherWorks
lc1	at isa? port 0x280		# DEC EtherWorks
pcic0	at isa? port 0x3e0 iomem 0xd0000 iosiz 0x10000
pcic1	at isa? port 0x3e2 iomem 0xcc000 iosiz 0x10000

pcmcia*	at pcic? controller ? socket ?
ep*	at pcmcia? function ?		# 3Com 3c589 and 3c562 Eth.

cy0	at isa? iomem 0xd4000 irq 12	# ISA cyclom card
fdc0	at isa? port 0x3f0 irq 6 drq 2	# floppy controller
fd*	at fdc?

#aic0	at isa? port 0x340 irq 11	# Adaptec 152[02] SCSI

# option for using CD1400 handshaking for incoming data
# requires a special cable that exchanges the RTS and DTR lines
# options CY_HW_RTS
#ahc0	at isa?				# Adaptec 284x SCSI controllers

# EISA devices
ahc*	at eisa?			# Adaptec 274x, aic7770 SCSI

# SCSI devices
scsibus* at scsi?
cd*	at scsibus?
sd*	at scsibus?
st*	at scsibus?
ch*	at scsibus?
safte*	at scsibus?
ses*	at scsibus?
uk*	at scsibus?

# IDE controllers
pciide* at pci? flags 0x0000
wdc0	at isa? port 0x1f0 irq 14 flags 0x00
wdc1	at isa? port 0x170 irq 15 flags 0x00
wd*	at wdc? flags 0x0000
wd*	at pciide? flags 0x0000

# ATAPI<->SCSI
atapiscsi* at wdc?
atapiscsi* at pciide?

# Audio devices
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?

# UNTESTED.  The following drivers are untested
sv*	at pci?				# S3 SonicVibes (S3 617)
fms*	at pci?				# Forte Media FM801
auvia*	at pci?				# VIA VT82C686A
##

# MIDI support
midi*	at eap?

#Audio Support
audio*	at bba?
audio*	at eap?
audio*	at emu?
audio*	at eso?
audio*	at sv?
audio*	at cmpci?
audio*	at fms?
audio*	at auvia?
audio*	at uaudio?

bktr0	at pci?

# FM-Radio support
radio*	at bktr?

# Workstation Console attachments
#wsdisplay*	at	cfb?
#wsdisplay*	at	sfb?
wsdisplay*	at	vga?
wsdisplay*	at	tga?
wskbd*		at	pckbd? mux 1
wsmouse*	at	pms? mux 0

# crypto support
hifn*	at pci?				# Hi/fn 7751 crypto card
ubsec*	at pci?				# Bluesteel Networks 5xxx crypto card
safe*	at pci?				# SafeNet SafeXcel 1141/1741

# 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

path: sys/arch/alpha/conf/GENERIC


code:
#	$OpenBSD: GENERIC.MP,v 1.1 2014/01/26 17:40:11 miod Exp $

include "arch/alpha/conf/GENERIC"

option	MULTIPROCESSOR
#option	MP_LOCKDEBUG

cpu*		at mainbus?


code:
#	$OpenBSD: Makefile.alpha,v 1.87 2015/01/13 01:12:48 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=	-mno-fp-regs -Wa,-mev56
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=	-T ${LDSCRIPT} -X -N -G 4 --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

# 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.78 2015/07/17 22:52:28 tedu Exp $

machine		alpha
maxusers	4

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

option		RAMDISK_HOOKS
option		MINIROOTSIZE=5744

option		SCSITERSE

option		FFS

# CPU Support; at least one is REQUIRED
#option		DEC_3000_500	# Flamingo etc:	3000/[4-9]00*
#option		DEC_3000_300	# Pelican etc:	3000/300*
option		DEC_2100_A50	# Avanti etc:	AlphaStation 400, 200, etc.
option		DEC_KN20AA	# KN20AA:	AlphaStation 600
option		DEC_KN300	# KN300:	AlphaServer 4100 and 1200
option		DEC_AXPPCI_33	# NoName:	AXPpci33, etc.
option		DEC_EB164	# EB164:	AlphaPC 164
#option		DEC_EB64PLUS	# EB64+:	AlphaPC 64, etc.
option		DEC_2000_300	# "Jensen":	2000/300 (DECpc AXP 150)
option		DEC_550		# Miata:	Digital Personal Workstation
option		DEC_1000	# Mikasa etc:	Digital AlphaServer 1000
option		DEC_1000A	# Corelle etc:	Digital AlphaServer 800/1000A
#option		DEC_6600	# EV6:		XP1000, 264DP OEM Board
#option		API_UP1000	# EV6:		Alpha Processor UP1000
option		NO_IEEE		# Disable IEEE math

option		WSKBD_NO_INTL_LAYOUTS	# no international keyboard layouts

config		bsd root on rd0a swap on rd0b and wd0b and sd0b

mainbus0	at root
cpu*		at mainbus0

mcbus*		at mainbus?
mcmem*		at mcbus? mid?

apecs*		at mainbus?
cia*		at mainbus?
lca*		at mainbus?
mcpcia*		at mcbus? mid?

pci*		at apecs?
pci*		at cia?
pci*		at lca?
pci*		at ppb?
pci*		at mcpcia?

#ahc*		at pci?				# AHA-28xx SCSI (NOT 64-BIT)
de*		at pci?				# 21x4[012]-based Ethernet
dc*		at pci?				# 21143, "tulip" clone ethernet
fxp*		at pci?				# EtherExpress 10/100B ethernet cards
siop*		at pci?				# NCR 53c8xx SCSI
pceb*		at pci?				# Intel PCI-EISA bridge
vga*		at pci?				# PCI VGA graphics
ppb*		at pci?				# PCI-PCI bridges
sio*		at pci?				# Intel PCI-ISA bridge
tga*		at pci?				# DEC ZLXp-E[123] graphics
pcn*		at pci?				# AMD PCnet-PCI Ethernet

qlw*		at pci?				# QLogic ISP SCSI
qla*		at pci?				# QLogic ISP 2[123]xx FibreChannel
option		ISP_NOFIRMWARE

amphy*		at mii?				# AMD 79C873 PHYs
bmtphy*		at mii?				# Broadcom 10/100 PHYs
dcphy*		at mii?				# Digital Clone PHYs
lxtphy*		at mii?				# Level1 LXT970 PHYs
mtdphy*		at mii?				# Myson MTD972 PHYs
nsphy*		at mii?				# NS and compatible PHYs
nsphyter*	at mii?			# NS and compatible PHYs
sqphy*		at mii?				# Seeq 8x220 PHYs
tqphy*		at mii?				# TDK 78Q212x PHYs
ukphy*		at mii?				# "unknown" PHYs

isa*		at pceb?
isa*		at sio?

mcclock*	at isa? port 0x70
pckbc*		at isa?				# PC keyboard controller
pckbd*		at pckbc?			# PC keyboard (kbd port)
com*		at isa? port 0x3f8 irq 4	# standard serial ports
com*		at isa? port 0x2f8 irq 3
vga*		at isa?				# ISA (EISA: XXX) VGA

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

scsibus*	at scsi?
sd*		at scsibus?			# SCSI disk drives
cd*		at scsibus?			# SCSI CD-ROM drives

wsdisplay*	at vga?
wsdisplay*	at tga?
wskbd*		at pckbd? mux 1

pseudo-device	bpfilter 1
pseudo-device	loop 1
pseudo-device	rd 1
pseudo-device	wsmux 2

path: sys/arch/alpha/conf/RAMDISK


code:
#	$OpenBSD: RAMDISKB,v 1.44 2015/07/17 22:52:28 tedu Exp $

machine		alpha
maxusers	4

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

option		RAMDISK_HOOKS
option		MINIROOTSIZE=5744

option		SCSITERSE

option		FFS

#option		DEC_3000_500	# Flamingo etc:	3000/[4-9]00*
#option		DEC_3000_300	# Pelican etc:	3000/300*
#option		DEC_2100_A50	# Avanti etc:	AlphaStation 400, 200, etc.
#option		DEC_KN20AA	# KN20AA:	AlphaStation 600
#option		DEC_AXPPCI_33	# NoName:	AXPpci33, etc.
#option		DEC_EB164	# EB164:	AlphaPC 164
#option		DEC_EB64PLUS	# EB64+:	AlphaPC 64, etc.
#option		DEC_2000_300	# "Jensen":	2000/300 (DECpc AXP 150)
#option		DEC_550		# Miata:	Digital Personal Workstation
#option		DEC_1000	# Mikasa etc:	Digital AlphaServer 1000
#option		DEC_1000A	# Corelle etc:	Digital AlphaServer 800/1000A
option		DEC_6600	# EV6:		XP1000, 264DP OEM Board
option		API_UP1000	# EV6:		Alpha Processor UP1000

option		WSKBD_NO_INTL_LAYOUTS	# no international keyboard layouts

config		bsd root on rd0a swap on rd0b and wd0b and sd0b

mainbus0	at root
cpu*		at mainbus0
option		NO_IEEE		# Disable IEEE math

irongate*	at mainbus?
tsc*		at mainbus0
tsp*		at tsc?

pci*		at irongate?
pci*		at tsp?
pci*		at ppb?

ahc*		at pci?				# AHA-28xx SCSI (NOT 64-BIT)
de*		at pci?				# 21x4[012]-based Ethernet
dc*		at pci?				# 21143, "tulip" clone ethernet
siop*		at pci?				# NCR 53c8xx SCSI
pceb*		at pci?				# Intel PCI-EISA bridge
vga*		at pci?				# PCI VGA graphics
ppb*		at pci?				# PCI-PCI bridges
sio*		at pci?				# Intel PCI-ISA bridge
tga*		at pci?				# DEC ZLXp-E[123] graphics

qlw*		at pci?				# QLogic ISP SCSI
qla*		at pci?				# Qlogic ISP 2[123]xx FibreChannel
option		ISP_NOFIRMWARE

amphy*		at mii?				# AMD 79C873 PHYs
bmtphy*		at mii?				# Broadcom 10/100 PHYs
dcphy*		at mii?				# Digital Clone PHYs
lxtphy*		at mii?				# Level1 LXT970 PHYs
mtdphy*		at mii?				# Myson MTD972 PHYs
sqphy*		at mii?				# Seeq 8x220 PHYs
tqphy*		at mii?				# TDK 78Q212x PHYs
ukphy*		at mii?				# "unknown" PHYs

isa*		at pceb?
isa*		at sio?

mcclock*	at isa? port 0x70
pckbc*		at isa?				# PC keyboard controller
pckbd*		at pckbc?			# PC keyboard (kbd port)
com*		at isa? port 0x3f8 irq 4	# standard serial ports
com*		at isa? port 0x2f8 irq 3

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

scsibus*	at scsi?
#cd*		at scsibus?			# SCSI CD-ROM drives
sd*		at scsibus?			# SCSI disk drives

wsdisplay*	at vga?
wsdisplay*	at tga?
wskbd*		at pckbd? mux 1

pseudo-device	loop 1
pseudo-device	rd 1

path: sys/arch/alpha/conf/RAMDISKB


code:
#	$OpenBSD: RAMDISKBIG,v 1.97 2015/07/17 22:52:28 tedu Exp $

machine		alpha
maxusers	4

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

option		RAMDISK_HOOKS
option		MINIROOTSIZE=5744

option		EISAVERBOSE
option		PCIVERBOSE
option		TCVERBOSE

option		FFS
option		FFS2
option		CD9660
option		INET6

option		DEC_3000_500	# Flamingo etc:	3000/[4-9]00*
option		DEC_3000_300	# Pelican etc:	3000/300*
option		DEC_2100_A50	# Avanti etc:	AlphaStation 400, 200, etc.
option		DEC_KN20AA	# KN20AA:	AlphaStation 600
option		DEC_KN300	# KN300:	AlphaServer 4100 and 1200
option		DEC_AXPPCI_33	# NoName:	AXPpci33, etc.
option		DEC_EB164	# EB164:	AlphaPC 164
option		DEC_EB64PLUS	# EB64+:	AlphaPC 64, etc.
option		DEC_2000_300	# "Jensen":	2000/300 (DECpc AXP 150)
option		DEC_550		# Miata:	Digital Personal Workstation
option		DEC_1000	# Mikasa etc:	Digital AlphaServer 1000
option		DEC_1000A	# Corelle etc:	Digital AlphaServer 800/1000A
option		DEC_6600	# EV6:		XP1000, 264DP OEM Board
option		API_UP1000	# EV6:		Alpha Processor UP1000

config		bsd root on rd0a swap on rd0b and wd0b and sd0b

mainbus0	at root
cpu*		at mainbus0
option		NO_IEEE		# Disable IEEE math

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

uhub*		at usb?
uhub*		at uhub?
uhidev*		at uhub?
uhid*		at uhidev?		# USB Generic HID devices
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
cdce*		at uhub?		# CDC Ethernet
cue*		at uhub?		# CATC USB-EL1201A based Ethernet
kue*		at uhub?		# Kawasaki KL5KUSB101B based Ethernet
smsc*		at uhub?		# SMSC LAN95xx Ethernet
udav*		at uhub?		# Davicom DM9601 based Ethernet
upl*		at uhub?		# Prolific PL2301/PL2302 host-to-host
ugl*		at uhub?		# Genesys Logic GL620USB-A host-to-host
url*		at uhub?		# Realtek RTL8150L based adapters
wi*		at uhub?		# WaveLAN IEEE 802.11DS

mcbus*		at mainbus0
mcmem*		at mcbus? mid ?

tcasic*		at mainbus0
tc*		at tcasic?
ioasic*		at tc?
mcclock*	at ioasic?
le*		at ioasic?
scc0		at ioasic?
scc1		at ioasic?
tcds*		at tc?
asc*		at tcds?
asc*		at tc?
#cfb*		at tc?
#sfb*		at tc?
le*		at tc?

apecs*		at mainbus?
cia*		at mainbus?
irongate*	at mainbus?
lca*		at mainbus?
tsc*		at mainbus0
tsp*		at tsc?
mcpcia*		at mcbus? mid?

pci*		at apecs?
pci*		at cia?
pci*		at irongate?
pci*		at lca?
pci*		at ppb?
pci*		at tsp?
pci*		at mcpcia?

ppb*		at pci?
sio*		at pci?			# Intel PCI-ISA bridge
pceb*		at pci?			# Intel PCI-EISA bridge

ahc*		at pci?			# Adaptec 2940 SCSI controllers
qlw*		at pci?			# QLogic ISP SCSI
qla*		at pci?			# Qlogic ISP 2[123]xx SCSI/FibreChannel
qle*		at pci?			# Qlogic ISP 2[45]xx SCSI/FibreChannel
siop*		at pci?			# NCR 53c8xx SCSI
pcscp*		at pci?			# AMD 53c974 PCscsi-PCI SCSI
twe*		at pci?			# 3ware Escalade RAID controllers
softraid0	at root
adw*		at pci?			# AdvanSys ULTRA WIDE SCSI
ciss*		at pci?			# Compaq Smart ARRAY [56]* RAID
gdt*		at pci?			# ICP Vortex GDT RAID controllers

pcn*		at pci?			# AMD PCnet-PCI Ethernet
de*		at pci?			# 21x4[012]-based Ethernet
dc*		at pci?			# 21143, "tulip" clone ethernet
ne*		at pci?			# NE2000-compat ethernet cards
fxp*		at pci?			# EtherExpress 10/100B ethernet
ep*		at pci?			# 3COM 3c59x
xl*		at pci?			# 3COM 3c9xx
txp*		at pci?			# 3COM 3CR990
bge*		at pci?			# Broadcom BCM570x (aka Tigon3)
vge*		at pci?			# VIA VT612x
re*		at pci?			# Realtek 8169/8169S/8110S
stge*		at pci?			# Sundance TC9021 GigE
lge*		at pci?			# Level1 LXT1001 GigE
hme*		at pci?			# Sun Happy Meal
ti*		at pci?			# Alteon Tigon 1Gb ethernet
rl*		at pci?			# Realtek 81[23]9 ethernet
vr*		at pci?			# VIA Rhine ethernet
em*		at pci?			# Intel Pro/1000 ethernet
sis*		at pci?			# SiS 900/7016 ethernet
mtd*		at pci?			# Myson MTD800/803/891
epic*		at pci?			# SMC EPIC/100 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
tl*		at pci?			# Compaq Thunderlan ethernet
ste*		at pci?			# Sundance ST201 ethernet
ral*		at pci?			# Ralink RT2500/RT2501/RT2600
xge*		at pci?			# Neterion Xframe-I/II 10Gb ethernet
sf*		at pci?			# Adaptec AIC-6915 ethernet
wb*		at pci?			# Winbond W89C840F ethernet
an*		at pci?			# Cisco/Aironet 802.11DS

vga*		at pci?			# PCI VGA graphics
tga*		at pci?			# DEC ZLXp-E[123] graphics

eephy*		at mii?			# Marvell PHYs
exphy*		at mii?			# 3Com internal PHYs
inphy*		at mii?			# Intel 82555 PHYs
iophy*		at mii?			# Intel 82553 PHYs
icsphy*		at mii?			# ICS 1890 PHYs
lxtphy*		at mii?			# Level1 LXT970 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
tlphy*		at mii?			# ThunderLAN PHYs
rlphy*		at mii?			# Realtek 8139 internal PHYs
mtdphy*		at mii?			# Myson MTD972 PHYs
dcphy*		at mii?			# Digital Clone PHYs
acphy*		at mii?			# Altima AC101 PHYs
amphy*		at mii?			# AMD 79C873 PHYs
tqphy*		at mii?			# TDK 78Q212x PHYs
bmtphy*		at mii?			# Broadcom 10/100 PHYs
brgphy*		at mii?			# Broadcom Gigabit PHYs
xmphy*		at mii?			# XaQti XMAC-II PHYs
urlphy*		at mii?			# Realtek RTL8150L internal PHY
rgephy*		at mii?			# Realtek 8169S/8110S PHY
ciphy*		at mii?			# Cicada CS8201 10/100/1000 copper PHY
ipgphy*		at mii?			# IC Plus IP1000A PHYs
mlphy*		at mii?			# Micro Linear 6692 PHY
ukphy*		at mii?			# "unknown" PHYs

isa*		at pceb?
eisa*		at pceb?
isa*		at sio?
isadma0		at isa?
isapnp0		at isa?

mcclock*	at isa? port 0x70
pckbc*		at isa?				# PC keyboard controller
pckbd*		at pckbc?			# PC keyboard (kbd port)
com*		at isa? port 0x3f8 irq 4	# standard serial ports
com*		at isa? port 0x2f8 irq 3
vga*		at isa?				# ISA (EISA: XXX) VGA
ep*		at isa?				# 3C509 ethernet cards
ep*		at isapnp?
lc0		at isa? port 0x200		# DEC EtherWorks
lc1		at isa? port 0x280		# DEC EtherWorks
ahc*		at eisa?			# Adaptec 274x, aic7770 SCSI

scsibus*	at scsi?
cd*		at scsibus?
sd*		at scsibus?
st*		at scsibus?

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

#wsdisplay*	at cfb?
#wsdisplay*	at sfb?
wsdisplay*	at vga?
wsdisplay*	at tga?
wskbd*		at pckbd? mux 1

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

path: sys/arch/alpha/conf/RAMDISKBIG


code:
#	$OpenBSD: RAMDISKC,v 1.8 2015/07/17 22:52:28 tedu Exp $

machine		alpha
maxusers	4

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

option		RAMDISK_HOOKS
option		MINIROOTSIZE=5744

option		SCSITERSE

option		FFS

option		WSKBD_NO_INTL_LAYOUTS	# no international keyboard layouts

config		bsd root on rd0a swap on rd0b and wd0b and sd0b

mainbus0	at root
cpu*		at mainbus0
option		DEC_ALPHABOOK1	# AlphaBook1:	Tadpole/DEC AlphaBook
option		NO_IEEE		# Disable IEEE math

lca*		at mainbus?

pci*		at lca?
pci*		at ppb?

siop*		at pci?				# NCR 53c8xx SCSI
pceb*		at pci?				# Intel PCI-EISA bridge
vga*		at pci?				# PCI VGA graphics
ppb*		at pci?				# PCI-PCI bridges
sio*		at pci?				# Intel PCI-ISA bridge
tga*		at pci?				# DEC ZLXp-E[123] graphics

qla*		at pci?				# Qlogic ISP 2[123]xx FibreChannel
option		ISP_NOFIRMWARE

tqphy*		at mii?				# TDK 78Q212x PHYs
ukphy*		at mii?				# "unknown" PHYs

isa*		at pceb?
isa*		at sio?

mcclock*	at isa? port 0x70
pckbc*		at isa?				# PC keyboard controller
pckbd*		at pckbc?			# PC keyboard (kbd port)
com*		at isa? port 0x3f8 irq 4	# standard serial ports
com*		at isa? port 0x2f8 irq 3
vga*		at isa?				# ISA (EISA: XXX) VGA

pciide*		at pci? flags 0x0000
wd*		at pciide? flags 0x0000
pcic0		at isa? port 0x3e0 iomem 0xd0000 iosiz 0x10000
pcic1		at isa? port 0x3e2 iomem 0xcc000 iosiz 0x10000

pcmcia*		at pcic? controller ? socket ?
ep*		at pcmcia? function ?		# 3Com 3c589 and 3c562 Eth.

scsibus*	at scsi?
#cd*		at scsibus?			# SCSI CD-ROM drives
sd*		at scsibus?			# SCSI disk drives

wsdisplay*	at vga?
wsdisplay*	at tga?
wskbd*		at pckbd? mux 1

pseudo-device	loop 1
pseudo-device	rd 1
pseudo-device	wsmux 2

path: sys/arch/alpha/conf/RAMDISKC