From 266653039eb5a6da5cc69ed72bd8792bf8befeca Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 10 May 2022 07:16:42 -0700 Subject: Support RISC-V: conditionally. Everything compiles, and most tests pass. Failing test are: - tests/014/dgram-stream.tl: - tests/017/glob-carray.tl: - tests/017/qsort.tl: The datagram test is not able to bind a UDP socket to a port. On the gcc402 machine of the GCC Compile Farm, attempts bind a UDP socket to any of the ports 1024-65535 all fail with errno 99 (EADDRNOTAVAIL). The FFI test cases are segfaulting. The qosrt.tl case has the problem in the test cases which abort the callback with a return-from. * unwind.h (struct jmp): Define for RISC-V. * jmp.S (DEFUN): Define macro for RISC-V. (jmp_save, jmp_restore): Define for RISC-V. --- jmp.S | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ unwind.h | 33 +++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/jmp.S b/jmp.S index f38c74bd..9acee8a9 100644 --- a/jmp.S +++ b/jmp.S @@ -60,6 +60,11 @@ NAME: ; .globl NAME ; \ .def NAME; .scl 2; .type 32; .endef; \ NAME: ; +#elif __riscv +#define DEFUN(NAME) \ +.global NAME ; \ +.type NAME, %function ; \ +NAME: ; #else #define DEFUN(NAME) \ .global NAME ; \ @@ -414,6 +419,73 @@ DEFUN(jmp_restore) ld $30, 88($4) jr $ra move $2, $5 + +#elif __riscv + +DEFUN(jmp_save) + sd ra, 0(a0) + sd sp, 8(a0) + sd fp, 16(a0) + sd s1, 24(a0) + sd s2, 32(a0) + sd s3, 40(a0) + sd s4, 48(a0) + sd s5, 56(a0) + sd s6, 64(a0) + sd s7, 72(a0) + sd s8, 80(a0) + sd s9, 88(a0) + sd s10, 96(a0) + sd s11, 104(a0) +#if 0 && !__riscv_float_abi_soft + fsd fs0, 112(a0) + fsd fs1, 120(a0) + fsd fs2, 128(a0) + fsd fs3, 136(a0) + fsd fs4, 144(a0) + fsd fs5, 152(a0) + fsd fs6, 160(a0) + fsd fs7, 168(a0) + fsd fs8, 176(a0) + fsd fs9, 184(a0) + fsd fs10, 192(a0) + fsd fs11, 200(a0) +#endif + li a0, 0 + ret + +DEFUN(jmp_restore) + ld ra, 0(a0) + ld sp, 8(a0) + ld fp, 16(a0) + ld s1, 24(a0) + ld s2, 32(a0) + ld s3, 40(a0) + ld s4, 48(a0) + ld s5, 56(a0) + ld s6, 64(a0) + ld s7, 72(a0) + ld s8, 80(a0) + ld s9, 88(a0) + ld s10, 96(a0) + ld s11, 104(a0) +#if 0 && !__riscv_float_abi_soft + fld fs0, 112(a0) + fld fs1, 120(a0) + fld fs2, 128(a0) + fld fs3, 136(a0) + fld fs4, 144(a0) + fld fs5, 152(a0) + fld fs6, 160(a0) + fld fs7, 168(a0) + fld fs8, 176(a0) + fld fs9, 184(a0) + fld fs10, 192(a0) + fld fs11, 200(a0) +#endif + mv a0, a1 + ret + #else #error port me! #endif diff --git a/unwind.h b/unwind.h index 923981ac..ea9bd9a6 100644 --- a/unwind.h +++ b/unwind.h @@ -159,6 +159,39 @@ struct jmp { unsigned long ra; /* $31 */ }; +#elif __riscv + +struct jmp { + unsigned long ra; /* x1 */ + unsigned long sp; /* x2 */ + unsigned long fp; /* x8 */ + unsigned long s1; /* x9 */ + unsigned long s2; /* x18 */ + unsigned long s3; /* x19 */ + unsigned long s4; /* x20 */ + unsigned long s5; /* x21 */ + unsigned long s6; /* x22 */ + unsigned long s7; /* x23 */ + unsigned long s8; /* x24 */ + unsigned long s9; /* x25 */ + unsigned long s10; /* x26 */ + unsigned long s11; /* x27 */ +#if 0 && !__riscv_float_abi_soft + double fs0; /* f8 */ + double fs1; /* f9 */ + double fs2; /* f18 */ + double fs3; /* f19 */ + double fs4; /* f20 */ + double fs5; /* f21 */ + double fs6; /* f22 */ + double fs7; /* f23 */ + double fs8; /* f24 */ + double fs9; /* f25 */ + double fs10; /* f26 */ + double fs11; /* f27 */ +#endif +}; + #else #error port me! #endif -- cgit v1.2.3