code:
/*	$OpenBSD: prom.h,v 1.4 2014/03/29 18:09:29 guenther Exp $	*/
/*
 * Copyright (c) 2006, Miodrag Vallat
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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.
 */

#define	SCM_CHAR		0x00
#define	SCM_OCHAR		0x20
#define	SCM_OCRLF		0x26
#define	SCM_HALT		0x63
#define	SCM_CPUID		0x102
#define	SCM_COMMID		0x114

uint	cpuid(void);
void	scm_getenaddr(u_char *);

/*
 * Simpler version of SCM_CALL() from aviion/prom.c since we are using
 * in PROM context.
 */

#define SCM_CALL(x) \
	__asm__ volatile ("or %%r9,%%r0," __STRING(x) "; tb0 0,%%r0,496" \
	    :::	"r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8",		\
		"r9", "r10", "r11", "r12", "r13")

/*
 * cpuid values
 */

#define	AVIION_300_310		0x7904	/* mono Maverick */
#define	AVIION_5100_6100	0x7906	/* 20MHz Topgun */
#define	AVIION_400_4000		0x7908	/* 16MHz Mav+ */
#define	AVIION_410_4100		0x790c	/* 20MHz Mav+ */
#define	AVIION_300C_310C	0x7910	/* color Maverick */
#define	AVIION_5200_6200	0x7912	/* 25MHz Topgun */
#define	AVIION_5240_6240	0x7918	/* 25MHz Shotgun */
#define	AVIION_300CD_310CD	0x7920	/* dual duart color Maverick */
#define	AVIION_300D_310D	0x7924	/* dual duart mono Maverick */
#define	AVIION_4600_530		0x7930	/* Rolling Rock */
#define	AVIION_4300_25		0x7932	/* 25MHz Terra */
#define	AVIION_4300_20		0x7934	/* 20MHz Terra */
#define	AVIION_4300_16		0x7936	/* 16MHz Terra */
#define	AVIION_5255_6255	0x7942	/* 25MHz Tophat */
#define	AVIION_350		0x7944	/* KME */
#define	AVIION_6280		0x7946	/* High Noon */
#define	AVIION_8500_9500	0x794a	/* Odyssey */
#define	AVIION_9500_HA		0x794c	/* Oz */
#define	AVIION_500		0x794e	/* Robin Hood */
#define	AVIION_5500		0x7950	/* Schooner */
#define	AVIION_450		0x7958	/* Inner Tube */
#define	AVIION_8500_9500_45_1MB	0x795a	/* 45MHz Iliad (1MB L2) */
#define	AVIION_10000		0x7960	/* Sierra */
#define	AVIION_10000_QT		0x7962	/* Sierra QT */
#define	AVIION_5500PLUS		0x7964	/* Schooner+ */
#define	AVIION_450PLUS		0x7966	/* Inner Tube+ */
#define	AVIION_8500_9500_50_1MB	0x7968	/* 50MHz Iliad (1MB L2) */
#define	AVIION_8500_9500_50_2MB	0x796a	/* 50MHz Iliad (2MB L2) */

/* did the following ever hit the market? */
#define	AVIION_UNKNOWN1		0x7926	/* mono Montezuma */
#define	AVIION_UNKNOWN2		0x7928	/* color Montezuma */
#define	AVIION_UNKNOWN3		0x7956	/* Flintstone */
#define	AVIION_UNKNOWN1_DIS	0xfff0	/* mono disabled Montezuma */
#define	AVIION_UNKNOWN2_DIS	0xfff1	/* color disabled Montezuma */


code:
/*	$OpenBSD: putc.c,v 1.3 2014/03/29 18:09:29 guenther Exp $	*/
/*
 * Copyright (c) 2006, Miodrag Vallat
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/types.h>

#include "prom.h"

void
putchar(int c)
{
	if (c == '\n') {
		SCM_CALL(SCM_OCRLF);
	} else {
		__asm__ volatile ("or %%r2, %%r0, %0" : : "r" (c));
		SCM_CALL(SCM_OCHAR);
	}
}

license: unknown


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


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


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

LIB=sa

NOPIC=nopic
NOPROFILE=noprofile
NOPIE=

# Logically src/sys
S=${.CURDIR}/../../../..

SRCS=	clock.c delay.S exec.c fault.c parse_args.c setjmp.S

.PATH:	${S}/lib/libsa
SRCS+=	alloc.c memcpy.c exit.c getfile.c gets.c globals.c loadfile.c \
	printf.c strerror.c memset.c memcmp.c strncpy.c strcmp.c strlen.c \
	strlcpy.c strlcat.c snprintf.c strchr.c strtol.c \
	close.c closeall.c dev.c dkcksum.c \
	lseek.c open.c nullfs.c read.c fstat.c disklabel.c \
	ufs.c cread.c
SRCS+= arp.c ether.c in_cksum.c net.c netif.c netudp.c rpc.c nfs.c \
	rarp.c bootparam.c

.PATH:	${S}/lib/libkern/arch/m88k ${S}/lib/libkern
SRCS+=	ashrdi3.c bzero.c __main.c

# DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \
# 	-DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG

#DEFS= -DCOMPAT_UFS
DEFS= -D__INTERNAL_LIBSA_CREAD -D_STANDALONE
#-DNETIF_DEBUG
INCL= -I${.CURDIR} -I${.CURDIR}/../libprom -I${S}/lib/libsa -I${S}
CFLAGS+= ${XCFLAGS} ${COPTS} ${DEFS} ${DBG} ${INCL}

all: libsa.a

install:

.include <bsd.lib.mk>

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


code:
#	$OpenBSD: Makefile.inc,v 1.1 2006/05/16 22:48:18 miod Exp $

LIB_SA_DIR=${S}/arch/aviion/stand/libsa

LIBSA_DIR!= cd ${LIB_SA_DIR}; \
     printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx

LIBSA=${LIBSA_DIR}/libsa.a
SRTOBJ?= ${LIBSA_DIR}/SRT0.o

$(LIBSA):	.NOTMAIN __always_make_libsa
	@echo making sure the libsa is up to date...
	@(cd ${LIB_SA_DIR}; ${MAKE} "XCFLAGS=${CFLAGS}")

__always_make_libsa:	.NOTMAIN


code:
/*	$OpenBSD: clock.c,v 1.2 2013/10/08 21:55:21 miod Exp $	*/

#include <sys/types.h>
#include <machine/prom.h>

#include "stand.h"
#include "libsa.h"

#include "nvramreg.h"

/*
 * BCD to decimal and decimal to BCD.
 */
#define FROMBCD(x)      (((x) >> 4) * 10 + ((x) & 0xf))
#define TOBCD(x)        (((x) / 10 * 16) + ((x) % 10))

#define LEAPYEAR(y)     (((y) & 3) == 0)

/*
 * This code is defunct after 2068.
 * Will Unix still be here then??
 */
const int dayyr[12] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };

u_long
chiptotime(sec, min, hour, day, mon, year)
	int sec, min, hour, day, mon, year;
{
	int days, yr;

	sec = FROMBCD(sec);
	min = FROMBCD(min);
	hour = FROMBCD(hour);
	day = FROMBCD(day);
	mon = FROMBCD(mon);
	year = FROMBCD(year) + YEAR0;

	/* simple sanity checks */
	if (year > 164 || mon < 1 || mon > 12 || day < 1 || day > 31)
		return (0);
	yr = 70;
	days = 0;

	if (year < 70) {
		for (; yr < year; yr++)
			days += LEAPYEAR(yr) ? 366 : 365;
		yr = 0;
	}

	for (; yr < year; yr++)
		days += LEAPYEAR(yr) ? 366 : 365;

	days += dayyr[mon - 1] + day - 1;

	if (LEAPYEAR(yr) && mon > 2)
		days++;

	/* now have days since Jan 1, 1970; the rest is easy... */
	return (days * SECDAY + hour * 3600 + min * 60 + sec);
}

time_t
getsecs()
{
	int sec, min, hour, day, mon, year;
#define	TOD_BASE	(0xfff80000 + AV400_NVRAM_TOD_OFF)

	*(volatile u_int32_t *)(TOD_BASE + (CLK_CSR << 2)) = CLK_READ |
	    *(volatile u_int32_t *)(TOD_BASE + (CLK_CSR << 2));
	sec = *(volatile u_int32_t *)(TOD_BASE + (CLK_SEC << 2)) & 0xff;
	min = *(volatile u_int32_t *)(TOD_BASE + (CLK_MIN << 2)) & 0xff;
	hour = *(volatile u_int32_t *)(TOD_BASE + (CLK_HOUR << 2)) & 0xff;
	day = *(volatile u_int32_t *)(TOD_BASE + (CLK_DAY << 2)) & 0xff;
	mon = *(volatile u_int32_t *)(TOD_BASE + (CLK_MONTH << 2)) & 0xff;
	year = *(volatile u_int32_t *)(TOD_BASE + (CLK_YEAR << 2)) & 0xff;
	*(volatile u_int32_t *)(TOD_BASE + (CLK_CSR << 2)) = ~CLK_READ &
	    *(volatile u_int32_t *)(TOD_BASE + (CLK_CSR << 2));

	return (chiptotime(sec, min, hour, day, mon, year));
}


code:
/*	$OpenBSD: delay.S,v 1.1 2013/10/08 21:55:21 miod Exp $	*/
/*
 * Mach Operating System
 * Copyright (c) 1993-1991 Carnegie Mellon University
 * Copyright (c) 1991 OMRON Corporation
 * All Rights Reserved.
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <machine/asm.h>

/*
 * void delay(int us)
 *
 * The processor loops (busy waits) for the given number of microseconds:
 * Thus, delay(1000000) will delay for one second.
 * (originally from Mach 2.5)
 */
ENTRY(delay)
	bcnd	eq0, %r2, 2f
	or.u	%r3, %r0, %hi16(_C_LABEL(aviion_delay_const))
	ld	%r3, %r3, %lo16(_C_LABEL(aviion_delay_const))
	mul	%r4, %r2, %r3
	subu	%r4, %r4, 4	/* overhead of these instructions */

	/* now loop for the given number of cycles */
1:
	bcnd.n	gt0, %r4, 1b
	 subu	%r4, %r4, 2	/* two cycles per iteration */
2:
	jmp	%r1

	.data

GLOBAL(aviion_delay_const)
	.word	33


code:
/*	$OpenBSD: exec.c,v 1.4 2014/02/24 20:15:37 miod Exp $	*/

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

#include <sys/param.h>
#include <sys/reboot.h>
#include <machine/prom.h>

#include "stand.h"
#include "libsa.h"

#include <lib/libsa/loadfile.h>

#define	BOOT_MAGIC	0x6274ef2e	/* need to match locore.S */

/*ARGSUSED*/
void
exec(char *file, const char *args, uint bootdev, uint bootunit, uint bootlun,
    uint bootpart)
{
	u_long marks[MARK_MAX];
	int rc;
	void (*entry)(const char *, uint, uint, uint, uint, uint, uint);

	marks[MARK_START] = 0;
	rc = loadfile(file, marks, LOAD_KERNEL | COUNT_KERNEL);
	if (rc != 0)
		return;

	entry = (void(*)(const char *, uint, uint, uint, uint, uint, uint))
	    marks[MARK_START];
	(*entry)(args, bootdev, bootunit, bootlun, BOOT_MAGIC + 1,
	    bootpart, marks[MARK_END]);

	printf("exec: kernel returned!\n");
}


code:
/*	$OpenBSD: fault.c,v 1.2 2014/03/29 18:09:29 guenther Exp $	*/

/*
 * Copyright (c) 2013 Miodrag Vallat.
 *
 * 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.
 */

/*
 * Standalone code to recover from faults. Allows for hardware detection.
 */

#include <sys/param.h>

#include <machine/asm.h>
#include <machine/asm_macro.h>
#include <machine/prom.h>
#include <machine/psl.h>

#include "stand.h"
#include "libsa.h"

typedef struct label_t {
        long val[19];
} label_t;

extern int setjmp(label_t *);
extern void longjmp(label_t *);

static label_t badaddr_jmpbuf;
static uint32_t badaddr_psr;

static uint32_t prom_vbr;
static uint32_t vector_page[512 * 2] __attribute__ ((__aligned__(0x1000)));

static __inline__ uint32_t
get_vbr()
{
	uint32_t vbr;
	__asm__ volatile ("ldcr %0, %%cr7" : "=r"(vbr));
	return vbr;
}

static __inline__ void
set_vbr(uint32_t vbr)
{
	__asm__ volatile ("stcr %0, %%cr7" :: "r"(vbr));
}

/*
 * This is an horribly crude logic to recover from data access exceptions
 * by longjmp'ing back to badaddr(). We should theoretically at least use
 * an `rte' somewhere to unfreeze the scoreboard. But since we restore a
 * PSR with interrupts disabled, this turns out to be safe.
 */
static void
libsa_fault_handler(void)
{
	set_psr(badaddr_psr | PSR_IND);	/* undo SFRZ */
	flush_pipeline();

	longjmp(&badaddr_jmpbuf);
	/* NOTREACHED */
}

static __inline__ uint32_t
br(uint32_t delta)
{
	return 0xc0000000 | (((int32_t)delta >> 2) & 0x03ffffff);
}

static void
libsa_fault_init()
{
	int vec;
	uint32_t *insn;
	uint32_t br_insn;

	prom_vbr = get_vbr();

	insn = vector_page;
	br_insn = br(prom_vbr - (uint32_t)&vector_page - 4);
	for (vec = 512; vec != 0; vec--) {
		*insn++ = 0xf4005800;	/* nop */
		*insn++ = br_insn;	/* br into prom vbr page */
	}

	/* override data access exception */
	vector_page[3 * 2 + 1] =
	    br((uint32_t)&libsa_fault_handler -
	       (uint32_t)&vector_page[3 * 2 + 1]);
}

int
badaddr(void *addr, int len)
{
	int rc;

	if (vector_page[0] == 0)
		libsa_fault_init();

	badaddr_psr = get_psr();
	set_psr(badaddr_psr | PSR_IND);

	set_vbr((uint32_t)&vector_page);

	if (setjmp(&badaddr_jmpbuf) == 0) {
		switch (len) {
		case 1:
			(void)*(volatile uint8_t *)addr;
			rc = 0;
			break;
		case 2:
			if ((uint32_t)addr & 1)
				rc = 1;
			else {
				(void)*(volatile uint16_t *)addr;
				rc = 0;
			}
			break;
		case 4:
			if ((uint32_t)addr & 3)
				rc = 1;
			else {
				(void)*(volatile uint32_t *)addr;
				rc = 0;
			}
			break;
		default:
			rc = 1;
			break;
		}
	} else {
		rc = 1;
	}

	set_vbr(prom_vbr);
	flush_pipeline();
	set_psr(badaddr_psr);

	return rc;
}


code:
/*	$OpenBSD: libsa.h,v 1.5 2013/10/16 16:59:35 miod Exp $	*/

/*
 * libsa prototypes
 */

#include <machine/prom.h>

extern int boothowto;

struct boot_info {
	unsigned int bootdev;
	unsigned int bootunit;
	unsigned int bootlun;
	unsigned int bootpart;
};

extern struct boot_info bi;

int	badaddr(void *, int);
void	delay(unsigned int);
void	exec(char *, const char *, uint, uint, uint, uint);
int	parse_args(const char *, char **, int);


code:
/*	$OpenBSD: nvramreg.h,v 1.2 2007/04/10 17:47:54 miod Exp $ */

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

/*
 * Mostek TOD clock/NVRAM
 */

/*
 * Mostek MK48T08 clock.
 *
 * This chip is 8k in size.
 * The first TOD clock starts at offset 0x1FF8. The following structure
 * describes last 2K of its 8K address space. The first 6K of the NVRAM
 * space is used for various things as follows:
 * 	0000-0fff	User Area
 *	1000-10ff	Networking Area
 *	1100-16f7	Operating System Area
 *	16f8-1ef7	ROM Debugger Area
 *	1ef8-1ff7	Configuration Area (Ethernet address etc)
 *	1ff8-1fff	TOD clock
 */

/*
 * On AV400, these offsets need shifting two bits, as they are 32 bit
 * registers.
 */
#define	CLK_CSR		0		/* control register */
#define	CLK_SEC		1		/* seconds (0..59; BCD) */
#define	CLK_MIN		2		/* minutes (0..59; BCD) */
#define	CLK_HOUR	3		/* hour (0..23; BCD) */
#define	CLK_WDAY	4		/* weekday (1..7) */
#define	CLK_DAY		5		/* day in month (1..31; BCD) */
#define	CLK_MONTH	6		/* month (1..12; BCD) */
#define	CLK_YEAR	7		/* year (0..99; BCD) */
#define	CLK_NREG	8

/* csr bits */
#define	CLK_WRITE	0x80		/* want to write */
#define	CLK_READ	0x40		/* want to read (freeze clock) */

/*
 * Data General, following Motorola, chose the year `1900' as their base count.
 * It has already wrapped by now...
 */
#define	YEAR0	00

#define AV400_NVRAM_TOD_OFF	0x1fe0 /* offset of tod in NVRAM space */
#define MK48T02_SIZE	2 * 1024


code:
/*	$OpenBSD: parse_args.c,v 1.6 2013/10/16 16:59:35 miod Exp $ */

/*-
 * Copyright (c) 1995 Theo de Raadt
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include <sys/param.h>
#include <sys/reboot.h>
#include <machine/prom.h>

#include "stand.h"
#include "libsa.h"

#define KERNEL_NAME "bsd"

int	boothowto = 0;

/* skip end of token and whitespace */
static const char *stws(const char *);
static const char *
stws(const char *p)
{
	while (*p != ' ' && *p != '\0')
		p++;

	while (*p == ' ')
		p++;

	return p;
}

int
parse_args(const char *line, char **filep, int first)
{
	const char *po, *pc, *p;
	char *name;
	size_t namelen;

	if (first == 0) {
		/* recognize the special ``halt'' keyword */
		if (strcmp(line, "halt") == 0)
			return (1);
	}

	/* skip boot device; up to two nested foo(...) constructs */
	p = line;
	po = strchr(line, '(');
	if (po != NULL) {
		pc = strchr(po + 1, ')');
		if (pc != NULL) {
			p = strchr(po + 1, '(');
			if (p == NULL || pc < p)
				p = pc + 1;
			else if (pc != NULL) {
				p = strchr(pc + 1, ')');
				if (p != NULL)
					p = p + 1;
				else
					p = line;
			}
		}
	}

	/* skip partition number if any */
	pc = strchr(p, ':');
	if (pc != NULL)
		p = pc + 1;

	/* figure out how long the kernel name is */
	pc = strchr(p, ' ');
	if (pc == NULL)
		pc = p + strlen(p);

	if (p == pc) {
		/* empty, use the default kernel name */
		namelen = 1 + (p - line) + strlen(KERNEL_NAME);
		name = (char *)alloc(namelen);
		if (name == NULL)
			panic("out of memory");
		memcpy(name, line, p - line);
		memcpy(name + (p - line), KERNEL_NAME, sizeof(KERNEL_NAME));
	} else {
		namelen = pc - line;
		name = (char *)alloc(1 + namelen);
		if (name == NULL)
			panic("out of memory");
		memcpy(name, line, namelen);
		name[namelen] = '\0';
	}
	*filep = name;

	/*
	 * If this commandline is the one passed by the PROM, then look
	 * for options specific to the standalone code.
	 */

	if (first) {
		p = stws(p);
		while (*p != '\0') {
			if (*p++ == '-')
				while (*p != ' ' && *p != '\0')
					switch (*p++) {
					case 'a':
						boothowto |= RB_ASKNAME;
						break;
					}
			p = stws(p);
		}
	}

	return 0;
}


code:
/*	$OpenBSD: setjmp.S,v 1.1 2013/10/08 21:55:22 miod Exp $	*/
/*
 * Mach Operating System
 * Copyright (c) 1993-1992 Carnegie Mellon University
 * Copyright (c) 1991 OMRON Corporation
 * Copyright (c) 1996 Nivas Madhur
 * Copyright (c) 1998 Steve Murphree, Jr.
 * All Rights Reserved.
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <machine/asm.h>

/* int setjmp(label_t *); */
ENTRY(setjmp)
	st	%r1,  %r2, 0
	st	%r14, %r2, 4
	st	%r15, %r2, 2*4
	st	%r16, %r2, 3*4
	st	%r17, %r2, 4*4
	st	%r18, %r2, 5*4
	st	%r19, %r2, 6*4
	st	%r20, %r2, 7*4
	st	%r21, %r2, 8*4
	st	%r22, %r2, 9*4
	st	%r23, %r2, 10*4
	st	%r24, %r2, 11*4
	st	%r25, %r2, 12*4
	st	%r26, %r2, 13*4
	st	%r27, %r2, 14*4
	st	%r28, %r2, 15*4
	st	%r29, %r2, 16*4
	st	%r30, %r2, 17*4
	st	%r31, %r2, 18*4
	jmp.n	%r1
	 or	%r2,  %r0, %r0

/* void longjmp(label_t*); */
ENTRY(longjmp)
	ld	%r1,  %r2, 0
	ld	%r14, %r2, 4
	ld	%r15, %r2, 2*4
	ld	%r16, %r2, 3*4
	ld	%r17, %r2, 4*4
	ld	%r18, %r2, 5*4
	ld	%r19, %r2, 6*4
	ld	%r20, %r2, 7*4
	ld	%r21, %r2, 8*4
	ld	%r22, %r2, 9*4
	ld	%r23, %r2, 10*4
	ld	%r24, %r2, 11*4
	ld	%r25, %r2, 12*4
	ld	%r26, %r2, 13*4
	ld	%r27, %r2, 14*4
	ld	%r28, %r2, 15*4
	ld	%r29, %r2, 16*4
	ld	%r30, %r2, 17*4
	ld	%r31, %r2, 18*4
	jmp.n	%r1
	 or	%r2,  %r0, 1


code:
/Makefile/1.1/Tue May 16 22:48:18 2006//TOPENBSD_5_8_BASE
/Makefile.inc/1.1/Tue May 16 22:48:18 2006//TOPENBSD_5_8_BASE
D

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


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


code:
#	$OpenBSD: Makefile,v 1.1 2006/05/16 22:48:18 miod Exp $

S=${.CURDIR}/../../../..
ZDST=${.OBJDIR}

.PATH: ${S}/lib/libz

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

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


code:
#	$OpenBSD: Makefile.inc,v 1.1 2006/05/16 22:48:18 miod Exp $

LIB_Z_DIR=${S}/arch/aviion/stand/libz

LIBZ_DIR!= cd ${LIB_Z_DIR}; \
     printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx

LIBZ=${LIBZ_DIR}/libz.a

$(LIBZ):	.NOTMAIN __always_make_libz
	@echo making sure the libz is up to date...
	@(cd ${LIB_Z_DIR}; ${MAKE} "XCFLAGS=${CFLAGS}")

__always_make_libz:	.NOTMAIN


code: src/sys/arch/aviion/stand/vdmtool


path: sys/arch/aviion/stand/vdmtool/CVS/Tag


code:
#	$OpenBSD: Makefile,v 1.1 2013/10/01 20:32:30 miod Exp $

MAN=		vdmtool.8
MANSUBDIR=	aviion

.if ${MACHINE} == "aviion"
PROG=		vdmtool
BINDIR=		/usr/mdec
DPADD=		${LIBUTIL}
LDADD=		-lutil
LDSTATIC=	-static
.else
NOPROG=
.endif

.include <bsd.prog.mk>

path: sys/arch/aviion/stand/vdmtool/Makefile


code:
/*	$OpenBSD: vdmtool.c,v 1.5 2014/08/14 17:55:28 tobias Exp $	*/

/*
 * Copyright (c) 2013 Miodrag Vallat.
 *
 * 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.
 */

#include <unistd.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <util.h>
#include <sys/disklabel.h>

void	initialize(int);
void	report(int);
void	usage(void);

int	verbose;

#define	VDM_BLOCK_SIZE	0x200

void
usage()
{
	fprintf(stderr, "usage: vdmtool [-iv] rawdev\n");
	exit(1);
}

int
main(int argc, char *argv[])
{
	int c;
	int fd;
	int iflag = 0;
	int exitcode = 0;
	char *realpath;

	while ((c = getopt(argc, argv, "iqv")) != -1) {
		switch (c) {
		case 'i':
			iflag = 1;
			break;
		case 'v':
			verbose = 1;
			break;
		default:
			usage();
		}
	}

	if (argc - optind != 1)
		usage();

	fd = opendev(argv[optind], iflag ? O_RDWR : O_RDONLY, OPENDEV_PART,
	    &realpath);
	if (fd < 0)
		err(1, "open(%s)", realpath);

	if (iflag)
		initialize(fd);
	else
		report(fd);

	close(fd);
	exit(exitcode);
}

void
read_sector(int fd, uint32_t secno, void *buf)
{
	if (lseek(fd, (off_t)secno * VDM_BLOCK_SIZE, SEEK_SET) == -1)
		err(1, "lseek");

	if (read(fd, buf, VDM_BLOCK_SIZE) != VDM_BLOCK_SIZE)
		err(1, "read(%d,%08x)", fd, secno);
}

void
write_sector(int fd, uint32_t secno, void *buf)
{
	if (lseek(fd, (off_t)secno * VDM_BLOCK_SIZE, SEEK_SET) == -1)
		err(1, "lseek");

	if (write(fd, buf, VDM_BLOCK_SIZE) != VDM_BLOCK_SIZE)
		err(1, "write(%d,%08x)", fd, secno);
}

void
analyze_label_sector(uint8_t *sector, struct vdm_label **dl,
    struct vdm_boot_info **dbi)
{
	struct vdm_label *l;
	struct vdm_boot_info *bi;

	l = (struct vdm_label *)(sector + VDM_LABEL_OFFSET);
	if (betoh32(l->signature) != VDM_LABEL_SIGNATURE) {
		l = (struct vdm_label *)(sector + VDM_LABEL_OFFSET_ALT);
		if (betoh32(l->signature) != VDM_LABEL_SIGNATURE)
			l = NULL;
	}

	if (l != NULL) {
		bi = (struct vdm_boot_info *)
		    (sector + VDM_BLOCK_SIZE - sizeof *bi);
		if (betoh32(bi->signature) != VDM_LABEL_SIGNATURE)
			bi = NULL;
	} else
		bi = NULL;

	*dl = l;
	*dbi = bi;
}

uint32_t
get_vdit_size(int fd, uint32_t secno)
{
	uint8_t sector[VDM_BLOCK_SIZE];
	struct vdit_block_header *hdr;
	uint32_t cursize = 0;
	int kind = VDIT_BLOCK_HEAD_BE;

	for (;;) {
		read_sector(fd, secno, sector);
		hdr = (struct vdit_block_header *)sector;
		if (VDM_ID_KIND(&hdr->id) != kind) {
			printf("unexpected VDIT block kind "
			    "on sector %08x: %02x\n",
			    secno, VDM_ID_KIND(&hdr->id));
			return 0;
		}

		if (verbose)
			printf("sector %08x: vdit frag type %02x, length %04x, "
			    "next frag at %08x\n",
			    secno, VDM_ID_KIND(&hdr->id),
			    betoh16(hdr->chunksz), secno);

		cursize += betoh16(hdr->chunksz);
		if (betoh32(hdr->nextblk) == VDM_NO_BLK_NUMBER)
			break;

		secno = betoh32(hdr->nextblk);
		kind = VDIT_PORTION_HEADER_BLOCK;
	}

	return cursize;
}

vdit_id_t	subdriver_vdmphys_id;
vdit_id_t	subdriver_vdmpart_id;
vdit_id_t	subdriver_vdmaggr_id;
vdit_id_t	subdriver_vdmremap_id;

void
register_subdriver(uint8_t *buf)
{
	struct vdit_subdriver_entry entry;
	vdit_id_t id, *regid;

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	memcpy(&id, &entry.subdriver_id, sizeof id);
	id = betoh32(id);

	if (strcmp(entry.name, VDM_SUBDRIVER_VDMPHYS) == 0)
		regid = &subdriver_vdmphys_id;
	else if (strcmp(entry.name, VDM_SUBDRIVER_VDMPART) == 0)
		regid = &subdriver_vdmpart_id;
	else if (strcmp(entry.name, VDM_SUBDRIVER_VDMAGGR) == 0)
		regid = &subdriver_vdmaggr_id;
	else if (strcmp(entry.name, VDM_SUBDRIVER_VDMREMAP) == 0)
		regid = &subdriver_vdmremap_id;
	else
		regid = NULL;

	if (regid != NULL) {
		if (*regid != 0)
			printf("WARNING: subdriver \"%s\" overridden\n",
			    entry.name);
		*regid = id;
	}
}

void
print_vdit_instance_id(struct vdit_instance_id *buf, const char *descr)
{
	struct vdit_instance_id instance;

	memcpy(&instance, buf, sizeof instance);
	instance.generation_timestamp = betoh32(instance.generation_timestamp);
	instance.system_id = betoh32(instance.system_id);
	if (instance.generation_timestamp != 0 || instance.system_id != 0 ||
	    verbose)
		printf("%s id %08x:%08x",
		    descr, instance.generation_timestamp, instance.system_id);
}

uint32_t
print_vdit_boot_info(uint8_t *buf, uint32_t size)
{
	struct vdit_boot_info_entry entry;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	printf("\tboot info: version %02x", entry.version);
	print_vdit_instance_id(&entry.default_swap, " default swap");
	print_vdit_instance_id(&entry.default_root, " default root");
	printf("\n");

	return size - sizeof entry;
}

uint32_t
print_vdit_subdriver_info(uint8_t *buf, uint32_t size)
{
	struct vdit_subdriver_entry entry;
	vdit_id_t id;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	printf("\tsubdriver: version %02x", entry.version);
	memcpy(&id, &entry.subdriver_id, sizeof id);
	id = betoh32(id);
	printf(" id %08x name \"%s\"\n", id, entry.name);

	return size - sizeof entry;
}

uint32_t
print_vdmphys_instance(uint8_t *buf, uint32_t size)
{
	struct vdit_vdmphys_instance entry;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	entry.mode = betoh16(entry.mode);
	printf("\tvdmphys: version %02x mode %02x\n",
	    entry.version, entry.mode);

	return size - sizeof entry;
}

uint32_t
print_vdmpart_instance(uint8_t *buf, uint32_t size)
{
	struct vdit_vdmpart_instance entry;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	entry.start_blkno = betoh32(entry.start_blkno);
	entry.size = betoh32(entry.size);
	printf("\tvdmpart: version %02x", entry.version);
	print_vdit_instance_id(&entry.child_instance, " child");
	printf("\n");
	printf("\t\tstarting block %08x size %08x",
	    entry.start_blkno, entry.size);
	print_vdit_instance_id(&entry.remap_instance, " remap");
	printf("\n");

	return size - sizeof entry;
}

uint32_t
print_vdmaggr_instance(uint8_t *buf, uint32_t size)
{
	struct vdit_vdmaggr_instance entry;
	struct vdit_instance_id *aggr;
	uint32_t aggrsize;
	uint stripe;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	entry.aggr_count = betoh16(entry.aggr_count);
	entry.stripe_size = betoh32(entry.stripe_size);
	printf("\tvdmaggr: version %02x count %02x stripe size %08x\n",
	    entry.version, entry.aggr_count, entry.stripe_size);

	aggrsize = entry.aggr_count * sizeof(struct vdit_instance_id) +
	    sizeof entry;
	if (size < aggrsize) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02x)\n",
		    size, aggrsize);
		return 0;
	}

	aggr = (struct vdit_instance_id *)(buf + sizeof entry);
	for (stripe = 0; stripe < entry.aggr_count; stripe++) {
		printf("\t\tstripe %u", stripe);
		print_vdit_instance_id(aggr++, "");
		printf("\n");
	}

	return size - aggrsize;
}

uint32_t
print_vdmremap_instance(uint8_t *buf, uint32_t size)
{
	struct vdit_vdmremap_instance entry;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	printf("\tvdmremap: version %02x", entry.version);
	print_vdit_instance_id(&entry.primary_remap_table,
	    " primary remap table");
	printf("\n");
	print_vdit_instance_id(&entry.secondary_remap_table,
	    "\t\tsecondary remap table");
	printf("\n");
	print_vdit_instance_id(&entry.remap_area, "\t\tremap area");
	printf("\n");

	return size - sizeof entry;
}

uint32_t
print_vdit_instance_info(uint8_t *buf, uint32_t size)
{
	struct vdit_instance_entry entry;
	vdit_id_t id;

	if (size < sizeof entry) {
		printf("\tTRUNCATED ENTRY (%02x bytes, expected %02zx)\n",
		    size, sizeof entry);
		return 0;
	}

	memcpy(&entry, buf, sizeof entry);
	entry.version = betoh16(entry.version);
	printf("\tinstance: version %02x name \"%s\"\n",
	    entry.version, entry.name);
	memcpy(&id, &entry.subdriver_id, sizeof id);
	id = betoh32(id);
	printf("\t\tsubdriver id %08x", id);
	print_vdit_instance_id(&entry.instance_id, "");
	printf(" export %d\n", entry.exported);

	if (id == subdriver_vdmphys_id)
		return print_vdmphys_instance(buf, size);
	if (id == subdriver_vdmpart_id)
		return print_vdmpart_instance(buf, size);
	if (id == subdriver_vdmaggr_id)
		return print_vdmaggr_instance(buf, size);
	if (id == subdriver_vdmremap_id)
		return print_vdmremap_instance(buf, size);

	return size - sizeof entry;
}

uint8_t *
print_vdit_entry(uint8_t *buf)
{
	struct vdit_entry_header hdr;
	uint32_t remaining, cnt;
	uint8_t *rembuf;

	memcpy(&hdr, buf, sizeof hdr);
	hdr.type = betoh16(hdr.type);
	hdr.size = betoh16(hdr.size);

	printf("vdit entry: type %02x size %02x\n", hdr.type, hdr.size);
	if (hdr.type == VDIT_ENTRY_SENTINEL)
		return NULL;

	remaining = hdr.size - sizeof hdr;

	switch (hdr.type) {
	case VDIT_ENTRY_UNUSED:
		remaining = 0;	/* don't print anything */
		break;
	case VDIT_ENTRY_BOOT_INFO:
		remaining = print_vdit_boot_info(buf + sizeof hdr, remaining);
		break;
	case VDIT_ENTRY_SUBDRIVER_INFO:
		register_subdriver(buf + sizeof hdr);
		remaining = print_vdit_subdriver_info(buf + sizeof hdr,
		    remaining);
		break;
	case VDIT_ENTRY_INSTANCE:
		remaining = print_vdit_instance_info(buf + sizeof hdr,
		    remaining);
		break;
	}

	if (remaining == 4) {
		/* timestamp */
		remaining -= 4;
	}

	if (remaining != 0 && verbose) {
		printf("\t%02x bytes unparsed", remaining);
		rembuf = buf + hdr.size - remaining;
		cnt = 0;
		while (remaining-- != 0) {
			if (cnt % 16 == 0)
				printf("\n    ");
			printf("%02x ", *rembuf++);
			cnt++;
		}
		printf("\n");
	}

	return buf + hdr.size;
}

uint8_t *
append_vdit_sector(uint32_t secno, uint8_t *buf, uint8_t *sector, int kind)
{
	struct vdit_block_header *hdr;

	hdr = (struct vdit_block_header *)sector;
	if (VDM_ID_KIND(&hdr->id) != kind) {
		printf("unexpected block kind on sector %08x: %02x\n",
		    secno, VDM_ID_KIND(&hdr->id));
		return NULL;
	}

#ifdef DEBUG
	printf("sector %08x: vdit block %08x\n",
	    secno, VDM_ID_BLKNO(&hdr->id));
#endif

	memcpy(buf, sector + sizeof *hdr, VDM_BLOCK_SIZE - (sizeof *hdr));
	return buf + VDM_BLOCK_SIZE - (sizeof *hdr);
}

uint8_t *
append_vdit_portion(int fd, uint32_t secno, uint8_t *buf, uint8_t *sector,
    int kind)
{
	struct vdit_block_header *hdr;
	u_int chunksz;

	hdr = (struct vdit_block_header *)sector;
	if (VDM_ID_KIND(&hdr->id) != kind) {
		printf("unexpected block kind on sector %08x: %02x\n",
		    secno, VDM_ID_KIND(&hdr->id));
		return NULL;
	}

	/* store first sector of the portion */
	chunksz = betoh16(hdr->chunksz);
	buf = append_vdit_sector(secno, buf, sector, kind);
	chunksz--;
	secno++;

	/* do the others */
	while (chunksz-- != 0) {
		read_sector(fd, secno, sector);
		buf = append_vdit_sector(secno, buf, sector, VDIT_BLOCK);
		if (buf == NULL)
			return NULL;
		secno++;
	}

	return buf;
}

uint8_t *
read_vdit(int fd, uint32_t secno, size_t *vditsize)
{
	uint8_t sector[VDM_BLOCK_SIZE];
	struct vdit_block_header hdr;
	uint32_t vdit_size;
	uint8_t *buf, *curbuf;
	int first = 1;

	vdit_size = get_vdit_size(fd, secno);
#ifdef DEBUG
	printf("vdit size: %02x sectors\n", vdit_size);
#endif

	buf = (uint8_t *)malloc(VDM_BLOCK_SIZE * vdit_size);
	if (buf == NULL)
		err(1, "malloc");
	memset(buf, 0, VDM_BLOCK_SIZE * vdit_size);

	curbuf = buf;
	for (;;) {
		/* read first sector of portion */
		read_sector(fd, secno, sector);
		memcpy(&hdr, sector, sizeof hdr);

		curbuf = append_vdit_portion(fd, secno, curbuf, sector,
		    first ? VDIT_BLOCK_HEAD_BE : VDIT_PORTION_HEADER_BLOCK);
		if (curbuf == NULL) {
			free(buf);
			return NULL;
		}
		first = 0;

		if (hdr.nextblk == VDM_NO_BLK_NUMBER)
			break;

		secno = betoh32(hdr.nextblk);
	}

	if (verbose)
		printf("vdit final size: 0x%zx bytes\n", curbuf - buf);

	*vditsize = curbuf - buf;
	return buf;
}

void
report(int fd)
{
	uint8_t *vdit, *vdit2, *tmpvdit;
	size_t vditsize, vditsize2;
	struct vdm_label *dl;
	struct vdm_boot_info *bi;
	struct disklabel *lp;
	uint8_t sector[VDM_BLOCK_SIZE];
	struct vdit_block_header *hdr;

	read_sector(fd, VDM_LABEL_SECTOR, sector);
	analyze_label_sector(sector, &dl, &bi);

	if (dl == NULL)
		return;

	printf("label version %04x\n", betoh16(dl->version));

	if (bi != NULL)
		printf("disk boot info: start %08x size %08x version %08x\n",
		    betoh32(bi->boot_start),
		    betoh32(bi->boot_size), betoh32(bi->version));

	read_sector(fd, VDIT_SECTOR, sector);
	hdr = (struct vdit_block_header *)sector;
	if (VDM_ID_KIND(&hdr->id) != VDIT_BLOCK_HEAD_BE) {
		lp = (struct disklabel *)(sector + LABELOFFSET);
		if (lp->d_magic == DISKMAGIC && lp->d_magic2 == DISKMAGIC) {
			if (verbose)
				printf("no VDIT but a native OpenBSD label\n");
			return;
		}
		errx(3, "unexpected block kind on sector %08x: %02x",
		    1, VDM_ID_KIND(&hdr->id));
	}

	vdit = read_vdit(fd, 1, &vditsize);
	if (vdit != NULL) {
		tmpvdit = vdit;
		while (tmpvdit != NULL)
			tmpvdit = print_vdit_entry(tmpvdit);

		vdit2 = read_vdit(fd, betoh32(hdr->secondary_vdit), &vditsize2);
		if (vdit2 == NULL)
			printf("can't read backup VDIT\n");
		else {
			if (vditsize2 < vditsize) {
				printf("WARNING: backup VDIT is smaller "
				    "than main VDIT!\n");
				vditsize = vditsize2;
			}
			if (memcmp(vdit, vdit2, vditsize) != 0)
				printf("VDIT and backup VDIT differ!\n");
			free(vdit2);
		}

		free(vdit);
	}
}

/*
 * Build a minimal VDM label and boot area.
 * Allows you to shoot yourself in the foot, badly.
 */
void
initialize(int fd)
{
	uint8_t sector[VDM_BLOCK_SIZE];
	struct vdm_label dl;
	struct vdm_boot_info bi;

	memset(sector, 0, sizeof sector);
	memset(&dl, 0, sizeof dl);
	memset(&bi, 0, sizeof bi);

	dl.signature = htobe32(VDM_LABEL_SIGNATURE);
	bi.signature = htobe32(VDM_LABEL_SIGNATURE);
	bi.boot_start = htobe32(8);
	bi.boot_size = htobe32(VDM_BOOT_DEFAULT_SIZE);
	bi.version = htobe32(VDM_BOOT_INFO_VERSION);

	memcpy(sector + VDM_LABEL_OFFSET_ALT, &dl, sizeof dl);
	memcpy(sector + VDM_BLOCK_SIZE - sizeof bi, &bi, sizeof bi);

	write_sector(fd, VDM_LABEL_SECTOR, sector);
}


code:
/Makefile/1.11/Sun Dec  8 14:46:39 2013//TOPENBSD_5_8_BASE
D/compile////
D/conf////
D/dev////
D/gsc////
D/hppa////
D/include////
D/spmath////
D/stand////

path: sys/arch/hppa/CVS/Entries


code: src/sys/arch/hppa

path: sys/arch/hppa/CVS/Repository


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

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

NOPROG=
NOMAN=
NOOBJ=
SUBDIR=	stand

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

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

obj:	_SUBDIRUSE

.include <bsd.prog.mk>

path: sys/arch/hppa/Makefile


code:
/.cvsignore/1.5/Sat Jun 26 17:43:26 2010//TOPENBSD_5_8_BASE
D

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


code: src/sys/arch/hppa/compile

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


code: src/sys/arch/hppa/conf

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


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

machine		hppa
include		"../../../conf/GENERIC"
maxusers	80				# estimated number of users

# Support for various CPU types
option		HP7000_CPU		# PCXS
option		HP7100_CPU		# PCXT
option		HP7200_CPU		# PCXT'
option		HP7100LC_CPU		# PCXL
option		HP7300LC_CPU		# PCXL2
option		HP8000_CPU		# PCXU  (in 32bit mode)
option		HP8200_CPU		# PCXU2 (in 32bit mode)
option		HP8500_CPU		# PCXW  (in 32bit mode)
option		HP8700_CPU		# PCXW2 (in 32bit mode)
#option		USE_HPT

option		FPEMUL
option		USELEDS		# blink 'em
option		USER_PCICONF	# user-space PCI configuration
option	WSDISPLAY_COMPAT_RAWKBD		# provide raw scancodes; needed for X11

config	bsd swap generic

mainbus0 at root		# root bus

mem*	at mainbus0 flags 0x0000	# /dev/*mem and memory controller
pdc0	at mainbus0		# PDC/IODC wrapper for boot console
power0	at mainbus0		# power/fail manager (iv 30)
lcd0	at mainbus0		# LCD
cpu0	at mainbus0 irq 31	# HP PA-RISC cpu
#fpu*	at mainbus0		# HP PA-RISC fpu (iv N/A)
#pmu*	at mainbus0 irq 29	# HP PA-RISC performance monitor unit
phantomas0 at mainbus0		# Phantom PseudoBC GSC+ Port
uturn0	at mainbus0		# U2/UTurn Runway IOA
uturn1	at mainbus0
astro*	at mainbus0		# Astro memory & I/O controller

lasi0	at mainbus0 offset 0x100000 irq 28	# LASI host adapter
lasi0	at mainbus0 offset 0xfd00000 irq 28	# LASI on C1[01]0, J2[01]0
lasi0	at phantomas0 offset 0xfd00000 irq 28	# LASI on [AB]*
lasi0	at uturn? offset 0xfd00000 irq 28	# LASI on [CJ]*
lasi1	at mainbus0 offset 0x500000 irq 27	# 712 GIO card
asp*	at mainbus0 irq 28	# this one comes w/ Viper and LEDs
wax*	at mainbus0 irq 24	# Wax may host EISA as well
wax*	at phantomas0 irq 24	# Wax on [AB]*
wax*	at uturn? irq 24	# Wax on C*
mongoose* at mainbus0 irq 17	# EISA Bus Adapter (i82350 or TI???)
#vmeb*	at mainbus0 irq ?	# VME bus adapter
dino0	at phantomas? irq 26	# PCI bus bridge on [AB]*
dino1	at phantomas? irq 25
dino0	at uturn0 irq 26	# PCI bus bridge on [CJ]*
dino1	at uturn1 irq 25
pci*	at dino?
option	PCIVERBOSE
#pckbc0	at dino? irq 9
com1	at dino? irq 11

elroy*	at astro?
pci*	at elroy?

ppb*	at pci?
pci*	at ppb?

ssio*	at pci?
com0	at ssio? irq 4
com1	at ssio? irq 3
lpt0	at ssio?

# CardBus bus support
cbb*		at pci?
cardslot*	at cbb?
option		CARDBUS_DEBUG,CARDSLOT_DEBUG,CARDBUS_MAP_DEBUG
cardbus*	at cardslot?
option		PCMCIADEBUG,PCMCIAVERBOSE
pcmcia*		at cardslot?

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

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

# USB devices
uhub*	at usb?			# USB Hubs
uhub*	at uhub?		# USB Hubs
uftdi*	at uhub?		# FTDI FT8U100AX serial adapter
ucom*	at uftdi?
uplcom* at uhub?		# I/O DATA USB-RSAQ2 serial adapter
ucom*	at uplcom?
uark*	at uhub?		# Arkmicro ARK3116 serial
ucom*	at uark?
umass*	at uhub?		# USB Mass Storage devices
uhidev*	at uhub?		# Human Interface Devices
ums*	at uhidev?		# USB mouse
wsmouse* at ums? mux 0
ukbd*	at uhidev?		# USB keyboard
wskbd*	at ukbd? mux 1
uhid*	at uhidev?		# USB generic HID support
upd*	at uhidev?		# USB Power Devices sensors
aue*	at uhub?		# ADMtek AN986 Pegasus Ethernet
url*	at uhub?		# Realtek RTL8150L based adapters
rsu*	at uhub?		# Realtek RTL8188SU/RTL8191SU/RTL8192SU

# untested USB devices
ualea*	at uhub?		# Araneus Alea II TRNG
umodem*	at uhub?		# USB Modems/Serial
ucom*	at umodem?
uvisor*	at uhub?		# Handspring Visor
ucom*	at uvisor?
uvscom*	at uhub?		# SUNTAC Slipper U VS-10U serial
ucom*	at uvscom?
ubsa*	at uhub?		# Belkin serial adapter
ucom*	at ubsa?
umct*	at uhub?		# MCT USB-RS232 serial adapter
ucom*	at umct?
uslcom*	at uhub?		# Silicon Laboratories CP210x serial
ucom*	at uslcom?
uipaq*	at uhub?		# iPAQ serial adapter
ucom*	at uipaq?
umsm*	at uhub?		# Qualcomm MSM EVDO
ucom*	at umsm?
ucycom*	at uhidev?		# Cypress serial
ucom*	at ucycom?
uslhcom* at uhidev?		# Silicon Labs CP2110 USB HID UART
ucom*	at uslhcom?
uchcom*	at uhub?		# WinChipHead CH341/340 serial
ucom*	at uchcom?
uaudio* at uhub?		# USB Audio
audio*	at uaudio?
umidi*	at uhub?		# USB MIDI
midi*	at umidi?
ulpt*	at uhub?		# USB Printers
atu*	at uhub?		# Atmel AT76c50x based 802.11b
axe*	at uhub?		# ASIX Electronics AX88172 USB Ethernet
axen*	at uhub?		# ASIX Electronics AX88179 USB Ethernet
cue*	at uhub?		# CATC USB-EL1201A based Ethernet
kue*	at uhub?		# Kawasaki KL5KUSB101B based Ethernet
smsc*	at uhub?		# SMSC LAN95xx Ethernet
cdce*	at uhub?		# CDC Ethernet
urndis*	at uhub?		# Remote NDIS Ethernet
udav*	at uhub?		# Davicom DM9601 based Ethernet
upl*	at uhub?		# Prolific PL2301/PL2302 host-to-host `network'
ugl*	at uhub?		# Genesys Logic GL620USB-A host-to-host `network'
wi*	at uhub?		# WaveLAN IEEE 802.11DS
udsbr*	at uhub?		# D-Link DSB-R100 radio
radio*	at udsbr?		# USB radio
ugen*	at uhub?		# USB Generic driver
ural*	at uhub?		# Ralink RT2500USB
rum*	at uhub?		# Ralink RT2501USB/RT2601USB
run*	at uhub?		# Ralink RT2700U/RT2800U/RT3000U
zyd*	at uhub?		# Zydas ZD1211
uthum*	at uhidev?		# TEMPerHUM sensor
ugold*	at uhidev?		# gold TEMPer sensor
utwitch* at uhidev?		# YUREX BBU sensor
uow*	at uhub?		# Maxim/Dallas DS2490 1-Wire adapter
onewire* at uow?
udl*	at uhub?		# DisplayLink USB displays
wsdisplay* at udl?

sti0	at mainbus0 irq 11	# [H]CRX-{8,24,48}[Z] graphics
sti0	at phantomas0 irq 11	# builtin graphics on BC*
sti0	at uturn? irq 11
sti1	at mainbus0 irq 12
sti1	at phantomas0 irq 12
sti1	at uturn? irq 12
sti*	at pci?			# EG-PCI, FX*

#medusa* at mainbus? irq 4	# FDDI
#venus* at mainbus? irq 5	# ATM J2498A/J3420A

# internal i/o space
gsc0	at asp?			# Snakes, old 715, old 725, 735/755
gsc0	at lasi0		# 712,715/100,725/64,725/100,[ABCJ]*
gsc1	at lasi1
gsc2	at wax?			# it's another face of LASI

#vme*	at vmeb?
#option	VMEVERBOSE
eisa*	at mongoose?
#eisa*	at wax?
option	EISAVERBOSE
#isa*	at mongoose?
#isa*	at wax?

# GSC devices

hil*	at gsc? irq 1	# Human Interface Loop, kbd and mouse
hilkbd*	at hil?		# keyboard, knob and buttons
hilms*	at hil?		# mouse and tablets
hilid*	at hil?		# ID module

# RS/232 serial ports
com0	at gsc0 offset 0x5000 irq 5	# on lasi
com1	at gsc1 offset 0x5000 irq 5
com1	at gsc2 offset 0x2000 irq 6	# on wax
com0	at gsc0 offset 0x823000 irq 5	# on asp
com1	at gsc0 offset 0x822000 irq 6
com2	at gsc0 offset 0x0 irq 13	# only on asp0 w/o audio (off ?)
com2	at gsc0 offset 0x4040 irq 13	# gecko's fax/voice/modems
com3	at gsc0 offset 0x4060 irq 13
#com*	at pcmcia?			# PCMCIA modems

lpt0	at gsc? irq 7		# both com and lpt are on WD16C552
ie0	at gsc0 irq 8		# 82C596DX/CA ether
#ie1	at gsc1 irq 8
#ie*	at eisa?
#ie*	at isa? port 0x360 iomem 0xd0000 irq 7
#ie*	at isa? port 0x300 irq 10
#ie*	at pci?
#tms*	at gsc? irq 10		# TMS380C26 Network Controller
#siop*	at gsc? irq 3		# NCR 53C720 (Fast-Wide HVD)
osiop*	at gsc? irq 9		# NCR 53C710 (Narrow SE)
#osiop* at eisa?
oosiop*	at gsc? irq 9		# NCR 53C700 (Narrow SE)
arcofi*	at gsc? irq 13		# Audio Type 1 (PSB2160)
audio*	at arcofi?
harmony* at gsc? irq 13		# Audio Type 2 (CS4215/AD1849)
audio*	at harmony?
gsckbc*	at gsc? irq 26
pckbd*	at gsckbc?		# PS/2 keyboard
pms*	at gsckbc?		# PS/2 mouse

#sh*	at eisa?		# Interphase Seahawk 4811 EISA/FDDI
#ahb*	at eisa?		# Adaptec 174[024] SCSI controllers
#ahc*	at eisa?		# Adaptec 274x, aic7770 SCSI controllers
ahc*	at pci?			# Adaptec 2940 SCSI controllers
mpi*	at pci?			# LSI Logic Fusion MPT Message Passing Interface
#option	BHADEBUG
#bha*	at eisa?
#bha*	at pci?
qlw*	at pci?			# QLogic ISP SCSI
qla*	at pci?			# QLogic ISP 2[123]xx FibreChannel
qle*	at pci?			# QLogic ISP 2[45]xx FibreChannel

siop*	at mainbus? irq 3	# NCR 53C720 (Fast-Wide HVD)
siop*	at phantomas? irq 3
siop*	at uturn? irq 3
siop*	at pci?			# NCR 53C8XX SCSI controllers
#ahd*	at pci?			# Adaptec 79?? SCSI controllers

em*	at pci?			# Intel Pro/1000 ethernet
ti*	at pci?			# Alteon Tigon 1Gb ethernet
#txp*	at pci?			# 3com 3CR990
#epic*	at pci?			# SMC EPIC/100 ethernet
#de*	at pci?			# 21x4[012]-based Ethernet
#de*	at eisa?
dc*	at pci?			# 21143, "tulip" clone ethernet
#dc*	at cardbus?
rl*	at pci?			# Realtek 81[23]9 ethernet
#rl*	at cardbus?
#ep*	at pci?			# 3c59x ethernet
#ep*	at eisa?		# 3c579 ethernet
#ep*	at pcmcia?		# 3c589 ethernet
xl*	at pci?			# 3C9xx ethernet
#xl*	at cardbus?
fxp*	at pci?			# EtherExpress 10/100B ethernet
#fxp*	at cardbus?
ne*	at pci?			# NE2000-compatible Ethernet
ne*	at pcmcia?
#atw*	at pci?			# ADMtek ADM8211 (802.11)
#atw*	at cardbus?
#an*	at pci?			# Cisco/Aironet 802.11DS
an*	at pcmcia?
#wi*	at pci?			# WaveLAN IEEE 802.11DS
wi*	at pcmcia?
skc*	at pci?			# SysKonnect GEnesis 984x
sk*	at skc?			#  each port of above
mskc*	at pci?			# Marvell Yukon-2
msk*	at mskc?		#  each port of above
bge*	at pci?			# Broadcom BCM570x (aka Tigon3)
hme*	at pci?			# Sun Happy Meal
stge*	at pci?			# Sundance TC9021 GigE

dcphy*		at mii?		# Digital Clone PHYs
acphy*		at mii?		# Altima AC101 PHYs
amphy*		at mii?		# AMD 79C873 PHYs
exphy*		at mii?		# 3Com internal PHYs
gentbi*		at mii?		# Generic 1000BASE-X ten-bit PHY
inphy*		at mii?		# Intel 82555 PHYs
iophy*		at mii?		# Intel 82553 PHYs
icsphy*		at mii?		# ICS1890 PHYs
lxtphy*		at mii?		# Level One LXT-970 PHYs
nsphy*		at mii?		# NS83840 PHYs
nsphyter*	at mii?		# NS83843 PHYs
mtdphy*		at mii?		# Myson MTD972 PHYs
qsphy*		at mii?		# Quality Semi QS6612 PHYs
luphy*		at mii?		# Lucent LU6612 PHY
sqphy*		at mii?		# Seeq 8022[013] PHYs
#tlphy*		at mii?		# ThunderLAN PHYs
tqphy*		at mii?		# TDK Semiconductor PHYs
brgphy*		at mii?		# Broadcom 10/100/1000 PHYs
bmtphy*		at mii?		# Broadcom 10/100 PHYs
eephy*		at mii?		# Marvell 88E1000 Gigabit PHYs
xmphy*		at mii?		# XaQti XMAC-II PHYs
rlphy*		at mii?		# Realtek 8139 internal PHYs
urlphy*		at mii?		# Realtek RTL8150L internal PHY
rgephy*		at mii?		# Realtek 8169S/8110S PHY
ipgphy*		at mii?		# IC Plus IP1000A PHYs
ukphy*		at mii?		# generic unknown PHYs

# MI devices
#wsdisplay*	at vgafb?
wsdisplay*	at sti?
wskbd*		at pckbd? mux 1
wskbd*		at hilkbd? mux 1
wsmouse*	at pms? mux 0
wsmouse*	at hilms? mux 0

#fdc*	at gsc?			# PC floppy controller (WD37C65C)
#fdc*	at isa? port 0x3f0 irq 6 drq 2
#option	FD_DEBUG
#fd*	at fdc?			# floppy drives

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

# These entries find devices on all SCSI busses and assign
# unit numers dynamically.
scsibus* at scsi?
sd*	at scsibus?
st*	at scsibus?
cd*	at scsibus?
ch*	at scsibus?
safte*	at scsibus?
ses*	at scsibus?
uk*	at scsibus?

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

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

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

path: sys/arch/hppa/conf/GENERIC


code:
#	$OpenBSD: GENERIC.MP,v 1.1 2010/06/26 17:43:26 jsing Exp $

include "arch/hppa/conf/GENERIC"

option MULTIPROCESSOR
#option MP_LOCKDEBUG

cpu*   at mainbus?


code:
#	$OpenBSD: Makefile.hppa,v 1.80 2015/01/13 01:12:49 deraadt Exp $

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

.include <bsd.own.mk>

SIZE?=	size
STRIP?=	strip

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

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

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

CMACHFLAGS=	-mfast-indirect-calls -mportable-runtime -mno-space-regs
CMACHFLAGS+=	-fno-builtin-printf -fno-builtin-snprintf \
		-fno-builtin-vsnprintf -fno-builtin-log \
		-fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS}
CMACHFLAGS+=	-fno-stack-protector

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

.if ${IDENT:M-DDDB} != ""
CFLAGS+=	-fno-omit-frame-pointer
.endif

.if ${IDENT:M-DHP7000_CPU} != ""
CFLAGS+=	-mpa-risc-1-0
.elif ${IDENT:M-DHP8*_CPU} != ""
CFLAGS+=	-mpa-risc-2-0
.else
CFLAGS+=	-mpa-risc-1-1
.endif

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

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

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

%OBJS

%CFILES

%SFILES

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

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

%LOAD

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

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

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

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

ioconf.o: ioconf.c
	${NORMAL_C}

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

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

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

depend:
	@touch $@

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

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

locore.o: ${_machdir}/${_mach}/locore.S assym.h
fpemu.o spcopy.o: assym.h

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

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

%RULES


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

machine		hppa
maxusers	4

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

option		RAMDISK_HOOKS
option		MINIROOTSIZE=5120

option		SCSITERSE
option		PCIVERBOSE

option		FFS
option		FFS2
option		NFSCLIENT
option		CD9660
option		MSDOSFS
option		INET6

# Support for various CPU types
option		HP7000_CPU		# PCXS
option		HP7100_CPU		# PCXT
option		HP7200_CPU		# PCXT'
option		HP7100LC_CPU		# PCXL
option		HP7300LC_CPU		# PCXL2
option		HP8000_CPU		# PCXU  (in 32bit mode)
option		HP8200_CPU		# PCXU2 (in 32bit mode)
option		HP8500_CPU		# PCXW  (in 32bit mode)
option		HP8700_CPU		# PCXW2 (in 32bit mode)
option		FPEMUL

config		bsd root on rd0a swap on rd0b # and sd0b

mainbus0	at root

mem*		at mainbus0 flags 0x0000	# /dev/*mem and memory controller
pdc0		at mainbus0		# PDC/IODC wrapper for boot console
power0		at mainbus0		# power/fail manager (iv 30)
cpu*		at mainbus0 irq 31	# HP PA-RISC cpu
#fpu*		at mainbus0		# HP PA-RISC fpu (iv N/A)
phantomas0	at mainbus0		# Phantom PseudoBC GSC+ Port
uturn0		at mainbus0		# U2/UTurn Runway IOA
uturn1		at mainbus0
astro*		at mainbus0		# Astro memory & I/O controller

lasi0		at mainbus0 offset 0x100000 irq 28	# LASI host adapter
lasi0		at mainbus0 offset 0xfd00000 irq 28	# LASI on C1[01]0, J2[01]0
lasi0		at phantomas0 offset 0xfd00000 irq 28	# LASI on [AB]*
lasi0		at uturn? offset 0xfd00000 irq 28	# LASI on [CJ]*
lasi1		at mainbus0 offset 0x500000 irq 27	# 712 GIO card
asp*		at mainbus0 irq 28	# this one comes w/ Viper and LEDs
wax*		at mainbus0 irq 24	# Wax may host EISA as well
wax*		at phantomas0 irq 24	# Wax on [AB]*
wax*		at uturn? irq 24	# Wax on C*
mongoose*	at mainbus0 irq 17	# EISA Bus Adapter (i82350 or TI???)
dino0		at phantomas? irq 26	# PCI bus bridge on [AB]*
dino1		at phantomas? irq 25
dino0		at uturn0 irq 26	# PCI bus bridge on [CJ]*
dino1		at uturn1 irq 25
pci*		at dino?
com1		at dino? irq 11

elroy*		at astro?
pci*		at elroy?

ppb*		at pci?
pci*		at ppb?

ssio*		at pci?
com0		at ssio? irq 4
com1		at ssio? irq 3

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

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

uhub*		at usb?
uhub*		at uhub?
umass*		at uhub?
uhidev*		at uhub?		# Human Interface Devices
ukbd*		at uhidev?		# USB keyboard
wskbd*		at ukbd? mux 1
uhid*		at uhidev?		# USB generic HID support
aue*		at uhub?		# ADMtek AN986 Pegasus Ethernet
url*		at uhub?		# Realtek RTL8150L based adapters
atu*		at uhub?		# Atmel AT76c50x based 802.11b
axe*		at uhub?		# ASIX Electronics AX88172 USB Ethernet
axen*		at uhub?		# ASIX Electronics AX88179 USB Ethernet
cue*		at uhub?		# CATC USB-EL1201A based Ethernet
kue*		at uhub?		# Kawasaki KL5KUSB101B based Ethernet
smsc*		at uhub?		# SMSC LAN95xx Ethernet
cdce*		at uhub?		# CDC Ethernet
udav*		at uhub?		# Davicom DM9601 based Ethernet
upl*		at uhub?		# Prolific PL2301/PL2302 host-to-host
ugl*		at uhub?		# Genesys Logic GL620USB-A host-to-host
wi*		at uhub?		# WaveLAN IEEE 802.11DS
ural*		at uhub?		# Ralink RT2500

sti0		at mainbus0 irq 11	# [H]CRX-{8,24,48}[Z] graphics
sti0		at phantomas0 irq 11	# builtin graphics on BC*
sti0		at uturn? irq 11
sti1		at mainbus0 irq 12
sti1		at phantomas0 irq 12
sti1		at uturn? irq 12
sti*		at pci?			# EG-PCI, FX*

gsc0		at asp?			# Snakes, old 715, old 725, 735/755
gsc0		at lasi0		# 712,715/100,725/64,725/100,[ABCJ]*
gsc1		at lasi1
gsc2		at wax?			# it's another face of LASI

eisa*		at mongoose?

hil*		at gsc? irq 1		# Human Interface Loop, kbd and mouse
hilkbd*		at hil?			# keyboard, knob and buttons

com0		at gsc0 offset 0x5000 irq 5	# on lasi
com1		at gsc1 offset 0x5000 irq 5
com1		at gsc2 offset 0x2000 irq 6	# on wax
com0		at gsc0 offset 0x823000 irq 5	# on asp
com1		at gsc0 offset 0x822000 irq 6
com2		at gsc0 offset 0x0 irq 13	# only on asp0 w/o audio (off ?)
com2		at gsc0 offset 0x4040 irq 13	# gecko's fax/voice/modems
com3		at gsc0 offset 0x4060 irq 13

ie0		at gsc0 irq 8		# 82C596DX/CA ether
osiop*		at gsc? irq 9		# NCR 53C710 (Narrow SE)
oosiop*		at gsc? irq 9		# NCR 53C700 (Narrow SE)
gsckbc*		at gsc? irq 26
pckbd*		at gsckbc?		# PS/2 keyboard
ahc*		at pci?			# Adaptec 2940 SCSI controllers
mpi*		at pci?			# LSI Logic Fusion MPT Message Passing Interface
qlw*		at pci?			# QLogic ISP SCSI
qla*		at pci?			# QLogic ISP 2[123]xx FibreChannel
option		QLE_NOFIRMWARE
qle*		at pci?			# QLogic ISP 2[45]xx FibreChannel

siop*		at mainbus? irq 3	# NCR 53C720 (Fast/Wide HVD)
siop*		at phantomas? irq 3
siop*		at uturn? irq 3
siop*		at pci?			# NCR 53C8XX SCSI controllers
softraid0	at root

em*		at pci?			# Intel Pro/1000 ethernet
dc*		at pci?			# 21143, "tulip" clone ethernet
rl*		at pci?			# Realtek 81[23]9 ethernet
xl*		at pci?			# 3C9xx ethernet
fxp*		at pci?			# EtherExpress 10/100B ethernet
ne*		at pci?			# NE2000-compatible Ethernet
ne*		at pcmcia?
an*		at pcmcia?
wi*		at pcmcia?
skc*		at pci?			# SysKonnect GEnesis 984x
sk*		at skc?			#  each port of above
mskc*		at pci?			# Marvell Yukon-2
msk*		at mskc?		#  each port of above
bge*		at pci?			# Broadcom BCM570x (aka Tigon3)
hme*		at pci?			# Sun Happy Meal
stge*		at pci?			# Sundance TC9021 GigE

dcphy*		at mii?			# Digital Clone PHYs
acphy*		at mii?			# Altima AC101 PHYs
amphy*		at mii?			# AMD 79C873 PHYs
exphy*		at mii?			# 3Com internal PHYs
gentbi*		at mii?			# Generic 1000BASE-X ten-bit PHY
inphy*		at mii?			# Intel 82555 PHYs
iophy*		at mii?			# Intel 82553 PHYs
icsphy*		at mii?			# ICS1890 PHYs
lxtphy*		at mii?			# Level One LXT-970 PHYs
nsphy*		at mii?			# NS83840 PHYs
nsphyter*	at mii?			# NS83843 PHYs
mtdphy*		at mii?			# Myson MTD972 PHYs
qsphy*		at mii?			# Quality Semi QS6612 PHYs
luphy*		at mii?			# Lucent LU6612 PHY
sqphy*		at mii?			# Seeq 8022[013] PHYs
tqphy*		at mii?			# TDK Semiconductor PHYs
brgphy*		at mii?			# Broadcom 10/100/1000 PHYs
bmtphy*		at mii?			# Broadcom 10/100 PHYs
eephy*		at mii?			# Marvell 88E1000 Gigabit PHYs
xmphy*		at mii?			# XaQti XMAC-II PHYs
rlphy*		at mii?			# Realtek 8139 internal PHYs
urlphy*		at mii?			# Realtek RTL8150L internal PHY
rgephy*		at mii?			# Realtek 8169S/8110S PHY
ipgphy*		at mii?			# IC Plus IP1000A PHYs
ukphy*		at mii?			# generic unknown PHYs

wsdisplay*	at sti?
wskbd*		at pckbd? mux 1
wskbd*		at hilkbd? mux 1

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

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

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

path: sys/arch/hppa/conf/RAMDISK


code:
#	$OpenBSD: files.hppa,v 1.94 2015/07/17 22:52:28 tedu Exp $
#
# hppa-specific configuration info

# maxpartitions must be the first item in files.${ARCH}
maxpartitions 16

maxusers 2 8 128

#
# "workstation console" routines
#
include "dev/wscons/files.wscons"
file	arch/hppa/hppa/wscons_machdep.c	wsdisplay

include "dev/rasops/files.rasops"
include "dev/wsfont/files.wsfont"

#
# Media Independent Interface (mii)
#
include "dev/mii/files.mii"

#
# Machine-independent SCSI drivers
#
include "scsi/files.scsi"
major	{sd = 4}
major	{st = 5}
major	{cd = 6}

#
# MI ATAPI drivers
#
include "dev/atapiscsi/files.atapiscsi"
include "dev/ata/files.ata"
major	{wd = 8}

#
# ISA Bus support
#
include "dev/isa/files.isa"
include "dev/isa/files.isapnp"

#
# EISA Bus support
#
include "dev/eisa/files.eisa"

#
# PCI Bus support
#
include "dev/pci/files.pci"

device	hme: ether, ifnet, mii, ifmedia
file	dev/ic/hme.c			hme
attach	hme at pci with hme_pci
file	dev/pci/if_hme_pci.c		hme_pci

#
# CardBus support
#
include	"dev/cardbus/files.cardbus"

#
# Machine-independent PCMCIA drivers
#
include	"dev/pcmcia/files.pcmcia"

#
# Machine-independent USB drivers
#
include "dev/usb/files.usb"

#
# HIL Human Interface Loop devices
#
include "dev/hil/files.hil"

#
# Machine-independent 1-Wire drivers
#
include "dev/onewire/files.onewire"

#
# Gonzo System Connect Bus
#	(GSC, GSC-1X, GSC+, GSC-1.5X, GSC-2X)
#
define	gscbus	{}

#
# Mainbus
#

define	gedoens {[offset = -1], [irq = -1]}
device	mainbus: gedoens
attach	mainbus at root
file	arch/hppa/hppa/mainbus.c		mainbus

device	pdc
attach	pdc at gedoens
file	arch/hppa/dev/pdc.c			pdc

device	power
attach	power at gedoens
file	arch/hppa/dev/power.c			power needs-flag

device	lcd
attach	lcd at gedoens
file	arch/hppa/dev/lcd.c			lcd needs-flag

device	mem
attach	mem at gedoens
file	arch/hppa/dev/mem.c			mem

device	cpu
attach	cpu at gedoens
file	arch/hppa/dev/cpu.c			cpu

device	fpu
attach	fpu at gedoens
file	arch/hppa/dev/fpu.c			fpu

# Phantom PseudoBC GSC+ Port
device	phantomas: gedoens
attach	phantomas at gedoens
file	arch/hppa/dev/phantomas.c		phantomas

# GeckoBOA BC GSC+ port
device	gecko: gedoens
attach	gecko at gedoens
file	arch/hppa/dev/gecko.c			gecko

# U2/Uturn, Runway to GSC Bus bridge & IOA
device	uturn: gedoens
attach	uturn at gedoens
file	arch/hppa/dev/uturn.c			uturn

# Astro memory & I/O controller
device	astro: gedoens
attach	astro at gedoens
file	arch/hppa/dev/astro.c			astro

# 1FT1-0002, 1FU2-0002
# as goes w/ 7100LC, 7300LC, 7200 and some of 8000, 8200, 8500
device	lasi: gscbus
attach	lasi at gedoens
file	arch/hppa/dev/lasi.c			lasi

# all the older systems
device	asp: gscbus
attach	asp at gedoens
file	arch/hppa/dev/asp.c			asp

# 1FT4-0001, ASIC used on gecko cards
device	wax: gscbus, isabus, eisabus
attach	wax at gedoens
file	arch/hppa/dev/wax.c			wax

device	mongoose: isabus, eisabus
attach	mongoose at gedoens with mg_gedoens
file	arch/hppa/dev/mongoose.c		mongoose

define	dinobus {[offset = -1], [irq = -1]}

# Dino, GSC-PCI bridge. Includes ps/2, cereal and a flying toaster interfaces
# Cujo is a 64-bit data path Dino
device	dino: pcibus, dinobus
attach	dino at gedoens
file	arch/hppa/dev/dino.c			dino

attach	com at dinobus with com_dino
file	arch/hppa/dev/com_dino.c		com_dino

# Elroy, Ropes to PCI Bridge. Supports 4X PCI and dual address cycle.
# Mercury; QuickSilver is an AGP also
device	elroy: pcibus
attach	elroy at gedoens
file	arch/hppa/dev/elroy.c		elroy
file	arch/hppa/dev/apic.c		elroy

# EPIC, Excalibur PCI Interface Chip. Integrated IOA
# SAGA is a 64-bit data path EPIC
#device	epic: pcibus
#attach	epic at gedoens
#file	arch/hppa/dev/epic.c			epic

attach	sti at gedoens with sti_gedoens
file	arch/hppa/dev/sti_sgc.c			sti_gedoens
file	arch/hppa/dev/sti_pci_machdep.c		sti_pci

attach	siop at gedoens with siop_gedoens
file	arch/hppa/dev/siop_sgc.c		siop_gedoens

device	ssio {[irq = -1]}
attach	ssio at pci
file	arch/hppa/dev/ssio.c			ssio

attach	com at ssio with com_ssio
file	arch/hppa/dev/com_ssio.c		com_ssio

attach	lpt at ssio with lpt_ssio
file	arch/hppa/dev/lpt_ssio.c		lpt_ssio

###

major	{vnd = 2}
major	{rd = 3}

#
# GSC bus devices
#

device	gsc {[offset = -1], [irq = -1]}
attach	gsc at gscbus
file	arch/hppa/gsc/gscbus.c			gsc

# com and lpt are both on WD 16C552
attach	com at gsc with com_gsc
file	arch/hppa/gsc/com_gsc.c			com_gsc

attach	lpt at gsc with lpt_gsc
file	arch/hppa/gsc/lpt_gsc.c			lpt_gsc

attach	mongoose at gsc with mg_gsc
file	arch/hppa/gsc/mongoose_gsc.c		mg_gsc

#include "dev/fdc/files.fdc"
#major	{fd = 7}
#attach	fdc at gsc with fdc_gsc
#file	arch/hppa/gsc/fdc_gsc.c			fdc_gsc

attach	ie at gsc with ie_gsc
file	arch/hppa/gsc/if_ie_gsc.c		ie_gsc

attach	siop at gsc with siop_gsc
file	arch/hppa/gsc/siop_gsc.c		siop_gsc

attach	osiop at gsc with osiop_gsc
file	arch/hppa/gsc/osiop_gsc.c		osiop_gsc

attach	oosiop at gsc with oosiop_gsc
file	arch/hppa/gsc/oosiop_gsc.c		oosiop_gsc

attach	hil at gsc with hil_gsc
file	arch/hppa/gsc/hil_gsc.c			hil_gsc

# PSB 2160-N based 8bit mono audio (705, 710, 745i/*, 747i/*)
attach	arcofi at gsc with arcofi_gsc
file	arch/hppa/gsc/arcofi_gsc.c		arcofi_gsc

# CS4215/AD1849 based 16bit mono/stereo audio iface (most of others not w/ aone)
# a.k.a. Audio Type 2 (optional beeper)
device	harmony: audio
attach	harmony at gsc
file	arch/hppa/gsc/harmony.c			harmony

# HPA4011A/B w/ TMS380C26PQL, TMS38054FNL
#device	tms: tokenring
#attach	tms at gsc
#file	arch/hppa/gsc/if_tms.c			tms

# these we don't know yet
# AMD Supernet2 FDDI ?
#device	medusa: fddi
#attach	medusa at gsc
#file	arch/hppa/gsc/medusa.c			medusa

# XXX should not be here
# ANSI/VITA 26-1998 Gbit packet switching network iface
#device	myri: ether
#attach	myri at pci
#file	dev/pci/myri.c				myri

# PS/2 input ports
device	gsckbc: pckbcslot
attach	gsckbc at gsc
file	arch/hppa/gsc/gsckbc.c			gsckbc

# PS/2 keyboard and mouse
include	"dev/pckbc/files.pckbc"

#
# Non-device files
#

file	arch/hppa/hppa/autoconf.c
file	arch/hppa/hppa/conf.c
file	arch/hppa/hppa/db_interface.c		ddb
file	arch/hppa/hppa/db_disasm.c		ddb
file	arch/hppa/hppa/disksubr.c		disk
file	arch/hppa/hppa/fpu.c
file	arch/hppa/hppa/ipi.c			multiprocessor
file	arch/hppa/hppa/lock_machdep.c		multiprocessor
file	arch/hppa/hppa/machdep.c
file	arch/hppa/hppa/mutex.c
file	arch/hppa/hppa/pmap.c
file	arch/hppa/hppa/process_machdep.c
file	arch/hppa/hppa/sys_machdep.c
file	arch/hppa/hppa/trap.c
file	arch/hppa/hppa/intr.c
file	arch/hppa/hppa/vm_machdep.c
file	arch/hppa/hppa/in_cksum.c
file	netinet/in4_cksum.c
file	arch/hppa/dev/clock.c
file	arch/hppa/hppa/fpemu.S			fpemul

# quad support is necessary for 32 bit architectures
file	lib/libkern/adddi3.c
file	lib/libkern/anddi3.c
file	lib/libkern/ashldi3.c
file	lib/libkern/ashrdi3.c
file	lib/libkern/cmpdi2.c
file	lib/libkern/divdi3.c
file	lib/libkern/iordi3.c
file	lib/libkern/lshldi3.c
file	lib/libkern/lshrdi3.c
file	lib/libkern/moddi3.c
file	lib/libkern/muldi3.c
file	lib/libkern/negdi2.c
file	lib/libkern/notdi2.c
file	lib/libkern/qdivrem.c
file	lib/libkern/subdi3.c
file	lib/libkern/ucmpdi2.c
file	lib/libkern/udivdi3.c
file	lib/libkern/umoddi3.c
file	lib/libkern/xordi3.c

# kern..
file	lib/libkern/arch/hppa/milli.S
file	lib/libkern/arch/hppa/spcopy.S

# fpu emulation
file	arch/hppa/spmath/dfadd.c	fpemul
file	arch/hppa/spmath/dfcmp.c	fpemul
file	arch/hppa/spmath/dfdiv.c	fpemul
file	arch/hppa/spmath/dfmpy.c	fpemul
file	arch/hppa/spmath/dfrem.c	fpemul
file	arch/hppa/spmath/dfsqrt.c	fpemul
file	arch/hppa/spmath/dfsub.c	fpemul
file	arch/hppa/spmath/divsfm.c	fpemul
file	arch/hppa/spmath/divsfr.c	fpemul
file	arch/hppa/spmath/divsim.c	fpemul
file	arch/hppa/spmath/divsir.c	fpemul
file	arch/hppa/spmath/divufr.c	fpemul
file	arch/hppa/spmath/divuir.c	fpemul
file	arch/hppa/spmath/fcnvff.c	fpemul
file	arch/hppa/spmath/fcnvfx.c	fpemul
file	arch/hppa/spmath/fcnvfxt.c	fpemul
file	arch/hppa/spmath/fcnvxf.c	fpemul
file	arch/hppa/spmath/frnd.c		fpemul
file	arch/hppa/spmath/mpyaccs.c	fpemul
file	arch/hppa/spmath/mpyaccu.c	fpemul
file	arch/hppa/spmath/mpys.c		fpemul
file	arch/hppa/spmath/mpyscv.c	fpemul
file	arch/hppa/spmath/mpyu.c		fpemul
file	arch/hppa/spmath/mpyucv.c	fpemul
file	arch/hppa/spmath/sfadd.c	fpemul
file	arch/hppa/spmath/sfcmp.c	fpemul
file	arch/hppa/spmath/sfdiv.c	fpemul
file	arch/hppa/spmath/sfmpy.c	fpemul
file	arch/hppa/spmath/sfrem.c	fpemul
file	arch/hppa/spmath/sfsqrt.c	fpemul
file	arch/hppa/spmath/sfsub.c	fpemul
file	arch/hppa/spmath/divu.S		fpemul
file	arch/hppa/spmath/impys.S	fpemul
file	arch/hppa/spmath/impyu.S	fpemul


code:
/* 	$OpenBSD: ld.script,v 1.17 2011/04/25 20:43:40 kettenis Exp $	*/

/*
 * Copyright (c) 2003 Michael Shalayeff
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES 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 MIND, 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.
 */

OUTPUT_FORMAT("elf32-hppa")
OUTPUT_ARCH(hppa)
ENTRY($start)
SECTIONS
{
	. = + SIZEOF_HEADERS;
	.text :
	{
		kernel_text = . ;
		*(.text) *(.text.*)
		*(.reginfo)
		*(.init)
		*(.stub)
		/* .gnu.warning sections are handled specially by elf32.em.  */
		*(.gnu.warning)
		. = ALIGN(4096);
		etext = ABSOLUTE(.);
	} = 0x08000240	/* nop filled */

	. = 0x500000;

	.rodata :
	{
		__rodata_start = .;
		*(.rodata) *(.rodata1)
		. = ALIGN(8);
		__unwind_start = .;
		*(.PARISC.unwind)
		__unwind_end = .;
		. = ALIGN(4096);
		__rodata_end = .;
	} = 0
	__data_start = ABSOLUTE(.);

	.data  :
	{
		$global$ = . ;
		. += 4;
		*(.data)
		CONSTRUCTORS
		. = ALIGN(4096);
		edata = ABSOLUTE(.);
	} = 0
	.ctors	: { *(.ctors) }
	.dtors	: { *(.dtors) }

	__bss_start = .;
	/* .sbss	: { *(.sbss) *(.scommon) } */
	.bss :
	{
		*(.dynbss) *(.bss)
		*(COMMON) *($COMMON$)
		. = ALIGN(4096);
	}
	end = ABSOLUTE(.);
}


code: src/sys/arch/hppa/dev

path: sys/arch/hppa/dev/CVS/Repository


code:
#	$OpenBSD: Makefile,v 1.4 2014/07/16 20:08:25 okan Exp $

AWK?=	awk

cpudevs.h cpudevs_data.h: cpudevs devlist2h.awk
	/bin/rm -f cpudevs.h cpudevs_data.h
	${AWK} -f devlist2h.awk cpudevs

path: sys/arch/hppa/dev/Makefile


code:
/*	$OpenBSD: apic.c,v 1.16 2014/12/09 06:58:28 doug Exp $	*/

/*
 * Copyright (c) 2005 Michael Shalayeff
 * Copyright (c) 2007 Mark Kettenis
 * All rights reserved.
 *
 * 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 MIND, 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. */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/evcount.h>
#include <sys/malloc.h>

#include <machine/autoconf.h>
#include <machine/pdc.h>

#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>

#include <hppa/dev/elroyreg.h>
#include <hppa/dev/elroyvar.h>

#define APIC_INT_LINE_MASK	0x0000ff00
#define APIC_INT_LINE_SHIFT	8
#define APIC_INT_IRQ_MASK	0x0000001f

#define APIC_INT_LINE(x) (((x) & APIC_INT_LINE_MASK) >> APIC_INT_LINE_SHIFT)
#define APIC_INT_IRQ(x) ((x) & APIC_INT_IRQ_MASK)

/*
 * Interrupt types match the Intel MP Specification.
 */

#define MPS_INTPO_DEF		0
#define MPS_INTPO_ACTHI		1
#define MPS_INTPO_ACTLO		3
#define MPS_INTPO_SHIFT		0
#define MPS_INTPO_MASK		3

#define MPS_INTTR_DEF		0
#define MPS_INTTR_EDGE		1
#define MPS_INTTR_LEVEL		3
#define MPS_INTTR_SHIFT		2
#define MPS_INTTR_MASK		3

#define MPS_INT(p,t) \
    ((((p) & MPS_INTPO_MASK) << MPS_INTPO_SHIFT) | \
     (((t) & MPS_INTTR_MASK) << MPS_INTTR_SHIFT))

struct apic_iv {
	struct elroy_softc *sc;
	pci_intr_handle_t ih;
	int (*handler)(void *);
	void *arg;
	struct apic_iv *next;
	struct evcount *cnt;
};

struct apic_iv *apic_intr_list[CPU_NINTS];

void	apic_get_int_tbl(struct elroy_softc *);
u_int32_t apic_get_int_ent0(struct elroy_softc *, int);
#ifdef DEBUG
void	apic_dump(struct elroy_softc *);
#endif

void		apic_write(volatile struct elroy_regs *r, u_int32_t reg,
		    u_int32_t val);
u_int32_t	apic_read(volatile struct elroy_regs *r, u_int32_t reg);

void
apic_write(volatile struct elroy_regs *r, u_int32_t reg, u_int32_t val)
{
	elroy_write32(&r->apic_addr, htole32(reg));
	elroy_write32(&r->apic_data, htole32(val));
	elroy_read32(&r->apic_data);
}

u_int32_t
apic_read(volatile struct elroy_regs *r, u_int32_t reg)
{
	elroy_write32(&r->apic_addr, htole32(reg));
	return letoh32(elroy_read32(&r->apic_data));
}

void
apic_attach(struct elroy_softc *sc)
{
	volatile struct elroy_regs *r = sc->sc_regs;
	u_int32_t data;

	data = apic_read(r, APIC_VERSION);
	sc->sc_nints = (data & APIC_VERSION_NENT) >> APIC_VERSION_NENT_SHIFT;
	printf(" APIC ver %x, %d pins",
	    data & APIC_VERSION_MASK, sc->sc_nints);

	sc->sc_irq = mallocarray(sc->sc_nints, sizeof(int), M_DEVBUF,
	    M_NOWAIT | M_ZERO);
	if (sc->sc_irq == NULL)
		panic("apic_attach: cannot allocate irq table");

	apic_get_int_tbl(sc);

#ifdef DEBUG
	apic_dump(sc);
#endif
}

int
apic_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
	struct elroy_softc *sc = pa->pa_pc->_cookie;
	pci_chipset_tag_t pc = pa->pa_pc;
	pcitag_t tag = pa->pa_tag;
	pcireg_t reg;
	int line;

	reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
#ifdef DEBUG
	printf(" pin=%d line=%d ", PCI_INTERRUPT_PIN(reg),
	    PCI_INTERRUPT_LINE(reg));
#endif
	line = PCI_INTERRUPT_LINE(reg);
	if (sc->sc_irq[line] == 0)
		sc->sc_irq[line] = cpu_intr_findirq();
	*ihp = (line << APIC_INT_LINE_SHIFT) | sc->sc_irq[line];
	return (APIC_INT_IRQ(*ihp) == 0);
}

const char *
apic_intr_string(void *v, pci_intr_handle_t ih)
{
	static char buf[32];

	snprintf(buf, 32, "line %ld irq %ld",
	    APIC_INT_LINE(ih), APIC_INT_IRQ(ih));

	return (buf);
}

void *
apic_intr_establish(void *v, pci_intr_handle_t ih,
    int pri, int (*handler)(void *), void *arg, const char *name)
{
	struct elroy_softc *sc = v;
	volatile struct elroy_regs *r = sc->sc_regs;
	hppa_hpa_t hpa = cpu_gethpa(0);
	struct evcount *cnt;
	struct apic_iv *aiv, *biv;
	void *iv;
	int irq = APIC_INT_IRQ(ih);
	int line = APIC_INT_LINE(ih);
	u_int32_t ent0;

	/* no mapping or bogus */
	if (irq <= 0 || irq > 31)
		return (NULL);

	aiv = malloc(sizeof(struct apic_iv), M_DEVBUF, M_NOWAIT);
	if (aiv == NULL) {
		free(cnt, M_DEVBUF, 0);
		return NULL;
	}

	cnt = malloc(sizeof(struct evcount), M_DEVBUF, M_NOWAIT);
	if (!cnt) {
		free(aiv, M_DEVBUF, 0);
		return (NULL);
	}

	aiv->sc = sc;
	aiv->ih = ih;
	aiv->handler = handler;
	aiv->arg = arg;
	aiv->next = NULL;
	aiv->cnt = cnt;

	evcount_attach(cnt, name, NULL);

	if (apic_intr_list[irq]) {
		biv = apic_intr_list[irq];
		while (biv->next)
			biv = biv->next;
		biv->next = aiv;
		return (arg);
	}

	if ((iv = cpu_intr_establish(pri, irq, apic_intr, aiv, NULL))) {
		ent0 = (31 - irq) & APIC_ENT0_VEC;
		ent0 |= apic_get_int_ent0(sc, line);
#if 0
		if (cold) {
			sc->sc_imr |= (1 << irq);
			ent0 |= APIC_ENT0_MASK;
		}
#endif
		apic_write(sc->sc_regs, APIC_ENT0(line), APIC_ENT0_MASK);
		apic_write(sc->sc_regs, APIC_ENT1(line),
		    ((hpa & 0x0ff00000) >> 4) | ((hpa & 0x000ff000) << 12));
		apic_write(sc->sc_regs, APIC_ENT0(line), ent0);

		/* Signal EOI. */
		elroy_write32(&r->apic_eoi,
		    htole32((31 - irq) & APIC_ENT0_VEC));

		apic_intr_list[irq] = aiv;
	}

	return (arg);
}

void
apic_intr_disestablish(void *v, void *cookie)
{
}

int
apic_intr(void *v)
{
	struct apic_iv *iv = v;
	struct elroy_softc *sc = iv->sc;
	volatile struct elroy_regs *r = sc->sc_regs;
	pci_intr_handle_t ih = iv->ih;
	int claimed = 0;

	while (iv) {
		claimed = iv->handler(iv->arg);
		if (claimed != 0 && iv->cnt)
			iv->cnt->ec_count++;
		if (claimed == 1)
			break;
		iv = iv->next;
	}

	/* Signal EOI. */
	elroy_write32(&r->apic_eoi,
	    htole32((31 - APIC_INT_IRQ(ih)) & APIC_ENT0_VEC));

	return (claimed);
}

/* Maximum number of supported interrupt routing entries. */
#define MAX_INT_TBL_SZ	16

void
apic_get_int_tbl(struct elroy_softc *sc)
{
	struct pdc_pat_io_num int_tbl_sz PDC_ALIGNMENT;
	struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT;
	size_t size;

	/*
	 * XXX int_tbl should not be allocated on the stack, but we need a
	 * 1:1 mapping, and malloc doesn't provide that.
	 */

	if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SZ,
	    &int_tbl_sz, 0, 0, 0, 0, 0))
		return;

	if (int_tbl_sz.num > MAX_INT_TBL_SZ)
		panic("interrupt routing table too big (%d entries)",
		    int_tbl_sz.num);

	size = int_tbl_sz.num * sizeof(struct pdc_pat_pci_rt);
	sc->sc_int_tbl_sz = int_tbl_sz.num;
	sc->sc_int_tbl = malloc(size, M_DEVBUF, M_NOWAIT);
	if (sc->sc_int_tbl == NULL)
		return;

	if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL,
	    &int_tbl_sz, 0, &int_tbl, 0, 0, 0))
		return;

	memcpy(sc->sc_int_tbl, int_tbl, size);
}

u_int32_t
apic_get_int_ent0(struct elroy_softc *sc, int line)
{
	volatile struct elroy_regs *r = sc->sc_regs;
	int trigger = MPS_INT(MPS_INTPO_DEF, MPS_INTTR_DEF);
	u_int32_t ent0 = APIC_ENT0_LOW | APIC_ENT0_LEV;
	int bus, mpspo, mpstr;
	int i;

	bus = letoh32(elroy_read32(&r->busnum)) & 0xff;
	for (i = 0; i < sc->sc_int_tbl_sz; i++) {
		if (bus == sc->sc_int_tbl[i].bus &&
		    line == sc->sc_int_tbl[i].line)
			trigger = sc->sc_int_tbl[i].trigger;
	}

	mpspo = (trigger >> MPS_INTPO_SHIFT) & MPS_INTPO_MASK;
	mpstr = (trigger >> MPS_INTTR_SHIFT) & MPS_INTTR_MASK;

	switch (mpspo) {
	case MPS_INTPO_DEF:
		break;
	case MPS_INTPO_ACTHI:
		ent0 &= ~APIC_ENT0_LOW;
		break;
	case MPS_INTPO_ACTLO:
		ent0 |= APIC_ENT0_LOW;
		break;
	default:
		panic("unknown MPS interrupt polarity %d", mpspo);
	}

	switch(mpstr) {
	case MPS_INTTR_DEF:
		break;
	case MPS_INTTR_LEVEL:
		ent0 |= APIC_ENT0_LEV;
		break;
	case MPS_INTTR_EDGE:
		ent0 &= ~APIC_ENT0_LEV;
		break;
	default:
		panic("unknown MPS interrupt trigger %d", mpstr);
	}

	return ent0;
}

#ifdef DEBUG
void
apic_dump(struct elroy_softc *sc)
{
	int i;

	for (i = 0; i < sc->sc_nints; i++)
		printf("0x%04x 0x%04x\n", apic_read(sc->sc_regs, APIC_ENT0(i)),
		    apic_read(sc->sc_regs, APIC_ENT1(i)));

	for (i = 0; i < sc->sc_int_tbl_sz; i++) {
		printf("type=%x ", sc->sc_int_tbl[i].type);
		printf("len=%d ", sc->sc_int_tbl[i].len);
		printf("itype=%d ", sc->sc_int_tbl[i].itype);
		printf("trigger=%x ", sc->sc_int_tbl[i].trigger);
		printf("pin=%x ", sc->sc_int_tbl[i].pin);
		printf("bus=%d ", sc->sc_int_tbl[i].bus);
		printf("line=%d ", sc->sc_int_tbl[i].line);
		printf("addr=%x\n", sc->sc_int_tbl[i].addr);
	}
}
#endif


code:
/*	$OpenBSD: asp.c,v 1.14 2005/06/09 18:01:36 mickey Exp $	*/

/*
 * Copyright (c) 1998-2003 Michael Shalayeff
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES 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 MIND, 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.
 */

/*
 * References:
 *
 * 1. Cobra/Coral I/O Subsystem External Reference Specification
 *    Hewlett-Packard
 *
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/reboot.h>

#include <machine/bus.h>
#include <machine/iomod.h>
#include <machine/autoconf.h>
#include <machine/cpufunc.h>

#include <hppa/dev/cpudevs.h>
#include <hppa/dev/viper.h>

#include <hppa/gsc/gscbusvar.h>

struct asp_hwr {
	u_int8_t asp_reset;
	u_int8_t asp_resv[31];
	u_int8_t asp_version;
	u_int8_t asp_resv1[15];
	u_int8_t asp_scsidsync;
	u_int8_t asp_resv2[15];
	u_int8_t asp_error;
};

struct asp_trs {
	u_int32_t asp_irr;
	u_int32_t asp_imr;
	u_int32_t asp_ipr;
	u_int32_t asp_icr;
	u_int32_t asp_iar;
	u_int32_t asp_resv[3];
	u_int8_t  asp_cled;
	u_int8_t  asp_resv1[3];
	struct {
		u_int		:20,
			asp_spu	: 3,	/* SPU ID board jumper */
#define	ASP_SPUCOBRA	0
#define	ASP_SPUCORAL	1
#define	ASP_SPUBUSH	2
#define	ASP_SPUHARDBALL	3
#define	ASP_SPUSCORPIO	4
#define	ASP_SPUCORAL2	5
			asp_sw	: 1,	/* front switch is normal */
			asp_clk : 1,	/* SCSI clock is doubled */
			asp_lan : 2,	/* LAN iface selector */
#define	ASP_LANINVAL	0
#define	ASP_LANAUI	1
#define	ASP_LANTHIN	2
#define	ASP_LANMISS	3
			asp_lanf: 1,	/* LAN AUI fuse is ok */
			asp_spwr: 1,	/* SCSI power ok */
			asp_scsi: 3;	/* SCSI ctrl ID */
	} _asp_ios;
#define	asp_spu		_asp_ios.asp_spu
#define	asp_sw		_asp_ios.asp_sw
#define	asp_clk		_asp_ios.asp_clk
#define	asp_lan		_asp_ios.asp_lan
#define	asp_lanf	_asp_ios.asp_lanf
#define	asp_spwr	_asp_ios.asp_spwr
#define	asp_scsi	_asp_ios.asp_scsi
};

const struct asp_spus_tag {
	char	name[12];
	int	ledword;
} asp_spus[] = {
	{ "Cobra", 0 },
	{ "Coral", 0 },
	{ "Bushmaster", 0 },
	{ "Hardball", 1 },
	{ "Scorpio", 0 },
	{ "Coral II", 1 },
	{ "#6", 0 },
	{ "#7", 0 }
};

struct asp_softc {
	struct  device sc_dev;
	struct gscbus_ic sc_ic;

	volatile struct asp_hwr *sc_hw;
	volatile struct asp_trs *sc_trs;
};

#define	ASP_IOMASK	0xfe000000
/* ASP "Primary Controller" HPA */
#define	ASP_CHPA	0xF0800000

int	aspmatch(struct device *, void *, void *);
void	aspattach(struct device *, struct device *, void *);

struct cfattach asp_ca = {
	sizeof(struct asp_softc), aspmatch, aspattach
};

struct cfdriver asp_cd = {
	NULL, "asp", DV_DULL
};

int
aspmatch(parent, cfdata, aux)
	struct device *parent;
	void *cfdata;
	void *aux;
{
	struct confargs *ca = aux;
	/* struct cfdata *cf = cfdata; */

	if (ca->ca_type.iodc_type != HPPA_TYPE_BHA ||
	    ca->ca_type.iodc_sv_model != HPPA_BHA_ASP)
		return 0;

	return 1;
}

void
aspattach(parent, self, aux)
	struct device *parent;
	struct device *self;
	void *aux;
{
	register struct confargs *ca = aux;
	register struct asp_softc *sc = (struct asp_softc *)self;
	struct gsc_attach_args ga;
	bus_space_handle_t ioh;
	register u_int32_t irr;
	register int s;

	if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) {
		printf(": can't map IO space\n");
		return;
	}

	sc->sc_trs = (struct asp_trs *)ASP_CHPA;
	sc->sc_hw = (struct asp_hwr *)ca->ca_hpa;

#ifdef USELEDS
	machine_ledaddr = &sc->sc_trs->asp_cled;
	machine_ledword = asp_spus[sc->sc_trs->asp_spu].ledword;
#endif

	/* reset ASP */
	/* sc->sc_hw->asp_reset = 1; */
	/* delay(400000); */

	s = splhigh();
	viper_setintrwnd(1 << ca->ca_irq);

	sc->sc_trs->asp_imr = ~0;
	irr = sc->sc_trs->asp_irr;
	sc->sc_trs->asp_imr = 0;
	splx(s);

	printf (": %s rev %d, lan %d scsi %d\n",
	    asp_spus[sc->sc_trs->asp_spu].name, sc->sc_hw->asp_version,
	    sc->sc_trs->asp_lan, sc->sc_trs->asp_scsi);

	sc->sc_ic.gsc_type = gsc_asp;
	sc->sc_ic.gsc_dv = sc;
	sc->sc_ic.gsc_base = sc->sc_trs;

	ga.ga_ca = *ca;	/* clone from us */
	ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1];
	ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2];
	ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3];
	ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4];
	ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5];
	ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod;
	ga.ga_dp.dp_mod = 0;
	ga.ga_hpamask = ASP_IOMASK;
	ga.ga_name = "gsc";
	ga.ga_ic = &sc->sc_ic;
	config_found(self, &ga, gscprint);
}