ARM64: Add initial kernel headers
Signed-off-by: Augustin Cavalier <[email protected]> aarch64 -> arm64 and coding style fixes by me.
This commit is contained in:
committed by
Augustin Cavalier
parent
0689d8ddb8
commit
3a72e3ebee
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_ATOMIC_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_ATOMIC_H_
|
||||
|
||||
|
||||
static inline void memory_read_barrier_inline(void)
|
||||
{
|
||||
__asm__ __volatile__("dmb ishld");
|
||||
}
|
||||
|
||||
|
||||
static inline void memory_write_barrier_inline(void)
|
||||
{
|
||||
__asm__ __volatile__("dsb ishst");
|
||||
}
|
||||
|
||||
|
||||
static inline void memory_full_barrier_inline(void)
|
||||
{
|
||||
__asm__ __volatile__("dsb sy");
|
||||
}
|
||||
|
||||
|
||||
#define memory_read_barrier memory_read_barrier_inline
|
||||
#define memory_write_barrier memory_write_barrier_inline
|
||||
#define memory_full_barrier memory_full_barrier_inline
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_ATOMIC_H_ */
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_CPU_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_CPU_H_
|
||||
|
||||
|
||||
#define CPU_MAX_CACHE_LEVEL 8
|
||||
#define CACHE_LINE_SIZE 64
|
||||
|
||||
#define set_ac()
|
||||
#define clear_ac()
|
||||
|
||||
#include <kernel/arch/arm64/armreg.h>
|
||||
|
||||
#ifndef _ASSEMBLER
|
||||
|
||||
#include <arch/arm64/arch_thread_types.h>
|
||||
#include <kernel.h>
|
||||
|
||||
#define arm64_sev() __asm__ __volatile__("sev" : : : "memory")
|
||||
#define arm64_wfe() __asm__ __volatile__("wfe" : : : "memory")
|
||||
#define arm64_dsb() __asm__ __volatile__("dsb" : : : "memory")
|
||||
#define arm64_dmb() __asm__ __volatile__("dmb" : : : "memory")
|
||||
#define arm64_isb() __asm__ __volatile__("isb" : : : "memory")
|
||||
#define arm64_nop() __asm__ __volatile__("nop" : : : "memory")
|
||||
#define arm64_yield() __asm__ __volatile__("yield" : : : "memory")
|
||||
|
||||
/* Extract CPU affinity levels 0-3 */
|
||||
#define CPU_AFF0(mpidr) (u_int)(((mpidr) >> 0) & 0xff)
|
||||
#define CPU_AFF1(mpidr) (u_int)(((mpidr) >> 8) & 0xff)
|
||||
#define CPU_AFF2(mpidr) (u_int)(((mpidr) >> 16) & 0xff)
|
||||
#define CPU_AFF3(mpidr) (u_int)(((mpidr) >> 32) & 0xff)
|
||||
#define CPU_AFF0_MASK 0xffUL
|
||||
#define CPU_AFF1_MASK 0xff00UL
|
||||
#define CPU_AFF2_MASK 0xff0000UL
|
||||
#define CPU_AFF3_MASK 0xff00000000UL
|
||||
#define CPU_AFF_MASK (CPU_AFF0_MASK | CPU_AFF1_MASK | \
|
||||
CPU_AFF2_MASK| CPU_AFF3_MASK) /* Mask affinity fields in MPIDR_EL1 */
|
||||
|
||||
|
||||
#define CPU_IMPL_ARM 0x41
|
||||
#define CPU_IMPL_BROADCOM 0x42
|
||||
#define CPU_IMPL_CAVIUM 0x43
|
||||
#define CPU_IMPL_DEC 0x44
|
||||
#define CPU_IMPL_INFINEON 0x49
|
||||
#define CPU_IMPL_FREESCALE 0x4D
|
||||
#define CPU_IMPL_NVIDIA 0x4E
|
||||
#define CPU_IMPL_APM 0x50
|
||||
#define CPU_IMPL_QUALCOMM 0x51
|
||||
#define CPU_IMPL_MARVELL 0x56
|
||||
#define CPU_IMPL_INTEL 0x69
|
||||
|
||||
#define CPU_PART_THUNDER 0x0A1
|
||||
#define CPU_PART_FOUNDATION 0xD00
|
||||
#define CPU_PART_CORTEX_A35 0xD04
|
||||
#define CPU_PART_CORTEX_A53 0xD03
|
||||
#define CPU_PART_CORTEX_A55 0xD05
|
||||
#define CPU_PART_CORTEX_A57 0xD07
|
||||
#define CPU_PART_CORTEX_A72 0xD08
|
||||
#define CPU_PART_CORTEX_A73 0xD09
|
||||
#define CPU_PART_CORTEX_A75 0xD0A
|
||||
|
||||
#define CPU_REV_THUNDER_1_0 0x00
|
||||
#define CPU_REV_THUNDER_1_1 0x01
|
||||
|
||||
#define CPU_IMPL(midr) (((midr) >> 24) & 0xff)
|
||||
#define CPU_PART(midr) (((midr) >> 4) & 0xfff)
|
||||
#define CPU_VAR(midr) (((midr) >> 20) & 0xf)
|
||||
#define CPU_REV(midr) (((midr) >> 0) & 0xf)
|
||||
|
||||
#define CPU_IMPL_TO_MIDR(val) (((val) & 0xff) << 24)
|
||||
#define CPU_PART_TO_MIDR(val) (((val) & 0xfff) << 4)
|
||||
#define CPU_VAR_TO_MIDR(val) (((val) & 0xf) << 20)
|
||||
#define CPU_REV_TO_MIDR(val) (((val) & 0xf) << 0)
|
||||
|
||||
#define CPU_IMPL_MASK (0xff << 24)
|
||||
#define CPU_PART_MASK (0xfff << 4)
|
||||
#define CPU_VAR_MASK (0xf << 20)
|
||||
#define CPU_REV_MASK (0xf << 0)
|
||||
|
||||
#define CPU_ID_RAW(impl, part, var, rev) \
|
||||
(CPU_IMPL_TO_MIDR((impl)) | \
|
||||
CPU_PART_TO_MIDR((part)) | CPU_VAR_TO_MIDR((var)) | \
|
||||
CPU_REV_TO_MIDR((rev)))
|
||||
|
||||
#define CPU_MATCH(mask, impl, part, var, rev) \
|
||||
(((mask) & PCPU_GET(midr)) == \
|
||||
((mask) & CPU_ID_RAW((impl), (part), (var), (rev))))
|
||||
|
||||
#define CPU_MATCH_RAW(mask, devid) \
|
||||
(((mask) & PCPU_GET(midr)) == ((mask) & (devid)))
|
||||
|
||||
static inline uint64 arm64_get_cyclecount(void)
|
||||
{
|
||||
return READ_SPECIALREG(cntvct_el0);
|
||||
}
|
||||
|
||||
#define ADDRESS_TRANSLATE_FUNC(stage) \
|
||||
static inline uint64 \
|
||||
arm64_address_translate_ ##stage (uint64 addr) \
|
||||
{ \
|
||||
uint64 ret; \
|
||||
\
|
||||
__asm __volatile( \
|
||||
"at " __STRING(stage) ", %1 \n" \
|
||||
"mrs %0, par_el1" : "=r"(ret) : "r"(addr)); \
|
||||
\
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
ADDRESS_TRANSLATE_FUNC(s1e0r)
|
||||
ADDRESS_TRANSLATE_FUNC(s1e0w)
|
||||
ADDRESS_TRANSLATE_FUNC(s1e1r)
|
||||
ADDRESS_TRANSLATE_FUNC(s1e1w)
|
||||
|
||||
/* raw exception frames */
|
||||
struct iframe {
|
||||
uint64 sp;
|
||||
uint64 lr;
|
||||
uint64 elr;
|
||||
uint32 spsr;
|
||||
uint32 esr;
|
||||
uint64 x[30];
|
||||
};
|
||||
|
||||
namespace BKernel {
|
||||
struct Thread;
|
||||
} // namespace BKernel
|
||||
|
||||
typedef struct arch_cpu_info {
|
||||
uint32 mpidr;
|
||||
BKernel::Thread* last_vfp_user;
|
||||
} arch_cpu_info;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline void arch_cpu_pause(void)
|
||||
{
|
||||
arm64_yield();
|
||||
}
|
||||
|
||||
static inline void arch_cpu_idle(void)
|
||||
{
|
||||
arm64_yield();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_CPU_H_ */
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_DEBUG_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_DEBUG_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
struct arch_debug_registers {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_DEBUG_H_ */
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_INT_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_INT_H_
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
#define NUM_IO_VECTORS 1024
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_INT_H_ */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_KERNEL_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_KERNEL_H_
|
||||
|
||||
|
||||
#include <kernel/arch/cpu.h>
|
||||
|
||||
|
||||
// memory layout
|
||||
#define KERNEL_BASE 0xffff000000000000
|
||||
#define KERNEL_SIZE 0x8000000000
|
||||
#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
|
||||
|
||||
#define USER_BASE 0x1000
|
||||
#define USER_BASE_ANY USER_BASE
|
||||
#define USER_SIZE (0x0001000000000000UL - USER_BASE)
|
||||
#define USER_TOP (0x0001000000000000UL - 1)
|
||||
|
||||
#define KERNEL_USER_DATA_BASE 0x60000000
|
||||
#define USER_STACK_REGION 0x70000000
|
||||
#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1)
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_KERNEL_H_ */
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_KERNEL_ARGS_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_KERNEL_ARGS_H_
|
||||
|
||||
|
||||
#ifndef KERNEL_BOOT_KERNEL_ARGS_H
|
||||
# error This file is included from <boot/kernel_args.h> only
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int nothing_yet;
|
||||
} arch_kernel_args;
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_KERNEL_ARGS_H_ */
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_SYSTEM_INFO_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_SYSTEM_INFO_H_
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_SYSTEM_INFO_H_ */
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_THREAD_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_THREAD_H_
|
||||
|
||||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
static inline Thread * arch_thread_get_current_thread(void)
|
||||
{
|
||||
return (Thread *)READ_SPECIALREG(tpidr_el1);
|
||||
}
|
||||
|
||||
|
||||
static inline void arch_thread_set_current_thread(Thread *t)
|
||||
{
|
||||
WRITE_SPECIALREG(tpidr_el1, t);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_THREAD_H_ */
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_
|
||||
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
|
||||
struct arch_thread {
|
||||
uint64 x[31];
|
||||
uint64 pc;
|
||||
uint64 sp;
|
||||
uint64 tpidr_el0;
|
||||
uint64 tpidrro_el0;
|
||||
int last_vfp_cpu;
|
||||
};
|
||||
|
||||
struct arch_team {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
struct arch_fork_arg {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_ */
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_USER_DEBUGGER_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_USER_DEBUGGER_H_
|
||||
|
||||
|
||||
struct arch_team_debug_info {
|
||||
};
|
||||
|
||||
|
||||
struct arch_thread_debug_info {
|
||||
};
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_USER_DEBUGGER_H_ */
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_VM_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_VM_H_
|
||||
|
||||
|
||||
#define PAGE_SHIFT 12
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_VM_H_ */
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_VM_TRANSLATION_MAP_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_VM_TRANSLATION_MAP_H_
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_VM_TRANSLATION_MAP_H_ */
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2018, Jaroslaw Pelczar <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_ARM64_ARCH_VM_TYPES_H_
|
||||
#define _KERNEL_ARCH_ARM64_ARCH_VM_TYPES_H_
|
||||
|
||||
|
||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_VM_TYPES_H_ */
|
||||
Reference in New Issue
Block a user