about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/internal/or1k/syscall.s13
-rw-r--r--src/ldso/or1k/dlsym.s5
-rw-r--r--src/ldso/or1k/start.s34
-rw-r--r--src/setjmp/or1k/longjmp.s25
-rw-r--r--src/setjmp/or1k/setjmp.s24
-rw-r--r--src/signal/or1k/sigsetjmp.s22
-rw-r--r--src/thread/or1k/__set_thread_area.s6
-rw-r--r--src/thread/or1k/__unmapself.s8
-rw-r--r--src/thread/or1k/clone.s30
-rw-r--r--src/thread/or1k/syscall_cp.s20
10 files changed, 187 insertions, 0 deletions
diff --git a/src/internal/or1k/syscall.s b/src/internal/or1k/syscall.s
new file mode 100644
index 00000000..2ea0eb13
--- /dev/null
+++ b/src/internal/or1k/syscall.s
@@ -0,0 +1,13 @@
+.global __syscall
+.type   __syscall,@function
+__syscall:
+	l.ori	r11, r3, 0
+	l.lwz	r3, 0(r1)
+	l.lwz	r4, 4(r1)
+	l.lwz	r5, 8(r1)
+	l.lwz	r6, 12(r1)
+	l.lwz	r7, 16(r1)
+	l.lwz	r8, 20(r1)
+	l.sys	1
+	l.jr	r9
+	 l.nop
diff --git a/src/ldso/or1k/dlsym.s b/src/ldso/or1k/dlsym.s
new file mode 100644
index 00000000..b2f4dfe3
--- /dev/null
+++ b/src/ldso/or1k/dlsym.s
@@ -0,0 +1,5 @@
+.global dlsym
+.type   dlsym,@function
+dlsym:
+	l.j	plt(__dlsym)
+	 l.ori	r5, r9, 0
diff --git a/src/ldso/or1k/start.s b/src/ldso/or1k/start.s
new file mode 100644
index 00000000..83b7c2c6
--- /dev/null
+++ b/src/ldso/or1k/start.s
@@ -0,0 +1,34 @@
+.global _dlstart
+_dlstart:
+	l.jal	1f
+	 l.nop
+1:	l.movhi	r5, gotpchi(_GLOBAL_OFFSET_TABLE_+0)
+	l.ori	r5, r5, gotpclo(_GLOBAL_OFFSET_TABLE_+4)
+	l.add	r5, r5, r9
+	l.movhi	r3, gotoffhi(_DYNAMIC)
+	l.ori	r3, r3, gotofflo(_DYNAMIC)
+	l.add	r5, r5, r3
+
+	l.lwz	r3, 0(r1)
+	l.addi	r4, r1, 4
+	l.jal	plt(__reloc_self)
+	 l.addi	r1, r1, -16
+
+	l.lwz	r3, 16(r1)
+	l.jal	plt(__dynlink)
+	 l.addi	r4, r1, 20
+	l.addi	r1, r1, 16
+
+	l.lwz	r4, 0(r1)
+1:	l.addi	r4, r4, -1
+	l.lwz	r5, 4(r1)
+	l.sfeqi	r5, -1
+	l.bf	1b
+	 l.addi	r1, r1, 4
+
+	l.addi	r4, r4, 1
+	l.addi	r1, r1, -4
+	l.sw	0(r1), r4
+
+	l.jr	r11
+	 l.ori	r3, r0, 0
diff --git a/src/setjmp/or1k/longjmp.s b/src/setjmp/or1k/longjmp.s
new file mode 100644
index 00000000..1db9fd93
--- /dev/null
+++ b/src/setjmp/or1k/longjmp.s
@@ -0,0 +1,25 @@
+.global _longjmp
+.global longjmp
+.type   _longjmp,@function
+.type   longjmp,@function
+_longjmp:
+longjmp:
+	l.sfeqi	r4, 0
+	l.bnf	1f
+	 l.addi	r11, r4,0
+	l.ori	r11, r0, 1
+1:	l.lwz	r1, 0(r3)
+	l.lwz	r2, 4(r3)
+	l.lwz	r9, 8(r3)
+	l.lwz	r10, 12(r3)
+	l.lwz	r14, 16(r3)
+	l.lwz	r16, 20(r3)
+	l.lwz	r18, 24(r3)
+	l.lwz	r20, 28(r3)
+	l.lwz	r22, 32(r3)
+	l.lwz	r24, 36(r3)
+	l.lwz	r26, 40(r3)
+	l.lwz	r28, 44(r3)
+	l.lwz	r30, 48(r3)
+	l.jr	r9
+	 l.nop
diff --git a/src/setjmp/or1k/setjmp.s b/src/setjmp/or1k/setjmp.s
new file mode 100644
index 00000000..8de4d3c2
--- /dev/null
+++ b/src/setjmp/or1k/setjmp.s
@@ -0,0 +1,24 @@
+.global __setjmp
+.global _setjmp
+.global setjmp
+.type __setjmp,@function
+.type _setjmp,@function
+.type setjmp,@function
+__setjmp:
+_setjmp:
+setjmp:
+	l.sw	0(r3), r1
+	l.sw	4(r3), r2
+	l.sw	8(r3), r9
+	l.sw	12(r3), r10
+	l.sw	16(r3), r14
+	l.sw	20(r3), r16
+	l.sw	24(r3), r18
+	l.sw	28(r3), r20
+	l.sw	32(r3), r22
+	l.sw	36(r3), r24
+	l.sw	40(r3), r26
+	l.sw	44(r3), r28
+	l.sw	48(r3), r30
+	l.jr	r9
+	 l.ori	r11,r0,0
diff --git a/src/signal/or1k/sigsetjmp.s b/src/signal/or1k/sigsetjmp.s
new file mode 100644
index 00000000..70a29223
--- /dev/null
+++ b/src/signal/or1k/sigsetjmp.s
@@ -0,0 +1,22 @@
+.global sigsetjmp
+.global __sigsetjmp
+.type sigsetjmp,@function
+.type __sigsetjmp,@function
+sigsetjmp:
+__sigsetjmp:
+	l.sfeq	r4, r0
+	l.bf	plt(setjmp)
+	 l.sw	52(r3), r4	/* buf->__fl = save */
+
+	l.addi	r1, r1, -8
+	l.sw	0(r1), r9
+	l.sw	4(r1), r3
+	l.addi	r5, r3, 56	/* buf->__ss */
+	l.add	r4, r0, r0
+	l.jal	plt(sigprocmask)
+	 l.ori	r3, r0, 2	/* SIG_SETMASK */
+
+	l.lwz	r9, 0(r1)
+	l.lwz	r3, 4(r1)
+	l.j	plt(setjmp)
+	 l.addi	r1, r1, 8
diff --git a/src/thread/or1k/__set_thread_area.s b/src/thread/or1k/__set_thread_area.s
new file mode 100644
index 00000000..44c5d459
--- /dev/null
+++ b/src/thread/or1k/__set_thread_area.s
@@ -0,0 +1,6 @@
+.global __set_thread_area
+.type   __set_thread_area,@function
+__set_thread_area:
+	l.ori	r10, r3, 0
+	l.jr	r9
+	 l.ori	r11, r0, 0
diff --git a/src/thread/or1k/__unmapself.s b/src/thread/or1k/__unmapself.s
new file mode 100644
index 00000000..6c0fa2ac
--- /dev/null
+++ b/src/thread/or1k/__unmapself.s
@@ -0,0 +1,8 @@
+.global __unmapself
+.type   __unmapself,@function
+__unmapself:
+	l.ori	r11, r0, 215 /* __NR_munmap */
+	l.sys	1
+	l.ori	r3, r0, 0
+	l.ori	r11, r0, 93 /* __NR_exit */
+	l.sys	1
diff --git a/src/thread/or1k/clone.s b/src/thread/or1k/clone.s
new file mode 100644
index 00000000..02f380bd
--- /dev/null
+++ b/src/thread/or1k/clone.s
@@ -0,0 +1,30 @@
+/* int clone(fn, stack, flags, arg, ptid, tls, ctid)
+ *           r3  r4     r5     r6   sp+0  sp+4 sp+8
+ * sys_clone(flags, stack, ptid, ctid, tls)
+ */
+.global __clone
+.type   __clone,@function
+__clone:
+	l.addi	r4, r4, -8
+	l.sw	0(r4), r3
+	l.sw	4(r4), r6
+	/* (fn, st, fl, ar, pt, tl, ct) => (fl, st, pt, ct, tl) */
+	l.ori	r3, r5, 0
+	l.lwz	r5, 0(r1)
+	l.lwz	r6, 8(r1)
+	l.lwz	r7, 4(r1)
+	l.ori	r11, r0, 220 /* __NR_clone */
+	l.sys	1
+
+	l.sfeqi	r11, 0
+	l.bf	1f
+	 l.nop
+	l.jr	r9
+	 l.nop
+
+1:	l.lwz	r11, 0(r1)
+	l.jalr	r11
+	 l.lwz	r3, 4(r1)
+
+	l.ori	r11, r0, 93 /* __NR_exit */
+	l.sys	1
diff --git a/src/thread/or1k/syscall_cp.s b/src/thread/or1k/syscall_cp.s
new file mode 100644
index 00000000..02d4cd79
--- /dev/null
+++ b/src/thread/or1k/syscall_cp.s
@@ -0,0 +1,20 @@
+.global __syscall_cp_asm
+.type   __syscall_cp_asm,@function
+__syscall_cp_asm:
+.global __cp_begin
+__cp_begin:
+	l.lwz	r3, 0(r3)
+	l.sfeqi	r3, 0
+	l.bnf	plt(__cancel)
+	 l.ori	r11, r4, 0
+	l.ori	r3, r5, 0
+	l.ori	r4, r6, 0
+	l.ori	r5, r7, 0
+	l.ori	r6, r8, 0
+	l.lwz	r7, 0(r1)
+	l.lwz	r8, 4(r1)
+	l.sys	1
+.global __cp_end
+__cp_end:
+	l.jr	r9
+	 l.nop