code:
/*	$OpenBSD: ka48.h,v 1.3 2006/03/04 19:33:21 miod Exp $	*/
/*
 * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of
 *      Lule}, Sweden and its contributors.
 * 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.
 */

/*
 * KA48 (VS4000 VLC) specific definitions. *** INCOMPLETE ! MK-990306 ***
 */

/* IPR bits definitions */
#define	PCSTS_FLUSH		 4
#define	PCSTS_ENABLE		 2
#define	PCTAG_PARITY	0x80000000
#define	PCTAG_VALID		 1

/* memory addresses of interest */
#define	KA48_INVFLT	0x20200000
#define	KA48_INVFLTSZ	16384
#define	KA48_CCR	0x23000000
#define	KA48_TAGST	0x2d000000
#define	KA48_TAGSZ	32768

#define	CCR_CENA	0x00000001
#define	CCR_SPECIO	0x00000010

#define	KA48_BWF0	0x20080014
#define	BWF0_FEN	0x01000000

/* From OpenVMS $IO440DEF & $KA440DEF */
#define	KA48_PARCTL	0x20080014
#define	KA48_PARCTL_CPEN	0x00000001	/* CPU Parity Enable? */
#define	KA48_PARCTL_NPEN	0x00000100	/* ?? Parity Enable */
#define	KA48_PARCTL_INVENA	0x01000000	/* Invalid ? Enable */
#define	KA48_PARCTL_AGS		0x02000000	/* ??? */


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

#ifndef _MACHINE_KA630_H_
#define	_MACHINE_KA630_H_

#define UVAXIISID	((u_long *)0x20040004)
#define UVAXIICPU	((struct uvaxIIcpu *)0x20080000)

#ifndef _LOCORE
struct uvaxIIcpu {
	u_short uvaxII_bdr;
	u_short uvaxII_xxx;
	u_long  uvaxII_mser;
	u_long  uvaxII_cear;
	u_long  uvaxII_dear;
};
#endif

/* Memory system err reg. */
#define	UVAXIIMSER_CD	0x00000300
#define	UVAXIIMSER_NXM	0x00000080
#define	UVAXIIMSER_LPE	0x00000040
#define	UVAXIIMSER_QPE	0x00000020
#define	UVAXIIMSER_MERR	0x000000f0
#define	UVAXIIMSER_CPUE	0x00000060
#define	UVAXIIMSER_DQPE	0x00000010
#define	UVAXIIMSER_LEB	0x00000008
#define	UVAXIIMSER_WRWP	0x00000002
#define	UVAXIIMSER_PEN	0x00000001

/* Mem. error address regs. */
#define	UVAXIICEAR_PG	0x00007fff
#define	UVAXIIDEAR_PG	0x00007fff

/*
 * Definitions specific to the ka630 MicroVAXII Q22 bus cpu card. Includes the
 * tod clock chip and the cpu registers.
 */
#define KA630CLK	((struct ka630clock *)0x200b8000)

/* Bdr register bits */
#define	KA630BDR_PWROK	0x8000
#define	KA630BDR_HLTENB	0x4000
#define	KA630BDR_CPU	0x0c00
#define	KA630BDR_BDG	0x0300
#define	KA630BDR_DSPL	0x000f

/* Clock registers and constants */
#define	MINSEC	60
#define	HRSEC	3600
#define DAYSEC	(HRSEC * 24)
#define YEARSEC	(DAYSEC * 365)

#define	KA630CLK_VRT	0200
#define	KA630CLK_UIP	0200
#define	KA630CLK_RATE	040
#define	KA630CLK_ENABLE	06
#define	KA630CLK_SET	0206
/* cpmbx bits */
#define	KA630CLK_HLTACT	03
/* halt action values */
#define	KA630CLK_RESTRT	01
#define	KA630CLK_REBOOT	02
#define	KA630CLK_HALT	03
#define	KA630CLK_DOTHIS	040
/* in progress flags */
#define	KA630CLK_BOOT	04
#define	KA630CLK_RSTRT	010
#define	KA630CLK_LANG	0360

#ifndef _LOCORE
struct ka630clock {
	u_short	sec;
	u_short	secalrm;
	u_short	min;
	u_short	minalrm;
	u_short	hr;
	u_short	hralrm;
	u_short	dayofwk;
	u_short	day;
	u_short	mon;
	u_short	yr;
	u_short	csr0;
	u_short	csr1;
	u_short	csr2;
	u_short	csr3;
	u_short	cpmbx;	/* CPMBX is used by the boot rom. see ka630-ug-3.3.3 */
};
#endif

#define KA630_NVR_ADRS	0x200B8024
/* Definitions for various locations in the KA630 console page */
#define KA630_PUTC_POLL 0x20
#define KA630_PUTC	0x24
#define KA630_GETC	0x1C
#define KA630_ROW	0x4C
#define KA630_MINROW	0x4D
#define KA630_MAXROW	0x4E
#define KA630_COL	0x50
#define KA630_MINCOL	0x51
#define KA630_MAXCOL	0x52

#endif /* _MACHINE_KA630_H_ */

license: unknown


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

/*
 *
 * Definitions specific to the ka650 (uVAX 3600/3602) cpu card.
 */

/*
 * CAER: Memory System Error Register (IPR 39)
 */
#define CAER_DAL	0x00000040	/* CDAL or level 2 cache data parity */
#define CAER_MCD	0x00000020	/* mcheck due to DAL parity error */
#define CAER_MCC	0x00000010	/* mcheck due to 1st lev cache parity */
#define CAER_DAT	0x00000002	/* data parity in 1st level cache */
#define CAER_TAG	0x00000001	/* tag parity in 1st level cache */

/*
 * DMA System Error Register (merr_dser)
 */
#define DSER_QNXM	0x00000080	/* Q-22 Bus NXM */
#define DSER_QPE	0x00000020	/* Q-22 Bus parity Error */
#define DSER_MEM	0x00000010	/* Main mem err due to ext dev DMA */
#define DSER_LOST	0x00000008	/* Lost error: DSER <7,5,4,0> set */
#define DSER_NOGRANT	0x00000004	/* No Grant timeout on cpu demand R/W */
#define DSER_DNXM	0x00000001	/* DMA NXM */
#define DSER_CLEAR 	(DSER_QNXM | DSER_QPE | DSER_MEM |  \
			 DSER_LOST | DSER_NOGRANT | DSER_DNXM)
#define DMASER_BITS \
"\20\20BHALT\17DCNEG\10QBNXM\6QBPE\5MEMERR\4LOSTERR\3NOGRANT\1DMANXM"

#ifndef _LOCORE
/*
 * Local registers (in I/O space)
 * This is done in disjoint sections.  Map names are set in locore.s
 * and they are mapped in routine configcpu()
 */

/*
 * memory error & configuration registers
 */
struct ka650_merr {
	u_long	merr_scr;	/* System Config Register */
	u_long	merr_dser;	/* DMA System Error Register */
	u_long	merr_qbear;	/* QBus Error Address Register */
	u_long	merr_dear;	/* DMA Error Address Register */
	u_long	merr_qbmbr;	/* Q Bus Map Base address Register */
	u_long	pad[59];
	u_long	merr_csr[16];	/* Main Memory Config Regs (16 banks) */
	u_long	merr_errstat;	/* Main Memory Error Status */
	u_long	merr_cont;	/* Main Memory Control */
};
#define KA650_MERR	0x20080000

/*
 * Main Memory Error Status Register (merr_errstat)
 */
#define MEM_EMASK	0xe0000180	/* mask of all err bits */
#define MEM_RDS		0x80000000	/* uncorrectable main memory */
#define MEM_RDSHIGH	0x40000000	/* high rate RDS errors */
#define MEM_CRD		0x20000000	/* correctable main memory */
#define MEM_DMA		0x00000100	/* DMA read or write error */
#define MEM_CDAL	0x00000080	/* CDAL Parity error on write */
#define MEM_PAGE	0x1ffffe00	/* Offending Page Number */
#define MEM_PAGESHFT	9		/* Shift to normalize page number */

/*
 * Main Memory Control & Diag Status Reg (merr_cont)
 */
#define MEM_CRDINT	0x00001000	/* CRD interrupts enabled */
#define MEM_REFRESH	0x00000800	/* Forced memory refresh */
#define MEM_ERRDIS	0x00000400	/* error detect disable	*/
#define MEM_DIAG	0x00000080	/* Diagnostics mode */
#define MEM_CHECK	0x0000007f	/* check bits for diagnostic mode */

/*
 * Main Memory Config Regs (merr_csr[0-15])
 */
#define MEM_BNKENBLE	0x80000000	/* Bank Enable */
#define MEM_BNKNUM	0x03c00000	/* Physical map Bank number */
#define MEM_BNKUSAGE	0x00000003	/* Bank Usage */

/*
 * Cache Control & Boot/Diag registers
 */
struct ka650_cbd {
	u_char	cbd_cacr;	/* Low byte: Cache Enable & Parity Err detect */
	u_char	cbd_cdf1;	/* Cache diagnostic field (unused) */
	u_char	cbd_cdf2;	/* Cache diagnostic field (unused) */
	u_char	pad;
	u_long	cbd_bdr;	/* Boot & Diagnostic Register (unused) */
};
#define KA650_CBD	0x20084000

/*
 * CACR: Cache Control Register (2nd level cache) (cbd_cacr)
 */
#define CACR_CEN	0x00000010	/* Cache enable */
#define CACR_CPE	0x00000020	/* Cache Parity Error */

/*
 * Inter Processor Communication Register
 * To determine if memory error was from QBUS device DMA (as opposed to cpu).
 */
struct ka650_ipcr {
	u_long	pad[80];
	u_short	ipcr0;		/* InterProcessor Comm Reg for arbiter */
};
#define KA650_IPCR	0x20001e00

#endif /* _LOCORE */

/*
 * Mapping info for Cache Entries, including
 * Size (in bytes) of 2nd Level Cache for cache flush operation
 */
#define KA650_CACHE	0x10000000
#define KA650_CACHESIZE	(64*1024)

/*
 * Useful ROM addresses
 */
#define	KA650ROM_SIDEX	0x20060004	/* system ID extension */
#define	KA650ROM_GETC	0x20060008	/* (jsb) get character from console */
#define	KA650ROM_PUTS	0x2006000c	/* (jsb) put string to console */
#define	KA650ROM_GETS	0x20060010	/* (jsb) read string with prompt */
#define KA650_CONSTYPE	0x20140401	/* byte at which console type resides */

/*
 * Some useful macros
 */
#define	GETFRMREV(x)	((x >> 16) & 0xff)
#define	GETCODREV(x)	(x & 0xff)


code:
/*	$OpenBSD: ka670.h,v 1.1 2000/04/26 06:08:27 bjc Exp $	*/
/*	$NetBSD: ka670.h,v 1.1 1999/06/06 14:23:46 ragge Exp $	*/
/*
 * Copyright (c) 1999 Ludd, University of Lule}, Sweden.
 * All rights reserved.
 *
 * This code is derived from software contributed to Ludd by Bertram Barth.
 *
 * 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 at Ludd, University of
 *      Lule}, Sweden and its contributors.
 * 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.
 */

/*
 * Definitions for I/O addresses of
 *
 *	VAX 4000/300 (KA670)
 */

#define KA670_SIDEX	0x20040004	/* SID extension register */
#define KA670_IORESET	0x20020000	/* I/O Reset register */

#define KA670_ROM_BASE	0x20040000	/* System module ROM */
#define KA670_ROM_END	0x2007FFFF
#define KA670_ROM_SIZE	   0x40000

/*
 * The following values refer to bits/bitfields within the 4 internal
 * registers controlling primary cache:
 * PR_PCTAG(124, tag-register)		PR_PCIDX(125, index-register)
 * PR_PCERR(126, error-register)	PR_PCSTS(127, status-register)
 */
#define KA670_PCTAG_TAG		0x1FFFF800	/* bits 11-29 */
#define KA670_PCTAG_PARITY	0x40000000
#define KA670_PCTAG_VALID	0x80000000

#define KA670_PCIDX_INDEX	0x000007F8	/* 0x100 Q-word entries */

#define KA670_PCERR_ADDR		0x3FFFFFFF

#define KA670_PCS_FORCEHIT	0x00000001	/* Force hit */
#define KA670_PCS_ENABLE		0x00000002	/* Enable primary cache */
#define KA670_PCS_FLUSH		0x00000004	/* Flush cache */
#define KA670_PCS_REFRESH	0x00000008	/* Enable refresh */
#define KA670_PCS_HIT		0x00000010	/* Cache hit */
#define KA670_PCS_INTERRUPT	0x00000020	/* Interrupt pending */
#define KA670_PCS_TRAP2		0x00000040	/* Trap while trap */
#define KA670_PCS_TRAP1		0x00000080	/* Micro trap/machine check */
#define KA670_PCS_TPERR		0x00000100	/* Tag parity error */
#define KA670_PCS_DPERR		0x00000200	/* Dal data parity error */
#define KA670_PCS_PPERR		0x00000400	/* P data parity error */
#define KA670_PCS_BUSERR		0x00000800	/* Bus error */
#define KA670_PCS_BCHIT		0x00001000	/* B cache hit */

#define KA670_PCSTS_BITS \
	"\020\015BCHIT\014BUSERR\013PPERR\012DPERR\011TPERR\010TRAP1" \
	"\007TRAP2\006INTR\005HIT\004REFRESH\003FLUSH\002ENABLE\001FORCEHIT"

#define KA670_BCSTS_BITS \
	"\020\015BCHIT\014BUSERR\013PPERR\012DPERR\011TPERR\010TRAP1" \
	"\007TRAP2\006INTR\005HIT\004REFRESH\003FLUSH\002ENABLE\001FORCEHIT"

/*
 * Bits in PR_ACCS (Floating Point Accelerator Register)
 */
#define KA670_ACCS_VECTOR	(1<<0)	/* Vector Unit Present */
#define KA670_ACCS_FCHIP		(1<<1)	/* FPU chip present */
#define KA670_ACCS_WEP		(1<<31)	/* Write Even Parity */


code:
/*	$OpenBSD: ka680.h,v 1.1 2001/02/24 10:31:56 hugh Exp $	*/
/*	$NetBSD: ka680.h,v 1.1 2001/02/05 13:20:10 ragge Exp $	*/
/*
 * Copyright (c) 1998 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of
 *      Lule}, Sweden and its contributors.
 * 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.
 */

/* Done by Michael Kukat (michael@unixiron.org) */

/*
 * KA675/680 (VAX4000/[45]00) specific definitions.
 */

/* IPR bits definitions */
#define        PCSTS_FLUSH              4
#define        PCSTS_ENABLE             2
#define        PCTAG_PARITY    0x80000000
#define        PCTAG_VALID              1

/* memory addresses of interest */
#define        KA680_INVFLT    0x20200000
#define        KA680_INVFLTSZ  32768
#define        KA680_CCR       0x23000000
#define        KA680_TAGST     0x2d000000
#define        KA680_TAGSZ     32768

#define        CCR_CENA        0x00000001
#define        CCR_SPECIO      0x00000010

#define        KA680_BWF0      0x20080014
#define        BWF0_FEN        0x01000000


code:
/*	$OpenBSD: kcore.h,v 1.1 2006/06/11 22:09:32 miod Exp $	*/
/* public domain */

/* Keep this define consistent with VM_PHYSSEG_MAX in <machine/vmparam.h> */
#define	NPHYS_RAM_SEGS	1

typedef struct cpu_kcore_hdr {
	vaddr_t		sysmap;
	phys_ram_seg_t	ram_segs[NPHYS_RAM_SEGS];
} cpu_kcore_hdr_t;


code:
/*	$OpenBSD: limits.h,v 1.16 2015/04/30 13:42:08 millert Exp $	*/
/*	$NetBSD: limits.h,v 1.9 2000/03/07 19:33:01 kleink Exp $	*/

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

#ifndef _MACHINE_LIMITS_H_
#define _MACHINE_LIMITS_H_

#include <sys/cdefs.h>

#if __POSIX_VISIBLE || __XPG_VISIBLE
#define	SSIZE_MAX	LONG_MAX	/* max value for a ssize_t */
#endif

#if __BSD_VISIBLE
#define	SIZE_T_MAX	ULONG_MAX	/* max value for a size_t (historic) */

#define UQUAD_MAX       0xffffffffffffffffULL           /* max unsigned quad */
#define QUAD_MAX        0x7fffffffffffffffLL            /* max signed quad */
#define QUAD_MIN        (-0x7fffffffffffffffLL-1)       /* min signed quad */

#endif /* __BSD_VISIBLE */

#endif /* _MACHINE_LIMITS_H_ */


code:
/*	$OpenBSD: loadfile_machdep.h,v 1.3 2013/10/17 11:54:02 miod Exp $	*/

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

#define BOOT_ELF
#define ELFSIZE 32

#define LOAD_KERNEL	LOAD_ALL
#define COUNT_KERNEL	COUNT_ALL

#define LOADADDR(a)		(((u_long)(a)) + offset)
#define ALIGNENTRY(a)		(0)
#define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
#define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
#define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
#define	WARN(a)			(void)(printf a, \
				    printf((errno ? ": %s\n" : "\n"), \
				    strerror(errno)))
#define PROGRESS(a)		(void) printf a
#define ALLOC(a)		alloc(a)
#define FREE(a, b)		free(a, b)


code:
/*	$OpenBSD: lock.h,v 1.4 2013/05/21 20:05:30 tedu Exp $	*/

/* public domain */

#ifndef	_MACHINE_LOCK_H_
#define	_MACHINE_LOCK_H_

#include <machine/atomic.h>

#endif	/* _MACHINE_LOCK_H_ */


code:
/*	$OpenBSD: macros.h,v 1.22 2014/03/29 18:09:30 guenther Exp $ */
/*	$NetBSD: macros.h,v 1.20 2000/07/19 01:02:52 matt Exp $	*/

/*
 * Copyright (c) 1994, 1998, 2000 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

 /* All bugs are subject to removal without further notice */

#ifndef _MACHINE_MACROS_H_
#define _MACHINE_MACROS_H_

/* Here general macros are supposed to be stored */

static __inline__ int
ffs(int reg)
{
	register int val;

	__asm__ volatile ("ffs	$0,$32,%1,%0;"
		"	bneq	1f;"
		"	mnegl	$1,%0;"
		"1:	incl	%0"
			: "=&r" (val)
			: "r" (reg) );
	return	val;
}

static __inline__ size_t
strlen(const char *cp)
{
	register size_t ret;

	__asm__ volatile("locc $0,$65535,(%1);subl3 %%r0,$65535,%0"
			: "=r" (ret)
			: "r" (cp)
			: "r0","r1","cc" );
	return	ret;
}

#if 0
static __inline__ char *
strncat(char *cp, const char *c2, size_t count)
{
	__asm__ volatile("locc $0,%2,(%1);subl3 %%r0,%2,%%r2;"
			   "locc $0,$65535,(%0);movc3 %%r2,(%1),(%%r1);"
			   "movb $0,(%%r3)"
			:
			: "r" (cp), "r" (c2), "g"(count)
			: "r0","r1","r2","r3","r4","r5","memory","cc");
	return	cp;
}
#endif

static __inline__ char *
strncpy(char *cp, const char *c2, size_t len)
{
	__asm__ volatile("movl %2,%%r2;locc $0,%%r2,(%1);beql 1f;"
			   "subl3 %%r0,%2,%%r2;clrb (%0)[%%r2];1:"
			   "movc3 %%r2,(%1),(%0)"
			:
			: "r" (cp), "r" (c2), "g"(len)
			: "r0","r1","r2","r3","r4","r5","memory","cc");
	return	cp;
}

static __inline__ void *
memchr(const void *cp, int c, size_t len)
{
	void *ret;
	__asm__ volatile("locc %2,%3,(%1);bneq 1f;clrl %%r1;1:movl %%r1,%0"
			: "=g"(ret)
			: "r" (cp), "r" (c), "g"(len)
			: "r0","r1","cc");
	return	ret;
}

static __inline__ int
strcmp(const char *cp, const char *c2)
{
	register int ret;
	__asm__ volatile("locc $0,$65535,(%1);subl3 %%r0,$65535,%%r0;"
			   "incl %%r0;cmpc3 %%r0,(%1),(%2);beql 1f;"
			   "movl $1,%%r2;cmpb (%%r1),(%%r3);bcc 1f;"
			   "movl $-1,%%r2;1:movl %%r2,%0"
			: "=g"(ret)
			: "r" (cp), "r" (c2)
			: "r0","r1","r2","r3","cc");
	return	ret;
}
/* End nya */

#if 0 /* unused, but no point in deleting it since it _is_ an instruction */
static __inline__ int
locc(int mask, char *cp, size_t size)
{
	register ret;

	__asm__ volatile("locc %1,%2,(%3);movl %%r0,%0"
			: "=r" (ret)
			: "r" (mask),"r"(size),"r"(cp)
			: "r0","r1" );
	return	ret;
}
#endif

static __inline__ int
scanc(u_int size, const u_char *cp, const u_char *table, int mask)
{
	register int ret;

	__asm__ volatile("scanc %1,(%2),(%3),%4;movl %%r0,%0"
			: "=g"(ret)
			: "r"(size),"r"(cp),"r"(table),"r"(mask)
			: "r0","r1","r2","r3" );
	return ret;
}

static __inline__ int
skpc(int mask, size_t size, u_char *cp)
{
	register int ret;

	__asm__ volatile("skpc %1,%2,(%3);movl %%r0,%0"
			: "=g"(ret)
			: "r"(mask),"r"(size),"r"(cp)
			: "r0","r1" );
	return	ret;
}

#define	cpu_switchto(o, n) \
	__asm__ volatile( \
	    "movl %0, %%r0; movl %1, %%r1; movpsl -(%%sp); jsb __cpu_switchto" \
	    :: "g"(o), "g"(n) : "r0", "r1");

/*
 * Interlock instructions. Used both in multiprocessor environments to
 * lock between CPUs and in uniprocessor systems when locking is required
 * between I/O devices and the master CPU.
 */
/*
 * Insqti() locks and inserts an element into the end of a queue.
 * Returns -1 if interlock failed, 1 if inserted OK and 0 if first in queue.
 */
static __inline__ int
insqti(void *entry, void *header) {
	register int ret;

	__asm__ volatile(
		"	mnegl $1,%0;"
		"	insqti (%1),(%2);"
		"	bcs 1f;			# failed insert"
		"	beql 2f;		# jump if first entry"
		"	movl $1,%0;"
		"	brb 1f;"
		"2:	clrl %0;"
		"	1:;"
			: "=&g"(ret)
			: "r"(entry), "r"(header)
			: "memory");

	return ret;
}

/*
 * Remqhi() removes an element from the head of the queue.
 * Returns -1 if interlock failed, 0 if queue empty, address of the
 * removed element otherwise.
 */
static __inline__ void *
remqhi(void *header) {
	register void *ret;

	__asm__ volatile(
		"	remqhi (%1),%0;"
		"	bcs 1f;			# failed interlock"
		"	bvs 2f;			# nothing was removed"
		"	brb 3f;"
		"1:	mnegl $1,%0;"
		"	brb 3f;"
		"2:	clrl %0;"
		"	3:;"
			: "=&g"(ret)
			: "r"(header)
			: "memory");

	return ret;
}
#define	ILCK_FAILED	-1	/* Interlock failed */
#define	Q_EMPTY		0	/* Queue is/was empty */
#define	Q_OK		1	/* Inserted OK */

#endif	/* _MACHINE_MACROS_H_ */


code:
/*      $OpenBSD: mtpr.h,v 1.9 2014/03/29 18:09:30 guenther Exp $     */
/*      $NetBSD: mtpr.h,v 1.12 1999/06/06 19:06:29 ragge Exp $     */

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

 /* All bugs are subject to removal without further notice */

#ifndef	_MACHINE_MTPR_H_
#define	_MACHINE_MTPR_H_

/******************************************************************************

  Processor register numbers in the VAX		/IC

******************************************************************************/

#define PR_KSP     0 /* Kernel Stack Pointer */
#define PR_ESP     1 /* Executive Stack Pointer */
#define PR_SSP     2 /* Supervisor Stack Pointer */
#define PR_USP     3 /* User Stack Pointer */
#define PR_ISP     4 /* Interrupt Stack Pointer */

#define PR_P0BR    8 /* P0 Base Register */
#define PR_P0LR    9 /* P0 Length Register */
#define PR_P1BR   10 /* P1 Base Register */
#define PR_P1LR   11 /* P1 Length Register */
#define PR_SBR    12 /* System Base Register */
#define PR_SLR    13 /* System Limit Register */
#define PR_PCBB   16 /* Process Control Block Base */
#define PR_SCBB   17 /* System Control Block Base */
#define PR_IPL    18 /* Interrupt Priority Level */
#define PR_ASTLVL 19 /* AST Level */
#define PR_SIRR   20 /* Software Interrupt Request */
#define PR_SISR   21 /* Software Interrupt Summary */
#define	PR_IPIR	  22 /* KA820 Interprocessor register */
#define PR_MCSR   23 /* Machine Check Status Register 11/750 */
#define PR_ICCS   24 /* Interval Clock Control */
#define PR_NICR   25 /* Next Interval Count */
#define PR_ICR    26 /* Interval Count */
#define PR_TODR   27 /* Time Of Year (optional) */
#define	PR_CSRS	  28 /* Console Storage R/S */
#define	PR_CSRD	  29 /* Console Storage R/D */
#define	PR_CSTS	  30 /* Console Storage T/S */
#define	PR_CSTD	  31 /* Console Storage T/D */
#define PR_RXCS   32 /* Console Receiver C/S */
#define PR_RXDB   33 /* Console Receiver D/B */
#define PR_TXCS   34 /* Console Transmit C/S */
#define PR_TXDB   35 /* Console Transmit D/B */
#define PR_TBDR   36 /* Translation Buffer Group Disable Register 11/750 */
#define PR_CADR   37 /* Cache Disable Register 11/750 */
#define PR_MCESR  38 /* Machine Check Error Summary Register 11/750 */
#define PR_CAER   39 /* Cache Error Register 11/750 */
#define PR_ACCS   40 /* Accelerator control register */
#define PR_SAVISP 41 /* Console Saved ISP */
#define PR_SAVPC  42 /* Console Saved PC */
#define PR_SAVPSL 43 /* Console Saved PSL */
#define PR_WCSA   44 /* WCS Address */
#define PR_WCSB   45 /* WCS Data */
#define PR_SBIFS  48 /* SBI Fault/Status */
#define PR_SBIS   49 /* SBI Silo */
#define PR_SBISC  50 /* SBI Silo Comparator */
#define PR_SBIMT  51 /* SBI Silo Maintenance */
#define PR_SBIER  52 /* SBI Error Register */
#define PR_SBITA  53 /* SBI Timeout Address Register */
#define PR_SBIQC  54 /* SBI Quadword Clear */
#define PR_IUR    55 /* Initialize Unibus Register 11/750 */
#define PR_MAPEN  56 /* Memory Management Enable */
#define PR_TBIA   57 /* Trans. Buf. Invalidate All */
#define PR_TBIS   58 /* Trans. Buf. Invalidate Single */
#define PR_TBDATA 59 /* Translation Buffer Data */
#define PR_MBRK   60 /* Microprogram Break */
#define PR_PMR    61 /* Performance Monitor Enable */
#define PR_SID    62 /* System ID Register */
#define PR_TBCHK  63 /* Translation Buffer Check */

#define	PR_PAMACC 64 /* Physical Address Memory Map Access (KA86) */
#define	PR_PAMLOC 65 /* Physical Address Memory Map Location (KA86) */
#define PR_CSWP   66 /* Cache Sweep (KA86) */
#define PR_MDECC  67 /* MBOX Data Ecc Register (KA86) */
#define PR_MENA   68 /* MBOX Error Enable Register (KA86) */
#define PR_MDCTL  69 /* MBOX Data Control Register (KA86) */
#define PR_MCCTL  70 /* MBOX Mcc Control Register (KA86) */
#define PR_MERG   71 /* MBOX Error Generator Register (KA86) */
#define PR_CRBT   72 /* Console Reboot (KA86) */
#define PR_DFI    73 /* Diagnostic Fault Insertion Register (KA86) */
#define PR_EHSR   74 /* Error Handling Status Register (KA86) */
#define PR_STXCS  76 /* Console Storage C/S (KA86) */
#define PR_STXDB  77 /* Console Storage D/B (KA86) */
#define PR_ESPA   78 /* EBOX Scratchpad Address (KA86) */
#define PR_ESPD   79 /* EBOX Scratchpad Data (KA86) */

#define	PR_RXCS1  80 /* Serial-Line Unit 1 Receive CSR (KA820) */
#define	PR_RXDB1  81 /* Serial-Line Unit 1 Receive Data Buffer (KA820) */
#define	PR_TXCS1  82 /* Serial-Line Unit 1 Transmit CSR (KA820) */
#define	PR_TXDB1  83 /* Serial-Line Unit 1 Transmit Data Buffer (KA820) */
#define	PR_RXCS2  84 /* Serial-Line Unit 2 Receive CSR (KA820) */
#define	PR_RXDB2  85 /* Serial-Line Unit 2 Receive Data Buffer (KA820) */
#define	PR_TXCS2  86 /* Serial-Line Unit 2 Transmit CSR (KA820) */
#define	PR_TXDB2  87 /* Serial-Line Unit 2 Transmit Data Buffer (KA820) */
#define	PR_RXCS3  88 /* Serial-Line Unit 3 Receive CSR (KA820) */
#define	PR_RXDB3  89 /* Serial-Line Unit 3 Receive Data Buffer (KA820) */
#define	PR_TXCS3  90 /* Serial-Line Unit 3 Transmit CSR (KA820) */
#define	PR_TXDB3  91 /* Serial-Line Unit 3 Transmit Data Buffer (KA820) */
#define	PR_RXCD	  92 /* Receive Console Data from another cpu (KA820) */
#define	PR_CACHEX 93 /* Cache invalidate Register (KA820) */
#define	PR_BINID  94 /* VAXBI node ID Register (KA820) */
#define	PR_BISTOP 95 /* VAXBI Stop Register (KA820) */

#define PR_BCBTS  113 /* Backup Cache Tag Store (KA670) */
#define PR_BCP1TS 114 /* Primary Tag Store 1st half (KA670) */
#define PR_BCP2TS 115 /* Primary Tag Store 2st half (KA670) */
#define PR_BCRFR  116 /* Refresh Register (KA670) */
#define PR_BCIDX  117 /* Index Register (KA670) */
#define PR_BCSTS  118 /* Status (KA670) */
#define PR_BCCTL  119 /* Control Register (KA670) */
#define PR_BCERR  120 /* Error Address (KA670) */
#define PR_BCFBTS 121 /* Flush backup tag store (KA670) */
#define PR_BCFPTS 122 /* Flush primary tag store (KA670) */

#define	PR_VINTSR 123 /* vector i/f error status (KA43/KA46) */
#define PR_PCTAG  124 /* primary cache tag store (KA43/KA46) */
#define PR_PCIDX  125 /* primary cache index (KA43/KA46) */
#define PR_PCERR  126 /* primary cache error address (KA43/KA46) */
#define PR_PCSTS  127 /* primary cache status (KA43/KA46) */

/* Definitions for AST */
#define	AST_NO	  4
#define	AST_OK	  3

#ifndef _LOCORE

static inline void
mtpr(register_t val, int reg)
{
	__asm__ volatile ("mtpr %0,%1"
			: /* No output */
			: "g" (val), "g" (reg)
			: "memory");
}

static inline register_t
mfpr(int reg)
{
	register_t __val;
	__asm__ volatile ("mfpr %1,%0"
			: "=g" (__val)
			: "g" (reg));
	return __val;
}
#endif	/* _LOCORE */

#endif /* _MACHINE_MTPR_H_ */


code:
/*	$OpenBSD: mutex.h,v 1.1 2007/02/03 20:08:50 miod Exp $	*/

/*
 * Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
 * 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. 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 ``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.
 */

#ifndef _MACHINE_MUTEX_H_
#define _MACHINE_MUTEX_H_

/*
 * Simple non-mp implementation.
 */
struct mutex {
	int mtx_lock;
	int mtx_wantipl;
	int mtx_oldipl;
};

void mtx_init(struct mutex *, int);

#define MUTEX_INITIALIZER(ipl) { 0, ipl, 0 }

#ifdef DIAGNOSTIC
#define MUTEX_ASSERT_LOCKED(mtx) do {					\
	if ((mtx)->mtx_lock == 0)					\
		panic("mutex %p not held in %s", (mtx), __func__);	\
} while (0)

#define MUTEX_ASSERT_UNLOCKED(mtx) do {					\
	if ((mtx)->mtx_lock != 0)					\
		panic("mutex %p held in %s", (mtx), __func__);		\
} while (0)
#else
#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0)
#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0)
#endif

#define MUTEX_OLDIPL(mtx)	(mtx)->mtx_oldipl

#endif


code:
/*	$OpenBSD: nexus.h,v 1.17 2011/07/06 20:44:11 miod Exp $	*/
/*	$NetBSD: nexus.h,v 1.17 2000/06/04 17:58:19 ragge Exp $	*/

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

#ifndef _MACHINE_NEXUS_H_
#define _MACHINE_NEXUS_H_

#include <machine/bus.h>

struct	mainbus_attach_args {
	int	maa_bustype;
};

/*
 * Values for bus (or pseudo-bus) types
 */
#define	VAX_VSBUS	0	/* Virtual vaxstation bus */
#define	VAX_IBUS	1	/* Internal Microvax bus */
#define	VAX_VXTBUS	2	/* Pseudo VXT2000 bus */
#define	VAX_MBUS	3	/* M-bus (KA60) */

#define	VAX_LEDS	4	/* pseudo value to attach led0 */

#ifdef _KERNEL

struct bp_conf {
	const char *type;
};

#endif

/* Memory recover defines */
#define	MCHK_PANIC	-1
#define	MCHK_RECOVERED	0

#endif /* _MACHINE_NEXUS_H_ */


code:
/*	$OpenBSD: param.h,v 1.42 2013/11/24 22:15:24 miod Exp $ */

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

#ifndef	_MACHINE_PARAM_H_
#define	_MACHINE_PARAM_H_

#define	_MACHINE	vax
#define	MACHINE		"vax"
#define	_MACHINE_ARCH	vax
#define	MACHINE_ARCH	"vax"
#define	MID_MACHINE	MID_VAX

#define	PAGE_SHIFT	12
#define	PAGE_SIZE	(1 << PAGE_SHIFT)
#define	PAGE_MASK	(PAGE_SIZE - 1)

#define	VAX_PGSHIFT	9
#define	VAX_NBPG	(1 << VAX_PGSHIFT)
#define	VAX_PGOFSET	(VAX_NBPG - 1)
#define	VAX_NPTEPG	(VAX_NBPG / 4)

#define	KERNBASE	0x80000000		/* start of kernel virtual */

#ifdef _KERNEL

#define	NBPG		PAGE_SIZE		/* bytes/page */
#define	PGSHIFT		PAGE_SHIFT		/* LOG2(PAGE_SIZE) */
#define	PGOFSET		PAGE_MASK		/* byte offset into page */

#define	UPAGES		2			/* pages of u-area */
#define	USPACE		(UPAGES * PAGE_SIZE)
#define	USPACE_ALIGN	(0)			/* u-area alignment 0-none */
#define	REDZONEADDR	(VAX_NBPG*3)		/* Must be > sizeof(struct user) */

#define	NMBCLUSTERS	1024			/* map size, max cluster allocation */

#ifndef	MSGBUFSIZE
#define	MSGBUFSIZE	(2 * PAGE_SIZE)		/* default message buffer size */
#endif

/*
 * Maximum size of the kernel malloc arena in PAGE_SIZE-sized
 * logical pages.
 */
#define	NKMEMPAGES_MAX_DEFAULT	((4 * 1024 * 1024) >> PAGE_SHIFT)

/* MD conversion macros */
#define	vax_atop(x)	(((unsigned)(x) + VAX_PGOFSET) >> VAX_PGSHIFT)
#define	vax_btop(x)	(((unsigned)(x)) >> VAX_PGSHIFT)

#include <machine/intr.h>

/* Prototype needed for delay() */
#ifndef	_LOCORE
#include <machine/cpu.h>

void	delay(int);
/* inline macros used inside kernel */
#include <machine/macros.h>
#endif

#define	DELAY(x) delay(x)
#endif /* _KERNEL */

#endif /* _MACHINE_PARAM_H_ */


code:
/*	$OpenBSD: pcb.h,v 1.9 2015/05/05 02:13:47 guenther Exp $	*/
/*	$NetBSD: pcb.h,v 1.10 1996/02/02 18:08:26 mycroft Exp $	*/

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

 /* All bugs are subject to removal without further notice */

#ifndef _MACHINE_PCB_H_
#define _MACHINE_PCB_H_

#include <machine/reg.h>
#include <machine/pte.h>

struct pcb {

  	/* Hardware registers, based on VAX special instructions */

	long	KSP;		/*  Kernel Stack Pointer      */
	long	ESP;		/*  Executive Stack Pointer   */
	long	SSP;		/*  Supervisor Stack Pointer  */
	long	USP;		/*  User Stack Pointer        */
	long	R[12];		/*  Register 0-11             */
	long	AP;		/*  Argument Pointer          */
	long	FP;		/*  Frame Pointer             */
	long	PC;		/*  Program Counter           */
	long	PSL;		/*  Program Status Longword   */
	pt_entry_t *P0BR;	/*  Page 0 Base Register      */
	long	P0LR;		/*  Page 0 Length Register    */
	pt_entry_t *P1BR;	/*  Page 1 Base Register      */
	long	P1LR;		/*  Page 1 Length Register    */

	/* Software registers, only used by kernel software */
	void   *framep;		/* Pointer to syscall frame */
	void   *iftrap;		/* Tells whether fault copy */

	paddr_t	pcb_paddr;	/* physical address of PCB */
	struct pmap *pcb_pm;	/* owning pmap */
	struct pcb *pcb_pmnext;	/* next pcb that shares this pmap */
};

#define	AST_MASK 0x07000000
#define	AST_PCB	 0x04000000

#endif /* _MACHINE_PCB_H_ */


code:
/*      $OpenBSD: pmap.h,v 1.38 2014/01/30 18:16:41 miod Exp $     */
/*	$NetBSD: pmap.h,v 1.37 1999/08/01 13:48:07 ragge Exp $	   */

/*
 * Copyright (c) 1987 Carnegie-Mellon University
 * Copyright (c) 1991 Regents of the University of California.
 * All rights reserved.
 *
 * Changed for the VAX port. /IC
 *
 * This code is derived from software contributed to Berkeley by
 * the Systems Programming Group of the University of Utah Computer
 * Science Department.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)pmap.h	7.6 (Berkeley) 5/10/91
 */

#ifndef _MACHINE_PMAP_H_
#define _MACHINE_PMAP_H_

#ifdef _KERNEL

#include <machine/pte.h>
#include <machine/mtpr.h>
#include <machine/pcb.h>

/*
 * Some constants to make life easier.
 */
#define LTOHPS		(PAGE_SHIFT - VAX_PGSHIFT)
#define LTOHPN		(1 << LTOHPS)

/*
 * Pmap structure
 */

struct pmap {
	pt_entry_t	*pm_p1ap;	/* Base of alloced p1 pte space */
	u_int		 pm_count;	/* reference count */
	struct pcb	*pm_pcbs;	/* PCBs using this pmap */
	pt_entry_t	*pm_p0br;	/* page 0 base register */
	u_long		 pm_p0lr;	/* page 0 length register */
	pt_entry_t	*pm_p1br;	/* page 1 base register */
	u_long		 pm_p1lr;	/* page 1 length register */
	struct pmap_statistics	 pm_stats;	/* Some statistics */
};

typedef struct pmap *pmap_t;

/*
 * For each vm_page_t, there is a list of all currently valid virtual
 * mappings of that page.  An entry is a pv_entry_t.
 */

struct pv_entry {
	struct pv_entry *pv_next;	/* next pv_entry */
	struct pmap	*pv_pmap;	/* pmap this entry belongs to */
	vaddr_t		 pv_va;		/* address of the virtual mapping */
};

extern	struct pmap kernel_pmap_store;

#define pmap_kernel()			(&kernel_pmap_store)

/*
 * Real nice (fast) routines to get the virtual address of a physical page
 * (and vice versa).
 */
#define pmap_map_direct(pg)	(VM_PAGE_TO_PHYS(pg) | KERNBASE)
#define pmap_unmap_direct(va)	PHYS_TO_VM_PAGE((va) & ~KERNBASE)
#define	__HAVE_PMAP_DIRECT

#define PMAP_STEAL_MEMORY

/*
 * This is the by far most used pmap routine. Make it inline.
 */

/* Routines that are best to define as macros */
#define pmap_copy(a,b,c,d,e)		/* Dont do anything */
#define pmap_collect(pm)		/* nothing */
#define pmap_update(pm)			/* nothing */
#define pmap_remove(pmap, start, slut)	pmap_protect(pmap, start, slut, 0)
#define pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
#define pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
#define pmap_reference(pmap)		(pmap)->pm_count++

/* These can be done as efficient inline macros */
#define pmap_copy_page(srcpg, dstpg) do {				\
	paddr_t __src = VM_PAGE_TO_PHYS(srcpg);				\
	paddr_t __dst = VM_PAGE_TO_PHYS(dstpg);				\
	__asm__("addl3 $0x80000000,%0,%%r0;addl3 $0x80000000,%1,%%r1;	\
	    movc3 $4096,(%%r0),(%%r1)"					\
	    :: "r"(__src),"r"(__dst):"r0","r1","r2","r3","r4","r5");	\
} while (0)

#define pmap_zero_page(pg) do {						\
	paddr_t __pa = VM_PAGE_TO_PHYS(pg);				\
	__asm__("addl3 $0x80000000,%0,%%r0;movc5 $0,(%%r0),$0,$4096,(%%r0)" \
	    :: "r"(__pa): "r0","r1","r2","r3","r4","r5");		\
} while (0)

#define pmap_proc_iflush(p,va,len)	/* nothing */
#define pmap_unuse_final(p)		/* nothing */

/* Prototypes */
void	pmap_bootstrap(void);
vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, int);
void	pmap_pinit(pmap_t);

#endif	/* _KERNEL */

struct vm_page_md {
	struct pv_entry *pv_head;
	int		 pv_attr;	/* write/modified bits */
};

#define	VM_MDPAGE_INIT(pg) \
	do { \
		(pg)->mdpage.pv_head = NULL; \
		(pg)->mdpage.pv_attr = 0; \
	} while (0)

#endif /* _MACHINE_PMAP_H_ */


code:
/*	$OpenBSD: proc.h,v 1.5 2006/04/17 20:44:45 miod Exp $	*/
/*	$NetBSD: proc.h,v 1.2 1994/10/26 08:02:21 cgd Exp $	*/

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

/*
 * Machine-dependent part of the proc structure for vax.
 */
struct mdproc {
};


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

/*
 * _mcount can't be declared static, gcc will optimize it away then.
 */
#define _MCOUNT_DECL void _mcount

/*
 * Note here: the second argument to __mcount() is pc when mcount
 * was called. Because it's already on the stack we only have to
 * push previous pc _and_ tell calls that it is only one argument
 * to __mcount, so that our return address won't get popped from stack.
 */
#define MCOUNT \
__asm__(".text; .globl mcount; mcount: pushl 16(%fp); calls $1,__mcount; rsb");

#ifdef _KERNEL
/*
 * Note that we assume splhigh() and splx() cannot call mcount()
 * recursively.
 */
#define MCOUNT_ENTER    s = splhigh()
#define MCOUNT_EXIT     splx(s)
#endif /* _KERNEL */


code:
/*      $OpenBSD: psl.h,v 1.7 2003/06/02 23:27:57 millert Exp $      */
/*      $NetBSD: psl.h,v 1.6 1997/06/07 12:15:28 ragge Exp $      */

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

#ifndef PSL_C

/*
 * VAX program status longword
 */

#define	PSL_C		0x00000001	/* carry bit */
#define	PSL_V		0x00000002	/* overflow bit */
#define	PSL_Z		0x00000004     	/* zero bit */
#define	PSL_N		0x00000008     	/* negative bit */
#define	PSL_T		0x00000010      /* trace enable bit */
#define	PSL_IPL00	0x00000000	/* interrupt priority level 0 */
#define	PSL_IPL01	0x00010000	/* interrupt priority level 1 */
#define	PSL_IPL02	0x00020000	/* interrupt priority level 2 */
#define	PSL_IPL03	0x00030000	/* interrupt priority level 3 */
#define	PSL_IPL04	0x00040000	/* interrupt priority level 4 */
#define	PSL_IPL05	0x00050000	/* interrupt priority level 5 */
#define	PSL_IPL06	0x00060000	/* interrupt priority level 6 */
#define	PSL_IPL07	0x00070000	/* interrupt priority level 7 */
#define	PSL_IPL08	0x00080000	/* interrupt priority level 8 */
#define	PSL_IPL09	0x00090000	/* interrupt priority level 9 */
#define	PSL_IPL0A	0x000a0000	/* interrupt priority level 10 */
#define	PSL_IPL0B	0x000b0000	/* interrupt priority level 11 */
#define	PSL_IPL0C	0x000c0000	/* interrupt priority level 12 */
#define	PSL_IPL0D	0x000d0000	/* interrupt priority level 13 */
#define	PSL_IPL0E	0x000e0000	/* interrupt priority level 14 */
#define	PSL_IPL0F	0x000f0000	/* interrupt priority level 15 */
#define	PSL_IPL10	0x00100000	/* interrupt priority level 16 */
#define	PSL_IPL11	0x00110000	/* interrupt priority level 17 */
#define	PSL_IPL12	0x00120000	/* interrupt priority level 18 */
#define	PSL_IPL13	0x00130000	/* interrupt priority level 19 */
#define	PSL_IPL14	0x00140000	/* interrupt priority level 20 */
#define	PSL_IPL15	0x00150000	/* interrupt priority level 21 */
#define	PSL_IPL16	0x00160000	/* interrupt priority level 22 */
#define	PSL_IPL17	0x00170000	/* interrupt priority level 23 */
#define	PSL_IPL18	0x00180000	/* interrupt priority level 24 */
#define	PSL_IPL19	0x00190000	/* interrupt priority level 25 */
#define	PSL_IPL1A	0x001a0000	/* interrupt priority level 26 */
#define	PSL_IPL1B	0x001b0000	/* interrupt priority level 27 */
#define	PSL_IPL1C	0x001c0000	/* interrupt priority level 28 */
#define	PSL_IPL1D	0x001d0000	/* interrupt priority level 29 */
#define	PSL_IPL1E	0x001e0000	/* interrupt priority level 30 */
#define	PSL_IPL1F	0x001f0000	/* interrupt priority level 31 */
#define	PSL_PREVU	0x00c00000	/* Previous user mode */
#define	PSL_K		0x00000000	/* kernel mode */
#define	PSL_E		0x01000000     	/* executive mode */
#define	PSL_S		0x02000000     	/* supervisor mode */
#define	PSL_U		0x03000000	/* user mode */
#define	PSL_IS		0x04000000	/* interrupt stack select */
#define	PSL_FPD	        0x08000000	/* first part done flag */
#define PSL_TP          0x40000000      /* trace pending */
#define	PSL_CM		0x80000000	/* compatibility mode */

#define	PSL_LOWIPL	(PSL_K)
#define	PSL_HIGHIPL	(PSL_K | PSL_IPL1F)
#define PSL_IPL		(PSL_IPL1F)
#define	PSL_USER	(0)

#define	PSL_MBZ		0x3020ff00	/* must be zero bits */

#define	PSL_USERSET	(0)
#define	PSL_USERCLR	(PSL_S | PSL_IPL1F | PSL_MBZ)

/*
 * Macros to decode processor status word.
 */
#define	CLKF_USERMODE(framep)	((((framep)->ps) & (PSL_U)) == PSL_U)
#define	CLKF_PC(framep)		((framep)->pc)
#define	CLKF_INTR(framep)	((((framep)->ps) & (PSL_IS)) == PSL_IS)
#define PSL2IPL(ps)             ((ps) >> 16)

#endif


code:
/*      $OpenBSD: pte.h,v 1.12 2013/11/24 22:08:23 miod Exp $      */
/*	$NetBSD: pte.h,v 1.21 2005/12/24 22:45:40 perry Exp $	  */

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

#ifndef _MACHINE_PTE_H_
#define _MACHINE_PTE_H_

#ifndef _LOCORE

typedef u_int32_t	pt_entry_t;	/* page table entry */

#endif /* _LOCORE */

#define	PG_V		0x80000000
#define	PG_NV		0x00000000
#define	PG_PROT		0x78000000
#define	PG_RW		0x20000000
#define	PG_KW		0x10000000
#define	PG_KR		0x18000000
#define	PG_URKW		0x70000000
#define	PG_RO		0x78000000
#define	PG_NONE		0x00000000
#define	PG_M		0x04000000
#define	PG_W		0x01000000
#define	PG_SREF		0x00800000
#define	PG_ILLEGAL	0x00600000
#define	PG_FRAME	0x001fffff
#define	PG_PFNUM(x)	(((unsigned long)(x) & 0x3ffffe00) >> VAX_PGSHIFT)

#ifndef _LOCORE
/*
 * Kernel virtual address to page table entry and to physical address.
 */
extern pt_entry_t *Sysmap;
#endif

#ifdef __GNUC__
static inline pt_entry_t *
kvtopte(vaddr_t va)
{
	pt_entry_t *pte;

	__asm(
		"extzv $9,$21,%1,%0\n\t"
		"moval *Sysmap[%0],%0\n\t"
	    : "=r"(pte)
	    : "g"(va));
	return pte;
}
static inline paddr_t
kvtophys(vaddr_t va)
{
	paddr_t pa;

	__asm(
		"extzv $9,$21,%1,%0\n\t"
		"ashl $9,*Sysmap[%0],%0\n\t"
		"insv %1,$0,$9,%0\n\t"
	    : "=&r"(pa)
	    : "g"(va) : "cc");
	return pa;
}
#else /* __GNUC__ */
#define kvtopte(va) (&Sysmap[PG_PFNUM(va)])
#define kvtophys(va) \
    (((*kvtopte(va) & PG_FRAME) << VAX_PGSHIFT) | ((paddr_t)(va) & VAX_PGOFSET))
#endif /* __GNUC__ */
#define uvtopte(va, pcb) \
	(((vaddr_t)(va) < 0x40000000) ? \
	&(((pcb)->P0BR)[PG_PFNUM(va)]) : \
	&(((pcb)->P1BR)[PG_PFNUM(va)]))

#endif


code:
/*	$OpenBSD: ptrace.h,v 1.2 1997/05/29 00:04:48 niklas Exp $	*/
/*	$NetBSD: ptrace.h,v 1.3 1995/04/12 15:26:49 ragge Exp $	*/

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

 /* All bugs are subject to removal without further notice */

#define PT_STEP         (PT_FIRSTMACH + 0)
#define PT_GETREGS      (PT_FIRSTMACH + 1)
#define PT_SETREGS      (PT_FIRSTMACH + 2)


code:
/*	$OpenBSD: reg.h,v 1.4 2011/03/23 16:54:37 pirofti Exp $	*/
/*	$NetBSD: reg.h,v 1.3 1995/04/12 15:26:52 ragge Exp $	*/

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

 /* All bugs are subject to removal without further notice */

#ifndef _MACHINE_REG_H_
#define _MACHINE_REG_H_

struct  reg {
	int	r0;     /* General registers saved upon trap/syscall */
	int	r1;
	int	r2;
	int	r3;
	int	r4;
	int	r5;
	int	r6;
	int	r7;
	int	r8;
	int	r9;
	int	r10;
	int	r11;
	int	ap;     /* Argument pointer on user stack */
	int	fp;     /* Stack frame pointer */
	int	sp;
	int	pc;     /* User pc */
	int	psl;    /* User psl */
};

#endif /* _MACHINE_REG_H_ */


code:
/*	$OpenBSD: reloc.h,v 1.1 2013/07/05 21:10:50 miod Exp $	*/
/* VAX ELF relocation types */

#define	R_VAX_NONE		0
#define	R_VAX_32		1
#define	R_VAX_16		2
#define	R_VAX_8			3
#define	R_VAX_PC32		4
#define	R_VAX_PC16		5
#define	R_VAX_PC8		6
#define	R_VAX_GOT32		7
#define	R_VAX_PLT32		13
#define	R_VAX_COPY		19
#define	R_VAX_GLOB_DAT		20
#define	R_VAX_JMP_SLOT		21
#define	R_VAX_RELATIVE		22
#define	R_VAX_GNU_VTINHERIT	23
#define	R_VAX_GNU_VTENTRY	24


code:
/*	$OpenBSD: rpb.h,v 1.11 2008/08/18 23:19:24 miod Exp $ */
/*	$NetBSD: rpb.h,v 1.6 1998/07/01 09:37:11 ragge Exp $ */
/*
 * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
 * All rights reserved.
 *
 * This code is derived from software contributed to Ludd by Bertram Barth.
 *
 * 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 at Ludd, University of
 *      Lule}, Sweden and its contributors.
 * 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.
 */

/*
 * Look at "VAX/VMS Internals and Data Structures" around page 907
 * to get more info about RPB.
 */

struct rpb {		/* size		description */
	struct rpb *rpb_base;	/* 4  physical base address of block */
	void	(*rpb_restart)(void);/* 4  physical address of restart routine */
	long	rpb_chksum;/* 4  checksum of first 31 longwords of restart */
	long	rpb_rstflg;	/* 4  Restart in progress flag */
	long	rpb_haltpc;	/* 4  PC at HALT/restart */
			/* offset: 20 */
	long	rpb_haltpsl;/* 4  PSL at HALT/restart */
	long	rpb_haltcode;/* 4  reason for restart */
	long	rpb_bootr0;/* 24  Saved bootstrap parameters (R0 through R5) */
	long	rpb_bootr1;
	long	rpb_bootr2;
	long	rpb_bootr3;
	long	rpb_bootr4;
	long	rpb_bootr5;
	long	iovec;	/* 4  Address of bootstrap driver */
	long	iovecsz;/* 4  Size (in bytes) of bootstrap driver */
			/* offset: 60 */
	long	fillbn;	/* 4  LBN of seconday bootstrap file */
	long	filsiz;	/* 4  Size (in blocks) of seconday bootstrap file */
	long	pfnmap[2];	/* 8  Descriptor of PFN bitmap */
	long	pfncnt;	/* 4  Count of physical pages */
			/* offset: 80 */
	long	svaspt;	/* 4  system virtual address of system page table */
	long	csrphy;	/* 4  Physical Address of UBA device CSR */
	long	csrvir;	/* 4  Virtual Address of UBA device CSR */
	long	adpphy;	/* 4  Physical Address of adapter configurate reg. */
	long	adpvir;	/* 4  Virtual Address of adapter configurate reg. */
			/* offset: 100 */
	short	unit;	/* 2  Bootstrap device unit number */
	u_char	devtyp;	/* 1  Bootstrap device type code */
	u_char	slave;	/* 1  Bootstrap device slave unit number */
	char	file[40];	/* 40  Secondary bootstrap file name */
	u_char	confreg[16];	/* 16  Byte array of adapter types */
			/* offset: 160 */
#if 0
	u_char	hdrpgcnt; /* 1  Count of header pages in 2nd bootstrap image */
	short	bootndt;/* 2  Type of boot adapter */
	u_char	flags;	/* 1  Miscellaneous flag bits */
#else
	long	align;	/* if the compiler doesnt proper alignment */
#endif
	long	max_pfn;/* 4  Absolute highest PFN */
	long	sptep;	/* 4  System space PTE prototype register */
	long	sbr;	/* 4  Saved system base register */
	long	cpudbvec;/* 4  Physical address of per-CPU database vector */
			/* offset: 180 */
	long	cca_addr;	/* 4  Physical address of CCA */
	long	slr;	/* 4  Saved system length register */
	long	memdesc[16];	/* 64  Longword array of memory descriptors */
	long	smp_pc;	/* 4  SMP boot page physical address */
	long	wait;	/* 4  Bugcheck loop code for attached processor */
			/* offset: 260 */
	long	badpgs;	/* 4  Number of bad pages found in memory scan */
	u_char	ctrlltr;/* 1  Controller letter designation */
	u_char	scbpagct;	/* 1  SCB page count */
	u_char	reserved[6];	/* 6  -- */
	long	vmb_revision;	/* 4  VMB revision label */
};

/*
 * Bootstrap device number encoding.
 */
#define	BDEV_HP		0
#define	BDEV_RK		1
#define	BDEV_RL		2
#define	BDEV_IDC	3
#define	BDEV_UDA	17
#define	BDEV_TK		18
#define	BDEV_HSC	32
#define	BDEV_KDB	33
#define	BDEV_KRB	34
#define	BDEV_NK		35
#define	BDEV_RD		36	/* ST506/MFM disk on HDC9224 */
#define	BDEV_ST		37	/* SCSI tape on NCR5380 */
#define	BDEV_SDS	39	/* SCSI disk on SII */
#define	BDEV_SD		42	/* SCSI disk on NCR5380 */
#define BDEV_SDN	46	/* SCSI disk on NCR5394 */
#define	BDEV_CNSL	64
#define	BDEV_QE		96
#define	BDEV_DE		97
#define	BDEV_NI		98
#define	BDEV_LE		99
#define	BDEV_ZE		100

#define	BDEV_NET 	BDEV_QE		/* first network BDEV */

#ifdef _KERNEL
extern struct rpb rpb;
#endif


code:
/*	$OpenBSD: scb.h,v 1.10 2008/08/18 23:19:24 miod Exp $	*/
/*	$NetBSD: scb.h,v 1.11 2000/07/10 09:14:34 ragge Exp $	*/

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */
#ifndef _VAX_SCB_H
#define	_VAX_SCB_H

/*
 * Definition of the System Control Block. More about it can be
 * found in the Vax Architecture Reference Manual, section 6.6.
 */
struct scb {
	void	*scb_unused;	/* First unused vector */
	void	*scb_mcheck;
	void	*scb_kspinv;
	void	*scb_powfail;
	void	*scb_privinst;	/* 10 Privileged Instruction fault */
	void	*scb_xfcinst;
	void	*scb_resop;
	void	*scb_resad;
	void	*scb_accessv;	/* 20 Access Control violation fault */
	void	*scb_transinv;
	void	*scb_trace;
	void	*scb_breakp;
	void	*scb_compat;	/* 30 Compatibility instruction fault */
	void	*scb_arith;
	void	*scb_unused1;
	void	*scb_unused2;
	void	*scb_chmk;	/* 40 CHMK */
	void	*scb_chme;
	void	*scb_chms;
	void	*scb_chmu;
	void	*scb_sbisilo;	/* 50 SBI Silo compare */
	void	*scb_cmrd;
	void	*scb_sbialert;
	void	*scb_sbifault;
	void	*scb_memwtimo;	/* 60 Memory write timeout */
	void	*scb_unused3;
	void	*scb_unused4;
	void	*scb_unused5;
	void	*scb_unused6;	/* 70 unused */
	void	*scb_unused7;
	void	*scb_unused8;
	void	*scb_unused9;
	void	*scb_unused10;	/* 80 unused */
	void	*scb_softint1;
	void	*scb_softint2;
	void	*scb_softint3;
	void	*scb_softint4;	/* 90 Software interrupt level 4 */
	void	*scb_softint5;
	void	*scb_softint6;
	void	*scb_softint7;
	void	*scb_softint8;	/* A0 Software interrupt level 8 */
	void	*scb_softint9;
	void	*scb_softinta;
	void	*scb_softintb;
	void	*scb_softintc;	/* B0 Software interrupt level C */
	void	*scb_softintd;
	void	*scb_softinte;
	void	*scb_softintf;
	void	*scb_timer;	/* C0 Interval timer */
	void	*scb_unused11;
	void	*scb_unused12;
	void	*scb_unused13;
	void	*scb_unused14;	/* D0 Unused */
	void	*scb_unused15;
	void	*scb_unused16;
	void	*scb_unused17;
	void	*scb_unused18;	/* E0 Unused */
	void	*scb_unused19;
	void	*scb_unused20;
	void	*scb_unused21;
	void	*scb_csrint;
	void	*scb_cstint;	/* F0 Console storage transmit interrupt */
	void	*scb_ctrint;
	void	*scb_cttint;
	struct	ivec_dsp *scb_nexvec[4][16];	/* Nexus interrupt vectors */
};

#define	SCB_KSTACK	0
#define	SCB_ISTACK	1

#define vecnum(bus, ipl, tr) (256+(ipl-0x14)*64+tr*4+bus*256)

/*
 * This struct is used when setting up interrupt vectors dynamically.
 * It puts a opaque 32 bit quantity on the stack and also has a placeholder
 * for evcount structure.
 */
struct ivec_dsp {
	char	pushr;		/* pushr */
	char	pushrarg;	/* $0x3f */
	char	jsb;
	char	mode;
	long	displacement;
	void	(*hoppaddr)(void *);
	void	*pushlarg;
	struct	evcount *ev;
};

#ifdef _KERNEL
extern	const struct ivec_dsp idsptch;
extern	struct scb *scb;
extern	struct ivec_dsp *scb_vec;

extern	paddr_t scb_init(paddr_t);
extern	int scb_vecref(int *, int *);
extern	void scb_fake(int, int);
extern	void scb_stray(void *);
extern	void scb_vecalloc(int, void(*)(void *), void *, int, struct evcount *);
#endif /* _KERNEL */

#endif /* _VAX_SCB_H */


code:
/*	$OpenBSD: setjmp.h,v 1.3 2000/04/26 03:08:42 bjc Exp $	*/
/*	$NetBSD: setjmp.h,v 1.1 1994/12/20 10:37:18 cgd Exp $	*/

/*
 * machine/setjmp.h: machine dependent setjmp-related information.
 */

#define	_JBLEN	14		/* size, in longs, of a jmp_buf */


code:
/*	$OpenBSD: sgmap.h,v 1.7 2008/06/26 05:42:14 ray Exp $	*/
/* $NetBSD: sgmap.h,v 1.3 2000/05/17 21:22:18 matt Exp $ */

/*-
 * Copyright (c) 1997, 1998 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.
 */

#ifndef	_VAX_COMMON_SGMAPVAR_H
#define	_VAX_COMMON_SGMAPVAR_H

#include <sys/extent.h>
#include <machine/bus.h>
#include <machine/pte.h>

/*
 * A VAX SGMAP's state information.  Nothing in the sgmap requires
 * locking[*], with the exception of the extent map.  Locking of the
 * extent map is handled within the extent manager itself.
 *
 * [*] While the page table is a `global' resource, access to it is
 * controlled by the extent map; once a region has been allocated from
 * the map, that region is effectively `locked'.
 */
struct vax_sgmap {
	struct extent *aps_ex;		/* extent map to manage sgva space */
	pt_entry_t *aps_pt;		/* page table */
	bus_addr_t aps_sgvabase;	/* base of the sgva space */
	bus_size_t aps_sgvasize;	/* size of the sgva space */
	bus_addr_t aps_pa;		/* Address in region */
	unsigned int aps_flags;		/* flags */
};

void	vax_sgmap_init(bus_dma_tag_t, struct vax_sgmap *,
	    const char *, bus_addr_t, bus_size_t, pt_entry_t *, bus_size_t);

int	vax_sgmap_alloc(bus_dmamap_t, bus_size_t,
	    struct vax_sgmap *, int);
void	vax_sgmap_free(bus_dmamap_t, struct vax_sgmap *);

int     vax_sgmap_load(bus_dma_tag_t, bus_dmamap_t, void *,
	    bus_size_t, struct proc *, int, struct vax_sgmap *);

int	vax_sgmap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
	    struct mbuf *, int, struct vax_sgmap *);

int     vax_sgmap_load_uio(bus_dma_tag_t, bus_dmamap_t,
	    struct uio *, int, struct vax_sgmap *);

int	vax_sgmap_load_raw(bus_dma_tag_t, bus_dmamap_t,
	    bus_dma_segment_t *, int, bus_size_t, int, struct vax_sgmap *);

void	vax_sgmap_unload( bus_dma_tag_t, bus_dmamap_t,
	    struct vax_sgmap *);

#endif	/* _VAX_COMMON_SGMAPVAR_H */


code:
/*	$OpenBSD: sid.h,v 1.16 2011/09/19 21:53:02 miod Exp $	*/
/*	$NetBSD: sid.h,v 1.12 1999/12/11 17:55:13 ragge Exp $	*/

/*
 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
 * 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 at Ludd, University of Lule}.
 * 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.
 */

/*
 * Chip CPU types / chip CPU Subtypes
 *
 * The type of a VAX is given by the high-order byte of the System
 * identification register (SID) and describes families or series of VAXen.
 * Board-Types/Sub-Types within series are described by the SIED register.
 */

/*
 * 700 series (1977)
 */
#define VAX_TYP_780	1	/* VAX-11/780, 785, 782 */
#define VAX_TYP_750	2	/* VAX-11/750 */
#define VAX_TYP_730	3	/* VAX-11/730, 725 */
#define VAX_TYP_790	4	/* VAX 8600, 8650 */

#define VAX_BTYP_780	0x01000000	/* generic 11/780 */
#define VAX_BTYP_750	0x02000000	/* generic 11/750 */
#define VAX_BTYP_730	0x03000000	/* generic 11/730 */
#define VAX_BTYP_790	0x04000000	/* generic 11/790 */

/*
 * 8000 series (1986)
 */
#define VAX_TYP_8SS	5	/* VAX 8200, 8300, 8250, 8350, VS 8000 */
#define VAX_TYP_8NN	6	/* VAX 8530, 8550, 8700, 8800 */

#define VAX_BTYP_8000	0x05000000	/* generic VAX 8000 */

#define VAX_BTYP_8800	0x06000000	/* generic Nautilus */
#define VAX_BTYP_8700	0x06000001
#define VAX_BTYP_8550	0x06000006
#define VAX_BTYP_8500	0x06000007

/*
 * MicroVAX I (1984)
 */
#define VAX_TYP_UV1	7	/* MicroVAX I, VAXstation I */

#define VAX_BTYP_610	0x07000000	/* generic MicroVAX-I */

/*
 * MicroVAX II series (1985)
 */
#define VAX_TYP_UV2	8

#define VAX_BTYP_630	0x08000001	/* MicroVAX II, VAXstation II */
#define VAX_BTYP_410	0x08000004	/* MicroVAX 2000, VAXstation 2000 */

/*
 * CVAX chip series (1987)
 */
#define VAX_TYP_CVAX	10

#define VAX_BTYP_650	0x0A000001	/* MicroVAX 3[345689]00 */
#define	VAX_STYP_650	0x1		/* MicroVAX 3500, 3600 */
#define	VAX_STYP_640	0x2		/* MicroVAX 3300, 3400 */
#define	VAX_STYP_655	0x3		/* MicroVAX 3800, 3900 */
#define VAX_BTYP_9CC	0x0A000002	/* VAX 6000 model 210/310 */
#define VAX_BTYP_60	0x0A000003	/* VAXstation 3520, 3540 */
#define VAX_BTYP_420	0x0A000004	/* VAXstation 3100 models 10 - 48 */
#define	VAX_BTYP_IS1	0x0A000006	/* Infoserver 1000 */
#define VAX_BTYP_5x0	0x0A000007	/* VAXft model 110, 310 */

/*
 * Rigel chip series (1990)
 */
#define VAX_TYP_RIGEL	11

#define VAX_BTYP_670	0x0B000001	/* VAX 4000 300 */
#define	VAX_STYP_670	0x4		/* VAX 4000 300 */
#define VAX_BTYP_9RR	0x0B000002	/* VAX 6000 model 410-460 */
#define VAX_BTYP_43	0x0B000004	/* VAXstation 3100 model 76 */

/*
 * Aquarius series (1990)
 */
#define VAX_TYP_9000	14

/*
 * Polarstar series (1988)
 */
#define VAX_TYP_8PS	17

#define VAX_BTYP_8PS	0x11000000	/* VAX 8810 to 8840 */

/*
 * Mariah chip series (1991)
 */
#define VAX_TYP_MARIAH	18

#define VAX_BTYP_1202	0x12000002	/* VAX 6000 model 510-560 */

#define VAX_BTYP_46	0x12000004	/* VAXstation 4000/60, 3100/80 */
#define VAX_VTYP_47	0x00000001	/* MicroVAX 3100/80 */
#define VAX_VTYP_46	0x00000002	/* VAXstation 4000/60 */

/*
 * NVAX chip series (1991)
 */
#define VAX_TYP_NVAX	19

#define VAX_BTYP_1301	0x13000001	/* Omega machines */
#define VAX_STYP_675	0x00000c	/* VAX 4000 model 400 */
#define VAX_STYP_680	0x000006	/* VAX 4000 model 500 */
#define VAX_STYP_690	0x000007	/* VAX 4000 model 600 */

#define VAX_BTYP_1302	0x13000002

#define VAX_BTYP_1303	0x13000003	/* Cheetah machines */
#define VAX_STYP_50	0x000008	/* KA50 or KA55 */
#define VAX_STYP_51	0x000009	/* MicroVAX 3100 model 90 / 95 */
#define VAX_STYP_52	0x00000a	/* VAX 4000 model 100 */
#define VAX_STYP_53	0x00000b	/* VAX 4000 model 105A */

#define VAX_BTYP_1305	0x13000005	/* Legacy machines */
#define VAX_STYP_681	0x00000e	/* VAX 4000 model 500A */
#define VAX_STYP_691	0x00000f	/* VAX 4000 model 605A */
#define VAX_STYP_692	0x000010	/* VAX 4000 model 700 */
#define VAX_STYP_694	0x000010	/* VAX 4000 model 705A
					   (same value as 692) */

#define VAX_BTYP_49	0x13000004	/* VaxStation 4000 model 90 */

/*
 * SOC chip series (1991)
 */
#define VAX_TYP_SOC	20

#define VAX_BTYP_660	0x14000001	/* VAX 4000 model 200 */
#define	VAX_STYP_660	0x5
#define VAX_BTYP_48	0x14000004	/* VS4000/VLC and MV3100/{30,40} */
#define VAX_STYP_45	0x000000	/* MicroVAX 3100 {30,40} */
#define VAX_STYP_48	0x000001	/* VAXstation 4000 VLC */
#define VAX_BTYP_550	0x14000007	/* VAXft model 410, 610 */
#define VAX_BTYP_VXT	0x14000008	/* VXT 2000+ */

/*
 * NVAX+ chip series (1991)
 */
#define VAX_TYP_NVPLUS	23

#define VAX_BTYP_1701	0x17000001

/*
 * Some common-used external variables.
 */
extern	int vax_cputype;	/* general, highest byte of the SID-register */
extern	int vax_cpustype;	/* general, second byte of the SIE-register */
extern	int vax_cpudata;	/* general, the contents of the SID-register */
extern	int vax_siedata;	/* contents of the SIE register */
extern	int vax_bustype;	/* HW-dep., setup at consinit() in ka???.c */
extern	int vax_boardtype;	/* HW-dep., msb of SID | SIE (SID-extension) */
extern	int vax_confdata;	/* HW-dep., hardware dependent config-data   */


code:
/*      $OpenBSD: signal.h,v 1.8 2012/12/02 07:03:31 guenther Exp $   */
/*      $NetBSD: signal.h,v 1.4 1995/01/10 19:01:52 jtc Exp $   */

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

 /* All bugs are subject to removal without further notice */

#ifndef _MACHINE_SIGNAL_H_
#define _MACHINE_SIGNAL_H_

#include <sys/cdefs.h>

typedef int sig_atomic_t;

#if __BSD_VISIBLE || __XPG_VISIBLE >= 420
/*
 * Information pushed on stack when a signal is delivered.
 * This is used by the kernel to restore state following
 * execution of the signal handler.  It is also made available
 * to the handler to allow it to restore state properly if
 * a non-standard exit is performed.
 */
struct	sigcontext {
	int	__sc_unused;
	int	sc_mask;		/* signal mask to restore */
	int	sc_sp;			/* sp to restore */
	int	sc_fp;			/* fp to restore */
	int	sc_ap;			/* ap to restore */
	int	sc_pc;			/* pc to restore */
	int	sc_ps;			/* psl to restore */
	int	sc_r[12];		/* registers to restore */
};
#endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
#endif	/* !_MACHINE_SIGNAL_H_ */


code:
/*	$OpenBSD: spinlock.h,v 1.3 2013/06/01 20:47:40 tedu Exp $	*/

#ifndef _MACHINE_SPINLOCK_H_
#define _MACHINE_SPINLOCK_H_

#define _ATOMIC_LOCK_UNLOCKED	(0)
#define _ATOMIC_LOCK_LOCKED	(1)
typedef int _atomic_lock_t;

#ifndef _KERNEL
int _atomic_lock(volatile _atomic_lock_t *);
#endif

#endif


code:
/*	$OpenBSD: stdarg.h,v 1.12 2014/03/11 19:45:27 guenther Exp $	*/
/*	$NetBSD: stdarg.h,v 1.11 1999/05/03 16:30:34 christos Exp $	*/

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

#ifndef _MACHINE_STDARG_H_
#define	_MACHINE_STDARG_H_

#include <sys/cdefs.h>
#include <machine/_types.h>

typedef __va_list	va_list;

#define	__va_size(type) \
	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))

#define va_start(ap, last) \
	((ap) = (va_list)__builtin_next_arg(last))

#define	va_arg(ap, type) \
	(*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))

#if __BSD_VISIBLE
#define __va_copy(dest, src) \
	((dest) = (src))
#endif

#define va_end(ap)

#endif /* !_MACHINE_STDARG_H_ */


code:
/*	$OpenBSD: tcb.h,v 1.1 2011/10/27 04:01:17 guenther Exp $	*/

/*
 * Copyright (c) 2011 Philip Guenther <guenther@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _MACHINE_TCB_H_
#define _MACHINE_TCB_H_

#ifdef _KERNEL

#error "not yet"

#else /* _KERNEL */

/* Not ELF, so for now use a big TCB to save a memory reference for errno */
#define TLS_VARIANT	2

#endif /* _KERNEL */

#endif /* _MACHINE_TCB_H_ */