blob: 20e4a96a6dcbe064ddc99f719e7ffdb506fa4cdc [file] [log] [blame]
Jeff Dike54ae36f2007-10-16 01:27:33 -07001#include "as-layout.h"
Jeff Diked67b5692005-07-07 17:56:49 -07002
3 .globl syscall_stub
Amerigo Wang276c9742009-06-16 15:33:30 -07004.section .__syscall_stub, "ax"
Jeff Diked67b5692005-07-07 17:56:49 -07005syscall_stub:
6 syscall
7 /* We don't have 64-bit constants, so this constructs the address
8 * we need.
9 */
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080010 movq $(STUB_DATA >> 32), %rbx
Jeff Diked67b5692005-07-07 17:56:49 -070011 salq $32, %rbx
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080012 movq $(STUB_DATA & 0xffffffff), %rcx
Jeff Diked67b5692005-07-07 17:56:49 -070013 or %rcx, %rbx
14 movq %rax, (%rbx)
15 int3
Jeff Dikec5600492005-09-03 15:57:36 -070016
17 .globl batch_syscall_stub
18batch_syscall_stub:
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080019 mov $(STUB_DATA >> 32), %rbx
Bodo Stroesser07bf7312005-09-03 15:57:50 -070020 sal $32, %rbx
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080021 mov $(STUB_DATA & 0xffffffff), %rax
Bodo Stroesser07bf7312005-09-03 15:57:50 -070022 or %rax, %rbx
23 /* load pointer to first operation */
24 mov %rbx, %rsp
25 add $0x10, %rsp
26again:
27 /* load length of additional data */
28 mov 0x0(%rsp), %rax
29
30 /* if(length == 0) : end of list */
31 /* write possible 0 to header */
32 mov %rax, 8(%rbx)
33 cmp $0, %rax
34 jz done
35
36 /* save current pointer */
37 mov %rsp, 8(%rbx)
38
39 /* skip additional data */
40 add %rax, %rsp
41
42 /* load syscall-# */
43 pop %rax
44
45 /* load syscall params */
Jeff Dikec5600492005-09-03 15:57:36 -070046 pop %rdi
47 pop %rsi
48 pop %rdx
49 pop %r10
50 pop %r8
51 pop %r9
Bodo Stroesser07bf7312005-09-03 15:57:50 -070052
53 /* execute syscall */
Jeff Dikec5600492005-09-03 15:57:36 -070054 syscall
Bodo Stroesser07bf7312005-09-03 15:57:50 -070055
56 /* check return value */
57 pop %rcx
58 cmp %rcx, %rax
59 je again
60
61done:
62 /* save return value */
Jeff Dikec5600492005-09-03 15:57:36 -070063 mov %rax, (%rbx)
Bodo Stroesser07bf7312005-09-03 15:57:50 -070064
65 /* stop */
66 int3