kernel: riscv64 patches
Change-Id: I8ebcbaa395cbccb50af08fd2f1b049b5cbb949c7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3883 Reviewed-by: Fredrik Holmqvist <[email protected]> Reviewed-by: Adrien Destugues <[email protected]> Reviewed-by: X512 <[email protected]>
This commit is contained in:
@@ -422,8 +422,9 @@ rule KernelArchitectureSetup architecture
|
|||||||
case riscv64 :
|
case riscv64 :
|
||||||
# Kernel lives within any single 2 GiB address space.
|
# Kernel lives within any single 2 GiB address space.
|
||||||
# Default is medlow (-2GiB / +2GiB)
|
# Default is medlow (-2GiB / +2GiB)
|
||||||
HAIKU_KERNEL_CCFLAGS += -mcmodel=medany ;
|
HAIKU_KERNEL_CCFLAGS += -mcmodel=medany -fpic ;
|
||||||
HAIKU_KERNEL_C++FLAGS += -mcmodel=medany ;
|
HAIKU_KERNEL_C++FLAGS += -mcmodel=medany -fpic ;
|
||||||
|
HAIKU_KERNEL_PIC_LINKFLAGS = -shared ;
|
||||||
|
|
||||||
case sparc :
|
case sparc :
|
||||||
# The medlow code model is enough (64-bit addresses, programs must
|
# The medlow code model is enough (64-bit addresses, programs must
|
||||||
|
|||||||
@@ -13,4 +13,44 @@
|
|||||||
|
|
||||||
#define NUM_IO_VECTORS 256
|
#define NUM_IO_VECTORS 256
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
arch_int_enable_interrupts_inline(void)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
arch_int_disable_interrupts_inline(void)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
arch_int_restore_interrupts_inline(int oldState)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
arch_int_are_interrupts_enabled_inline(void)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// map the functions to the inline versions
|
||||||
|
#define arch_int_enable_interrupts() arch_int_enable_interrupts_inline()
|
||||||
|
#define arch_int_disable_interrupts() arch_int_disable_interrupts_inline()
|
||||||
|
#define arch_int_restore_interrupts(status) \
|
||||||
|
arch_int_restore_interrupts_inline(status)
|
||||||
|
#define arch_int_are_interrupts_enabled() \
|
||||||
|
arch_int_are_interrupts_enabled_inline()
|
||||||
|
|
||||||
|
|
||||||
#endif /* _KERNEL_ARCH_RISCV64_INT_H */
|
#endif /* _KERNEL_ARCH_RISCV64_INT_H */
|
||||||
|
|||||||
@@ -5,9 +5,13 @@
|
|||||||
#ifndef _KERNEL_ARCH_RISCV64_KERNEL_H
|
#ifndef _KERNEL_ARCH_RISCV64_KERNEL_H
|
||||||
#define _KERNEL_ARCH_RISCV64_KERNEL_H
|
#define _KERNEL_ARCH_RISCV64_KERNEL_H
|
||||||
|
|
||||||
#include <arch/cpu.h>
|
|
||||||
|
|
||||||
#warning Review arch_kernel.h
|
#ifndef _ASSEMBLER
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# include <arch/cpu.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// memory layout
|
// memory layout
|
||||||
#define KERNEL_LOAD_BASE 0x80000000
|
#define KERNEL_LOAD_BASE 0x80000000
|
||||||
@@ -17,25 +21,22 @@
|
|||||||
#if defined(__riscv64__)
|
#if defined(__riscv64__)
|
||||||
|
|
||||||
// Base of the kernel address space.
|
// Base of the kernel address space.
|
||||||
#define KERNEL_BASE 0xffffff0000000000
|
#define KERNEL_BASE (0x0000000000000000 + 0x1000)
|
||||||
#define KERNEL_SIZE 0x10000000000
|
#define KERNEL_TOP (0x0000004000000000 - 1)
|
||||||
#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
|
#define KERNEL_SIZE ((KERNEL_TOP - KERNEL_BASE) + 1)
|
||||||
|
|
||||||
// Kernel physical memory map area.
|
// Kernel physical memory map area.
|
||||||
#define KERNEL_PMAP_BASE 0xffffff0000000000
|
#define KERNEL_PMAP_BASE 0x0000003000000000
|
||||||
#define KERNEL_PMAP_SIZE 0x8000000000
|
#define KERNEL_PMAP_SIZE 0x1000000000
|
||||||
|
|
||||||
// Userspace address space layout.
|
// Userspace address space layout.
|
||||||
// There is a 2MB hole just before the end of the bottom half of the address
|
#define USER_BASE 0xffffffc000000000
|
||||||
// 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_BASE_ANY USER_BASE
|
||||||
#define USER_SIZE (0x800000000000 - (0x200000 + USER_BASE))
|
#define USER_SIZE 0x0000004000000000
|
||||||
#define USER_TOP (USER_BASE + (USER_SIZE - 1))
|
#define USER_TOP (USER_BASE + (USER_SIZE - 1))
|
||||||
|
|
||||||
#define KERNEL_USER_DATA_BASE 0x7f0000000000
|
#define KERNEL_USER_DATA_BASE (USER_BASE + 0x3000000000)
|
||||||
#define USER_STACK_REGION 0x7f0000000000
|
#define USER_STACK_REGION (USER_BASE + 0x3000000000)
|
||||||
#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1)
|
#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1)
|
||||||
|
|
||||||
#else /* ! __riscv64__ */
|
#else /* ! __riscv64__ */
|
||||||
|
|||||||
@@ -20,19 +20,13 @@
|
|||||||
|
|
||||||
// kernel args
|
// kernel args
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// architecture specific
|
|
||||||
uint64 phys_pgdir;
|
|
||||||
uint64 vir_pgdir;
|
|
||||||
uint64 next_pagetable;
|
|
||||||
|
|
||||||
uint64 virtual_end;
|
|
||||||
|
|
||||||
// The virtual ranges we want to keep in the kernel.
|
// The virtual ranges we want to keep in the kernel.
|
||||||
uint32 num_virtual_ranges_to_keep;
|
uint32 num_virtual_ranges_to_keep;
|
||||||
addr_range virtual_ranges_to_keep[MAX_VIRTUAL_RANGES_TO_KEEP];
|
addr_range virtual_ranges_to_keep[MAX_VIRTUAL_RANGES_TO_KEEP];
|
||||||
|
|
||||||
// needed for UEFI, otherwise kernel acpi support can't find ACPI root
|
// needed for UEFI, otherwise kernel acpi support can't find ACPI root
|
||||||
FixedWidthPointer<void> acpi_root;
|
FixedWidthPointer<void> acpi_root;
|
||||||
|
FixedWidthPointer<void> fdt;
|
||||||
} _PACKED arch_kernel_args;
|
} _PACKED arch_kernel_args;
|
||||||
|
|
||||||
#endif /* KERNEL_ARCH_RISCV64_KERNEL_ARGS_H */
|
#endif /* KERNEL_ARCH_RISCV64_KERNEL_ARGS_H */
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
# include <arch/generic/user_memory.h>
|
# include <arch/generic/user_memory.h>
|
||||||
#elif defined(__M68K__)
|
#elif defined(__M68K__)
|
||||||
# include <arch/generic/user_memory.h>
|
# include <arch/generic/user_memory.h>
|
||||||
|
#elif defined(__riscv)
|
||||||
|
# include <arch/generic/user_memory.h>
|
||||||
#else
|
#else
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#ifndef _SYSTEM_ARCH_RISCV64_CONFIG_H
|
#ifndef _SYSTEM_ARCH_RISCV64_CONFIG_H
|
||||||
#define _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 FUNCTION_CALL_PARAMETER_ALIGNMENT_TYPE unsigned int
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <boot/kernel_args.h>
|
#include <boot/kernel_args.h>
|
||||||
#include <boot/stage2.h>
|
#include <boot/stage2.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <arch_cpu_defs.h>
|
||||||
#include <arch_kernel.h>
|
#include <arch_kernel.h>
|
||||||
#include <arch_system_info.h>
|
#include <arch_system_info.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -5,62 +5,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <asm_defs.h>
|
#include <asm_defs.h>
|
||||||
#include <arch_cpu_defs.h>
|
|
||||||
|
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
|
|
||||||
#warning TODO: Fix overly simplistic IRQ
|
|
||||||
|
|
||||||
/* void arch_int_enable_interrupts(void) */
|
|
||||||
FUNCTION(arch_int_enable_interrupts):
|
|
||||||
li t0, ARCH_SR_SIE
|
|
||||||
csrrs zero, sstatus, t0
|
|
||||||
ret
|
|
||||||
FUNCTION_END(arch_int_enable_interrupts)
|
|
||||||
|
|
||||||
|
|
||||||
/* int arch_int_disable_interrupts(void)
|
|
||||||
*/
|
|
||||||
FUNCTION(arch_int_disable_interrupts):
|
|
||||||
li t0, ARCH_SR_SIE
|
|
||||||
csrrc zero, sstatus, ARCH_SR_SIE
|
|
||||||
ret
|
|
||||||
FUNCTION_END(arch_int_disable_interrupts)
|
|
||||||
|
|
||||||
|
|
||||||
/* void arch_int_restore_interrupts(int oldState)
|
|
||||||
*/
|
|
||||||
FUNCTION(arch_int_restore_interrupts):
|
|
||||||
// TODO
|
|
||||||
ret
|
|
||||||
FUNCTION_END(arch_int_restore_interrupts)
|
|
||||||
|
|
||||||
|
|
||||||
/* bool arch_int_are_interrupts_enabled(void) */
|
|
||||||
FUNCTION(arch_int_are_interrupts_enabled):
|
|
||||||
// TODO
|
|
||||||
ret
|
|
||||||
FUNCTION_END(arch_int_are_interrupts_enabled)
|
|
||||||
|
|
||||||
|
|
||||||
/* status_t arch_cpu_user_memcpy(void *to, const void *from, size_t size, addr_t *faultHandler) */
|
|
||||||
FUNCTION(_arch_cpu_user_memcpy):
|
|
||||||
// TODO
|
|
||||||
ret
|
|
||||||
FUNCTION_END(_arch_cpu_user_memcpy)
|
|
||||||
|
|
||||||
|
|
||||||
/* status_t arch_cpu_user_memset(void *to, char c, size_t count, addr_t *faultHandler) */
|
|
||||||
FUNCTION(_arch_cpu_user_memset):
|
|
||||||
// TODO
|
|
||||||
ret
|
|
||||||
FUNCTION_END(_arch_cpu_user_memset)
|
|
||||||
|
|
||||||
|
|
||||||
/* ssize_t arch_cpu_user_strlcpy(void *to, const void *from, size_t size, addr_t *faultHandler) */
|
|
||||||
FUNCTION(_arch_cpu_user_strlcpy):
|
|
||||||
// TODO
|
|
||||||
ret
|
|
||||||
FUNCTION_END(_arch_cpu_user_strlcpy)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user