Merge pull request #23913 from alexrp/netbsd-libc

Support dynamically-linked NetBSD libc when cross-compiling
This commit is contained in:
Alex Rønne Petersen 2025-05-20 07:46:08 +02:00 committed by GitHub
commit b27c5fbbde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2273 changed files with 340293 additions and 176 deletions

2
.gitattributes vendored
View File

@ -3,6 +3,8 @@
*.txt text eol=lf
langref.html.in text eol=lf
lib/libc/*/abilists binary
lib/std/compress/testdata/** binary
lib/std/compress/flate/testdata/** binary
lib/std/compress/lzma/testdata/** binary

View File

@ -588,6 +588,7 @@ set(ZIG_STAGE2_SOURCES
src/dev.zig
src/libs/freebsd.zig
src/libs/glibc.zig
src/libs/netbsd.zig
src/introspect.zig
src/libs/libcxx.zig
src/libs/libtsan.zig

View File

@ -0,0 +1,3 @@
/* $NetBSD: ansi.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */
#include <arm/ansi.h>

View File

@ -0,0 +1,37 @@
/* $NetBSD: aout_machdep.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_AOUT_MACHDEP_H_
#define _AARCH64_AOUT_MACHDEP_H_
#include <arm/aout_machdep.h>
#endif /* !_AARCH64_AOUT_MACHDEP_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
/* $NetBSD: asm.h,v 1.9 2020/08/02 06:58:16 maxv Exp $ */
#ifndef _AARCH64_ASM_H_
#define _AARCH64_ASM_H_
#if defined(_KERNEL_OPT)
#include "opt_cpuoptions.h"
#endif
#include <arm/asm.h>
#ifdef __aarch64__
#ifdef __ASSEMBLER__
.macro adrl reg, addr
adrp \reg, \addr
add \reg, \reg, #:lo12:\addr
.endm
#endif
#define fp x29
#define lr x30
/*
* Add a speculation barrier after the 'eret'.
* Some aarch64 cpus speculatively execute instructions after 'eret',
* and this potentiates side-channel attacks.
*/
#define ERET \
eret; dsb sy; isb
/*
* ARMv8 options to be made available for the compiler to use. Should be
* inserted at the beginning of the ASM files that need them.
*
* The options are:
* - PAN, needed for the compiler to recognize the PAN register.
* - PAC, needed for the compiler to recognize the key registers.
*/
#ifdef ARMV83_PAC
#define ARMV8_DEFINE_OPTIONS \
.arch armv8.3-a
#elif defined(ARMV81_PAN)
#define ARMV8_DEFINE_OPTIONS \
.arch armv8.1-a
#else
#define ARMV8_DEFINE_OPTIONS /* nothing */
#endif
#endif
#endif /* !_AARCH64_ASM_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: bswap.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/bswap.h>

View File

@ -0,0 +1,112 @@
/* $NetBSD: byte_swap.h,v 1.4 2017/01/17 11:09:36 rin Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 __aarch64__
#ifdef _LOCORE
#define BSWAP16(_src, _dst) \
rev16 _dst, _src
#define BSWAP32(_src, _dst) \
rev _dst, _src
#define BSWAP64(_src, _dst) \
rev _dst, _src
#else
#ifdef __GNUC__
#include <sys/types.h>
__BEGIN_DECLS
#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable
static __inline uint64_t
__byte_swap_u64_variable(uint64_t v)
{
if (!__builtin_constant_p(v)) {
__asm("rev\t%x0, %x1" : "=r" (v) : "0" (v));
return v;
}
v = ((v & 0x000000ff) << (56 - 0)) | ((v >> (56 - 0)) & 0x000000ff)
| ((v & 0x0000ff00) << (48 - 8)) | ((v >> (48 - 8)) & 0x0000ff00)
| ((v & 0x00ff0000) << (40 - 16)) | ((v >> (40 - 16)) & 0x00ff0000)
| ((v & 0xff000000) << (32 - 24)) | ((v >> (32 - 24)) & 0xff000000);
return v;
}
#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
static __inline uint32_t
__byte_swap_u32_variable(uint32_t v)
{
if (!__builtin_constant_p(v)) {
__asm("rev\t%w0, %w1" : "=r" (v) : "0" (v));
return v;
}
v = ((v & 0x00ff) << (24 - 0)) | ((v >> (24 - 0)) & 0x00ff)
| ((v & 0xff00) << (16 - 8)) | ((v >> (16 - 8)) & 0xff00);
return v;
}
#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable
static __inline uint16_t
__byte_swap_u16_variable(uint16_t v)
{
if (!__builtin_constant_p(v)) {
uint32_t v32 = v;
__asm("rev16\t%w0, %w1" : "=r" (v32) : "0" (v32));
return (uint16_t)v32;
}
v &= 0xffff;
v = (uint16_t)((v >> 8) | (v << 8));
return v;
}
__END_DECLS
#endif
#endif /* _LOCORE */
#elif defined(__arm__)
#include <arm/asm.h>
#endif
#endif /* _ARM_BYTE_SWAP_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: cdefs.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/cdefs.h>

View File

@ -0,0 +1,257 @@
/* $NetBSD: cpu.h,v 1.48.2.1 2024/10/13 10:43:11 martin Exp $ */
/*-
* Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_CPU_H_
#define _AARCH64_CPU_H_
#include <arm/cpu.h>
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_gprof.h"
#include "opt_multiprocessor.h"
#include "opt_pmap.h"
#endif
#include <sys/param.h>
#if defined(_KERNEL) || defined(_KMEMUSER)
#include <sys/evcnt.h>
#include <aarch64/armreg.h>
#include <aarch64/frame.h>
struct clockframe {
struct trapframe cf_tf;
};
/* (spsr & 15) == SPSR_M_EL0T(64bit,0) or USER(32bit,0) */
#define CLKF_USERMODE(cf) ((((cf)->cf_tf.tf_spsr) & 0x0f) == 0)
#define CLKF_PC(cf) ((cf)->cf_tf.tf_pc)
#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1)
/*
* LWP_PC: Find out the program counter for the given lwp.
*/
#define LWP_PC(l) ((l)->l_md.md_utf->tf_pc)
#include <sys/cpu_data.h>
#include <sys/device_if.h>
#include <sys/intr.h>
struct aarch64_cpufuncs {
void (*cf_set_ttbr0)(uint64_t);
void (*cf_icache_sync_range)(vaddr_t, vsize_t);
};
#define MAX_CACHE_LEVEL 8 /* ARMv8 has maximum 8 level cache */
struct aarch64_cache_unit {
u_int cache_type;
#define CACHE_TYPE_VPIPT 0 /* VMID-aware PIPT */
#define CACHE_TYPE_VIVT 1 /* ASID-tagged VIVT */
#define CACHE_TYPE_VIPT 2
#define CACHE_TYPE_PIPT 3
u_int cache_line_size;
u_int cache_ways;
u_int cache_sets;
u_int cache_way_size;
u_int cache_size;
};
struct aarch64_cache_info {
u_int cacheable;
#define CACHE_CACHEABLE_NONE 0
#define CACHE_CACHEABLE_ICACHE 1 /* instruction cache only */
#define CACHE_CACHEABLE_DCACHE 2 /* data cache only */
#define CACHE_CACHEABLE_IDCACHE 3 /* instruction and data caches */
#define CACHE_CACHEABLE_UNIFIED 4 /* unified cache */
struct aarch64_cache_unit icache;
struct aarch64_cache_unit dcache;
};
struct cpu_info {
struct cpu_data ci_data;
device_t ci_dev;
cpuid_t ci_cpuid;
/*
* the following are in their own cache line, as they are stored to
* regularly by remote CPUs; when they were mixed with other fields
* we observed frequent cache misses.
*/
int ci_want_resched __aligned(COHERENCY_UNIT);
/* XXX pending IPIs? */
/*
* this is stored frequently, and is fetched by remote CPUs.
*/
struct lwp *ci_curlwp __aligned(COHERENCY_UNIT);
struct lwp *ci_onproc;
/*
* largely CPU-private.
*/
struct lwp *ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT);
uint64_t ci_lastintr;
int ci_mtx_oldspl;
int ci_mtx_count;
int ci_cpl; /* current processor level (spl) */
volatile int ci_hwpl; /* current hardware priority */
volatile u_int ci_softints;
volatile u_int ci_intr_depth;
volatile uint32_t ci_blocked_pics;
volatile uint32_t ci_pending_pics;
volatile uint32_t ci_pending_ipls;
int ci_kfpu_spl;
#if defined(PMAP_MI)
struct pmap_tlb_info *ci_tlb_info;
struct pmap *ci_pmap_lastuser;
struct pmap *ci_pmap_cur;
#endif
/* ASID of current pmap */
tlb_asid_t ci_pmap_asid_cur;
/* event counters */
struct evcnt ci_vfp_use;
struct evcnt ci_vfp_reuse;
struct evcnt ci_vfp_save;
struct evcnt ci_vfp_release;
struct evcnt ci_uct_trap;
struct evcnt ci_intr_preempt;
struct evcnt ci_rndrrs_fail;
/* FDT or similar supplied "cpu capacity" */
uint32_t ci_capacity_dmips_mhz;
/* interrupt controller */
u_int ci_gic_redist; /* GICv3 redistributor index */
uint64_t ci_gic_sgir; /* GICv3 SGIR target */
/* ACPI */
uint32_t ci_acpiid; /* ACPI Processor Unique ID */
/* cached system registers */
uint64_t ci_sctlr_el1;
uint64_t ci_sctlr_el2;
/* sysctl(9) exposed system registers */
struct aarch64_sysctl_cpu_id ci_id;
/* cache information and function pointers */
struct aarch64_cache_info ci_cacheinfo[MAX_CACHE_LEVEL];
struct aarch64_cpufuncs ci_cpufuncs;
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon; /* MI per-cpu GPROF */
#endif
} __aligned(COHERENCY_UNIT);
#ifdef _KERNEL
static inline __always_inline struct lwp * __attribute__ ((const))
aarch64_curlwp(void)
{
struct lwp *l;
__asm("mrs %0, tpidr_el1" : "=r"(l));
return l;
}
/* forward declaration; defined in sys/lwp.h. */
static __inline struct cpu_info *lwp_getcpu(struct lwp *);
#define curcpu() (lwp_getcpu(aarch64_curlwp()))
#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc))
#undef curlwp
#define curlwp (aarch64_curlwp())
#define curpcb ((struct pcb *)lwp_getpcb(curlwp))
void cpu_signotify(struct lwp *l);
void cpu_need_proftick(struct lwp *l);
void cpu_hatch(struct cpu_info *);
extern struct cpu_info *cpu_info[];
extern struct cpu_info cpu_info_store[];
#define CPU_INFO_ITERATOR int
#if defined(MULTIPROCESSOR) || defined(_MODULE)
#define cpu_number() (curcpu()->ci_index)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0)
#define CPU_INFO_FOREACH(cii, ci) \
cii = 0, ci = cpu_info[0]; \
cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; \
cii++
#else /* MULTIPROCESSOR */
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) true
#define CPU_INFO_FOREACH(cii, ci) \
cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL
#endif /* MULTIPROCESSOR */
#define LWP0_CPU_INFO (&cpu_info_store[0])
#define __HAVE_CPU_DOSOFTINTS_CI
static inline void
cpu_dosoftints_ci(struct cpu_info *ci)
{
#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS)
void dosoftints(void);
if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) {
dosoftints();
}
#endif
}
static inline void
cpu_dosoftints(void)
{
#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS)
cpu_dosoftints_ci(curcpu());
#endif
}
#endif /* _KERNEL */
#endif /* _KERNEL || _KMEMUSER */
#endif
#endif /* _AARCH64_CPU_H_ */

View File

@ -0,0 +1,7 @@
/* $NetBSD: disklabel.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
#if HAVE_NBTOOL_CONFIG_H
#include <nbinclude/arm/disklabel.h>
#else
#include <arm/disklabel.h>
#endif /* HAVE_NBTOOL_CONFIG_H */

View File

@ -0,0 +1,256 @@
/* $NetBSD: elf_machdep.h,v 1.5 2022/05/30 21:18:37 jkoshy Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_ELF_MACHDEP_H_
#define _AARCH64_ELF_MACHDEP_H_
#ifdef __aarch64__
#if defined(__AARCH64EB__)
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
#else
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
#endif
/* 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_BE8 0x00800000
#define EF_ARM_EABIMASK 0xff000000
#define EF_ARM_EABI_VER1 0x01000000
#define EF_ARM_EABI_VER2 0x02000000
#define EF_ARM_EABI_VER3 0x03000000
#define EF_ARM_EABI_VER4 0x04000000
#define EF_ARM_EABI_VER5 0x05000000
#define ELF32_MACHDEP_ID_CASES \
case EM_ARM: \
break;
#define ELF64_MACHDEP_ID_CASES \
case EM_AARCH64: \
break;
#define ELF64_MACHDEP_ID EM_AARCH64
#define ELF32_MACHDEP_ID EM_ARM
#define KERN_ELFSIZE 64
#define ARCH_ELFSIZE 64 /* MD native binary size */
/* Processor specific relocation types */
#define R_AARCH64_NONE 0
#define R_AARCH64_NONE2 256
#define R_AARCH64_ABS64 257 /* S + A */
#define R_AARCH64_ABS32 258 /* S + A */
#define R_AARCH64_ABS16 259 /* S + A */
#define R_AARCH64_PREL64 260 /* S + A - P */
#define R_AARCH64_PREL32 261 /* S + A - P */
#define R_AARCH64_PREL16 262 /* S + A - P */
#define R_AARCH64_MOVW_UABS_G0 263 /* S + A [bits 0..15] */
#define R_AARCH64_MOVW_UABS_G0_NC 264 /* S + A [bits 0..15] */
#define R_AARCH64_MOVW_UABS_G1 265 /* S + A [bits 16..31] */
#define R_AARCH64_MOVW_UABS_G1_NC 266 /* S + A [bits 16..31] */
#define R_AARCH64_MOVW_UABS_G2 267 /* S + A [bits 32..47] */
#define R_AARCH64_MOVW_UABS_G2_NC 268 /* S + A [bits 32..47] */
#define R_AARCH64_MOVW_UABS_G3 269 /* S + A [bits 48..63] */
#define R_AARCH64_MOVW_SABS_G0 270 /* S + A [bits 0..15] */
#define R_AARCH64_MOVW_SABS_G1 271 /* S + A [bits 16..31] */
#define R_AARCH64_MOVW_SABS_G2 272 /* S + A [bits 32..47] */
#define R_AARCH64_LD_PREL_LO19 273 /* S + A - P */
#define R_AARCH64_ADR_PREL_LO21 274 /* S + A - P */
#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page(S + A) - Page(P) */
#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Page(S + A) - Page(P) */
#define R_AARCH64_ADD_ABS_LO12_NC 277 /* S + A */
#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* S + A */
#define R_AARCH_TSTBR14 279 /* S + A - P */
#define R_AARCH_CONDBR19 281 /* S + A - P */
#define R_AARCH_JUMP26 282 /* S + A - P */
#define R_AARCH_CALL26 283 /* S + A - P */
#define R_AARCH_LDST16_ABS_LO12_NC 284 /* S + A */
#define R_AARCH_LDST32_ABS_LO12_NC 285 /* S + A */
#define R_AARCH_LDST64_ABS_LO12_NC 286 /* S + A */
#define R_AARCH64_MOVW_PREL_G0 287 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G0_NC 288 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G1 289 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G1_NC 290 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G2 291 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G2_NC 292 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G3 293 /* S + A - P */
#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* S + A */
#define R_AARCH64_MOVW_GOTOFF_G0 300 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G1 302 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G2 304 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G3 306 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_GOTREL64 307 /* S + A - GOT */
#define R_AARCH64_GOTREL32 308 /* S + A - GOT */
#define R_AARCH64_GOT_LD_PREL19 309 /* G(GDAT(S + A)) - P */
#define R_AARCH64_LD64_GOTOFF_LO15 310 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_ADR_GOT_PAGE 311 /* Page(G(GDAT(S + A))) - Page(GOT) */
#define R_AARCH64_LD64_GOT_LO12_NC 312 /* G(GDAT(S + A)) */
#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* G(GDAT(S + A)) - Page(GOT) */
#define R_AARCH64_TLSGD_ADR_PREL21 512 /* G(GTLSIDX(S,A)) - P */
#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* Page(G(GTLSIDX(S,A))) - Page(P) */
#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* G(GTLSIDX(S,A)) */
#define R_AARCH64_TLSGD_MOVW_G1 515 /* G(GTLSIDX(S,A)) - GOT */
#define R_AARCH64_TLSGD_MOVW_G0_NV 516 /* G(GTLSIDX(S,A)) - GOT */
#define R_AARCH64_TLSLD_ADR_PREL21 517 /* G(GLDM(S,A)) - P */
#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Page(G(GLDM(S))) - Page(P) */
#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* G(GLDM(S)) */
#define R_AARCH64_TLSLD_MOVW_G1 520 /* G(GLDM(S)) - GOT */
#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* G(GLDM(S)) - GOT */
#define R_AARCH64_TLSLD_LD_PREL21 522 /* G(GLDM(S)) - P */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 528 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* DTPREL(S+A) */
#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* G(GTPREL(S+A)) - GOT */
#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* G(GTPREL(S+A)) - GOT */
#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page(G(GTPREL(S+A))) - Page(P) */
#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* G(GTPREL(S+A)) */
#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* G(GTPREL(S+A)) - P */
#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G1 545 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G1_NC 546 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G0 547 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G0_NC 548 /* TPREL(S+A) */
#define R_AARCH64_ADD_TPREL_HI12 549 /* TPREL(S+A) */
#define R_AARCH64_ADD_TPREL_LO12 550 /* TPREL(S+A) */
#define R_AARCH64_ADD_TPREL_LO12_NC 551 /* TPREL(S+A) */
#define R_AARCH64_LDST8_TPREL_LO12 552 /* TPREL(S+A) */
#define R_AARCH64_LDST8_TPREL_LO12_NC 553 /* TPREL(S+A) */
#define R_AARCH64_LDST16_TPREL_LO12 554 /* TPREL(S+A) */
#define R_AARCH64_LDST16_TPREL_LO12_NC 555 /* TPREL(S+A) */
#define R_AARCH64_LDST32_TPREL_LO12 556 /* TPREL(S+A) */
#define R_AARCH64_LDST32_TPREL_LO12_NC 557 /* TPREL(S+A) */
#define R_AARCH64_LDST64_TPREL_LO12 558 /* TPREL(S+A) */
#define R_AARCH64_LDST64_TPREL_LO12_NC 559 /* TPREL(S+A) */
#define R_AARCH64_TLSDESC_LD_PREL19 560 /* G(GTLSDESC(S+A)) - P */
#define R_AARCH64_TLSDESC_LD_PREL21 561 /* G(GTLSDESC(S+A)) - P */
#define R_AARCH64_TLSDESC_LD_PAGE21 562 /* Page(G(GTLSDESC(S+A))) - Page(P) */
#define R_AARCH64_TLSDESC_LD64_LO12 563 /* G(GTLSDESC(S+A)) */
#define R_AARCH64_TLSDESC_ADD_LO12 564 /* G(GTLSDESC(S+A)) */
#define R_AARCH64_TLSDESC_OFF_G1 565 /* G(GTLSDESC(S+A)) - GOT */
#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* G(GTLSDESC(S+A)) - GOT */
#define R_AARCH64_TLSDESC_LDR 567 /* */
#define R_AARCH64_TLSDESC_ADD 568 /* */
#define R_AARCH64_TLSDESC_CALL 569 /* */
#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TPREL(S+A) */
#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* TPREL(S+A) */
#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* DTPREL(S+A) */
/* Dynamic Relocations */
#define R_AARCH64_P32_COPY 180
#define R_AARCH64_P32_GLOB_DAT 181 /* S + A */
#define R_AARCH64_P32_JUMP_SLOT 182 /* S + A */
#define R_AARCH64_P32_RELATIVE 183 /* Delta(S) + A */
#define R_AARCH64_P32_TLS_DTPREL 184 /* DTPREL(S+A) */
#define R_AARCH64_P32_TLS_DTPMOD 185 /* LBM(S) */
#define R_AARCH64_P32_TLS_TPREL 186 /* TPREL(S+A) */
#define R_AARCH64_P32_TLSDESC 187 /* TLSDESC(S+A) */
#define R_AARCH64_P32_IRELATIVE 188 /* Indirect(Delta(S) + A) */
#define R_AARCH64_COPY 1024
#define R_AARCH64_GLOB_DAT 1025 /* S + A */
#define R_AARCH64_JUMP_SLOT 1026 /* S + A */
#define R_AARCH64_RELATIVE 1027 /* Delta(S) + A */
#define R_AARCH64_TLS_DTPREL64 1028 /* DTPREL(S+A) */
#define R_AARCH64_TLS_DTPMOD64 1029 /* LBM(S) */
#define R_AARCH64_TLS_TPREL64 1030 /* TPREL(S+A) */
#define R_AARCH64_TLSDESC 1031 /* TLSDESC(S+A) */
#define R_AARCH64_IRELATIVE 1032 /* Indirect(Delta(S) + A) */
#define R_TYPE(name) R_AARCH64_ ## name
#define R_TLS_TYPE(name) R_AARCH64_ ## name ## 64
/* Processor specific program header types */
#define PT_AARCH64_ARCHEXT (PT_LOPROC + 0)
#define PT_AARCH64_UNWIND (PT_LOPROC + 1)
/* Processor specific section header flags */
#define SHF_ENTRYSECT 0x10000000
#define SHF_COMDEF 0x80000000
#define SHT_AARCH64_ATTRIBUTES (SHT_LOPROC + 3)
#ifdef _KERNEL
#ifdef ELFSIZE
#define ELF_MD_PROBE_FUNC ELFNAME2(aarch64_netbsd,probe)
#endif
struct exec_package;
int aarch64_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *,
char *, vaddr_t *);
int aarch64_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *,
char *, vaddr_t *);
#endif
#elif defined(__arm__)
#include <arm/elf_machdep.h>
#endif
#endif /* _AARCH64_ELF_MACHDEP_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: endian.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <sys/endian.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: endian_machdep.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/endian_machdep.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: fenv.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/fenv.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: float.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/float.h>

View File

@ -0,0 +1,83 @@
/* $NetBSD: frame.h,v 1.5 2020/08/06 06:49:55 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_FRAME_H_
#define _AARCH64_FRAME_H_
#ifdef __aarch64__
#include <aarch64/reg.h>
struct trapframe {
struct reg tf_regs __aligned(16);
uint64_t tf_esr; // 32-bit register
uint64_t tf_far; // 64-bit register
#define tf_reg tf_regs.r_reg
#define tf_lr tf_regs.r_reg[30]
#define tf_pc tf_regs.r_pc
#define tf_sp tf_regs.r_sp
#define tf_spsr tf_regs.r_spsr
};
#ifdef _KERNEL
/* size of trapframe (stack pointer) must be 16byte aligned */
__CTASSERT((sizeof(struct trapframe) & 15) == 0);
#endif
#define TF_SIZE sizeof(struct trapframe)
#define FB_X19 0
#define FB_X20 1
#define FB_X21 2
#define FB_X22 3
#define FB_X23 4
#define FB_X24 5
#define FB_X25 6
#define FB_X26 7
#define FB_X27 8
#define FB_X28 9
#define FB_X29 10
#define FB_LR 11
#define FB_SP 12
#define FB_MAX 13
struct faultbuf {
register_t fb_reg[FB_MAX];
};
#define lwp_trapframe(l) ((l)->l_md.md_utf)
#elif defined(__arm__)
#include <arm/frame.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_FRAME_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: ieee.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/ieee.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: ieeefp.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/ieeefp.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_const.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_const.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_fmtio.h,v 1.3 2014/08/13 19:51:27 matt Exp $ */
#include <arm/int_fmtio.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_limits.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_mwgwtypes.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_types.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_types.h>

View File

@ -0,0 +1,50 @@
/* $NetBSD: kcore.h,v 1.2 2018/11/09 04:05:27 mrg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_KCORE_H_
#define _AARCH64_KCORE_H_
#ifdef __aarch64__
typedef struct cpu_kcore_hdr {
uint64_t kh_tcr1; /* TCR for EL1 */
uint64_t kh_ttbr1; /* TTBR for EL1 */
uint64_t kh_nramsegs;
phys_ram_seg_t kh_ramsegs[0];
} cpu_kcore_hdr_t;
#elif defined(__arm__)
#include <arm/kcore.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_KCORE_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/limits.h>

View File

@ -0,0 +1,20 @@
/* $NetBSD: lock.h,v 1.5 2022/07/24 20:28:32 riastradh Exp $ */
#ifndef _AARCH64_LOCK_H_
#define _AARCH64_LOCK_H_
#include <sys/param.h>
#ifdef __aarch64__
# ifdef _HARDKERNEL
# ifdef SPINLOCK_BACKOFF_HOOK
# undef SPINLOCK_BACKOFF_HOOK
# endif
# define SPINLOCK_BACKOFF_HOOK asm volatile("yield" ::: "memory")
# endif
# include <sys/common_lock.h>
#elif defined(__arm__)
# include <arm/lock.h>
#endif
#endif /* _AARCH64_LOCK_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: math.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/math.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: mcontext.h,v 1.4 2018/04/01 04:35:03 ryo Exp $ */
#include <arm/mcontext.h>

View File

@ -0,0 +1,5 @@
/* $NetBSD: mutex.h,v 1.2 2020/08/12 13:28:46 skrll Exp $ */
#include <arm/mutex.h>
#define __HAVE_MUTEX_STUBS 1

View File

@ -0,0 +1,181 @@
/* $NetBSD: param.h,v 1.16 2021/05/31 14:38:57 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PARAM_H_
#define _AARCH64_PARAM_H_
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_cputypes.h"
#include "opt_param.h"
#endif
/*
* 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 */
# ifdef __AARCH64EB__
# define _MACHINE_ARCH aarch64eb
# define MACHINE_ARCH "aarch64eb"
# define _MACHINE32_ARCH earmv7hfeb
# define MACHINE32_ARCH "earmv7hfeb"
# else
# define _MACHINE_ARCH aarch64
# define MACHINE_ARCH "aarch64"
# define _MACHINE32_ARCH earmv7hf
# define MACHINE32_ARCH "earmv7hf"
# endif /* __AARCH64EB__ */
# endif /* MACHINE_ARCH */
#else
# undef _MACHINE
# undef MACHINE
# undef _MACHINE_ARCH
# undef MACHINE_ARCH
# undef _MACHINE32_ARCH
# undef MACHINE32_ARCH
# define _MACHINE aarch64
# define MACHINE "aarch64"
# ifdef __AARCH64EB__
# define _MACHINE_ARCH aarch64eb
# define MACHINE_ARCH "aarch64eb"
# define _MACHINE32_ARCH earmv7hfeb
# define MACHINE32_ARCH "earmv7hfeb"
# else
# define _MACHINE_ARCH aarch64
# define MACHINE_ARCH "aarch64"
# define _MACHINE32_ARCH earmv7hf
# define MACHINE32_ARCH "earmv7hf"
# endif /* __AARCH64EB__ */
#endif /* !_KERNEL */
#define MID_MACHINE MID_AARCH64
/* AARCH64-specific macro to align a stack pointer (downwards). */
#define STACK_ALIGNBYTES (16 - 1)
#define ALIGNBYTES32 (8 - 1)
#define ALIGN32(p) \
(((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
#define NKMEMPAGES_MAX_UNLIMITED 1
#ifdef AARCH64_PAGE_SHIFT
#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
#error AARCH64_PAGE_SHIFT contains an unsupported value.
#endif
#define PGSHIFT AARCH64_PAGE_SHIFT
#else
#define PGSHIFT 12
#endif
#define NBPG (1 << PGSHIFT)
#define PGOFSET (NBPG - 1)
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than NBPG (the software page size), and
* NBPG % MCLBYTES must be zero.
*/
#if PGSHIFT > 12
#define MSIZE 256 /* size of an mbuf */
#else
#define MSIZE 512 /* size of an mbuf */
#endif
#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 NFS_RSIZE
#define NFS_RSIZE 32768 /* Default NFS read data size */
#endif
#ifndef NFS_WSIZE
#define NFS_WSIZE 32768 /* Default NFS write data size */
#endif
#ifndef MSGBUFSIZE
#define MSGBUFSIZE 65536 /* default message buffer size */
#endif
#define COHERENCY_UNIT 128
#define CACHE_LINE_SIZE 128
#define MAXCPUS 256
#ifdef _KERNEL
#ifndef __HIDE_DELAY
void delay(unsigned int);
#define DELAY(x) delay(x)
#endif
/*
* Compatibility /dev/zero mapping.
*/
#ifdef COMPAT_16
#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM))
#endif
#endif /* _KERNEL */
#define aarch64_btop(x) ((unsigned long)(x) >> PGSHIFT)
#define aarch64_ptob(x) ((unsigned long)(x) << PGSHIFT)
#define aarch64_trunc_page(x) ((unsigned long)(x) & ~PGSHIFT)
#define aarch64_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
/* compatibility for arm */
#define arm_btop(x) aarch64_btop(x)
#define arm_ptob(x) aarch64_ptob(x)
#elif defined(__arm__)
#include <arm/param.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PARAM_H_ */

View File

@ -0,0 +1,55 @@
/* $NetBSD: pcb.h,v 1.2 2018/12/27 09:55:27 mrg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PCB_H_
#define _AARCH64_PCB_H_
#ifdef __aarch64__
#include <aarch64/reg.h>
struct pcb {
struct fpreg pcb_fpregs;
struct trapframe *pcb_tf;
};
struct md_coredump {
struct reg reg;
struct fpreg fpreg;
};
#elif defined(__arm__)
#include <arm/pcb.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PCB_H_ */

View File

@ -0,0 +1,434 @@
/* $NetBSD: pmap.h,v 1.57 2022/11/03 09:04:56 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PMAP_H_
#define _AARCH64_PMAP_H_
#ifdef __aarch64__
#ifdef _KERNEL
#ifdef _KERNEL_OPT
#include "opt_kasan.h"
#include "opt_pmap.h"
#endif
#include <sys/types.h>
#include <sys/pool.h>
#include <sys/queue.h>
#include <uvm/uvm_pglist.h>
#include <aarch64/armreg.h>
#include <aarch64/pte.h>
#define PMAP_TLB_MAX 1
#if PMAP_TLB_MAX > 1
#define PMAP_TLB_NEED_SHOOTDOWN 1
#endif
#define PMAP_TLB_FLUSH_ASID_ON_RESET true
/* Maximum number of ASIDs. Some CPUs have less.*/
#define PMAP_TLB_NUM_PIDS 65536
#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS
#define cpu_set_tlb_info(ci, ti) ((void)((ci)->ci_tlb_info = (ti)))
#if PMAP_TLB_MAX > 1
#define cpu_tlb_info(ci) ((ci)->ci_tlb_info)
#else
#define cpu_tlb_info(ci) (&pmap_tlb0_info)
#endif
static inline tlb_asid_t
pmap_md_tlb_asid_max(void)
{
switch (__SHIFTOUT(reg_id_aa64mmfr0_el1_read(), ID_AA64MMFR0_EL1_ASIDBITS)) {
case ID_AA64MMFR0_EL1_ASIDBITS_8BIT:
return (1U << 8) - 1;
case ID_AA64MMFR0_EL1_ASIDBITS_16BIT:
return (1U << 16) - 1;
default:
return 0;
}
}
#include <uvm/pmap/tlb.h>
#include <uvm/pmap/pmap_tlb.h>
#define KERNEL_PID 0 /* The kernel uses ASID 0 */
/* memory attributes are configured MAIR_EL1 in locore */
#define LX_BLKPAG_ATTR_NORMAL_WB __SHIFTIN(0, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_NORMAL_NC __SHIFTIN(1, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_NORMAL_WT __SHIFTIN(2, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_DEVICE_MEM __SHIFTIN(3, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_DEVICE_MEM_NP __SHIFTIN(4, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_MASK LX_BLKPAG_ATTR_INDX
#define lxpde_pa(pde) ((paddr_t)((pde) & LX_TBL_PA))
#define lxpde_valid(pde) (((pde) & LX_VALID) == LX_VALID)
#define l0pde_pa(pde) lxpde_pa(pde)
#define l0pde_index(v) (((vaddr_t)(v) & L0_ADDR_BITS) >> L0_SHIFT)
#define l0pde_valid(pde) lxpde_valid(pde)
/* l0pte always contains table entries */
#define l1pde_pa(pde) lxpde_pa(pde)
#define l1pde_index(v) (((vaddr_t)(v) & L1_ADDR_BITS) >> L1_SHIFT)
#define l1pde_valid(pde) lxpde_valid(pde)
#define l1pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK)
#define l1pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL)
#define l2pde_pa(pde) lxpde_pa(pde)
#define l2pde_index(v) (((vaddr_t)(v) & L2_ADDR_BITS) >> L2_SHIFT)
#define l2pde_valid(pde) lxpde_valid(pde)
#define l2pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK)
#define l2pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL)
#define l3pte_pa(pde) lxpde_pa(pde)
#define l3pte_executable(pde,user) \
(((pde) & ((user) ? LX_BLKPAG_UXN : LX_BLKPAG_PXN)) == 0)
#define l3pte_readable(pde) ((pde) & LX_BLKPAG_AF)
#define l3pte_writable(pde) \
(((pde) & (LX_BLKPAG_AF | LX_BLKPAG_AP)) == (LX_BLKPAG_AF | LX_BLKPAG_AP_RW))
#define l3pte_index(v) (((vaddr_t)(v) & L3_ADDR_BITS) >> L3_SHIFT)
#define l3pte_valid(pde) lxpde_valid(pde)
#define l3pte_is_page(pde) (((pde) & LX_TYPE) == L3_TYPE_PAG)
pd_entry_t *pmap_l0table(struct pmap *);
void pmap_bootstrap(vaddr_t, vaddr_t);
bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user);
bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *);
/* change attribute of kernel segment */
static inline pt_entry_t
pmap_kvattr(pt_entry_t *ptep, vm_prot_t prot)
{
pt_entry_t pte = *ptep;
const pt_entry_t opte = pte;
pte &= ~(LX_BLKPAG_AF | LX_BLKPAG_AP);
switch (prot & (VM_PROT_READ | VM_PROT_WRITE)) {
case 0:
break;
case VM_PROT_READ:
pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RO;
break;
case VM_PROT_WRITE:
case VM_PROT_READ | VM_PROT_WRITE:
pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RW;
break;
}
if ((prot & VM_PROT_EXECUTE) == 0) {
pte |= LX_BLKPAG_PXN;
} else {
pte |= LX_BLKPAG_AF;
pte &= ~LX_BLKPAG_PXN;
}
*ptep = pte;
return opte;
}
/* devmap */
struct pmap_devmap {
vaddr_t pd_va; /* virtual address */
paddr_t pd_pa; /* physical address */
psize_t pd_size; /* size of region */
vm_prot_t pd_prot; /* protection code */
u_int pd_flags; /* flags for pmap_kenter_pa() */
};
void pmap_devmap_register(const struct pmap_devmap *);
void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *);
const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t);
const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t);
vaddr_t pmap_devmap_phystov(paddr_t);
paddr_t pmap_devmap_vtophys(paddr_t);
#define L1_TRUNC_BLOCK(x) ((x) & L1_FRAME)
#define L1_ROUND_BLOCK(x) L1_TRUNC_BLOCK((x) + L1_SIZE - 1)
#define L2_TRUNC_BLOCK(x) ((x) & L2_FRAME)
#define L2_ROUND_BLOCK(x) L2_TRUNC_BLOCK((x) + L2_SIZE - 1)
#define L3_TRUNC_BLOCK(x) ((x) & L3_FRAME)
#define L3_ROUND_BLOCK(x) L3_TRUNC_BLOCK((x) + L3_SIZE - 1)
#define DEVMAP_ALIGN(x) L3_TRUNC_BLOCK((x))
#define DEVMAP_SIZE(x) L3_ROUND_BLOCK((x))
#define DEVMAP_ENTRY(va, pa, sz) \
{ \
.pd_va = DEVMAP_ALIGN(va), \
.pd_pa = DEVMAP_ALIGN(pa), \
.pd_size = DEVMAP_SIZE(sz), \
.pd_prot = VM_PROT_READ | VM_PROT_WRITE, \
.pd_flags = PMAP_DEV \
}
#define DEVMAP_ENTRY_END { 0 }
/* Hooks for the pool allocator */
paddr_t vtophys(vaddr_t);
/* mmap cookie and flags */
#define AARCH64_MMAP_FLAG_SHIFT (64 - PGSHIFT)
#define AARCH64_MMAP_FLAG_MASK 0xf
#define AARCH64_MMAP_WRITEBACK 0UL
#define AARCH64_MMAP_NOCACHE 1UL
#define AARCH64_MMAP_WRITECOMBINE 2UL
#define AARCH64_MMAP_DEVICE 3UL
#define ARM_MMAP_MASK __BITS(63, AARCH64_MMAP_FLAG_SHIFT)
#define ARM_MMAP_WRITECOMBINE __SHIFTIN(AARCH64_MMAP_WRITECOMBINE, ARM_MMAP_MASK)
#define ARM_MMAP_WRITEBACK __SHIFTIN(AARCH64_MMAP_WRITEBACK, ARM_MMAP_MASK)
#define ARM_MMAP_NOCACHE __SHIFTIN(AARCH64_MMAP_NOCACHE, ARM_MMAP_MASK)
#define ARM_MMAP_DEVICE __SHIFTIN(AARCH64_MMAP_DEVICE, ARM_MMAP_MASK)
#define PMAP_PTE 0x10000000 /* kenter_pa */
#define PMAP_DEV 0x20000000 /* kenter_pa */
#define PMAP_DEV_NP 0x40000000 /* kenter_pa */
#define PMAP_DEV_MASK (PMAP_DEV | PMAP_DEV_NP)
static inline u_int
aarch64_mmap_flags(paddr_t mdpgno)
{
u_int nflag, pflag;
/*
* aarch64 arch has 5 memory attributes defined:
*
* WriteBack - write back cache
* WriteThru - write through cache
* NoCache - no cache
* Device(nGnRE) - no Gathering, no Reordering, Early write ack
* Device(nGnRnE) - no Gathering, no Reordering, no Early write ack
*
* but pmap has PMAP_{NOCACHE,WRITE_COMBINE,WRITE_BACK} flags.
*/
nflag = (mdpgno >> AARCH64_MMAP_FLAG_SHIFT) & AARCH64_MMAP_FLAG_MASK;
switch (nflag) {
case AARCH64_MMAP_DEVICE:
pflag = PMAP_DEV;
break;
case AARCH64_MMAP_WRITECOMBINE:
pflag = PMAP_WRITE_COMBINE;
break;
case AARCH64_MMAP_WRITEBACK:
pflag = PMAP_WRITE_BACK;
break;
case AARCH64_MMAP_NOCACHE:
default:
pflag = PMAP_NOCACHE;
break;
}
return pflag;
}
#define pmap_phys_address(pa) aarch64_ptob((pa))
#define pmap_mmap_flags(ppn) aarch64_mmap_flags((ppn))
void pmap_bootstrap(vaddr_t, vaddr_t);
bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user);
pd_entry_t *pmapboot_pagealloc(void);
void pmapboot_enter(vaddr_t, paddr_t, psize_t, psize_t, pt_entry_t,
void (*pr)(const char *, ...) __printflike(1, 2));
void pmapboot_enter_range(vaddr_t, paddr_t, psize_t, pt_entry_t,
void (*)(const char *, ...) __printflike(1, 2));
int pmapboot_protect(vaddr_t, vaddr_t, vm_prot_t);
#if defined(DDB)
void pmap_db_pte_print(pt_entry_t, int, void (*)(const char *, ...) __printflike(1, 2));
void pmap_db_pteinfo(vaddr_t, void (*)(const char *, ...) __printflike(1, 2));
void pmap_db_ttbrdump(bool, vaddr_t, void (*)(const char *, ...) __printflike(1, 2));
#endif
#define LX_BLKPAG_OS_WIRED LX_BLKPAG_OS_2
#define LX_BLKPAG_OS_BOOT LX_BLKPAG_OS_3
#define PMAP_PTE_OS2 "wired"
#define PMAP_PTE_OS3 "boot"
#if defined(PMAP_MI)
#include <aarch64/pmap_machdep.h>
#else
#define PMAP_NEED_PROCWR
#define PMAP_GROWKERNEL
#define PMAP_STEAL_MEMORY
#define __HAVE_VM_PAGE_MD
#define __HAVE_PMAP_PV_TRACK 1
struct pmap {
kmutex_t pm_lock;
struct pool *pm_pvpool;
pd_entry_t *pm_l0table; /* L0 table: 512G*512 */
paddr_t pm_l0table_pa;
LIST_HEAD(, vm_page) pm_vmlist; /* for L[0123] tables */
LIST_HEAD(, pv_entry) pm_pvlist; /* all pv of this process */
struct pmap_statistics pm_stats;
unsigned int pm_refcnt;
unsigned int pm_idlepdp;
kcpuset_t *pm_onproc;
kcpuset_t *pm_active;
struct pmap_asid_info pm_pai[PMAP_TLB_MAX];
bool pm_activated;
};
static inline paddr_t
pmap_l0pa(struct pmap *pm)
{
return pm->pm_l0table_pa;
}
/*
* should be kept <=32 bytes sized to reduce memory consumption & cache misses,
* but it doesn't...
*/
struct pv_entry {
struct pv_entry *pv_next;
struct pmap *pv_pmap;
vaddr_t pv_va; /* for embedded entry (pp_pv) also includes flags */
void *pv_ptep; /* pointer for fast pte lookup */
LIST_ENTRY(pv_entry) pv_proc; /* belonging to the process */
};
struct pmap_page {
kmutex_t pp_pvlock;
struct pv_entry pp_pv;
};
/* try to keep vm_page at or under 128 bytes to reduce cache misses */
struct vm_page_md {
struct pmap_page mdpg_pp;
};
/* for page descriptor page only */
#define mdpg_ptep_parent mdpg_pp.pp_pv.pv_ptep
#define VM_MDPAGE_INIT(pg) \
do { \
PMAP_PAGE_INIT(&(pg)->mdpage.mdpg_pp); \
} while (/*CONSTCOND*/ 0)
#define PMAP_PAGE_INIT(pp) \
do { \
mutex_init(&(pp)->pp_pvlock, MUTEX_NODEBUG, IPL_NONE); \
(pp)->pp_pv.pv_next = NULL; \
(pp)->pp_pv.pv_pmap = NULL; \
(pp)->pp_pv.pv_va = 0; \
(pp)->pp_pv.pv_ptep = NULL; \
} while (/*CONSTCOND*/ 0)
/* saved permission bit for referenced/modified emulation */
#define LX_BLKPAG_OS_READ LX_BLKPAG_OS_0
#define LX_BLKPAG_OS_WRITE LX_BLKPAG_OS_1
#define LX_BLKPAG_OS_RWMASK (LX_BLKPAG_OS_WRITE | LX_BLKPAG_OS_READ)
#define PMAP_PTE_OS0 "read"
#define PMAP_PTE_OS1 "write"
#define VTOPHYS_FAILED ((paddr_t)-1L) /* POOL_PADDR_INVALID */
#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va))
#ifndef KASAN
#define PMAP_MAP_POOLPAGE(pa) AARCH64_PA_TO_KVA(pa)
#define PMAP_UNMAP_POOLPAGE(va) AARCH64_KVA_TO_PA(va)
#define PMAP_DIRECT
static __inline int
pmap_direct_process(paddr_t pa, voff_t pgoff, size_t len,
int (*process)(void *, size_t, void *), void *arg)
{
vaddr_t va = AARCH64_PA_TO_KVA(pa);
return process((void *)(va + pgoff), len, arg);
}
#endif
/* l3pte contains always page entries */
static inline uint64_t
pte_value(pt_entry_t pte)
{
return pte;
}
static inline bool
pte_valid_p(pt_entry_t pte)
{
return l3pte_valid(pte);
}
pt_entry_t *kvtopte(vaddr_t);
#define pmap_update(pmap) ((void)0)
#define pmap_copy(dp,sp,d,l,s) ((void)0)
#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
struct pmap *
pmap_efirt(void);
void pmap_activate_efirt(void);
void pmap_deactivate_efirt(void);
void pmap_procwr(struct proc *, vaddr_t, int);
void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t);
void pmap_pv_init(void);
void pmap_pv_track(paddr_t, psize_t);
void pmap_pv_untrack(paddr_t, psize_t);
void pmap_pv_protect(paddr_t, vm_prot_t);
#define PMAP_MAPSIZE1 L2_SIZE
/* for ddb */
void pmap_db_pmap_print(struct pmap *, void (*)(const char *, ...) __printflike(1, 2));
void pmap_db_mdpg_print(struct vm_page *, void (*)(const char *, ...) __printflike(1, 2));
#endif /* !PMAP_MI */
#endif /* _KERNEL */
#elif defined(__arm__)
#include <arm/pmap.h>
#endif /* __arm__/__aarch64__ */
#endif /* !_AARCH64_PMAP_ */

View File

@ -0,0 +1,71 @@
/* $NetBSD: proc.h,v 1.8 2020/08/12 13:19:35 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PROC_H_
#define _AARCH64_PROC_H_
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd32.h"
#endif
struct mdlwp {
void *md_onfault;
struct trapframe *md_utf;
uint64_t md_cpacr;
uint32_t md_flags;
volatile uint32_t md_astpending;
uint64_t md_ia_kern[2]; /* APIAKey{Lo,Hi}_EL1 used in the kernel */
uint64_t md_ia_user[2]; /* APIAKey{Lo,Hi}_EL1 used in user-process */
uint64_t md_ib_user[2]; /* APIBKey{Lo,Hi}_EL1 only used in user-proc. */
uint64_t md_da_user[2]; /* APDAKey{Lo,Hi}_EL1 only used in user-proc. */
uint64_t md_db_user[2]; /* APDBKey{Lo,Hi}_EL1 only used in user-proc. */
uint64_t md_ga_user[2]; /* APGAKey{Lo,Hi}_EL1 only used in user-proc. */
};
struct mdproc {
void (*md_syscall)(struct trapframe *);
char md_march32[12]; /* machine arch of executable */
};
#ifdef COMPAT_NETBSD32
#define PROC0_MD_INITIALIZERS .p_md = { .md_march32 = MACHINE32_ARCH },
#endif
#elif defined(__arm__)
#include <arm/proc.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PROC_H_ */

View File

@ -0,0 +1,99 @@
/* $NetBSD: profile.h,v 1.4 2021/02/10 12:31:34 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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.
*/
#ifdef __aarch64__
#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" /* gcc */
#define MCOUNT_ASM_NAME_ALIAS "__mcount" /* llvm */
#define PLTSYM
#define MCOUNT \
__asm(".text"); \
__asm(".align 6"); \
__asm(".type " MCOUNT_ASM_NAME ",@function"); \
__asm(".global " MCOUNT_ASM_NAME); \
__asm(".global " MCOUNT_ASM_NAME_ALIAS); \
__asm(MCOUNT_ASM_NAME ":"); \
__asm(MCOUNT_ASM_NAME_ALIAS ":"); \
/* \
* Preserve registers that are trashed during mcount \
*/ \
__asm("stp x29, x30, [sp, #-80]!"); \
__asm("stp x0, x1, [sp, #16]"); \
__asm("stp x2, x3, [sp, #32]"); \
__asm("stp x4, x5, [sp, #48]"); \
__asm("stp x6, x7, [sp, #64]"); \
/* \
* find the return address for mcount, \
* and the return address for mcount's caller. \
* \
* frompcindex = pc pushed by call into self. \
*/ \
__asm("ldr x0, [x29, #8]"); \
/* \
* selfpc = pc pushed by mcount call \
*/ \
__asm("mov x1, x30"); \
/* \
* Call the real mcount code \
*/ \
__asm("bl " ___STRING(_C_LABEL(mcount))); \
/* \
* Restore registers that were trashed during mcount \
*/ \
__asm("ldp x0, x1, [sp, #16]"); \
__asm("ldp x2, x3, [sp, #32]"); \
__asm("ldp x4, x5, [sp, #48]"); \
__asm("ldp x6, x7, [sp, #64]"); \
__asm("ldp x29, x30, [sp], #80"); \
__asm("ret"); \
__asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
#ifdef _KERNEL
#define MCOUNT_ENTER \
__asm __volatile ("mrs %x0, daif; msr daifset, #3": "=r"(s):: "memory")
#define MCOUNT_EXIT \
__asm __volatile ("msr daif, %x0":: "r"(s): "memory")
#endif /* _KERNEL */
#elif defined(__arm__)
#include <arm/profile.h>
#endif

View File

@ -0,0 +1,145 @@
/* $NetBSD: pte.h,v 1.14 2022/08/19 08:17:32 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PTE_H_
#define _AARCH64_PTE_H_
#ifdef __aarch64__
#ifndef _LOCORE
typedef uint64_t pd_entry_t; /* L0(512G) / L1(1G) / L2(2M) table entry */
#ifndef __BSD_PTENTRY_T__
#define __BSD_PTENTRY_T__
typedef uint64_t pt_entry_t; /* L3(4k) table entry */
#define PRIxPTE PRIx64
#endif /* __BSD_PTENTRY_T__ */
#endif /* _LOCORE */
/*
* translation table, block, and page descriptors
*/
#define LX_TBL_NSTABLE __BIT(63) /* inherited next level */
#define LX_TBL_APTABLE __BITS(62,61) /* inherited next level */
#define LX_TBL_APTABLE_NOEFFECT __SHIFTIN(0,LX_TBL_APTABLE)
#define LX_TBL_APTABLE_EL0_NOACCESS __SHIFTIN(1,LX_TBL_APTABLE)
#define LX_TBL_APTABLE_RO __SHIFTIN(2,LX_TBL_APTABLE)
#define LX_TBL_APTABLE_RO_EL0_NOREAD __SHIFTIN(3,LX_TBL_APTABLE)
#define LX_TBL_UXNTABLE __BIT(60) /* inherited next level */
#define LX_TBL_PXNTABLE __BIT(59) /* inherited next level */
#define LX_BLKPAG_OS __BITS(58, 55)
#define LX_BLKPAG_OS_0 __SHIFTIN(1,LX_BLKPAG_OS)
#define LX_BLKPAG_OS_1 __SHIFTIN(2,LX_BLKPAG_OS)
#define LX_BLKPAG_OS_2 __SHIFTIN(4,LX_BLKPAG_OS)
#define LX_BLKPAG_OS_3 __SHIFTIN(8,LX_BLKPAG_OS)
#define LX_BLKPAG_UXN __BIT(54) /* Unprivileged Execute Never */
#define LX_BLKPAG_PXN __BIT(53) /* Privileged Execute Never */
#define LX_BLKPAG_CONTIG __BIT(52) /* Hint of TLB cache */
#define LX_BLKPAG_DBM __BIT(51) /* Dirty Bit Modifier (V8.1) */
#define LX_BLKPAG_GP __BIT(50) /* Guarded Page (V8.5) */
#define LX_TBL_PA __BITS(47, 12)
#define LX_BLKPAG_OA __BITS(47, 12)
#define LX_BLKPAG_NG __BIT(11) /* Not Global */
#define LX_BLKPAG_AF __BIT(10) /* Access Flag */
#define LX_BLKPAG_SH __BITS(9,8) /* Shareability */
#define LX_BLKPAG_SH_NS __SHIFTIN(0,LX_BLKPAG_SH) /* Non Shareable */
#define LX_BLKPAG_SH_OS __SHIFTIN(2,LX_BLKPAG_SH) /* Outer Shareable */
#define LX_BLKPAG_SH_IS __SHIFTIN(3,LX_BLKPAG_SH) /* Inner Shareable */
#define LX_BLKPAG_AP __BIT(7)
#define LX_BLKPAG_AP_RW __SHIFTIN(0,LX_BLKPAG_AP) /* RW */
#define LX_BLKPAG_AP_RO __SHIFTIN(1,LX_BLKPAG_AP) /* RO */
#define LX_BLKPAG_APUSER __BIT(6)
#define LX_BLKPAG_NS __BIT(5)
#define LX_BLKPAG_ATTR_INDX __BITS(4,2) /* refer MAIR_EL1 attr<n> */
#define LX_BLKPAG_ATTR_INDX_0 __SHIFTIN(0,LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_INDX_1 __SHIFTIN(1,LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_INDX_2 __SHIFTIN(2,LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_INDX_3 __SHIFTIN(3,LX_BLKPAG_ATTR_INDX)
#define LX_TYPE __BIT(1)
#define LX_TYPE_BLK __SHIFTIN(0, LX_TYPE)
#define LX_TYPE_TBL __SHIFTIN(1, LX_TYPE)
#define L3_TYPE_PAG __SHIFTIN(1, LX_TYPE)
#define LX_VALID __BIT(0)
#define L1_BLK_OA __BITS(47, 30) /* 1GB */
#define L2_BLK_OA __BITS(47, 21) /* 2MB */
#define L3_PAG_OA __BITS(47, 12) /* 4KB */
#define AARCH64_MAX_PA __BIT(48)
/* L0 table, 512GB/entry * 512 */
#define L0_SHIFT 39
#define L0_ADDR_BITS __BITS(47,39)
#define L0_SIZE (1UL << L0_SHIFT)
#define L0_OFFSET (L0_SIZE - 1UL)
#define L0_FRAME (~L0_OFFSET)
/* L0_BLOCK Level 0 doesn't support block translation */
#define L0_TABLE (LX_TYPE_TBL | LX_VALID)
/* L1 table, 1GB/entry * 512 */
#define L1_SHIFT 30
#define L1_ADDR_BITS __BITS(38,30)
#define L1_SIZE (1UL << L1_SHIFT)
#define L1_OFFSET (L1_SIZE - 1UL)
#define L1_FRAME (~L1_OFFSET)
#define L1_BLOCK (LX_TYPE_BLK | LX_VALID)
#define L1_TABLE (LX_TYPE_TBL | LX_VALID)
/* L2 table, 2MB/entry * 512 */
#define L2_SHIFT 21
#define L2_ADDR_BITS __BITS(29,21)
#define L2_SIZE (1UL << L2_SHIFT)
#define L2_OFFSET (L2_SIZE - 1UL)
#define L2_FRAME (~L2_OFFSET)
#define L2_BLOCK (LX_TYPE_BLK | LX_VALID)
#define L2_TABLE (LX_TYPE_TBL | LX_VALID)
#define L2_BLOCK_MASK __BITS(47,21)
/* L3 table, 4KB/entry * 512 */
#define L3_SHIFT 12
#define L3_ADDR_BITS __BITS(20,12)
#define L3_SIZE (1UL << L3_SHIFT)
#define L3_OFFSET (L3_SIZE - 1UL)
#define L3_FRAME (~L3_OFFSET)
#define L3_PAGE (L3_TYPE_PAG | LX_VALID)
#define Ln_ENTRIES_SHIFT 9
#define Ln_ENTRIES (1 << Ln_ENTRIES_SHIFT)
#define Ln_TABLE_SIZE (8 << Ln_ENTRIES_SHIFT)
#elif defined(__arm__)
#include <arm/pte.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PTE_H_ */

View File

@ -0,0 +1,94 @@
/* $NetBSD: ptrace.h,v 1.12 2020/09/07 18:29:48 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PTRACE_H_
#define _AARCH64_PTRACE_H_
#ifdef __aarch64__
/*
* AARCH64-dependent ptrace definitions.
*/
#define PT_GETREGS (PT_FIRSTMACH + 0)
#define PT_SETREGS (PT_FIRSTMACH + 1)
#define PT_GETFPREGS (PT_FIRSTMACH + 2)
#define PT_SETFPREGS (PT_FIRSTMACH + 3)
#define PT_STEP (PT_FIRSTMACH + 4)
#define PT_SETSTEP (PT_FIRSTMACH + 5)
#define PT_CLEARSTEP (PT_FIRSTMACH + 6)
#define PT_MACHDEP_STRINGS \
"PT_GETREGS", \
"PT_SETREGS", \
"PT_GETFPREGS", \
"PT_SETFPREGS", \
"PT_STEP", \
"PT_SETSTEP", \
"PT_CLEARSTEP",
#include <machine/reg.h>
#define PTRACE_REG_PC(r) (r)->r_pc
#define PTRACE_REG_FP(r) (r)->r_reg[29]
#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v)
#define PTRACE_REG_SP(r) (r)->r_sp
#define PTRACE_REG_INTRV(r) (r)->r_reg[0]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xa0, 0x01, 0x20, 0xd4 })
#define PTRACE_BREAKPOINT_ASM __asm __volatile("brk #13" ::: "memory")
#define PTRACE_BREAKPOINT_SIZE 4
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd32.h"
#endif
#ifdef COMPAT_NETBSD32
#include <machine/netbsd32_machdep.h>
#define process_read_regs32 netbsd32_process_read_regs
#define process_read_fpregs32 netbsd32_process_read_fpregs
#define process_write_regs32 netbsd32_process_write_regs
#define process_write_fpregs32 netbsd32_process_write_fpregs
#define process_reg32 struct reg32
#define process_fpreg32 struct fpreg32
#define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x)
#endif /* COMPAT_NETBSD32 */
#elif defined(__arm__)
#include <arm/ptrace.h>
#endif
#endif /* _AARCH64_PTRACE_H_ */

View File

@ -0,0 +1,64 @@
/* $NetBSD: reg.h,v 1.3 2018/07/17 16:21:43 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_REG_H_
#define _AARCH64_REG_H_
#ifdef __aarch64__
struct reg {
uint64_t r_reg[31];
uint64_t r_sp;
uint64_t r_pc; /* aka elr */
uint64_t r_spsr;
uint64_t r_tpidr;
};
union fpelem {
uint64_t u64[2];
#ifdef __SIZEOF_INT128__
__uint128_t u128[1];
#endif
};
struct fpreg {
union fpelem fp_reg[32];
uint32_t fpcr;
uint32_t fpsr;
} __aligned(16);
#elif defined(__arm__)
#include <arm/reg.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_REG_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: rwlock.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/rwlock.h>

View File

@ -0,0 +1,71 @@
/* $NetBSD: setjmp.h,v 1.2 2020/05/10 14:05:59 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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.
*/
#ifdef __aarch64__
#define _JB_MAGIC_AARCH64__SETJMP 0x4545524348363400
#define _JB_MAGIC_AARCH64_SETJMP 0x4545524348363401
/* magic + 13 reg + 8 simd + 4 sigmask + 6 slop */
#define _JBLEN (32 * sizeof(_BSD_JBSLOT_T_)/sizeof(long))
#define _JB_MAGIC 0
#define _JB_SP 1
#define _JB_X19 2
#define _JB_X20 3
#define _JB_X21 4
#define _JB_X22 5
#define _JB_X23 6
#define _JB_X24 7
#define _JB_X25 8
#define _JB_X26 9
#define _JB_X27 10
#define _JB_X28 11
#define _JB_X29 12
#define _JB_X30 13
#define _JB_D8 16
#define _JB_D9 17
#define _JB_D10 18
#define _JB_D11 19
#define _JB_D12 20
#define _JB_D13 21
#define _JB_D14 22
#define _JB_D15 23
#define _JB_SIGMASK 24
#ifndef _BSD_JBSLOT_T_
#define _BSD_JBSLOT_T_ long long
#endif
#elif defined(__arm__)
#include <arm/setjmp.h>
#endif

View File

@ -0,0 +1,21 @@
/* $NetBSD: signal.h,v 1.4 2021/11/05 15:18:18 thorpej Exp $ */
#ifndef _AARCH64_SIGNAL_H_
#define _AARCH64_SIGNAL_H_
#include <arm/signal.h>
#ifdef _KERNEL
/*
* Normally, to support COMPAT_NETBSD32 we need to define
* __HAVE_STRUCT_SIGCONTEXT in order to support the old
* "sigcontext" style of handlers for 32-bit binaries.
* However, we only support 32-bit EABI binaries on AArch64,
* and by happy accident (due to a libc bug introduced in
* 2006), 32-bit NetBSD EABI binaries never used "sigcontext"
* style handlers. So, we don't need to carry any of this
* baggage forward.
*/
#endif /* _KERNEL */
#endif /* ! _AARCH64_SIGNAL_H_ */

View File

@ -0,0 +1,67 @@
/* $NetBSD: sljit_machdep.h,v 1.3.18.2 2024/05/11 14:08:32 martin Exp $ */
/*-
* Copyright (c) 2014 Alexander Nasonov.
* 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 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 _AARCH64_SLJITARCH_H
#define _AARCH64_SLJITARCH_H
#ifndef __aarch64__ /* compat32 */
#include <arm/sljit_machdep.h>
#else /* __aarch64__ */
#include <sys/cdefs.h>
#ifdef _KERNEL
#include <machine/types.h>
#include <arm/cpufunc.h>
#else
#include <stddef.h>
#include <stdint.h>
#include <aarch64/sysarch.h>
#endif
#define SLJIT_CONFIG_ARM_64 1
#ifdef _HARDKERNEL
/*
* XXX Currently sys/rump/include/machine/cpu.h doesn't have
* ci_cpufuncs for cpu_icache_sync_range, so we do this only for
* non-rump kernels for now.
*/
#define SLJIT_CACHE_FLUSH(from, to) \
cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from)))
#else
#define SLJIT_CACHE_FLUSH(from, to) \
(void)__builtin___clear_cache((char *)(from), (char *)(to))
#endif
#endif /* __aarch64__ (vs compat32) */
#endif /* _AARCH64_SLJITARCH_H */

View File

@ -0,0 +1,3 @@
/* $NetBSD: sysarch.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
#include <arm/sysarch.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: trap.h,v 1.3 2020/05/10 11:04:09 skrll Exp $ */
/* This file is intentionally empty */

View File

@ -0,0 +1,135 @@
/* $NetBSD: types.h,v 1.21 2022/11/03 09:04:56 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_TYPES_H_
#define _AARCH64_TYPES_H_
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_pmap.h"
#endif
#include <sys/cdefs.h>
#include <sys/featuretest.h>
#include <arm/int_types.h>
#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || \
defined(_STANDALONE)
typedef unsigned long vm_offset_t; /* deprecated */
typedef unsigned long vm_size_t; /* deprecated */
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"
typedef __uint64_t register_t;
typedef __uint32_t register32_t;
#define PRIxREGISTER PRIx64
#define PRIxREGISTER32 PRIx32
typedef unsigned int tlb_asid_t;
#if defined(_KERNEL)
#define LBL_X19 0
#define LBL_X20 1
#define LBL_X21 2
#define LBL_X22 3
#define LBL_X23 4
#define LBL_X24 5
#define LBL_X25 6
#define LBL_X26 7
#define LBL_X27 8
#define LBL_X28 9
#define LBL_X29 10
#define LBL_LR 11
#define LBL_SP 12
#define LBL_MAX 13
typedef struct label_t { /* Used by setjmp & longjmp */
register_t lb_reg[LBL_MAX]; /* x19 .. x30, sp */
} label_t;
#endif
#endif
/*
* This should have always been an 8-bit type.
*/
typedef unsigned char __cpu_simple_lock_nv_t;
typedef __uint64_t __register_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
#define __HAVE_ATOMIC64_OPS
#define __HAVE_BUS_SPACE_8
#define __HAVE_COMMON___TLS_GET_ADDR
#define __HAVE_CPU_COUNTER
#define __HAVE_CPU_DATA_FIRST
#define __HAVE_FAST_SOFTINTS
#define __HAVE_MINIMAL_EMUL
#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
#define __HAVE_MM_MD_KERNACC
#define __HAVE_NEW_STYLE_BUS_H
#define __HAVE_OLD_DISKLABEL /* compatibility */
#define __HAVE_SYSCALL_INTERN
#define __HAVE_TLS_VARIANT_I
#define __HAVE___LWP_GETPRIVATE_FAST
#define __HAVE_UCAS_FULL
#if defined(_KERNEL) || defined(_KMEMUSER)
#define PCU_FPU 0
#define PCU_UNIT_COUNT 1
#endif
#if defined(_KERNEL)
#define __HAVE_RAS
#endif
#if defined(PMAP_MI)
/* XXX temporary */
#define __HAVE_UNLOCKED_PMAP
#endif
#elif defined(__arm__)
#include <arm/types.h>
#endif
#endif /* _AARCH64_TYPES_H_ */

View File

@ -0,0 +1,194 @@
/* $NetBSD: vmparam.h,v 1.19.4.1 2024/07/03 19:13:20 martin Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_VMPARAM_H_
#define _AARCH64_VMPARAM_H_
#ifdef __aarch64__
#define __USE_TOPDOWN_VM
/*
* Default pager_map of 16MB is small and we have plenty of VA to burn.
*/
#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
/*
* Defaults for Unified Buffer Cache parameters.
*/
#ifndef UBC_WINSHIFT
#define UBC_WINSHIFT 16 /* 64kB */
#endif
#ifndef UBC_NWINS
#define UBC_NWINS 4096 /* 256MB */
#endif
/*
* AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB. Each page table can
* even have its own page size.
*/
#ifdef AARCH64_PAGE_SHIFT
#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
#error AARCH64_PAGE_SHIFT contains an unsupported value.
#endif
#define PAGE_SHIFT AARCH64_PAGE_SHIFT
#else
#define PAGE_SHIFT 12
#endif
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SIZE - 1)
#if PAGE_SHIFT <= 14
#define USPACE 32768
#else
#define USPACE 65536
#endif
#define UPAGES (USPACE >> PAGE_SHIFT)
/*
* USRSTACK is the top (end) of the user stack. The user VA space is a
* 48-bit address space starting at 0. Place the stack at its top end.
*/
#define USRSTACK VM_MAXUSER_ADDRESS
#ifndef MAXTSIZ
#define MAXTSIZ (1L << 30) /* max text size (1GB) */
#endif
#ifndef MAXDSIZ
#define MAXDSIZ (1L << 36) /* max data size (64GB) */
#endif
#ifndef MAXSSIZ
#define MAXSSIZ (1L << 26) /* max stack size (64MB) */
#endif
#ifndef DFLDSIZ
#define DFLDSIZ (1L << 32) /* default data size (4GB) */
#endif
#ifndef DFLSSIZ
#define DFLSSIZ (1L << 23) /* default stack size (8MB) */
#endif
#define USRSTACK32 VM_MAXUSER_ADDRESS32
#ifndef MAXDSIZ32
#define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */
#endif
#ifndef MAXSSIZ32
#define MAXSSIZ32 (64*1024*1024) /* max stack size */
#endif
#ifndef DFLDSIZ32
#define DFLDSIZ32 (1L << 27) /* 32bit default data size (128MB) */
#endif
#ifndef DFLSSIZ32
#define DFLSSIZ32 (1L << 21) /* 32bit default stack size (2MB) */
#endif
#define VM_MIN_ADDRESS ((vaddr_t) 0x0)
#define VM_MAXUSER_ADDRESS ((vaddr_t) (1L << 48) - PAGE_SIZE)
#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
#define VM_MAXUSER_ADDRESS32 ((vaddr_t) 0xfffff000)
/*
* kernel virtual space layout:
* 0xffff_0000_0000_0000 - 64T direct mapping
* 0xffff_4000_0000_0000 - 32T (KASAN SHADOW MAP)
* 0xffff_6000_0000_0000 - 32T (not used)
* 0xffff_8000_0000_0000 - 1G (EFI_RUNTIME - legacy)
* 0xffff_8000_4000_0000 - 64T (not used)
* 0xffff_c000_0000_0000 - 64T KERNEL VM Space (including text/data/bss)
* (0xffff_c000_4000_0000 -1GB) KERNEL VM start of KVM
* 0xffff_ffff_f000_0000 - 254M KERNEL_IO for pmap_devmap
* 0xffff_ffff_ffe0_0000 - 2M RESERVED
*/
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffc00000000000L)
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) 0xffffffffffe00000L)
/*
* Reserved space for EFI runtime services (legacy)
*/
#define EFI_RUNTIME_VA 0xffff800000000000L
#define EFI_RUNTIME_SIZE 0x0000000040000000L
/*
* last 254MB of kernel vm area (0xfffffffff0000000-0xffffffffffe00000)
* may be used for devmap. see aarch64/pmap.c:pmap_devmap_*
*/
#define VM_KERNEL_IO_ADDRESS 0xfffffffff0000000L
#define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS)
#define VM_KERNEL_VM_BASE (0xffffc00040000000L)
#define VM_KERNEL_VM_SIZE (VM_KERNEL_IO_ADDRESS - VM_KERNEL_VM_BASE)
/* virtual sizes (bytes) for various kernel submaps */
#define USRIOSIZE (PAGE_SIZE / 8)
#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \
trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size)
#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \
round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32)
/*
* Since we have the address space, we map all of physical memory (RAM)
* using block page table entries.
*/
#define AARCH64_DIRECTMAP_MASK ((vaddr_t) 0xffff000000000000L)
#define AARCH64_DIRECTMAP_SIZE (1UL << 46) /* 64TB */
#define AARCH64_DIRECTMAP_START AARCH64_DIRECTMAP_MASK
#define AARCH64_DIRECTMAP_END (AARCH64_DIRECTMAP_START + AARCH64_DIRECTMAP_SIZE)
#define AARCH64_KVA_P(va) (((vaddr_t) (va) & AARCH64_DIRECTMAP_MASK) != 0)
#define AARCH64_PA_TO_KVA(pa) ((vaddr_t) ((pa) | AARCH64_DIRECTMAP_START))
#define AARCH64_KVA_TO_PA(va) ((paddr_t) ((va) & ~AARCH64_DIRECTMAP_MASK))
/* */
#define VM_PHYSSEG_MAX 256 /* XXX */
#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
#define VM_NFREELIST 1
#define VM_FREELIST_DEFAULT 0
#elif defined(__arm__)
#include <arm/vmparam.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_VMPARAM_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: wchar_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/wchar_limits.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: float.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/float.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: ansi.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */
#include <arm/ansi.h>

View File

@ -0,0 +1,37 @@
/* $NetBSD: aout_machdep.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_AOUT_MACHDEP_H_
#define _AARCH64_AOUT_MACHDEP_H_
#include <arm/aout_machdep.h>
#endif /* !_AARCH64_AOUT_MACHDEP_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
/* $NetBSD: asm.h,v 1.9 2020/08/02 06:58:16 maxv Exp $ */
#ifndef _AARCH64_ASM_H_
#define _AARCH64_ASM_H_
#if defined(_KERNEL_OPT)
#include "opt_cpuoptions.h"
#endif
#include <arm/asm.h>
#ifdef __aarch64__
#ifdef __ASSEMBLER__
.macro adrl reg, addr
adrp \reg, \addr
add \reg, \reg, #:lo12:\addr
.endm
#endif
#define fp x29
#define lr x30
/*
* Add a speculation barrier after the 'eret'.
* Some aarch64 cpus speculatively execute instructions after 'eret',
* and this potentiates side-channel attacks.
*/
#define ERET \
eret; dsb sy; isb
/*
* ARMv8 options to be made available for the compiler to use. Should be
* inserted at the beginning of the ASM files that need them.
*
* The options are:
* - PAN, needed for the compiler to recognize the PAN register.
* - PAC, needed for the compiler to recognize the key registers.
*/
#ifdef ARMV83_PAC
#define ARMV8_DEFINE_OPTIONS \
.arch armv8.3-a
#elif defined(ARMV81_PAN)
#define ARMV8_DEFINE_OPTIONS \
.arch armv8.1-a
#else
#define ARMV8_DEFINE_OPTIONS /* nothing */
#endif
#endif
#endif /* !_AARCH64_ASM_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: bswap.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/bswap.h>

View File

@ -0,0 +1,112 @@
/* $NetBSD: byte_swap.h,v 1.4 2017/01/17 11:09:36 rin Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 __aarch64__
#ifdef _LOCORE
#define BSWAP16(_src, _dst) \
rev16 _dst, _src
#define BSWAP32(_src, _dst) \
rev _dst, _src
#define BSWAP64(_src, _dst) \
rev _dst, _src
#else
#ifdef __GNUC__
#include <sys/types.h>
__BEGIN_DECLS
#define __BYTE_SWAP_U64_VARIABLE __byte_swap_u64_variable
static __inline uint64_t
__byte_swap_u64_variable(uint64_t v)
{
if (!__builtin_constant_p(v)) {
__asm("rev\t%x0, %x1" : "=r" (v) : "0" (v));
return v;
}
v = ((v & 0x000000ff) << (56 - 0)) | ((v >> (56 - 0)) & 0x000000ff)
| ((v & 0x0000ff00) << (48 - 8)) | ((v >> (48 - 8)) & 0x0000ff00)
| ((v & 0x00ff0000) << (40 - 16)) | ((v >> (40 - 16)) & 0x00ff0000)
| ((v & 0xff000000) << (32 - 24)) | ((v >> (32 - 24)) & 0xff000000);
return v;
}
#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
static __inline uint32_t
__byte_swap_u32_variable(uint32_t v)
{
if (!__builtin_constant_p(v)) {
__asm("rev\t%w0, %w1" : "=r" (v) : "0" (v));
return v;
}
v = ((v & 0x00ff) << (24 - 0)) | ((v >> (24 - 0)) & 0x00ff)
| ((v & 0xff00) << (16 - 8)) | ((v >> (16 - 8)) & 0xff00);
return v;
}
#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable
static __inline uint16_t
__byte_swap_u16_variable(uint16_t v)
{
if (!__builtin_constant_p(v)) {
uint32_t v32 = v;
__asm("rev16\t%w0, %w1" : "=r" (v32) : "0" (v32));
return (uint16_t)v32;
}
v &= 0xffff;
v = (uint16_t)((v >> 8) | (v << 8));
return v;
}
__END_DECLS
#endif
#endif /* _LOCORE */
#elif defined(__arm__)
#include <arm/asm.h>
#endif
#endif /* _ARM_BYTE_SWAP_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: cdefs.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/cdefs.h>

View File

@ -0,0 +1,257 @@
/* $NetBSD: cpu.h,v 1.48.2.1 2024/10/13 10:43:11 martin Exp $ */
/*-
* Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_CPU_H_
#define _AARCH64_CPU_H_
#include <arm/cpu.h>
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_gprof.h"
#include "opt_multiprocessor.h"
#include "opt_pmap.h"
#endif
#include <sys/param.h>
#if defined(_KERNEL) || defined(_KMEMUSER)
#include <sys/evcnt.h>
#include <aarch64/armreg.h>
#include <aarch64/frame.h>
struct clockframe {
struct trapframe cf_tf;
};
/* (spsr & 15) == SPSR_M_EL0T(64bit,0) or USER(32bit,0) */
#define CLKF_USERMODE(cf) ((((cf)->cf_tf.tf_spsr) & 0x0f) == 0)
#define CLKF_PC(cf) ((cf)->cf_tf.tf_pc)
#define CLKF_INTR(cf) ((void)(cf), curcpu()->ci_intr_depth > 1)
/*
* LWP_PC: Find out the program counter for the given lwp.
*/
#define LWP_PC(l) ((l)->l_md.md_utf->tf_pc)
#include <sys/cpu_data.h>
#include <sys/device_if.h>
#include <sys/intr.h>
struct aarch64_cpufuncs {
void (*cf_set_ttbr0)(uint64_t);
void (*cf_icache_sync_range)(vaddr_t, vsize_t);
};
#define MAX_CACHE_LEVEL 8 /* ARMv8 has maximum 8 level cache */
struct aarch64_cache_unit {
u_int cache_type;
#define CACHE_TYPE_VPIPT 0 /* VMID-aware PIPT */
#define CACHE_TYPE_VIVT 1 /* ASID-tagged VIVT */
#define CACHE_TYPE_VIPT 2
#define CACHE_TYPE_PIPT 3
u_int cache_line_size;
u_int cache_ways;
u_int cache_sets;
u_int cache_way_size;
u_int cache_size;
};
struct aarch64_cache_info {
u_int cacheable;
#define CACHE_CACHEABLE_NONE 0
#define CACHE_CACHEABLE_ICACHE 1 /* instruction cache only */
#define CACHE_CACHEABLE_DCACHE 2 /* data cache only */
#define CACHE_CACHEABLE_IDCACHE 3 /* instruction and data caches */
#define CACHE_CACHEABLE_UNIFIED 4 /* unified cache */
struct aarch64_cache_unit icache;
struct aarch64_cache_unit dcache;
};
struct cpu_info {
struct cpu_data ci_data;
device_t ci_dev;
cpuid_t ci_cpuid;
/*
* the following are in their own cache line, as they are stored to
* regularly by remote CPUs; when they were mixed with other fields
* we observed frequent cache misses.
*/
int ci_want_resched __aligned(COHERENCY_UNIT);
/* XXX pending IPIs? */
/*
* this is stored frequently, and is fetched by remote CPUs.
*/
struct lwp *ci_curlwp __aligned(COHERENCY_UNIT);
struct lwp *ci_onproc;
/*
* largely CPU-private.
*/
struct lwp *ci_softlwps[SOFTINT_COUNT] __aligned(COHERENCY_UNIT);
uint64_t ci_lastintr;
int ci_mtx_oldspl;
int ci_mtx_count;
int ci_cpl; /* current processor level (spl) */
volatile int ci_hwpl; /* current hardware priority */
volatile u_int ci_softints;
volatile u_int ci_intr_depth;
volatile uint32_t ci_blocked_pics;
volatile uint32_t ci_pending_pics;
volatile uint32_t ci_pending_ipls;
int ci_kfpu_spl;
#if defined(PMAP_MI)
struct pmap_tlb_info *ci_tlb_info;
struct pmap *ci_pmap_lastuser;
struct pmap *ci_pmap_cur;
#endif
/* ASID of current pmap */
tlb_asid_t ci_pmap_asid_cur;
/* event counters */
struct evcnt ci_vfp_use;
struct evcnt ci_vfp_reuse;
struct evcnt ci_vfp_save;
struct evcnt ci_vfp_release;
struct evcnt ci_uct_trap;
struct evcnt ci_intr_preempt;
struct evcnt ci_rndrrs_fail;
/* FDT or similar supplied "cpu capacity" */
uint32_t ci_capacity_dmips_mhz;
/* interrupt controller */
u_int ci_gic_redist; /* GICv3 redistributor index */
uint64_t ci_gic_sgir; /* GICv3 SGIR target */
/* ACPI */
uint32_t ci_acpiid; /* ACPI Processor Unique ID */
/* cached system registers */
uint64_t ci_sctlr_el1;
uint64_t ci_sctlr_el2;
/* sysctl(9) exposed system registers */
struct aarch64_sysctl_cpu_id ci_id;
/* cache information and function pointers */
struct aarch64_cache_info ci_cacheinfo[MAX_CACHE_LEVEL];
struct aarch64_cpufuncs ci_cpufuncs;
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon; /* MI per-cpu GPROF */
#endif
} __aligned(COHERENCY_UNIT);
#ifdef _KERNEL
static inline __always_inline struct lwp * __attribute__ ((const))
aarch64_curlwp(void)
{
struct lwp *l;
__asm("mrs %0, tpidr_el1" : "=r"(l));
return l;
}
/* forward declaration; defined in sys/lwp.h. */
static __inline struct cpu_info *lwp_getcpu(struct lwp *);
#define curcpu() (lwp_getcpu(aarch64_curlwp()))
#define setsoftast(ci) (cpu_signotify((ci)->ci_onproc))
#undef curlwp
#define curlwp (aarch64_curlwp())
#define curpcb ((struct pcb *)lwp_getpcb(curlwp))
void cpu_signotify(struct lwp *l);
void cpu_need_proftick(struct lwp *l);
void cpu_hatch(struct cpu_info *);
extern struct cpu_info *cpu_info[];
extern struct cpu_info cpu_info_store[];
#define CPU_INFO_ITERATOR int
#if defined(MULTIPROCESSOR) || defined(_MODULE)
#define cpu_number() (curcpu()->ci_index)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_index == 0)
#define CPU_INFO_FOREACH(cii, ci) \
cii = 0, ci = cpu_info[0]; \
cii < (ncpu ? ncpu : 1) && (ci = cpu_info[cii]) != NULL; \
cii++
#else /* MULTIPROCESSOR */
#define cpu_number() 0
#define CPU_IS_PRIMARY(ci) true
#define CPU_INFO_FOREACH(cii, ci) \
cii = 0, __USE(cii), ci = curcpu(); ci != NULL; ci = NULL
#endif /* MULTIPROCESSOR */
#define LWP0_CPU_INFO (&cpu_info_store[0])
#define __HAVE_CPU_DOSOFTINTS_CI
static inline void
cpu_dosoftints_ci(struct cpu_info *ci)
{
#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS)
void dosoftints(void);
if (ci->ci_intr_depth == 0 && (ci->ci_softints >> ci->ci_cpl) > 0) {
dosoftints();
}
#endif
}
static inline void
cpu_dosoftints(void)
{
#if defined(__HAVE_FAST_SOFTINTS) && !defined(__HAVE_PIC_FAST_SOFTINTS)
cpu_dosoftints_ci(curcpu());
#endif
}
#endif /* _KERNEL */
#endif /* _KERNEL || _KMEMUSER */
#endif
#endif /* _AARCH64_CPU_H_ */

View File

@ -0,0 +1,7 @@
/* $NetBSD: disklabel.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
#if HAVE_NBTOOL_CONFIG_H
#include <nbinclude/arm/disklabel.h>
#else
#include <arm/disklabel.h>
#endif /* HAVE_NBTOOL_CONFIG_H */

View File

@ -0,0 +1,256 @@
/* $NetBSD: elf_machdep.h,v 1.5 2022/05/30 21:18:37 jkoshy Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_ELF_MACHDEP_H_
#define _AARCH64_ELF_MACHDEP_H_
#ifdef __aarch64__
#if defined(__AARCH64EB__)
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
#else
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
#endif
/* 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_BE8 0x00800000
#define EF_ARM_EABIMASK 0xff000000
#define EF_ARM_EABI_VER1 0x01000000
#define EF_ARM_EABI_VER2 0x02000000
#define EF_ARM_EABI_VER3 0x03000000
#define EF_ARM_EABI_VER4 0x04000000
#define EF_ARM_EABI_VER5 0x05000000
#define ELF32_MACHDEP_ID_CASES \
case EM_ARM: \
break;
#define ELF64_MACHDEP_ID_CASES \
case EM_AARCH64: \
break;
#define ELF64_MACHDEP_ID EM_AARCH64
#define ELF32_MACHDEP_ID EM_ARM
#define KERN_ELFSIZE 64
#define ARCH_ELFSIZE 64 /* MD native binary size */
/* Processor specific relocation types */
#define R_AARCH64_NONE 0
#define R_AARCH64_NONE2 256
#define R_AARCH64_ABS64 257 /* S + A */
#define R_AARCH64_ABS32 258 /* S + A */
#define R_AARCH64_ABS16 259 /* S + A */
#define R_AARCH64_PREL64 260 /* S + A - P */
#define R_AARCH64_PREL32 261 /* S + A - P */
#define R_AARCH64_PREL16 262 /* S + A - P */
#define R_AARCH64_MOVW_UABS_G0 263 /* S + A [bits 0..15] */
#define R_AARCH64_MOVW_UABS_G0_NC 264 /* S + A [bits 0..15] */
#define R_AARCH64_MOVW_UABS_G1 265 /* S + A [bits 16..31] */
#define R_AARCH64_MOVW_UABS_G1_NC 266 /* S + A [bits 16..31] */
#define R_AARCH64_MOVW_UABS_G2 267 /* S + A [bits 32..47] */
#define R_AARCH64_MOVW_UABS_G2_NC 268 /* S + A [bits 32..47] */
#define R_AARCH64_MOVW_UABS_G3 269 /* S + A [bits 48..63] */
#define R_AARCH64_MOVW_SABS_G0 270 /* S + A [bits 0..15] */
#define R_AARCH64_MOVW_SABS_G1 271 /* S + A [bits 16..31] */
#define R_AARCH64_MOVW_SABS_G2 272 /* S + A [bits 32..47] */
#define R_AARCH64_LD_PREL_LO19 273 /* S + A - P */
#define R_AARCH64_ADR_PREL_LO21 274 /* S + A - P */
#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page(S + A) - Page(P) */
#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Page(S + A) - Page(P) */
#define R_AARCH64_ADD_ABS_LO12_NC 277 /* S + A */
#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* S + A */
#define R_AARCH_TSTBR14 279 /* S + A - P */
#define R_AARCH_CONDBR19 281 /* S + A - P */
#define R_AARCH_JUMP26 282 /* S + A - P */
#define R_AARCH_CALL26 283 /* S + A - P */
#define R_AARCH_LDST16_ABS_LO12_NC 284 /* S + A */
#define R_AARCH_LDST32_ABS_LO12_NC 285 /* S + A */
#define R_AARCH_LDST64_ABS_LO12_NC 286 /* S + A */
#define R_AARCH64_MOVW_PREL_G0 287 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G0_NC 288 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G1 289 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G1_NC 290 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G2 291 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G2_NC 292 /* S + A - P */
#define R_AARCH64_MOVW_PREL_G3 293 /* S + A - P */
#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* S + A */
#define R_AARCH64_MOVW_GOTOFF_G0 300 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G1 302 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G2 304 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_MOVW_GOTOFF_G3 306 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_GOTREL64 307 /* S + A - GOT */
#define R_AARCH64_GOTREL32 308 /* S + A - GOT */
#define R_AARCH64_GOT_LD_PREL19 309 /* G(GDAT(S + A)) - P */
#define R_AARCH64_LD64_GOTOFF_LO15 310 /* G(GDAT(S + A)) - GOT */
#define R_AARCH64_ADR_GOT_PAGE 311 /* Page(G(GDAT(S + A))) - Page(GOT) */
#define R_AARCH64_LD64_GOT_LO12_NC 312 /* G(GDAT(S + A)) */
#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* G(GDAT(S + A)) - Page(GOT) */
#define R_AARCH64_TLSGD_ADR_PREL21 512 /* G(GTLSIDX(S,A)) - P */
#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* Page(G(GTLSIDX(S,A))) - Page(P) */
#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* G(GTLSIDX(S,A)) */
#define R_AARCH64_TLSGD_MOVW_G1 515 /* G(GTLSIDX(S,A)) - GOT */
#define R_AARCH64_TLSGD_MOVW_G0_NV 516 /* G(GTLSIDX(S,A)) - GOT */
#define R_AARCH64_TLSLD_ADR_PREL21 517 /* G(GLDM(S,A)) - P */
#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Page(G(GLDM(S))) - Page(P) */
#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* G(GLDM(S)) */
#define R_AARCH64_TLSLD_MOVW_G1 520 /* G(GLDM(S)) - GOT */
#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* G(GLDM(S)) - GOT */
#define R_AARCH64_TLSLD_LD_PREL21 522 /* G(GLDM(S)) - P */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 528 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* DTPREL(S+A) */
#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* G(GTPREL(S+A)) - GOT */
#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* G(GTPREL(S+A)) - GOT */
#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page(G(GTPREL(S+A))) - Page(P) */
#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* G(GTPREL(S+A)) */
#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* G(GTPREL(S+A)) - P */
#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G1 545 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G1_NC 546 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G0 547 /* TPREL(S+A) */
#define R_AARCH64_MOVW_TPREL_G0_NC 548 /* TPREL(S+A) */
#define R_AARCH64_ADD_TPREL_HI12 549 /* TPREL(S+A) */
#define R_AARCH64_ADD_TPREL_LO12 550 /* TPREL(S+A) */
#define R_AARCH64_ADD_TPREL_LO12_NC 551 /* TPREL(S+A) */
#define R_AARCH64_LDST8_TPREL_LO12 552 /* TPREL(S+A) */
#define R_AARCH64_LDST8_TPREL_LO12_NC 553 /* TPREL(S+A) */
#define R_AARCH64_LDST16_TPREL_LO12 554 /* TPREL(S+A) */
#define R_AARCH64_LDST16_TPREL_LO12_NC 555 /* TPREL(S+A) */
#define R_AARCH64_LDST32_TPREL_LO12 556 /* TPREL(S+A) */
#define R_AARCH64_LDST32_TPREL_LO12_NC 557 /* TPREL(S+A) */
#define R_AARCH64_LDST64_TPREL_LO12 558 /* TPREL(S+A) */
#define R_AARCH64_LDST64_TPREL_LO12_NC 559 /* TPREL(S+A) */
#define R_AARCH64_TLSDESC_LD_PREL19 560 /* G(GTLSDESC(S+A)) - P */
#define R_AARCH64_TLSDESC_LD_PREL21 561 /* G(GTLSDESC(S+A)) - P */
#define R_AARCH64_TLSDESC_LD_PAGE21 562 /* Page(G(GTLSDESC(S+A))) - Page(P) */
#define R_AARCH64_TLSDESC_LD64_LO12 563 /* G(GTLSDESC(S+A)) */
#define R_AARCH64_TLSDESC_ADD_LO12 564 /* G(GTLSDESC(S+A)) */
#define R_AARCH64_TLSDESC_OFF_G1 565 /* G(GTLSDESC(S+A)) - GOT */
#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* G(GTLSDESC(S+A)) - GOT */
#define R_AARCH64_TLSDESC_LDR 567 /* */
#define R_AARCH64_TLSDESC_ADD 568 /* */
#define R_AARCH64_TLSDESC_CALL 569 /* */
#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TPREL(S+A) */
#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* TPREL(S+A) */
#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTPREL(S+A) */
#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* DTPREL(S+A) */
/* Dynamic Relocations */
#define R_AARCH64_P32_COPY 180
#define R_AARCH64_P32_GLOB_DAT 181 /* S + A */
#define R_AARCH64_P32_JUMP_SLOT 182 /* S + A */
#define R_AARCH64_P32_RELATIVE 183 /* Delta(S) + A */
#define R_AARCH64_P32_TLS_DTPREL 184 /* DTPREL(S+A) */
#define R_AARCH64_P32_TLS_DTPMOD 185 /* LBM(S) */
#define R_AARCH64_P32_TLS_TPREL 186 /* TPREL(S+A) */
#define R_AARCH64_P32_TLSDESC 187 /* TLSDESC(S+A) */
#define R_AARCH64_P32_IRELATIVE 188 /* Indirect(Delta(S) + A) */
#define R_AARCH64_COPY 1024
#define R_AARCH64_GLOB_DAT 1025 /* S + A */
#define R_AARCH64_JUMP_SLOT 1026 /* S + A */
#define R_AARCH64_RELATIVE 1027 /* Delta(S) + A */
#define R_AARCH64_TLS_DTPREL64 1028 /* DTPREL(S+A) */
#define R_AARCH64_TLS_DTPMOD64 1029 /* LBM(S) */
#define R_AARCH64_TLS_TPREL64 1030 /* TPREL(S+A) */
#define R_AARCH64_TLSDESC 1031 /* TLSDESC(S+A) */
#define R_AARCH64_IRELATIVE 1032 /* Indirect(Delta(S) + A) */
#define R_TYPE(name) R_AARCH64_ ## name
#define R_TLS_TYPE(name) R_AARCH64_ ## name ## 64
/* Processor specific program header types */
#define PT_AARCH64_ARCHEXT (PT_LOPROC + 0)
#define PT_AARCH64_UNWIND (PT_LOPROC + 1)
/* Processor specific section header flags */
#define SHF_ENTRYSECT 0x10000000
#define SHF_COMDEF 0x80000000
#define SHT_AARCH64_ATTRIBUTES (SHT_LOPROC + 3)
#ifdef _KERNEL
#ifdef ELFSIZE
#define ELF_MD_PROBE_FUNC ELFNAME2(aarch64_netbsd,probe)
#endif
struct exec_package;
int aarch64_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *,
char *, vaddr_t *);
int aarch64_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *,
char *, vaddr_t *);
#endif
#elif defined(__arm__)
#include <arm/elf_machdep.h>
#endif
#endif /* _AARCH64_ELF_MACHDEP_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: endian.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <sys/endian.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: endian_machdep.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/endian_machdep.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: fenv.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/fenv.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: float.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/float.h>

View File

@ -0,0 +1,83 @@
/* $NetBSD: frame.h,v 1.5 2020/08/06 06:49:55 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_FRAME_H_
#define _AARCH64_FRAME_H_
#ifdef __aarch64__
#include <aarch64/reg.h>
struct trapframe {
struct reg tf_regs __aligned(16);
uint64_t tf_esr; // 32-bit register
uint64_t tf_far; // 64-bit register
#define tf_reg tf_regs.r_reg
#define tf_lr tf_regs.r_reg[30]
#define tf_pc tf_regs.r_pc
#define tf_sp tf_regs.r_sp
#define tf_spsr tf_regs.r_spsr
};
#ifdef _KERNEL
/* size of trapframe (stack pointer) must be 16byte aligned */
__CTASSERT((sizeof(struct trapframe) & 15) == 0);
#endif
#define TF_SIZE sizeof(struct trapframe)
#define FB_X19 0
#define FB_X20 1
#define FB_X21 2
#define FB_X22 3
#define FB_X23 4
#define FB_X24 5
#define FB_X25 6
#define FB_X26 7
#define FB_X27 8
#define FB_X28 9
#define FB_X29 10
#define FB_LR 11
#define FB_SP 12
#define FB_MAX 13
struct faultbuf {
register_t fb_reg[FB_MAX];
};
#define lwp_trapframe(l) ((l)->l_md.md_utf)
#elif defined(__arm__)
#include <arm/frame.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_FRAME_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: ieee.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/ieee.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: ieeefp.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/ieeefp.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_const.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_const.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_fmtio.h,v 1.3 2014/08/13 19:51:27 matt Exp $ */
#include <arm/int_fmtio.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_limits.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_mwgwtypes.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: int_types.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/int_types.h>

View File

@ -0,0 +1,50 @@
/* $NetBSD: kcore.h,v 1.2 2018/11/09 04:05:27 mrg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_KCORE_H_
#define _AARCH64_KCORE_H_
#ifdef __aarch64__
typedef struct cpu_kcore_hdr {
uint64_t kh_tcr1; /* TCR for EL1 */
uint64_t kh_ttbr1; /* TTBR for EL1 */
uint64_t kh_nramsegs;
phys_ram_seg_t kh_ramsegs[0];
} cpu_kcore_hdr_t;
#elif defined(__arm__)
#include <arm/kcore.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_KCORE_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/limits.h>

View File

@ -0,0 +1,20 @@
/* $NetBSD: lock.h,v 1.5 2022/07/24 20:28:32 riastradh Exp $ */
#ifndef _AARCH64_LOCK_H_
#define _AARCH64_LOCK_H_
#include <sys/param.h>
#ifdef __aarch64__
# ifdef _HARDKERNEL
# ifdef SPINLOCK_BACKOFF_HOOK
# undef SPINLOCK_BACKOFF_HOOK
# endif
# define SPINLOCK_BACKOFF_HOOK asm volatile("yield" ::: "memory")
# endif
# include <sys/common_lock.h>
#elif defined(__arm__)
# include <arm/lock.h>
#endif
#endif /* _AARCH64_LOCK_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: math.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/math.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: mcontext.h,v 1.4 2018/04/01 04:35:03 ryo Exp $ */
#include <arm/mcontext.h>

View File

@ -0,0 +1,5 @@
/* $NetBSD: mutex.h,v 1.2 2020/08/12 13:28:46 skrll Exp $ */
#include <arm/mutex.h>
#define __HAVE_MUTEX_STUBS 1

View File

@ -0,0 +1,181 @@
/* $NetBSD: param.h,v 1.16 2021/05/31 14:38:57 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PARAM_H_
#define _AARCH64_PARAM_H_
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_cputypes.h"
#include "opt_param.h"
#endif
/*
* 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 */
# ifdef __AARCH64EB__
# define _MACHINE_ARCH aarch64eb
# define MACHINE_ARCH "aarch64eb"
# define _MACHINE32_ARCH earmv7hfeb
# define MACHINE32_ARCH "earmv7hfeb"
# else
# define _MACHINE_ARCH aarch64
# define MACHINE_ARCH "aarch64"
# define _MACHINE32_ARCH earmv7hf
# define MACHINE32_ARCH "earmv7hf"
# endif /* __AARCH64EB__ */
# endif /* MACHINE_ARCH */
#else
# undef _MACHINE
# undef MACHINE
# undef _MACHINE_ARCH
# undef MACHINE_ARCH
# undef _MACHINE32_ARCH
# undef MACHINE32_ARCH
# define _MACHINE aarch64
# define MACHINE "aarch64"
# ifdef __AARCH64EB__
# define _MACHINE_ARCH aarch64eb
# define MACHINE_ARCH "aarch64eb"
# define _MACHINE32_ARCH earmv7hfeb
# define MACHINE32_ARCH "earmv7hfeb"
# else
# define _MACHINE_ARCH aarch64
# define MACHINE_ARCH "aarch64"
# define _MACHINE32_ARCH earmv7hf
# define MACHINE32_ARCH "earmv7hf"
# endif /* __AARCH64EB__ */
#endif /* !_KERNEL */
#define MID_MACHINE MID_AARCH64
/* AARCH64-specific macro to align a stack pointer (downwards). */
#define STACK_ALIGNBYTES (16 - 1)
#define ALIGNBYTES32 (8 - 1)
#define ALIGN32(p) \
(((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
#define NKMEMPAGES_MAX_UNLIMITED 1
#ifdef AARCH64_PAGE_SHIFT
#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
#error AARCH64_PAGE_SHIFT contains an unsupported value.
#endif
#define PGSHIFT AARCH64_PAGE_SHIFT
#else
#define PGSHIFT 12
#endif
#define NBPG (1 << PGSHIFT)
#define PGOFSET (NBPG - 1)
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than NBPG (the software page size), and
* NBPG % MCLBYTES must be zero.
*/
#if PGSHIFT > 12
#define MSIZE 256 /* size of an mbuf */
#else
#define MSIZE 512 /* size of an mbuf */
#endif
#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 NFS_RSIZE
#define NFS_RSIZE 32768 /* Default NFS read data size */
#endif
#ifndef NFS_WSIZE
#define NFS_WSIZE 32768 /* Default NFS write data size */
#endif
#ifndef MSGBUFSIZE
#define MSGBUFSIZE 65536 /* default message buffer size */
#endif
#define COHERENCY_UNIT 128
#define CACHE_LINE_SIZE 128
#define MAXCPUS 256
#ifdef _KERNEL
#ifndef __HIDE_DELAY
void delay(unsigned int);
#define DELAY(x) delay(x)
#endif
/*
* Compatibility /dev/zero mapping.
*/
#ifdef COMPAT_16
#define COMPAT_ZERODEV(x) (x == makedev(0, _DEV_ZERO_oARM))
#endif
#endif /* _KERNEL */
#define aarch64_btop(x) ((unsigned long)(x) >> PGSHIFT)
#define aarch64_ptob(x) ((unsigned long)(x) << PGSHIFT)
#define aarch64_trunc_page(x) ((unsigned long)(x) & ~PGSHIFT)
#define aarch64_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
/* compatibility for arm */
#define arm_btop(x) aarch64_btop(x)
#define arm_ptob(x) aarch64_ptob(x)
#elif defined(__arm__)
#include <arm/param.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PARAM_H_ */

View File

@ -0,0 +1,55 @@
/* $NetBSD: pcb.h,v 1.2 2018/12/27 09:55:27 mrg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PCB_H_
#define _AARCH64_PCB_H_
#ifdef __aarch64__
#include <aarch64/reg.h>
struct pcb {
struct fpreg pcb_fpregs;
struct trapframe *pcb_tf;
};
struct md_coredump {
struct reg reg;
struct fpreg fpreg;
};
#elif defined(__arm__)
#include <arm/pcb.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PCB_H_ */

View File

@ -0,0 +1,434 @@
/* $NetBSD: pmap.h,v 1.57 2022/11/03 09:04:56 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PMAP_H_
#define _AARCH64_PMAP_H_
#ifdef __aarch64__
#ifdef _KERNEL
#ifdef _KERNEL_OPT
#include "opt_kasan.h"
#include "opt_pmap.h"
#endif
#include <sys/types.h>
#include <sys/pool.h>
#include <sys/queue.h>
#include <uvm/uvm_pglist.h>
#include <aarch64/armreg.h>
#include <aarch64/pte.h>
#define PMAP_TLB_MAX 1
#if PMAP_TLB_MAX > 1
#define PMAP_TLB_NEED_SHOOTDOWN 1
#endif
#define PMAP_TLB_FLUSH_ASID_ON_RESET true
/* Maximum number of ASIDs. Some CPUs have less.*/
#define PMAP_TLB_NUM_PIDS 65536
#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS
#define cpu_set_tlb_info(ci, ti) ((void)((ci)->ci_tlb_info = (ti)))
#if PMAP_TLB_MAX > 1
#define cpu_tlb_info(ci) ((ci)->ci_tlb_info)
#else
#define cpu_tlb_info(ci) (&pmap_tlb0_info)
#endif
static inline tlb_asid_t
pmap_md_tlb_asid_max(void)
{
switch (__SHIFTOUT(reg_id_aa64mmfr0_el1_read(), ID_AA64MMFR0_EL1_ASIDBITS)) {
case ID_AA64MMFR0_EL1_ASIDBITS_8BIT:
return (1U << 8) - 1;
case ID_AA64MMFR0_EL1_ASIDBITS_16BIT:
return (1U << 16) - 1;
default:
return 0;
}
}
#include <uvm/pmap/tlb.h>
#include <uvm/pmap/pmap_tlb.h>
#define KERNEL_PID 0 /* The kernel uses ASID 0 */
/* memory attributes are configured MAIR_EL1 in locore */
#define LX_BLKPAG_ATTR_NORMAL_WB __SHIFTIN(0, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_NORMAL_NC __SHIFTIN(1, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_NORMAL_WT __SHIFTIN(2, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_DEVICE_MEM __SHIFTIN(3, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_DEVICE_MEM_NP __SHIFTIN(4, LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_MASK LX_BLKPAG_ATTR_INDX
#define lxpde_pa(pde) ((paddr_t)((pde) & LX_TBL_PA))
#define lxpde_valid(pde) (((pde) & LX_VALID) == LX_VALID)
#define l0pde_pa(pde) lxpde_pa(pde)
#define l0pde_index(v) (((vaddr_t)(v) & L0_ADDR_BITS) >> L0_SHIFT)
#define l0pde_valid(pde) lxpde_valid(pde)
/* l0pte always contains table entries */
#define l1pde_pa(pde) lxpde_pa(pde)
#define l1pde_index(v) (((vaddr_t)(v) & L1_ADDR_BITS) >> L1_SHIFT)
#define l1pde_valid(pde) lxpde_valid(pde)
#define l1pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK)
#define l1pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL)
#define l2pde_pa(pde) lxpde_pa(pde)
#define l2pde_index(v) (((vaddr_t)(v) & L2_ADDR_BITS) >> L2_SHIFT)
#define l2pde_valid(pde) lxpde_valid(pde)
#define l2pde_is_block(pde) (((pde) & LX_TYPE) == LX_TYPE_BLK)
#define l2pde_is_table(pde) (((pde) & LX_TYPE) == LX_TYPE_TBL)
#define l3pte_pa(pde) lxpde_pa(pde)
#define l3pte_executable(pde,user) \
(((pde) & ((user) ? LX_BLKPAG_UXN : LX_BLKPAG_PXN)) == 0)
#define l3pte_readable(pde) ((pde) & LX_BLKPAG_AF)
#define l3pte_writable(pde) \
(((pde) & (LX_BLKPAG_AF | LX_BLKPAG_AP)) == (LX_BLKPAG_AF | LX_BLKPAG_AP_RW))
#define l3pte_index(v) (((vaddr_t)(v) & L3_ADDR_BITS) >> L3_SHIFT)
#define l3pte_valid(pde) lxpde_valid(pde)
#define l3pte_is_page(pde) (((pde) & LX_TYPE) == L3_TYPE_PAG)
pd_entry_t *pmap_l0table(struct pmap *);
void pmap_bootstrap(vaddr_t, vaddr_t);
bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user);
bool pmap_extract_coherency(pmap_t, vaddr_t, paddr_t *, bool *);
/* change attribute of kernel segment */
static inline pt_entry_t
pmap_kvattr(pt_entry_t *ptep, vm_prot_t prot)
{
pt_entry_t pte = *ptep;
const pt_entry_t opte = pte;
pte &= ~(LX_BLKPAG_AF | LX_BLKPAG_AP);
switch (prot & (VM_PROT_READ | VM_PROT_WRITE)) {
case 0:
break;
case VM_PROT_READ:
pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RO;
break;
case VM_PROT_WRITE:
case VM_PROT_READ | VM_PROT_WRITE:
pte |= LX_BLKPAG_AF | LX_BLKPAG_AP_RW;
break;
}
if ((prot & VM_PROT_EXECUTE) == 0) {
pte |= LX_BLKPAG_PXN;
} else {
pte |= LX_BLKPAG_AF;
pte &= ~LX_BLKPAG_PXN;
}
*ptep = pte;
return opte;
}
/* devmap */
struct pmap_devmap {
vaddr_t pd_va; /* virtual address */
paddr_t pd_pa; /* physical address */
psize_t pd_size; /* size of region */
vm_prot_t pd_prot; /* protection code */
u_int pd_flags; /* flags for pmap_kenter_pa() */
};
void pmap_devmap_register(const struct pmap_devmap *);
void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *);
const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t);
const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t);
vaddr_t pmap_devmap_phystov(paddr_t);
paddr_t pmap_devmap_vtophys(paddr_t);
#define L1_TRUNC_BLOCK(x) ((x) & L1_FRAME)
#define L1_ROUND_BLOCK(x) L1_TRUNC_BLOCK((x) + L1_SIZE - 1)
#define L2_TRUNC_BLOCK(x) ((x) & L2_FRAME)
#define L2_ROUND_BLOCK(x) L2_TRUNC_BLOCK((x) + L2_SIZE - 1)
#define L3_TRUNC_BLOCK(x) ((x) & L3_FRAME)
#define L3_ROUND_BLOCK(x) L3_TRUNC_BLOCK((x) + L3_SIZE - 1)
#define DEVMAP_ALIGN(x) L3_TRUNC_BLOCK((x))
#define DEVMAP_SIZE(x) L3_ROUND_BLOCK((x))
#define DEVMAP_ENTRY(va, pa, sz) \
{ \
.pd_va = DEVMAP_ALIGN(va), \
.pd_pa = DEVMAP_ALIGN(pa), \
.pd_size = DEVMAP_SIZE(sz), \
.pd_prot = VM_PROT_READ | VM_PROT_WRITE, \
.pd_flags = PMAP_DEV \
}
#define DEVMAP_ENTRY_END { 0 }
/* Hooks for the pool allocator */
paddr_t vtophys(vaddr_t);
/* mmap cookie and flags */
#define AARCH64_MMAP_FLAG_SHIFT (64 - PGSHIFT)
#define AARCH64_MMAP_FLAG_MASK 0xf
#define AARCH64_MMAP_WRITEBACK 0UL
#define AARCH64_MMAP_NOCACHE 1UL
#define AARCH64_MMAP_WRITECOMBINE 2UL
#define AARCH64_MMAP_DEVICE 3UL
#define ARM_MMAP_MASK __BITS(63, AARCH64_MMAP_FLAG_SHIFT)
#define ARM_MMAP_WRITECOMBINE __SHIFTIN(AARCH64_MMAP_WRITECOMBINE, ARM_MMAP_MASK)
#define ARM_MMAP_WRITEBACK __SHIFTIN(AARCH64_MMAP_WRITEBACK, ARM_MMAP_MASK)
#define ARM_MMAP_NOCACHE __SHIFTIN(AARCH64_MMAP_NOCACHE, ARM_MMAP_MASK)
#define ARM_MMAP_DEVICE __SHIFTIN(AARCH64_MMAP_DEVICE, ARM_MMAP_MASK)
#define PMAP_PTE 0x10000000 /* kenter_pa */
#define PMAP_DEV 0x20000000 /* kenter_pa */
#define PMAP_DEV_NP 0x40000000 /* kenter_pa */
#define PMAP_DEV_MASK (PMAP_DEV | PMAP_DEV_NP)
static inline u_int
aarch64_mmap_flags(paddr_t mdpgno)
{
u_int nflag, pflag;
/*
* aarch64 arch has 5 memory attributes defined:
*
* WriteBack - write back cache
* WriteThru - write through cache
* NoCache - no cache
* Device(nGnRE) - no Gathering, no Reordering, Early write ack
* Device(nGnRnE) - no Gathering, no Reordering, no Early write ack
*
* but pmap has PMAP_{NOCACHE,WRITE_COMBINE,WRITE_BACK} flags.
*/
nflag = (mdpgno >> AARCH64_MMAP_FLAG_SHIFT) & AARCH64_MMAP_FLAG_MASK;
switch (nflag) {
case AARCH64_MMAP_DEVICE:
pflag = PMAP_DEV;
break;
case AARCH64_MMAP_WRITECOMBINE:
pflag = PMAP_WRITE_COMBINE;
break;
case AARCH64_MMAP_WRITEBACK:
pflag = PMAP_WRITE_BACK;
break;
case AARCH64_MMAP_NOCACHE:
default:
pflag = PMAP_NOCACHE;
break;
}
return pflag;
}
#define pmap_phys_address(pa) aarch64_ptob((pa))
#define pmap_mmap_flags(ppn) aarch64_mmap_flags((ppn))
void pmap_bootstrap(vaddr_t, vaddr_t);
bool pmap_fault_fixup(struct pmap *, vaddr_t, vm_prot_t, bool user);
pd_entry_t *pmapboot_pagealloc(void);
void pmapboot_enter(vaddr_t, paddr_t, psize_t, psize_t, pt_entry_t,
void (*pr)(const char *, ...) __printflike(1, 2));
void pmapboot_enter_range(vaddr_t, paddr_t, psize_t, pt_entry_t,
void (*)(const char *, ...) __printflike(1, 2));
int pmapboot_protect(vaddr_t, vaddr_t, vm_prot_t);
#if defined(DDB)
void pmap_db_pte_print(pt_entry_t, int, void (*)(const char *, ...) __printflike(1, 2));
void pmap_db_pteinfo(vaddr_t, void (*)(const char *, ...) __printflike(1, 2));
void pmap_db_ttbrdump(bool, vaddr_t, void (*)(const char *, ...) __printflike(1, 2));
#endif
#define LX_BLKPAG_OS_WIRED LX_BLKPAG_OS_2
#define LX_BLKPAG_OS_BOOT LX_BLKPAG_OS_3
#define PMAP_PTE_OS2 "wired"
#define PMAP_PTE_OS3 "boot"
#if defined(PMAP_MI)
#include <aarch64/pmap_machdep.h>
#else
#define PMAP_NEED_PROCWR
#define PMAP_GROWKERNEL
#define PMAP_STEAL_MEMORY
#define __HAVE_VM_PAGE_MD
#define __HAVE_PMAP_PV_TRACK 1
struct pmap {
kmutex_t pm_lock;
struct pool *pm_pvpool;
pd_entry_t *pm_l0table; /* L0 table: 512G*512 */
paddr_t pm_l0table_pa;
LIST_HEAD(, vm_page) pm_vmlist; /* for L[0123] tables */
LIST_HEAD(, pv_entry) pm_pvlist; /* all pv of this process */
struct pmap_statistics pm_stats;
unsigned int pm_refcnt;
unsigned int pm_idlepdp;
kcpuset_t *pm_onproc;
kcpuset_t *pm_active;
struct pmap_asid_info pm_pai[PMAP_TLB_MAX];
bool pm_activated;
};
static inline paddr_t
pmap_l0pa(struct pmap *pm)
{
return pm->pm_l0table_pa;
}
/*
* should be kept <=32 bytes sized to reduce memory consumption & cache misses,
* but it doesn't...
*/
struct pv_entry {
struct pv_entry *pv_next;
struct pmap *pv_pmap;
vaddr_t pv_va; /* for embedded entry (pp_pv) also includes flags */
void *pv_ptep; /* pointer for fast pte lookup */
LIST_ENTRY(pv_entry) pv_proc; /* belonging to the process */
};
struct pmap_page {
kmutex_t pp_pvlock;
struct pv_entry pp_pv;
};
/* try to keep vm_page at or under 128 bytes to reduce cache misses */
struct vm_page_md {
struct pmap_page mdpg_pp;
};
/* for page descriptor page only */
#define mdpg_ptep_parent mdpg_pp.pp_pv.pv_ptep
#define VM_MDPAGE_INIT(pg) \
do { \
PMAP_PAGE_INIT(&(pg)->mdpage.mdpg_pp); \
} while (/*CONSTCOND*/ 0)
#define PMAP_PAGE_INIT(pp) \
do { \
mutex_init(&(pp)->pp_pvlock, MUTEX_NODEBUG, IPL_NONE); \
(pp)->pp_pv.pv_next = NULL; \
(pp)->pp_pv.pv_pmap = NULL; \
(pp)->pp_pv.pv_va = 0; \
(pp)->pp_pv.pv_ptep = NULL; \
} while (/*CONSTCOND*/ 0)
/* saved permission bit for referenced/modified emulation */
#define LX_BLKPAG_OS_READ LX_BLKPAG_OS_0
#define LX_BLKPAG_OS_WRITE LX_BLKPAG_OS_1
#define LX_BLKPAG_OS_RWMASK (LX_BLKPAG_OS_WRITE | LX_BLKPAG_OS_READ)
#define PMAP_PTE_OS0 "read"
#define PMAP_PTE_OS1 "write"
#define VTOPHYS_FAILED ((paddr_t)-1L) /* POOL_PADDR_INVALID */
#define POOL_VTOPHYS(va) vtophys((vaddr_t) (va))
#ifndef KASAN
#define PMAP_MAP_POOLPAGE(pa) AARCH64_PA_TO_KVA(pa)
#define PMAP_UNMAP_POOLPAGE(va) AARCH64_KVA_TO_PA(va)
#define PMAP_DIRECT
static __inline int
pmap_direct_process(paddr_t pa, voff_t pgoff, size_t len,
int (*process)(void *, size_t, void *), void *arg)
{
vaddr_t va = AARCH64_PA_TO_KVA(pa);
return process((void *)(va + pgoff), len, arg);
}
#endif
/* l3pte contains always page entries */
static inline uint64_t
pte_value(pt_entry_t pte)
{
return pte;
}
static inline bool
pte_valid_p(pt_entry_t pte)
{
return l3pte_valid(pte);
}
pt_entry_t *kvtopte(vaddr_t);
#define pmap_update(pmap) ((void)0)
#define pmap_copy(dp,sp,d,l,s) ((void)0)
#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
struct pmap *
pmap_efirt(void);
void pmap_activate_efirt(void);
void pmap_deactivate_efirt(void);
void pmap_procwr(struct proc *, vaddr_t, int);
void pmap_icache_sync_range(pmap_t, vaddr_t, vaddr_t);
void pmap_pv_init(void);
void pmap_pv_track(paddr_t, psize_t);
void pmap_pv_untrack(paddr_t, psize_t);
void pmap_pv_protect(paddr_t, vm_prot_t);
#define PMAP_MAPSIZE1 L2_SIZE
/* for ddb */
void pmap_db_pmap_print(struct pmap *, void (*)(const char *, ...) __printflike(1, 2));
void pmap_db_mdpg_print(struct vm_page *, void (*)(const char *, ...) __printflike(1, 2));
#endif /* !PMAP_MI */
#endif /* _KERNEL */
#elif defined(__arm__)
#include <arm/pmap.h>
#endif /* __arm__/__aarch64__ */
#endif /* !_AARCH64_PMAP_ */

View File

@ -0,0 +1,71 @@
/* $NetBSD: proc.h,v 1.8 2020/08/12 13:19:35 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PROC_H_
#define _AARCH64_PROC_H_
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd32.h"
#endif
struct mdlwp {
void *md_onfault;
struct trapframe *md_utf;
uint64_t md_cpacr;
uint32_t md_flags;
volatile uint32_t md_astpending;
uint64_t md_ia_kern[2]; /* APIAKey{Lo,Hi}_EL1 used in the kernel */
uint64_t md_ia_user[2]; /* APIAKey{Lo,Hi}_EL1 used in user-process */
uint64_t md_ib_user[2]; /* APIBKey{Lo,Hi}_EL1 only used in user-proc. */
uint64_t md_da_user[2]; /* APDAKey{Lo,Hi}_EL1 only used in user-proc. */
uint64_t md_db_user[2]; /* APDBKey{Lo,Hi}_EL1 only used in user-proc. */
uint64_t md_ga_user[2]; /* APGAKey{Lo,Hi}_EL1 only used in user-proc. */
};
struct mdproc {
void (*md_syscall)(struct trapframe *);
char md_march32[12]; /* machine arch of executable */
};
#ifdef COMPAT_NETBSD32
#define PROC0_MD_INITIALIZERS .p_md = { .md_march32 = MACHINE32_ARCH },
#endif
#elif defined(__arm__)
#include <arm/proc.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PROC_H_ */

View File

@ -0,0 +1,99 @@
/* $NetBSD: profile.h,v 1.4 2021/02/10 12:31:34 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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.
*/
#ifdef __aarch64__
#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" /* gcc */
#define MCOUNT_ASM_NAME_ALIAS "__mcount" /* llvm */
#define PLTSYM
#define MCOUNT \
__asm(".text"); \
__asm(".align 6"); \
__asm(".type " MCOUNT_ASM_NAME ",@function"); \
__asm(".global " MCOUNT_ASM_NAME); \
__asm(".global " MCOUNT_ASM_NAME_ALIAS); \
__asm(MCOUNT_ASM_NAME ":"); \
__asm(MCOUNT_ASM_NAME_ALIAS ":"); \
/* \
* Preserve registers that are trashed during mcount \
*/ \
__asm("stp x29, x30, [sp, #-80]!"); \
__asm("stp x0, x1, [sp, #16]"); \
__asm("stp x2, x3, [sp, #32]"); \
__asm("stp x4, x5, [sp, #48]"); \
__asm("stp x6, x7, [sp, #64]"); \
/* \
* find the return address for mcount, \
* and the return address for mcount's caller. \
* \
* frompcindex = pc pushed by call into self. \
*/ \
__asm("ldr x0, [x29, #8]"); \
/* \
* selfpc = pc pushed by mcount call \
*/ \
__asm("mov x1, x30"); \
/* \
* Call the real mcount code \
*/ \
__asm("bl " ___STRING(_C_LABEL(mcount))); \
/* \
* Restore registers that were trashed during mcount \
*/ \
__asm("ldp x0, x1, [sp, #16]"); \
__asm("ldp x2, x3, [sp, #32]"); \
__asm("ldp x4, x5, [sp, #48]"); \
__asm("ldp x6, x7, [sp, #64]"); \
__asm("ldp x29, x30, [sp], #80"); \
__asm("ret"); \
__asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
#ifdef _KERNEL
#define MCOUNT_ENTER \
__asm __volatile ("mrs %x0, daif; msr daifset, #3": "=r"(s):: "memory")
#define MCOUNT_EXIT \
__asm __volatile ("msr daif, %x0":: "r"(s): "memory")
#endif /* _KERNEL */
#elif defined(__arm__)
#include <arm/profile.h>
#endif

View File

@ -0,0 +1,145 @@
/* $NetBSD: pte.h,v 1.14 2022/08/19 08:17:32 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PTE_H_
#define _AARCH64_PTE_H_
#ifdef __aarch64__
#ifndef _LOCORE
typedef uint64_t pd_entry_t; /* L0(512G) / L1(1G) / L2(2M) table entry */
#ifndef __BSD_PTENTRY_T__
#define __BSD_PTENTRY_T__
typedef uint64_t pt_entry_t; /* L3(4k) table entry */
#define PRIxPTE PRIx64
#endif /* __BSD_PTENTRY_T__ */
#endif /* _LOCORE */
/*
* translation table, block, and page descriptors
*/
#define LX_TBL_NSTABLE __BIT(63) /* inherited next level */
#define LX_TBL_APTABLE __BITS(62,61) /* inherited next level */
#define LX_TBL_APTABLE_NOEFFECT __SHIFTIN(0,LX_TBL_APTABLE)
#define LX_TBL_APTABLE_EL0_NOACCESS __SHIFTIN(1,LX_TBL_APTABLE)
#define LX_TBL_APTABLE_RO __SHIFTIN(2,LX_TBL_APTABLE)
#define LX_TBL_APTABLE_RO_EL0_NOREAD __SHIFTIN(3,LX_TBL_APTABLE)
#define LX_TBL_UXNTABLE __BIT(60) /* inherited next level */
#define LX_TBL_PXNTABLE __BIT(59) /* inherited next level */
#define LX_BLKPAG_OS __BITS(58, 55)
#define LX_BLKPAG_OS_0 __SHIFTIN(1,LX_BLKPAG_OS)
#define LX_BLKPAG_OS_1 __SHIFTIN(2,LX_BLKPAG_OS)
#define LX_BLKPAG_OS_2 __SHIFTIN(4,LX_BLKPAG_OS)
#define LX_BLKPAG_OS_3 __SHIFTIN(8,LX_BLKPAG_OS)
#define LX_BLKPAG_UXN __BIT(54) /* Unprivileged Execute Never */
#define LX_BLKPAG_PXN __BIT(53) /* Privileged Execute Never */
#define LX_BLKPAG_CONTIG __BIT(52) /* Hint of TLB cache */
#define LX_BLKPAG_DBM __BIT(51) /* Dirty Bit Modifier (V8.1) */
#define LX_BLKPAG_GP __BIT(50) /* Guarded Page (V8.5) */
#define LX_TBL_PA __BITS(47, 12)
#define LX_BLKPAG_OA __BITS(47, 12)
#define LX_BLKPAG_NG __BIT(11) /* Not Global */
#define LX_BLKPAG_AF __BIT(10) /* Access Flag */
#define LX_BLKPAG_SH __BITS(9,8) /* Shareability */
#define LX_BLKPAG_SH_NS __SHIFTIN(0,LX_BLKPAG_SH) /* Non Shareable */
#define LX_BLKPAG_SH_OS __SHIFTIN(2,LX_BLKPAG_SH) /* Outer Shareable */
#define LX_BLKPAG_SH_IS __SHIFTIN(3,LX_BLKPAG_SH) /* Inner Shareable */
#define LX_BLKPAG_AP __BIT(7)
#define LX_BLKPAG_AP_RW __SHIFTIN(0,LX_BLKPAG_AP) /* RW */
#define LX_BLKPAG_AP_RO __SHIFTIN(1,LX_BLKPAG_AP) /* RO */
#define LX_BLKPAG_APUSER __BIT(6)
#define LX_BLKPAG_NS __BIT(5)
#define LX_BLKPAG_ATTR_INDX __BITS(4,2) /* refer MAIR_EL1 attr<n> */
#define LX_BLKPAG_ATTR_INDX_0 __SHIFTIN(0,LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_INDX_1 __SHIFTIN(1,LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_INDX_2 __SHIFTIN(2,LX_BLKPAG_ATTR_INDX)
#define LX_BLKPAG_ATTR_INDX_3 __SHIFTIN(3,LX_BLKPAG_ATTR_INDX)
#define LX_TYPE __BIT(1)
#define LX_TYPE_BLK __SHIFTIN(0, LX_TYPE)
#define LX_TYPE_TBL __SHIFTIN(1, LX_TYPE)
#define L3_TYPE_PAG __SHIFTIN(1, LX_TYPE)
#define LX_VALID __BIT(0)
#define L1_BLK_OA __BITS(47, 30) /* 1GB */
#define L2_BLK_OA __BITS(47, 21) /* 2MB */
#define L3_PAG_OA __BITS(47, 12) /* 4KB */
#define AARCH64_MAX_PA __BIT(48)
/* L0 table, 512GB/entry * 512 */
#define L0_SHIFT 39
#define L0_ADDR_BITS __BITS(47,39)
#define L0_SIZE (1UL << L0_SHIFT)
#define L0_OFFSET (L0_SIZE - 1UL)
#define L0_FRAME (~L0_OFFSET)
/* L0_BLOCK Level 0 doesn't support block translation */
#define L0_TABLE (LX_TYPE_TBL | LX_VALID)
/* L1 table, 1GB/entry * 512 */
#define L1_SHIFT 30
#define L1_ADDR_BITS __BITS(38,30)
#define L1_SIZE (1UL << L1_SHIFT)
#define L1_OFFSET (L1_SIZE - 1UL)
#define L1_FRAME (~L1_OFFSET)
#define L1_BLOCK (LX_TYPE_BLK | LX_VALID)
#define L1_TABLE (LX_TYPE_TBL | LX_VALID)
/* L2 table, 2MB/entry * 512 */
#define L2_SHIFT 21
#define L2_ADDR_BITS __BITS(29,21)
#define L2_SIZE (1UL << L2_SHIFT)
#define L2_OFFSET (L2_SIZE - 1UL)
#define L2_FRAME (~L2_OFFSET)
#define L2_BLOCK (LX_TYPE_BLK | LX_VALID)
#define L2_TABLE (LX_TYPE_TBL | LX_VALID)
#define L2_BLOCK_MASK __BITS(47,21)
/* L3 table, 4KB/entry * 512 */
#define L3_SHIFT 12
#define L3_ADDR_BITS __BITS(20,12)
#define L3_SIZE (1UL << L3_SHIFT)
#define L3_OFFSET (L3_SIZE - 1UL)
#define L3_FRAME (~L3_OFFSET)
#define L3_PAGE (L3_TYPE_PAG | LX_VALID)
#define Ln_ENTRIES_SHIFT 9
#define Ln_ENTRIES (1 << Ln_ENTRIES_SHIFT)
#define Ln_TABLE_SIZE (8 << Ln_ENTRIES_SHIFT)
#elif defined(__arm__)
#include <arm/pte.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_PTE_H_ */

View File

@ -0,0 +1,94 @@
/* $NetBSD: ptrace.h,v 1.12 2020/09/07 18:29:48 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_PTRACE_H_
#define _AARCH64_PTRACE_H_
#ifdef __aarch64__
/*
* AARCH64-dependent ptrace definitions.
*/
#define PT_GETREGS (PT_FIRSTMACH + 0)
#define PT_SETREGS (PT_FIRSTMACH + 1)
#define PT_GETFPREGS (PT_FIRSTMACH + 2)
#define PT_SETFPREGS (PT_FIRSTMACH + 3)
#define PT_STEP (PT_FIRSTMACH + 4)
#define PT_SETSTEP (PT_FIRSTMACH + 5)
#define PT_CLEARSTEP (PT_FIRSTMACH + 6)
#define PT_MACHDEP_STRINGS \
"PT_GETREGS", \
"PT_SETREGS", \
"PT_GETFPREGS", \
"PT_SETFPREGS", \
"PT_STEP", \
"PT_SETSTEP", \
"PT_CLEARSTEP",
#include <machine/reg.h>
#define PTRACE_REG_PC(r) (r)->r_pc
#define PTRACE_REG_FP(r) (r)->r_reg[29]
#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v)
#define PTRACE_REG_SP(r) (r)->r_sp
#define PTRACE_REG_INTRV(r) (r)->r_reg[0]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xa0, 0x01, 0x20, 0xd4 })
#define PTRACE_BREAKPOINT_ASM __asm __volatile("brk #13" ::: "memory")
#define PTRACE_BREAKPOINT_SIZE 4
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd32.h"
#endif
#ifdef COMPAT_NETBSD32
#include <machine/netbsd32_machdep.h>
#define process_read_regs32 netbsd32_process_read_regs
#define process_read_fpregs32 netbsd32_process_read_fpregs
#define process_write_regs32 netbsd32_process_write_regs
#define process_write_fpregs32 netbsd32_process_write_fpregs
#define process_reg32 struct reg32
#define process_fpreg32 struct fpreg32
#define PTRACE_TRANSLATE_REQUEST32(x) netbsd32_ptrace_translate_request(x)
#endif /* COMPAT_NETBSD32 */
#elif defined(__arm__)
#include <arm/ptrace.h>
#endif
#endif /* _AARCH64_PTRACE_H_ */

View File

@ -0,0 +1,64 @@
/* $NetBSD: reg.h,v 1.3 2018/07/17 16:21:43 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_REG_H_
#define _AARCH64_REG_H_
#ifdef __aarch64__
struct reg {
uint64_t r_reg[31];
uint64_t r_sp;
uint64_t r_pc; /* aka elr */
uint64_t r_spsr;
uint64_t r_tpidr;
};
union fpelem {
uint64_t u64[2];
#ifdef __SIZEOF_INT128__
__uint128_t u128[1];
#endif
};
struct fpreg {
union fpelem fp_reg[32];
uint32_t fpcr;
uint32_t fpsr;
} __aligned(16);
#elif defined(__arm__)
#include <arm/reg.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_REG_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: rwlock.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/rwlock.h>

View File

@ -0,0 +1,71 @@
/* $NetBSD: setjmp.h,v 1.2 2020/05/10 14:05:59 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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.
*/
#ifdef __aarch64__
#define _JB_MAGIC_AARCH64__SETJMP 0x4545524348363400
#define _JB_MAGIC_AARCH64_SETJMP 0x4545524348363401
/* magic + 13 reg + 8 simd + 4 sigmask + 6 slop */
#define _JBLEN (32 * sizeof(_BSD_JBSLOT_T_)/sizeof(long))
#define _JB_MAGIC 0
#define _JB_SP 1
#define _JB_X19 2
#define _JB_X20 3
#define _JB_X21 4
#define _JB_X22 5
#define _JB_X23 6
#define _JB_X24 7
#define _JB_X25 8
#define _JB_X26 9
#define _JB_X27 10
#define _JB_X28 11
#define _JB_X29 12
#define _JB_X30 13
#define _JB_D8 16
#define _JB_D9 17
#define _JB_D10 18
#define _JB_D11 19
#define _JB_D12 20
#define _JB_D13 21
#define _JB_D14 22
#define _JB_D15 23
#define _JB_SIGMASK 24
#ifndef _BSD_JBSLOT_T_
#define _BSD_JBSLOT_T_ long long
#endif
#elif defined(__arm__)
#include <arm/setjmp.h>
#endif

View File

@ -0,0 +1,21 @@
/* $NetBSD: signal.h,v 1.4 2021/11/05 15:18:18 thorpej Exp $ */
#ifndef _AARCH64_SIGNAL_H_
#define _AARCH64_SIGNAL_H_
#include <arm/signal.h>
#ifdef _KERNEL
/*
* Normally, to support COMPAT_NETBSD32 we need to define
* __HAVE_STRUCT_SIGCONTEXT in order to support the old
* "sigcontext" style of handlers for 32-bit binaries.
* However, we only support 32-bit EABI binaries on AArch64,
* and by happy accident (due to a libc bug introduced in
* 2006), 32-bit NetBSD EABI binaries never used "sigcontext"
* style handlers. So, we don't need to carry any of this
* baggage forward.
*/
#endif /* _KERNEL */
#endif /* ! _AARCH64_SIGNAL_H_ */

View File

@ -0,0 +1,67 @@
/* $NetBSD: sljit_machdep.h,v 1.3.18.2 2024/05/11 14:08:32 martin Exp $ */
/*-
* Copyright (c) 2014 Alexander Nasonov.
* 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 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 _AARCH64_SLJITARCH_H
#define _AARCH64_SLJITARCH_H
#ifndef __aarch64__ /* compat32 */
#include <arm/sljit_machdep.h>
#else /* __aarch64__ */
#include <sys/cdefs.h>
#ifdef _KERNEL
#include <machine/types.h>
#include <arm/cpufunc.h>
#else
#include <stddef.h>
#include <stdint.h>
#include <aarch64/sysarch.h>
#endif
#define SLJIT_CONFIG_ARM_64 1
#ifdef _HARDKERNEL
/*
* XXX Currently sys/rump/include/machine/cpu.h doesn't have
* ci_cpufuncs for cpu_icache_sync_range, so we do this only for
* non-rump kernels for now.
*/
#define SLJIT_CACHE_FLUSH(from, to) \
cpu_icache_sync_range((vaddr_t)(from), (vsize_t)((to) - (from)))
#else
#define SLJIT_CACHE_FLUSH(from, to) \
(void)__builtin___clear_cache((char *)(from), (char *)(to))
#endif
#endif /* __aarch64__ (vs compat32) */
#endif /* _AARCH64_SLJITARCH_H */

View File

@ -0,0 +1,3 @@
/* $NetBSD: sysarch.h,v 1.2 2018/04/01 04:35:03 ryo Exp $ */
#include <arm/sysarch.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: trap.h,v 1.3 2020/05/10 11:04:09 skrll Exp $ */
/* This file is intentionally empty */

View File

@ -0,0 +1,135 @@
/* $NetBSD: types.h,v 1.21 2022/11/03 09:04:56 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_TYPES_H_
#define _AARCH64_TYPES_H_
#ifdef __aarch64__
#ifdef _KERNEL_OPT
#include "opt_pmap.h"
#endif
#include <sys/cdefs.h>
#include <sys/featuretest.h>
#include <arm/int_types.h>
#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || \
defined(_STANDALONE)
typedef unsigned long vm_offset_t; /* deprecated */
typedef unsigned long vm_size_t; /* deprecated */
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"
typedef __uint64_t register_t;
typedef __uint32_t register32_t;
#define PRIxREGISTER PRIx64
#define PRIxREGISTER32 PRIx32
typedef unsigned int tlb_asid_t;
#if defined(_KERNEL)
#define LBL_X19 0
#define LBL_X20 1
#define LBL_X21 2
#define LBL_X22 3
#define LBL_X23 4
#define LBL_X24 5
#define LBL_X25 6
#define LBL_X26 7
#define LBL_X27 8
#define LBL_X28 9
#define LBL_X29 10
#define LBL_LR 11
#define LBL_SP 12
#define LBL_MAX 13
typedef struct label_t { /* Used by setjmp & longjmp */
register_t lb_reg[LBL_MAX]; /* x19 .. x30, sp */
} label_t;
#endif
#endif
/*
* This should have always been an 8-bit type.
*/
typedef unsigned char __cpu_simple_lock_nv_t;
typedef __uint64_t __register_t;
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
#define __HAVE_ATOMIC64_OPS
#define __HAVE_BUS_SPACE_8
#define __HAVE_COMMON___TLS_GET_ADDR
#define __HAVE_CPU_COUNTER
#define __HAVE_CPU_DATA_FIRST
#define __HAVE_FAST_SOFTINTS
#define __HAVE_MINIMAL_EMUL
#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
#define __HAVE_MM_MD_KERNACC
#define __HAVE_NEW_STYLE_BUS_H
#define __HAVE_OLD_DISKLABEL /* compatibility */
#define __HAVE_SYSCALL_INTERN
#define __HAVE_TLS_VARIANT_I
#define __HAVE___LWP_GETPRIVATE_FAST
#define __HAVE_UCAS_FULL
#if defined(_KERNEL) || defined(_KMEMUSER)
#define PCU_FPU 0
#define PCU_UNIT_COUNT 1
#endif
#if defined(_KERNEL)
#define __HAVE_RAS
#endif
#if defined(PMAP_MI)
/* XXX temporary */
#define __HAVE_UNLOCKED_PMAP
#endif
#elif defined(__arm__)
#include <arm/types.h>
#endif
#endif /* _AARCH64_TYPES_H_ */

View File

@ -0,0 +1,194 @@
/* $NetBSD: vmparam.h,v 1.19.4.1 2024/07/03 19:13:20 martin Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 _AARCH64_VMPARAM_H_
#define _AARCH64_VMPARAM_H_
#ifdef __aarch64__
#define __USE_TOPDOWN_VM
/*
* Default pager_map of 16MB is small and we have plenty of VA to burn.
*/
#define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024)
/*
* Defaults for Unified Buffer Cache parameters.
*/
#ifndef UBC_WINSHIFT
#define UBC_WINSHIFT 16 /* 64kB */
#endif
#ifndef UBC_NWINS
#define UBC_NWINS 4096 /* 256MB */
#endif
/*
* AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB. Each page table can
* even have its own page size.
*/
#ifdef AARCH64_PAGE_SHIFT
#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
#error AARCH64_PAGE_SHIFT contains an unsupported value.
#endif
#define PAGE_SHIFT AARCH64_PAGE_SHIFT
#else
#define PAGE_SHIFT 12
#endif
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SIZE - 1)
#if PAGE_SHIFT <= 14
#define USPACE 32768
#else
#define USPACE 65536
#endif
#define UPAGES (USPACE >> PAGE_SHIFT)
/*
* USRSTACK is the top (end) of the user stack. The user VA space is a
* 48-bit address space starting at 0. Place the stack at its top end.
*/
#define USRSTACK VM_MAXUSER_ADDRESS
#ifndef MAXTSIZ
#define MAXTSIZ (1L << 30) /* max text size (1GB) */
#endif
#ifndef MAXDSIZ
#define MAXDSIZ (1L << 36) /* max data size (64GB) */
#endif
#ifndef MAXSSIZ
#define MAXSSIZ (1L << 26) /* max stack size (64MB) */
#endif
#ifndef DFLDSIZ
#define DFLDSIZ (1L << 32) /* default data size (4GB) */
#endif
#ifndef DFLSSIZ
#define DFLSSIZ (1L << 23) /* default stack size (8MB) */
#endif
#define USRSTACK32 VM_MAXUSER_ADDRESS32
#ifndef MAXDSIZ32
#define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */
#endif
#ifndef MAXSSIZ32
#define MAXSSIZ32 (64*1024*1024) /* max stack size */
#endif
#ifndef DFLDSIZ32
#define DFLDSIZ32 (1L << 27) /* 32bit default data size (128MB) */
#endif
#ifndef DFLSSIZ32
#define DFLSSIZ32 (1L << 21) /* 32bit default stack size (2MB) */
#endif
#define VM_MIN_ADDRESS ((vaddr_t) 0x0)
#define VM_MAXUSER_ADDRESS ((vaddr_t) (1L << 48) - PAGE_SIZE)
#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
#define VM_MAXUSER_ADDRESS32 ((vaddr_t) 0xfffff000)
/*
* kernel virtual space layout:
* 0xffff_0000_0000_0000 - 64T direct mapping
* 0xffff_4000_0000_0000 - 32T (KASAN SHADOW MAP)
* 0xffff_6000_0000_0000 - 32T (not used)
* 0xffff_8000_0000_0000 - 1G (EFI_RUNTIME - legacy)
* 0xffff_8000_4000_0000 - 64T (not used)
* 0xffff_c000_0000_0000 - 64T KERNEL VM Space (including text/data/bss)
* (0xffff_c000_4000_0000 -1GB) KERNEL VM start of KVM
* 0xffff_ffff_f000_0000 - 254M KERNEL_IO for pmap_devmap
* 0xffff_ffff_ffe0_0000 - 2M RESERVED
*/
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 0xffffc00000000000L)
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t) 0xffffffffffe00000L)
/*
* Reserved space for EFI runtime services (legacy)
*/
#define EFI_RUNTIME_VA 0xffff800000000000L
#define EFI_RUNTIME_SIZE 0x0000000040000000L
/*
* last 254MB of kernel vm area (0xfffffffff0000000-0xffffffffffe00000)
* may be used for devmap. see aarch64/pmap.c:pmap_devmap_*
*/
#define VM_KERNEL_IO_ADDRESS 0xfffffffff0000000L
#define VM_KERNEL_IO_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_ADDRESS)
#define VM_KERNEL_VM_BASE (0xffffc00040000000L)
#define VM_KERNEL_VM_SIZE (VM_KERNEL_IO_ADDRESS - VM_KERNEL_VM_BASE)
/* virtual sizes (bytes) for various kernel submaps */
#define USRIOSIZE (PAGE_SIZE / 8)
#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \
trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size)
#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \
round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32)
/*
* Since we have the address space, we map all of physical memory (RAM)
* using block page table entries.
*/
#define AARCH64_DIRECTMAP_MASK ((vaddr_t) 0xffff000000000000L)
#define AARCH64_DIRECTMAP_SIZE (1UL << 46) /* 64TB */
#define AARCH64_DIRECTMAP_START AARCH64_DIRECTMAP_MASK
#define AARCH64_DIRECTMAP_END (AARCH64_DIRECTMAP_START + AARCH64_DIRECTMAP_SIZE)
#define AARCH64_KVA_P(va) (((vaddr_t) (va) & AARCH64_DIRECTMAP_MASK) != 0)
#define AARCH64_PA_TO_KVA(pa) ((vaddr_t) ((pa) | AARCH64_DIRECTMAP_START))
#define AARCH64_KVA_TO_PA(va) ((paddr_t) ((va) & ~AARCH64_DIRECTMAP_MASK))
/* */
#define VM_PHYSSEG_MAX 256 /* XXX */
#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
#define VM_NFREELIST 1
#define VM_FREELIST_DEFAULT 0
#elif defined(__arm__)
#include <arm/vmparam.h>
#endif /* __aarch64__/__arm__ */
#endif /* _AARCH64_VMPARAM_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: wchar_limits.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
#include <arm/wchar_limits.h>

View File

@ -0,0 +1,63 @@
/* $NetBSD: float.h,v 1.8 2014/01/29 01:10:36 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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_FLOAT_H_
#define _ARM_FLOAT_H_
#include <sys/cdefs.h>
#ifdef __ARM_PCS_AAPCS64
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_MIN __LDBL_MIN__
#define LDBL_MAX __LDBL_MAX__
#endif /* __ARM_PCS_AAPCS64 */
#include <sys/float_ieee754.h>
#if defined(__ARM_PCS_AAPCS64) \
&& ((!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 __DECIMAL_DIG__
#endif /* __ARM_PCS_AAPCS64 && ... */
#endif /* !_ARM_FLOAT_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: ansi.h,v 1.18 2019/05/07 03:49:26 kamil Exp $ */
#include <sys/common_ansi.h>

View File

@ -0,0 +1,59 @@
/* $NetBSD: aout_machdep.h,v 1.8 2018/03/17 04:16:09 ryo Exp $ */
/*
* Copyright (c) 1994-1996 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 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 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_AOUT_MACHDEP_H_
#define _ARM_AOUT_MACHDEP_H_
#define AOUT_LDPGSZ 4096
/* Relocation format. */
struct relocation_info_arm6 {
int r_address; /* offset in text or data segment */
unsigned r_symbolnum:24;/* ordinal number of add symbol */
unsigned r_pcrel:1; /* 1 if value should be pc-relative */
unsigned r_length:2; /* 0=byte, 1=word, 2=long, 3=24bits shifted by 2 */
unsigned r_extern:1; /* 1 if need to add symbol to value */
unsigned r_neg:1; /* 1 if addend is negative */
unsigned r_baserel:1; /* 1 if linkage table relative */
unsigned r_jmptable:1; /* 1 if relocation to jump table */
unsigned r_relative:1; /* 1 if load address relative */
};
#define relocation_info relocation_info_arm6
/* No special executable format */
#define cpu_exec_aout_makecmds(a, b) ENOEXEC
#endif /* _ARM_AOUT_MACHDEP_H_ */

View File

@ -0,0 +1,305 @@
/* $NetBSD: asm.h,v 1.34 2020/04/23 23:22:41 jakllsch Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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.
*/
/*
* 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 _ARM_ASM_H_
#define _ARM_ASM_H_
#include <arm/cdefs.h>
#if defined(_KERNEL_OPT)
#include "opt_cpuoptions.h"
#endif
#ifdef __thumb__
#define THUMB_INSN(n) n
#else
#define THUMB_INSN(n)
#endif
#define __BIT(n) (1 << (n))
#define __BITS(hi,lo) ((~((~0)<<((hi)+1)))&((~0)<<(lo)))
#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))
#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))
#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 2
#endif
#ifndef _TEXT_SECTION
#define _TEXT_SECTION .text
#endif
#ifdef __arm__
.syntax unified
/*
* 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
#define _THUMB_ENTRY(x) \
_TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \
.thumb_func; .code 16; x:
#define _ARM_ENTRY(x) \
_TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; \
.code 32; x:
#ifdef __thumb__
#define _ENTRY(x) _THUMB_ENTRY(x)
#else
#define _ENTRY(x) _ARM_ENTRY(x)
#endif
#define _END(x) .size x,.-x
#ifdef GPROF
# define _PROF_PROLOGUE \
mov ip, lr; bl __mcount
#else
# define _PROF_PROLOGUE
#endif
#endif
#ifdef __aarch64__
#define _ASM_TYPE_FUNCTION @function
#define _ASM_TYPE_OBJECT @object
#define _ENTRY(x) \
_TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
#define _END(x) .size x,.-x
#ifdef GPROF
# define _PROF_PROLOGUE \
stp x29, x30, [sp, #-16]!; \
mov fp, sp; \
bl __mcount; \
ldp x29, x30, [sp], #16;
#else
# define _PROF_PROLOGUE
#endif
#ifdef __PIC__
#define GOTREF(x) :got:x
#define GOTLO12(x) :got_lo12:x
#else
#define GOTREF(x) x
#define GOTLO12(x) :lo12:x
#endif
#endif
#ifdef ARMV85_BTI
#define _BTI_PROLOGUE \
.byte 0x5F, 0x24, 0x03, 0xD5 /* the "bti c" instruction */
#else
#define _BTI_PROLOGUE /* nothing */
#endif
#define ENTRY(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE ; _PROF_PROLOGUE
#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)); _BTI_PROLOGUE
#define ENTRY_NBTI(y) _ENTRY(_C_LABEL(y))
#define END(y) _END(_C_LABEL(y))
#define ARM_ENTRY(y) _ARM_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
#define ARM_ENTRY_NP(y) _ARM_ENTRY(_C_LABEL(y))
#define THUMB_ENTRY(y) _THUMB_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
#define THUMB_ENTRY_NP(y) _THUMB_ENTRY(_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 ARM_ASENTRY(y) _ARM_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
#define ARM_ASENTRY_NP(y) _ARM_ENTRY(_ASM_LABEL(y))
#define THUMB_ASENTRY(y) _THUMB_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
#define THUMB_ASENTRY_NP(y) _THUMB_ENTRY(_ASM_LABEL(y))
#define ASMSTR .asciz
#ifdef __PIC__
#define REL_SYM(a, b) ((a) - (b))
#define PLT_SYM(x) x
#define GOT_SYM(x) PIC_SYM(x, GOT)
#define GOT_GET(x,got,sym) \
ldr x, sym; \
ldr x, [x, got]
#define GOT_INIT(got,gotsym,pclabel) \
ldr got, gotsym; \
pclabel: add got, got, pc
#ifdef __thumb__
#define GOT_INITSYM(gotsym,pclabel) \
.align 0; \
gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+4)
#else
#define GOT_INITSYM(gotsym,pclabel) \
.align 0; \
gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+8)
#endif
#ifdef __STDC__
#define PIC_SYM(x,y) x ## ( ## y ## )
#else
#define PIC_SYM(x,y) x/**/(/**/y/**/)
#endif
#else
#define REL_SYM(a, b) (a)
#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","MS",%progbits,1; \
.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(__aarch64__)
# define RET ret
#elif defined (_ARM_ARCH_4T)
# define RET bx lr
# define RETr(r) bx r
# if defined(__thumb__)
# if defined(_ARM_ARCH_7)
# define RETc(c) it c; __CONCAT(bx,c) lr
# endif
# else
# define RETc(c) __CONCAT(bx,c) lr
# endif
#else
# define RET mov pc, lr
# define RETr(r) mov pc, r
# define RETc(c) __CONCAT(mov,c) pc, lr
#endif
#ifdef _ARM_ARCH_7
#define KMODTRAMPOLINE(n) \
_ENTRY(__wrap_ ## n) \
movw ip, #:lower16:n; \
movt ip, #:upper16:n; \
bx ip
#elif defined(_ARM_ARCH_4T)
#define KMODTRAMPOLINE(n) \
_ENTRY(__wrap_ ## n) \
ldr ip, [pc]; \
bx ip; \
.word n
#else
#define KMODTRAMPOLINE(n) \
_ENTRY(__wrap_ ## n) \
ldr pc, [pc, #-4]; \
.word n
#endif
#endif /* !_ARM_ASM_H_ */

View File

@ -0,0 +1,15 @@
/* $NetBSD: bswap.h,v 1.6 2014/01/29 01:36:43 matt Exp $ */
#ifndef _ARM_BSWAP_H_
#define _ARM_BSWAP_H_
#ifdef __aarch64__
#include <aarch64/byte_swap.h>
#else
#include <arm/byte_swap.h>
#endif
#define __BSWAP_RENAME
#include <sys/bswap.h>
#endif /* !_ARM_BSWAP_H_ */

View File

@ -0,0 +1,121 @@
/* $NetBSD: byte_swap.h,v 1.16 2017/01/17 11:08:50 rin 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 _LOCORE
#if defined(_ARM_ARCH_6) || defined(_ARM_ARCH_7)
#define BSWAP16(_src, _dst, _tmp) \
rev16 _dst, _src
#define BSWAP32(_src, _dst, _tmp) \
rev _dst, _src
#else
#define BSWAP16(_src, _dst, _tmp) \
mov _tmp, _src, ror #8 ;\
orr _tmp, _tmp, _tmp, lsr #16 ;\
bic _dst, _tmp, _tmp, lsl #16
#define BSWAP32(_src, _dst, _tmp) \
eor _tmp, _src, _src, ror #16 ;\
bic _tmp, _tmp, #0x00FF0000 ;\
mov _dst, _src, ror #8 ;\
eor _dst, _dst, _tmp, lsr #8
#endif
#else
#ifdef __GNUC__
#include <sys/types.h>
__BEGIN_DECLS
#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
static __inline uint32_t
__byte_swap_u32_variable(uint32_t v)
{
uint32_t t1;
#ifdef _ARM_ARCH_6
if (!__builtin_constant_p(v)) {
__asm("rev\t%0, %1" : "=r" (v) : "0" (v));
return v;
}
#endif
t1 = v ^ ((v << 16) | (v >> 16));
t1 &= 0xff00ffffU;
v = (v >> 8) | (v << 24);
v ^= (t1 >> 8);
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
if (!__builtin_constant_p(v)) {
uint32_t v32 = v;
__asm("rev16\t%0, %1" : "=r" (v32) : "0" (v32));
return (uint16_t)v32;
}
#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */
if (!__builtin_constant_p(v)) {
uint32_t v0 = v;
__asm volatile(
"mov %0, %1, ror #8\n"
"orr %0, %0, %0, lsr #16\n"
"bic %0, %0, %0, lsl #16"
: "=&r" (v0)
: "0" (v0));
return (uint16_t)v0;
}
#endif
v &= 0xffff;
v = (uint16_t)((v >> 8) | (v << 8));
return v;
}
__END_DECLS
#endif
#endif /* _LOCORE */
#endif /* _ARM_BYTE_SWAP_H_ */

View File

@ -0,0 +1,70 @@
/* $NetBSD: cdefs.h,v 1.19 2020/12/01 02:43:14 rin Exp $ */
#ifndef _ARM_CDEFS_H_
#define _ARM_CDEFS_H_
#ifndef __lint__
#if (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || __GNUC__ < 4
#error GCC 4.1 or compatible required.
#endif
#endif
#if defined (__ARM_ARCH_8A__) || defined (__ARM_ARCH_8A) || \
__ARM_ARCH == 8
/* __ARM_ARCH_8A__ is a typo */
#define _ARM_ARCH_8
#endif
#if defined (_ARM_ARCH_8) || defined (__ARM_ARCH_7__) || \
defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) || \
defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
/* 7R, 7M, 7EM are for non MMU arms */
#define _ARM_ARCH_7
#endif
#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6T2__)
#define _ARM_ARCH_T2 /* Thumb2 */
#endif
#if defined (_ARM_ARCH_T2) || defined (__ARM_ARCH_6__) || \
defined (__ARM_ARCH_6J__) || \
defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6KZ__) || \
defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__) || \
defined (__ARM_ARCH_6ZM__)
#define _ARM_ARCH_6
#endif
#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5T__) || \
defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__)
#define _ARM_ARCH_5T
#endif
#if defined (_ARM_ARCH_6) || defined (_ARM_ARCH_5T) || defined (__ARM_ARCH_5__)
#define _ARM_ARCH_5
#endif
#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__)
#define _ARM_ARCH_4T
#endif
#if defined (_ARM_ARCH_T2) || \
(!defined (__thumb__) && \
(defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5TE__) || \
defined (__ARM_ARCH_5TEJ__)))
#define _ARM_ARCH_DWORD_OK
#endif
#if defined (__ARMEB__) && defined (_ARM_ARCH_6)
#define _ARM_ARCH_BE8
#endif
#if defined(__ARM_PCS_AAPCS64)
#define __ALIGNBYTES (sizeof(__int128_t) - 1)
#elif defined(__ARM_EABI__)
#define __ALIGNBYTES (sizeof(long long) - 1)
#else
#define __ALIGNBYTES (sizeof(int) - 1)
#endif
#endif /* !_ARM_CDEFS_H_ */

Some files were not shown because too many files have changed in this diff Show More