about summary refs log tree commit diff
path: root/src/thread/superh
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2013-10-05 05:13:18 -0500
committerBobby Bingham <koorogi@koorogi.info>2014-02-23 16:15:54 -0600
commit3a3c813e08d808224c12fd0e9104aeff7c45c9a7 (patch)
tree508b28c42438615d711afcb9b44d7b0e0842f28d /src/thread/superh
parentd05aaedaabd4f5472c233dbbd1ff4bb9c9c99794 (diff)
downloadmusl-3a3c813e08d808224c12fd0e9104aeff7c45c9a7.tar.gz
musl-3a3c813e08d808224c12fd0e9104aeff7c45c9a7.tar.xz
musl-3a3c813e08d808224c12fd0e9104aeff7c45c9a7.zip
superh port
Diffstat (limited to 'src/thread/superh')
-rw-r--r--src/thread/superh/__set_thread_area.s5
-rw-r--r--src/thread/superh/__unmapself.s22
-rw-r--r--src/thread/superh/clone.s47
-rw-r--r--src/thread/superh/syscall_cp.s39
4 files changed, 113 insertions, 0 deletions
diff --git a/src/thread/superh/__set_thread_area.s b/src/thread/superh/__set_thread_area.s
new file mode 100644
index 00000000..53887e64
--- /dev/null
+++ b/src/thread/superh/__set_thread_area.s
@@ -0,0 +1,5 @@
+.global __set_thread_area
+.type   __set_thread_area, @function
+__set_thread_area:
+	rts
+	 ldc r4, gbr
diff --git a/src/thread/superh/__unmapself.s b/src/thread/superh/__unmapself.s
new file mode 100644
index 00000000..b34c3c80
--- /dev/null
+++ b/src/thread/superh/__unmapself.s
@@ -0,0 +1,22 @@
+.text
+.global __unmapself
+.type   __unmapself, @function
+__unmapself:
+	mov   #91, r3  ! SYS_munmap
+	trapa #18
+
+	or    r0, r0
+	or    r0, r0
+	or    r0, r0
+	or    r0, r0
+	or    r0, r0
+
+	mov   #1, r3   ! SYS_exit
+	mov   #0, r4
+	trapa #17
+
+	or    r0, r0
+	or    r0, r0
+	or    r0, r0
+	or    r0, r0
+	or    r0, r0
diff --git a/src/thread/superh/clone.s b/src/thread/superh/clone.s
new file mode 100644
index 00000000..d6c9184d
--- /dev/null
+++ b/src/thread/superh/clone.s
@@ -0,0 +1,47 @@
+.text
+.global __clone
+.type   __clone, @function
+__clone:
+! incoming: fn stack flags arg ptid tls      ctid
+!           r4 r5    r6    r7  @r15 @(4,r15) @(8,r15)
+
+	mov   #-16, r0
+	and   r0, r5
+
+	mov   r4, r1         ! r1 = fn
+	mov   r7, r2         ! r2 = arg
+
+	mov   #120,     r3   ! r3 = __NR_clone
+	mov   r6,       r4   ! r4 = flags
+	!mov  r5,       r5   ! r5 = stack
+	mov.l @r15,     r6   ! r6 = ptid
+	mov.l @(8,r15), r7   ! r7 = ctid
+	mov.l @(4,r15), r0   ! r0 = tls
+	trapa #21
+
+	or r0, r0
+	or r0, r0
+	or r0, r0
+	or r0, r0
+	or r0, r0
+
+	cmp/eq #0, r0
+	bt     1f
+
+	! we are the parent, return
+	rts
+	 nop
+
+1:	! we are the child, call fn(arg)
+	jsr    @r1
+	 mov   r2, r4
+
+	mov   #1, r3   ! __NR_exit
+	mov   r0, r4
+	trapa #17
+
+	or   r0, r0
+	or   r0, r0
+	or   r0, r0
+	or   r0, r0
+	or   r0, r0
diff --git a/src/thread/superh/syscall_cp.s b/src/thread/superh/syscall_cp.s
new file mode 100644
index 00000000..5677b9c0
--- /dev/null
+++ b/src/thread/superh/syscall_cp.s
@@ -0,0 +1,39 @@
+.text
+.global __syscall_cp_asm
+.type   __syscall_cp_asm, @function
+__syscall_cp_asm:
+
+.global __cp_begin
+__cp_begin:
+	mov.l @r4, r4
+	tst   r4, r4
+	bt    2f
+
+	mov.l L1, r0
+	braf  r0
+	 nop
+1:
+
+.align 2
+L1:	.long __cancel@PLT-(1b-.)
+
+2:	mov   r5, r3
+	mov   r6, r4
+	mov   r7, r5
+	mov.l @r15, r6
+	mov.l @(4,r15), r7
+	mov.l @(8,r15), r0
+	mov.l @(12,r15), r1
+	trapa #22
+
+.global __cp_end
+__cp_end:
+	! work around hardware bug
+	or   r0, r0
+	or   r0, r0
+	or   r0, r0
+	or   r0, r0
+	or   r0, r0
+
+	rts
+	 nop