diff --git a/sysdeps/managarm/generic/file.cpp b/sysdeps/managarm/generic/file.cpp index e920f9c99a..bf93b30997 100644 --- a/sysdeps/managarm/generic/file.cpp +++ b/sysdeps/managarm/generic/file.cpp @@ -2560,6 +2560,8 @@ int sys_uname(struct utsname *buf) { strcpy(buf->machine, "x86_64"); #elif defined (__aarch64__) strcpy(buf->machine, "aarch64"); +#elif defined (__riscv) + strcpy(buf->machine, "riscv64"); #else # error Unknown architecture #endif diff --git a/sysdeps/managarm/meson.build b/sysdeps/managarm/meson.build index c2d8434a84..f6debe5483 100644 --- a/sysdeps/managarm/meson.build +++ b/sysdeps/managarm/meson.build @@ -71,6 +71,9 @@ elif host_machine.cpu_family() == 'x86_64' 'x86_64/thread.cpp' ) elif host_machine.cpu_family() == 'riscv64' + libc_sources += files( + 'riscv64/thread.cpp', + ) else error('Unknown architecture') endif @@ -129,7 +132,7 @@ endif if not headers_only crtstuff = ['crt0'] - if host_machine.cpu_family() in ['x86_64', 'aarch64'] + if host_machine.cpu_family() in ['x86_64', 'aarch64', 'riscv64'] crtstuff += [ 'Scrt1', 'crti', diff --git a/sysdeps/managarm/riscv64/crt-src/Scrt1.S b/sysdeps/managarm/riscv64/crt-src/Scrt1.S new file mode 100644 index 0000000000..9ee8625264 --- /dev/null +++ b/sysdeps/managarm/riscv64/crt-src/Scrt1.S @@ -0,0 +1,18 @@ +.section .text +.global _start +_start: + .weak __global_pointer$ + .hidden __global_pointer$ + .option push + .option norelax + lla gp, __global_pointer$ + .option pop + + mv a0, sp + la a1, main + call __mlibc_entry@plt + unimp + + +.section .note.GNU-stack,"",%progbits + diff --git a/sysdeps/managarm/riscv64/crt-src/crt0.S b/sysdeps/managarm/riscv64/crt-src/crt0.S new file mode 100644 index 0000000000..16c79d681f --- /dev/null +++ b/sysdeps/managarm/riscv64/crt-src/crt0.S @@ -0,0 +1,15 @@ +.section .text +.global _start +_start: + .weak __global_pointer$ + .hidden __global_pointer$ + .option push + .option norelax + lla gp, __global_pointer$ + .option pop + + mv a0, sp + la a1, main + call __mlibc_entry +.section .note.GNU-stack,"",%progbits + diff --git a/sysdeps/managarm/riscv64/crt-src/crti.S b/sysdeps/managarm/riscv64/crt-src/crti.S new file mode 100644 index 0000000000..69f23ea88f --- /dev/null +++ b/sysdeps/managarm/riscv64/crt-src/crti.S @@ -0,0 +1,11 @@ +.section .init +.global _init +_init: + unimp + +.section .fini +.global _fini +_fini: + unimp +.section .note.GNU-stack,"",%progbits + diff --git a/sysdeps/managarm/riscv64/crt-src/crtn.S b/sysdeps/managarm/riscv64/crt-src/crtn.S new file mode 100644 index 0000000000..525efd6649 --- /dev/null +++ b/sysdeps/managarm/riscv64/crt-src/crtn.S @@ -0,0 +1,7 @@ +.section .init + unimp + +.section .fini + unimp +.section .note.GNU-stack,"",%progbits + diff --git a/sysdeps/managarm/riscv64/thread.cpp b/sysdeps/managarm/riscv64/thread.cpp new file mode 100644 index 0000000000..e2ffc2a74c --- /dev/null +++ b/sysdeps/managarm/riscv64/thread.cpp @@ -0,0 +1,9 @@ +#include + +extern "C" void __mlibc_start_thread() { + __ensure(!"unimplemented"); +} + +extern "C" void __mlibc_signal_restore() { + __ensure(!"unimplemented"); +}