diff --git a/build/jam/repositories/HaikuPorts/riscv64 b/build/jam/repositories/HaikuPorts/riscv64 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/headers/private/system/arch/riscv64/arch_cpu_defs.h b/headers/private/system/arch/riscv64/arch_cpu_defs.h new file mode 100644 index 0000000000..b6785ec526 --- /dev/null +++ b/headers/private/system/arch/riscv64/arch_cpu_defs.h @@ -0,0 +1,41 @@ +/* + * Copyright 2018-2019, Haiku, Inc. All rights reserved + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV + */ +#ifndef _SYSTEM_ARCH_RISCV64_DEFS_H +#define _SYSTEM_ARCH_RISCV64_DEFS_H + + +#define SPINLOCK_PAUSE() do {} while (false) + +// Status register flags +#define ARCH_SR_SIE 0x00000002 // Supervisor Interrupt Enable +#define ARCH_SR_SPIE 0x00000020 // Previous Supervisor Interrupt En +#define ARCH_SR_SPP 0x00000100 // Previously Supervisor +#define ARCH_SR_SUM 0x00040000 // Supervisor may access user memory + +#define ARCH_SR_FS 0x00006000 // Floating Point Status +#define ARCH_SR_FS_OFF 0x00000000 +#define ARCH_SR_FS_INITIAL 0x00002000 +#define ARCH_SR_FS_CLEAN 0x00004000 +#define ARCH_SR_FS_DIRTY 0x00006000 + +#define ARCH_SR_XS 0x00018000 // Extension Status +#define ARCH_SR_XS_OFF 0x00000000 +#define ARCH_SR_XS_INITIAL 0x00008000 +#define ARCH_SR_XS_CLEAN 0x00010000 +#define ARCH_SR_XS_DIRTY 0x00018000 + +#define ARCH_SR_SD 0x8000000000000000 // FS/XS dirty + +// Interrupt Enable and Interrupt Pending +#define ARCH_SIE_SSIE 0x00000002 // Software Interrupt Enable +#define ARCH_SIE_STIE 0x00000020 // Timer Interrupt Enable +#define ARCH_SIE_SEIE 0x00000200 // External Interrupt Enable + + +#endif /* _SYSTEM_ARCH_RISCV64_DEFS_H */ + diff --git a/headers/private/system/arch/riscv64/asm_defs.h b/headers/private/system/arch/riscv64/asm_defs.h new file mode 100644 index 0000000000..c7ae40598e --- /dev/null +++ b/headers/private/system/arch/riscv64/asm_defs.h @@ -0,0 +1,19 @@ +/* + * Copyright 2008, François Revol, revol@free.fr. + * Distributed under the terms of the MIT License. + */ +#ifndef SYSTEM_ARCH_RISCV64_ASM_DEFS_H +#define SYSTEM_ARCH_RISCV64_ASM_DEFS_H + + +/* include arch version helpers */ +//#include + +#define SYMBOL(name) .global name; name +#define SYMBOL_END(name) 1: .size name, 1b - name +#define STATIC_FUNCTION(name) .type name, %function; name +#define FUNCTION(name) .global name; .type name, %function; name +#define FUNCTION_END(name) 1: .size name, 1b - name + + +#endif /* SYSTEM_ARCH_RISCV64_ASM_DEFS_H */ diff --git a/src/data/package_infos/riscv64/haiku b/src/data/package_infos/riscv64/haiku new file mode 100644 index 0000000000..b72acaa5a4 --- /dev/null +++ b/src/data/package_infos/riscv64/haiku @@ -0,0 +1,135 @@ +name haiku +version %HAIKU_VERSION% +architecture riscv64 +summary "The Haiku base system" + +description "The Haiku base system includes all system core software, like +boot loader, kernel, the system libraries, servers, and applications." + +packager "The Haiku build system" +vendor "Haiku Project" + +copyrights "2001-2019 Haiku, Inc. et al" +licenses { + MIT + "GNU LGPL v2.1" +} +flags system_package + +provides { + haiku=%HAIKU_VERSION% compat>=R1~beta1 + cmd:arp + cmd:chop + cmd:clear + cmd:compress + cmd:df + cmd:ftp + cmd:ftpd + cmd:hd + cmd:hey + cmd:login + cmd:more + cmd:passwd + cmd:ping + cmd:ping6 + cmd:prio + cmd:ps + cmd:renice + cmd:resattr + cmd:su + cmd:telnet + cmd:telnetd + cmd:top + cmd:tput + cmd:traceroute + cmd:trash + cmd:unchop + cmd:useradd + cmd:watch + cmd:xres +} + +requires { + coreutils + cmd:sh +#ifdef HAIKU_REGULAR_BUILD + cmd:bunzip2 + cmd:gunzip + cmd:tar + cmd:unzip +#endif + lib:libfreetype +#ifdef HAIKU_BUILD_FEATURE_RISCV64_FONTCONFIG_ENABLED + lib:libfontconfig +#endif + lib:libgcc_s + lib:libicudata >= 57 + lib:libicui18n >= 57 + lib:libicuio >= 57 + lib:libicule >= 57 + lib:libiculx >= 57 + lib:libicutest >= 57 + lib:libicutu >= 57 + lib:libicuuc >= 57 + lib:libncurses >= 6.0 +#ifdef HAIKU_REGULAR_BUILD +#ifdef HAIKU_BUILD_FEATURE_RISCV64_EXPAT_ENABLED + lib:libexpat +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_GUTENPRINT_ENABLED + lib:libgutenprint +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_LIBICNS_ENABLED + lib:libicns +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_JASPER_ENABLED + lib:libjasper +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_JPEG_ENABLED + lib:libjpeg +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_LIBPNG_ENABLED + lib:libpng >= 16.0 +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_TIFF_ENABLED + lib:libtiff >= 5.2 +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_LIBWEBP_ENABLED + lib:libwebp +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_ILMBASE_ENABLED + lib:libhalf + lib:libiex + lib:libiexmath + lib:libilmthread + lib:libimath +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_OPENEXR_ENABLED + lib:libilmimf + lib:libilmimfutil +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_OPENSSL_ENABLED + lib:libssl >= 1.0.0 + lib:libcrypto >= 1.0.0 +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_FFMPEG_ENABLED + lib:libavcodec >= 58 + lib:libavfilter >= 7 + lib:libavformat >= 58 + lib:libavutil >= 56 + lib:libswresample >= 3 +#endif +#ifdef HAIKU_BUILD_FEATURE_RISCV64_ZSTD_ENABLED + lib:libzstd >= 1 +#endif +#endif + lib:libsolv + lib:libsolvext + lib:libstdc++ + lib:libsupc++ + lib:libz + noto +#ifdef HAIKU_REGULAR_BUILD + noto_sans_cjk_jp +#endif +} diff --git a/src/kits/debug/arch/riscv64/arch_debug_support.cpp b/src/kits/debug/arch/riscv64/arch_debug_support.cpp new file mode 100644 index 0000000000..83f6b35cdf --- /dev/null +++ b/src/kits/debug/arch/riscv64/arch_debug_support.cpp @@ -0,0 +1,52 @@ +/* + * Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include "arch_debug_support.h" + + +struct stack_frame { + struct stack_frame *previous; + void *return_address; +}; + + +status_t +arch_debug_get_instruction_pointer(debug_context *context, thread_id thread, + void **ip, void **stackFrameAddress) +{ + // get the CPU state + debug_cpu_state cpuState; + status_t error = debug_get_cpu_state(context, thread, NULL, &cpuState); + if (error != B_OK) + return error; + + *ip = (void*)cpuState.rip; + *stackFrameAddress = (void*)cpuState.rbp; + + return B_OK; +} + + +status_t +arch_debug_get_stack_frame(debug_context *context, void *stackFrameAddress, + debug_stack_frame_info *stackFrameInfo) +{ + stack_frame stackFrame; + ssize_t bytesRead = debug_read_memory(context, stackFrameAddress, + &stackFrame, sizeof(stackFrame)); + if (bytesRead < B_OK) + return bytesRead; + if (bytesRead != sizeof(stackFrame)) + return B_ERROR; + + stackFrameInfo->frame = stackFrameAddress; + stackFrameInfo->parent_frame = stackFrame.previous; + stackFrameInfo->return_address = stackFrame.return_address; + return B_OK; +} diff --git a/src/system/boot/arch/riscv64/Jamfile b/src/system/boot/arch/riscv64/Jamfile new file mode 100644 index 0000000000..e309eb55a8 --- /dev/null +++ b/src/system/boot/arch/riscv64/Jamfile @@ -0,0 +1,33 @@ +SubDir HAIKU_TOP src system boot arch riscv64 ; + +{ + local defines = _BOOT_MODE ; + + defines = [ FDefines $(defines) ] ; + SubDirCcFlags $(defines) ; + SubDirC++Flags $(defines) -fno-rtti ; +} + + +local kernelLibArchObjects = + byteorder.o + memcpy.o + memset.o +; + +BootMergeObject boot_arch_$(TARGET_KERNEL_ARCH).o : + debug_uart_8250.cpp + #arch_uart_8250.cpp + arch_elf.cpp + : # additional flags + : + $(kernelArchObjects) + $(kernelLibArchObjects) +; + +SEARCH on [ FGristFiles arch_elf.cpp arch_uart_8250.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ; + +SEARCH on [ FGristFiles debug_uart_8250.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel arch generic ] ; + diff --git a/src/system/kernel/arch/riscv64/Jamfile b/src/system/kernel/arch/riscv64/Jamfile index 8fb0460454..f76a4dfe22 100644 --- a/src/system/kernel/arch/riscv64/Jamfile +++ b/src/system/kernel/arch/riscv64/Jamfile @@ -2,3 +2,25 @@ SubDir HAIKU_TOP src system kernel arch riscv64 ; SubDirHdrs $(SUBDIR) $(DOTDOT) generic ; UsePrivateKernelHeaders ; + +KernelMergeObject kernel_arch_riscv64.o : + arch_asm.S + arch_commpage.cpp + arch_cpu.cpp + arch_debug.cpp + arch_debug_console.cpp + arch_elf.cpp + arch_int.cpp + arch_platform.cpp + arch_real_time_clock.cpp + arch_smp.cpp + arch_system_info.cpp + arch_timer.cpp + arch_thread.cpp + arch_user_debugger.cpp + arch_vm.cpp + arch_vm_translation_map.cpp + : + $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused + : +; diff --git a/src/system/kernel/arch/riscv64/arch_asm.S b/src/system/kernel/arch/riscv64/arch_asm.S new file mode 100644 index 0000000000..1c3a6ec705 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_asm.S @@ -0,0 +1,66 @@ +/* + * Copyright 2019, Haiku, Inc. All Rights Reserved + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +.text + + +#warning TODO: Fix overly simplistic IRQ + +/* void arch_int_enable_interrupts(void) */ +FUNCTION(arch_int_enable_interrupts): + // TODO + csrs sstatus, ARCH_SR_SIE + ret +FUNCTION_END(arch_int_enable_interrupts) + + +/* int arch_int_disable_interrupts(void) + */ +FUNCTION(arch_int_disable_interrupts): + csrrc 0, sstatus, ARCH_SR_SIE + // TODO + 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) diff --git a/src/system/kernel/arch/riscv64/arch_commpage.cpp b/src/system/kernel/arch/riscv64/arch_commpage.cpp new file mode 100644 index 0000000000..b7378611ab --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_commpage.cpp @@ -0,0 +1,29 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + +#include + +#include +#include +#include + + +status_t +arch_commpage_init(void) +{ + return B_OK; +} + + +status_t +arch_commpage_init_post_cpus(void) +{ + return B_OK; +} + diff --git a/src/system/kernel/arch/riscv64/arch_cpu.cpp b/src/system/kernel/arch/riscv64/arch_cpu.cpp new file mode 100644 index 0000000000..c8fa731a13 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_cpu.cpp @@ -0,0 +1,99 @@ +/* + * Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include +#include +#include + + +status_t +arch_cpu_preboot_init_percpu(kernel_args *args, int curr_cpu) +{ + return B_OK; +} + + +status_t +arch_cpu_init_percpu(kernel_args *args, int curr_cpu) +{ + //detect_cpu(curr_cpu); + + // we only support one anyway... + return 0; +} + + +status_t +arch_cpu_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_cpu_init_post_vm(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_cpu_init_post_modules(kernel_args *args) +{ + return B_OK; +} + + +void +arch_cpu_sync_icache(void *address, size_t len) +{ +} + + +void +arch_cpu_memory_read_barrier(void) +{ +} + + +void +arch_cpu_memory_write_barrier(void) +{ +} + + +void +arch_cpu_invalidate_TLB_range(addr_t start, addr_t end) +{ +} + + +void +arch_cpu_invalidate_TLB_list(addr_t pages[], int num_pages) +{ +} + + +void +arch_cpu_global_TLB_invalidate(void) +{ +} + + +void +arch_cpu_user_TLB_invalidate(void) +{ +} + + +status_t +arch_cpu_shutdown(bool reboot) +{ + return B_ERROR; +} diff --git a/src/system/kernel/arch/riscv64/arch_debug.cpp b/src/system/kernel/arch/riscv64/arch_debug.cpp new file mode 100644 index 0000000000..495c9abf0e --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_debug.cpp @@ -0,0 +1,106 @@ +/* + * Copyright 2019, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Adrien Destugues + */ + + +#include + + +void +arch_debug_stack_trace(void) +{ +} + + +bool +arch_debug_contains_call(Thread *thread, const char *symbol, + addr_t start, addr_t end) +{ + return false; +} + + +void * +arch_debug_get_caller(void) +{ + return NULL; +} + + +void +arch_debug_save_registers(struct arch_debug_registers* registers) +{ +} + + +void +arch_debug_call_with_fault_handler(cpu_ent* cpu, jmp_buf jumpBuffer, + void (*function)(void*), void* parameter) +{ +} + + +bool +arch_is_debug_variable_defined(const char* variableName) +{ + // TODO: Implement! + return false; +} + + +status_t +arch_set_debug_variable(const char* variableName, uint64 value) +{ + // TODO: Implement! + return B_ENTRY_NOT_FOUND; +} + + +status_t +arch_get_debug_variable(const char* variableName, uint64* value) +{ + // TODO: Implement! + return B_ENTRY_NOT_FOUND; +} + + +int32 +arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, + int32 skipIframes, int32 skipFrames, uint32 flags) +{ + return 0; +} + + +ssize_t +arch_debug_gdb_get_registers(char* buffer, size_t bufferSize) +{ + // TODO: Implement! + return B_NOT_SUPPORTED; +} + + +void* +arch_debug_get_interrupt_pc(bool* _isSyscall) +{ + // TODO: Implement! + return NULL; +} + + +status_t +arch_debug_init(kernel_args *args) +{ +#if 0 + add_debugger_command("where", &stack_trace, "Same as \"sc\""); + add_debugger_command("bt", &stack_trace, "Same as \"sc\" (as in gdb)"); + add_debugger_command("sc", &stack_trace, "Stack crawl for current thread"); +#endif + + return B_NO_ERROR; +} + diff --git a/src/system/kernel/arch/riscv64/arch_debug_console.cpp b/src/system/kernel/arch/riscv64/arch_debug_console.cpp new file mode 100644 index 0000000000..32eaa295fe --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_debug_console.cpp @@ -0,0 +1,95 @@ +/* + * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ + + +#include +#include +#include +#include + +#include + + +void +arch_debug_remove_interrupt_handler(uint32 line) +{ +} + + +void +arch_debug_install_interrupt_handlers(void) +{ +} + + +int +arch_debug_blue_screen_try_getchar(void) +{ + return 0; +} + + +char +arch_debug_blue_screen_getchar(void) +{ + return 0; +} + + +int +arch_debug_serial_try_getchar(void) +{ + // TODO: Implement correctly! + return arch_debug_serial_getchar(); +} + + +char +arch_debug_serial_getchar(void) +{ + return 0; +} + + +void +arch_debug_serial_putchar(const char c) +{ +} + + +void +arch_debug_serial_puts(const char *s) +{ + while (*s != '\0') { + arch_debug_serial_putchar(*s); + s++; + } +} + + +void +arch_debug_serial_early_boot_message(const char *string) +{ + // this function will only be called in fatal situations +} + + +status_t +arch_debug_console_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_debug_console_init_settings(kernel_args *args) +{ + return B_OK; +} + + diff --git a/src/system/kernel/arch/riscv64/arch_elf.cpp b/src/system/kernel/arch/riscv64/arch_elf.cpp new file mode 100644 index 0000000000..e34c185241 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_elf.cpp @@ -0,0 +1,99 @@ +/* + * Copyright 2019, Adrien Destugues + * Copyright 2010, Ithamar R. Adema + * Copyright 2009, Johannes Wischert, johanneswi@gmail.com. + * Copyright 2005, Ingo Weinhold . + * Copyright 2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include + + +//#define TRACE_ARCH_ELF +#ifdef TRACE_ARCH_ELF +# define TRACE(x) dprintf x +# define CHATTY 1 +#else +# define TRACE(x) ; +# define CHATTY 0 +#endif + + +#ifndef _BOOT_MODE +static bool +is_in_image(struct elf_image_info *image, addr_t address) +{ + return (address >= image->text_region.start + && address < image->text_region.start + image->text_region.size) + || (address >= image->data_region.start + && address < image->data_region.start + image->data_region.size); +} +#endif // !_BOOT_MODE + + +int +arch_elf_relocate_rel(struct elf_image_info *image, + struct elf_image_info *resolve_image, Elf64_Rel *rel, int rel_len) +{ + // TODO: rel entries in RISCV64 elf + return B_NO_ERROR; +} + + +static inline void +write_32(addr_t P, Elf32_Word value) +{ + *(Elf32_Word*)P = value; +} + + +static inline void +write_16(addr_t P, Elf32_Word value) +{ + // bits 16:29 + *(Elf32_Half*)P = (Elf32_Half)value; +} + + +static inline bool +write_16_check(addr_t P, Elf32_Word value) +{ + // bits 15:0 + if ((value & 0xffff0000) && (~value & 0xffff8000)) + return false; + *(Elf32_Half*)P = (Elf32_Half)value; + return true; +} + + +static inline bool +write_8(addr_t P, Elf32_Word value) +{ + // bits 7:0 + *(uint8 *)P = (uint8)value; + return true; +} + + +static inline bool +write_8_check(addr_t P, Elf32_Word value) +{ + // bits 7:0 + if ((value & 0xffffff00) && (~value & 0xffffff80)) + return false; + *(uint8 *)P = (uint8)value; + return true; +} + + +int +arch_elf_relocate_rela(struct elf_image_info *image, + struct elf_image_info *resolve_image, Elf64_Rela *rel, int rel_len) +{ + return B_OK; +} diff --git a/src/system/kernel/arch/riscv64/arch_int.cpp b/src/system/kernel/arch/riscv64/arch_int.cpp new file mode 100644 index 0000000000..885044d2aa --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_int.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2003-2011, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Adrien Destugues, pulkomandy@pulkomandy.tk + */ + + +#include + + +status_t +arch_int_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_int_init_post_vm(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_int_init_post_device_manager(struct kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_int_init_io(kernel_args* args) +{ + return B_OK; +} + + +void +arch_int_enable_io_interrupt(int irq) +{ +} + + +void +arch_int_disable_io_interrupt(int irq) +{ +} + + +void +arch_int_assign_to_cpu(int32 irq, int32 cpu) +{ +} diff --git a/src/system/kernel/arch/riscv64/arch_platform.cpp b/src/system/kernel/arch/riscv64/arch_platform.cpp new file mode 100644 index 0000000000..30a2394057 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_platform.cpp @@ -0,0 +1,27 @@ +/* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk. + * Distributed under the terms of the MIT License. + */ + + +#include + + +status_t +arch_platform_init(struct kernel_args *kernelArgs) +{ + return B_OK; +} + + +status_t +arch_platform_init_post_vm(struct kernel_args *kernelArgs) +{ + return B_OK; +} + + +status_t +arch_platform_init_post_thread(struct kernel_args *kernelArgs) +{ + return B_OK; +} diff --git a/src/system/kernel/arch/riscv64/arch_real_time_clock.cpp b/src/system/kernel/arch/riscv64/arch_real_time_clock.cpp new file mode 100644 index 0000000000..937b58d595 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_real_time_clock.cpp @@ -0,0 +1,37 @@ +#include + +#include +#include + + +status_t +arch_rtc_init(kernel_args *args, struct real_time_data *data) +{ + return B_OK; +} + + +uint32 +arch_rtc_get_hw_time(void) +{ + return 0; +} + + +void +arch_rtc_set_hw_time(uint32 seconds) +{ +} + + +void +arch_rtc_set_system_time_offset(struct real_time_data *data, bigtime_t offset) +{ +} + + +bigtime_t +arch_rtc_get_system_time_offset(struct real_time_data *data) +{ + return 0; +} diff --git a/src/system/kernel/arch/riscv64/arch_smp.cpp b/src/system/kernel/arch/riscv64/arch_smp.cpp new file mode 100644 index 0000000000..5971139e11 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_smp.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * François Revol + * + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include +#include +#include + + +status_t +arch_smp_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_smp_per_cpu_init(kernel_args *args, int32 cpu) +{ + return B_OK; +} + + +void +arch_smp_send_multicast_ici(CPUSet& cpuSet) +{ +#if KDEBUG + if (are_interrupts_enabled()) + panic("arch_smp_send_multicast_ici: called with interrupts enabled"); +#endif +} + + +void +arch_smp_send_ici(int32 target_cpu) +{ + panic("called arch_smp_send_ici!\n"); +} + + +void +arch_smp_send_broadcast_ici() +{ + panic("called arch_smp_send_broadcast_ici\n"); +} + + diff --git a/src/system/kernel/arch/riscv64/arch_system_info.cpp b/src/system/kernel/arch/riscv64/arch_system_info.cpp new file mode 100644 index 0000000000..97905d62e9 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_system_info.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2007, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * François Revol + * + * Copyright 2006, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include + +#include +#include +#include + + +static uint64 sCPUClockFrequency; +static uint64 sBusClockFrequency; +static uint16 sCPURevision; + + +void +arch_fill_topology_node(cpu_topology_node_info* node, int32 cpu) +{ +} + + +status_t +arch_system_info_init(struct kernel_args *args) +{ + return B_OK; +} + diff --git a/src/system/kernel/arch/riscv64/arch_thread.cpp b/src/system/kernel/arch/riscv64/arch_thread.cpp new file mode 100644 index 0000000000..eda19a1cd2 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_thread.cpp @@ -0,0 +1,132 @@ +/* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include +#include +#include +#include +#include + + +status_t +arch_thread_init(struct kernel_args *args) +{ + // Initialize the static initial arch_thread state (sInitialState). + // Currently nothing to do, i.e. zero initialized is just fine. + + return B_OK; +} + + +status_t +arch_team_init_team_struct(Team *team, bool kernel) +{ + // Nothing to do. The structure is empty. + return B_OK; +} + + +status_t +arch_thread_init_thread_struct(Thread *thread) +{ + // set up an initial state (stack & fpu) + //memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); + + return B_OK; +} + + +void +arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop, + void (*function)(void*), const void* data) +{ + #warning RISCV64: Implement thread init kthread + panic("arch_thread_init_kthread_stack(): Implement me!"); +} + + +status_t +arch_thread_init_tls(Thread *thread) +{ + // TODO: Implement! + return B_OK; +} + + +void +arch_thread_context_switch(Thread *from, Thread *to) +{ +} + + +void +arch_thread_dump_info(void *info) +{ +} + + +status_t +arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) +{ + panic("arch_thread_enter_uspace(): not yet implemented\n"); + return B_ERROR; +} + + +bool +arch_on_signal_stack(Thread *thread) +{ + return false; +} + + +status_t +arch_setup_signal_frame(Thread *thread, struct sigaction *sa, + struct signal_frame_data *signalFrameData) +{ + return B_ERROR; +} + + +int64 +arch_restore_signal_frame(struct signal_frame_data* signalFrameData) +{ + return 0; +} + + +void +arch_check_syscall_restart(Thread *thread) +{ +} + + +/** Saves everything needed to restore the frame in the child fork in the + * arch_fork_arg structure to be passed to arch_restore_fork_frame(). + * Also makes sure to return the right value. + */ + +void +arch_store_fork_frame(struct arch_fork_arg *arg) +{ +} + + +/** Restores the frame from a forked team as specified by the provided + * arch_fork_arg structure. + * Needs to be called from within the child team, ie. instead of + * arch_thread_enter_uspace() as thread "starter". + * This function does not return to the caller, but will enter userland + * in the child team at the same position where the parent team left of. + */ + +void +arch_restore_fork_frame(struct arch_fork_arg *arg) +{ +} + diff --git a/src/system/kernel/arch/riscv64/arch_timer.cpp b/src/system/kernel/arch/riscv64/arch_timer.cpp new file mode 100644 index 0000000000..fc5193b4a4 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_timer.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2019, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Adrien Destugues + */ + + +#include +#include +#include +#include + + +void +arch_timer_set_hardware_timer(bigtime_t timeout) +{ +} + + +void +arch_timer_clear_hardware_timer() +{ +} + + +int +arch_init_timer(kernel_args *args) +{ + return B_OK; +} + + +bigtime_t +system_time(void) +{ + // TODO + return 0; +} diff --git a/src/system/kernel/arch/riscv64/arch_user_debugger.cpp b/src/system/kernel/arch/riscv64/arch_user_debugger.cpp new file mode 100644 index 0000000000..08023893e8 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_user_debugger.cpp @@ -0,0 +1,95 @@ +/* + * Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk. + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include +#include + + +void +arch_clear_team_debug_info(struct arch_team_debug_info *info) +{ +} + + +void +arch_destroy_team_debug_info(struct arch_team_debug_info *info) +{ + arch_clear_team_debug_info(info); +} + + +void +arch_clear_thread_debug_info(struct arch_thread_debug_info *info) +{ +} + + +void +arch_destroy_thread_debug_info(struct arch_thread_debug_info *info) +{ + arch_clear_thread_debug_info(info); +} + + +void +arch_update_thread_single_step() +{ +} + + +void +arch_set_debug_cpu_state(const debug_cpu_state *cpuState) +{ +} + + +void +arch_get_debug_cpu_state(debug_cpu_state *cpuState) +{ +} + + +status_t +arch_get_thread_debug_cpu_state(Thread* thread, debug_cpu_state* cpuState) +{ + return B_UNSUPPORTED; +} + + +status_t +arch_set_breakpoint(void *address) +{ + return B_ERROR; +} + + +status_t +arch_clear_breakpoint(void *address) +{ + return B_ERROR; +} + + +status_t +arch_set_watchpoint(void *address, uint32 type, int32 length) +{ + return B_ERROR; +} + + +status_t +arch_clear_watchpoint(void *address) +{ + return B_ERROR; +} + +bool +arch_has_breakpoints(struct arch_team_debug_info *info) +{ + return false; +} diff --git a/src/system/kernel/arch/riscv64/arch_vm.cpp b/src/system/kernel/arch/riscv64/arch_vm.cpp new file mode 100644 index 0000000000..5aa8636c06 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_vm.cpp @@ -0,0 +1,122 @@ +/* + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include + + +//#define TRACE_ARCH_VM +#ifdef TRACE_ARCH_VM +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +status_t +arch_vm_init(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_init_post_area(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_init_post_modules(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_init_end(kernel_args *args) +{ + TRACE(("arch_vm_init_end(): %lu virtual ranges to keep:\n", + args->arch_args.num_virtual_ranges_to_keep)); + + for (int i = 0; i < (int)args->arch_args.num_virtual_ranges_to_keep; i++) { + addr_range &range = args->arch_args.virtual_ranges_to_keep[i]; + + TRACE((" start: %p, size: 0x%lx\n", (void*)range.start, range.size)); + +#if 0 + // skip ranges outside the kernel address space + if (!IS_KERNEL_ADDRESS(range.start)) { + TRACE((" no kernel address, skipping...\n")); + continue; + } + + phys_addr_t physicalAddress; + void *address = (void*)range.start; + if (vm_get_page_mapping(VMAddressSpace::KernelID(), range.start, + &physicalAddress) != B_OK) + panic("arch_vm_init_end(): No page mapping for %p\n", address); + area_id area = vm_map_physical_memory(VMAddressSpace::KernelID(), + "boot loader reserved area", &address, + B_EXACT_ADDRESS, range.size, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, + physicalAddress, true); + if (area < 0) { + panic("arch_vm_init_end(): Failed to create area for boot loader " + "reserved area: %p - %p\n", (void*)range.start, + (void*)(range.start + range.size)); + } +#endif + } + +#if 0 + // Throw away any address space mappings we've inherited from the boot + // loader and have not yet turned into an area. + vm_free_unused_boot_loader_range(0, 0xffffffff - B_PAGE_SIZE + 1); +#endif + + return B_OK; +} + + +void +arch_vm_aspace_swap(struct VMAddressSpace *from, struct VMAddressSpace *to) +{ + // This functions is only invoked when a userland thread is in the process + // of dying. It switches to the kernel team and does whatever cleanup is + // necessary (in case it is the team's main thread, it will delete the + // team). + // It is however not necessary to change the page directory. Userland team's + // page directories include all kernel mappings as well. Furthermore our + // arch specific translation map data objects are ref-counted, so they won't + // go away as long as they are still used on any CPU. +} + + +bool +arch_vm_supports_protection(uint32 protection) +{ + return true; +} + + +void +arch_vm_unset_memory_type(VMArea *area) +{ +} + + +status_t +arch_vm_set_memory_type(VMArea *area, addr_t physicalBase, uint32 type) +{ + if (type == 0) + return B_OK; + + return B_ERROR; +} diff --git a/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp b/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp new file mode 100644 index 0000000000..afb42677a2 --- /dev/null +++ b/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp @@ -0,0 +1,100 @@ +/* + * Copyright 2007-2010, François Revol, revol@free.fr. + * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk. + * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ + + +#include +#include +#include +#include +#include + + +#define TRACE_VM_TMAP +#ifdef TRACE_VM_TMAP +# define TRACE(x...) dprintf(x) +#else +# define TRACE(x...) ; +#endif + + +status_t +arch_vm_translation_map_init(kernel_args *args, + VMPhysicalPageMapper** _physicalPageMapper) +{ + TRACE("vm_translation_map_init: entry\n"); + +#ifdef TRACE_VM_TMAP + TRACE("physical memory ranges:\n"); + for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) { + phys_addr_t start = args->physical_memory_range[i].start; + phys_addr_t end = start + args->physical_memory_range[i].size; + TRACE(" %#10" B_PRIxPHYSADDR " - %#10" B_PRIxPHYSADDR "\n", start, + end); + } + + TRACE("allocated physical ranges:\n"); + for (uint32 i = 0; i < args->num_physical_allocated_ranges; i++) { + phys_addr_t start = args->physical_allocated_range[i].start; + phys_addr_t end = start + args->physical_allocated_range[i].size; + TRACE(" %#10" B_PRIxPHYSADDR " - %#10" B_PRIxPHYSADDR "\n", start, + end); + } + + TRACE("allocated virtual ranges:\n"); + for (uint32 i = 0; i < args->num_virtual_allocated_ranges; i++) { + addr_t start = args->virtual_allocated_range[i].start; + addr_t end = start + args->virtual_allocated_range[i].size; + TRACE(" %#10" B_PRIxADDR " - %#10" B_PRIxADDR "\n", start, end); + } +#endif + + return B_OK; +} + + +status_t +arch_vm_translation_map_init_post_sem(kernel_args *args) +{ + return B_OK; +} + + +status_t +arch_vm_translation_map_init_post_area(kernel_args *args) +{ + TRACE("vm_translation_map_init_post_area: entry\n"); + return B_OK; +} + + +status_t +arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, + uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) +{ + TRACE("early_tmap: entry pa 0x%lx va 0x%lx\n", pa, va); + return B_OK; +} + + +status_t +arch_vm_translation_map_create_map(bool kernel, VMTranslationMap** _map) +{ + return B_OK; +} + + +bool +arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress, + uint32 protection) +{ + return false; +} + diff --git a/src/system/kernel/lib/arch/riscv64/Jamfile b/src/system/kernel/lib/arch/riscv64/Jamfile index 1fe370fc36..3ffd75a931 100644 --- a/src/system/kernel/lib/arch/riscv64/Jamfile +++ b/src/system/kernel/lib/arch/riscv64/Jamfile @@ -9,7 +9,7 @@ SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; SEARCH_SOURCE += [ FDirName $(librootSources) os arch generic ] ; KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : - byteorder.S + #byteorder.S generic_atomic.cpp generic_system_time_nsecs.cpp @@ -22,12 +22,13 @@ SEARCH_SOURCE += [ FDirName $(posixSources) string arch generic ] ; SEARCH_SOURCE += [ FDirName $(posixSources) string arch $(TARGET_ARCH) ] ; KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o : - siglongjmp.S - sigsetjmp.S + #siglongjmp.S + #sigsetjmp.S kernel_longjmp_return.c kernel_setjmp_save_sigs.c - arch_string.S + #arch_string.S + memcpy.c memset.c : $(TARGET_KERNEL_PIC_CCFLAGS) diff --git a/src/system/libroot/os/arch/riscv64/Jamfile b/src/system/libroot/os/arch/riscv64/Jamfile new file mode 100644 index 0000000000..330af393f7 --- /dev/null +++ b/src/system/libroot/os/arch/riscv64/Jamfile @@ -0,0 +1,23 @@ +SubDir HAIKU_TOP src system libroot os arch riscv64 ; + +SubDirC++Flags -std=gnu++11 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv64 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + UsePrivateKernelHeaders ; + UsePrivateSystemHeaders ; + + SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + + MergeObject <$(architecture)>os_arch_$(TARGET_ARCH).o : + tls.c + thread.c + + generic_atomic.cpp + generic_system_time_nsecs.cpp + ; + } +} diff --git a/src/system/libroot/os/arch/riscv64/byteorder.S b/src/system/libroot/os/arch/riscv64/byteorder.S new file mode 100644 index 0000000000..9bded18ee4 --- /dev/null +++ b/src/system/libroot/os/arch/riscv64/byteorder.S @@ -0,0 +1,38 @@ +/* + * Copyright 2009, Johannes Wischert. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include + +.text + +/* + * These aren't needed on gcc4+ + * uint16 __swap_int16(uint16 value) + * uint32 __swap_int32(uint32 value) + * uint64 __swap_int64(uint64 value) + */ + +/* TODO: The following functions can surely be optimized. A simple optimization + * would be to define macros with the contents of the __swap_int{32,64} + * functions and use those instead of calling the functions. + */ + +/* float __swap_float(float value) + */ +FUNCTION(__swap_float): + // Assumes single precision + b __swap_int32 + //rts +FUNCTION_END(__swap_float) + + +/* double __swap_double(double value) + */ +FUNCTION(__swap_double): + // Assumes double is int64 on RV64 + b __swap_int64 + //rts +FUNCTION_END(__swap_double) + diff --git a/src/system/libroot/os/arch/riscv64/thread.c b/src/system/libroot/os/arch/riscv64/thread.c new file mode 100644 index 0000000000..df90b6ad6a --- /dev/null +++ b/src/system/libroot/os/arch/riscv64/thread.c @@ -0,0 +1,9 @@ +#include +#include "syscalls.h" + + +thread_id +find_thread(const char *name) +{ + return _kern_find_thread(name); +} diff --git a/src/system/libroot/os/arch/riscv64/tls.c b/src/system/libroot/os/arch/riscv64/tls.c new file mode 100644 index 0000000000..f030edb966 --- /dev/null +++ b/src/system/libroot/os/arch/riscv64/tls.c @@ -0,0 +1,53 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the MIT License. +*/ + +// ToDo: this is a dummy implementation - I've not yet gained enough knowledge +// to decide how this should be done, so it's just broken now (okay for single +// threaded apps, though). + +// we don't want to have the inline assembly included here +#ifndef _NO_INLINE_ASM +# define _NO_INLINE_ASM 1 +#endif + +#include "support/TLS.h" +#include "tls.h" + + +static int32 gNextSlot = TLS_FIRST_FREE_SLOT; +static void *gSlots[TLS_MAX_KEYS]; + + +int32 +tls_allocate(void) +{ + int32 next = atomic_add(&gNextSlot, 1); + if (next >= TLS_MAX_KEYS) + return B_NO_MEMORY; + + return next; +} + + +void * +tls_get(int32 index) +{ + return gSlots[index]; +} + + +void ** +tls_address(int32 index) +{ + return &gSlots[index]; +} + + +void +tls_set(int32 index, void *value) +{ + gSlots[index] = value; +} + diff --git a/src/system/libroot/posix/arch/riscv64/Jamfile b/src/system/libroot/posix/arch/riscv64/Jamfile new file mode 100644 index 0000000000..5a8d678ea7 --- /dev/null +++ b/src/system/libroot/posix/arch/riscv64/Jamfile @@ -0,0 +1,24 @@ +SubDir HAIKU_TOP src system libroot posix arch riscv64 ; + +local architectureObject ; +for architectureObject in [ MultiArchSubDirSetup riscv64 ] { + on $(architectureObject) { + local architecture = $(TARGET_PACKAGING_ARCH) ; + + local genericSources = + setjmp_save_sigs.c + longjmp_return.c + ; + + MergeObject <$(architecture)>posix_arch_$(TARGET_ARCH).o : + fenv.c + #sigsetjmp.S + #siglongjmp.S + + $(genericSources) + ; + + SEARCH on [ FGristFiles $(genericSources) ] + = [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + } +} diff --git a/src/system/libroot/posix/arch/riscv64/fenv.c b/src/system/libroot/posix/arch/riscv64/fenv.c new file mode 100644 index 0000000000..fc5e716a92 --- /dev/null +++ b/src/system/libroot/posix/arch/riscv64/fenv.c @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2004 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#if 0 // disabled for now +#include + +const fenv_t __fe_dfl_env = 0x00000000; +#endif diff --git a/src/system/libroot/posix/glibc/arch/riscv64/Jamfile b/src/system/libroot/posix/glibc/arch/riscv64/Jamfile new file mode 100644 index 0000000000..ba38192712 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/riscv64/Jamfile @@ -0,0 +1,139 @@ +SubDir HAIKU_TOP src system libroot posix glibc arch riscv64 ; + +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc arch $(TARGET_ARCH) ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch + $(TARGET_ARCH) ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch generic ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc stdlib ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc math ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc libio ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ; + +SubDirHdrs $(HAIKU_TOP) src system libroot posix glibc arch generic ; + +UsePrivateHeaders libroot ; + +SubDirCcFlags -D_GNU_SOURCE -D_IEEE_LIBM ; + +local genericSources = + branred.c + cmp.c dbl2mpn.c divrem.c + dosincos.c + halfulp.c + memrchr.c + mpa.c mpatan.c mpatan2.c mpexp.c mplog.c mpn2dbl.c + mpn2flt.c mpn2ldbl.c mpsqrt.c mptan.c + mul.c mul_n.c + sincos32.c + slowexp.c + slowpow.c + + e_acosh.c e_acoshf.c # e_acoshl.c + e_atan2.c e_atan2f.c # e_atan2l.c + e_atanh.c e_atanhf.c # e_atanhl.c + e_cosh.c e_coshf.c # e_coshl.c + e_exp.c e_expf.c + e_fmod.c e_fmodf.c # e_fmodl.c + e_gamma_r.c e_gammaf_r.c + e_hypot.c e_hypotf.c # e_hypotl.c + e_j0.c e_j0f.c + e_j1.c e_j1f.c + e_jn.c e_jnf.c + e_lgamma_r.c e_lgammaf_r.c + e_log.c e_logf.c + e_log10.c e_log10f.c + e_pow.c e_powf.c # e_powl.c + e_rem_pio2f.c + e_remainder.c e_remainderf.c # e_remainderl.c + e_scalb.c e_scalbf.c # e_scalbl.c + e_sinh.c e_sinhf.c # e_sinhl.c + k_cos.c k_cosf.c + k_sin.c k_sinf.c + k_rem_pio2.c k_rem_pio2f.c # k_rem_pio2l.c + k_tan.c k_tanf.c + s_asinh.c s_asinhf.c # s_asinhl.c + s_atan.c s_atanf.c # s_atanl.c + s_cbrt.c s_cbrtf.c # s_cbrtl.c + s_ceil.c s_ceilf.c # s_ceill.c + s_copysign.c s_copysignf.c # s_copysignl.c + s_cos.c s_cosf.c + s_erf.c s_erff.c # s_erfl.c + s_expm1f.c s_expm1.c + s_fabs.c s_fabsf.c # s_fabsl.S + s_finite.c s_finitef.c # s_finitel.c + s_floor.c s_floorf.c # s_floorl.c + s_fma.c s_fmaf.c # s_fmal.c + s_fmax.c s_fmaxf.c # s_fmaxl.c + s_fmin.c s_fminf.c # s_fminl.c + s_fpclassify.c s_fpclassifyf.c # s_fpclassifyl.c + s_frexp.c s_frexpf.c # s_frexpl.c + s_ilogb.c s_ilogbf.c + s_isinf.c s_isinff.c # s_isinfl.c + s_ldexp.c s_ldexpf.c # s_ldexpl.c + s_llrint.c s_llrintf.c # s_llrintl.c + s_log1p.c s_log1pf.c + s_logb.c s_logbf.c # s_logbl.c + s_lrint.c s_lrintf.c # s_lrintl.c + s_lround.c s_lroundf.c + s_modf.c s_modff.c # s_modfl.c + s_nan.c s_nanf.c # s_nanl.c + s_nextafter.c s_nextafterf.c # s_nextafterl.c + s_nexttoward.c # s_nexttowardf.c s_nexttowardl.c + s_round.c s_roundf.c # s_roundl.c + s_scalbn.c s_scalbnf.c # s_scalbnl.c + s_signbit.c s_signbitf.c # s_signbitl.c + s_significand.c s_significandf.c + s_signgam.c + s_sin.c s_sinf.c # s_sinl.c + s_sincos.c s_sincosf.c + s_tan.c s_tanf.c + s_tanh.c s_tanhf.c + s_trunc.c s_truncf.c + t_exp.c + w_acos.c w_acosf.c # w_acosl.c + w_acosh.c w_acoshf.c # w_acoshl.c + w_atan2.c w_atan2f.c # w_atan2l.c + w_asin.c w_asinf.c # w_asinl.c + w_atanh.c w_atanhf.c # w_atanhl.c + w_cosh.c w_coshf.c # w_coshl.c + w_drem.c w_dremf.c # w_dreml.c + w_exp.c w_expf.c # w_expl.c + w_fmod.c w_fmodf.c # w_fmodl.c + w_hypot.c w_hypotf.c # w_hypotl.c + w_j0.c w_j0f.c + w_j1.c w_j1f.c + w_jn.c w_jnf.c + w_lgamma.c w_lgammaf.c + w_lgamma_r.c w_lgammaf_r.c + w_log.c w_logf.c # w_logl.c + w_log10.c w_log10f.c # w_log10l.c + w_pow.c w_powf.c # w_powl.c + w_remainder.c w_remainderf.c # w_remainderl.c + w_scalb.c w_scalbf.c # w_scalbl.c + w_sinh.c w_sinhf.c # w_sinhl.c + # no asm for m68k in glibc + w_sqrt.c w_sqrtf.c # w_sqrtl.c + ; + + +MergeObject <$(TARGET_ARCH)>posix_gnu_arch_$(TARGET_ARCH)_generic.o : + $(genericSources) +; + + +#MergeObject <$(TARGET_ARCH)>posix_gnu_arch_$(TARGET_ARCH)_other.o : +# ; + + +MergeObjectFromObjects <$(TARGET_ARCH)>posix_gnu_arch_$(TARGET_ARCH).o + : : + <$(TARGET_ARCH)>posix_gnu_arch_$(TARGET_ARCH)_generic.o + # <$(TARGET_ARCH)>posix_gnu_arch_$(TARGET_ARCH)_other.o +; + + +SEARCH on [ FGristFiles $(genericSources) ] + = [ FDirName $(HAIKU_TOP) src system libroot posix glibc arch + generic ] ; + diff --git a/src/system/libroot/posix/string/arch/riscv64/arch_string.S b/src/system/libroot/posix/string/arch/riscv64/arch_string.S new file mode 100644 index 0000000000..70106ebffb --- /dev/null +++ b/src/system/libroot/posix/string/arch/riscv64/arch_string.S @@ -0,0 +1,21 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ + +#include + +#warning RISCV64: optimized assembly memcpy +// for now, a generic C one in: +// * src/system/kernel/lib/arch/riscv64/Jamfile +// * src/system/runtime_loader/arch/riscv64/Jamfile + +#if 0 + +/* that should be enough for now */ + +.align 4 +FUNCTION(memcpy): +/* void *memcpy(void *dest, const void *src, size_t count) */ +FUNCTION_END(memcpy) +#endif diff --git a/src/system/runtime_loader/arch/riscv64/Jamfile b/src/system/runtime_loader/arch/riscv64/Jamfile index 16c9f534bf..4204d6d9d3 100644 --- a/src/system/runtime_loader/arch/riscv64/Jamfile +++ b/src/system/runtime_loader/arch/riscv64/Jamfile @@ -15,7 +15,8 @@ for architectureObject in [ MultiArchSubDirSetup riscv64 ] { : thread.o - arch_string.o + #arch_string.o + memcpy.o memset.o ; } diff --git a/src/tools/gensyscalls/arch/riscv64/arch_gensyscalls.h b/src/tools/gensyscalls/arch/riscv64/arch_gensyscalls.h new file mode 100644 index 0000000000..620802d3a9 --- /dev/null +++ b/src/tools/gensyscalls/arch/riscv64/arch_gensyscalls.h @@ -0,0 +1,2 @@ +#define SYSCALL_RETURN_TYPE_ALIGNMENT_TYPE long +#define SYSCALL_PARAMETER_ALIGNMENT_TYPE long