diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-10-06 21:02:56 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-10-06 21:02:56 +0000 |
commit | f2984aabfd358ae2731013df5d571a596cb9a5eb (patch) | |
tree | 0b36a098a4b5fcb0d202c68c5a85123e7d95f419 /sys/arch/sh/include | |
parent | b50063e7723d8a96f3eaeb641e59f7f161dcd917 (diff) |
Preliminary bits for SuperH-based ports, based on NetBSD/sh3 codebase with
minor changes.
Diffstat (limited to 'sys/arch/sh/include')
50 files changed, 4983 insertions, 0 deletions
diff --git a/sys/arch/sh/include/_types.h b/sys/arch/sh/include/_types.h new file mode 100644 index 00000000000..8b528bbf524 --- /dev/null +++ b/sys/arch/sh/include/_types.h @@ -0,0 +1,121 @@ +/* $OpenBSD: _types.h,v 1.1 2006/10/06 21:02:55 miod 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. 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.3 (Berkeley) 1/5/94 + * @(#)ansi.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _SH__TYPES_H_ +#define _SH__TYPES_H_ + +#if defined(_KERNEL) +typedef struct label_t { + int val[9]; +} label_t; +#endif + +/* 7.18.1.1 Exact-width integer types */ +typedef __signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short __int16_t; +typedef unsigned short __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +/* LONGLONG */ +typedef long long __int64_t; +/* LONGLONG */ +typedef unsigned long long __uint64_t; + +/* 7.18.1.2 Minimum-width integer types */ +typedef __int8_t __int_least8_t; +typedef __uint8_t __uint_least8_t; +typedef __int16_t __int_least16_t; +typedef __uint16_t __uint_least16_t; +typedef __int32_t __int_least32_t; +typedef __uint32_t __uint_least32_t; +typedef __int64_t __int_least64_t; +typedef __uint64_t __uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef __int32_t __int_fast8_t; +typedef __uint32_t __uint_fast8_t; +typedef __int32_t __int_fast16_t; +typedef __uint32_t __uint_fast16_t; +typedef __int32_t __int_fast32_t; +typedef __uint32_t __uint_fast32_t; +typedef __int64_t __int_fast64_t; +typedef __uint64_t __uint_fast64_t; + +/* 7.18.1.4 Integer types capable of holding object pointers */ +typedef long __intptr_t; +typedef unsigned long __uintptr_t; + +/* 7.18.1.5 Greatest-width integer types */ +typedef __int64_t __intmax_t; +typedef __uint64_t __uintmax_t; + +/* Register size */ +typedef __uint32_t __register_t; + +/* VM system types */ +typedef unsigned long __vaddr_t; +typedef unsigned long __paddr_t; +typedef unsigned long __vsize_t; +typedef unsigned long __psize_t; + +/* Standard system types */ +typedef int __clock_t; +typedef int __clockid_t; +typedef long long __off_t; +typedef long __ptrdiff_t; +typedef unsigned long __size_t; +typedef long __ssize_t; +typedef int __time_t; +typedef int __timer_t; +#if defined(__GNUC__) && __GNUC__ >= 3 +typedef __builtin_va_list __va_list; +#else +struct __va_list_tag; +typedef struct __va_list_tag * __va_list; +#endif + +/* Wide character support types */ +#ifndef __cplusplus +typedef int __wchar_t; +#endif +typedef int __wint_t; +typedef int __rune_t; +typedef void * __wctrans_t; +typedef void * __wctype_t; + +/* Feature test macros */ +#define __HAVE_GENERIC_SOFT_INTERRUPTS + +#endif /* _SH__TYPES_H_ */ diff --git a/sys/arch/sh/include/asm.h b/sys/arch/sh/include/asm.h new file mode 100644 index 00000000000..052d5a1748a --- /dev/null +++ b/sys/arch/sh/include/asm.h @@ -0,0 +1,217 @@ +/* $OpenBSD: asm.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: asm.h,v 1.25 2006/01/20 22:02:40 christos Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _SH_ASM_H_ +#define _SH_ASM_H_ + +#ifdef __ELF__ +# define _C_LABEL(x) x +#else +#ifdef __STDC__ +# define _C_LABEL(x) _ ## x +#else +# define _C_LABEL(x) _/**/x +#endif +#endif +#define _ASM_LABEL(x) x + +#ifdef __STDC__ +# define __CONCAT(x,y) x ## y +# define __STRING(x) #x +#else +# define __CONCAT(x,y) x/**/y +# define __STRING(x) "x" +#endif + +/* let kernels and others override entrypoint alignment */ +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 2 +#endif + +#ifdef __ELF__ +#define _ENTRY(x) \ + .text ;\ + _ALIGN_TEXT ;\ + .globl x ;\ + .type x,@function ;\ + x: +#else /* !__ELF__ */ +#define _ENTRY(x) \ + .text ;\ + _ALIGN_TEXT ;\ + .globl x ;\ + x: +#endif /* !__ELF__ */ + +#ifdef GPROF +#define _PROF_PROLOGUE \ + mov.l 1f,r1 ; \ + mova 2f,r0 ; \ + jmp @r1 ; \ + nop ; \ + .align 2 ; \ +1: .long __mcount ; \ +2: +#else /* !GPROF */ +#define _PROF_PROLOGUE +#endif /* !GPROF */ + +#define ENTRY(y) _ENTRY(_C_LABEL(y)) _PROF_PROLOGUE +#define NENTRY(y) _ENTRY(_C_LABEL(y)) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)) _PROF_PROLOGUE + +#define SET_ENTRY_SIZE(y) \ + .size _C_LABEL(y), . - _C_LABEL(y) + +#define SET_ASENTRY_SIZE(y) \ + .size _ASM_LABEL(y), . - _ASM_LABEL(y) + +#ifdef __ELF__ +#define ALTENTRY(name) \ + .globl _C_LABEL(name) ;\ + .type _C_LABEL(name),@function ;\ + _C_LABEL(name): +#else +#define ALTENTRY(name) \ + .globl _C_LABEL(name) ;\ + _C_LABEL(name): +#endif + + +/* + * Hide the gory details of PIC calls vs. normal calls. Use as in the + * following example: + * + * sts.l pr, @-sp + * PIC_PROLOGUE(.L_got, r0) ! saves old r12 on stack + * ... + * mov.l .L_function_1, r0 + * 1: CALL r0 ! each call site needs a label + * nop + * ... + * mov.l .L_function_2, r0 + * 2: CALL r0 + * nop + * ... + * PIC_EPILOGUE ! restores r12 from stack + * lds.l @sp+, pr ! so call in right order + * rts + * nop + * + * .align 2 + * .L_got: + * PIC_GOT_DATUM + * .L_function_1: ! if you call the same function twice + * CALL_DATUM(function, 1b) ! provide call datum for each call + * .L_function_2: + * CALL_DATUM(function, 2b) + */ + +#ifdef PIC + +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOT +#define PIC_GOTOFF(x) x@GOTOFF + +#define PIC_PROLOGUE(got) \ + mov.l r12, @-sp; \ + PIC_PROLOGUE_NOSAVE(got) + +/* + * Functions that do non local jumps don't need to preserve r12, + * so we can shave off two instructions to save/restore it. + */ +#define PIC_PROLOGUE_NOSAVE(got) \ + mov.l got, r12; \ + mova got, r0; \ + add r0, r12 + +#define PIC_EPILOGUE \ + mov.l @sp+, r12 + +#define PIC_EPILOGUE_SLOT \ + PIC_EPILOGUE + +#define PIC_GOT_DATUM \ + .long _GLOBAL_OFFSET_TABLE_ + +#define CALL bsrf +#define JUMP braf + +#define CALL_DATUM(function, lpcs) \ + .long PIC_PLT(function) - ((lpcs) + 4 - (.)) + +/* + * This will result in text relocations in the shared library, + * unless the function is local or has hidden or protected visibility. + * Does not require PIC prologue. + */ +#define CALL_DATUM_LOCAL(function, lpcs) \ + .long function - ((lpcs) + 4) + +#else /* !PIC */ + +#define PIC_PROLOGUE(label) +#define PIC_PROLOGUE_NOSAVE(label) +#define PIC_EPILOGUE +#define PIC_EPILOGUE_SLOT nop +#define PIC_GOT_DATUM + +#define CALL jsr @ +#define JUMP jmp @ + +#define CALL_DATUM(function, lpcs) \ + .long function + +#define CALL_DATUM_LOCAL(function, lpcs) \ + .long function + +#endif /* !PIC */ + + +#define ASMSTR .asciz + +#ifdef __ELF__ +#define WEAK_ALIAS(alias,sym) \ + .weak _C_LABEL(alias); \ + _C_LABEL(alias) = _C_LABEL(sym) +#endif + +#define WARN_REFERENCES(_sym,_msg) \ + .section .gnu.warning._sym; .ascii _msg; .previous + +#endif /* !_SH_ASM_H_ */ diff --git a/sys/arch/sh/include/bscreg.h b/sys/arch/sh/include/bscreg.h new file mode 100644 index 00000000000..86ea687978d --- /dev/null +++ b/sys/arch/sh/include/bscreg.h @@ -0,0 +1,70 @@ +/* $OpenBSD: bscreg.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: bscreg.h,v 1.6 2005/12/11 12:18:58 christos Exp $ */ + +/*- + * Copyright (C) 1999 SAITOH Masanobu. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_BSCREG_H_ +#define _SH_BSCREG_H_ +#include <sh/devreg.h> + +/* + * Bus State Controller + */ + +#define SH3_BCR1 0xffffff60 /* 16bit */ +#define SH3_BCR2 0xffffff62 /* 16bit */ +#define SH3_WCR1 0xffffff64 /* 16bit */ +#define SH3_WCR2 0xffffff66 /* 16bit */ +#define SH3_MCR 0xffffff68 /* 16bit */ +#define SH3_DCR 0xffffff6a /* 16bit */ +#define SH3_PCR 0xffffff6c /* 16bit */ +#define SH3_RTCSR 0xffffff6e /* 16bit */ +#define SH3_RTCNT 0xffffff70 /* 16bit */ +#define SH3_RTCOR 0xffffff72 /* 16bit */ +#define SH3_RFCR 0xffffff74 /* 16bit */ +#define SH3_BCR3 0xffffff7e /* 16bit */ + +#define SH4_BCR1 0xff800000 /* 32bit */ +#define SH4_BCR2 0xff800004 /* 16bit */ +#define SH4_WCR1 0xff800008 /* 32bit */ +#define SH4_WCR2 0xff80000c /* 32bit */ +#define SH4_WCR3 0xff800010 /* 32bit */ +#define SH4_MCR 0xff800014 /* 32bit */ +#define SH4_PCR 0xff800018 /* 16bit */ +#define SH4_RTCSR 0xff80001c /* 16bit */ +#define SH4_RTCNT 0xff800020 /* 16bit */ +#define SH4_RTCOR 0xff800024 /* 16bit */ +#define SH4_RFCR 0xff800028 /* 16bit */ +#define SH4_BCR3 0xff800050 /* 16bit: SH7751R */ +#define SH4_BCR4 0xfe0a00f0 /* 32bit: SH7751R */ + +#define BCR1_MASTER (1 << 30) +#define BCR1_BREQEN (1 << 19) + +#define BCR2_PORTEN (1 << 0) + +#endif /* !_SH_BSCREG_H_ */ diff --git a/sys/arch/sh/include/cache.h b/sys/arch/sh/include/cache.h new file mode 100644 index 00000000000..2e4fa50249a --- /dev/null +++ b/sys/arch/sh/include/cache.h @@ -0,0 +1,194 @@ +/* $OpenBSD: cache.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: cache.h,v 1.7 2006/01/21 00:46:36 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +/* + * Cache configurations. + * + * SH3 I/D unified virtual-index physical-tag cache. + * SH4 I/D separated virtual-index physical-tag cache. + * + * + * size line-size entry way type + * SH7708 4/8K 16B 128 2/4 P0,P2,U0 [1] + * P1 [2] + * SH7709 4/8K 16B 128 2/4 [1] + * SH7709A 16K 16B 256 4 [1] + * + * SH7750 I$ D$ line-size entry way + * 8K 8/16K 32B 256 1 [1] + * SH7750 + * SH7750S + * SH7751 I$ D$ line-size entry way + * 8K 8/16K 32B 256 1 [1] + * + * SH7750R + * SH7751R I$ D$ line-size entry way + * 16K 16/32K 32B 512 2 [1] + * + * [1] write-through/back selectable + * [2] write-through only + * + * Cache operations. + * + * There are some rules that must be followed: + * + * I-cache Sync (all or range): + * The goal is to synchronize the instruction stream, + * so you may need to write-back dirty data cache + * blocks first. If a range is requested, and you + * can't synchronize just a range, you have to hit + * the whole thing. + * + * D-cache Write-back Invalidate range: + * If you can't WB-Inv a range, you must WB-Inv the + * entire D-cache. + * + * D-cache Invalidate: + * If you can't Inv the D-cache without doing a + * Write-back, YOU MUST PANIC. This is to catch + * errors in calling code. Callers must be aware + * of this scenario, and must handle it appropriately + * (consider the bus_dma(9) operations). + * + * D-cache Write-back: + * If you can't Write-back without doing an invalidate, + * that's fine. Then treat this as a WB-Inv. Skipping + * the invalidate is merely an optimization. + * + * All operations: + * Valid virtual addresses must be passed to the + * cache operation. + * + * + * sh_icache_sync_all Synchronize I-cache + * + * sh_icache_sync_range Synchronize I-cache range + * + * sh_icache_sync_range_index (index ops) + * + * sh_dcache_wbinv_all Write-back Invalidate D-cache + * + * sh_dcache_wbinv_range Write-back Invalidate D-cache range + * + * sh_dcache_wbinv_range_index (index ops) + * + * sh_dcache_inv_range Invalidate D-cache range + * + * sh_dcache_wb_range Write-back D-cache range + * + * If I/D unified cache (SH3), I-cache ops are writeback invalidate + * operation. + * If write-through mode, sh_dcache_wb_range is no-operation. + * + */ + +#ifndef _SH_CACHE_H_ +#define _SH_CACHE_H_ + +#ifdef _KERNEL +struct sh_cache_ops { + void (*_icache_sync_all)(void); + void (*_icache_sync_range)(vaddr_t, vsize_t); + void (*_icache_sync_range_index)(vaddr_t, vsize_t); + + void (*_dcache_wbinv_all)(void); + void (*_dcache_wbinv_range)(vaddr_t, vsize_t); + void (*_dcache_wbinv_range_index)(vaddr_t, vsize_t); + void (*_dcache_inv_range)(vaddr_t, vsize_t); + void (*_dcache_wb_range)(vaddr_t, vsize_t); +}; + +/* Cache configurations */ +#define sh_cache_enable_unified sh_cache_enable_icache +extern int sh_cache_enable_icache; +extern int sh_cache_enable_dcache; +extern int sh_cache_write_through; +extern int sh_cache_write_through_p0_u0_p3; +extern int sh_cache_write_through_p1; +extern int sh_cache_ways; +extern int sh_cache_unified; +#define sh_cache_size_unified sh_cache_size_icache +extern int sh_cache_size_icache; +extern int sh_cache_size_dcache; +extern int sh_cache_line_size; +/* for n-way set associative cache */ +extern int sh_cache_way_size; +extern int sh_cache_way_shift; +extern int sh_cache_entry_mask; + +/* Special mode */ +extern int sh_cache_ram_mode; +extern int sh_cache_index_mode_icache; +extern int sh_cache_index_mode_dcache; + +extern struct sh_cache_ops sh_cache_ops; + +#define sh_icache_sync_all() \ + (*sh_cache_ops._icache_sync_all)() + +#define sh_icache_sync_range(v, s) \ + (*sh_cache_ops._icache_sync_range)((v), (s)) + +#define sh_icache_sync_range_index(v, s) \ + (*sh_cache_ops._icache_sync_range_index)((v), (s)) + +#define sh_dcache_wbinv_all() \ + (*sh_cache_ops._dcache_wbinv_all)() + +#define sh_dcache_wbinv_range(v, s) \ + (*sh_cache_ops._dcache_wbinv_range)((v), (s)) + +#define sh_dcache_wbinv_range_index(v, s) \ + (*sh_cache_ops._dcache_wbinv_range_index)((v), (s)) + +#define sh_dcache_inv_range(v, s) \ + (*sh_cache_ops._dcache_inv_range)((v), (s)) + +#define sh_dcache_wb_range(v, s) \ + (*sh_cache_ops._dcache_wb_range)((v), (s)) + +void sh_cache_init(void); +void sh_cache_information(void); + +#define SH_HAS_UNIFIED_CACHE CPU_IS_SH3 +#define SH_HAS_VIRTUAL_ALIAS CPU_IS_SH4 +#define SH_HAS_WRITEBACK_CACHE (!sh_cache_write_through) + +#endif /* _KERNEL */ +#endif /* _SH_CACHE_H_ */ diff --git a/sys/arch/sh/include/cache_sh3.h b/sys/arch/sh/include/cache_sh3.h new file mode 100644 index 00000000000..b51e1c469b5 --- /dev/null +++ b/sys/arch/sh/include/cache_sh3.h @@ -0,0 +1,159 @@ +/* $OpenBSD: cache_sh3.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: cache_sh3.h,v 1.8 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +/* + * SH3: SH7708, SH7708S, SH7708R, SH7709, SH7709A + */ +#ifndef _SH_CACHE_SH3_H_ +#define _SH_CACHE_SH3_H_ +#include <sh/devreg.h> +#ifdef _KERNEL + +#define SH3_CCR 0xffffffec +#define SH3_CCR_CE 0x00000001 +#define SH3_CCR_WT 0x00000002 +/* SH7708 don't have CB bit */ +#define SH3_CCR_CB 0x00000004 +#define SH3_CCR_CF 0x00000008 +/* SH7709A don't have RA bit */ +#define SH3_CCR_RA 0x00000020 + +/* SH7709A specific cache-lock control register */ +#define SH7709A_CCR2 0xa40000b0 +#define SH7709A_CCR2_W2LOCK 0x00000001 +#define SH7709A_CCR2_W2LOAD 0x00000002 +#define SH7709A_CCR2_W3LOCK 0x00000100 +#define SH7709A_CCR2_W3LOAD 0x00000200 + +#define SH3_CCA 0xf0000000 +/* Address specification */ +#define CCA_A 0x00000008 +#define CCA_ENTRY_SHIFT 4 +/* 8KB cache (SH7708, SH7708S, SH7708R, SH7709) */ +#define CCA_8K_ENTRY 128 +#define CCA_8K_ENTRY_MASK 0x000007f0 /* [10:4] */ +#define CCA_8K_WAY_SHIFT 11 +#define CCA_8K_WAY_MASK 0x00001800 /* [12:11] */ +/* 16KB cache (SH7709A) */ +#define CCA_16K_ENTRY 256 +#define CCA_16K_ENTRY_MASK 0x00000ff0 /* [11:4] */ +#define CCA_16K_WAY_SHIFT 12 +#define CCA_16K_WAY_MASK 0x00003000 /* [13:12] */ + +/* Data specification */ +#define CCA_V 0x00000001 +#define CCA_U 0x00000002 +#define CCA_LRU_SHIFT 4 +#define CCA_LRU_MASK 0x000003f0 /* [9:4] */ +#define CCA_TAGADDR_SHIFT 10 +#define CCA_TAGADDR_MASK 0xfffffc00 /* [31:10] */ + +#define SH3_CCD 0xf1000000 +/* Address specification */ +#define CCD_L_SHIFT 2 +#define CCD_L_MASK 0x0000000c /* [3:2] */ +#define CCD_E_SHIFT 4 +#define CCD_8K_E_MASK 0x000007f0 /* [10:4] */ +#define CCD_16K_E_MASK 0x00000ff0 /* [11:4] */ +#define CCD_8K_W_SHIFT 11 +#define CCD_8K_W_MASK 0x00001800 /* [12:11] */ +#define CCD_16K_W_SHIFT 12 +#define CCD_16K_W_MASK 0x00003000 /* [13:12] */ +/* Data specification */ + +/* + * Configuration + */ +#define SH3_CACHE_LINESZ 16 +#define SH3_CACHE_NORMAL_WAY 4 +#define SH3_CACHE_RAMMODE_WAY 2 + +#define SH3_CACHE_8K_ENTRY 128 +#define SH3_CACHE_8K_WAY_NORMAL 4 +#define SH3_CACHE_8K_WAY_RAMMODE 2 + +#define SH3_CACHE_16K_ENTRY 256 +#define SH3_CACHE_16K_WAY 4 + +/* + * cache flush macro for locore level code. + */ +#define SH3_CACHE_8K_FLUSH(maxway) \ +do { \ + uint32_t __e, __w, __wa, __a; \ + \ + for (__w = 0; __w < maxway; __w++) { \ + __wa = SH3_CCA | __w << CCA_8K_WAY_SHIFT; \ + for (__e = 0; __e < CCA_8K_ENTRY; __e++) { \ + __a = __wa |(__e << CCA_ENTRY_SHIFT); \ + (*(volatile uint32_t *)__a) &= \ + ~(CCA_U | CCA_V); \ + } \ + } \ +} while (/*CONSTCOND*/0) + +#define SH3_CACHE_16K_FLUSH() \ +do { \ + uint32_t __e, __w, __wa, __a; \ + \ + for (__w = 0; __w < SH3_CACHE_16K_WAY; __w++) { \ + __wa = SH3_CCA | __w << CCA_16K_WAY_SHIFT; \ + for (__e = 0; __e < CCA_16K_ENTRY; __e++) { \ + __a = __wa |(__e << CCA_ENTRY_SHIFT); \ + (*(volatile uint32_t *)__a) &= \ + ~(CCA_U | CCA_V); \ + } \ + } \ +} while (/*CONSTCOND*/0) + +#define SH7708_CACHE_FLUSH() SH3_CACHE_8K_FLUSH(4) +#define SH7708_CACHE_FLUSH_RAMMODE() SH3_CACHE_8K_FLUSH(2) +#define SH7708S_CACHE_FLUSH() SH3_CACHE_8K_FLUSH(4) +#define SH7708S_CACHE_FLUSH_RAMMODE() SH3_CACHE_8K_FLUSH(2) +#define SH7708R_CACHE_FLUSH() SH3_CACHE_8K_FLUSH(4) +#define SH7708R_CACHE_FLUSH_RAMMODE() SH3_CACHE_8K_FLUSH(2) +#define SH7709_CACHE_FLUSH() SH3_CACHE_8K_FLUSH(4) +#define SH7709_CACHE_FLUSH_RAMMODE() SH3_CACHE_8K_FLUSH(2) +#define SH7709A_CACHE_FLUSH() SH3_CACHE_16K_FLUSH() + +#ifndef _LOCORE +extern void sh3_cache_config(void); +#endif +#endif /* _KERNEL */ +#endif /* !_SH_CACHE_SH3_H_ */ diff --git a/sys/arch/sh/include/cache_sh4.h b/sys/arch/sh/include/cache_sh4.h new file mode 100644 index 00000000000..dfc5ff14434 --- /dev/null +++ b/sys/arch/sh/include/cache_sh4.h @@ -0,0 +1,155 @@ +/* $OpenBSD: cache_sh4.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: cache_sh4.h,v 1.11 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +/* + * SH4: SH7750 SH7750S SH7750R SH7751 SH7751R + */ + +#ifndef _SH_CACHE_SH4_H_ +#define _SH_CACHE_SH4_H_ +#include <sh/devreg.h> +#ifdef _KERNEL + +#define SH4_ICACHE_SIZE 8192 +#define SH4_DCACHE_SIZE 16384 +#define SH4_EMODE_ICACHE_SIZE 16384 +#define SH4_EMODE_DCACHE_SIZE 32768 +#define SH4_CACHE_LINESZ 32 + +#define SH4_CCR 0xff00001c +#define SH4_CCR_EMODE 0x80000000 +#define SH4_CCR_IIX 0x00008000 +#define SH4_CCR_ICI 0x00000800 +#define SH4_CCR_ICE 0x00000100 +#define SH4_CCR_OIX 0x00000080 +#define SH4_CCR_ORA 0x00000020 +#define SH4_CCR_OCI 0x00000008 +#define SH4_CCR_CB 0x00000004 +#define SH4_CCR_WT 0x00000002 +#define SH4_CCR_OCE 0x00000001 + +#define SH4_QACR0 0xff000038 +#define SH4_QACR1 0xff00003c +#define SH4_QACR_AREA_SHIFT 2 +#define SH4_QACR_AREA_MASK 0x0000001c + +/* I-cache address/data array */ +#define SH4_CCIA 0xf0000000 +/* address specification */ +#define CCIA_A 0x00000008 /* associate bit */ +#define CCIA_ENTRY_SHIFT 5 /* line size 32B */ +#define CCIA_ENTRY_MASK 0x00001fe0 /* [12:5] 256-entries */ +#define CCIA_EMODE_ENTRY_MASK 0x00003fe0 /* [13:5] 512-entries */ +/* data specification */ +#define CCIA_V 0x00000001 +#define CCIA_TAGADDR_MASK 0xfffffc00 /* [31:10] */ + +#define SH4_CCID 0xf1000000 +/* address specification */ +#define CCID_L_SHIFT 2 +#define CCID_L_MASK 0x1c /* line-size is 32B */ +#define CCID_ENTRY_MASK 0x00001fe0 /* [12:5] 256-entries */ + +/* D-cache address/data array */ +#define SH4_CCDA 0xf4000000 +/* address specification */ +#define CCDA_A 0x00000008 /* associate bit */ +#define CCDA_ENTRY_SHIFT 5 /* line size 32B */ +#define CCDA_ENTRY_MASK 0x00003fe0 /* [13:5] 512-entries */ +/* data specification */ +#define CCDA_V 0x00000001 +#define CCDA_U 0x00000002 +#define CCDA_TAGADDR_MASK 0xfffffc00 /* [31:10] */ + +#define SH4_CCDD 0xf5000000 + +/* Store Queue */ +#define SH4_SQ 0xe0000000 + +/* + * cache flush macro for locore level code. + */ +#define SH4_CACHE_FLUSH() \ +do { \ + uint32_t __e, __a; \ + \ + /* D-cache */ \ + for (__e = 0; __e < (SH4_DCACHE_SIZE / SH4_CACHE_LINESZ); __e++) {\ + __a = SH4_CCDA | (__e << CCDA_ENTRY_SHIFT); \ + (*(volatile uint32_t *)__a) &= ~(CCDA_U | CCDA_V); \ + } \ + /* I-cache */ \ + for (__e = 0; __e < (SH4_ICACHE_SIZE / SH4_CACHE_LINESZ); __e++) {\ + __a = SH4_CCIA | (__e << CCIA_ENTRY_SHIFT); \ + (*(volatile uint32_t *)__a) &= ~(CCIA_V); \ + } \ +} while(/*CONSTCOND*/0) + +#define SH4_EMODE_CACHE_FLUSH() \ +do { \ + uint32_t __e, __a; \ + \ + /* D-cache */ \ + for (__e = 0;__e < (SH4_EMODE_DCACHE_SIZE / SH4_CACHE_LINESZ);__e++) {\ + __a = SH4_CCDA | (__e << CCDA_ENTRY_SHIFT); \ + (*(volatile uint32_t *)__a) &= ~(CCDA_U | CCDA_V); \ + } \ + /* I-cache */ \ + for (__e = 0;__e < (SH4_EMODE_ICACHE_SIZE / SH4_CACHE_LINESZ);__e++) {\ + __a = SH4_CCIA | (__e << CCIA_ENTRY_SHIFT); \ + (*(volatile uint32_t *)__a) &= ~(CCIA_V); \ + } \ +} while(/*CONSTCOND*/0) + +#define SH7750_CACHE_FLUSH() SH4_CACHE_FLUSH() +#define SH7750S_CACHE_FLUSH() SH4_CACHE_FLUSH() +#define SH7751_CACHE_FLUSH() SH4_CACHE_FLUSH() +#if defined(SH4_CACHE_DISABLE_EMODE) +#define SH7750R_CACHE_FLUSH() SH4_CACHE_FLUSH() +#define SH7751R_CACHE_FLUSH() SH4_CACHE_FLUSH() +#else +#define SH7750R_CACHE_FLUSH() SH4_EMODE_CACHE_FLUSH() +#define SH7751R_CACHE_FLUSH() SH4_EMODE_CACHE_FLUSH() +#endif + +#ifndef _LOCORE +extern void sh4_cache_config(void); +#endif +#endif /* _KERNEL */ +#endif /* !_SH_CACHE_SH4_H_ */ diff --git a/sys/arch/sh/include/cdefs.h b/sys/arch/sh/include/cdefs.h new file mode 100644 index 00000000000..eb7c7eb3761 --- /dev/null +++ b/sys/arch/sh/include/cdefs.h @@ -0,0 +1,19 @@ +/* $OpenBSD: cdefs.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ + +#ifndef _SH_CDEFS_H_ +#define _SH_CDEFS_H_ + +#if defined(lint) +#define __indr_reference(sym,alias) __lint_equal__(sym,alias) +#define __warn_references(sym,msg) +#define __weak_alias(alias,sym) __lint_equal__(sym,alias) +#elif defined(__GNUC__) && defined(__STDC__) +#define __weak_alias(alias,sym) \ + __asm__(".weak " __STRING(alias) " ; " __STRING(alias) \ + " = " __STRING(sym)) +#define __warn_references(sym,msg) \ + __asm__(".section .gnu.warning." __STRING(sym) \ + " ; .ascii \"" msg "\" ; .text") +#endif + +#endif /* !_SH_CDEFS_H_ */ diff --git a/sys/arch/sh/include/clock.h b/sys/arch/sh/include/clock.h new file mode 100644 index 00000000000..80a3167b639 --- /dev/null +++ b/sys/arch/sh/include/clock.h @@ -0,0 +1,90 @@ +/* $OpenBSD: clock.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: clock.h,v 1.2 2002/04/28 17:10:33 uch Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +/* + * void sh_clock_init(int flags, struct rtc_ops *): + * flags: + * SH_CLOCK_NORTC ... If SH RTC module is disabled, set this. + * internal module don't use RTCCLK. + * SH_CLOCK_NOINITTODR ... Don't initialize RTC time. + * rtc_ops: + * Machine dependent RTC ops pointer. If NULL is specified, use SH + * internal RTC. + * + * void machine_clock_init(void): + * Implement machine specific part of clock routines. + * must call sh_clock_init() at exit. + * + * int sh_clock_get_cpuclock(void): + * returns CPU clock estimated by sh_clock_init(). + * + * int sh_clock_get_pclock(void): + * returns PCLOCK. when PCLOCK is not specified by kernel configuration + * file, this value is estimated by sh_clock_init(). + * + */ +struct rtc_ops; +struct clock_ymdhms; + +void sh_clock_init(int, struct rtc_ops *); +#define SH_CLOCK_NORTC 0x00000001 +#define SH_CLOCK_NOINITTODR 0x00000002 +void machine_clock_init(void); + +int sh_clock_get_cpuclock(void); +int sh_clock_get_pclock(void); + +/* + * SH RTC module interface. + */ +void sh_rtc_init(void *); +void sh_rtc_get(void *, time_t, struct clock_ymdhms *); +void sh_rtc_set(void *, struct clock_ymdhms *); + +/* + * machine specific RTC ops + */ +struct clock_ymdhms; +struct rtc_ops { + void *_cookie; + void (*init)(void *); + void (*get)(void *, time_t, struct clock_ymdhms *); + void (*set)(void *, struct clock_ymdhms *); +}; + diff --git a/sys/arch/sh/include/cpgreg.h b/sys/arch/sh/include/cpgreg.h new file mode 100644 index 00000000000..2e7d5694295 --- /dev/null +++ b/sys/arch/sh/include/cpgreg.h @@ -0,0 +1,48 @@ +/* $OpenBSD: cpgreg.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: cpgreg.h,v 1.5 2002/04/28 17:10:34 uch Exp $ */ + +/*- + * Copyright (C) 1999 SAITOH Masanobu. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_CPGREG_H_ +#define _SH_CPGREG_H_ + +/* + * Clock Pulse Generator + */ +#define SH3_FRQCR 0xffffff80 /* 16bit */ +#define SH4_FRQCR 0xffc00000 /* 16bit */ + +/* + * Standby Control + */ +#define SH3_STBCR 0xffffff82 /* 8bit */ +#define SH7709_STBCR2 0xffffff88 /* 8bit */ + +#define SH4_STBCR 0xffc00004 /* 8bit */ +#define SH4_STBCR2 0xffc00010 /* 8bit */ + +#endif /* !_SH_CPGREG_H_ */ diff --git a/sys/arch/sh/include/cpu.h b/sys/arch/sh/include/cpu.h new file mode 100644 index 00000000000..682ab233eaa --- /dev/null +++ b/sys/arch/sh/include/cpu.h @@ -0,0 +1,213 @@ +/* $OpenBSD: cpu.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 + */ + +/* + * SH3/SH4 support. + * + * T.Horiuchi Brains Corp. 5/22/98 + */ + +#ifndef _SH_CPU_H_ +#define _SH_CPU_H_ + +#include <sh/psl.h> +#include <sh/frame.h> + +#ifdef _KERNEL + +/* + * Can't swapout u-area, (__SWAP_BROKEN) + * since we use P1 converted address for trapframe. + */ +#define cpu_swapin(p) /* nothing */ +#define cpu_swapout(p) /* nothing */ + +/* + * Arguments to hardclock and gatherstats encapsulate the previous + * machine state in an opaque clockframe. + */ +struct clockframe { + int spc; /* program counter at time of interrupt */ + int ssr; /* status register at time of interrupt */ + int ssp; /* stack pointer at time of interrupt */ +}; + +#define CLKF_USERMODE(cf) (!KERNELMODE((cf)->ssr)) +#define CLKF_BASEPRI(cf) (((cf)->ssr & 0xf0) == 0) +#define CLKF_PC(cf) ((cf)->spc) +#define CLKF_INTR(cf) 0 /* XXX */ + +/* + * This is used during profiling to integrate system time. It can safely + * assume that the process is resident. + */ +#define PROC_PC(p) \ + (((struct trapframe *)(p)->p_md.md_regs)->tf_spc) + +/* + * Preempt the current process if in interrupt from user mode, + * or after the current trap/syscall if in system mode. + */ +#define need_resched(ci) \ +do { \ + want_resched = 1; \ + if (curproc != NULL) \ + aston(curproc); \ +} while (/*CONSTCOND*/0) + +/* + * Give a profiling tick to the current process when the user profiling + * buffer pages are invalid. On the MIPS, request an ast to send us + * through trap, marking the proc as needing a profiling tick. + */ +#define need_proftick(p) \ +do { \ + (p)->p_flag |= P_OWEUPC; \ + aston(p); \ +} while (/*CONSTCOND*/0) + +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define signotify(p) aston(p) + +#define aston(p) ((p)->p_md.md_astpending = 1) + +extern int want_resched; /* need_resched() was called */ + +/* + * We need a machine-independent name for this. + */ +#define DELAY(x) delay(x) +#endif /* _KERNEL */ + +/* + * Logical address space of SH3/SH4 CPU. + */ +#define SH3_PHYS_MASK 0x1fffffff + +#define SH3_P0SEG_BASE 0x00000000 /* TLB mapped, also U0SEG */ +#define SH3_P0SEG_END 0x7fffffff +#define SH3_P1SEG_BASE 0x80000000 /* pa == va */ +#define SH3_P1SEG_END 0x9fffffff +#define SH3_P2SEG_BASE 0xa0000000 /* pa == va, non-cacheable */ +#define SH3_P2SEG_END 0xbfffffff +#define SH3_P3SEG_BASE 0xc0000000 /* TLB mapped, kernel mode */ +#define SH3_P3SEG_END 0xdfffffff +#define SH3_P4SEG_BASE 0xe0000000 /* peripheral space */ +#define SH3_P4SEG_END 0xffffffff + +#define SH3_P1SEG_TO_PHYS(x) ((uint32_t)(x) & SH3_PHYS_MASK) +#define SH3_P2SEG_TO_PHYS(x) ((uint32_t)(x) & SH3_PHYS_MASK) +#define SH3_PHYS_TO_P1SEG(x) ((uint32_t)(x) | SH3_P1SEG_BASE) +#define SH3_PHYS_TO_P2SEG(x) ((uint32_t)(x) | SH3_P2SEG_BASE) +#define SH3_P1SEG_TO_P2SEG(x) ((uint32_t)(x) | 0x20000000) +#define SH3_P2SEG_TO_P1SEG(x) ((uint32_t)(x) & ~0x20000000) + +#ifdef _KERNEL +#ifndef __lint__ + +/* switch from P1 to P2 */ +#define RUN_P2 do { \ + void *p; \ + p = &&P2; \ + goto *(void *)SH3_P1SEG_TO_P2SEG(p); \ + P2: (void)0; \ + } while (0) + +/* switch from P2 to P1 */ +#define RUN_P1 do { \ + void *p; \ + p = &&P1; \ + __asm volatile("nop;nop;nop;nop;nop;nop;nop;nop"); \ + goto *(void *)SH3_P2SEG_TO_P1SEG(p); \ + P1: (void)0; \ + } while (0) + +#else /* __lint__ */ +#define RUN_P2 do {} while (/* CONSTCOND */ 0) +#define RUN_P1 do {} while (/* CONSTCOND */ 0) +#endif +#endif + +#if defined(SH4) +/* SH4 Processor Version Register */ +#define SH4_PVR_ADDR 0xff000030 /* P4 address */ +#define SH4_PVR (*(volatile uint32_t *) SH4_PVR_ADDR) +#define SH4_PRR_ADDR 0xff000044 /* P4 address */ +#define SH4_PRR (*(volatile uint32_t *) SH4_PRR_ADDR) + +#define SH4_PVR_MASK 0xffffff00 +#define SH4_PVR_SH7750 0x04020500 /* SH7750 */ +#define SH4_PVR_SH7750S 0x04020600 /* SH7750S */ +#define SH4_PVR_SH775xR 0x04050000 /* SH775xR */ +#define SH4_PVR_SH7751 0x04110000 /* SH7751 */ + +#define SH4_PRR_MASK 0xfffffff0 +#define SH4_PRR_7750R 0x00000100 /* SH7750R */ +#define SH4_PRR_7751R 0x00000110 /* SH7751R */ +#endif + +/* + * pull in #defines for kinds of processors + */ +#include <machine/cputypes.h> + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_CONSDEV 1 /* dev_t: console terminal device */ +#define CPU_MAXID 2 /* number of valid machdep ids */ + +#define CTL_MACHDEP_NAMES { \ + { 0, 0 }, \ + { "console_device", CTLTYPE_STRUCT }, \ +} + +#ifdef _KERNEL +void sh_cpu_init(int, int); +void sh_startup(void); +__dead void cpu_reset(void); /* soft reset */ +void _cpu_spin(uint32_t); /* for delay loop. */ +void delay(int); +struct pcb; +void savectx(struct pcb *); +void dumpsys(void); +#endif /* _KERNEL */ +#endif /* !_SH_CPU_H_ */ diff --git a/sys/arch/sh/include/cputypes.h b/sys/arch/sh/include/cputypes.h new file mode 100644 index 00000000000..5befc6321c6 --- /dev/null +++ b/sys/arch/sh/include/cputypes.h @@ -0,0 +1,79 @@ +/* $OpenBSD: cputypes.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: cputypes.h,v 1.10 2006/01/21 00:40:36 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * 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 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. + */ + +#ifndef _SH_CPUTYPES_H_ +#define _SH_CPUTYPES_H_ + +#ifdef _KERNEL + +#define CPU_ARCH_SH3 3 +#define CPU_ARCH_SH4 4 + +/* SH3 series */ +#define CPU_PRODUCT_7708 1 +#define CPU_PRODUCT_7708S 2 +#define CPU_PRODUCT_7708R 3 +#define CPU_PRODUCT_7709 4 +#define CPU_PRODUCT_7709A 5 + +/* SH4 series */ +#define CPU_PRODUCT_7750 6 +#define CPU_PRODUCT_7750S 7 +#define CPU_PRODUCT_7750R 8 +#define CPU_PRODUCT_7751 9 +#define CPU_PRODUCT_7751R 10 + + +#ifndef _LOCORE +extern int cpu_arch; +extern int cpu_product; +#if defined(SH3) && defined(SH4) +#define CPU_IS_SH3 (cpu_arch == CPU_ARCH_SH3) +#define CPU_IS_SH4 (cpu_arch == CPU_ARCH_SH4) +#elif defined(SH3) +#define CPU_IS_SH3 (/* CONSTCOND */1) +#define CPU_IS_SH4 (/* CONSTCOND */0) +#elif defined(SH4) +#define CPU_IS_SH3 (/* CONSTCOND */0) +#define CPU_IS_SH4 (/* CONSTCOND */1) +#else +#error "define SH3 and/or SH4" +#endif +#endif /* !_LOCORE */ + +#endif /* _KERNEL */ + +#endif /* !_SH_CPUTYPES_H_ */ diff --git a/sys/arch/sh/include/db_machdep.h b/sys/arch/sh/include/db_machdep.h new file mode 100644 index 00000000000..10afa9cf335 --- /dev/null +++ b/sys/arch/sh/include/db_machdep.h @@ -0,0 +1,83 @@ +/* $OpenBSD: db_machdep.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: db_machdep.h,v 1.12 2006/05/10 06:24:03 skrll Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#ifndef _SH_DB_MACHDEP_H_ +#define _SH_DB_MACHDEP_H_ + +/* + * Machine-dependent defines for the kernel debugger. + */ + +#include <sys/param.h> +#include <uvm/uvm_extern.h> +#include <sh/trap.h> + +typedef vaddr_t db_addr_t; /* address - unsigned */ +typedef long db_expr_t; /* expression - signed */ + +typedef struct trapframe db_regs_t; +extern db_regs_t ddb_regs; /* register state */ +#define DDB_REGS (&ddb_regs) + +#define PC_REGS(regs) ((db_addr_t)(regs)->tf_spc) +#define PC_ADVANCE(regs) ((regs)->tf_spc += BKPT_SIZE) + +#define BKPT_INST 0xc3c3 /* breakpoint instruction */ +#define BKPT_SIZE 2 /* size of breakpoint inst */ +#define BKPT_SET(inst) BKPT_INST + +#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_spc -= BKPT_SIZE) + +#define IS_BREAKPOINT_TRAP(type, code) ((type) == EXPEVT_BREAK) +#define IS_WATCHPOINT_TRAP(type, code) (0) /* XXX (msaitoh) */ + +#define inst_load(ins) 0 +#define inst_store(ins) 0 + +/* macro for checking if a thread has used floating-point */ +#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0) + +int kdb_trap(int, int, db_regs_t *); +boolean_t inst_call(int); +boolean_t inst_return(int); +boolean_t inst_trap_return(int); + +/* + * We use ELF symbols in DDB. + * + */ +#define DB_ELF_SYMBOLS +#define DB_ELFSIZE 32 + +/* + * We have machine-dependent commands. + */ +#define DB_MACHINE_COMMANDS + +#endif /* !_SH_DB_MACHDEP_H_ */ diff --git a/sys/arch/sh/include/devreg.h b/sys/arch/sh/include/devreg.h new file mode 100644 index 00000000000..37886f04a7b --- /dev/null +++ b/sys/arch/sh/include/devreg.h @@ -0,0 +1,83 @@ +/* $OpenBSD: devreg.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: devreg.h,v 1.5 2006/01/21 04:57:07 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * 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 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. + */ + +#ifndef _SH_DEVREG_H_ +#define _SH_DEVREG_H_ +/* + * SH embeded device register defines. + */ + +/* + * Access method + */ +#define _reg_read_1(a) (*(volatile uint8_t *)((vaddr_t)(a))) +#define _reg_read_2(a) (*(volatile uint16_t *)((vaddr_t)(a))) +#define _reg_read_4(a) (*(volatile uint32_t *)((vaddr_t)(a))) +#define _reg_write_1(a, v) \ + (*(volatile uint8_t *)(a) = (uint8_t)(v)) +#define _reg_write_2(a, v) \ + (*(volatile uint16_t *)(a) = (uint16_t)(v)) +#define _reg_write_4(a, v) \ + (*(volatile uint32_t *)(a) = (uint32_t)(v)) +#define _reg_bset_1(a, v) \ + (*(volatile uint8_t *)(a) |= (uint8_t)(v)) +#define _reg_bset_2(a, v) \ + (*(volatile uint16_t *)(a) |= (uint16_t)(v)) +#define _reg_bset_4(a, v) \ + (*(volatile uint32_t *)(a) |= (uint32_t)(v)) +#define _reg_bclr_1(a, v) \ + (*(volatile uint8_t *)(a) &= ~(uint8_t)(v)) +#define _reg_bclr_2(a, v) \ + (*(volatile uint16_t *)(a) &= ~(uint16_t)(v)) +#define _reg_bclr_4(a, v) \ + (*(volatile uint32_t *)(a) &= ~(uint32_t)(v)) + +/* + * Register address. + */ +#if defined(SH3) && defined(SH4) +#define SH_(x) __sh_ ## x +#elif defined(SH3) +#define SH_(x) SH3_ ## x +#elif defined(SH4) +#define SH_(x) SH4_ ## x +#endif + +#ifndef _LOCORE +/* Initialize register address for SH3 && SH4 kernel. */ +void sh_devreg_init(void); +#endif +#endif /* !_SH_DEVREG_H_ */ diff --git a/sys/arch/sh/include/disklabel.h b/sys/arch/sh/include/disklabel.h new file mode 100644 index 00000000000..0b61abbc41a --- /dev/null +++ b/sys/arch/sh/include/disklabel.h @@ -0,0 +1,112 @@ +/* $OpenBSD: disklabel.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: disklabel.h,v 1.2 2001/11/25 19:02:03 thorpej Exp $ */ + +/* + * Copyright (c) 1994 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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 Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * RiscBSD kernel project + * + * disklabel.h + * + * machine specific disk label info + * + * Created : 04/10/94 + */ + +#ifndef _ARM_DISKLABEL_H_ +#define _ARM_DISKLABEL_H_ + +#define LABELSECTOR 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#include <sys/dkbad.h> +#if 0 +#include <arm/disklabel_acorn.h> +#include <sys/disklabel_mbr.h> +#endif + +/* MBR partition table */ +#define DOSBBSECTOR 0 /* MBR sector number */ +#define DOSPARTOFF 446 /* Offset of MBR partition table */ +#define NDOSPART 4 /* # of partitions in MBR */ +#define DOSMAGICOFF 510 /* Offset of magic number */ +#define DOSMAGIC 0xaa55 /* Actual magic number */ +#define MBRMAGIC DOSMAGIC +#define DOSMBR_SIGNATURE MBRMAGIC +#define DOSMBR_SIGNATURE_OFF DOSMAGICOFF +#define DOSACTIVE 0x80 + + +struct dos_partition { + u_int8_t dp_flag; /* bootstrap flags */ + u_int8_t dp_shd; /* starting head */ + u_int8_t dp_ssect; /* starting sector */ + u_int8_t dp_scyl; /* starting cylinder */ + u_int8_t dp_typ; /* partition type (see below) */ + u_int8_t dp_ehd; /* end head */ + u_int8_t dp_esect; /* end sector */ + u_int8_t dp_ecyl; /* end cylinder */ + u_int32_t dp_start; /* absolute starting sector number */ + u_int32_t dp_size; /* partition size in sectors */ +}; + +/* Known DOS partition types. */ +#define DOSPTYP_UNUSED 0x00 /* Unused partition */ +#define DOSPTYP_FAT12 0x01 /* 12-bit FAT */ +#define DOSPTYP_FAT16S 0x04 /* 16-bit FAT, less than 32M */ +#define DOSPTYP_EXTEND 0x05 /* Extended; contains sub-partitions */ +#define DOSPTYP_FAT16B 0x06 /* 16-bit FAT, more than 32M */ +#define DOSPTYP_FAT32 0x0b /* 32-bit FAT */ +#define DOSPTYP_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */ +#define DOSPTYP_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */ +#define DOSPTYP_EXTENDL 0x0f /* Extended, LBA-mapped; contains sub-partitions */ +#define DOSPTYP_ONTRACK 0x54 +#define DOSPTYP_LINUX 0x83 /* That other thing */ +#define DOSPTYP_FREEBSD 0xa5 /* FreeBSD partition type */ +#define DOSPTYP_OPENBSD 0xa6 /* OpenBSD partition type */ +#define DOSPTYP_NETBSD 0xa9 /* NetBSD partition type */ + +/* Isolate the relevant bits to get sector and cylinder. */ +#define DPSECT(s) ((s) & 0x3f) +#define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) + + +struct cpu_disklabel { + struct dos_partition dosparts[NDOSPART]; + struct dkbad bad; +}; + +#endif /* _ARM_DISKLABEL_H_ */ diff --git a/sys/arch/sh/include/endian.h b/sys/arch/sh/include/endian.h new file mode 100644 index 00000000000..9615f567cd1 --- /dev/null +++ b/sys/arch/sh/include/endian.h @@ -0,0 +1,43 @@ +/* $OpenBSD: endian.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: endian.h,v 1.4 2000/03/17 00:09:25 mycroft Exp $ */ + +/* Written by Manuel Bouyer. Public domain */ + +#ifndef _SH_ENDIAN_H_ +#define _SH_ENDIAN_H_ + +#ifdef __GNUC__ + +#define __swap64md __swap64gen + +#define __swap16md(x) ({ \ + uint16_t rval; \ + \ + __asm volatile ("swap.b %1,%0" : "=r"(rval) : "r"(x)); \ + \ + rval; \ +}) + +#define __swap32md(x) ({ \ + uint32_t rval; \ + \ + __asm volatile ("swap.b %1,%0; swap.w %0,%0; swap.b %0,%0" \ + : "=r"(rval) : "r"(x)); \ + \ + rval; \ +}) + +#define MD_SWAP + +#endif /* __GNUC_ */ + +#ifdef __LITTLE_ENDIAN__ +#define _BYTE_ORDER _LITTLE_ENDIAN +#else +#define _BYTE_ORDER _BIG_ENDIAN +#endif +#include <sys/endian.h> + +#define __STRICT_ALIGNMENT + +#endif /* !_SH_ENDIAN_H_ */ diff --git a/sys/arch/sh/include/exec.h b/sys/arch/sh/include/exec.h new file mode 100644 index 00000000000..2bf1c48d8ae --- /dev/null +++ b/sys/arch/sh/include/exec.h @@ -0,0 +1,70 @@ +/* $OpenBSD: exec.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.8 2002/04/28 17:10:34 uch Exp $ */ + +#define __LDPGSZ 4096 + +#define NATIVE_EXEC_ELF + +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#define ELF_TARG_CLASS ELFCLASS32 +#ifdef __LITTLE_ENDIAN__ +#define ELF_TARG_DATA ELFDATA2LSB +#else +#define ELF_TARG_DATA ELFDATA2MSB +#endif +#define ELF_TARG_MACH EM_SH + +#define _KERN_DO_ELF +#define _NLIST_DO_ELF + +/* + * SuperH ELF header flags. + */ +#define EF_SH_MACH_MASK 0x1f + +#define EF_SH_UNKNOWN 0x00 +#define EF_SH_SH1 0x01 +#define EF_SH_SH2 0x02 +#define EF_SH_SH3 0x03 +#define EF_SH_DSP 0x04 +#define EF_SH_SH3_DSP 0x05 +#define EF_SH_SH3E 0x08 +#define EF_SH_SH4 0x09 + +#define EF_SH_HAS_DSP(x) ((x) & EF_SH_DSP) +#define EF_SH_HAS_FP(x) ((x) & EF_SH_SH3E) + + +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_LOOP_START 36 +#define R_SH_LOOP_END 37 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 + +#define R_TYPE(name) __CONCAT(R_SH_,name) diff --git a/sys/arch/sh/include/float.h b/sys/arch/sh/include/float.h new file mode 100644 index 00000000000..b39dd8fe6ff --- /dev/null +++ b/sys/arch/sh/include/float.h @@ -0,0 +1,76 @@ +/* $OpenBSD: float.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ + +/* + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)float.h 7.1 (Berkeley) 5/8/90 + */ + +#ifndef _SH_FLOAT_H_ +#define _SH_FLOAT_H_ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +int __flt_rounds(void); +__END_DECLS + +#define FLT_RADIX 2 /* b */ +#define FLT_ROUNDS __flt_rounds() + +#define FLT_MANT_DIG 24 /* p */ +#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ +#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ +#define FLT_MIN_EXP (-125) /* emin */ +#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ +#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ +#define FLT_MAX_EXP 128 /* emax */ +#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ +#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503131E-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072014E-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX 1.7976931348623157E+308 +#define DBL_MAX_10_EXP 308 + +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON DBL_EPSILON +#define LDBL_DIG DBL_DIG +#define LDBL_MIN_EXP DBL_MIN_EXP +#define LDBL_MIN DBL_MIN +#define LDBL_MIN_10_EXP DBL_MIN_10_EXP +#define LDBL_MAX_EXP DBL_MAX_EXP +#define LDBL_MAX DBL_MAX +#define LDBL_MAX_10_EXP DBL_MAX_10_EXP + +#endif /* _SH_FLOAT_H_ */ diff --git a/sys/arch/sh/include/frame.h b/sys/arch/sh/include/frame.h new file mode 100644 index 00000000000..fd7176d829a --- /dev/null +++ b/sys/arch/sh/include/frame.h @@ -0,0 +1,130 @@ +/* $OpenBSD: frame.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: frame.h,v 1.14 2005/12/11 12:18:58 christos Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)frame.h 5.2 (Berkeley) 1/18/91 + */ + +/*- + * Copyright (c) 1995 Charles M. Hannum. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. 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. + * + * @(#)frame.h 5.2 (Berkeley) 1/18/91 + */ + +#ifndef _SH_FRAME_H_ +#define _SH_FRAME_H_ + +#include <sys/signal.h> + +/* + * Exception Stack Frame + */ +struct trapframe { + /* software member */ + int tf_expevt; + int tf_ubc; + /* hardware registers */ + int tf_spc; + int tf_ssr; + int tf_macl; + int tf_mach; + int tf_pr; + int tf_r13; + int tf_r12; + int tf_r11; + int tf_r10; + int tf_r9; + int tf_r8; + int tf_r7; + int tf_r6; + int tf_r5; + int tf_r4; + int tf_r3; + int tf_r2; + int tf_r1; + int tf_r0; + int tf_r15; + int tf_r14; +}; + +/* + * Stack frame inside cpu_switch() + */ +struct switchframe { + int sf_r15; + int sf_r14; + int sf_r13; + int sf_r12; + int sf_r11; + int sf_r10; + int sf_r9; + int sf_r8; + int sf_pr; + int sf_r6_bank; + int sf_sr; + int sf_r7_bank; +}; + +#endif /* !_SH_FRAME_H_ */ diff --git a/sys/arch/sh/include/ieee.h b/sys/arch/sh/include/ieee.h new file mode 100644 index 00000000000..7ee46d82db4 --- /dev/null +++ b/sys/arch/sh/include/ieee.h @@ -0,0 +1,132 @@ +/* $OpenBSD: ieee.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ieee.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * ieee.h defines the machine-dependent layout of the machine's IEEE + * floating point. It does *not* define (yet?) any of the rounding + * mode bits, exceptions, and so forth. + */ + +/* + * Define the number of bits in each fraction and exponent. + * + * k k+1 + * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented + * + * (-exp_bias+1) + * as fractions that look like 0.fffff x 2 . This means that + * + * -126 + * the number 0.10000 x 2 , for instance, is the same as the normalized + * + * -127 -128 + * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero + * + * -129 + * in the fraction; to represent 2 , we need two, and so on. This + * + * (-exp_bias-fracbits+1) + * implies that the smallest denormalized number is 2 + * + * for whichever format we are talking about: for single precision, for + * + * -126 -149 + * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and + * + * -149 == -127 - 23 + 1. + */ +#define SNG_EXPBITS 8 +#define SNG_FRACBITS 23 + +#define DBL_EXPBITS 11 +#define DBL_FRACBITS 52 + +#define EXT_EXPBITS 15 +#define EXT_FRACBITS 112 + +struct ieee_single { + u_int sng_sign:1; + u_int sng_exp:8; + u_int sng_frac:23; +}; + +struct ieee_double { + u_int dbl_sign:1; + u_int dbl_exp:11; + u_int dbl_frach:20; + u_int dbl_fracl; +}; + +struct ieee_ext { + u_int ext_sign:1; + u_int ext_exp:15; + u_int ext_frach:16; + u_int ext_frachm; + u_int ext_fraclm; + u_int ext_fracl; +}; + +/* + * Floats whose exponent is in [1..INFNAN) (of whatever type) are + * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. + * Floats whose exponent is zero are either zero (iff all fraction + * bits are zero) or subnormal values. + * + * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its + * high fraction; if the bit is set, it is a `quiet NaN'. + */ +#define SNG_EXP_INFNAN 255 +#define DBL_EXP_INFNAN 2047 +#define EXT_EXP_INFNAN 32767 + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#define EXT_QUIETNAN (1 << 15) +#endif + +/* + * Exponent biases. + */ +#define SNG_EXP_BIAS 127 +#define DBL_EXP_BIAS 1023 +#define EXT_EXP_BIAS 16383 diff --git a/sys/arch/sh/include/ieeefp.h b/sys/arch/sh/include/ieeefp.h new file mode 100644 index 00000000000..141048038ad --- /dev/null +++ b/sys/arch/sh/include/ieeefp.h @@ -0,0 +1,27 @@ +/* $OpenBSD: ieeefp.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: ieeefp.h,v 1.3 2002/04/28 17:10:34 uch Exp $ */ + +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _SH_IEEEFP_H_ +#define _SH_IEEEFP_H_ + +typedef int fp_except; +#define FP_X_INV 0x01 /* invalid operation exception */ +#define FP_X_DNML 0x02 /* denormalization exception */ +#define FP_X_DZ 0x04 /* divide-by-zero exception */ +#define FP_X_OFL 0x08 /* overflow exception */ +#define FP_X_UFL 0x10 /* underflow exception */ +#define FP_X_IMP 0x20 /* imprecise (loss of precision) */ + +typedef enum { + FP_RN=0, /* round to nearest representable number */ + FP_RM=1, /* round toward negative infinity */ + FP_RP=2, /* round toward positive infinity */ + FP_RZ=3 /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_SH_IEEEFP_H_ */ diff --git a/sys/arch/sh/include/intcreg.h b/sys/arch/sh/include/intcreg.h new file mode 100644 index 00000000000..e69f31db7aa --- /dev/null +++ b/sys/arch/sh/include/intcreg.h @@ -0,0 +1,127 @@ +/* $OpenBSD: intcreg.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: intcreg.h,v 1.10 2005/12/11 12:18:58 christos Exp $ */ + +/*- + * Copyright (C) 1999 SAITOH Masanobu. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_INTCREG_H_ +#define _SH_INTCREG_H_ +#include <sh/devreg.h> + +/* + * INTC + */ +/* SH3 SH7708*, SH7709* common */ +#define SH3_ICR0 0xfffffee0 /* 16bit */ +#define SH3_IPRA 0xfffffee2 /* 16bit */ +#define SH3_IPRB 0xfffffee4 /* 16bit */ + +/* SH7709, SH7709A only */ +#define SH7709_ICR1 0xa4000010 /* 16bit */ +#define SH7709_ICR2 0xa4000012 /* 16bit */ +#define SH7709_PINTER 0xa4000014 /* 16bit */ +#define SH7709_IPRC 0xa4000016 /* 16bit */ +#define SH7709_IPRD 0xa4000018 /* 16bit */ +#define SH7709_IPRE 0xa400001a /* 16bit */ +#define SH7709_IRR0 0xa4000004 /* 8bit */ +#define SH7709_IRR1 0xa4000006 /* 8bit */ +#define SH7709_IRR2 0xa4000008 /* 8bit */ + +#define IPRC_IRQ3_MASK 0xf000 +#define IPRC_IRQ2_MASK 0x0f00 +#define IPRC_IRQ1_MASK 0x00f0 +#define IPRC_IRQ0_MASK 0x000f + +#define IPRD_PINT07_MASK 0xf000 +#define IPRD_PINT8F_MASK 0x0f00 +#define IPRD_IRQ5_MASK 0x00f0 +#define IPRD_IRQ4_MASK 0x000f + +#define IPRE_DMAC_MASK 0xf000 +#define IPRE_IRDA_MASK 0x0f00 +#define IPRE_SCIF_MASK 0x00f0 +#define IPRE_ADC_MASK 0x000f + +#define IRR0_PINT8F 0x80 +#define IRR0_PINT07 0x40 +#define IRR0_IRQ5 0x20 +#define IRR0_IRQ4 0x10 +#define IRR0_IRQ3 0x08 +#define IRR0_IRQ2 0x04 +#define IRR0_IRQ1 0x02 +#define IRR0_IRQ0 0x01 + + +/* SH4 */ +#define SH4_ICR 0xffd00000 /* 16bit */ +#define SH4_IPRA 0xffd00004 /* 16bit */ +#define SH4_IPRB 0xffd00008 /* 16bit */ +#define SH4_IPRC 0xffd0000c /* 16bit */ +#define SH4_IPRD 0xffd00010 /* 16bit */ +#define SH4_INTPRI00 0xfe080000 /* 32bit */ +#define SH4_INTREQ00 0xfe080020 /* 32bit */ +#define SH4_INTMSK00 0xfe080040 /* 32bit */ +#define SH4_INTMSKCLR00 0xfe080060 /* 32bit */ + +#define IPRC_GPIO_MASK 0xf000 +#define IPRC_DMAC_MASK 0x0f00 +#define IPRC_SCIF_MASK 0x00f0 +#define IPRC_HUDI_MASK 0x000f + +#define IPRD_IRL0_MASK 0xf000 +#define IPRD_IRL1_MASK 0x0f00 +#define IPRD_IRL2_MASK 0x00f0 +#define IPRD_IRL3_MASK 0x000f + +#define IPRA_TMU0_MASK 0xf000 +#define IPRA_TMU1_MASK 0x0f00 +#define IPRA_TMU2_MASK 0x00f0 +#define IPRA_RTC_MASK 0x000f + +#define IPRB_WDT_MASK 0xf000 +#define IPRB_REF_MASK 0x0f00 +#define IPRB_SCI_MASK 0x00f0 + +#define INTPRI00_PCI0_MASK 0x0000000f +#define INTPRI00_PCI1_MASK 0x000000f0 +#define INTPRI00_TMU3_MASK 0x00000f00 +#define INTPRI00_TMU4_MASK 0x0000f000 + +/* INTREQ/INTMSK/INTMSKCLR */ +#define INTREQ00_PCISERR 0x00000001 +#define INTREQ00_PCIDMA3 0x00000002 +#define INTREQ00_PCIDMA2 0x00000004 +#define INTREQ00_PCIDMA1 0x00000008 +#define INTREQ00_PCIDMA0 0x00000010 +#define INTREQ00_PCIPWON 0x00000020 +#define INTREQ00_PCIPWDWN 0x00000040 +#define INTREQ00_PCIERR 0x00000080 +#define INTREQ00_TUNI3 0x00000100 +#define INTREQ00_TUNI4 0x00000200 + +#define INTMSK00_MASK_ALL 0x000003ff + +#endif /* !_SH_INTCREG_H_ */ diff --git a/sys/arch/sh/include/internal_types.h b/sys/arch/sh/include/internal_types.h new file mode 100644 index 00000000000..1c6d5a40911 --- /dev/null +++ b/sys/arch/sh/include/internal_types.h @@ -0,0 +1,6 @@ +/* $OpenBSD: internal_types.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* Public domain */ +#ifndef _SH_INTERNAL_TYPES_H_ +#define _SH_INTERNAL_TYPES_H_ + +#endif diff --git a/sys/arch/sh/include/intr.h b/sys/arch/sh/include/intr.h new file mode 100644 index 00000000000..eabf78662ad --- /dev/null +++ b/sys/arch/sh/include/intr.h @@ -0,0 +1,145 @@ +/* $OpenBSD: intr.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: intr.h,v 1.22 2006/01/24 23:51:42 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * 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 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. + */ + +#ifndef _SH_INTR_H_ +#define _SH_INTR_H_ + +#ifdef _KERNEL + +#include <sys/device.h> +#include <sys/evcount.h> +#include <sys/lock.h> +#include <sys/queue.h> +#include <sh/psl.h> + +/* Interrupt sharing types. */ +#define IST_NONE 0 /* none */ +#define IST_PULSE 1 /* pulsed */ +#define IST_EDGE 2 /* edge-triggered */ +#define IST_LEVEL 3 /* level-triggered */ + +/* Interrupt priority levels */ +#define _IPL_N 15 +#define _IPL_NSOFT 4 + +#define IPL_NONE 0 /* nothing */ +#define IPL_SOFT 1 +#define IPL_SOFTCLOCK 2 /* timeouts */ +#define IPL_SOFTNET 3 /* protocol stacks */ +#define IPL_SOFTSERIAL 4 /* serial */ + +#define IPL_SOFTNAMES { \ + "misc", \ + "clock", \ + "net", \ + "serial", \ +} + +struct intc_intrhand { + int (*ih_func)(void *); + void *ih_arg; + int ih_level; /* SR.I[0:3] value */ + int ih_evtcode; /* INTEVT or INTEVT2(SH7709/SH7709A) */ + int ih_idx; /* evtcode -> intrhand mapping */ + struct evcount ih_count; +}; + +/* from 0x200 by 0x20 -> from 0 by 1 */ +#define EVTCODE_TO_MAP_INDEX(x) (((x) >> 5) - 0x10) +#define EVTCODE_TO_IH_INDEX(x) \ + __intc_evtcode_to_ih[EVTCODE_TO_MAP_INDEX(x)] +#define EVTCODE_IH(x) (&__intc_intrhand[EVTCODE_TO_IH_INDEX(x)]) +extern int8_t __intc_evtcode_to_ih[]; +extern struct intc_intrhand __intc_intrhand[]; + +void intc_init(void); +void *intc_intr_establish(int, int, int, int (*)(void *), void *, const char *); +void intc_intr_disestablish(void *); +void intc_intr_enable(int); +void intc_intr_disable(int); +void intc_intr(int, int, int); + +void intpri_intr_priority(int evtcode, int level); + +/* + * software simulated interrupt + */ +struct sh_soft_intrhand { + TAILQ_ENTRY(sh_soft_intrhand) sih_q; + struct sh_soft_intr *sih_intrhead; + void (*sih_fn)(void *); + void *sih_arg; + int sih_pending; +}; + +struct sh_soft_intr { + TAILQ_HEAD(, sh_soft_intrhand) softintr_q; + struct evcnt softintr_evcnt; + struct simplelock softintr_slock; + unsigned long softintr_ipl; +}; + +#define softintr_schedule(arg) \ +do { \ + struct sh_soft_intrhand *__sih = (arg); \ + struct sh_soft_intr *__si = __sih->sih_intrhead; \ + int __s; \ + \ + __s = _cpu_intr_suspend(); \ + simple_lock(&__si->softintr_slock); \ + if (__sih->sih_pending == 0) { \ + TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \ + __sih->sih_pending = 1; \ + setsoft(__si->softintr_ipl); \ + } \ + simple_unlock(&__si->softintr_slock); \ + _cpu_intr_resume(__s); \ +} while (/*CONSTCOND*/0) + +void softintr_init(void); +void *softintr_establish(int, void (*)(void *), void *); +void softintr_disestablish(void *); +void softintr_dispatch(int); +void setsoft(int); + +/* XXX For legacy software interrupts. */ +extern struct sh_soft_intrhand *softnet_intrhand; + +#define setsoftnet() softintr_schedule(softnet_intrhand) + +#endif /* _KERNEL */ + +#endif /* !_SH_INTR_H_ */ diff --git a/sys/arch/sh/include/limits.h b/sys/arch/sh/include/limits.h new file mode 100644 index 00000000000..e8ceb6d29f5 --- /dev/null +++ b/sys/arch/sh/include/limits.h @@ -0,0 +1,57 @@ +/* $OpenBSD: limits.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: limits.h,v 1.1 1996/09/30 16:34:28 ws Exp $ */ + +/*- + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * 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 TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_LIMITS_H_ +#define _SH_LIMITS_H_ + +#include <sys/cdefs.h> + +#define MB_LEN_MAX 1 /* no multibyte characters */ + +#if __POSIX_VISIBLE || __XPG_VISIBLE +#ifndef SIZE_MAX +#define SIZE_MAX UINT_MAX /* max value for a size_t */ +#endif +#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ +#endif + +#if __BSD_VISIBLE +#define SIZE_T_MAX UINT_MAX /* max value for a size_t (historic) */ + +#define UQUAD_MAX 0xffffffffffffffffULL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ +#endif /* __BSD_VISIBLE */ + +#endif /* _SH_LIMITS_H_ */ diff --git a/sys/arch/sh/include/lock.h b/sys/arch/sh/include/lock.h new file mode 100644 index 00000000000..017e083c7dc --- /dev/null +++ b/sys/arch/sh/include/lock.h @@ -0,0 +1,87 @@ +/* $OpenBSD: lock.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: lock.h,v 1.10 2006/01/03 01:29:46 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gregory McGarry. + * + * 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. + */ + +/* + * Machine-dependent spin lock operations. + */ + +#ifndef _SH_LOCK_H_ +#define _SH_LOCK_H_ + +typedef volatile u_int8_t __cpu_simple_lock_t; + +#define __SIMPLELOCK_LOCKED 0x80 +#define __SIMPLELOCK_UNLOCKED 0x00 + +static __inline void +__cpu_simple_lock_init(__cpu_simple_lock_t *alp) +{ + *alp = __SIMPLELOCK_UNLOCKED; +} + +static __inline void +__cpu_simple_lock(__cpu_simple_lock_t *alp) +{ + __asm volatile( + "1: tas.b %0 \n" + " bf 1b \n" + : "=m" (*alp)); +} + +static __inline int +__cpu_simple_lock_try(__cpu_simple_lock_t *alp) +{ + int __rv; + + __asm volatile( + " tas.b %0 \n" + " mov #0, %1 \n" + " rotcl %1 \n" + : "=m" (*alp), "=r" (__rv)); + + return (__rv); +} + +static __inline void +__cpu_simple_unlock(__cpu_simple_lock_t *alp) +{ + *alp = __SIMPLELOCK_UNLOCKED; +} + +#endif /* !_SH_LOCK_H_ */ diff --git a/sys/arch/sh/include/locore.h b/sys/arch/sh/include/locore.h new file mode 100644 index 00000000000..40fc0839f84 --- /dev/null +++ b/sys/arch/sh/include/locore.h @@ -0,0 +1,207 @@ +/* $OpenBSD: locore.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: locore.h,v 1.11 2006/01/23 22:32:50 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * 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 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. + */ + +#if defined(SH3) && defined(SH4) +#define MOV(x, r) mov.l .L_/**/x, r; mov.l @r, r +#define REG_SYMBOL(x) .L_/**/x: .long _C_LABEL(__sh_/**/x) +#define FUNC_SYMBOL(x) .L_/**/x: .long _C_LABEL(__sh_/**/x) +#elif defined(SH3) +#define MOV(x, r) mov.l .L_/**/x, r +#define REG_SYMBOL(x) .L_/**/x: .long SH3_/**/x +#define FUNC_SYMBOL(x) .L_/**/x: .long _C_LABEL(sh3_/**/x) +#elif defined(SH4) +#define MOV(x, r) mov.l .L_/**/x, r +#define REG_SYMBOL(x) .L_/**/x: .long SH4_/**/x +#define FUNC_SYMBOL(x) .L_/**/x: .long _C_LABEL(sh4_/**/x) +#endif /* SH3 && SH4 */ + +/* + * BANK1 r7 contains kernel stack top address. + * BANK1 r6 conatins current frame pointer. (per process) + */ +/* + * __EXCEPTION_ENTRY: + * + setup stack pointer + * + save all register to frame. (struct trapframe) + * + setup kernel stack. + * + change bank from 1 to 0 + * + set BANK0 (r4, r5, r6) = (ssr, spc, ssp) + */ +#define __EXCEPTION_ENTRY ;\ + /* Check kernel/user mode. */ ;\ + mov #0x40, r3 ;\ + swap.b r3, r3 ;\ + stc ssr, r2 ;\ + swap.w r3, r3 /* r3 = 0x40000000 */ ;\ + mov r2, r0 /* r2 = r0 = SSR */ ;\ + and r3, r0 ;\ + tst r0, r0 /* if (SSR.MD == 0) T = 1 */ ;\ + mov r14, r1 ;\ + mov r6, r14 /* frame pointer */ ;\ + bf/s 1f /* T==0 ...Exception from kernel mode */;\ + mov r15, r0 ;\ + /* Exception from user mode */ ;\ + mov r7, r15 /* change to kernel stack */ ;\ +1: ;\ + /* Save registers */ ;\ + mov.l r1, @-r14 /* tf_r14 */ ;\ + mov.l r0, @-r14 /* tf_r15 */ ;\ + stc.l r0_bank,@-r14 /* tf_r0 */ ;\ + stc.l r1_bank,@-r14 /* tf_r1 */ ;\ + stc.l r2_bank,@-r14 /* tf_r2 */ ;\ + stc.l r3_bank,@-r14 /* tf_r3 */ ;\ + stc.l r4_bank,@-r14 /* tf_r4 */ ;\ + stc.l r5_bank,@-r14 /* tf_r5 */ ;\ + stc.l r6_bank,@-r14 /* tf_r6 */ ;\ + stc.l r7_bank,@-r14 /* tf_r7 */ ;\ + mov.l r8, @-r14 /* tf_r8 */ ;\ + mov.l r9, @-r14 /* tf_r9 */ ;\ + mov.l r10, @-r14 /* tf_r10 */ ;\ + mov.l r11, @-r14 /* tf_r11 */ ;\ + mov.l r12, @-r14 /* tf_r12 */ ;\ + mov.l r13, @-r14 /* tf_r13 */ ;\ + sts.l pr, @-r14 /* tf_pr */ ;\ + sts.l mach, @-r14 /* tf_mach*/ ;\ + sts.l macl, @-r14 /* tf_macl*/ ;\ + mov.l r2, @-r14 /* tf_ssr */ ;\ + stc.l spc, @-r14 /* tf_spc */ ;\ + add #-8, r14 /* skip tf_ubc, tf_expevt */ ;\ + mov r14, r6 /* store frame pointer */ ;\ + /* Change register bank to 0 */ ;\ + shlr r3 /* r3 = 0x20000000 */ ;\ + stc sr, r1 /* r1 = SR */ ;\ + not r3, r3 ;\ + and r1, r3 ;\ + ldc r3, sr /* SR.RB = 0 */ ;\ + /* Set up argument. r4 = ssr, r5 = spc */ ;\ + stc r2_bank,r4 ;\ + stc spc, r5 + +/* + * __EXCEPTION_RETURN: + * + block exception + * + restore all register from stack. + * + rte. + */ +#define __EXCEPTION_RETURN ;\ + mov #0x10, r0 ;\ + swap.b r0, r0 ;\ + swap.w r0, r0 /* r0 = 0x10000000 */ ;\ + stc sr, r1 ;\ + or r0, r1 ;\ + ldc r1, sr /* SR.BL = 1 */ ;\ + stc r6_bank,r0 ;\ + mov r0, r14 ;\ + add #TF_SIZE, r0 ;\ + ldc r0, r6_bank /* roll up frame pointer */ ;\ + add #8, r14 /* skip tf_expevt, tf_ubc */ ;\ + mov.l @r14+, r0 /* tf_spc */ ;\ + ldc r0, spc ;\ + mov.l @r14+, r0 /* tf_ssr */ ;\ + ldc r0, ssr ;\ + lds.l @r14+, macl /* tf_macl*/ ;\ + lds.l @r14+, mach /* tf_mach*/ ;\ + lds.l @r14+, pr /* tf_pr */ ;\ + mov.l @r14+, r13 /* tf_r13 */ ;\ + mov.l @r14+, r12 /* tf_r12 */ ;\ + mov.l @r14+, r11 /* tf_r11 */ ;\ + mov.l @r14+, r10 /* tf_r10 */ ;\ + mov.l @r14+, r9 /* tf_r9 */ ;\ + mov.l @r14+, r8 /* tf_r8 */ ;\ + mov.l @r14+, r7 /* tf_r7 */ ;\ + mov.l @r14+, r6 /* tf_r6 */ ;\ + mov.l @r14+, r5 /* tf_r5 */ ;\ + mov.l @r14+, r4 /* tf_r4 */ ;\ + mov.l @r14+, r3 /* tf_r3 */ ;\ + mov.l @r14+, r2 /* tf_r2 */ ;\ + mov.l @r14+, r1 /* tf_r1 */ ;\ + mov.l @r14+, r0 /* tf_r0 */ ;\ + mov.l @r14+ r15 /* tf_r15 */ ;\ + mov.l @r14+, r14 /* tf_r14 */ ;\ + rte ;\ + nop + + +/* + * Macros to disable and enable exceptions (including interrupts). + * This modifies SR.BL + */ +#define __0x10 #0x10 +#define __0x78 #0x78 + +#define __EXCEPTION_BLOCK(Rn, Rm) ;\ + mov __0x10, Rn ;\ + swap.b Rn, Rn ;\ + swap.w Rn, Rn /* Rn = 0x10000000 */ ;\ + stc sr, Rm ;\ + or Rn, Rm ;\ + ldc Rm, sr /* block exceptions */ + +#define __EXCEPTION_UNBLOCK(Rn, Rm) ;\ + mov __0x10, Rn ;\ + swap.b Rn, Rn ;\ + swap.w Rn, Rn /* Rn = 0x10000000 */ ;\ + not Rn, Rn ;\ + stc sr, Rm ;\ + and Rn, Rm ;\ + ldc Rm, sr /* unblock exceptions */ + +/* + * Macros to disable and enable interrupts. + * This modifies SR.I[0-3] + */ +#define __INTR_MASK(Rn, Rm) ;\ + mov __0x78, Rn ;\ + shll Rn /* Rn = 0x000000f0 */ ;\ + stc sr, Rm ;\ + or Rn, Rm ;\ + ldc Rm, sr /* mask all interrupt */ + +#define __INTR_UNMASK(Rn, Rm) ;\ + mov __0x78, Rn ;\ + shll Rn /* Rn = 0x000000f0 */ ;\ + not Rn, Rn ;\ + stc sr, Rm ;\ + and Rn, Rm ;\ + ldc Rm, sr /* unmask all interrupt */ + +#ifndef _LOCORE +void sh3_switch_setup(struct proc *); +void sh4_switch_setup(struct proc *); +void sh3_switch_resume(struct proc *); +void sh4_switch_resume(struct proc *); +extern void (*__sh_switch_resume)(struct proc *); +#endif /* !_LOCORE */ diff --git a/sys/arch/sh/include/mmu.h b/sys/arch/sh/include/mmu.h new file mode 100644 index 00000000000..da1cdc501cb --- /dev/null +++ b/sys/arch/sh/include/mmu.h @@ -0,0 +1,115 @@ +/* $OpenBSD: mmu.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: mmu.h,v 1.9 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +#ifndef _SH_MMU_H_ +#define _SH_MMU_H_ + +/* + * Initialize routines. + * sh_mmu_init Assign function vector. Don't access hardware. + * Call as early as possible. + * sh_mmu_start Reset TLB entry, set default ASID, and start to + * translate addresses. + * Call after exception vector was installed. + * + * TLB access ops. + * sh_tlb_invalidate_addr invalidate TLB entris for given + * virtual addr with ASID. + * sh_tlb_invalidate_asid invalidate TLB entries for given ASID. + * sh_tlb_invalidate_all invalidate all non-wired TLB entries. + * sh_tlb_set_asid set ASID. + * sh_tlb_update load new PTE to TLB. + * + */ + +void sh_mmu_init(void); +void sh_mmu_information(void); +void sh_tlb_set_asid(int); + +#ifdef SH3 +void sh3_mmu_start(void); +void sh3_tlb_invalidate_addr(int, vaddr_t); +void sh3_tlb_invalidate_asid(int); +void sh3_tlb_invalidate_all(void); +void sh3_tlb_update(int, vaddr_t, uint32_t); +#endif + +#ifdef SH4 +void sh4_mmu_start(void); +void sh4_tlb_invalidate_addr(int, vaddr_t); +void sh4_tlb_invalidate_asid(int); +void sh4_tlb_invalidate_all(void); +void sh4_tlb_update(int, vaddr_t, uint32_t); +#endif + + +#if defined(SH3) && defined(SH4) +extern uint32_t __sh_PTEH; + +extern void (*__sh_mmu_start)(void); +extern void (*__sh_tlb_invalidate_addr)(int, vaddr_t); +extern void (*__sh_tlb_invalidate_asid)(int); +extern void (*__sh_tlb_invalidate_all)(void); +extern void (*__sh_tlb_update)(int, vaddr_t, uint32_t); + +#define sh_mmu_start() (*__sh_mmu_start)() +#define sh_tlb_invalidate_addr(a, va) (*__sh_tlb_invalidate_addr)(a, va) +#define sh_tlb_invalidate_asid(a) (*__sh_tlb_invalidate_asid)(a) +#define sh_tlb_invalidate_all() (*__sh_tlb_invalidate_all)() +#define sh_tlb_update(a, va, pte) (*__sh_tlb_update)(a, va, pte) + +#elif defined(SH3) + +#define sh_mmu_start() sh3_mmu_start() +#define sh_tlb_invalidate_addr(a, va) sh3_tlb_invalidate_addr(a, va) +#define sh_tlb_invalidate_asid(a) sh3_tlb_invalidate_asid(a) +#define sh_tlb_invalidate_all() sh3_tlb_invalidate_all() +#define sh_tlb_update(a, va, pte) sh3_tlb_update(a, va, pte) + +#elif defined(SH4) + +#define sh_mmu_start() sh4_mmu_start() +#define sh_tlb_invalidate_addr(a, va) sh4_tlb_invalidate_addr(a, va) +#define sh_tlb_invalidate_asid(a) sh4_tlb_invalidate_asid(a) +#define sh_tlb_invalidate_all() sh4_tlb_invalidate_all() +#define sh_tlb_update(a, va, pte) sh4_tlb_update(a, va, pte) + +#endif + +#endif /* !_SH_MMU_H_ */ diff --git a/sys/arch/sh/include/mmu_sh3.h b/sys/arch/sh/include/mmu_sh3.h new file mode 100644 index 00000000000..a8f5139e8ca --- /dev/null +++ b/sys/arch/sh/include/mmu_sh3.h @@ -0,0 +1,90 @@ +/* $OpenBSD: mmu_sh3.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: mmu_sh3.h,v 1.6 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +#ifndef _SH_MMU_SH3_H_ +#define _SH_MMU_SH3_H_ +#include <sh/devreg.h> + +/* 128-entry 4-way set-associative */ +#define SH3_MMU_WAY 4 +#define SH3_MMU_ENTRY 32 + +#define SH3_PTEH 0xfffffff0 +#define SH3_PTEH_ASID_MASK 0x000000ff +#define SH3_PTEH_VPN_MASK 0xfffffc00 +#define SH3_PTEL 0xfffffff4 +#define SH3_PTEL_HWBITS 0x1ffff17e /* [28:12][8][6:1] */ +#define SH3_TTB 0xfffffff8 +#define SH3_TEA 0xfffffffc +#define SH3_MMUCR 0xffffffe0 +#define SH3_MMUCR_AT 0x00000001 +#define SH3_MMUCR_IX 0x00000002 +#define SH3_MMUCR_TF 0x00000004 +#define SH3_MMUCR_RC 0x00000030 +#define SH3_MMUCR_SV 0x00000100 + +/* + * memory-mapped TLB + */ +/* Address array */ +#define SH3_MMUAA 0xf2000000 +/* address specification */ +#define SH3_MMU_VPN_SHIFT 12 +#define SH3_MMU_VPN_MASK 0x0001f000 /* [16:12] */ +#define SH3_MMU_WAY_SHIFT 8 +#define SH3_MMU_WAY_MASK 0x00000300 /* [9:8] */ +/* data specification */ +#define SH3_MMU_D_VALID 0x00000100 +#define SH3_MMUAA_D_VPN_MASK_1K 0xfffe0c00 /* [31:17][11:10] */ +#define SH3_MMUAA_D_VPN_MASK_4K 0xfffe0000 /* [31:17] */ +#define SH3_MMUAA_D_ASID_MASK 0x000000ff + +/* Data array */ +#define SH3_MMUDA 0xf3000000 +#define SH3_MMUDA_D_PPN_MASK 0xfffffc00 +#define SH3_MMUDA_D_V 0x00000100 +#define SH3_MMUDA_D_PR_SHIFT 5 +#define SH3_MMUDA_D_PR_MASK 0x00000060 /* [6:5] */ +#define SH3_MMUDA_D_SZ 0x00000010 +#define SH3_MMUDA_D_C 0x00000008 +#define SH3_MMUDA_D_D 0x00000004 +#define SH3_MMUDA_D_SH 0x00000002 + +#define SH3_TLB_DISABLE *(volatile uint32_t *)SH3_MMUCR = SH3_MMUCR_TF +#endif /* !_SH_MMU_SH3_H_ */ diff --git a/sys/arch/sh/include/mmu_sh4.h b/sys/arch/sh/include/mmu_sh4.h new file mode 100644 index 00000000000..c25a48c4748 --- /dev/null +++ b/sys/arch/sh/include/mmu_sh4.h @@ -0,0 +1,154 @@ +/* $OpenBSD: mmu_sh4.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: mmu_sh4.h,v 1.6 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +#ifndef _SH_MMU_SH4_H_ +#define _SH_MMU_SH4_H_ +#include <sh/devreg.h> + +/* ITLB 4-entry full-associative UTLB 64-entry full-associative */ +#define SH4_PTEH 0xff000000 +#define SH4_PTEH_VPN_MASK 0xfffffc00 +#define SH4_PTEH_ASID_MASK 0x000000ff +#define SH4_PTEL 0xff000004 +#define SH4_PTEL_WT 0x00000001 +#define SH4_PTEL_SH 0x00000002 +#define SH4_PTEL_D 0x00000004 +#define SH4_PTEL_C 0x00000008 +#define SH4_PTEL_PR_SHIFT 5 +#define SH4_PTEL_PR_MASK 0x00000060 /* [5:6] */ +#define SH4_PTEL_SZ_MASK 0x00000090 /* [4][7] */ +#define SH4_PTEL_SZ_1K 0x00000000 +#define SH4_PTEL_SZ_4K 0x00000010 +#define SH4_PTEL_SZ_64K 0x00000080 +#define SH4_PTEL_SZ_1M 0x00000090 +#define SH4_PTEL_V 0x00000100 +#define SH4_PTEL_HWBITS 0x1ffff1ff /* [28:12]PFN [8:0]attr. */ + +#define SH4_PTEA 0xff000034 +#define SH4_PTEA_SA_MASK 0x00000007 +#define SH4_PTEA_SA_TC 0x00000008 +#define SH4_TTB 0xff000008 +#define SH4_TEA 0xff00000c +#define SH4_MMUCR 0xff000010 +#define SH4_MMUCR_AT 0x00000001 +#define SH4_MMUCR_TI 0x00000004 +#define SH4_MMUCR_SV 0x00000100 +#define SH4_MMUCR_SQMD 0x00000200 +#define SH4_MMUCR_URC_SHIFT 10 +#define SH4_MMUCR_URC_MASK 0x0000fc00 /* [10:15] */ +#define SH4_MMUCR_URB_SHIFT 18 +#define SH4_MMUCR_URB_MASK 0x00fc0000 /* [18:23] */ +#define SH4_MMUCR_LRUI_SHIFT 26 +#define SH4_MMUCR_LRUT_MASK 0xfc000000 /* [26:31] */ + +#define SH4_MMUCR_MASK (SH4_MMUCR_LRUT_MASK | SH4_MMUCR_URB_MASK | \ + SH4_MMUCR_URC_MASK | SH4_MMUCR_SQMD | SH4_MMUCR_SV | SH4_MMUCR_AT) +/* + * memory-mapped TLB + * must be access from P2-area program. + * branch to the other area must be maed at least 8 instruction + * after access. + */ +#define SH4_ITLB_ENTRY 4 +#define SH4_UTLB_ENTRY 64 + +/* ITLB */ +#define SH4_ITLB_AA 0xf2000000 +/* address specification (common for address and data array(0,1)) */ +#define SH4_ITLB_E_SHIFT 8 +#define SH4_ITLB_E_MASK 0x00000300 /* [9:8] */ +/* data specification */ +/* address-array */ +#define SH4_ITLB_AA_ASID_MASK 0x000000ff /* [7:0] */ +#define SH4_ITLB_AA_V 0x00000100 +#define SH4_ITLB_AA_VPN_SHIFT 10 +#define SH4_ITLB_AA_VPN_MASK 0xfffffc00 /* [31:10] */ +/* data-array 1 */ +#define SH4_ITLB_DA1 0xf3000000 +#define SH4_ITLB_DA1_SH 0x00000002 +#define SH4_ITLB_DA1_C 0x00000008 +#define SH4_ITLB_DA1_SZ_MASK 0x00000090 /* [7][4] */ +#define SH4_ITLB_DA1_SZ_1K 0x00000000 +#define SH4_ITLB_DA1_SZ_4K 0x00000010 +#define SH4_ITLB_DA1_SZ_64K 0x00000080 +#define SH4_ITLB_DA1_SZ_1M 0x00000090 +#define SH4_ITLB_DA1_PR 0x00000040 +#define SH4_ITLB_DA1_V 0x00000100 +#define SH4_ITLB_DA1_PPN_SHIFT 11 +#define SH4_ITLB_DA1_PPN_MASK 0x1ffffc00 /* [28:10] */ +/* data-array 2 */ +#define SH4_ITLB_DA2 0xf3800000 +#define SH4_ITLB_DA2_SA_MASK 0x00000003 +#define SH4_ITLB_DA2_TC 0x00000004 + +/* UTLB */ +#define SH4_UTLB_AA 0xf6000000 +/* address specification (common for address and data array(0,1)) */ +#define SH4_UTLB_E_SHIFT 8 +#define SH4_UTLB_E_MASK 0x00003f00 +#define SH4_UTLB_A 0x00000080 +/* data specification */ +/* address-array */ +#define SH4_UTLB_AA_VPN_MASK 0xfffffc00 /* [31:10] */ +#define SH4_UTLB_AA_D 0x00000200 +#define SH4_UTLB_AA_V 0x00000100 +#define SH4_UTLB_AA_ASID_MASK 0x000000ff /* [7:0] */ +/* data-array 1 */ +#define SH4_UTLB_DA1 0xf7000000 +#define SH4_UTLB_DA1_WT 0x00000001 +#define SH4_UTLB_DA1_SH 0x00000002 +#define SH4_UTLB_DA1_D 0x00000004 +#define SH4_UTLB_DA1_C 0x00000008 +#define SH4_UTLB_DA1_SZ_MASK 0x00000090 /* [7][4] */ +#define SH4_UTLB_DA1_SZ_1K 0x00000000 +#define SH4_UTLB_DA1_SZ_4K 0x00000010 +#define SH4_UTLB_DA1_SZ_64K 0x00000080 +#define SH4_UTLB_DA1_SZ_1M 0x00000090 +#define SH4_UTLB_DA1_PR_SHIFT 5 +#define SH4_UTLB_DA1_PR_MASK 0x00000060 +#define SH4_UTLB_DA1_V 0x00000100 +#define SH4_UTLB_DA1_PPN_SHIFT 11 +#define SH4_UTLB_DA1_PPN_MASK 0x1ffffc00 /* [28:10] */ +/* data-array 2 */ +#define SH4_UTLB_DA2 0xf7800000 +#define SH4_UTLB_DA2_SA_MASK 0x00000003 +#define SH4_UTLB_DA2_TC 0x00000004 + +#define SH4_TLB_DISABLE *(volatile uint32_t *)SH4_MMUCR = SH4_MMUCR_TI +#endif /* !_SH_MMU_SH4_H_ */ diff --git a/sys/arch/sh/include/param.h b/sys/arch/sh/include/param.h new file mode 100644 index 00000000000..9a4493af3ee --- /dev/null +++ b/sys/arch/sh/include/param.h @@ -0,0 +1,137 @@ +/* $OpenBSD: param.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: param.h,v 1.15 2006/08/28 13:43:35 yamt Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)param.h 5.8 (Berkeley) 6/28/91 + */ + +/* + * SuperH dependent constants. + */ + +#ifndef _SH_PARAM_H_ +#define _SH_PARAM_H_ + +#define _MACHINE_ARCH sh +#define MACHINE_ARCH "sh" + +#ifndef MID_MACHINE +#define MID_MACHINE MID_SH3 +#endif + +#if defined(_KERNEL) && !defined(_LOCORE) +#include <sh/cpu.h> +#endif + +/* + * We use 4K pages on the sh3/sh4. Override the PAGE_* definitions + * to be compile-time constants. + */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) +#define PAGE_MASK (PAGE_SIZE - 1) + +#define PGSHIFT PAGE_SHIFT +#define NBPG PAGE_SIZE +#define PGOFSET PAGE_MASK + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). 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 ALIGNBYTES (sizeof(int) - 1) +#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES) +#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0) + +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define DEV_BSIZE (1 << DEV_BSHIFT) +#define BLKDEV_IOSIZE 2048 +#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ + +/* + * u-space. + */ +#define UPAGES 2 /* pages of u-area */ +#define USPACE (UPAGES * NBPG) /* total size of u-area */ +#define USPACE_ALIGN (0) +#if UPAGES == 1 +#error "too small u-area" +#elif UPAGES == 2 +#define P1_STACK /* kernel stack is P1-area */ +#else +#undef P1_STACK /* kernel stack is P3-area */ +#endif + +#ifndef MSGBUFSIZE +#define MSGBUFSIZE NBPG /* default message buffer size */ +#endif + +#define btoc(x) (((x) + PAGE_MASK) >> PAGE_SHIFT) +#define ctob(x) ((x) << PAGE_SHIFT) + +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + ((bytes) >> DEV_BSHIFT) +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((db) << DEV_BSHIFT) + +/* + * 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 MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#define NMBCLUSTERS 4096 /* map size, max cluster allocation */ + +/* + * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * logical pages. + */ +#define NKMEMPAGES_MIN_DEFAULT ((4 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((64 * 1024 * 1024) >> PAGE_SHIFT) + +#endif /* !_SH3_PARAM_H_ */ diff --git a/sys/arch/sh/include/pcb.h b/sys/arch/sh/include/pcb.h new file mode 100644 index 00000000000..2dbc63c7cfa --- /dev/null +++ b/sys/arch/sh/include/pcb.h @@ -0,0 +1,55 @@ +/* $OpenBSD: pcb.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: pcb.h,v 1.7 2002/05/09 12:28:08 uch Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +#ifndef _SH_PCB_H_ +#define _SH_PCB_H_ + +#include <sh/frame.h> + +struct pcb { + struct switchframe pcb_sf; /* kernel context for resume */ + caddr_t pcb_onfault; /* for copyin/out fault */ + int pcb_faultbail; /* bail out before call uvm_fault. */ +}; + +struct md_coredump { +}; + +extern struct pcb *curpcb; +#endif /* !_SH_PCB_H_ */ diff --git a/sys/arch/sh/include/pmap.h b/sys/arch/sh/include/pmap.h new file mode 100644 index 00000000000..b26dd562137 --- /dev/null +++ b/sys/arch/sh/include/pmap.h @@ -0,0 +1,91 @@ +/* $OpenBSD: pmap.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: pmap.h,v 1.28 2006/04/10 23:12:11 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +/* + * OpenBSD/sh pmap: + * pmap.pm_ptp[512] ... 512 slot of page table page + * page table page contains 1024 PTEs. (PAGE_SIZE / sizeof(pt_entry_t)) + * | PTP 11bit | PTOFSET 10bit | PGOFSET 12bit | + */ + +#ifndef _SH_PMAP_H_ +#define _SH_PMAP_H_ +#include <sys/queue.h> +#include <sh/pte.h> + +#define PMAP_STEAL_MEMORY +#define PMAP_GROWKERNEL + +#define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */ +typedef struct pmap { + pt_entry_t **pm_ptp; + int pm_asid; + int pm_refcnt; + struct pmap_statistics pm_stats; /* pmap statistics */ +} *pmap_t; +extern struct pmap __pmap_kernel; + +void pmap_bootstrap(void); +void pmap_proc_iflush(struct proc *, vaddr_t, size_t); +#define pmap_unuse_final(p) do { /* nothing */ } while (0) +#define pmap_kernel() (&__pmap_kernel) +#define pmap_deactivate(pmap) do { /* nothing */ } while (0) +#define pmap_update(pmap) do { /* nothing */ } while (0) +#define pmap_copy(dp,sp,d,l,s) do { /* nothing */ } while (0) +#define pmap_collect(pmap) do { /* nothing */ } while (0) +#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) +#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) +#define pmap_phys_address(frame) ((paddr_t)(ptoa(frame))) + +/* ARGSUSED */ +static __inline void +pmap_remove_all(struct pmap *pmap) +{ + /* Nothing. */ +} + +#define __HAVE_PMAP_DIRECT +#define pmap_map_direct(pg) SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg)) +#define pmap_unmap_direct(va) PHYS_TO_VM_PAGE(SH3_P1SEG_TO_PHYS((va))) + +/* MD pmap utils. */ +pt_entry_t *__pmap_pte_lookup(pmap_t, vaddr_t); +pt_entry_t *__pmap_kpte_lookup(vaddr_t); +boolean_t __pmap_pte_load(pmap_t, vaddr_t, int); +#endif /* !_SH_PMAP_H_ */ diff --git a/sys/arch/sh/include/proc.h b/sys/arch/sh/include/proc.h new file mode 100644 index 00000000000..a308274bf3e --- /dev/null +++ b/sys/arch/sh/include/proc.h @@ -0,0 +1,69 @@ +/* $OpenBSD: proc.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: proc.h,v 1.10 2005/12/11 12:18:58 christos Exp $ */ + +/* + * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. + * Copyright (c) 1991 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)proc.h 7.1 (Berkeley) 5/15/91 + */ + +#ifndef _SH_PROC_H_ +#define _SH_PROC_H_ + +/* + * Machine-dependent part of the proc structure for sh. + */ + +#include <machine/param.h> + +/* Kernel stack PTE */ +struct md_upte { + uint32_t addr; + uint32_t data; +}; + +struct mdproc { + struct trapframe *md_regs; /* user context */ + struct pcb *md_pcb; /* pcb access address */ + volatile int md_astpending; /* AST pending on return to userland */ + int md_flags; /* machine-dependent flags */ + /* u-area PTE: *2 .. SH4 data/address data array access */ + struct md_upte md_upte[UPAGES * 2]; +}; + +/* md_flags */ +#define MDP_USEDFPU 0x0001 /* has used the FPU */ + +#ifdef _KERNEL +#ifndef _LOCORE +extern void sh_proc0_init(void); +extern struct md_upte *curupte; /* SH3 wired u-area hack */ +#endif /* _LOCORE */ +#endif /* _KERNEL */ +#endif /* !_SH_PROC_H_ */ diff --git a/sys/arch/sh/include/profile.h b/sys/arch/sh/include/profile.h new file mode 100644 index 00000000000..2b2caf62119 --- /dev/null +++ b/sys/arch/sh/include/profile.h @@ -0,0 +1,74 @@ +/* $OpenBSD: profile.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: profile.h,v 1.4 2002/04/28 17:10:36 uch Exp $ */ + +/*- + * Copyright (c) 2000 Tsubai Masanari. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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 defined(__ELF__) +#define _MCOUNT_DECL static void _mcount +#else +#define _MCOUNT_DECL static void mcount +#endif + +#define MCOUNT __asm (" \n\ + .text \n\ + .align 2 \n\ + .globl __mcount \n\ +__mcount: \n\ + mov.l r0,@-r15 \n\ + mov.l r4,@-r15 \n\ + mov.l r5,@-r15 \n\ + mov.l r6,@-r15 \n\ + mov.l r7,@-r15 \n\ + mov.l r14,@-r15 \n\ + sts.l pr,@-r15 \n\ + mov r15,r14 \n\ + \n\ + mov.l 1f,r1 ! _mcount \n\ + sts pr,r4 ! frompc \n\ + mov r0,r5 ! selfpc \n\ + jsr @r1 \n\ + nop \n\ + \n\ + mov r14,r15 \n\ + lds.l @r15+,pr \n\ + mov.l @r15+,r14 \n\ + mov.l @r15+,r7 \n\ + mov.l @r15+,r6 \n\ + mov.l @r15+,r5 \n\ + mov.l @r15+,r4 \n\ + mov.l @r15+,r0 \n\ + \n\ + jmp @r0 ! return \n\ + nop \n\ + \n\ + .align 2 \n\ +1: .long _mcount "); + +#ifdef _KERNEL +#define MCOUNT_ENTER s = splhigh() +#define MCOUNT_EXIT splx(s) +#endif diff --git a/sys/arch/sh/include/psl.h b/sys/arch/sh/include/psl.h new file mode 100644 index 00000000000..8a45a23a3fd --- /dev/null +++ b/sys/arch/sh/include/psl.h @@ -0,0 +1,76 @@ +/* $OpenBSD: psl.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: psl.h,v 1.8 2005/12/11 12:18:58 christos Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)psl.h 5.2 (Berkeley) 1/18/91 + */ + +#ifndef _SH_PSL_H_ +#define _SH_PSL_H_ + +/* + * SuperH Processer Status Register. + */ +#define PSL_TBIT 0x00000001 /* T bit */ +#define PSL_SBIT 0x00000002 /* S bit */ +#define PSL_IMASK 0x000000f0 /* Interrupt Mask bit */ +#define PSL_QBIT 0x00000100 /* Q bit */ +#define PSL_MBIT 0x00000200 /* M bit */ +#define PSL_BL 0x10000000 /* Exception Block bit */ +#define PSL_RB 0x20000000 /* Register Bank bit */ +#define PSL_MD 0x40000000 /* Processor Mode bit */ + /* 1 = kernel, 0 = user */ + +#define PSL_MBO 0x00000000 /* must be one bits */ +#define PSL_MBZ 0x8ffffc0c /* must be zero bits */ + +#define PSL_USERSET 0 +#define PSL_USERSTATIC (PSL_BL|PSL_RB|PSL_MD|PSL_IMASK|PSL_MBO|PSL_MBZ) + +#define KERNELMODE(sr) ((sr) & PSL_MD) + +#ifdef _KERNEL +#ifndef _LOCORE +/* SR.IMASK */ +int _cpu_intr_raise(int); +int _cpu_intr_suspend(void); +int _cpu_intr_resume(int); +/* SR.BL */ +int _cpu_exception_suspend(void); +void _cpu_exception_resume(int); +#endif /* !_LOCORE */ + +#include <machine/intr.h> +#endif /* _KERNEL */ + +#endif /* !_SH_PSL_H_ */ diff --git a/sys/arch/sh/include/pte.h b/sys/arch/sh/include/pte.h new file mode 100644 index 00000000000..b3034504cb9 --- /dev/null +++ b/sys/arch/sh/include/pte.h @@ -0,0 +1,99 @@ +/* $OpenBSD: pte.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: pte.h,v 1.11 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +#ifndef _SH_PTE_H_ +#define _SH_PTE_H_ + +/* + * OpenBSD/sh PTE format. + * + * [Hardware bit] + * SH3 + * PPN V PR SZ C D SH + * [28:10][8][6:5][4][3][2][1] + * + * SH4 + * V SZ PR SZ C D SH WT + * [28:10][8][7][6:5][4][3][2][1][0] + * + * [Software bit] + * [31] - PMAP_WIRED bit (not hardware wired entry) + * [11:9] - SH4 PCMCIA Assistant bit. (space attribute bit only) + */ + +/* + * Hardware bits + */ +#define PG_PPN 0x1ffff000 /* Physical page number mask */ +#define PG_V 0x00000100 /* Valid */ +#define PG_PR_MASK 0x00000060 /* Page protection mask */ +#define PG_PR_URW 0x00000060 /* kernel/user read/write */ +#define PG_PR_URO 0x00000040 /* kernel/user read only */ +#define PG_PR_KRW 0x00000020 /* kernel read/write */ +#define PG_PR_KRO 0x00000000 /* kernel read only */ +#define PG_4K 0x00000010 /* page size 4KB */ +#define PG_C 0x00000008 /* Cacheable */ +#define PG_D 0x00000004 /* Dirty */ +#define PG_SH 0x00000002 /* Share status */ +#define PG_WT 0x00000001 /* Write-through (SH4 only) */ + +#define PG_HW_BITS 0x1ffff17e /* [28:12][8][6:1] */ + +/* + * Software bits + */ +#define _PG_WIRED 0x80000000 + +/* SH4 PCMCIA MMU support bits */ +/* PTEA SA (Space Attribute bit) */ +#define _PG_PCMCIA 0x00000e00 /* [11:9] */ +#define _PG_PCMCIA_SHIFT 9 +#define _PG_PCMCIA_NONE 0x00000000 /* Non PCMCIA space */ +#define _PG_PCMCIA_IO 0x00000200 /* IOIS16 signal */ +#define _PG_PCMCIA_IO8 0x00000400 /* 8 bit I/O */ +#define _PG_PCMCIA_IO16 0x00000600 /* 16 bit I/O */ +#define _PG_PCMCIA_MEM8 0x00000800 /* 8 bit common memory */ +#define _PG_PCMCIA_MEM16 0x00000a00 /* 16 bit common memory */ +#define _PG_PCMCIA_ATTR8 0x00000c00 /* 8 bit attribute */ +#define _PG_PCMCIA_ATTR16 0x00000e00 /* 16 bit attribute */ + +#ifndef _LOCORE +typedef uint32_t pt_entry_t; +#endif /* _LOCORE */ +#endif /* !_SH_PTE_H_ */ diff --git a/sys/arch/sh/include/ptrace.h b/sys/arch/sh/include/ptrace.h new file mode 100644 index 00000000000..3c25fb88b73 --- /dev/null +++ b/sys/arch/sh/include/ptrace.h @@ -0,0 +1,40 @@ +/* $OpenBSD: ptrace.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: ptrace.h,v 1.3 2002/02/28 01:58:53 uch Exp $ */ + +/* + * Copyright (c) 1993 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * SuperH ptrace definitions + */ + +#define PT_GETREGS (PT_FIRSTMACH + 1) +#define PT_SETREGS (PT_FIRSTMACH + 2) + diff --git a/sys/arch/sh/include/reg.h b/sys/arch/sh/include/reg.h new file mode 100644 index 00000000000..ec499656bb1 --- /dev/null +++ b/sys/arch/sh/include/reg.h @@ -0,0 +1,103 @@ +/* $OpenBSD: reg.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: reg.h,v 1.5 2005/12/11 12:18:58 christos Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)reg.h 5.5 (Berkeley) 1/18/91 + */ + +#ifndef _SH_REG_H_ +#define _SH_REG_H_ + +/* + * Location of the users' stored + * registers within appropriate frame of 'trap' and 'syscall', relative to + * base of stack frame. + * + * XXX + * The #defines aren't used in the kernel, but some user-level code still + * expects them. + */ + +/* When referenced during a trap/exception, registers are at these offsets */ + +#define tSPC (0) +#define tSSR (1) +#define tPR (2) +#define tR14 (3) +#define tR13 (4) +#define tR12 (5) +#define tR11 (6) +#define tR10 (7) +#define tR9 (8) + +#define tR8 (11) +#define tR7 (12) +#define tR6 (13) +#define tR5 (14) +#define tR4 (15) +#define tR3 (16) +#define tR2 (17) +#define tR1 (18) +#define tR0 (19) + +/* + * Registers accessible to ptrace(2) syscall for debugger + * The machine-dependent code for PT_{SET,GET}REGS needs to + * use whichver order, defined above, is correct, so that it + * is all invisible to the user. + */ +struct reg { + int r_spc; + int r_ssr; + int r_pr; + int r_mach; + int r_macl; + int r_r15; + int r_r14; + int r_r13; + int r_r12; + int r_r11; + int r_r10; + int r_r9; + int r_r8; + int r_r7; + int r_r6; + int r_r5; + int r_r4; + int r_r3; + int r_r2; + int r_r1; + int r_r0; +}; + +#endif /* !_SH_REG_H_ */ diff --git a/sys/arch/sh/include/rtcreg.h b/sys/arch/sh/include/rtcreg.h new file mode 100644 index 00000000000..7ebd9274e38 --- /dev/null +++ b/sys/arch/sh/include/rtcreg.h @@ -0,0 +1,106 @@ +/* $OpenBSD: rtcreg.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: rtcreg.h,v 1.10 2006/09/03 12:38:34 uwe Exp $ */ + +/*- + * Copyright (C) 1999 SAITOH Masanobu. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_RTCREG_H_ +#define _SH_RTCREG_H_ +#include <sh/devreg.h> + +/* + * RTC + */ +#define SH3_R64CNT 0xfffffec0 +#define SH3_RSECCNT 0xfffffec2 +#define SH3_RMINCNT 0xfffffec4 +#define SH3_RHRCNT 0xfffffec6 +#define SH3_RWKCNT 0xfffffec8 +#define SH3_RDAYCNT 0xfffffeca +#define SH3_RMONCNT 0xfffffecc +#define SH3_RYRCNT 0xfffffece +#define SH3_RSECAR 0xfffffed0 +#define SH3_RMINAR 0xfffffed2 +#define SH3_RHRAR 0xfffffed4 +#define SH3_RWKAR 0xfffffed6 +#define SH3_RDAYAR 0xfffffed8 +#define SH3_RMONAR 0xfffffeda +#define SH3_RCR1 0xfffffedc +#define SH3_RCR2 0xfffffede + +#define SH4_R64CNT 0xffc80000 +#define SH4_RSECCNT 0xffc80004 +#define SH4_RMINCNT 0xffc80008 +#define SH4_RHRCNT 0xffc8000c +#define SH4_RWKCNT 0xffc80010 +#define SH4_RDAYCNT 0xffc80014 +#define SH4_RMONCNT 0xffc80018 +#define SH4_RYRCNT 0xffc8001c /* 16 bit */ +#define SH4_RSECAR 0xffc80020 +#define SH4_RMINAR 0xffc80024 +#define SH4_RHRAR 0xffc80028 +#define SH4_RWKAR 0xffc8002c +#define SH4_RDAYAR 0xffc80030 +#define SH4_RMONAR 0xffc80034 +#define SH4_RCR1 0xffc80038 +#define SH4_RCR2 0xffc8003c + +#define SH_RCR1_CF 0x80 /* carry flag */ +#define SH_RCR1_CIE 0x10 /* carry interrupt enable */ +#define SH_RCR1_AIE 0x08 /* alarm interrupt enable */ +#define SH_RCR1_AF 0x01 /* alarm flag */ + +#define SH_RCR2_PEF 0x80 /* periodic interrupt flag */ +#define SH_RCR2_PES2 0x40 /* periodic interrupt freq */ +#define SH_RCR2_PES1 0x20 /* -//- */ +#define SH_RCR2_PES0 0x10 /* -//- */ +#define SH_RCR2_ENABLE 0x08 +#define SH_RCR2_ADJ 0x04 /* second adjustment */ +#define SH_RCR2_RESET 0x02 +#define SH_RCR2_START 0x01 + +#ifndef _LOCORE +#if defined(SH3) && defined(SH4) +extern uint32_t __sh_R64CNT; +extern uint32_t __sh_RSECCNT; +extern uint32_t __sh_RMINCNT; +extern uint32_t __sh_RHRCNT; +extern uint32_t __sh_RWKCNT; +extern uint32_t __sh_RDAYCNT; +extern uint32_t __sh_RMONCNT; +extern uint32_t __sh_RYRCNT; +extern uint32_t __sh_RSECAR; +extern uint32_t __sh_RMINAR; +extern uint32_t __sh_RHRAR; +extern uint32_t __sh_RWKAR; +extern uint32_t __sh_RDAYAR; +extern uint32_t __sh_RMONAR; +extern uint32_t __sh_RCR1; +extern uint32_t __sh_RCR2; +#endif /* SH3 && SH4 */ +#endif /* !_LOCORE */ + +#endif /* !_SH_RTCREG_H_ */ diff --git a/sys/arch/sh/include/setjmp.h b/sys/arch/sh/include/setjmp.h new file mode 100644 index 00000000000..fb8887ca147 --- /dev/null +++ b/sys/arch/sh/include/setjmp.h @@ -0,0 +1,23 @@ +/* $OpenBSD: setjmp.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: setjmp.h,v 1.3 2006/01/05 00:50:23 uwe Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 14 /* size, in longs, of a jmp_buf */ + +#define _JB_REG_PR 0 +#define _JB_REG_R8 1 +#define _JB_REG_R9 2 +#define _JB_REG_R10 3 +#define _JB_REG_R11 4 +#define _JB_REG_R12 5 +#define _JB_REG_R13 6 +#define _JB_REG_R14 7 +#define _JB_REG_R15 8 + +#define _JB_HAS_MASK 9 +#define _JB_SIGMASK 10 /* occupies sizeof(sigset_t) = 4 slots */ + +#define _JB_REG_SP _JB_REG_R15 diff --git a/sys/arch/sh/include/sh_opcode.h b/sys/arch/sh/include/sh_opcode.h new file mode 100644 index 00000000000..3fad67a443c --- /dev/null +++ b/sys/arch/sh/include/sh_opcode.h @@ -0,0 +1,163 @@ +/* $OpenBSD: sh_opcode.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: sh_opcode.h,v 1.3 2002/04/28 17:10:36 uch Exp $ */ + +typedef union { + unsigned word; + +#if _BYTE_ORDER == BIG_ENDIAN + struct { + unsigned op: 16; + } oType; + + struct { + unsigned op1: 4; + unsigned n: 4; + unsigned op2: 8; + } nType; + + struct { + unsigned op1: 4; + unsigned m: 4; + unsigned op2: 8; + } mType; + + struct { + unsigned op1: 4; + unsigned n: 4; + unsigned m: 4; + unsigned op2: 4; + } nmType; + + struct { + unsigned op: 8; + unsigned m: 4; + unsigned d: 4; + } mdType; + + struct { + unsigned op: 8; + unsigned n: 4; + unsigned d: 4; + } nd4Type; + + struct { + unsigned op: 4; + unsigned n: 4; + unsigned m: 4; + unsigned d: 4; + } nmdType; + + struct { + unsigned op: 8; + unsigned d: 8; + } dType; + + struct { + unsigned op: 4; + unsigned d: 12; + } d12Type; + + struct { + unsigned op: 4; + unsigned n: 4; + unsigned d: 8; + } nd8Type; + + struct { + unsigned op: 8; + unsigned i: 8; + } iType; + + struct { + unsigned op: 4; + unsigned n: 4; + unsigned i: 8; + } niType; +#endif +#if _BYTE_ORDER == LITTLE_ENDIAN +struct { + unsigned op: 16; + } oType; + + struct { + unsigned op2: 8; + unsigned n: 4; + unsigned op1: 4; + } nType; + + struct { + unsigned op2: 8; + unsigned m: 4; + unsigned op1: 4; + } mType; + + struct { + unsigned op2: 4; + unsigned m: 4; + unsigned n: 4; + unsigned op1: 4; + } nmType; + + struct { + unsigned d: 4; + unsigned m: 4; + unsigned op: 8; + } mdType; + + struct { + unsigned d: 4; + unsigned n: 4; + unsigned op: 8; + } nd4Type; + + struct { + unsigned d: 4; + unsigned m: 4; + unsigned n: 4; + unsigned op: 4; + } nmdType; + + struct { + unsigned d: 8; + unsigned op: 8; + } dType; + + struct { + unsigned d: 12; + unsigned op: 4; + } d12Type; + + struct { + unsigned d: 8; + unsigned n: 4; + unsigned op: 4; + } nd8Type; + + struct { + unsigned i: 8; + unsigned op: 8; + } iType; + + struct { + unsigned i: 8; + unsigned n: 4; + unsigned op: 4; + } niType; +#endif +} InstFmt; + +#define OP_BF 0x8b +#define OP_BFS 0x8f +#define OP_BT 0x89 +#define OP_BTS 0x8d +#define OP_BRA 0xa +#define OP_BSR 0xb +#define OP1_BRAF 0x0 +#define OP2_BRAF 0x23 +#define OP1_BSRF 0x0 +#define OP2_BSRF 0x03 +#define OP1_JMP 0x4 +#define OP2_JMP 0x2b +#define OP1_JSR 0x4 +#define OP2_JSR 0x0b +#define OP_RTS 0xffff diff --git a/sys/arch/sh/include/signal.h b/sys/arch/sh/include/signal.h new file mode 100644 index 00000000000..b742e598ef5 --- /dev/null +++ b/sys/arch/sh/include/signal.h @@ -0,0 +1,80 @@ +/* $OpenBSD: signal.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: signal.h,v 1.12 2005/12/11 12:18:58 christos Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 7.16 (Berkeley) 3/17/91 + */ + +#ifndef _SH_SIGNAL_H_ +#define _SH_SIGNAL_H_ + +#include <sys/cdefs.h> + +typedef int sig_atomic_t; + +#if __BSD_VISIBLE || __XPG_VISIBLE >= 420 +/* + * Information pushed on stack when a signal is delivered. + * This is used by the kernel to restore state following + * execution of the signal handler. It is also made available + * to the handler to allow it to restore state properly if + * a non-standard exit is performed. + */ +struct sigcontext { + int sc_spc; + int sc_ssr; + int sc_pr; + int sc_r14; + int sc_r13; + int sc_r12; + int sc_r11; + int sc_r10; + int sc_r9; + int sc_r8; + int sc_r7; + int sc_r6; + int sc_r5; + int sc_r4; + int sc_r3; + int sc_r2; + int sc_r1; + int sc_r0; + int sc_r15; + + int sc_onstack; /* sigstack state to restore */ + + int sc_expevt; /* XXX should be above */ + int sc_err; + + unsigned int sc_mask; /* signal mask to restore */ +}; + +#endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */ +#endif /* !_SH_SIGNAL_H_ */ diff --git a/sys/arch/sh/include/spinlock.h b/sys/arch/sh/include/spinlock.h new file mode 100644 index 00000000000..6fc31bec819 --- /dev/null +++ b/sys/arch/sh/include/spinlock.h @@ -0,0 +1,52 @@ +/* $OpenBSD: spinlock.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: lock.h,v 1.10 2006/01/03 01:29:46 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gregory McGarry. + * + * 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. + */ + +/* + * Machine-dependent spin lock operations. + */ + +#ifndef _SH_SPINLOCK_H_ +#define _SH_SPINLOCK_H_ + +typedef volatile u_int8_t _spinlock_lock_t; + +#define _SPINLOCK_LOCKED 0x80 +#define _SPINLOCK_UNLOCKED 0x00 + +#endif /* !_SH_SPINLOCK_H_ */ diff --git a/sys/arch/sh/include/stdarg.h b/sys/arch/sh/include/stdarg.h new file mode 100644 index 00000000000..b6a7a3f7f88 --- /dev/null +++ b/sys/arch/sh/include/stdarg.h @@ -0,0 +1,60 @@ +/* $OpenBSD: stdarg.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: stdarg.h,v 1.9 2006/05/21 22:39:04 uwe Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)stdarg.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _SH_STDARG_H_ +#define _SH_STDARG_H_ + +#include <sys/cdefs.h> +#include <machine/_types.h> + +typedef __va_list va_list; + +#ifdef __lint__ +#define __builtin_next_arg(t) ((t) ? 0 : 0) +#define __builtin_stdarg_start(a, l) ((a) = ((l) ? 0 : 0)) +#define __builtin_va_arg(a, t) ((t)((a) ? 0 : 0)) +#define __builtin_va_end /* nothing */ +#define __builtin_va_copy(d, s) ((d) = (s)) +#endif + +#define va_start(ap, last) __builtin_stdarg_start((ap), (last)) +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#define __va_copy(dest, src) __builtin_va_copy((dest), (src)) + +#if __ISO_C_VISIBLE >= 1999 +#define va_copy(dest, src) __va_copy((dest), (src)) +#endif + +#endif /* !_SH_STDARG_H_ */ diff --git a/sys/arch/sh/include/tmureg.h b/sys/arch/sh/include/tmureg.h new file mode 100644 index 00000000000..959957bd8f2 --- /dev/null +++ b/sys/arch/sh/include/tmureg.h @@ -0,0 +1,115 @@ +/* $OpenBSD: tmureg.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: tmureg.h,v 1.11 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (C) 1999 SAITOH Masanobu. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_TMUREG_H_ +#define _SH_TMUREG_H_ +#include <sh/devreg.h> + +/* + * TMU + */ +#define SH3_TOCR 0xfffffe90 +#define SH3_TSTR 0xfffffe92 +#define SH3_TCOR0 0xfffffe94 +#define SH3_TCNT0 0xfffffe98 +#define SH3_TCR0 0xfffffe9c +#define SH3_TCOR1 0xfffffea0 +#define SH3_TCNT1 0xfffffea4 +#define SH3_TCR1 0xfffffea8 +#define SH3_TCOR2 0xfffffeac +#define SH3_TCNT2 0xfffffeb0 +#define SH3_TCR2 0xfffffeb4 +#define SH3_TCPR2 0xfffffeb8 + +#define SH4_TOCR 0xffd80000 +#define SH4_TSTR 0xffd80004 +#define SH4_TCOR0 0xffd80008 +#define SH4_TCNT0 0xffd8000c +#define SH4_TCR0 0xffd80010 +#define SH4_TCOR1 0xffd80014 +#define SH4_TCNT1 0xffd80018 +#define SH4_TCR1 0xffd8001c +#define SH4_TCOR2 0xffd80020 +#define SH4_TCNT2 0xffd80024 +#define SH4_TCR2 0xffd80028 +#define SH4_TCPR2 0xffd8002c +#define SH4_TSTR2 0xfe100004 +#define SH4_TCOR3 0xfe100008 +#define SH4_TCNT3 0xfe10000c +#define SH4_TCR3 0xfe100010 +#define SH4_TCOR4 0xfe100014 +#define SH4_TCNT4 0xfe100018 +#define SH4_TCR4 0xfe10001c + + +#define TOCR_TCOE 0x01 +#define TSTR_STR2 0x04 +#define TSTR_STR1 0x02 +#define TSTR_STR0 0x01 +#define TCR_ICPF 0x0200 +#define TCR_UNF 0x0100 +#define TCR_ICPE1 0x0080 +#define TCR_ICPE0 0x0040 +#define TCR_UNIE 0x0020 +#define TCR_CKEG1 0x0010 +#define TCR_CKEG0 0x0008 +#define TCR_TPSC2 0x0004 +#define TCR_TPSC1 0x0002 +#define TCR_TPSC0 0x0001 +#define TCR_TPSC_P4 0x0000 +#define TCR_TPSC_P16 0x0001 +#define TCR_TPSC_P64 0x0002 +#define TCR_TPSC_P256 0x0003 +#define SH3_TCR_TPSC_RTC 0x0004 +#define SH3_TCR_TPSC_TCLK 0x0005 +#define SH4_TCR_TPSC_P1024 0x0004 +#define SH4_TCR_TPSC_RTC 0x0006 +#define SH4_TCR_TPSC_TCLK 0x0007 +#define SH4_TSTR2_STR4 0x02 +#define SH4_TSTR2_STR3 0x01 + + +#ifndef _LOCORE +#if defined(SH3) && defined(SH4) +extern uint32_t __sh_TOCR; +extern uint32_t __sh_TSTR; +extern uint32_t __sh_TCOR0; +extern uint32_t __sh_TCNT0; +extern uint32_t __sh_TCR0; +extern uint32_t __sh_TCOR1; +extern uint32_t __sh_TCNT1; +extern uint32_t __sh_TCR1; +extern uint32_t __sh_TCOR2; +extern uint32_t __sh_TCNT2; +extern uint32_t __sh_TCR2; +extern uint32_t __sh_TCPR2; +#endif /* SH3 && SH4 */ +#endif /* !_LOCORE */ + +#endif /* !_SH_TMUREG_H_ */ diff --git a/sys/arch/sh/include/trap.h b/sys/arch/sh/include/trap.h new file mode 100644 index 00000000000..b3a4bca347b --- /dev/null +++ b/sys/arch/sh/include/trap.h @@ -0,0 +1,187 @@ +/* $OpenBSD: trap.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: exception.h,v 1.9 2006/07/22 21:58:29 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * 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 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. + */ + +#ifndef _SH_EXCEPTION_H_ +#define _SH_EXCEPTION_H_ +/* + * SH3/SH4 Exception handling. + */ +#include <sh/devreg.h> + +#ifdef _KERNEL +#define SH3_TRA 0xffffffd0 /* 32bit */ +#define SH3_EXPEVT 0xffffffd4 /* 32bit */ +#define SH3_INTEVT 0xffffffd8 /* 32bit */ +#define SH7709_INTEVT2 0xa4000000 /* 32bit */ + +#define SH4_TRA 0xff000020 /* 32bit */ +#define SH4_EXPEVT 0xff000024 /* 32bit */ +#define SH4_INTEVT 0xff000028 /* 32bit */ + +/* + * EXPEVT + */ +/* Reset exception */ +#define EXPEVT_RESET_POWER 0x000 /* Power-On reset */ +#define EXPEVT_RESET_MANUAL 0x020 /* Manual reset */ +#define EXPEVT_RESET_TLB_MULTI_HIT 0x140 /* SH4 only */ + +/* General exception */ +#define EXPEVT_TLB_MISS_LD 0x040 /* TLB miss (load) */ +#define EXPEVT_TLB_MISS_ST 0x060 /* TLB miss (store) */ +#define EXPEVT_TLB_MOD 0x080 /* Initial page write */ +#define EXPEVT_TLB_PROT_LD 0x0a0 /* Protection violation (load) */ +#define EXPEVT_TLB_PROT_ST 0x0c0 /* Protection violation (store)*/ +#define EXPEVT_ADDR_ERR_LD 0x0e0 /* Address error (load) */ +#define EXPEVT_ADDR_ERR_ST 0x100 /* Address error (store) */ +#define EXPEVT_FPU 0x120 /* FPU exception */ +#define EXPEVT_TRAPA 0x160 /* Unconditional trap (TRAPA) */ +#define EXPEVT_RES_INST 0x180 /* Illegal instruction */ +#define EXPEVT_SLOT_INST 0x1a0 /* Illegal slot instruction */ +#define EXPEVT_BREAK 0x1e0 /* User break */ +#define EXPEVT_FPU_DISABLE 0x800 /* FPU disabled */ +#define EXPEVT_FPU_SLOT_DISABLE 0x820 /* Slot FPU disabled */ + +/* Software bit */ +#define EXP_USER 0x001 /* exception from user-mode */ + +#define _SH_TRA_SYSCALL 0x80 /* syscall trapa number */ +#define _SH_TRA_BREAK 0xc3 /* magic number for debugger */ + +/* + * INTEVT/INTEVT2 + */ +/* External interrupt */ +#define SH_INTEVT_NMI 0x1c0 + +#define SH_INTEVT_TMU0_TUNI0 0x400 +#define SH_INTEVT_TMU1_TUNI1 0x420 +#define SH_INTEVT_TMU2_TUNI2 0x440 +#define SH_INTEVT_TMU2_TICPI2 0x460 + +#define SH_INTEVT_SCI_ERI 0x4e0 +#define SH_INTEVT_SCI_RXI 0x500 +#define SH_INTEVT_SCI_TXI 0x520 +#define SH_INTEVT_SCI_TEI 0x540 + +#define SH_INTEVT_WDT_ITI 0x560 + +#define SH_INTEVT_IRL9 0x320 +#define SH_INTEVT_IRL11 0x360 +#define SH_INTEVT_IRL13 0x3a0 + +#define SH4_INTEVT_SCIF_ERI 0x700 +#define SH4_INTEVT_SCIF_RXI 0x720 +#define SH4_INTEVT_SCIF_BRI 0x740 +#define SH4_INTEVT_SCIF_TXI 0x760 + +#define SH7709_INTEVT2_IRQ0 0x600 +#define SH7709_INTEVT2_IRQ1 0x620 +#define SH7709_INTEVT2_IRQ2 0x640 +#define SH7709_INTEVT2_IRQ3 0x660 +#define SH7709_INTEVT2_IRQ4 0x680 +#define SH7709_INTEVT2_IRQ5 0x6a0 + +#define SH7709_INTEVT2_PINT07 0x700 +#define SH7709_INTEVT2_PINT8F 0x720 + +#define SH7709_INTEVT2_DEI0 0x800 +#define SH7709_INTEVT2_DEI1 0x820 +#define SH7709_INTEVT2_DEI2 0x840 +#define SH7709_INTEVT2_DEI3 0x860 + +#define SH7709_INTEVT2_IRDA_ERI 0x880 +#define SH7709_INTEVT2_IRDA_RXI 0x8a0 +#define SH7709_INTEVT2_IRDA_BRI 0x8c0 +#define SH7709_INTEVT2_IRDA_TXI 0x8e0 + +#define SH7709_INTEVT2_SCIF_ERI 0x900 +#define SH7709_INTEVT2_SCIF_RXI 0x920 +#define SH7709_INTEVT2_SCIF_BRI 0x940 +#define SH7709_INTEVT2_SCIF_TXI 0x960 + +#define SH7709_INTEVT2_ADC 0x980 + +/* SH7750R, SH7751, SH7751R */ +#define SH4_INTEVT_IRL0 0x240 +#define SH4_INTEVT_IRL1 0x2a0 +#define SH4_INTEVT_IRL2 0x300 +#define SH4_INTEVT_IRL3 0x360 + +#define SH4_INTEVT_IRQ0 0x200 +#define SH4_INTEVT_IRQ1 0x220 +#define SH4_INTEVT_IRQ2 0x240 +#define SH4_INTEVT_IRQ3 0x260 +#define SH4_INTEVT_IRQ4 0x280 +#define SH4_INTEVT_IRQ5 0x2a0 +#define SH4_INTEVT_IRQ6 0x2c0 +#define SH4_INTEVT_IRQ7 0x2e0 +#define SH4_INTEVT_IRQ8 0x300 +#define SH4_INTEVT_IRQ9 0x320 +#define SH4_INTEVT_IRQ10 0x340 +#define SH4_INTEVT_IRQ11 0x360 +#define SH4_INTEVT_IRQ12 0x380 +#define SH4_INTEVT_IRQ13 0x3a0 +#define SH4_INTEVT_IRQ14 0x3c0 +#define SH4_INTEVT_IRQ15 0x3e0 + +#define SH4_INTEVT_TMU3 0xb00 +#define SH4_INTEVT_TMU4 0xb80 + +#define SH4_INTEVT_PCISERR 0xa00 +#define SH4_INTEVT_PCIERR 0xae0 +#define SH4_INTEVT_PCIPWDWN 0xac0 +#define SH4_INTEVT_PCIPWON 0xaa0 +#define SH4_INTEVT_PCIDMA0 0xa80 +#define SH4_INTEVT_PCIDMA1 0xa60 +#define SH4_INTEVT_PCIDMA2 0xa40 +#define SH4_INTEVT_PCIDMA3 0xa20 + +#ifndef _LOCORE + +#if defined(SH3) && defined(SH4) +extern uint32_t __sh_TRA; +extern uint32_t __sh_EXPEVT; +extern uint32_t __sh_INTEVT; +#endif /* SH3 && SH4 */ + +extern const char * const exp_type[]; +extern const int exp_types; + +#endif /* !_LOCORE */ + +#endif /* _KERNEL */ +#endif /* !_SH_EXCEPTION_H_ */ diff --git a/sys/arch/sh/include/ubcreg.h b/sys/arch/sh/include/ubcreg.h new file mode 100644 index 00000000000..dacbfa52f1d --- /dev/null +++ b/sys/arch/sh/include/ubcreg.h @@ -0,0 +1,86 @@ +/* $OpenBSD: ubcreg.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: ubcreg.h,v 1.4 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (C) 1999 SAITOH Masanobu. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SH_UBCREG_H_ +#define _SH_UBCREG_H_ +#include <sh/devreg.h> + +/* + * User Break Controller + */ + +/* ch-A */ +#define SH3_BARA 0xffffffb0 +#define SH3_BAMRA 0xffffffb4 +#define SH3_BASRA 0xffffffe4 +#define SH3_BBRA 0xffffffb8 +/* ch-B */ +#define SH3_BARB 0xffffffa0 +#define SH3_BAMRB 0xffffffa4 +#define SH3_BASRB 0xffffffe8 +#define SH3_BBRB 0xffffffa8 +#define SH3_BDRB 0xffffff90 +#define SH3_BDMRB 0xffffff94 +/* common */ +#define SH3_BRCR 0xffffff98 + + +/* ch-A */ +#define SH4_BARA 0xff200000 +#define SH4_BAMRA 0xff200004 +#define SH4_BASRA 0xff000014 +#define SH4_BBRA 0xff200008 + +/* ch-B */ +#define SH4_BARB 0xff20000c +#define SH4_BAMRB 0xff200010 +#define SH4_BASRB 0xff000018 +#define SH4_BBRB 0xff200014 +#define SH4_BDRB 0xff200018 +#define SH4_BDMRB 0xff20001c +/* common */ +#define SH4_BRCR 0xff200020 + +#ifndef _LOCORE +#if defined(SH3) && defined(SH4) +extern uint32_t __sh_BARA; +extern uint32_t __sh_BAMRA; +extern uint32_t __sh_BASRA; +extern uint32_t __sh_BBRA; +extern uint32_t __sh_BARB; +extern uint32_t __sh_BAMRB; +extern uint32_t __sh_BASRB; +extern uint32_t __sh_BBRB; +extern uint32_t __sh_BDRB; +extern uint32_t __sh_BDMRB; +extern uint32_t __sh_BRCR; +#endif /* SH3 && SH4 */ +#endif /* !_LOCORE */ + +#endif /* !_SH_UBCREG_H_ */ diff --git a/sys/arch/sh/include/userret.h b/sys/arch/sh/include/userret.h new file mode 100644 index 00000000000..07db83959a2 --- /dev/null +++ b/sys/arch/sh/include/userret.h @@ -0,0 +1,94 @@ +/* $OpenBSD: userret.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: userret.h,v 1.9 2006/02/16 20:17:15 perry Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and Ralph Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: Utah Hdr: trap.c 1.32 91/04/06 + * + * @(#)trap.c 8.5 (Berkeley) 1/11/94 + */ +/* + * Copyright (c) 1988 University of Utah. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and Ralph Campbell. + * + * 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: Utah Hdr: trap.c 1.32 91/04/06 + * + * @(#)trap.c 8.5 (Berkeley) 1/11/94 + */ + +#include <sys/signalvar.h> +#include <machine/cpu.h> + +static __inline void userret(struct proc *); + +static __inline void +userret(struct proc *p) +{ + int sig; + + while ((sig = CURSIG(p)) != 0) + postsig(sig); + + curpriority = p->p_priority = p->p_usrpri; +} diff --git a/sys/arch/sh/include/varargs.h b/sys/arch/sh/include/varargs.h new file mode 100644 index 00000000000..6fae10957e0 --- /dev/null +++ b/sys/arch/sh/include/varargs.h @@ -0,0 +1,57 @@ +/* $OpenBSD: varargs.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: varargs.h,v 1.7 2006/05/21 22:39:04 uwe Exp $ */ + +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)varargs.h 8.2 (Berkeley) 3/22/94 + */ + +#ifndef _SH_VARARGS_H_ +#define _SH_VARARGS_H_ + +#include <machine/stdarg.h> + +#if __GNUC__ == 1 +#define __va_ellipsis +#else +#define __va_ellipsis ... +#endif + +#define va_alist __builtin_va_alist +#define va_dcl __builtin_va_alist_t __builtin_va_alist; __va_ellipsis + +#undef va_start +#define va_start(ap) __builtin_varargs_start((ap)) + +#endif /* !_SH_VARARGS_H_ */ diff --git a/sys/arch/sh/include/vmparam.h b/sys/arch/sh/include/vmparam.h new file mode 100644 index 00000000000..c9bf886ac4d --- /dev/null +++ b/sys/arch/sh/include/vmparam.h @@ -0,0 +1,107 @@ +/* $OpenBSD: vmparam.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $NetBSD: vmparam.h,v 1.17 2006/03/04 01:55:03 uwe Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * + * 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. + */ + +#ifndef _SH_VMPARAM_H_ +#define _SH_VMPARAM_H_ +#include <sys/queue.h> + +/* Virtual address map. */ +#define VM_MIN_ADDRESS ((vaddr_t)0) +#define VM_MAXUSER_ADDRESS ((vaddr_t)0x7ffff000) +#define VM_MAX_ADDRESS ((vaddr_t)0x7ffff000) +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xc0000000) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xe0000000) + +/* top of stack */ +#define USRSTACK VM_MAXUSER_ADDRESS + +/* Virtual memory resoruce limit. */ +#define MAXTSIZ (64 * 1024 * 1024) /* max text size */ +#ifndef MAXDSIZ +#define MAXDSIZ (512 * 1024 * 1024) /* max data size */ +#endif +#ifndef MAXSSIZ +#define MAXSSIZ (32 * 1024 * 1024) /* max stack size */ +#endif + +/* initial data size limit */ +#ifndef DFLDSIZ +#define DFLDSIZ (128 * 1024 * 1024) +#endif +/* initial stack size limit */ +#ifndef DFLSSIZ +#define DFLSSIZ (2 * 1024 * 1024) +#endif + +#define STACKGAP_RANDOM (256 * 1024) + +/* + * Size of shared memory map + */ +#ifndef SHMMAXPGS +#define SHMMAXPGS 1024 +#endif + +/* Size of user raw I/O map */ +#ifndef USRIOSIZE +#define USRIOSIZE (MAXBSIZE / PAGE_SIZE * 8) +#endif + +#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE) + +/* pmap-specific data store in the vm_page structure. */ +#define __HAVE_VM_PAGE_MD +#define PVH_REFERENCED 1 +#define PVH_MODIFIED 2 + +#ifndef _LOCORE +struct pv_entry; +struct vm_page_md { + SLIST_HEAD(, pv_entry) pvh_head; + int pvh_flags; +}; + +#define VM_MDPAGE_INIT(pg) \ +do { \ + struct vm_page_md *pvh = &(pg)->mdpage; \ + SLIST_INIT(&pvh->pvh_head); \ + pvh->pvh_flags = 0; \ +} while (/*CONSTCOND*/0) +#endif /* _LOCORE */ +#endif /* !_SH_VMPARAM_H_ */ |