about summary refs log tree commit diff
path: root/src/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/x32/__set_thread_area.s10
-rw-r--r--src/thread/x32/__unmapself.s10
-rw-r--r--src/thread/x32/clone.s27
-rw-r--r--src/thread/x32/syscall_cp.s23
4 files changed, 70 insertions, 0 deletions
diff --git a/src/thread/x32/__set_thread_area.s b/src/thread/x32/__set_thread_area.s
new file mode 100644
index 00000000..f3ff4f61
--- /dev/null
+++ b/src/thread/x32/__set_thread_area.s
@@ -0,0 +1,10 @@
+/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
+.text
+.global __set_thread_area
+.type __set_thread_area,@function
+__set_thread_area:
+	mov %rdi,%rsi           /* shift for syscall */
+	movl $0x1002,%edi       /* SET_FS register */
+	movl $158,%eax          /* set fs segment to */
+	syscall                 /* arch_prctl(SET_FS, arg)*/
+	ret
diff --git a/src/thread/x32/__unmapself.s b/src/thread/x32/__unmapself.s
new file mode 100644
index 00000000..e2689e65
--- /dev/null
+++ b/src/thread/x32/__unmapself.s
@@ -0,0 +1,10 @@
+/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
+.text
+.global __unmapself
+.type   __unmapself,@function
+__unmapself:
+	movl $11,%eax   /* SYS_munmap */
+	syscall         /* munmap(arg2,arg3) */
+	xor %rdi,%rdi   /* exit() args: always return success */
+	movl $60,%eax   /* SYS_exit */
+	syscall         /* exit(0) */
diff --git a/src/thread/x32/clone.s b/src/thread/x32/clone.s
new file mode 100644
index 00000000..ee59903a
--- /dev/null
+++ b/src/thread/x32/clone.s
@@ -0,0 +1,27 @@
+.text
+.global __clone
+.type   __clone,@function
+__clone:
+	xor %eax,%eax
+	mov $56,%al
+	mov %rdi,%r11
+	mov %rdx,%rdi
+	mov %r8,%rdx
+	mov %r9,%r8
+	mov 8(%rsp),%r10
+	mov %r11,%r9
+	and $-16,%rsi
+	sub $8,%rsi
+	mov %rcx,(%rsi)
+	syscall
+	test %eax,%eax
+	jnz 1f
+	xor %ebp,%ebp
+	pop %rdi
+	call *%r9
+	mov %eax,%edi
+	xor %eax,%eax
+	mov $60,%al
+	syscall
+	hlt
+1:	ret
diff --git a/src/thread/x32/syscall_cp.s b/src/thread/x32/syscall_cp.s
new file mode 100644
index 00000000..788c53cc
--- /dev/null
+++ b/src/thread/x32/syscall_cp.s
@@ -0,0 +1,23 @@
+.text
+.global __syscall_cp_asm
+.type   __syscall_cp_asm,@function
+__syscall_cp_asm:
+
+.global __cp_begin
+__cp_begin:
+	mov (%rdi),%eax
+	test %eax,%eax
+	jnz __cancel
+	mov %rdi,%r11
+	mov %rsi,%rax
+	mov %rdx,%rdi
+	mov %rcx,%rsi
+	mov %r8,%rdx
+	mov %r9,%r10
+	mov 8(%rsp),%r8
+	mov 16(%rsp),%r9
+	mov %r11,8(%rsp)
+	syscall
+.global __cp_end
+__cp_end:
+	ret