hrev52937 adds 1 changeset to branch 'master'
old head: a30d07f80a48b77c1ef4e1dd2b94bfa9320565dd
new head: 05dda88dc1a8446a3b5a965d4ab74bf01776ff8e
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=05dda88dc1a8+%5Ea30d07f80a48
----------------------------------------------------------------------------
05dda88dc1a8: headers/riscv64: Implement basic arch headers
Change-Id: I6bfbacb61eae84ffebc30c2565683348d684d88f
Reviewed-on: https://review.haiku-os.org/c/1063
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
[ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev52937
Commit: 05dda88dc1a8446a3b5a965d4ab74bf01776ff8e
URL: https://git.haiku-os.org/haiku/commit/?id=05dda88dc1a8
Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date: Mon Feb 25 23:02:50 2019 UTC
Committer: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
Commit-Date: Tue Feb 26 14:50:35 2019 UTC
----------------------------------------------------------------------------
14 files changed, 363 insertions(+)
headers/os/arch/riscv64/arch_debugger.h | 15 +++++
headers/os/kernel/debugger.h | 3 +
.../private/kernel/arch/riscv64/arch_atomic.h | 41 ++++++++++++
.../private/kernel/arch/riscv64/arch_config.h | 19 ++++++
headers/private/kernel/arch/riscv64/arch_cpu.h | 11 ++++
headers/private/kernel/arch/riscv64/arch_int.h | 16 +++++
.../private/kernel/arch/riscv64/arch_kernel.h | 46 ++++++++++++++
.../kernel/arch/riscv64/arch_kernel_args.h | 20 ++++++
.../private/kernel/arch/riscv64/arch_thread.h | 46 ++++++++++++++
.../kernel/arch/riscv64/arch_thread_types.h | 40 ++++++++++++
.../kernel/arch/riscv64/arch_user_debugger.h | 17 +++++
headers/private/kernel/arch/riscv64/arch_vm.h | 16 +++++
.../private/kernel/arch/riscv64/arch_vm_types.h | 8 +++
headers/private/system/arch/riscv64/arch_elf.h | 65 ++++++++++++++++++++
----------------------------------------------------------------------------
diff --git a/headers/os/arch/riscv64/arch_debugger.h
b/headers/os/arch/riscv64/arch_debugger.h
new file mode 100644
index 0000000000..f4b8fb07eb
--- /dev/null
+++ b/headers/os/arch/riscv64/arch_debugger.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2009-2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _ARCH_RISCV64_DEBUGGER_H
+#define _ARCH_RISCV64_DEBUGGER_H
+
+
+//#warning RISCV64: fixme
+struct riscv64_debug_cpu_state {
+ uint32 dummy;
+} __attribute__((aligned(8)));
+
+
+#endif // _ARCH_RISCV64_DEBUGGER_H
diff --git a/headers/os/kernel/debugger.h b/headers/os/kernel/debugger.h
index 569a5d13ab..1265519ca1 100644
--- a/headers/os/kernel/debugger.h
+++ b/headers/os/kernel/debugger.h
@@ -18,6 +18,7 @@
#include <arch/m68k/arch_debugger.h>
#include <arch/mipsel/arch_debugger.h>
#include <arch/arm/arch_debugger.h>
+#include <arch/riscv64/arch_debugger.h>
#include <arch/sparc/arch_debugger.h>
@@ -33,6 +34,8 @@
typedef struct mipsel_debug_cpu_state debug_cpu_state;
#elif defined(__arm__)
typedef struct arm_debug_cpu_state debug_cpu_state;
+#elif defined(__RISCV__) || defined(__riscv64__)
+ typedef struct riscv64_debug_cpu_state debug_cpu_state;
#elif defined(__sparc64__)
typedef struct sparc_debug_cpu_state debug_cpu_state;
#else
diff --git a/headers/private/kernel/arch/riscv64/arch_atomic.h
b/headers/private/kernel/arch/riscv64/arch_atomic.h
new file mode 100644
index 0000000000..5ecc1e8749
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_atomic.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014, Paweł Dziepak, pdziepak@xxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * François Revol <revol@xxxxxxx>
+ */
+#ifndef _KERNEL_ARCH_RISCV64_ATOMIC_H
+#define _KERNEL_ARCH_RISCV64_ATOMIC_H
+
+
+static inline void
+memory_read_barrier_inline(void)
+{
+ asm volatile ("nop;" : : : "memory");
+#warning RISCV64: check memory_read_barrier_inline (FNOP ?)
+}
+
+
+static inline void
+memory_write_barrier_inline(void)
+{
+ asm volatile ("nop;" : : : "memory");
+#warning RISCV64: check memory_write_barrier_inline (FNOP ?)
+}
+
+
+static inline void
+memory_full_barrier_inline(void)
+{
+ asm volatile ("nop;" : : : "memory");
+#warning RISCV64: check memory_full_barrier_inline (FNOP ?)
+}
+
+
+#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_RISCV64_ATOMIC_H
diff --git a/headers/private/kernel/arch/riscv64/arch_config.h
b/headers/private/kernel/arch/riscv64/arch_config.h
new file mode 100644
index 0000000000..1be83d9386
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_config.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2009-2019 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _SYSTEM_ARCH_RISCV64_CONFIG_H
+#define _SYSTEM_ARCH_RISCV64_CONFIG_H
+
+#warning IMPLEMENT _SYSTEM_ARCH_RISCV64_CONFIG_H
+
+#define FUNCTION_CALL_PARAMETER_ALIGNMENT_TYPE unsigned int
+
+#define STACK_GROWS_DOWNWARDS
+
+//#define ATOMIC_FUNCS_ARE_SYSCALLS
+#define ATOMIC64_FUNCS_ARE_SYSCALLS
+
+
+#endif /* _SYSTEM_ARCH_RISCV64_CONFIG_H */
+
diff --git a/headers/private/kernel/arch/riscv64/arch_cpu.h
b/headers/private/kernel/arch/riscv64/arch_cpu.h
new file mode 100644
index 0000000000..b6d6fab937
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_cpu.h
@@ -0,0 +1,11 @@
+/*
+** Copyright 2003, Marcus Overhagen. All rights reserved.
+** Distributed under the terms of the MIT license.
+*/
+#ifndef _KERNEL_ARCH_CPU_H
+#define _KERNEL_ARCH_CPU_H
+
+#define CPU_MAX_CACHE_LEVEL 8
+#define ATOMIC_FUNCS_ARE_SYSCALLS 1
+
+#endif
diff --git a/headers/private/kernel/arch/riscv64/arch_int.h
b/headers/private/kernel/arch/riscv64/arch_int.h
new file mode 100644
index 0000000000..537e91564b
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_int.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2005-2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
+ * Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
+ */
+#ifndef _KERNEL_ARCH_RISCV64_INT_H
+#define _KERNEL_ARCH_RISCV64_INT_H
+
+#include <SupportDefs.h>
+
+#define NUM_IO_VECTORS 256
+
+#endif /* _KERNEL_ARCH_RISCV64_INT_H */
diff --git a/headers/private/kernel/arch/riscv64/arch_kernel.h
b/headers/private/kernel/arch/riscv64/arch_kernel.h
new file mode 100644
index 0000000000..fc0c1d0100
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_kernel.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
+ * Distributed under the terms of the NewOS License.
+ */
+#ifndef _KERNEL_ARCH_RISCV64_KERNEL_H
+#define _KERNEL_ARCH_RISCV64_KERNEL_H
+
+#include <arch/cpu.h>
+
+#warning Review arch_kernel.h
+
+// memory layout
+#define KERNEL_LOAD_BASE 0x80000000
+#define KERNEL_LOAD_BASE_64_BIT 0xffffffff80000000ll
+
+
+#if defined(__riscv64__)
+
+// Base of the kernel address space.
+#define KERNEL_BASE 0xffffff0000000000
+#define KERNEL_SIZE 0x10000000000
+#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
+#define KERNEL_LOAD_BASE 0xffffffff80000000
+
+// Kernel physical memory map area.
+#define KERNEL_PMAP_BASE 0xffffff0000000000
+#define KERNEL_PMAP_SIZE 0x8000000000
+
+// Userspace address space layout.
+// There is a 2MB hole just before the end of the bottom half of the address
+// space. This means that if userland passes in a buffer that crosses into the
+// uncanonical address region, it will be caught through a page fault.
+#define USER_BASE 0x100000
+#define USER_BASE_ANY USER_BASE
+#define USER_SIZE (0x800000000000 - (0x200000 + 0x100000))
+#define USER_TOP (USER_BASE + (USER_SIZE - 1))
+
+#define KERNEL_USER_DATA_BASE 0x7f0000000000
+#define USER_STACK_REGION 0x7f0000000000
+#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1)
+
+#else /* ! __riscv64__ */
+ #warning Unknown RISC-V Architecture!
+#endif
+
+#endif /* _KERNEL_ARCH_RISCV64_KERNEL_H */
diff --git a/headers/private/kernel/arch/riscv64/arch_kernel_args.h
b/headers/private/kernel/arch/riscv64/arch_kernel_args.h
new file mode 100644
index 0000000000..ddb9c85b08
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_kernel_args.h
@@ -0,0 +1,20 @@
+/*
+** Copyright 2003, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx. All rights reserved.
+** Distributed under the terms of the MIT License.
+*/
+#ifndef KERNEL_ARCH_RISCV64_KERNEL_ARGS_H
+#define KERNEL_ARCH_RISCV64_KERNEL_ARGS_H
+
+#ifndef KERNEL_BOOT_KERNEL_ARGS_H
+# error This file is included from <boot/kernel_args.h> only
+#endif
+
+// kernel args
+typedef struct {
+ // architecture specific
+ uint64 phys_pgdir;
+ uint64 vir_pgdir;
+ uint64 next_pagetable;
+} arch_kernel_args;
+
+#endif /* KERNEL_ARCH_RISCV64_KERNEL_ARGS_H */
diff --git a/headers/private/kernel/arch/riscv64/arch_thread.h
b/headers/private/kernel/arch/riscv64/arch_thread.h
new file mode 100644
index 0000000000..5da6ac7fa9
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_thread.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2003-2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
+ * Jonas Sundström <jonas@xxxxxxxxxxx>
+ */
+#ifndef _KERNEL_ARCH_RISCV64_THREAD_H
+#define _KERNEL_ARCH_RISCV64_THREAD_H
+
+#include <arch/cpu.h>
+
+#warning IMPLEMENT arch_thread.h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void riscv64_push_iframe(struct iframe_stack* stack, struct iframe* frame);
+void riscv64_pop_iframe(struct iframe_stack* stack);
+struct iframe* riscv64_get_user_iframe(void);
+
+
+static inline Thread*
+arch_thread_get_current_thread(void)
+{
+#warning IMPLEMENT arch_thread_get_current_thread
+ Thread* t = NULL;
+ return t;
+}
+
+
+static inline void
+arch_thread_set_current_thread(Thread* t)
+{
+#warning IMPLEMENT arch_thread_set_current_thread
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _KERNEL_ARCH_RISCV64_THREAD_H */
diff --git a/headers/private/kernel/arch/riscv64/arch_thread_types.h
b/headers/private/kernel/arch/riscv64/arch_thread_types.h
new file mode 100644
index 0000000000..cbcd9f70c8
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_thread_types.h
@@ -0,0 +1,40 @@
+/*
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+#ifndef KERNEL_ARCH_RISCV64_THREAD_TYPES_H
+#define KERNEL_ARCH_RISCV64_THREAD_TYPES_H
+
+#include <kernel.h>
+
+#define IFRAME_TRACE_DEPTH 4
+
+struct iframe_stack {
+ struct iframe *frames[IFRAME_TRACE_DEPTH];
+ int32 index;
+};
+
+// architecture specific thread info
+struct arch_thread {
+ void *sp; // stack pointer
+ void *interrupt_stack;
+
+ // used to track interrupts on this thread
+ struct iframe_stack iframes;
+};
+
+struct arch_team {
+ // gcc treats empty structures as zero-length in C, but as if they
contain
+ // a char in C++. So we have to put a dummy in to be able to use the
struct
+ // from both in a consistent way.
+ char dummy;
+};
+
+struct arch_fork_arg {
+ // gcc treats empty structures as zero-length in C, but as if they
contain
+ // a char in C++. So we have to put a dummy in to be able to use the
struct
+ // from both in a consistent way.
+ char dummy;
+};
+
+#endif /* KERNEL_ARCH_RISCV64_THREAD_TYPES_H */
diff --git a/headers/private/kernel/arch/riscv64/arch_user_debugger.h
b/headers/private/kernel/arch/riscv64/arch_user_debugger.h
new file mode 100644
index 0000000000..39544a4263
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_user_debugger.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2009-2019 Haiku, Inc. All rights reserved.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_RISCV64_USER_DEBUGGER_H
+#define _KERNEL_ARCH_RISCV64_USER_DEBUGGER_H
+
+struct arch_team_debug_info {
+ uint32 dummy;
+};
+
+struct arch_thread_debug_info {
+ uint32 dummy;
+};
+
+#endif /* _KERNEL_ARCH_RISCV64_USER_DEBUGGER_H */
+
diff --git a/headers/private/kernel/arch/riscv64/arch_vm.h
b/headers/private/kernel/arch/riscv64/arch_vm.h
new file mode 100644
index 0000000000..3e83f0c3fe
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_vm.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2009-2019 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_RISCV64_VM_H
+#define _KERNEL_ARCH_RISCV64_VM_H
+
+/* This many pages will be read/written on I/O if possible */
+
+#define NUM_IO_PAGES 4
+ /* 16 kB */
+
+#define PAGE_SHIFT 12
+
+#endif /* _KERNEL_ARCH_RISCV64_VM_H */
+
diff --git a/headers/private/kernel/arch/riscv64/arch_vm_types.h
b/headers/private/kernel/arch/riscv64/arch_vm_types.h
new file mode 100644
index 0000000000..afd546e9ab
--- /dev/null
+++ b/headers/private/kernel/arch/riscv64/arch_vm_types.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2009-2019 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_RISCV64_VM_TYPES_H
+#define _KERNEL_ARCH_RISCV64_VM_TYPES_H
+
+#endif /* _KERNEL_ARCH_RISCV64_VM_TYPES_H */
diff --git a/headers/private/system/arch/riscv64/arch_elf.h
b/headers/private/system/arch/riscv64/arch_elf.h
new file mode 100644
index 0000000000..c6b79cd3e8
--- /dev/null
+++ b/headers/private/system/arch/riscv64/arch_elf.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2009-2019, Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _SYSTEM_ARCH_RISCV64_ELF_H
+#define _SYSTEM_ARCH_RISCV64_ELF_H
+
+
+#define R_RISCV_NONE 0
+#define R_RISCV_32 1
+#define R_RISCV_64 2
+#define R_RISCV_RELATIVE 3
+#define R_RISCV_COPY 4
+#define R_RISCV_JUMP_SLOT 5
+#define R_RISCV_TLS_DTPMOD32 6
+#define R_RISCV_TLS_DTPMOD64 7
+#define R_RISCV_TLS_DTPREL32 8
+#define R_RISCV_TLS_DTPREL64 9
+#define R_RISCV_TLS_TPREL32 10
+#define R_RISCV_TLS_TPREL64 11
+#define R_RISCV_BRANCH 16
+#define R_RISCV_JAL 17
+#define R_RISCV_CALL 18
+#define R_RISCV_CALL_PLT 19
+#define R_RISCV_GOT_HI20 20
+#define R_RISCV_TLS_GOT_HI20 21
+#define R_RISCV_TLS_GD_HI20 22
+#define R_RISCV_PCREL_HI20 23
+#define R_RISCV_PCREL_LO12_I 24
+#define R_RISCV_PCREL_LO12_S 25
+#define R_RISCV_HI20 26
+#define R_RISCV_LO12_I 27
+#define R_RISCV_LO12_S 28
+#define R_RISCV_TPREL_HI20 29
+#define R_RISCV_TPREL_LO12_I 30
+#define R_RISCV_TPREL_LO12_S 31
+#define R_RISCV_TPREL_ADD 32
+#define R_RISCV_ADD8 33
+#define R_RISCV_ADD16 34
+#define R_RISCV_ADD32 35
+#define R_RISCV_ADD64 36
+#define R_RISCV_SUB8 37
+#define R_RISCV_SUB16 38
+#define R_RISCV_SUB32 39
+#define R_RISCV_SUB64 40
+#define R_RISCV_GNU_VTINHERIT 41
+#define R_RISCV_GNU_VTENTRY 42
+#define R_RISCV_ALIGN 43
+#define R_RISCV_RVC_BRANCH 44
+#define R_RISCV_RVC_JUMP 45
+#define R_RISCV_LUI 46
+#define R_RISCV_GPREL_I 47
+#define R_RISCV_GPREL_S 48
+#define R_RISCV_TPREL_I 49
+#define R_RISCV_TPREL_S 50
+#define R_RISCV_RELAX 51
+#define R_RISCV_SUB6 52
+#define R_RISCV_SET6 53
+#define R_RISCV_SET8 54
+#define R_RISCV_SET16 55
+#define R_RISCV_SET32 56
+#define R_RISCV_32_PCREL 57
+
+
+#endif /* _SYSTEM_ARCH_RISCV64_ELF_H */