diff --git a/include/arch/arm/include/ansi.h b/include/arch/arm/include/ansi.h new file mode 100644 index 000000000..a8271d954 --- /dev/null +++ b/include/arch/arm/include/ansi.h @@ -0,0 +1,67 @@ +/* $NetBSD: ansi.h,v 1.12 2010/03/27 22:14:09 tnozaki 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. + * + * from: @(#)ansi.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _ANSI_H_ +#define _ANSI_H_ + +#include + +#include + +/* + * Types which are fundamental to the implementation and may appear in + * more than one standard header are defined here. Standard headers + * then use: + * #ifdef _BSD_SIZE_T_ + * typedef _BSD_SIZE_T_ size_t; + * #undef _BSD_SIZE_T_ + * #endif + */ +#define _BSD_CLOCK_T_ unsigned int /* clock() */ +#define _BSD_PTRDIFF_T_ long int /* ptr1 - ptr2 */ +#define _BSD_SIZE_T_ unsigned long int /* sizeof() */ +#define _BSD_SSIZE_T_ long int /* byte count or error */ +#define _BSD_TIME_T_ __int64_t /* time() */ +#if __GNUC_PREREQ__(2, 96) +#define _BSD_VA_LIST_ __builtin_va_list /* GCC built-in type */ +#else +#define _BSD_VA_LIST_ char * /* va_list */ +#endif +#define _BSD_CLOCKID_T_ int /* clockid_t */ +#define _BSD_TIMER_T_ int /* timer_t */ +#define _BSD_SUSECONDS_T_ int /* suseconds_t */ +#define _BSD_USECONDS_T_ unsigned int /* useconds_t */ +#define _BSD_WCHAR_T_ int /* wchar_t */ +#define _BSD_WINT_T_ int /* wint_t */ + +#endif /* _ANSI_H_ */ diff --git a/include/arch/arm/include/asm.h b/include/arch/arm/include/asm.h new file mode 100644 index 000000000..0bd8b55ce --- /dev/null +++ b/include/arch/arm/include/asm.h @@ -0,0 +1,184 @@ +/* $NetBSD: asm.h,v 1.14 2011/06/30 20:09:20 wiz 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. + * + * from: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _ARM32_ASM_H_ +#define _ARM32_ASM_H_ + +#include + +#define _C_LABEL(x) x +#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 + +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 0 +#endif + +/* + * gas/arm uses @ as a single comment character and thus cannot be used here + * Instead it recognised the # instead of an @ symbols in .type directives + * We define a couple of macros so that assembly code will not be dependent + * on one or the other. + */ +#define _ASM_TYPE_FUNCTION %function +#define _ASM_TYPE_OBJECT %object +#ifdef __thumb__ +#define _ENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; .thumb_func; x: +#else +#define _ENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: +#endif +#define _END(x) .size x,.-x +#define _LABEL(x) \ + .globl x; x: + +#ifdef GPROF +# define _PROF_PROLOGUE \ + mov ip, lr; bl __mcount +#else +# define _PROF_PROLOGUE +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)) +#define END(y) _END(_C_LABEL(y)) +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE +#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) +#define ASEND(y) _END(_ASM_LABEL(y)) +#define LABEL(y) _LABEL(_C_LABEL(y)) + +#define ASMSTR .asciz + +#if defined(PIC) +#ifdef __thumb__ +#define PLT_SYM(x) x +#define GOT_SYM(x) PIC_SYM(x, GOTOFF) +#define GOT_GET(x,got,sym) \ + ldr x, sym; \ + add x, got; \ + ldr x, [x] +#else +#define PLT_SYM(x) PIC_SYM(x, PLT) +#define GOT_SYM(x) PIC_SYM(x, GOT) +#define GOT_GET(x,got,sym) \ + ldr x, sym; \ + ldr x, [x, got] +#endif /* __thumb__ */ + +#define GOT_INIT(got,gotsym,pclabel) \ + ldr got, gotsym; \ + add got, got, pc; \ + pclabel: +#define GOT_INITSYM(gotsym,pclabel) \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (pclabel+4)) + +#ifdef __STDC__ +#define PIC_SYM(x,y) x ## ( ## y ## ) +#else +#define PIC_SYM(x,y) x/**/(/**/y/**/) +#endif + +#else +#define PLT_SYM(x) x +#define GOT_SYM(x) x +#define GOT_GET(x,got,sym) \ + ldr x, sym; +#define GOT_INIT(got,gotsym,pclabel) +#define GOT_INITSYM(gotsym,pclabel) +#define PIC_SYM(x,y) x +#endif /* PIC */ + +#define RCSID(x) .pushsection ".ident"; .asciz x; .popsection + +#define WEAK_ALIAS(alias,sym) \ + .weak alias; \ + alias = sym + +/* + * STRONG_ALIAS: create a strong alias. + */ +#define STRONG_ALIAS(alias,sym) \ + .globl alias; \ + alias = sym + +#ifdef __STDC__ +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning. ## sym; \ + .ascii msg; \ + .popsection +#else +#define WARN_REFERENCES(sym,msg) \ + .pushsection .gnu.warning./**/sym; \ + .ascii msg; \ + .popsection +#endif /* __STDC__ */ + +#ifdef __thumb__ +# define XPUSH push +# define XPOP pop +# define XPOPRET pop {pc} +#else +# define XPUSH stmfd sp!, +# define XPOP ldmfd sp!, +# ifdef _ARM_ARCH_5 +# define XPOPRET ldmfd sp!, {pc} +# else +# define XPOPRET ldmfd sp!, {lr}; mov pc, lr +# endif +#endif + +#if defined (_ARM_ARCH_4T) +# define RET bx lr +# define RETc(c) __CONCAT(bx,c) lr +#else +# define RET mov pc, lr +# define RETc(c) __CONCAT(mov,c) pc, lr +#endif + +#ifdef __minix +#define IMPORT(sym) \ + .extern _C_LABEL(sym) +#endif + +#endif /* !_ARM_ASM_H_ */ diff --git a/include/arch/arm/include/bswap.h b/include/arch/arm/include/bswap.h new file mode 100644 index 000000000..ec0d6673c --- /dev/null +++ b/include/arch/arm/include/bswap.h @@ -0,0 +1,11 @@ +/* $NetBSD: bswap.h,v 1.4 2006/01/31 07:49:18 dsl Exp $ */ + +#ifndef _MACHINE_BSWAP_H_ +#define _MACHINE_BSWAP_H_ + +#include + +#define __BSWAP_RENAME +#include + +#endif /* !_MACHINE_BSWAP_H_ */ diff --git a/include/arch/arm/include/byte_swap.h b/include/arch/arm/include/byte_swap.h new file mode 100644 index 000000000..d113d5668 --- /dev/null +++ b/include/arch/arm/include/byte_swap.h @@ -0,0 +1,82 @@ +/* $NetBSD: byte_swap.h,v 1.8 2008/04/28 20:23:14 martin Exp $ */ + +/*- + * Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum, Neil A. Carson, and Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_BYTE_SWAP_H_ +#define _ARM_BYTE_SWAP_H_ + +#ifdef __GNUC__ +#include +__BEGIN_DECLS + +#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable +static __inline uint32_t +__byte_swap_u32_variable(uint32_t v) +{ +#ifdef _ARM_ARCH_6 + __asm("rev\t%0, %1" : "=r" (v) : "0" (v)); +#else + uint32_t t1; + + t1 = v ^ ((v << 16) | (v >> 16)); + t1 &= 0xff00ffffU; + v = (v >> 8) | (v << 24); + v ^= (t1 >> 8); +#endif + return (v); +} + +#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable +static __inline uint16_t +__byte_swap_u16_variable(uint16_t v) +{ + +#ifdef _ARM_ARCH_6 + __asm("rev16\t%0, %1" : "=r" (v) : "0" (v)); +#elif !defined(__thumb__) + __asm volatile( + "mov %0, %1, ror #8\n" + "orr %0, %0, %0, lsr #16\n" + "bic %0, %0, %0, lsl #16" + : "=r" (v) + : "0" (v)); +#else + v &= 0xffff; + v = (v >> 8) | (v << 8); +#endif + + return (v); +} + +__END_DECLS +#endif + + +#endif /* _ARM_BYTE_SWAP_H_ */ diff --git a/include/arch/arm/include/cdefs.h b/include/arch/arm/include/cdefs.h new file mode 100644 index 000000000..910708a4a --- /dev/null +++ b/include/arch/arm/include/cdefs.h @@ -0,0 +1,22 @@ +/* $NetBSD: cdefs.h,v 1.4 2012/01/20 14:08:05 joerg Exp $ */ + +#ifndef _MACHINE_CDEFS_H_ +#define _MACHINE_CDEFS_H_ + +#if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) +#define _ARM_ARCH_6 +#endif + +#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5__) || \ + defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5TE__) || \ + defined (__ARM_ARCH_5TEJ__) +#define _ARM_ARCH_5 +#endif + +#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__) +#define _ARM_ARCH_4T +#endif + +#define __ALIGNBYTES (sizeof(int) - 1) + +#endif /* !_MACHINE_CDEFS_H_ */ diff --git a/include/arch/arm/include/disklabel.h b/include/arch/arm/include/disklabel.h new file mode 100644 index 000000000..69aa0ebd2 --- /dev/null +++ b/include/arch/arm/include/disklabel.h @@ -0,0 +1,83 @@ +/* $NetBSD: disklabel.h,v 1.9 2009/11/23 13:40:09 pooka 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 8 /* number of partitions */ +#define RAW_PART 2 /* raw partition: XX?c */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#include +#include +#else +#include +#include +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + struct dkbad bad; +}; + +#ifdef _KERNEL +struct buf; +struct disklabel; + +/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */ +int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *, const char **, int *, int *); + +/* for writedisklabel. rv == 0 -> dosen't match, rv > 0 -> success */ +int mbr_label_locate(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *, int *, int *); +#endif /* _KERNEL */ + +#endif /* _ARM_DISKLABEL_H_ */ diff --git a/include/arch/arm/include/elf.h b/include/arch/arm/include/elf.h new file mode 100644 index 000000000..a77092bb0 --- /dev/null +++ b/include/arch/arm/include/elf.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 1996-1997 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_ELF_H_ +#define _MACHINE_ELF_H_ 1 + +/* + * ELF definitions for the ARM architecture. + */ + +/* Define "machine" characteristics */ +#define ELF_TARG_CLASS ELFCLASS32 +#define ELF_TARG_DATA ELFDATA2LSB +#define ELF_TARG_MACH EM_ARM +#define ELF_TARG_VER 1 + +#endif /* !_MACHINE_ELF_H_ */ diff --git a/include/arch/arm/include/elf_machdep.h b/include/arch/arm/include/elf_machdep.h new file mode 100644 index 000000000..963ff6401 --- /dev/null +++ b/include/arch/arm/include/elf_machdep.h @@ -0,0 +1,117 @@ +/* $NetBSD: elf_machdep.h,v 1.8 2009/05/30 05:56:52 skrll Exp $ */ + +#if defined(__ARMEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_EABIMASK 0xff000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF32_MACHDEP_ID EM_ARM + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 + +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ + +/* 20-31 are reserved for ARM Linux. */ +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 + +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_ALU_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 + +/* 96-111 are reserved to G++. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 + +/* More TLS relocations */ +#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ +#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ +#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ +#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 + +/* 112-127 are reserved for private experiments. */ + +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_TYPE(name) __CONCAT(R_ARM_,name) + +/* Processor specific program header flags */ +#define PF_ARM_SB 0x10000000 +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ENTRY 0x80000000 + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +/* Processor specific symbol types */ +#define STT_ARM_TFUNC STT_LOPROC diff --git a/include/arch/arm/include/endian.h b/include/arch/arm/include/endian.h new file mode 100644 index 000000000..927822e11 --- /dev/null +++ b/include/arch/arm/include/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.3 2001/06/23 12:20:27 bjh21 Exp $ */ + +#include diff --git a/include/arch/arm/include/endian_machdep.h b/include/arch/arm/include/endian_machdep.h new file mode 100644 index 000000000..96634547e --- /dev/null +++ b/include/arch/arm/include/endian_machdep.h @@ -0,0 +1,8 @@ +/* $NetBSD: endian_machdep.h,v 1.8 2006/01/30 21:52:38 dsl Exp $ */ + +/* GCC predefines __ARMEB__ when building for big-endian ARM. */ +#ifdef __ARMEB__ +#define _BYTE_ORDER _BIG_ENDIAN +#else +#define _BYTE_ORDER _LITTLE_ENDIAN +#endif diff --git a/include/arch/arm/include/float.h b/include/arch/arm/include/float.h new file mode 100644 index 000000000..6f339fb53 --- /dev/null +++ b/include/arch/arm/include/float.h @@ -0,0 +1,31 @@ +/* $NetBSD: float.h,v 1.6 2005/12/11 12:16:47 christos Exp $ */ + +#ifndef _ARM_FLOAT_H_ +#define _ARM_FLOAT_H_ + +#ifndef __VFP_FP__ +#define LDBL_MANT_DIG 64 +#define LDBL_EPSILON 1.0842021724855044340E-19L +#define LDBL_DIG 18 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MIN 1.6810515715560467531E-4932L +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_EXP 16384 +#define LDBL_MAX 1.1897314953572317650E+4932L +#define LDBL_MAX_10_EXP 4932 +#endif + +#include + +#ifndef __VFP_FP__ +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_XOPEN_SOURCE) || \ + ((__STDC_VERSION__ - 0) >= 199901L) || \ + ((_POSIX_C_SOURCE - 0) >= 200112L) || \ + ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) +#define DECIMAL_DIG 21 +#endif /* !defined(_ANSI_SOURCE) && ... */ +#endif /* !__VFP_FP__ */ + +#endif /* !_ARM_FLOAT_H_ */ diff --git a/include/arch/arm/include/ieee.h b/include/arch/arm/include/ieee.h new file mode 100644 index 000000000..1319178ac --- /dev/null +++ b/include/arch/arm/include/ieee.h @@ -0,0 +1,13 @@ +/* $NetBSD: ieee.h,v 1.9 2005/12/11 12:16:47 christos Exp $ */ + +#include + +/* + * 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'. + */ + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#endif diff --git a/include/arch/arm/include/ieeefp.h b/include/arch/arm/include/ieeefp.h new file mode 100644 index 000000000..08d0ef17a --- /dev/null +++ b/include/arch/arm/include/ieeefp.h @@ -0,0 +1,58 @@ +/* $NetBSD: ieeefp.h,v 1.2 2008/08/05 16:47:41 matt Exp $ */ + +/* + * Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995 + * Public domain. + */ + +#ifndef _ARM32_IEEEFP_H_ +#define _ARM32_IEEEFP_H_ + +#include + +#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE) + +typedef int fenv_t; +typedef int fexcept_t; + +#define FE_INVALID 0x01 /* invalid operation exception */ +#define FE_DIVBYZERO 0x02 /* divide-by-zero exception */ +#define FE_OVERFLOW 0x04 /* overflow exception */ +#define FE_UNDERFLOW 0x08 /* underflow exception */ +#define FE_INEXACT 0x10 /* imprecise (loss of precision; "inexact") */ + +#define FE_ALL_EXCEPT 0x1f + +#define FE_TONEAREST 0 /* round to nearest representable number */ +#define FE_UPWARD 1 /* round toward positive infinity */ +#define FE_DOWNWARD 2 /* round toward negative infinity */ +#define FE_TOWARDZERO 3 /* round to zero (truncate) */ + +#if !defined(_ISOC99_SOURCE) + +/* Exception type (used by fpsetmask() et al.) */ + +typedef int fp_except; + +/* Bit defines for fp_except */ + +#define FP_X_INV FE_INVALID /* invalid operation exception */ +#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */ +#define FP_X_OFL FE_OVERFLOW /* overflow exception */ +#define FP_X_UFL FE_UNDERFLOW /* underflow exception */ +#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */ + +/* Rounding modes */ + +typedef enum { + FP_RN=FE_TONEAREST, /* round to nearest representable number */ + FP_RP=FE_UPWARD, /* round toward positive infinity */ + FP_RM=FE_DOWNWARD, /* round toward negative infinity */ + FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */ +} fp_rnd; + +#endif /* !_ISOC99_SOURCE */ + +#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */ + +#endif /* _ARM32_IEEEFP_H_ */ diff --git a/include/arch/arm/include/int_const.h b/include/arch/arm/include/int_const.h new file mode 100644 index 000000000..264ae5dc5 --- /dev/null +++ b/include/arch/arm/include/int_const.h @@ -0,0 +1,56 @@ +/* $NetBSD: int_const.h,v 1.3 2010/05/29 17:33:57 tnozaki Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_INT_CONST_H_ +#define _ARM_INT_CONST_H_ + +/* + * 7.18.4 Macros for integer constants + */ + +/* 7.18.4.1 Macros for minimum-width integer constants */ + +#define INT8_C(c) c +#define INT16_C(c) c +#define INT32_C(c) c +#define INT64_C(c) c ## LL + +#define UINT8_C(c) c +#define UINT16_C(c) c +#define UINT32_C(c) c ## U +#define UINT64_C(c) c ## ULL + +/* 7.18.4.2 Macros for greatest-width integer constants */ + +#define INTMAX_C(c) c ## LL +#define UINTMAX_C(c) c ## ULL + +#endif /* !_ARM_INT_CONST_H_ */ diff --git a/include/arch/arm/include/int_fmtio.h b/include/arch/arm/include/int_fmtio.h new file mode 100644 index 000000000..f387c82e4 --- /dev/null +++ b/include/arch/arm/include/int_fmtio.h @@ -0,0 +1,212 @@ +/* $NetBSD: int_fmtio.h,v 1.5 2008/08/29 19:08:29 matt Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_INT_FMTIO_H_ +#define _ARM_INT_FMTIO_H_ + +/* + * 7.8.1 Macros for format specifiers + */ + +/* fprintf macros for signed integers */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 "lld" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 "lld" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 "lld" /* int_fast64_t */ +#define PRIdMAX "lld" /* intmax_t */ +#define PRIdPTR "ld" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 "lli" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 "lli" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 "lli" /* int_fast64_t */ +#define PRIiMAX "lli" /* intmax_t */ +#define PRIiPTR "li" /* intptr_t */ + +/* fprintf macros for unsigned integers */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 "llo" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 "llo" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 "llo" /* uint_fast64_t */ +#define PRIoMAX "llo" /* uintmax_t */ +#define PRIoPTR "lo" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 "llu" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 "llu" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 "llu" /* uint_fast64_t */ +#define PRIuMAX "llu" /* uintmax_t */ +#define PRIuPTR "lu" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 "llx" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 "llx" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 "llx" /* uint_fast64_t */ +#define PRIxMAX "llx" /* uintmax_t */ +#define PRIxPTR "lx" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 "llX" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 "llX" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 "llX" /* uint_fast64_t */ +#define PRIXMAX "llX" /* uintmax_t */ +#define PRIXPTR "lX" /* uintptr_t */ + +/* fscanf macros for signed integers */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 "lld" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 "lld" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 "lld" /* int_fast64_t */ +#define SCNdMAX "lld" /* intmax_t */ +#define SCNdPTR "ld" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 "lli" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 "lli" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 "lli" /* int_fast64_t */ +#define SCNiMAX "lli" /* intmax_t */ +#define SCNiPTR "li" /* intptr_t */ + +/* fscanf macros for unsigned integers */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 "llo" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 "llo" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 "llo" /* uint_fast64_t */ +#define SCNoMAX "llo" /* uintmax_t */ +#define SCNoPTR "lo" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 "llu" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 "llu" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 "llu" /* uint_fast64_t */ +#define SCNuMAX "llu" /* uintmax_t */ +#define SCNuPTR "lu" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 "llx" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 "llx" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 "llx" /* uint_fast64_t */ +#define SCNxMAX "llx" /* uintmax_t */ +#define SCNxPTR "lx" /* uintptr_t */ + +#endif /* !_ARM_INT_FMTIO_H_ */ diff --git a/include/arch/arm/include/int_limits.h b/include/arch/arm/include/int_limits.h new file mode 100644 index 000000000..0808402a4 --- /dev/null +++ b/include/arch/arm/include/int_limits.h @@ -0,0 +1,127 @@ +/* $NetBSD: int_limits.h,v 1.9 2008/08/29 19:08:29 matt Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_INT_LIMITS_H_ +#define _ARM_INT_LIMITS_H_ + +/* + * 7.18.2 Limits of specified-width integer types + */ + +/* 7.18.2.1 Limits of exact-width integer types */ + +/* minimum values of exact-width signed integer types */ +#define INT8_MIN (-0x7f-1) /* int8_t */ +#define INT16_MIN (-0x7fff-1) /* int16_t */ +#define INT32_MIN (-0x7fffffff-1) /* int32_t */ +#define INT64_MIN (-0x7fffffffffffffffLL-1) /* int64_t */ + +/* maximum values of exact-width signed integer types */ +#define INT8_MAX 0x7f /* int8_t */ +#define INT16_MAX 0x7fff /* int16_t */ +#define INT32_MAX 0x7fffffff /* int32_t */ +#define INT64_MAX 0x7fffffffffffffffLL /* int64_t */ + +/* maximum values of exact-width unsigned integer types */ +#define UINT8_MAX 0xff /* uint8_t */ +#define UINT16_MAX 0xffff /* uint16_t */ +#define UINT32_MAX 0xffffffffU /* uint32_t */ +#define UINT64_MAX 0xffffffffffffffffULL /* uint64_t */ + +/* 7.18.2.2 Limits of minimum-width integer types */ + +/* minimum values of minimum-width signed integer types */ +#define INT_LEAST8_MIN (-0x7f-1) /* int_least8_t */ +#define INT_LEAST16_MIN (-0x7fff-1) /* int_least16_t */ +#define INT_LEAST32_MIN (-0x7fffffff-1) /* int_least32_t */ +#define INT_LEAST64_MIN (-0x7fffffffffffffffLL-1) /* int_least64_t */ + +/* maximum values of minimum-width signed integer types */ +#define INT_LEAST8_MAX 0x7f /* int_least8_t */ +#define INT_LEAST16_MAX 0x7fff /* int_least16_t */ +#define INT_LEAST32_MAX 0x7fffffff /* int_least32_t */ +#define INT_LEAST64_MAX 0x7fffffffffffffffLL /* int_least64_t */ + +/* maximum values of minimum-width unsigned integer types */ +#define UINT_LEAST8_MAX 0xff /* uint_least8_t */ +#define UINT_LEAST16_MAX 0xffff /* uint_least16_t */ +#define UINT_LEAST32_MAX 0xffffffffU /* uint_least32_t */ +#define UINT_LEAST64_MAX 0xffffffffffffffffULL /* uint_least64_t */ + +/* 7.18.2.3 Limits of fastest minimum-width integer types */ + +/* minimum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MIN (-0x7fffffff-1) /* int_fast8_t */ +#define INT_FAST16_MIN (-0x7fffffff-1) /* int_fast16_t */ +#define INT_FAST32_MIN (-0x7fffffff-1) /* int_fast32_t */ +#define INT_FAST64_MIN (-0x7fffffffffffffffLL-1) /* int_fast64_t */ + +/* maximum values of fastest minimum-width signed integer types */ +#define INT_FAST8_MAX 0x7fffffff /* int_fast8_t */ +#define INT_FAST16_MAX 0x7fffffff /* int_fast16_t */ +#define INT_FAST32_MAX 0x7fffffff /* int_fast32_t */ +#define INT_FAST64_MAX 0x7fffffffffffffffLL /* int_fast64_t */ + +/* maximum values of fastest minimum-width unsigned integer types */ +#define UINT_FAST8_MAX 0xffffffffU /* uint_fast8_t */ +#define UINT_FAST16_MAX 0xffffffffU /* uint_fast16_t */ +#define UINT_FAST32_MAX 0xffffffffU /* uint_fast32_t */ +#define UINT_FAST64_MAX 0xffffffffffffffffULL /* uint_fast64_t */ + +/* 7.18.2.4 Limits of integer types capable of holding object pointers */ + +#define INTPTR_MIN (-0x7fffffffL-1) /* intptr_t */ +#define INTPTR_MAX 0x7fffffffL /* intptr_t */ +#define UINTPTR_MAX 0xffffffffUL /* uintptr_t */ + +/* 7.18.2.5 Limits of greatest-width integer types */ + +#define INTMAX_MIN (-0x7fffffffffffffffLL-1) /* intmax_t */ +#define INTMAX_MAX 0x7fffffffffffffffLL /* intmax_t */ +#define UINTMAX_MAX 0xffffffffffffffffULL /* uintmax_t */ + + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of ptrdiff_t */ +#define PTRDIFF_MIN (-0x7fffffffL-1) /* ptrdiff_t */ +#define PTRDIFF_MAX 0x7fffffffL /* ptrdiff_t */ + +/* limits of sig_atomic_t */ +#define SIG_ATOMIC_MIN (-0x7fffffff-1) /* sig_atomic_t */ +#define SIG_ATOMIC_MAX 0x7fffffff /* sig_atomic_t */ + +/* limit of size_t */ +#define SIZE_MAX 0xffffffffUL /* size_t */ + +#endif /* !_ARM_INT_LIMITS_H_ */ diff --git a/include/arch/arm/include/int_mwgwtypes.h b/include/arch/arm/include/int_mwgwtypes.h new file mode 100644 index 000000000..c368b246f --- /dev/null +++ b/include/arch/arm/include/int_mwgwtypes.h @@ -0,0 +1,86 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.4 2008/04/28 20:23:14 martin Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_INT_MWGWTYPES_H_ +#define _ARM_INT_MWGWTYPES_H_ + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.2 Minimum-width integer types */ + +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int int_least16_t; +typedef unsigned short int uint_least16_t; +typedef int int_least32_t; +typedef unsigned int uint_least32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_least64_t; +typedef __COMPILER_UINT64__ uint_least64_t; +#else +/* LONGLONG */ +typedef long long int int_least64_t; +/* LONGLONG */ +typedef unsigned long long int uint_least64_t; +#endif + +/* 7.18.1.3 Fastest minimum-width integer types */ +typedef int int_fast8_t; +typedef unsigned int uint_fast8_t; +typedef int int_fast16_t; +typedef unsigned int uint_fast16_t; +typedef int int_fast32_t; +typedef unsigned int uint_fast32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ int_fast64_t; +typedef __COMPILER_UINT64__ uint_fast64_t; +#else +/* LONGLONG */ +typedef long long int int_fast64_t; +/* LONGLONG */ +typedef unsigned long long int uint_fast64_t; +#endif + +/* 7.18.1.5 Greatest-width integer types */ + +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ intmax_t; +typedef __COMPILER_UINT64__ uintmax_t; +#else +/* LONGLONG */ +typedef long long int intmax_t; +/* LONGLONG */ +typedef unsigned long long int uintmax_t; +#endif + +#endif /* !_ARM_INT_MWGWTYPES_H_ */ diff --git a/include/arch/arm/include/int_types.h b/include/arch/arm/include/int_types.h new file mode 100644 index 000000000..89b0b1d39 --- /dev/null +++ b/include/arch/arm/include/int_types.h @@ -0,0 +1,68 @@ +/* $NetBSD: int_types.h,v 1.9 2008/08/29 19:08:29 matt Exp $ */ + +/* + * Copyright (c) 1990 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: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _ARM32_INT_TYPES_H_ +#define _ARM32_INT_TYPES_H_ + +#include + +/* + * 7.18.1 Integer types + */ + +/* 7.18.1.1 Exact-width integer types */ + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef short int __int16_t; +typedef unsigned short int __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +#ifdef __COMPILER_INT64__ +typedef __COMPILER_INT64__ __int64_t; +typedef __COMPILER_UINT64__ __uint64_t; +#else +/* LONGLONG */ +typedef long long int __int64_t; +/* LONGLONG */ +typedef unsigned long long int __uint64_t; +#endif + +#define __BIT_TYPES_DEFINED__ + +/* 7.18.1.4 Integer types capable of holding object pointers */ + +typedef long int __intptr_t; +typedef unsigned long int __uintptr_t; + +#endif /* !_ARM32_INT_TYPES_H_ */ diff --git a/include/arch/arm/include/limits.h b/include/arch/arm/include/limits.h new file mode 100644 index 000000000..612f9da33 --- /dev/null +++ b/include/arch/arm/include/limits.h @@ -0,0 +1,94 @@ +/* $NetBSD: limits.h,v 1.10 2010/06/07 13:52:30 tnozaki Exp $ */ + +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)limits.h 7.2 (Berkeley) 6/28/90 + */ + +#ifndef _ARM32_LIMITS_H_ +#define _ARM32_LIMITS_H_ + +#include + +#define CHAR_BIT 8 /* number of bits in a char */ + +#define SCHAR_MIN (-0x7f-1) /* max value for a signed char */ +#define SCHAR_MAX 0x7f /* min value for a signed char */ + +#define UCHAR_MAX 0xff /* max value for an unsigned char */ +#define CHAR_MAX 0xff /* max value for a char */ +#define CHAR_MIN 0 /* min value for a char */ + +#define USHRT_MAX 0xffff /* max value for an unsigned short */ +#define SHRT_MAX 0x7fff /* max value for a short */ +#define SHRT_MIN (-0x7fff-1) /* min value for a short */ + +#define UINT_MAX 0xffffffffU /* max value for an unsigned int */ +#define INT_MAX 0x7fffffff /* max value for an int */ +#define INT_MIN (-0x7fffffff-1) /* min value for an int */ + +#define ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ +#define LONG_MAX 0x7fffffffL /* max value for a long */ +#define LONG_MIN (-0x7fffffffL-1) /* min value for a long */ + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ + +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ +#endif + +#if defined(_NETBSD_SOURCE) +#define SIZE_T_MAX LONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX 0xffffffffffffffffLL /* max unsigned quad */ +#define QUAD_MAX 0x7fffffffffffffffLL /* max signed quad */ +#define QUAD_MIN (-0x7fffffffffffffffLL-1) /* min signed quad */ + +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define LONG_BIT 32 +#define WORD_BIT 32 + +#define DBL_DIG 15 +#define DBL_MAX 1.7976931348623157E+308 +#define DBL_MIN 2.2250738585072014E-308 + +#define FLT_DIG 6 +#define FLT_MAX 3.40282347E+38F +#define FLT_MIN 1.17549435E-38F +#endif + +#endif /* _ARM32_LIMITS_H_ */ diff --git a/include/arch/arm/include/math.h b/include/arch/arm/include/math.h new file mode 100644 index 000000000..e1bd8e876 --- /dev/null +++ b/include/arch/arm/include/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.2 2002/02/19 13:08:14 simonb Exp $ */ + +#define __HAVE_NANF diff --git a/include/arch/arm/include/mutex.h b/include/arch/arm/include/mutex.h new file mode 100644 index 000000000..5a41e7564 --- /dev/null +++ b/include/arch/arm/include/mutex.h @@ -0,0 +1,101 @@ +/* $NetBSD: mutex.h,v 1.10 2008/04/28 20:23:14 martin Exp $ */ + +/*- + * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_MUTEX_H_ +#define _ARM_MUTEX_H_ + +/* + * The ARM mutex implementation is troublesome, because pre-v6 ARM lacks a + * compare-and-swap operation. However, there aren't any MP pre-v6 ARM + * systems to speak of. We are mostly concerned with atomicity with respect + * to interrupts. + * + * ARMv6, however, does have ldrex/strex, and can thus implement an MP-safe + * compare-and-swap. + * + * So, what we have done is impement simple mutexes using a compare-and-swap. + * We support pre-ARMv6 by implementing CAS as a restartable atomic sequence + * that is checked by the IRQ vector. MP-safe ARMv6 support will be added later. + */ + +#ifndef __MUTEX_PRIVATE + +struct kmutex { + uintptr_t mtx_pad1; +}; + +#else /* __MUTEX_PRIVATE */ + +struct kmutex { + union { + /* Adaptive mutex */ + volatile uintptr_t mtxa_owner; /* 0-3 */ + + /* Spin mutex */ + struct { + volatile uint8_t mtxs_dummy; + ipl_cookie_t mtxs_ipl; + __cpu_simple_lock_t mtxs_lock; + volatile uint8_t mtxs_unused; + } s; + } u; +}; + +#define mtx_owner u.mtxa_owner +#define mtx_ipl u.s.mtxs_ipl +#define mtx_lock u.s.mtxs_lock + +#if 0 +#define __HAVE_MUTEX_STUBS 1 +#define __HAVE_SPIN_MUTEX_STUBS 1 +#endif +#define __HAVE_SIMPLE_MUTEXES 1 + +/* + * MUTEX_RECEIVE: no memory barrier required; we're synchronizing against + * interrupts, not multiple processors. + */ +#define MUTEX_RECEIVE(mtx) /* nothing */ + +/* + * MUTEX_GIVE: no memory barrier required; same reason. + */ +#define MUTEX_GIVE(mtx) /* nothing */ + +unsigned long _lock_cas(volatile unsigned long *, + unsigned long, unsigned long); + +#define MUTEX_CAS(p, o, n) \ + (_lock_cas((volatile unsigned long *)(p), (o), (n)) == (o)) + +#endif /* __MUTEX_PRIVATE */ + +#endif /* _ARM_MUTEX_H_ */ diff --git a/include/arch/arm/include/param.h b/include/arch/arm/include/param.h new file mode 100644 index 000000000..6582c2fde --- /dev/null +++ b/include/arch/arm/include/param.h @@ -0,0 +1,153 @@ +/* $NetBSD: param.h,v 1.13 2010/05/06 19:10:26 joerg Exp $ */ + +/* + * Copyright (c) 1994,1995 Mark Brinicombe. + * 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 RiscBSD team. + * 4. The name "RiscBSD" 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 RISCBSD ``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 RISCBSD 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 _ARM_PARAM_H_ +#define _ARM_PARAM_H_ + +/* + * Machine dependent constants for all ARM processors + */ + +/* + * For KERNEL code: + * MACHINE must be defined by the individual port. This is so that + * uname returns the correct thing, etc. + * + * MACHINE_ARCH may be defined by individual ports as a temporary + * measure while we're finishing the conversion to ELF. + * + * For non-KERNEL code: + * If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb". + */ + +#if defined(_KERNEL) +#ifndef MACHINE_ARCH /* XXX For now */ +#ifndef __ARMEB__ +#define _MACHINE_ARCH arm +#define MACHINE_ARCH "arm" +#else +#define _MACHINE_ARCH armeb +#define MACHINE_ARCH "armeb" +#endif /* __ARMEB__ */ +#endif /* MACHINE_ARCH */ +#else +#undef _MACHINE +#undef MACHINE +#undef _MACHINE_ARCH +#undef MACHINE_ARCH +#define _MACHINE arm +#define MACHINE "arm" +#ifndef __ARMEB__ +#define _MACHINE_ARCH arm +#define MACHINE_ARCH "arm" +#else +#define _MACHINE_ARCH armeb +#define MACHINE_ARCH "armeb" +#endif /* __ARMEB__ */ +#endif /* !_KERNEL */ + +#define MID_MACHINE MID_ARM6 + +/* + * 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) +/* ARM-specific macro to align a stack pointer (downwards). */ +#define STACKALIGNBYTES (8 - 1) +#define STACKALIGN(p) ((u_int)(p) &~ STACKALIGNBYTES) + +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define DEV_BSIZE (1 << DEV_BSHIFT) +#define BLKDEV_IOSIZE 2048 + +#ifndef MAXPHYS +#define MAXPHYS 65536 /* max I/O transfer size */ +#endif + +/* + * 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 */ + +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ + /* 2K cluster can hold Ether frame */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ + +#ifndef NMBCLUSTERS_MAX +#define NMBCLUSTERS_MAX (0x2000000 / MCLBYTES) /* Limit to 64MB for clusters */ +#endif + +/* + * Compatibility /dev/zero mapping. + */ +#ifdef _KERNEL +#ifdef COMPAT_16 +#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM)) +#endif +#endif /* _KERNEL */ + +#ifdef __minix +/* Minix expect to find in this file PAGE_* defines. */ +#include + +#define PGSHIFT 12 /* LOG2(NBPG) */ +#define NBPG (1 << PGSHIFT) /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ + +#define arm_round_page(x) ((((paddr_t)(x)) + PGOFSET) & ~PGOFSET) +#define arm_trunc_page(x) ((paddr_t)(x) & ~PGOFSET) + +#define trunc_page(x) arm_trunc_page(x) +#define round_page(x) arm_round_page(x) + +#endif + +#endif /* _ARM_PARAM_H_ */ diff --git a/include/arch/arm/include/profile.h b/include/arch/arm/include/profile.h new file mode 100644 index 000000000..140435479 --- /dev/null +++ b/include/arch/arm/include/profile.h @@ -0,0 +1,102 @@ +/* $NetBSD: profile.h,v 1.8 2008/08/29 19:08:29 matt Exp $ */ + +/* + * Copyright (c) 2001 Ben Harris + * Copyright (c) 1995-1996 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 Mark Brinicombe. + * 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. + */ + +#define _MCOUNT_DECL void _mcount + +/* + * Cannot implement mcount in C as GCC will trash the ip register when it + * pushes a trapframe. Pity we cannot insert assembly before the function + * prologue. + */ + +#define MCOUNT_ASM_NAME "__mcount" +#ifdef PIC +#define PLTSYM "(PLT)" +#endif + +#ifndef PLTSYM +#define PLTSYM +#endif + +#define MCOUNT \ + __asm(".text"); \ + __asm(".align 0"); \ + __asm(".type " MCOUNT_ASM_NAME ",%function"); \ + __asm(".global " MCOUNT_ASM_NAME); \ + __asm(MCOUNT_ASM_NAME ":"); \ + /* \ + * Preserve registers that are trashed during mcount \ + */ \ + __asm("stmfd sp!, {r0-r3, ip, lr}"); \ + /* Check what mode we're in. EQ => 32, NE => 26 */ \ + __asm("teq r0, r0"); \ + __asm("teq pc, r15"); \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("moveq r0, ip"); \ + __asm("bicne r0, ip, #0xfc000003"); \ + /* \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("moveq r1, lr"); \ + __asm("bicne r1, lr, #0xfc000003"); \ + /* \ + * Call the real mcount code \ + */ \ + __asm("bl " ___STRING(_C_LABEL(_mcount)) PLTSYM); \ + /* \ + * Restore registers that were trashed during mcount \ + */ \ + __asm("ldmfd sp!, {r0-r3, lr, pc}"); + +#ifdef _KERNEL +#ifdef __PROG26 +extern int int_off_save(void); +extern void int_restore(int); +#define MCOUNT_ENTER (s = int_off_save()) +#define MCOUNT_EXIT int_restore(s) +#else +#include +/* + * splhigh() and splx() are heavyweight, and call mcount(). Therefore + * we disabled interrupts (IRQ, but not FIQ) directly on the CPU. + * + * We're lucky that the CPSR and 's' both happen to be 'int's. + */ +#define MCOUNT_ENTER s = __set_cpsr_c(0x0080, 0x0080); /* kill IRQ */ +#define MCOUNT_EXIT __set_cpsr_c(0xffffffff, s); /* restore old value */ +#endif /* !acorn26 */ +#endif /* _KERNEL */ diff --git a/include/arch/arm/include/setjmp.h b/include/arch/arm/include/setjmp.h new file mode 100644 index 000000000..f05a5ba28 --- /dev/null +++ b/include/arch/arm/include/setjmp.h @@ -0,0 +1,82 @@ +/* $NetBSD: setjmp.h,v 1.3 2008/08/29 19:08:29 matt Exp $ */ + +/* + * machine/setjmp.h: machine dependent setjmp-related information. + */ + +#define _JBLEN 64 /* size, in longs, of a jmp_buf */ + +/* + * NOTE: The internal structure of a jmp_buf is *PRIVATE* + * This information is provided as there is software + * that fiddles with this with obtain the stack pointer + * (yes really ! and its commercial !). + * + * Description of the setjmp buffer + * + * word 0 magic number (dependant on creator) + * 1 - 3 f4 fp register 4 + * 4 - 6 f5 fp register 5 + * 7 - 9 f6 fp register 6 + * 10 - 12 f7 fp register 7 + * 13 fpsr fp status register + * 14 r4 register 4 + * 15 r5 register 5 + * 16 r6 register 6 + * 17 r7 register 7 + * 18 r8 register 8 + * 19 r9 register 9 + * 20 r10 register 10 (sl) + * 21 r11 register 11 (fp) + * 22 r12 register 12 (ip) + * 23 r13 register 13 (sp) + * 24 r14 register 14 (lr) + * 25 signal mask (dependant on magic) + * 26 (con't) + * 27 (con't) + * 28 (con't) + * + * The magic number number identifies the jmp_buf and + * how the buffer was created as well as providing + * a sanity check + * + * A side note I should mention - Please do not tamper + * with the floating point fields. While they are + * always saved and restored at the moment this cannot + * be garenteed especially if the compiler happens + * to be generating soft-float code so no fp + * registers will be used. + * + * Whilst this can be seen an encouraging people to + * use the setjmp buffer in this way I think that it + * is for the best then if changes occur compiles will + * break rather than just having new builds falling over + * mysteriously. + */ + +#define _JB_MAGIC__SETJMP 0x4278f500 +#define _JB_MAGIC_SETJMP 0x4278f501 + +/* Valid for all jmp_buf's */ + +#define _JB_MAGIC 0 +#define _JB_REG_F4 1 +#define _JB_REG_F5 4 +#define _JB_REG_F6 7 +#define _JB_REG_F7 10 +#define _JB_REG_FPSR 13 +#define _JB_REG_R4 14 +#define _JB_REG_R5 15 +#define _JB_REG_R6 16 +#define _JB_REG_R7 17 +#define _JB_REG_R8 18 +#define _JB_REG_R9 19 +#define _JB_REG_R10 20 +#define _JB_REG_R11 21 +#define _JB_REG_R12 22 +#define _JB_REG_R13 23 +#define _JB_REG_R14 24 + +/* Only valid with the _JB_MAGIC_SETJMP magic */ + +#define _JB_SIGMASK 25 diff --git a/include/arch/arm/include/stdarg.h b/include/arch/arm/include/stdarg.h new file mode 100644 index 000000000..f5ba7b2c9 --- /dev/null +++ b/include/arch/arm/include/stdarg.h @@ -0,0 +1,86 @@ +/* $NetBSD: stdarg.h,v 1.10 2008/06/21 00:56:39 gmcgarry 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 _ARM32_STDARG_H_ +#define _ARM32_STDARG_H_ + +#include +#include + +typedef _BSD_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 + +#if __GNUC_PREREQ__(4, 1) +#define va_start(ap, last) __builtin_va_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)) +#elif __GNUC_PREREQ__(2, 96) +#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)) +#elif defined(__PCC__) +#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)) +#else +#define __va_size(type) \ + (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long)) + +#define va_start(ap, last) \ + ((ap) = (va_list)__builtin_next_arg(last)) + +#define va_arg(ap, type) \ + ((type *)(ap += sizeof(type)))[-1] + +#define va_end(ap) + +#define __va_copy(dest, src) ((dest) = (src)) + +#endif /* __GNUC_PREREQ__(2, 96) */ + +#if !defined(_ANSI_SOURCE) && \ + (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE)) +#define va_copy(dest, src) __va_copy((dest), (src)) +#endif + +#endif /* !_ARM32_STDARG_H_ */ diff --git a/include/arch/arm/include/types.h b/include/arch/arm/include/types.h new file mode 100644 index 000000000..8060fd278 --- /dev/null +++ b/include/arch/arm/include/types.h @@ -0,0 +1,92 @@ +/* $NetBSD: types.h,v 1.18 2010/12/22 01:04:23 matt Exp $ */ + +/* + * Copyright (c) 1990 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: @(#)types.h 7.5 (Berkeley) 3/9/91 + */ + +#ifndef _ARM_TYPES_H_ +#define _ARM_TYPES_H_ + +#include +#include +#include + +#if defined(_KERNEL) +typedef struct label_t { /* Used by setjmp & longjmp */ + int val[11]; +} label_t; +#endif + +/* NB: This should probably be if defined(_KERNEL) */ +#if defined(_NETBSD_SOURCE) +typedef unsigned long vm_offset_t; /* depreciated */ +typedef unsigned long vm_size_t; /* depreciated */ + +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long vaddr_t; +typedef unsigned long vsize_t; +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" +#endif + +typedef int register_t; +#define PRIxREGISTER "x" + +typedef unsigned long pmc_evid_t; +#define PMC_INVALID_EVID (-1) +typedef unsigned long pmc_ctr_t; + +/* + * This should have always been an 8-bit type, but since it's been exposed + * to user-space, we don't want ABI breakage there. + */ +#if defined(_KERNEL) +typedef volatile unsigned char __cpu_simple_lock_t; +#else +typedef volatile int __cpu_simple_lock_t; +#endif /* _KERNEL */ + +#define __SIMPLELOCK_LOCKED 1 +#define __SIMPLELOCK_UNLOCKED 0 + +#define __HAVE_SYSCALL_INTERN +#define __HAVE_MINIMAL_EMUL +#define __HAVE_CPU_DATA_FIRST + +#if defined(_KERNEL) +#define __HAVE_RAS +#endif + +#endif /* _ARM_TYPES_H_ */ diff --git a/include/arch/arm/include/wchar_limits.h b/include/arch/arm/include/wchar_limits.h new file mode 100644 index 000000000..1dd2e913f --- /dev/null +++ b/include/arch/arm/include/wchar_limits.h @@ -0,0 +1,47 @@ +/* $NetBSD: wchar_limits.h,v 1.3 2008/04/28 20:23:14 martin Exp $ */ + +/*- + * Copyright (c) 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ARM_WCHAR_LIMITS_H_ +#define _ARM_WCHAR_LIMITS_H_ + +/* + * 7.18.3 Limits of other integer types + */ + +/* limits of wchar_t */ +#define WCHAR_MIN (-0x7fffffff-1) /* wchar_t */ +#define WCHAR_MAX 0x7fffffff /* wchar_t */ + +/* limits of wint_t */ +#define WINT_MIN (-0x7fffffff-1) /* wint_t */ +#define WINT_MAX 0x7fffffff /* wint_t */ + +#endif /* !_ARM_WCHAR_LIMITS_H_ */