diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2001-08-18 04:16:41 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2001-08-18 04:16:41 +0000 |
commit | 82639917752e0e1ba699d0edb3a0cad0749d1474 (patch) | |
tree | d1bced2e130a5de9b0010f52236058ddfbec54bc /sys | |
parent | 3f31c981b1a74d2ecb49a95f024d91fda9334da9 (diff) |
Enough of NetBSD/sparc64 to get compilable/working bootblk... more to come.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc64/include/ansi.h | 97 | ||||
-rw-r--r-- | sys/arch/sparc64/include/cdefs.h | 9 | ||||
-rw-r--r-- | sys/arch/sparc64/include/cpu.h | 344 | ||||
-rw-r--r-- | sys/arch/sparc64/include/endian.h | 11 | ||||
-rw-r--r-- | sys/arch/sparc64/include/fsr.h | 136 | ||||
-rw-r--r-- | sys/arch/sparc64/include/int_types.h | 94 | ||||
-rw-r--r-- | sys/arch/sparc64/include/intr.h | 64 | ||||
-rw-r--r-- | sys/arch/sparc64/include/limits.h | 117 | ||||
-rw-r--r-- | sys/arch/sparc64/include/param.h | 315 | ||||
-rw-r--r-- | sys/arch/sparc64/include/psl.h | 465 | ||||
-rw-r--r-- | sys/arch/sparc64/include/reg.h | 209 | ||||
-rw-r--r-- | sys/arch/sparc64/include/signal.h | 125 | ||||
-rw-r--r-- | sys/arch/sparc64/include/types.h | 89 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/intreg.h | 63 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/bootblk/Makefile | 68 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/bootblk/bootblk.fth | 613 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/bootblk/genassym.sh | 170 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/bootblk/genfth.cf | 162 |
18 files changed, 3151 insertions, 0 deletions
diff --git a/sys/arch/sparc64/include/ansi.h b/sys/arch/sparc64/include/ansi.h new file mode 100644 index 00000000000..0c1a48018e4 --- /dev/null +++ b/sys/arch/sparc64/include/ansi.h @@ -0,0 +1,97 @@ +/* $OpenBSD: ansi.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: ansi.h,v 1.7 2001/01/03 10:09:04 takemura Exp $ */ + +/*- + * Copyright (c) 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)ansi.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _ANSI_H_ +#define _ANSI_H_ + +#include <machine/int_types.h> + +/* + * Types which are fundamental to the implementation and may appear in + * more than one standard header are defined here. Standard headers + * then use: + * #ifdef _BSD_SIZE_T_ + * typedef _BSD_SIZE_T_ size_t; + * #undef _BSD_SIZE_T_ + * #endif + */ +#define _BSD_CLOCK_T_ int /* clock() */ +#define _BSD_PTRDIFF_T_ long /* ptr1 - ptr2 */ +#define _BSD_SIZE_T_ unsigned long /* sizeof() */ +#define _BSD_SSIZE_T_ long /* byte count or error */ +#define _BSD_TIME_T_ int /* time() */ +#define _BSD_VA_LIST_ char * /* va_list */ +#define _BSD_CLOCKID_T_ int /* clockid_t */ +#define _BSD_TIMER_T_ int /* timer_t */ +#define _BSD_SUSECONDS_T_ int /* suseconds_t */ +#define _BSD_USECONDS_T_ unsigned int /* useconds_t */ + +/* + * NOTE: rune_t is not covered by ANSI nor other standards, and should not + * be instantiated outside of lib/libc/locale. use wchar_t. + * + * Runes (wchar_t) is declared to be an ``int'' instead of the more natural + * ``unsigned long'' or ``long''. Two things are happening here. It is not + * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, + * it looks like 10646 will be a 31 bit standard. This means that if your + * ints cannot hold 32 bits, you will be in trouble. The reason an int was + * chosen over a long is that the is*() and to*() routines take ints (says + * ANSI C), but they use _RUNE_T_ instead of int. By changing it here, you + * lose a bit of ANSI conformance, but your programs will still work. + * + * Note that _WCHAR_T_ and _RUNE_T_ must be of the same type. When wchar_t + * and rune_t are typedef'd, _WCHAR_T_ will be undef'd, but _RUNE_T remains + * defined for ctype.h. + */ +#define _BSD_WCHAR_T_ int /* wchar_t */ +#define _BSD_WINT_T_ int /* wint_t */ +#define _BSD_RUNE_T_ int /* rune_t */ + +/* + * mbstate_t is an opaque object to keep conversion state, during multibyte + * stream conversions. The content must not be referenced by user programs. + */ +typedef union { + char __mbstate8[128]; + int64_t __mbstateL; /* for alignment */ +} __mbstate_t; +#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */ + +#define _BSD_OFF_T_ long long + +#endif /* _ANSI_H_ */ diff --git a/sys/arch/sparc64/include/cdefs.h b/sys/arch/sparc64/include/cdefs.h new file mode 100644 index 00000000000..d154e140584 --- /dev/null +++ b/sys/arch/sparc64/include/cdefs.h @@ -0,0 +1,9 @@ +/* $OpenBSD: cdefs.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: cdefs.h,v 1.3 1999/03/20 01:40:26 thorpej Exp $ */ + +#ifndef _MACHINE_CDEFS_H_ +#define _MACHINE_CDEFS_H_ + +/* No arch-specific cdefs. */ + +#endif /* !_MACHINE_CDEFS_H_ */ diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h new file mode 100644 index 00000000000..341af2609f1 --- /dev/null +++ b/sys/arch/sparc64/include/cpu.h @@ -0,0 +1,344 @@ +/* $OpenBSD: cpu.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)cpu.h 8.4 (Berkeley) 1/5/94 + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */ +#define CPU_MAXID 2 /* number of valid machdep ids */ + +#define CTL_MACHDEP_NAMES { \ + { 0, 0 }, \ + { "booted_kernel", CTLTYPE_STRING }, \ +} + +#ifdef _KERNEL +/* + * Exported definitions unique to SPARC cpu support. + */ + +#if !defined(_LKM) +#include "opt_multiprocessor.h" +#include "opt_lockdebug.h" +#endif + +#include <machine/psl.h> +#include <machine/reg.h> +#include <machine/intr.h> +#include <sparc64/sparc64/intreg.h> + +#include <sys/sched.h> + +/* + * CPU states. + * XXX Not really scheduler state, but no other good place to put + * it right now, and it really is per-CPU. + */ +#define CP_USER 0 +#define CP_NICE 1 +#define CP_SYS 2 +#define CP_INTR 3 +#define CP_IDLE 4 +#define CPUSTATES 5 + +/* + * Per-CPU scheduler state. + */ +struct schedstate_percpu { + struct timeval spc_runtime; /* time curproc started running */ + __volatile int spc_flags; /* flags; see below */ + u_int spc_schedticks; /* ticks for schedclock() */ + u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */ + u_char spc_curpriority; /* usrpri of curproc */ + int spc_rrticks; /* ticks until roundrobin() */ + int spc_pscnt; /* prof/stat counter */ + int spc_psdiv; /* prof/stat divisor */ +}; + +/* + * The cpu_info structure is part of a 64KB structure mapped both the kernel + * pmap and a single locked TTE a CPUINFO_VA for that particular processor. + * Each processor's cpu_info is accessible at CPUINFO_VA only for that + * processor. Other processors can access that through an additional mapping + * in the kernel pmap. + * + * The 64KB page contains: + * + * cpu_info + * interrupt stack (all remaining space) + * idle PCB + * idle stack (STACKSPACE - sizeof(PCB)) + * 32KB TSB + */ + +struct cpu_info { + /* Most important fields first */ + struct proc *ci_curproc; + struct pcb *ci_cpcb; /* also initial stack */ + struct cpu_info *ci_next; + + struct proc *ci_fpproc; + int ci_number; + int ci_upaid; + struct schedstate_percpu ci_schedstate; /* scheduler state */ + + /* DEBUG/DIAGNOSTIC stuff */ + u_long ci_spin_locks; /* # of spin locks held */ + u_long ci_simple_locks;/* # of simple locks held */ + + /* Spinning up the CPU */ + void (*ci_spinup) __P((void)); /* spinup routine */ + void *ci_initstack; + paddr_t ci_paddr; /* Phys addr of this structure. */ +}; + +extern struct cpu_info *cpus; +extern struct cpu_info cpu_info_store; + +#if 1 +#define curcpu() (&cpu_info_store) +#else +#define curcpu() ((struct cpu_info *)CPUINFO_VA) +#endif + +/* + * definitions of cpu-dependent requirements + * referenced in generic code + */ +#define cpu_swapin(p) /* nothing */ +#define cpu_swapout(p) /* nothing */ +#define cpu_wait(p) /* nothing */ +#if 1 +#define cpu_number() 0 +#else +#define cpu_number() (curcpu()->ci_number) +#endif + +/* + * Arguments to hardclock, softclock and gatherstats encapsulate the + * previous machine state in an opaque clockframe. The ipl is here + * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). + * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. + */ +extern int intstack[]; +extern int eintstack[]; +struct clockframe { + struct trapframe64 t; +}; + +#define CLKF_USERMODE(framep) (((framep)->t.tf_tstate & TSTATE_PRIV) == 0) +#define CLKF_BASEPRI(framep) (((framep)->t.tf_oldpil) == 0) +#define CLKF_PC(framep) ((framep)->t.tf_pc) +#define CLKF_INTR(framep) ((!CLKF_USERMODE(framep))&&\ + (((framep)->t.tf_kstack < (vaddr_t)EINTSTACK)&&\ + ((framep)->t.tf_kstack > (vaddr_t)INTSTACK))) + +/* + * Software interrupt request `register'. + */ +#ifdef DEPRECATED +union sir { + int sir_any; + char sir_which[4]; +} sir; + +#define SIR_NET 0 +#define SIR_CLOCK 1 +#endif + +extern struct intrhand soft01intr, soft01net, soft01clock; + +#if 0 +#define setsoftint() send_softint(-1, IPL_SOFTINT, &soft01intr) +#define setsoftnet() send_softint(-1, IPL_SOFTNET, &soft01net) +#else +void setsoftint __P((void)); +void setsoftnet __P((void)); +#endif + +int want_ast; + +/* + * Preempt the current process if in interrupt from user mode, + * or after the current trap/syscall if in system mode. + */ +int want_resched; /* resched() was called */ +#define need_resched(ci) (want_resched = 1, want_ast = 1) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the sparc, request an ast to send us + * through trap(), marking the proc as needing a profiling tick. + */ +#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1) + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define signotify(p) (want_ast = 1) + +/* + * Only one process may own the FPU state. + * + * XXX this must be per-cpu (eventually) + */ +struct proc *fpproc; /* FPU owner */ +int foundfpu; /* true => we have an FPU */ + +/* + * Interrupt handler chains. Interrupt handlers should return 0 for + * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a + * handler into the list. The handler is called with its (single) + * argument, or with a pointer to a clockframe if ih_arg is NULL. + */ +struct intrhand { + int (*ih_fun) __P((void *)); + void *ih_arg; + short ih_number; /* interrupt number */ + /* the H/W provides */ + char ih_pil; /* interrupt priority */ + struct intrhand *ih_next; /* global list */ + struct intrhand *ih_pending; /* interrupt queued */ + volatile u_int64_t *ih_map; /* Interrupt map reg */ + volatile u_int64_t *ih_clr; /* clear interrupt reg */ +}; +extern struct intrhand *intrhand[15]; +extern struct intrhand *intrlev[MAXINTNUM]; + +void intr_establish __P((int level, struct intrhand *)); + +/* cpu.c */ +paddr_t cpu_alloc __P((void)); +u_int64_t cpu_init __P((paddr_t, int)); +/* disksubr.c */ +struct dkbad; +int isbad __P((struct dkbad *bt, int, int, int)); +/* machdep.c */ +int ldcontrolb __P((caddr_t)); +void dumpconf __P((void)); +caddr_t reserve_dumppages __P((caddr_t)); +/* clock.c */ +struct timeval; +int tickintr __P((void *)); /* level 10 (tick) interrupt code */ +int clockintr __P((void *));/* level 10 (clock) interrupt code */ +int statintr __P((void *)); /* level 14 (statclock) interrupt code */ +/* locore.s */ +struct fpstate64; +void savefpstate __P((struct fpstate64 *)); +void loadfpstate __P((struct fpstate64 *)); +u_int64_t probeget __P((paddr_t, int, int)); +int probeset __P((paddr_t, int, int, u_int64_t)); +#if 0 +void write_all_windows __P((void)); +void write_user_windows __P((void)); +#else +#define write_all_windows() __asm __volatile("flushw" : : ) +#define write_user_windows() __asm __volatile("flushw" : : ) +#endif +void proc_trampoline __P((void)); +struct pcb; +void snapshot __P((struct pcb *)); +struct frame *getfp __P((void)); +int xldcontrolb __P((caddr_t, struct pcb *)); +void copywords __P((const void *, void *, size_t)); +void qcopy __P((const void *, void *, size_t)); +void qzero __P((void *, size_t)); +void switchtoctx __P((int)); +/* locore2.c */ +void remrq __P((struct proc *)); +/* trap.c */ +void kill_user_windows __P((struct proc *)); +int rwindow_save __P((struct proc *)); +/* amd7930intr.s */ +void amd7930_trap __P((void)); +/* cons.c */ +int cnrom __P((void)); +/* zs.c */ +void zsconsole __P((struct tty *, int, int, void (**)(struct tty *, int))); +#ifdef KGDB +void zs_kgdb_init __P((void)); +#endif +/* fb.c */ +void fb_unblank __P((void)); +/* kgdb_stub.c */ +#ifdef KGDB +void kgdb_attach __P((int (*)(void *), void (*)(void *, int), void *)); +void kgdb_connect __P((int)); +void kgdb_panic __P((void)); +#endif +/* emul.c */ +int fixalign __P((struct proc *, struct trapframe64 *)); +int emulinstr __P((vaddr_t, struct trapframe64 *)); + +/* + * + * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits + * of the trap vector table. The next eight bits are supplied by the + * hardware when the trap occurs, and the bottom four bits are always + * zero (so that we can shove up to 16 bytes of executable code---exactly + * four instructions---into each trap vector). + * + * The hardware allocates half the trap vectors to hardware and half to + * software. + * + * Traps have priorities assigned (lower number => higher priority). + */ + +struct trapvec { + int tv_instr[8]; /* the eight instructions */ +}; +extern struct trapvec *trapbase; /* the 256 vectors */ + +extern void wzero __P((void *, u_int)); +extern void wcopy __P((const void *, void *, u_int)); + +#endif /* _KERNEL */ +#endif /* _CPU_H_ */ diff --git a/sys/arch/sparc64/include/endian.h b/sys/arch/sparc64/include/endian.h new file mode 100644 index 00000000000..cca28ea4fd7 --- /dev/null +++ b/sys/arch/sparc64/include/endian.h @@ -0,0 +1,11 @@ +/* $OpenBSD: endian.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ + +#ifndef _SPARC64_ENDIAN_H_ +#define _SPARC64_ENDIAN_H_ + +#define BYTE_ORDER BIG_ENDIAN +#include <sys/endian.h> + +#define __STRICT_ALIGNMENT + +#endif /* _SPARC64_ENDIAN_H_ */ diff --git a/sys/arch/sparc64/include/fsr.h b/sys/arch/sparc64/include/fsr.h new file mode 100644 index 00000000000..7587f8a2aac --- /dev/null +++ b/sys/arch/sparc64/include/fsr.h @@ -0,0 +1,136 @@ +/* $OpenBSD: fsr.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: fsr.h,v 1.1.1.1 1998/06/20 04:58:51 eeh 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)fsr.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_FSR_H_ +#define _MACHINE_FSR_H_ + +/* + * Bits in FPRS + */ +#define FPRS_FEF 0x04 /* Enable FP -- must be set to enable FP regs */ +#define FPRS_DU 0x02 /* Dirty upper -- upper fp regs are dirty */ +#define FPRS_DL 0x01 /* Dirty lower -- lower fp regs are dirty */ + +/* + * Bits in FSR. + */ + +#define FSR_RD 0xc0000000 /* rounding direction */ +#define FSR_RD_RN 0 /* round to nearest */ +#define FSR_RD_RZ 1 /* round towards 0 */ +#define FSR_RD_RP 2 /* round towards +inf */ +#define FSR_RD_RM 3 /* round towards -inf */ +#define FSR_RD_SHIFT 30 +#define FSR_RD_MASK 0x03 + +#define FSR_RP 0x30000000 /* extended rounding precision */ +#define FSR_RP_X 0 /* extended stays extended */ +#define FSR_RP_S 1 /* extended => single */ +#define FSR_RP_D 2 /* extended => double */ +#define FSR_RP_80 3 /* extended => 80-bit */ +#define FSR_RP_SHIFT 28 +#define FSR_RP_MASK 0x03 + +#define FSR_TEM 0x0f800000 /* trap enable mask */ +#define FSR_TEM_SHIFT 23 +#define FSR_TEM_MASK 0x1f + +#define FSR_NS 0x00400000 /* ``nonstandard mode'' */ +#define FSR_AU 0x00400000 /* aka abrupt underflow mode */ +#define FSR_MBZ 0x00300000 /* reserved; must be zero */ + +#define FSR_VER 0x000e0000 /* version bits */ +#define FSR_VER_SHIFT 17 +#define FSR_VER_MASK 0x07 + +#define FSR_FTT 0x0001c000 /* FP trap type */ +#define FSR_TT_NONE 0 /* no trap */ +#define FSR_TT_IEEE 1 /* IEEE exception */ +#define FSR_TT_UNFIN 2 /* unfinished operation */ +#define FSR_TT_UNIMP 3 /* unimplemented operation */ +#define FSR_TT_SEQ 4 /* sequence error */ +#define FSR_TT_HWERR 5 /* hardware error (unrecoverable) */ +#define FSR_FTT_SHIFT 14 +#define FSR_FTT_MASK 0x03 + +#define FSR_QNE 0x00002000 /* queue not empty */ +#define FSR_PR 0x00001000 /* partial result */ + +#define FSR_FCC 0x00000c00 /* FP condition codes */ +#define FSR_CC_EQ 0 /* f1 = f2 */ +#define FSR_CC_LT 1 /* f1 < f2 */ +#define FSR_CC_GT 2 /* f1 > f2 */ +#define FSR_CC_UO 3 /* (f1,f2) unordered */ +#define FSR_FCC_SHIFT 10 +#define FSR_FCC_MASK 0x03 + +#define FSR_AX 0x000003e0 /* accrued exceptions */ +#define FSR_AX_SHIFT 5 +#define FSR_AX_MASK 0x1f +#define FSR_CX 0x0000001f /* current exceptions */ +#define FSR_CX_SHIFT 0 +#define FSR_CX_MASK 0x1f + +/* These are the 3 new v9 fcc's */ +#define FSR_FCC3 0x06000000000 /* FP condition codes */ +#define FSR_FCC3_SHIFT 36 + +#define FSR_FCC2 0x0c00000000 /* FP condition codes */ +#define FSR_FCC2_SHIFT 34 + +#define FSR_FCC1 0x0600000000 /* FP condition codes */ +#define FSR_FCC1_SHIFT 32 + + +/* The following exceptions apply to TEM, AX, and CX. */ +#define FSR_NV 0x10 /* invalid operand */ +#define FSR_OF 0x08 /* overflow */ +#define FSR_UF 0x04 /* underflow */ +#define FSR_DZ 0x02 /* division by zero */ +#define FSR_NX 0x01 /* inexact result */ + +#endif /* _MACHINE_FSR_H_ */ diff --git a/sys/arch/sparc64/include/int_types.h b/sys/arch/sparc64/include/int_types.h new file mode 100644 index 00000000000..7c409881010 --- /dev/null +++ b/sys/arch/sparc64/include/int_types.h @@ -0,0 +1,94 @@ +/* $OpenBSD: int_types.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: int_types.h,v 1.7 2001/04/28 15:41:33 kleink 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. 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, Berkeley and its contributors. + * 4. 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. + * + * from: @(#)types.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC64_INT_TYPES_H_ +#define _SPARC64_INT_TYPES_H_ + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef __signed char int8_t; +typedef unsigned char uint8_t; +typedef unsigned char u_int8_t; +typedef short int int16_t; +typedef unsigned short int uint16_t; +typedef unsigned short int u_int16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef unsigned int u_int32_t; + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int64_t; +typedef __COMPILER_UINT64__ uint64_t; +typedef __COMPILER_UINT64__ u_int64_t; +#else +#ifdef __arch64__ +/* 64-bit compiler */ +typedef long int int64_t; +typedef unsigned long int uint64_t; +typedef unsigned long int u_int64_t; +#else +/* 32-bit compiler */ +/* LONGLONG */ +typedef long long int int64_t; +/* LONGLONG */ +typedef unsigned long long int uint64_t; +typedef unsigned long long int u_int64_t; +#endif +#endif /* !__COMPILER_INT64__ */ + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef long int __intptr_t; +typedef unsigned long int __uintptr_t; + +#endif /* !_SPARC64_INT_TYPES_H_ */ diff --git a/sys/arch/sparc64/include/intr.h b/sys/arch/sparc64/include/intr.h new file mode 100644 index 00000000000..bfc6617b869 --- /dev/null +++ b/sys/arch/sparc64/include/intr.h @@ -0,0 +1,64 @@ +/* $OpenBSD: intr.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: intr.h,v 1.8 2001/01/14 23:50:30 thorpej Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* XXX - arbitrary numbers; no interpretation is defined yet */ +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFTINT 1 /* softint */ +#define IPL_SOFTCLOCK 1 /* timeouts */ +#define IPL_SOFTNET 1 /* protocol stack */ +#define IPL_BIO PIL_BIO /* block I/O */ +#define IPL_NET PIL_NET /* network */ +#define IPL_SOFTSERIAL 4 /* serial */ +#define IPL_TTY PIL_TTY /* terminal */ +#define IPL_IMP PIL_IMP /* memory allocation */ +#define IPL_AUDIO PIL_AUD /* audio */ +#define IPL_CLOCK PIL_CLOCK /* clock */ +#define IPL_SERIAL PIL_SER /* serial */ +#define IPL_SCHED PIL_SCHED /* scheduler */ +#define IPL_LOCK PIL_LOCK /* locks */ +#define IPL_HIGH PIL_HIGH /* everything */ + +void * +softintr_establish __P((int level, void (*fun)(void *), void *arg)); + +void +softintr_disestablish __P((void *cookie)); + +void +softintr_schedule __P((void *cookie)); diff --git a/sys/arch/sparc64/include/limits.h b/sys/arch/sparc64/include/limits.h new file mode 100644 index 00000000000..e71f20a4378 --- /dev/null +++ b/sys/arch/sparc64/include/limits.h @@ -0,0 +1,117 @@ +/* $OpenBSD: limits.h,v 1.1 2001/08/18 04:16:37 jason Exp $ */ +/* $NetBSD: limits.h,v 1.8 2000/08/08 22:31:14 tshiozak Exp $ */ + +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. 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, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)limits.h 8.3 (Berkeley) 1/4/94 + */ + +#ifndef _MACHINE_LIMITS_H_ +#define _MACHINE_LIMITS_H_ + +#define CHAR_BIT 8 /* number of bits in a char */ +#define MB_LEN_MAX 32 /* no multibyte characters */ + +#define SCHAR_MIN (-0x7f-1) /* max value for a signed char */ +#define SCHAR_MAX 0x7f /* min value for a signed char */ + +#define UCHAR_MAX 0xffU /* max value for an unsigned char */ +#define CHAR_MAX 0x7f /* max value for a char */ +#define CHAR_MIN (-0x7f-1) /* min value for a char */ + +#define USHRT_MAX 0xffffU /* max value for an unsigned short */ +#define SHRT_MAX 0x7fff /* max value for a short */ +#define SHRT_MIN (-0x7fff-1) /* min value for a short */ + +#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ +#define INT_MAX 0x7fffffff /* max value for an int */ +#define INT_MIN (-0x7fffffff-1) /* min value for an int */ + +/* Make sure _LP64 is defined if we have a 64-bit compiler */ +#if __arch64__||__sparcv9__ +#ifndef _LP64 +#define _LP64 +#endif +#endif + +#ifdef __arch64__ +#define ULONG_MAX 0xffffffffffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min value for a long */ +#else +#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffL-1) /* min value for a long */ +#endif + +#if !defined(_ANSI_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) || \ + defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +/* GCC requires that quad constants be written as expressions. */ +#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ + /* max value for a quad_t */ +#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) +#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ + +#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ +#endif /* !_ANSI_SOURCE */ + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \ + defined(_XOPEN_SOURCE) +#ifdef __arch64__ +#define LONG_BIT 64 +#else +#define LONG_BIT 32 +#endif +#define WORD_BIT 32 + +#define DBL_DIG 15 +#define DBL_MAX 1.7976931348623157E+308 +#define DBL_MIN 2.2250738585072014E-308 + +#define FLT_DIG 6 +#define FLT_MAX 3.40282347E+38F +#define FLT_MIN 1.17549435E-38F +#endif + +#endif /* _MACHINE_LIMITS_H_ */ diff --git a/sys/arch/sparc64/include/param.h b/sys/arch/sparc64/include/param.h new file mode 100644 index 00000000000..64b7253c3d2 --- /dev/null +++ b/sys/arch/sparc64/include/param.h @@ -0,0 +1,315 @@ +/* $OpenBSD: param.h,v 1.1 2001/08/18 04:16:37 jason Exp $ */ +/* $NetBSD: param.h,v 1.25 2001/05/30 12:28:51 mrg 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)param.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Copyright (c) 1996-1999 Eduardo Horvath + * + * 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. + * + * 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 _MACHINE sparc64 +#define MACHINE "sparc64" +#ifdef __arch64__ +#define _MACHINE_ARCH sparc64 +#define MACHINE_ARCH "sparc64" +#define MID_MACHINE MID_SPARC64 +#else +#define _MACHINE_ARCH sparc +#define MACHINE_ARCH "sparc" +#define MID_MACHINE MID_SPARC +#endif + +#ifdef _KERNEL /* XXX */ +#ifndef _LOCORE /* XXX */ +#include <machine/cpu.h> /* XXX */ +#endif /* XXX */ +#endif /* XXX */ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for + * the machine's strictest data type. The result is u_int and must be + * cast to any desired pointer type. + * + * ALIGNED_POINTER is a boolean macro that checks whether an address + * is valid to fetch data elements of type t from on this architecture. + * This does not reflect the optimal alignment, just the possibility + * (within reasonable limits). + * + */ +#define ALIGNBYTES32 0x7 +#define ALIGNBYTES64 0xf +#ifdef __arch64__ +#define ALIGNBYTES ALIGNBYTES64 +#else +#define ALIGNBYTES ALIGNBYTES32 +#endif +#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES) +#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) +#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) + + +/* + * The following variables are always defined and initialized (in locore) + * so independently compiled modules (e.g. LKMs) can be used irrespective + * of the `options SUN4?' combination a particular kernel was configured with. + * See also the definitions of NBPG, PGOFSET and PGSHIFT below. + */ +#if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE) +extern int nbpg, pgofset, pgshift; +#endif + +#define DEV_BSIZE 512 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define BLKDEV_IOSIZE 2048 +#define MAXPHYS (64 * 1024) + +#ifdef __arch64__ +/* We get stack overflows w/8K stacks in 64-bit mode */ +#define SSIZE 2 /* initial stack size in pages */ +#else +#define SSIZE 2 +#endif +#define USPACE (SSIZE*8192) + + +/* + * Here are all the magic kernel virtual addresses and how they're allocated. + * + * First, the PROM is usually a fixed-sized block from 0x00000000f0000000 to + * 0x00000000f0100000. It also uses some space around 0x00000000fff00000 to + * map in device registers. The rest is pretty much ours to play with. + * + * The kernel starts at KERNBASE. Here's they layout. We use macros to set + * the addresses so we can relocate everything easily. We use 4MB locked TTEs + * to map in the kernel text and data segments. Any extra pages are recycled, + * so they can potentially be double-mapped. This shouldn't really be a + * problem since they're unused, but wild pointers can cause silent data + * corruption if they are in those segments. + * + * 0x0000000000000000: 64K NFO page zero + * 0x0000000000010000: Userland or PROM + * KERNBASE: 4MB kernel text and read only data + * This is mapped in the ITLB and + * Read-Only in the DTLB + * KERNBASE+0x400000: 4MB kernel data and BSS -- not in ITLB + * Contains context table, kernel pmap, + * and other important structures. + * KERNBASE+0x800000: Unmapped page -- redzone + * KERNBASE+0x802000: Process 0 stack and u-area + * KERNBASE+0x806000: 2 pages for pmap_copy_page and /dev/mem + * KERNBASE+0x80a000: Start of kernel VA segment + * KERNEND: End of kernel VA segment + * KERNEND+0x02000: Auxreg_va (unused?) + * KERNEND+0x04000: TMPMAP_VA (unused?) + * KERNEND+0x06000: message buffer. + * KERNEND+0x010000: 64K locked TTE -- different for each CPU + * Contains interrupt stack, cpu_info structure, + * and 32KB kernel TSB. + * KERNEND+0x020000: IODEV_BASE -- begin mapping IO devices here. + * 0x00000000fe000000: IODEV_END -- end of device mapping space. + * + */ +#define KERNBASE 0x001000000 /* start of kernel virtual space */ +#define KERNEND 0x0e0000000 /* end of kernel virtual space */ +#define VM_MAX_KERNEL_BUF ((KERNEND-KERNBASE)/4) + +#define _MAXNBPG 8192 /* fixed VAs, independent of actual NBPG */ + +#define AUXREG_VA ( KERNEND + _MAXNBPG) /* 1 page REDZONE */ +#define TMPMAP_VA ( AUXREG_VA + _MAXNBPG) +#define MSGBUF_VA ( TMPMAP_VA + _MAXNBPG) +/* + * Here's the location of the interrupt stack and CPU structure. + */ +#define INTSTACK ( KERNEND + 8*_MAXNBPG)/* 64K after kernel end */ +#define EINTSTACK ( INTSTACK + 2*USPACE) /* 32KB */ +#define CPUINFO_VA ( EINTSTACK) +#define IODEV_BASE ( CPUINFO_VA + 8*_MAXNBPG)/* 64K long */ +#define IODEV_END 0x0f0000000UL /* 16 MB of iospace */ + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZE 256 /* size of an mbuf */ +#define MCLBYTES 2048 /* enough for whole Ethernet packet */ +#define MCLSHIFT 11 /* log2(MCLBYTES) */ +#define MCLOFSET (MCLBYTES - 1) + +#if defined(_KERNEL_OPT) +#include "opt_gateway.h" +#endif + +#ifndef NMBCLUSTERS +#ifdef GATEWAY +#define NMBCLUSTERS 512 /* map size, max cluster allocation */ +#else +#define NMBCLUSTERS 256 /* map size, max cluster allocation */ +#endif +#endif + +#define MSGBUFSIZE NBPG + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) + +/* pages ("clicks") to disk blocks */ +#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) +#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) + +/* pages to bytes */ +#define ctob(x) ((x) << PGSHIFT) +#define btoc(x) (((vsize_t)(x) + PGOFSET) >> PGSHIFT) + +/* bytes to disk blocks */ +#define btodb(x) ((x) >> DEV_BSHIFT) +#define dbtob(x) ((x) << DEV_BSHIFT) + +/* + * Map a ``block device block'' to a file system block. + * This should be device dependent, and should use the bsize + * field from the disk label. + * For now though just use DEV_BSIZE. + */ +#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE)) + +/* + * dvmamap manages a range of DVMA addresses intended to create double + * mappings of physical memory. In a way, `dvmamap' is a submap of the + * VM map `phys_map'. The difference is the use of the `resource map' + * routines to manage page allocation, allowing DVMA addresses to be + * allocated and freed from within interrupt routines. + * + * Note that `phys_map' can still be used to allocate memory-backed pages + * in DVMA space. + */ +#ifdef _KERNEL +#ifndef _LOCORE +#if 0 +extern vaddr_t dvma_base; +extern vaddr_t dvma_end; +extern struct map *dvmamap; +/* + * The dvma resource map is defined in page units, which are numbered 1 to N. + * Use these macros to convert to/from virtual addresses. + */ +#define rctov(n) (ctob(((n)-1))+dvma_base) +#define vtorc(v) ((btoc((v)-dvma_base))+1) + +extern caddr_t kdvma_mapin __P((caddr_t, int, int)); +extern caddr_t dvma_malloc __P((size_t, void *, int)); +extern void dvma_free __P((caddr_t, size_t, void *)); +#endif + +extern void delay __P((unsigned int)); +#define DELAY(n) delay(n) + +extern int cputyp; +extern int cpumod; +extern int mmumod; + +#endif /* _LOCORE */ +#endif /* _KERNEL */ + +/* + * Values for the cputyp variable. + */ +#define CPU_SUN4 0 +#define CPU_SUN4C 1 +#define CPU_SUN4M 2 +#define CPU_SUN4U 3 + +/* + * Shorthand CPU-type macros. Enumerate all eight cases. + * Let compiler optimize away code conditional on constants. + * + * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m + * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below, + * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized + * early in locore.s after the machine type has been detected. + * + * Note that whenever the macros defined below evaluate to expressions + * involving variables, the kernel will perform slighly worse due to the + * extra memory references they'll generate. + */ + +#define CPU_ISSUN4U (1) +#define CPU_ISSUN4MOR4U (1) +#define CPU_ISSUN4M (0) +#define CPU_ISSUN4C (0) +#define CPU_ISSUN4 (0) +#define CPU_ISSUN4OR4C (0) +#define CPU_ISSUN4COR4M (0) +#define NBPG 8192 /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define PGSHIFT 13 /* log2(NBPG) */ diff --git a/sys/arch/sparc64/include/psl.h b/sys/arch/sparc64/include/psl.h new file mode 100644 index 00000000000..ea20f99f20c --- /dev/null +++ b/sys/arch/sparc64/include/psl.h @@ -0,0 +1,465 @@ +/* $OpenBSD: psl.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: psl.h,v 1.20 2001/04/13 23:30:05 thorpej 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. 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, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)psl.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef PSR_IMPL + +/* + * SPARC Process Status Register (in psl.h for hysterical raisins). This + * doesn't exist on the V9. + * + * The picture in the Sun manuals looks like this: + * 1 1 + * 31 28 27 24 23 20 19 14 3 2 11 8 7 6 5 4 0 + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + * | impl | ver | icc | reserved |E|E| pil |S|P|E| CWP | + * | | |n z v c| |C|F| | |S|T| | + * +-------+-------+-------+-----------+-+-+-------+-+-+-+---------+ + */ + +#define PSR_IMPL 0xf0000000 /* implementation */ +#define PSR_VER 0x0f000000 /* version */ +#define PSR_ICC 0x00f00000 /* integer condition codes */ +#define PSR_N 0x00800000 /* negative */ +#define PSR_Z 0x00400000 /* zero */ +#define PSR_O 0x00200000 /* overflow */ +#define PSR_C 0x00100000 /* carry */ +#define PSR_EC 0x00002000 /* coprocessor enable */ +#define PSR_EF 0x00001000 /* FP enable */ +#define PSR_PIL 0x00000f00 /* interrupt level */ +#define PSR_S 0x00000080 /* supervisor (kernel) mode */ +#define PSR_PS 0x00000040 /* previous supervisor mode (traps) */ +#define PSR_ET 0x00000020 /* trap enable */ +#define PSR_CWP 0x0000001f /* current window pointer */ + +#define PSR_BITS "\20\16EC\15EF\10S\7PS\6ET" + +/* Interesting spl()s */ +#define PIL_SCSI 3 +#define PIL_FDSOFT 4 +#define PIL_AUSOFT 4 +#define PIL_BIO 5 +#define PIL_VIDEO 5 +#define PIL_TTY 6 +#define PIL_LPT 6 +#define PIL_NET 6 +#define PIL_IMP 7 +#define PIL_CLOCK 10 +#define PIL_FD 11 +#define PIL_SER 12 +#define PIL_AUD 13 +#define PIL_HIGH 15 +#define PIL_SCHED PIL_CLOCK +#define PIL_LOCK PIL_HIGH + +/* + * SPARC V9 CCR register + */ + +#define ICC_C 0x01L +#define ICC_V 0x02L +#define ICC_Z 0x04L +#define ICC_N 0x08L +#define XCC_SHIFT 4 +#define XCC_C (ICC_C<<XCC_SHIFT) +#define XCC_V (ICC_V<<XCC_SHIFT) +#define XCC_Z (ICC_Z<<XCC_SHIFT) +#define XCC_N (ICC_N<<XCC_SHIFT) + + +/* + * SPARC V9 PSTATE register (what replaces the PSR in V9) + * + * Here's the layout: + * + * 11 10 9 8 7 6 5 4 3 2 1 0 + * +------------------------------------------------------------+ + * | IG | MG | CLE | TLE | MM | RED | PEF | AM | PRIV | IE | AG | + * +------------------------------------------------------------+ + */ + +#define PSTATE_IG 0x800 /* enable spitfire interrupt globals */ +#define PSTATE_MG 0x400 /* enable spitfire MMU globals */ +#define PSTATE_CLE 0x200 /* current little endian */ +#define PSTATE_TLE 0x100 /* traps little endian */ +#define PSTATE_MM 0x0c0 /* memory model */ +#define PSTATE_MM_TSO 0x000 /* total store order */ +#define PSTATE_MM_PSO 0x040 /* partial store order */ +#define PSTATE_MM_RMO 0x080 /* Relaxed memory order */ +#define PSTATE_RED 0x020 /* RED state */ +#define PSTATE_PEF 0x010 /* enable floating point */ +#define PSTATE_AM 0x008 /* 32-bit address masking */ +#define PSTATE_PRIV 0x004 /* privileged mode */ +#define PSTATE_IE 0x002 /* interrupt enable */ +#define PSTATE_AG 0x001 /* enable alternate globals */ + +#define PSTATE_BITS "\20\14IG\13MG\12CLE\11TLE\10\7MM\6RED\5PEF\4AM\3PRIV\2IE\1AG" + + +/* + * 32-bit code requires TSO or at best PSO since that's what's supported on + * SPARC V8 and earlier machines. + * + * 64-bit code sets the memory model in the ELF header. + * + * We're running kernel code in TSO for the moment so we don't need to worry + * about possible memory barrier bugs. + */ + +#ifdef __arch64__ +#define PSTATE_PROM (PSTATE_MM_TSO|PSTATE_PRIV) +#define PSTATE_NUCLEUS (PSTATE_MM_TSO|PSTATE_PRIV|PSTATE_AG) +#define PSTATE_KERN (PSTATE_MM_TSO|PSTATE_PRIV) +#define PSTATE_INTR (PSTATE_KERN|PSTATE_IE) +#define PSTATE_USER32 (PSTATE_MM_TSO|PSTATE_AM|PSTATE_IE) +#define PSTATE_USER (PSTATE_MM_RMO|PSTATE_IE) +#else +#define PSTATE_PROM (PSTATE_MM_TSO|PSTATE_PRIV) +#define PSTATE_NUCLEUS (PSTATE_MM_TSO|PSTATE_AM|PSTATE_PRIV|PSTATE_AG) +#define PSTATE_KERN (PSTATE_MM_TSO|PSTATE_AM|PSTATE_PRIV) +#define PSTATE_INTR (PSTATE_KERN|PSTATE_IE) +#define PSTATE_USER32 (PSTATE_MM_TSO|PSTATE_AM|PSTATE_IE) +#define PSTATE_USER (PSTATE_MM_TSO|PSTATE_AM|PSTATE_IE) +#endif + + +/* + * SPARC V9 TSTATE register + * + * 39 32 31 24 23 18 17 8 7 5 4 0 + * +-----+-----+-----+--------+---+-----+ + * | CCR | ASI | - | PSTATE | - | CWP | + * +-----+-----+-----+--------+---+-----+ + */ + +#define TSTATE_CWP 0x01f +#define TSTATE_PSTATE 0x6ff00 +#define TSTATE_PSTATE_SHIFT 8 +#define TSTATE_ASI 0xff000000LL +#define TSTATE_ASI_SHIFT 24 +#define TSTATE_CCR 0xff00000000LL +#define TSTATE_CCR_SHIFT 32 + +#define PSRCC_TO_TSTATE(x) (((int64_t)(x)&PSR_ICC)<<(TSTATE_CCR_SHIFT-19)) +#define TSTATECCR_TO_PSR(x) (((x)&TSTATE_CCR)>>(TSTATE_CCR_SHIFT-19)) + +/* + * These are here to simplify life. + */ +#define TSTATE_IG (PSTATE_IG<<TSTATE_PSTATE_SHIFT) +#define TSTATE_MG (PSTATE_MG<<TSTATE_PSTATE_SHIFT) +#define TSTATE_CLE (PSTATE_CLE<<TSTATE_PSTATE_SHIFT) +#define TSTATE_TLE (PSTATE_TLE<<TSTATE_PSTATE_SHIFT) +#define TSTATE_MM (PSTATE_MM<<TSTATE_PSTATE_SHIFT) +#define TSTATE_MM_TSO (PSTATE_MM_TSO<<TSTATE_PSTATE_SHIFT) +#define TSTATE_MM_PSO (PSTATE_MM_PSO<<TSTATE_PSTATE_SHIFT) +#define TSTATE_MM_RMO (PSTATE_MM_RMO<<TSTATE_PSTATE_SHIFT) +#define TSTATE_RED (PSTATE_RED<<TSTATE_PSTATE_SHIFT) +#define TSTATE_PEF (PSTATE_PEF<<TSTATE_PSTATE_SHIFT) +#define TSTATE_AM (PSTATE_AM<<TSTATE_PSTATE_SHIFT) +#define TSTATE_PRIV (PSTATE_PRIV<<TSTATE_PSTATE_SHIFT) +#define TSTATE_IE (PSTATE_IE<<TSTATE_PSTATE_SHIFT) +#define TSTATE_AG (PSTATE_AG<<TSTATE_PSTATE_SHIFT) + +#define TSTATE_BITS "\20\14IG\13MG\12CLE\11TLE\10\7MM\6RED\5PEF\4AM\3PRIV\2IE\1AG" + +#define TSTATE_KERN ((TSTATE_KERN)<<TSTATE_PSTATE_SHIFT) +#define TSTATE_USER ((TSTATE_USER)<<TSTATE_PSTATE_SHIFT) +/* + * SPARC V9 VER version register. + * + * 63 48 47 32 31 24 23 16 15 8 7 5 4 0 + * +-------+------+------+-----+-------+---+--------+ + * | manuf | impl | mask | - | maxtl | - | maxwin | + * +-------+------+------+-----+-------+---+--------+ + * + */ + +#define VER_MANUF 0xffff000000000000LL +#define VER_MANUF_SHIFT 48 +#define VER_IMPL 0x0000ffff00000000LL +#define VER_IMPL_SHIFT 32 +#define VER_MASK 0x00000000ff000000LL +#define VER_MASK_SHIFT 24 +#define VER_MAXTL 0x000000000000ff00LL +#define VER_MAXTL_SHIFT 8 +#define VER_MAXWIN 0x000000000000001fLL + +/* + * Here are a few things to help us transition between user and kernel mode: + */ + +/* Memory models */ +#define KERN_MM PSTATE_MM_TSO +#define USER_MM PSTATE_MM_RMO + +/* + * Register window handlers. These point to generic routines that check the + * stack pointer and then vector to the real handler. We could optimize this + * if we could guarantee only 32-bit or 64-bit stacks. + */ +#define WSTATE_KERN 026 +#define WSTATE_USER 022 + +#define CWP 0x01f + +/* 64-byte alignment -- this seems the best place to put this. */ +#define BLOCK_SIZE 64 +#define BLOCK_ALIGN 0x3f + +#if defined(_KERNEL) && !defined(_LOCORE) + +extern u_int64_t ver; /* Copy of v9 version register. We need to read this only once, in locore.s. */ +static __inline int getpstate __P((void)); +static __inline void setpstate __P((int)); +static __inline int getcwp __P((void)); +static __inline void setcwp __P((int)); +#ifndef SPLDEBUG +static __inline void splx __P((int)); +#endif +static __inline u_int64_t getver __P((void)); + +/* + * GCC pseudo-functions for manipulating privileged registers + */ +static __inline int getpstate() +{ + int pstate; + + __asm __volatile("rdpr %%pstate,%0" : "=r" (pstate)); + return (pstate); +} + +static __inline void setpstate(newpstate) + int newpstate; +{ + __asm __volatile("wrpr %0,0,%%pstate" : : "r" (newpstate)); +} + +static __inline int getcwp() +{ + int cwp; + + __asm __volatile("rdpr %%cwp,%0" : "=r" (cwp)); + return (cwp); +} + +static __inline void setcwp(newcwp) + int newcwp; +{ + __asm __volatile("wrpr %0,0,%%cwp" : : "r" (newcwp)); +} + +static __inline u_int64_t getver() +{ + u_int64_t ver; + + __asm __volatile("rdpr %%ver,%0" : "=r" (ver)); + return (ver); +} + +/* + * GCC pseudo-functions for manipulating PIL + */ + +#ifdef SPLDEBUG +void prom_printf __P((const char *fmt, ...)); +extern int printspl; +#define SPLPRINT(x) if(printspl) { int i=10000000; prom_printf x ; while(i--); } +#define SPL(name, newpil) \ +static __inline int name##X __P((const char*, int)); \ +static __inline int name##X(const char* file, int line) \ +{ \ + int oldpil; \ + __asm __volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + SPLPRINT(("{%s:%d %d=>%d}", file, line, oldpil, newpil)); \ + __asm __volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil)); \ + return (oldpil); \ +} +/* A non-priority-decreasing version of SPL */ +#define SPLHOLD(name, newpil) \ +static __inline int name##X __P((const char*, int)); \ +static __inline int name##X(const char* file, int line) \ +{ \ + int oldpil; \ + __asm __volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + if (newpil <= oldpil) \ + return oldpil; \ + SPLPRINT(("{%s:%d %d->!d}", file, line, oldpil, newpil)); \ + __asm __volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil)); \ + return (oldpil); \ +} + +#else +#define SPLPRINT(x) +#define SPL(name, newpil) \ +static __inline int name __P((void)); \ +static __inline int name() \ +{ \ + int oldpil; \ + __asm __volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + __asm __volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil)); \ + return (oldpil); \ +} +/* A non-priority-decreasing version of SPL */ +#define SPLHOLD(name, newpil) \ +static __inline int name __P((void)); \ +static __inline int name() \ +{ \ + int oldpil; \ + __asm __volatile("rdpr %%pil,%0" : "=r" (oldpil)); \ + if (newpil <= oldpil) \ + return oldpil; \ + __asm __volatile("wrpr %%g0,%0,%%pil" : : "n" (newpil)); \ + return (oldpil); \ +} +#endif + +SPL(spl0, 0) + +SPL(spllowersoftclock, 1) + +SPLHOLD(splsoftint, 1) +#define splsoftclock splsoftint +#define splsoftnet splsoftint + +/* audio software interrupts are at software level 4 */ +SPLHOLD(splausoft, PIL_AUSOFT) + +/* floppy software interrupts are at software level 4 too */ +SPLHOLD(splfdsoft, PIL_FDSOFT) + +/* Block devices */ +SPLHOLD(splbio, PIL_BIO) + +/* network hardware interrupts are at level 6 */ +SPLHOLD(splnet, PIL_NET) + +/* tty input runs at software level 6 */ +SPLHOLD(spltty, PIL_TTY) + +/* parallel port runs at software level 6 */ +SPLHOLD(spllpt, PIL_LPT) + +/* + * Memory allocation (must be as high as highest network, tty, or disk device) + */ +SPLHOLD(splvm, PIL_IMP) + +SPLHOLD(splclock, PIL_CLOCK) + +/* fd hardware interrupts are at level 11 */ +SPLHOLD(splfd, PIL_FD) + +/* zs hardware interrupts are at level 12 */ +SPLHOLD(splzs, PIL_SER) +SPLHOLD(splserial, PIL_SER) + +/* audio hardware interrupts are at level 13 */ +SPLHOLD(splaudio, PIL_AUD) + +/* second sparc timer interrupts at level 14 */ +SPLHOLD(splstatclock, 14) + +SPLHOLD(splsched, PIL_SCHED) +SPLHOLD(spllock, PIL_LOCK) + +SPLHOLD(splhigh, PIL_HIGH) + +/* splx does not have a return value */ +#ifdef SPLDEBUG +/* Keep gcc happy -- reduce warnings */ +#if 0 +static __inline void splx(newpil) + int newpil; +{ + int pil; + + __asm __volatile("rdpr %%pil,%0" : "=r" (pil)); + SPLPRINT(("{%d->%d}", pil, newpil)); \ + __asm __volatile("wrpr %%g0,%0,%%pil" : : "rn" (newpil)); +} +#endif + +#define spl0() spl0X(__FILE__, __LINE__) +#define spllowersoftclock() spllowersoftclockX(__FILE__, __LINE__) +#define splsoftint() splsoftintX(__FILE__, __LINE__) +#define splausoft() splausoftX(__FILE__, __LINE__) +#define splfdsoft() splfdsoftX(__FILE__, __LINE__) +#define splbio() splbioX(__FILE__, __LINE__) +#define splnet() splnetX(__FILE__, __LINE__) +#define spltty() splttyX(__FILE__, __LINE__) +#define spllpt() spllptX(__FILE__, __LINE__) +#define splvm() splvmX(__FILE__, __LINE__) +#define splclock() splclockX(__FILE__, __LINE__) +#define splfd() splfdX(__FILE__, __LINE__) +#define splzs() splzsX(__FILE__, __LINE__) +#define splserial() splzerialX(__FILE__, __LINE__) +#define splaudio() splaudioX(__FILE__, __LINE__) +#define splstatclock() splstatclockX(__FILE__, __LINE__) +#define splsched() splschedX(__FILE__, __LINE__) +#define spllock() spllockX(__FILE__, __LINE__) +#define splhigh() splhighX(__FILE__, __LINE__) +#define splx(x) splxX((x),__FILE__, __LINE__) + +static __inline void splxX __P((int, const char*, int)); +static __inline void splxX(newpil, file, line) + int newpil, line; + const char* file; +#else +static __inline void splx(newpil) + int newpil; +#endif +{ + int pil; + + __asm __volatile("rdpr %%pil,%0" : "=r" (pil)); + SPLPRINT(("{%d->%d}", pil, newpil)); \ + __asm __volatile("wrpr %%g0,%0,%%pil" : : "rn" (newpil)); +} +#endif /* KERNEL && !_LOCORE */ + +#endif /* PSR_IMPL */ diff --git a/sys/arch/sparc64/include/reg.h b/sys/arch/sparc64/include/reg.h new file mode 100644 index 00000000000..d79726c6661 --- /dev/null +++ b/sys/arch/sparc64/include/reg.h @@ -0,0 +1,209 @@ +/* $OpenBSD: reg.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: reg.h,v 1.8 2001/06/19 12:59:16 wiz 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)reg.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_REG_H_ +#define _MACHINE_REG_H_ + +/* + * Registers passed to trap/syscall/etc. + * This structure is known to occupy exactly 80 bytes (see locore.s). + * Note, tf_global[0] is not actually written (since g0 is always 0). + * (The slot tf_global[0] is used to send a copy of %wim to kernel gdb. + * This is known as `cheating'.) + */ +struct trapframe32 { + int tf_psr; /* psr */ + int tf_pc; /* return pc */ + int tf_npc; /* return npc */ + int tf_y; /* %y register */ + int tf_global[8]; /* global registers in trap's caller */ + int tf_out[8]; /* output registers in trap's caller */ +}; + +/* + * The v9 trapframe is a bit more complex. Since we don't get a free + * register window with each trap we need some way to keep track of + * pending traps. We use tf_fault to save the faulting address for + * memory faults and tf_kstack to thread trapframes on the kernel + * stack(s). If tf_kstack == 0 then this is the lowest level trap; + * we came from user mode. + * (The slot tf_global[0] is used to store the %fp when this is used + * as a clockframe. This is known as `cheating'.) + */ +struct trapframe64 { + int64_t tf_tstate; /* tstate register */ + int64_t tf_pc; /* return pc */ + int64_t tf_npc; /* return npc */ + int64_t tf_fault; /* faulting addr -- need somewhere to save it */ + int64_t tf_kstack; /* kernel stack of prev tf */ + int tf_y; /* %y register -- 32-bits */ + short tf_tt; /* What type of trap this was */ + char tf_pil; /* What IRQ we're handling */ + char tf_oldpil; /* What our old SPL was */ + int64_t tf_global[8]; /* global registers in trap's caller */ + /* n.b. tf_global[0] is used for fp when this is a clockframe */ + int64_t tf_out[8]; /* output registers in trap's caller */ + int64_t tf_local[8]; /* local registers in trap's caller */ + int64_t tf_in[8]; /* in registers in trap's caller (for debug) */ +}; + +/* + * Register windows. Each stack pointer (%o6 aka %sp) in each window + * must ALWAYS point to some place at which it is safe to scribble on + * 64 bytes. (If not, your process gets mangled.) Furthermore, each + * stack pointer should be aligned on an 8-byte boundary for v8 stacks + * or a 16-byte boundary (plus the BIAS) for v9 stacks (the kernel + * as currently coded allows arbitrary alignment, but with a hefty + * performance penalty). + */ +struct rwindow32 { + int rw_local[8]; /* %l0..%l7 */ + int rw_in[8]; /* %i0..%i7 */ +}; + +/* Don't forget the BIAS!! */ +struct rwindow64 { + int64_t rw_local[8]; /* %l0..%l7 */ + int64_t rw_in[8]; /* %i0..%i7 */ +}; + +/* + * Clone trapframe for now; this seems to be the more useful + * than the old struct reg above. + */ +struct reg32 { + int r_psr; /* psr */ + int r_pc; /* return pc */ + int r_npc; /* return npc */ + int r_y; /* %y register */ + int r_global[8]; /* global registers in trap's caller */ + int r_out[8]; /* output registers in trap's caller */ +}; + +struct reg64 { + int64_t r_tstate; /* tstate register */ + int64_t r_pc; /* return pc */ + int64_t r_npc; /* return npc */ + int r_y; /* %y register -- 32-bits */ + int64_t r_global[8]; /* global registers in trap's caller */ + int64_t r_out[8]; /* output registers in trap's caller */ +}; + +#include <machine/fsr.h> + +/* + * FP coprocessor registers. + * + * FP_QSIZE is the maximum coprocessor instruction queue depth + * of any implementation on which the kernel will run. David Hough: + * ``I'd suggest allowing 16 ... allowing an indeterminate variable + * size would be even better''. Of course, we cannot do that; we + * need to malloc these. + * + * XXXX UltraSPARC processors don't implement a floating point queue. + */ +#define FP_QSIZE 16 +#define ALIGNFPSTATE(f) ((struct fpstate64 *)(((long)(f))&(~BLOCK_ALIGN))) + +struct fp_qentry { + int *fq_addr; /* the instruction's address */ + int fq_instr; /* the instruction itself */ +}; + +struct fpstate64 { + u_int fs_regs[64]; /* our view is 64 32-bit registers */ + int64_t fs_fsr; /* %fsr */ + int fs_gsr; /* graphics state reg */ + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +}; + +/* + * For 32-bit emulations. + */ +struct fpstate32 { + u_int fs_regs[32]; /* our view is 32 32-bit registers */ + int fs_fsr; /* %fsr */ + int fs_qsize; /* actual queue depth */ + struct fp_qentry fs_queue[FP_QSIZE]; /* queue contents */ +}; + +/* + * The actual FP registers are made accessible (c.f. ptrace(2)) through + * a `struct fpreg'; <arch/sparc64/sparc64/process_machdep.c> relies on the + * fact that `fpreg' is a prefix of `fpstate'. + */ +struct fpreg64 { + u_int fr_regs[64]; /* our view is 64 32-bit registers */ + int64_t fr_fsr; /* %fsr */ + int fr_gsr; /* graphics state reg */ +}; + +/* + * 32-bit fpreg used by 32-bit sparc CPUs + */ +struct fpreg32 { + u_int fr_regs[32]; /* our view is 32 32-bit registers */ + int fr_fsr; /* %fsr */ +}; + +#if defined(__arch64__) +/* Here we gotta do naughty things to let gdb work on 32-bit binaries */ +#define reg reg64 +#define fpreg fpreg64 +#define fpstate fpstate64 +#define trapframe trapframe64 +#define rwindow rwindow64 +#else +#define reg reg32 +#define fpreg fpreg32 +#define fpstate fpstate32 +#define trapframe trapframe32 +#define rwindow rwindow32 +#endif + +#endif /* _MACHINE_REG_H_ */ diff --git a/sys/arch/sparc64/include/signal.h b/sys/arch/sparc64/include/signal.h new file mode 100644 index 00000000000..0f4ec76710c --- /dev/null +++ b/sys/arch/sparc64/include/signal.h @@ -0,0 +1,125 @@ +/* $OpenBSD: signal.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: signal.h,v 1.10 2001/05/09 19:50:49 kleink 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. 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, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _SPARC_SIGNAL_H_ +#define _SPARC_SIGNAL_H_ + +#ifndef _LOCORE +typedef int sig_atomic_t; +#endif + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) +#ifndef _LOCORE + +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + * + * All machines must have an sc_onstack and sc_mask. + */ +#if defined(__LIBC12_SOURCE__) || defined(_KERNEL) +struct sigcontext13 { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore (old style) */ + /* begin machine dependent portion */ + long sc_sp; /* %sp to restore */ + long sc_pc; /* pc to restore */ + long sc_npc; /* npc to restore */ +#ifdef __arch64__ + long sc_tstate; /* tstate to restore */ +#else + long sc_psr; /* psr portion to restore */ +#endif + long sc_g1; /* %g1 to restore */ + long sc_o0; /* %o0 to restore */ +}; +#endif /* __LIBC12_SOURCE__ || _KERNEL */ +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int __sc_mask13; /* signal mask to restore (old style) */ + /* begin machine dependent portion */ + long sc_sp; /* %sp to restore */ + long sc_pc; /* pc to restore */ + long sc_npc; /* npc to restore */ +#ifdef __arch64__ + long sc_tstate; /* tstate to restore */ +#else + long sc_psr; /* psr portion to restore */ +#endif + long sc_g1; /* %g1 to restore */ + long sc_o0; /* %o0 to restore */ + int sc_mask; /* signal mask to restore (new style) */ +}; +#else /* _LOCORE */ +/* XXXXX These values don't work for _LP64 */ +#define SC_SP_OFFSET 8 +#define SC_PC_OFFSET 12 +#define SC_NPC_OFFSET 16 +#define SC_PSR_OFFSET 20 +#define SC_G1_OFFSET 24 +#define SC_O0_OFFSET 28 +#endif /* _LOCORE */ + +/* + * `Code' arguments to signal handlers. The names, and the funny numbering. + * are defined so as to match up with what SunOS uses; I have no idea why + * they did the numbers that way, except maybe to match up with the 68881. + */ +#define FPE_INTOVF_TRAP 0x01 /* integer overflow */ +#define FPE_INTDIV_TRAP 0x14 /* integer divide by zero */ +#define FPE_FLTINEX_TRAP 0xc4 /* inexact */ +#define FPE_FLTDIV_TRAP 0xc8 /* divide by zero */ +#define FPE_FLTUND_TRAP 0xcc /* underflow */ +#define FPE_FLTOPERR_TRAP 0xd0 /* operand error */ +#define FPE_FLTOVF_TRAP 0xd4 /* overflow */ + +#endif /* !_ANSI_SOURCE && !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ +#endif /* !_SPARC_SIGNAL_H_ */ diff --git a/sys/arch/sparc64/include/types.h b/sys/arch/sparc64/include/types.h new file mode 100644 index 00000000000..23006a67da2 --- /dev/null +++ b/sys/arch/sparc64/include/types.h @@ -0,0 +1,89 @@ +/* $OpenBSD: types.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: types.h,v 1.17 2001/05/12 22:42:07 kleink 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)types.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHTYPES_H_ +#define _MACHTYPES_H_ + +#include <sys/cdefs.h> +#include <machine/int_types.h> + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +typedef struct label_t { + int val[2]; +} label_t; +#endif + +/* The following are unsigned to prevent annoying sign extended pointers. */ +typedef unsigned long int register_t; +typedef unsigned int register32_t; +#ifdef __arch64__ +typedef unsigned long int register64_t; +#else +/* LONGLONG */ +typedef unsigned long long int register64_t; +#endif + +#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) +typedef unsigned long int vaddr_t; +typedef vaddr_t vsize_t; +#ifdef SUN4U +#ifdef __arch64__ +typedef unsigned long int paddr_t; +#else +/* LONGLONG */ +typedef unsigned long long int paddr_t; +#endif /* __arch64__ */ +#else +typedef unsigned long int paddr_t; +#endif /* SUN4U */ +typedef paddr_t psize_t; +#endif + +#define __HAVE_DEVICE_REGISTER +#define __HAVE_GENERIC_SOFT_INTERRUPTS + +#endif /* _MACHTYPES_H_ */ diff --git a/sys/arch/sparc64/sparc64/intreg.h b/sys/arch/sparc64/sparc64/intreg.h new file mode 100644 index 00000000000..461e7dadf04 --- /dev/null +++ b/sys/arch/sparc64/sparc64/intreg.h @@ -0,0 +1,63 @@ +/* $OpenBSD: intreg.h,v 1.1 2001/08/18 04:16:40 jason Exp $ */ +/* $NetBSD: intreg.h,v 1.4 2000/06/24 04:21:05 eeh 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. 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, Berkeley and its contributors. + * 4. 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. + * + * @(#)intreg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * All sun4u interrupts arrive as interrupt packets. These packets + * consist of up to six (three on spitfires) quads. The first one + * contains the interrupt number. This is either the device ID + * or a pointer to the handler routine. + * + * Device IDs are split into two parts: a 5-bit interrupt group number + * and a 5-bit interrupt number. We ignore this distinction. + * + */ +#define MAXINTNUM (1<<11) + +#ifndef _LOCORE +struct intrhand; /* This is in cpu.h if you need it. */ +void send_softint __P((int cpu, int level, struct intrhand *ih)); +#endif diff --git a/sys/arch/sparc64/stand/bootblk/Makefile b/sys/arch/sparc64/stand/bootblk/Makefile new file mode 100644 index 00000000000..0bd94dc67d0 --- /dev/null +++ b/sys/arch/sparc64/stand/bootblk/Makefile @@ -0,0 +1,68 @@ +# $OpenBSD: Makefile,v 1.1 2001/08/18 04:16:37 jason Exp $ +# $NetBSD: Makefile,v 1.1 2000/08/20 14:58:45 mrg Exp $ + +CURDIR= ${.CURDIR} +S= ${CURDIR}/../../../.. + +# +# Override normal settings +# + +PROG= bootblk +SRCS= bootblk.fth +OBJS= +CLEANFILES= assym.fth.h assym.fth.h.tmp machine sparc \ + bootblk bootblk.text bootblk.text.tmp + +NOMAN= +STRIPFLAG= + +# deal with Solaris vs. NetBSD build environments for now .. +OS!=uname -s +.if (${OS} == "NetBSD") +USE_GENASSYM?= no +SVR4= +.else +USE_GENASSYM?= yes +SVR4=-U__SVR4 -U__svr4__ -D__NetBSD__ +.endif + +INCLUDES= -I. -I$S/arch -I$S -nostdinc +CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_LKM ${SVR4} + +#all:: bootblk.text bootblk + +#clean:: +# rm assym.fth.h bootblk.text machine bootblk + +sparc: + ln -s ${.CURDIR}/../../../sparc/include sparc + +machine: + ln -s ${.CURDIR}/../../../${MACHINE}/include machine + +assym.fth.h: ${.CURDIR}/genassym.sh genfth.cf machine + sh ${.CURDIR}/genassym.sh ${CC} ${CFLAGS} \ + ${CPPFLAGS} ${PROF} <${.CURDIR}/genfth.cf >assym.fth.h.tmp && \ + mv -f assym.fth.h.tmp assym.fth.h + +bootblk.text: bootblk.fth assym.fth.h + awk '/fload/ { print "#include \"" $$2 "\"" }; !/fload/' \ + ${.CURDIR}/bootblk.fth | /usr/bin/cpp -P >bootblk.text.tmp && + mv -f bootblk.text.tmp bootblk.text + +bootblk: bootblk.fth assym.fth.h + fgen -o bootblk ${.CURDIR}/bootblk.fth + +beforedepend: + @touch .depend + +# +# The following are if you grab the fakeboot program from the Sun website +# + +fake: bootblk bootblk.text + ../fakeboot/fakeboot -elf32 <bootblk >/bootblk + ../fakeboot/fakeboot -elf32 <bootblk.text >/bootblk.text + +.include <bsd.prog.mk> diff --git a/sys/arch/sparc64/stand/bootblk/bootblk.fth b/sys/arch/sparc64/stand/bootblk/bootblk.fth new file mode 100644 index 00000000000..42f5e21089b --- /dev/null +++ b/sys/arch/sparc64/stand/bootblk/bootblk.fth @@ -0,0 +1,613 @@ +\ $OpenBSD: bootblk.fth,v 1.1 2001/08/18 04:16:37 jason Exp $ +\ $NetBSD: bootblk.fth,v 1.3 2001/08/15 20:10:24 eeh Exp $ +\ +\ IEEE 1275 Open Firmware Boot Block +\ +\ Parses disklabel and UFS and loads the file called `ofwboot' +\ +\ +\ Copyright (c) 1998 Eduardo Horvath. +\ All rights reserved. +\ +\ Redistribution and use in source and binary forms, with or without +\ modification, are permitted provided that the following conditions +\ are met: +\ 1. Redistributions of source code must retain the above copyright +\ notice, this list of conditions and the following disclaimer. +\ 2. Redistributions in binary form must reproduce the above copyright +\ notice, this list of conditions and the following disclaimer in the +\ documentation and/or other materials provided with the distribution. +\ 3. All advertising materials mentioning features or use of this software +\ must display the following acknowledgement: +\ This product includes software developed by Eduardo Horvath. +\ 4. The name of the author may not be used to endorse or promote products +\ derived from this software without specific prior written permission +\ +\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +\ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +\ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +\ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +\ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +\ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +\ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +\ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +\ + +offset16 +hex +headers + +false value boot-debug? + +\ +\ First some housekeeping: Open /chosen and set up vectors into +\ client-services + +" /chosen" find-package 0= if ." Cannot find /chosen" 0 then +constant chosen-phandle + +" /openprom/client-services" find-package 0= if + ." Cannot find client-services" cr abort +then constant cif-phandle + +defer cif-claim ( align size virt -- base ) +defer cif-release ( size virt -- ) +defer cif-open ( cstr -- ihandle|0 ) +defer cif-close ( ihandle -- ) +defer cif-read ( len adr ihandle -- #read ) +defer cif-seek ( low high ihandle -- -1|0|1 ) +\ defer cif-peer ( phandle -- phandle ) +\ defer cif-getprop ( len adr cstr phandle -- ) + +: find-cif-method ( method,len -- xf ) + cif-phandle find-method drop +; + +" claim" find-cif-method to cif-claim +" open" find-cif-method to cif-open +" close" find-cif-method to cif-close +" read" find-cif-method to cif-read +" seek" find-cif-method to cif-seek + +: twiddle ( -- ) ." ." ; \ Need to do this right. Just spit out periods for now. + +\ +\ Support routines +\ + +: strcmp ( s1 l1 s2 l2 -- true:false ) + rot tuck <> if 3drop false exit then + comp 0= +; + +\ Move string into buffer + +: strmov ( s1 l1 d -- d l1 ) + dup 2over swap -rot ( s1 l1 d s1 d l1 ) + move ( s1 l1 d ) + rot drop swap +; + +\ Move s1 on the end of s2 and return the result + +: strcat ( s1 l1 s2 l2 -- d tot ) + 2over swap ( s1 l1 s2 l2 l1 s1 ) + 2over + rot ( s1 l1 s2 l2 s1 d l1 ) + move rot + ( s1 s2 len ) + rot drop ( s2 len ) +; + +: strchr ( s1 l1 c -- s2 l2 ) + begin + dup 2over 0= if ( s1 l1 c c s1 ) + 2drop drop exit then + c@ = if ( s1 l1 c ) + drop exit then + -rot /c - swap ca1+ ( c l2 s2 ) + swap rot + again +; + + +: cstr ( ptr -- str len ) + dup + begin dup c@ 0<> while + repeat + over - +; + +\ +\ BSD FFS parameters +\ + +fload assym.fth.h + +sbsize buffer: sb-buf +-1 value boot-ihandle +dev_bsize value bsize +0 value raid-offset \ Offset if it's a raid-frame partition + +: strategy ( addr size start -- nread ) + raid-offset + bsize * 0 " seek" boot-ihandle $call-method + -1 = if + ." strategy: Seek failed" cr + abort + then + " read" boot-ihandle $call-method +; + +\ +\ Cylinder group macros +\ + +: cgbase ( cg fs -- cgbase ) fs_fpg l@ * ; +: cgstart ( cg fs -- cgstart ) + 2dup fs_cgmask l@ not and ( cg fs stuff -- ) + over fs_cgoffset l@ * -rot ( stuffcg fs -- ) + cgbase + +; +: cgdmin ( cg fs -- 1st-data-block ) dup fs_dblkno l@ -rot cgstart + ; +: cgimin ( cg fs -- inode-block ) dup fs_iblkno l@ -rot cgstart + ; +: cgsblock ( cg fs -- super-block ) dup fs_sblkno l@ -rot cgstart + ; +: cgstod ( cg fs -- cg-block ) dup fs_cblkno l@ -rot cgstart + ; + +\ +\ Block and frag position macros +\ + +: blkoff ( pos fs -- off ) fs_qbmask x@ and ; +: fragoff ( pos fs -- off ) fs_qfmask x@ and ; +: lblktosize ( blk fs -- off ) fs_bshift l@ << ; +: lblkno ( pos fs -- off ) fs_bshift l@ >> ; +: numfrags ( pos fs -- off ) fs_fshift l@ >> ; +: blkroundup ( pos fs -- off ) dup fs_bmask l@ -rot fs_qbmask x@ + and ; +: fragroundup ( pos fs -- off ) dup fs_fmask l@ -rot fs_qfmask x@ + and ; +\ : fragroundup ( pos fs -- off ) tuck fs_qfmask x@ + swap fs_fmask l@ and ; +: fragstoblks ( pos fs -- off ) fs_fragshift l@ >> ; +: blkstofrags ( blk fs -- frag ) fs_fragshift l@ << ; +: fragnum ( fsb fs -- off ) fs_frag l@ 1- and ; +: blknum ( fsb fs -- off ) fs_frag l@ 1- not and ; +: dblksize ( lbn dino fs -- size ) + -rot ( fs lbn dino ) + di_size x@ ( fs lbn di_size ) + -rot dup 1+ ( di_size fs lbn lbn+1 ) + 2over fs_bshift l@ ( di_size fs lbn lbn+1 di_size b_shift ) + rot swap << >= ( di_size fs lbn res1 ) + swap ndaddr >= or if ( di_size fs ) + swap drop fs_bsize l@ exit ( size ) + then tuck blkoff swap fragroundup ( size ) +; + + +: ino-to-cg ( ino fs -- cg ) fs_ipg l@ / ; +: ino-to-fsbo ( ino fs -- fsb0 ) fs_inopb l@ mod ; +: ino-to-fsba ( ino fs -- ba ) \ Need to remove the stupid stack diags someday + 2dup ( ino fs ino fs ) + ino-to-cg ( ino fs cg ) + over ( ino fs cg fs ) + cgimin ( ino fs inode-blk ) + -rot ( inode-blk ino fs ) + tuck ( inode-blk fs ino fs ) + fs_ipg l@ ( inode-blk fs ino ipg ) + mod ( inode-blk fs mod ) + swap ( inode-blk mod fs ) + dup ( inode-blk mod fs fs ) + fs_inopb l@ ( inode-blk mod fs inopb ) + rot ( inode-blk fs inopb mod ) + swap ( inode-blk fs mod inopb ) + / ( inode-blk fs div ) + swap ( inode-blk div fs ) + blkstofrags ( inode-blk frag ) + + +; +: fsbtodb ( fsb fs -- db ) fs_fsbtodb l@ << ; + +\ +\ File stuff +\ + +niaddr /w* constant narraysize + +struct + 8 field >f_ihandle \ device handle + 8 field >f_seekp \ seek pointer + 8 field >f_fs \ pointer to super block + dinode_SIZEOF field >f_di \ copy of on-disk inode + 8 field >f_buf \ buffer for data block + 4 field >f_buf_size \ size of data block + 4 field >f_buf_blkno \ block number of data block +constant file_SIZEOF + +file_SIZEOF buffer: the-file +sb-buf the-file >f_fs x! + +dinode_SIZEOF buffer: cur-inode +h# 2000 buffer: indir-block +-1 value indir-addr + +\ +\ Translate a fileblock to a disk block +\ +\ We only allow single indirection +\ + +: block-map ( fileblock -- diskblock ) + \ Direct block? + dup ndaddr < if ( fileblock ) + cur-inode di_db ( arr-indx arr-start ) + swap la+ l@ exit ( diskblock ) + then ( fileblock ) + ndaddr - ( fileblock' ) + \ Now we need to check the indirect block + dup sb-buf fs_nindir l@ < if ( fileblock' ) + cur-inode di_ib l@ dup ( fileblock' indir-block indir-block ) + indir-addr <> if ( fileblock' indir-block ) + to indir-addr ( fileblock' ) + indir-block ( fileblock' indir-block ) + sb-buf dup fs_bsize l@ ( fileblock' indir-block fs fs_bsize ) + swap indir-addr swap ( fileblock' indir-block fs_bsize indiraddr fs ) + fsbtodb ( fileblock' indir-block fs_bsize db ) + strategy ( fileblock' nread ) + then ( fileblock' nread|indir-block ) + drop \ Really should check return value + indir-block swap la+ l@ exit + then + dup sb-buf fs_nindir - ( fileblock'' ) + \ Now try 2nd level indirect block -- just read twice + dup sb-buf fs_nindir l@ dup * < if ( fileblock'' ) + cur-inode di_ib 1 la+ l@ ( fileblock'' indir2-block ) + to indir-addr ( fileblock'' ) + \ load 1st level indir block + indir-block ( fileblock'' indir-block ) + sb-buf dup fs_bsize l@ ( fileblock'' indir-block fs fs_bsize ) + swap indir-addr swap ( fileblock'' indir-block fs_bsize indiraddr fs ) + fsbtodb ( fileblock'' indir-block fs_bsize db ) + strategy ( fileblock'' nread ) + drop ( fileblock'' ) + dup sb-buf fs_nindir / ( fileblock'' indir-offset ) + indir-block swap la+ l@ ( fileblock'' indirblock ) + to indir-addr ( fileblock'' ) + \ load 2nd level indir block + indir-block ( fileblock'' indir-block ) + sb-buf dup fs_bsize l@ ( fileblock'' indir-block fs fs_bsize ) + swap indir-addr swap ( fileblock'' indir-block fs_bsize indiraddr fs ) + fsbtodb ( fileblock'' indir-block fs_bsize db ) + strategy ( fileblock'' nread ) + drop ( fileblock'' ) + sb-buf fs_nindir l@ mod indir-block swap la+ l@ exit + then + ." block-map: exceeded max file size" cr + abort +; + +\ +\ Read file into internal buffer and return pointer and len +\ + +2000 buffer: cur-block \ Why do dynamic allocation? +-1 value cur-blockno +0 value cur-offset + +: buf-read-file ( fs -- len buf ) + cur-offset swap ( seekp fs ) + 2dup blkoff ( seekp fs off ) + -rot 2dup lblkno ( off seekp fs block ) + swap 2dup cur-inode ( off seekp block fs block fs inop ) + swap dblksize ( off seekp block fs size ) + rot dup cur-blockno ( off seekp fs size block block cur ) + <> if ( off seekp fs size block ) + block-map ( off seekp fs size diskblock ) + dup 0= if ( off seekp fs size diskblock ) + over cur-block swap 0 fill ( off seekp fs size diskblock ) + boot-debug? if ." buf-read-file fell off end of file" cr then + else + 2dup sb-buf fsbtodb cur-block -rot strategy ( off seekp fs size diskblock nread ) + rot 2dup <> if " buf-read-file: short read." cr abort then + then ( off seekp fs diskblock nread size ) + nip nip ( off seekp fs size ) + else ( off seekp fs size block block cur ) + 2drop ( off seekp fs size ) + then +\ dup cur-offset + to cur-offset \ Set up next xfer -- not done + nip nip swap - ( len ) + cur-block +; + +\ +\ Read inode into cur-inode -- uses cur-block +\ + +: read-inode ( inode fs -- ) + twiddle ( inode fs -- inode fs ) + + cur-block ( inode fs -- inode fs buffer ) + + over ( inode fs buffer -- inode fs buffer fs ) + fs_bsize l@ ( inode fs buffer -- inode fs buffer size ) + + 2over ( inode fs buffer size -- inode fs buffer size inode fs ) + 2over ( inode fs buffer size inode fs -- inode fs buffer size inode fs buffer size ) + 2swap tuck ( inode fs buffer size inode fs buffer size -- inode fs buffer size buffer size fs inode fs ) + + ino-to-fsba ( inode fs buffer size buffer size fs inode fs -- inode fs buffer size buffer size fs fsba ) + swap ( inode fs buffer size buffer size fs fsba -- inode fs buffer size buffer size fsba fs ) + fsbtodb ( inode fs buffer size buffer size fsba fs -- inode fs buffer size buffer size db ) + + dup to cur-blockno ( inode fs buffer size buffer size dstart -- inode fs buffer size buffer size dstart ) + strategy ( inode fs buffer size buffer size dstart -- inode fs buffer size nread ) + <> if ." read-inode - residual" cr abort then + dup 2over ( inode fs buffer -- inode fs buffer buffer inode fs ) + ino-to-fsbo ( inode fs buffer -- inode fs buffer buffer fsbo ) + dinode_SIZEOF * + ( inode fs buffer buffer fsbo -- inode fs buffer dinop ) + cur-inode dinode_SIZEOF move ( inode fs buffer dinop -- inode fs buffer ) + \ clear out the old buffers + drop ( inode fs buffer -- inode fs ) + 2drop +; + +\ Identify inode type + +: is-dir? ( dinode -- true:false ) di_mode w@ ifmt and ifdir = ; +: is-symlink? ( dinode -- true:false ) di_mode w@ ifmt and iflnk = ; + + + +\ +\ Hunt for directory entry: +\ +\ repeat +\ load a buffer +\ while entries do +\ if entry == name return +\ next entry +\ until no buffers +\ + +: search-directory ( str len -- ino|0 ) + 0 to cur-offset + begin cur-offset cur-inode di_size x@ < while ( str len ) + sb-buf buf-read-file ( str len len buf ) + over 0= if ." search-directory: buf-read-file zero len" cr abort then + swap dup cur-offset + to cur-offset ( str len buf len ) + 2dup + nip ( str len buf bufend ) + swap 2swap rot ( bufend str len buf ) + begin dup 4 pick < while ( bufend str len buf ) + dup d_ino l@ 0<> if ( bufend str len buf ) + boot-debug? if dup dup d_name swap d_namlen c@ type cr then + 2dup d_namlen c@ = if ( bufend str len buf ) + dup d_name 2over ( bufend str len buf dname str len ) + comp 0= if ( bufend str len buf ) + \ Found it -- return inode + d_ino l@ nip nip nip ( dino ) + boot-debug? if ." Found it" cr then + exit ( dino ) + then + then ( bufend str len buf ) + then ( bufend str len buf ) + dup d_reclen w@ + ( bufend str len nextbuf ) + repeat + drop rot drop ( str len ) + repeat + 2drop 2drop 0 ( 0 ) +; + +: ffs_oldcompat ( -- ) +\ Make sure old ffs values in sb-buf are sane + sb-buf fs_npsect dup l@ sb-buf fs_nsect l@ max swap l! + sb-buf fs_interleave dup l@ 1 max swap l! + sb-buf fs_postblformat l@ fs_42postblfmt = if + 8 sb-buf fs_nrpos l! + then + sb-buf fs_inodefmt l@ fs_44inodefmt < if + sb-buf fs_bsize l@ + dup ndaddr * 1- sb-buf fs_maxfilesize x! + niaddr 0 ?do + sb-buf fs_nindir l@ * dup ( sizebp sizebp -- ) + sb-buf fs_maxfilesize dup x@ ( sizebp sizebp *fs_maxfilesize fs_maxfilesize -- ) + rot ( sizebp *fs_maxfilesize fs_maxfilesize sizebp -- ) + + ( sizebp *fs_maxfilesize new_fs_maxfilesize -- ) swap x! ( sizebp -- ) + loop drop ( -- ) + sb-buf dup fs_bmask l@ not swap fs_qbmask x! + sb-buf dup fs_fmask l@ not swap fs_qfmask x! + then +; + +: read-super ( sector -- ) +0 " seek" boot-ihandle $call-method + -1 = if + ." Seek failed" cr + abort + then + sb-buf sbsize " read" boot-ihandle $call-method + dup sbsize <> if + ." Read of superblock failed" cr + ." requested" space sbsize . + ." actual" space . cr + abort + else + drop + then +; + +: ufs-open ( bootpath,len -- ) + boot-ihandle -1 = if + over cif-open dup 0= if ( boot-path len ihandle? ) + ." Could not open device" space type cr + abort + then ( boot-path len ihandle ) + to boot-ihandle \ Save ihandle to boot device + then 2drop + sboff read-super + sb-buf fs_magic l@ fs_magic_value <> if + 64 dup to raid-offset + dev_bsize * sboff + read-super + sb-buf fs_magic l@ fs_magic_value <> if + ." Invalid superblock magic" cr + abort + then + then + sb-buf fs_bsize l@ dup maxbsize > if + ." Superblock bsize" space . ." too large" cr + abort + then + fs_SIZEOF < if + ." Superblock bsize < size of superblock" cr + abort + then + ffs_oldcompat + boot-debug? if ." ufs-open complete" cr then +; + +: ufs-close ( -- ) + boot-ihandle dup -1 <> if + cif-close -1 to boot-ihandle + then +; + +: boot-path ( -- boot-path ) + " bootpath" chosen-phandle get-package-property if + ." Could not find bootpath in /chosen" cr + abort + else + decode-string 2swap 2drop + then +; + +: boot-args ( -- boot-args ) + " bootargs" chosen-phandle get-package-property if + ." Could not find bootargs in /chosen" cr + abort + else + decode-string 2swap 2drop + then +; + +2000 buffer: boot-path-str +2000 buffer: boot-path-tmp + +: split-path ( path len -- right len left len ) +\ Split a string at the `/' + begin + dup -rot ( oldlen right len left ) + ascii / left-parse-string ( oldlen right len left len ) + dup 0<> if 4 roll drop exit then + 2drop ( oldlen right len ) + rot over = ( right len diff ) + until +; + +: find-file ( load-file len -- ) + rootino dup sb-buf read-inode ( load-file len -- load-file len ino ) + -rot ( load-file len ino -- pino load-file len ) + \ + \ For each path component + \ + begin split-path dup 0<> while ( pino right len left len -- ) + cur-inode is-dir? not if ." Inode not directory" cr abort then + boot-debug? if ." Looking for" space 2dup type space ." in directory..." cr then + search-directory ( pino right len left len -- pino right len ino|false ) + dup 0= if ." Bad path" cr abort then ( pino right len cino ) + sb-buf read-inode ( pino right len ) + cur-inode is-symlink? if \ Symlink -- follow the damn thing + \ Save path in boot-path-tmp + boot-path-tmp strmov ( pino new-right len ) + + \ Now deal with symlink + cur-inode di_size x@ ( pino right len linklen ) + dup sb-buf fs_maxsymlinklen l@ ( pino right len linklen linklen maxlinklen ) + < if \ Now join the link to the path + cur-inode di_shortlink l@ ( pino right len linklen linkp ) + swap boot-path-str strmov ( pino right len new-linkp linklen ) + else \ Read file for symlink -- Ugh + \ Read link into boot-path-str + boot-path-str dup sb-buf fs_bsize l@ + 0 block-map ( pino right len linklen boot-path-str bsize blockno ) + strategy drop swap ( pino right len boot-path-str linklen ) + then ( pino right len linkp linklen ) + \ Concatenate the two paths + strcat ( pino new-right newlen ) + swap dup c@ ascii / = if \ go to root inode? + rot drop rootino -rot ( rino len right ) + then + rot dup sb-buf read-inode ( len right pino ) + -rot swap ( pino right len ) + then ( pino right len ) + repeat + 2drop drop +; + +: read-file ( size addr -- ) + \ Read x bytes from a file to buffer + begin over 0> while + cur-offset cur-inode di_size x@ > if ." read-file EOF exceeded" cr abort then + sb-buf buf-read-file ( size addr len buf ) + over 2over drop swap ( size addr len buf addr len ) + move ( size addr len ) + dup cur-offset + to cur-offset ( size len newaddr ) + tuck + ( size len newaddr ) + -rot - swap ( newaddr newsize ) + repeat + 2drop +; + +h# 5000 constant loader-base + +\ +\ Elf support -- find the load addr +\ + +: is-elf? ( hdr -- res? ) h# 7f454c46 = ; + +\ +\ Finally we finish it all off +\ + +: load-file-signon ( load-file len boot-path len -- load-file len boot-path len ) + ." Loading file" space 2over type cr ." from device" space 2dup type cr +; + +: load-file-print-size ( size -- size ) + ." Loading" space dup . space ." bytes of file..." cr +; + +: load-file ( load-file len boot-path len -- load-base ) + boot-debug? if load-file-signon then + the-file file_SIZEOF 0 fill \ Clear out file structure + ufs-open ( load-file len ) + find-file ( ) + + \ + \ Now we've found the file we should read it in in one big hunk + \ + + cur-inode di_size x@ ( file-len ) + dup " to file-size" evaluate ( file-len ) + boot-debug? if load-file-print-size then + 0 to cur-offset + loader-base ( buf-len addr ) + 2dup read-file ( buf-len addr ) + ufs-close ( buf-len addr ) + dup is-elf? if ." load-file: not an elf executable" cr abort then + + \ Luckily the prom should be able to handle ELF executables by itself + + nip ( addr ) +; + +: do-boot ( bootfile -- ) + ." OpenBSD IEEE 1275 Bootblock" cr + boot-path load-file ( -- load-base ) + dup 0<> if " to load-base init-program" evaluate then +; + + +boot-args ascii V strchr 0<> swap drop if + true to boot-debug? +then + +boot-args ascii D strchr 0= swap drop if + " /ofwboot" do-boot +then exit + + diff --git a/sys/arch/sparc64/stand/bootblk/genassym.sh b/sys/arch/sparc64/stand/bootblk/genassym.sh new file mode 100644 index 00000000000..dd065b096a1 --- /dev/null +++ b/sys/arch/sparc64/stand/bootblk/genassym.sh @@ -0,0 +1,170 @@ +# $OpenBSD: genassym.sh,v 1.1 2001/08/18 04:16:37 jason Exp $ +# $NetBSD: genassym.sh,v 1.1 2000/08/20 14:58:45 mrg Exp $ + +# +# Copyright (c) 1998 Eduardo E. Horvath. +# Copyright (c) 1997 Matthias Pfaller. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by Matthias Pfaller. +# 4. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# If first argument is -c, create a temporary C file, +# compile it and execute the result. + +awk=${AWK:-awk} + +if [ $1 = '-c' ] ; then + shift + ccode=1 +else + ccode=0 +fi + +#trap "rm -f /tmp/$$.c /tmp/genassym.$$" 0 1 2 3 15 + +$awk ' +BEGIN { + printf("#ifndef _KERNEL\n#define _KERNEL\n#endif\n"); + printf("#define offsetof(type, member) ((size_t)(&((type *)0)->member))\n"); + defining = 0; + type = "long"; + asmtype = "n"; + asmprint = ""; +} + +$0 ~ /^[ \t]*#.*/ || $0 ~ /^[ \t]*$/ { + # Just ignore comments and empty lines + next; +} + +$0 ~ /^config[ \t]/ { + type = $2; + asmtype = $3; + asmprint = $4; + next; +} + +/^include[ \t]/ { + if (defining != 0) { + defining = 0; + printf("}\n"); + } + printf("#%s\n", $0); + next; +} + +$0 ~ /^if[ \t]/ || +$0 ~ /^ifdef[ \t]/ || +$0 ~ /^ifndef[ \t]/ || +$0 ~ /^else/ || +$0 ~ /^elif[ \t]/ || +$0 ~ /^endif/ { + printf("#%s\n", $0); + next; +} + +/^struct[ \t]/ { + structname = $2; + $0 = "define " structname "_SIZEOF sizeof(struct " structname ")"; + # fall through +} + +/^export[ \t]/ { + $0 = "define " $2 " " $2; + # fall through +} + +/^define[ \t]/ { + if (defining == 0) { + defining = 1; + printf("void f" FNR "(void);\n"); + printf("void f" FNR "() {\n"); + if (ccode) + call[FNR] = "f" FNR; + defining = 1; + } + value = $0 + gsub("^define[ \t]+[A-Za-z_][A-Za-z_0-9]*[ \t]+", "", value) + if (ccode) + printf("printf(\"#define " $2 " %%ld\\n\", (%s)" value ");\n", type); + else + printf("__asm(\"XYZZY d# %%%s0 constant %s\" : : \"%s\" (%s));\n", asmprint, $2, asmtype, value); + next; +} + +/^member[ \t]/ { + $0 = "define " $2 " offsetof(struct " structname ", " $2 ")"; + if (defining == 0) { + defining = 1; + printf("void f" FNR "(void);\n"); + printf("void f" FNR "() {\n"); + if (ccode) + call[FNR] = "f" FNR; + defining = 1; + } + value = $0 + gsub("^define[ \t]+[A-Za-z_][A-Za-z_0-9]*[ \t]+", "", value) + if (ccode) + printf("printf(\"#define " $2 " %%ld\\n\", (%s)" value ");\n", type); + else + printf("__asm(\"XYZZY : %s d\# %%%s0 + ;\" : : \"%s\" (%s));\n", $2, asmprint, asmtype, value); + next; +} + +/^quote[ \t]/ { + gsub("^quote[ \t]+", ""); + print; + next; +} + +{ + printf("syntax error in line %d\n", FNR) >"/dev/stderr"; + exit(1); +} + +END { + if (defining != 0) { + defining = 0; + printf("}\n"); + } + if (ccode) { + printf("int main(int argc, char **argv) {"); + for (i in call) + printf(call[i] "();"); + printf("return(0); }\n"); + } +} +' ccode=$ccode > /tmp/$$.c || exit 1 + +if [ $ccode = 1 ] ; then + "$@" /tmp/$$.c -o /tmp/genassym.$$ && /tmp/genassym.$$ +else + # Kill all of the "#" and "$" modifiers; locore.s already + # prepends the correct "constant" modifier. + "$@" -S /tmp/$$.c -o -| sed -e 's/\$//g' | \ + sed -n 's/.*XYZZY//gp' +fi diff --git a/sys/arch/sparc64/stand/bootblk/genfth.cf b/sys/arch/sparc64/stand/bootblk/genfth.cf new file mode 100644 index 00000000000..ed3a067cce5 --- /dev/null +++ b/sys/arch/sparc64/stand/bootblk/genfth.cf @@ -0,0 +1,162 @@ +# $OpenBSD: genfth.cf,v 1.1 2001/08/18 04:16:37 jason Exp $ +# $NetBSD: genfth.cf,v 1.1 2000/08/20 14:58:46 mrg Exp $ + +# +# Copyright (c) 1997 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Christos Zoulas. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# Copyright (c) 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. 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, Berkeley and its contributors. +# 4. 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. +# +# @(#)genassym.c 8.1 (Berkeley) 6/11/93 +# + +include <sys/param.h> +include <sys/time.h> +include <ufs/ufs/dinode.h> +include <ufs/ufs/dir.h> +include <ufs/ffs/fs.h> + +# +# ufs sizing constants +# +define dev_bsize DEV_BSIZE +define maxbsize MAXBSIZE +define bbsize BBSIZE +define sbsize SBSIZE +define bboff BBOFF +define sboff SBOFF +define bblock BBLOCK +define sblock SBLOCK + +# +# ufs superblock +# +struct fs +member fs_magic +member fs_bsize +member fs_npsect +member fs_nsect +member fs_interleave +member fs_postblformat +member fs_nrpos +member fs_inodefmt +member fs_maxfilesize +member fs_qbmask +member fs_qfmask +member fs_bmask +member fs_fmask +member fs_ipg +member fs_fpg +member fs_inopb +member fs_fragshift +member fs_bshift +member fs_fshift +member fs_cgoffset +member fs_cgmask +member fs_dblkno +member fs_iblkno +member fs_sblkno +member fs_cblkno +member fs_fsbtodb +member fs_nindir +member fs_frag +member fs_maxsymlinklen + +# +# ufs dinode +# +struct dinode +member di_size +member di_mode +member di_db +member di_ib +member di_shortlink + +# +# ufs direct +# +struct direct +member d_ino +member d_reclen +#member d_type # notused +member d_namlen +member d_name + +define fs_magic_value FS_MAGIC +define fs_42postblfmt FS_42POSTBLFMT +define fs_44inodefmt FS_44INODEFMT +define ndaddr NDADDR +define niaddr NIADDR +define rootino ROOTINO +define ifmt IFMT +define ifdir IFDIR +define iflnk IFLNK |