summaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/riscv64
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mlibc/options/internal/riscv64')
-rw-r--r--lib/mlibc/options/internal/riscv64/fenv.S57
-rw-r--r--lib/mlibc/options/internal/riscv64/mlibc_crtbegin.S29
-rw-r--r--lib/mlibc/options/internal/riscv64/mlibc_crtend.S21
-rw-r--r--lib/mlibc/options/internal/riscv64/setjmp.S71
4 files changed, 178 insertions, 0 deletions
diff --git a/lib/mlibc/options/internal/riscv64/fenv.S b/lib/mlibc/options/internal/riscv64/fenv.S
new file mode 100644
index 0000000..c62ea36
--- /dev/null
+++ b/lib/mlibc/options/internal/riscv64/fenv.S
@@ -0,0 +1,57 @@
+
+#ifdef __riscv_flen
+
+.global feclearexcept
+.type feclearexcept, %function
+feclearexcept:
+ csrc fflags, a0
+ li a0, 0
+ ret
+
+.global feraiseexcept
+.type feraiseexcept, %function
+feraiseexcept:
+ csrs fflags, a0
+ li a0, 0
+ ret
+
+.global fetestexcept
+.type fetestexcept, %function
+fetestexcept:
+ frflags t0
+ and a0, t0, a0
+ ret
+
+.global fegetround
+.type fegetround, %function
+fegetround:
+ frrm a0
+ ret
+
+.global __fesetround
+.type __fesetround, %function
+__fesetround:
+ fsrm t0, a0
+ li a0, 0
+ ret
+
+.global fegetenv
+.type fegetenv, %function
+fegetenv:
+ frcsr t0
+ sw t0, 0(a0)
+ li a0, 0
+ ret
+
+.global fesetenv
+.type fesetenv, %function
+fesetenv:
+ li t2, -1
+ li t1, 0
+ beq a0, t2, 1f
+ lw t1, 0(a0)
+1: fscsr t1
+ li a0, 0
+ ret
+
+#endif \ No newline at end of file
diff --git a/lib/mlibc/options/internal/riscv64/mlibc_crtbegin.S b/lib/mlibc/options/internal/riscv64/mlibc_crtbegin.S
new file mode 100644
index 0000000..b99748b
--- /dev/null
+++ b/lib/mlibc/options/internal/riscv64/mlibc_crtbegin.S
@@ -0,0 +1,29 @@
+
+.section .data
+.hidden __dso_handle
+.global __dso_handle
+__dso_handle:
+ .quad __dso_handle
+
+.section .init
+.hidden _init
+.global _init
+_init:
+
+.section .fini
+.hidden _fini
+.global _fini
+_fini:
+
+.section .ctors
+.hidden __CTOR_LIST__
+.global __CTOR_LIST__
+__CTOR_LIST__:
+
+.section .dtors
+.hidden __DTOR_LIST__
+.global __DTOR_LIST__
+__DTOR_LIST__:
+
+.section .note.GNU-stack,"",%progbits
+
diff --git a/lib/mlibc/options/internal/riscv64/mlibc_crtend.S b/lib/mlibc/options/internal/riscv64/mlibc_crtend.S
new file mode 100644
index 0000000..bd0cebc
--- /dev/null
+++ b/lib/mlibc/options/internal/riscv64/mlibc_crtend.S
@@ -0,0 +1,21 @@
+.hidden __mlibc_do_ctors
+.hidden __mlibc_do_dtors
+
+.section .init
+ tail __mlibc_do_ctors
+
+.section .fini
+ tail __mlibc_do_dtors
+
+.section .ctors
+.hidden __CTOR_END__
+.global __CTOR_END__
+__CTOR_END__:
+
+.section .dtors
+.hidden __DTOR_END__
+.global __DTOR_END__
+__DTOR_END__:
+
+.section .note.GNU-stack,"",%progbits
+
diff --git a/lib/mlibc/options/internal/riscv64/setjmp.S b/lib/mlibc/options/internal/riscv64/setjmp.S
new file mode 100644
index 0000000..51568f7
--- /dev/null
+++ b/lib/mlibc/options/internal/riscv64/setjmp.S
@@ -0,0 +1,71 @@
+.global setjmp
+.type setjmp, "function"
+setjmp:
+ sd ra, 0(a0)
+ sd s0, 8(a0)
+ sd s1, 16(a0)
+ sd s2, 24(a0)
+ sd s3, 32(a0)
+ sd s4, 40(a0)
+ sd s5, 48(a0)
+ sd s6, 56(a0)
+ sd s7, 64(a0)
+ sd s8, 72(a0)
+ sd s9, 80(a0)
+ sd s10, 88(a0)
+ sd s11, 96(a0)
+ sd sp, 104(a0)
+ 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)
+ li a0, 0
+ ret
+
+.global sigsetjmp
+.type sigsetjmp, "function"
+sigsetjmp:
+ unimp // TODO
+
+.global longjmp
+.type longjmp, "function"
+longjmp:
+ ld ra,0(a0)
+ ld s0,8(a0)
+ ld s1,16(a0)
+ ld s2,24(a0)
+ ld s3,32(a0)
+ ld s4,40(a0)
+ ld s5,48(a0)
+ ld s6,56(a0)
+ ld s7,64(a0)
+ ld s8,72(a0)
+ ld s9,80(a0)
+ ld s10,88(a0)
+ ld s11,96(a0)
+ ld sp,104(a0)
+ 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)
+ seqz a0,a1
+ add a0,a0,a1
+ ret
+.section .note.GNU-stack,"",%progbits
+