blob: 5687687631554dabc7e61719a4a900d8d5f691c1 [file] [log] [blame]
Jeff Diked67b5692005-07-07 17:56:49 -07001#include "uml-config.h"
Jeff Dike54ae36f2007-10-16 01:27:33 -07002#include "as-layout.h"
Jeff Diked67b5692005-07-07 17:56:49 -07003
4 .globl syscall_stub
5.section .__syscall_stub, "x"
6syscall_stub:
7 syscall
8 /* We don't have 64-bit constants, so this constructs the address
9 * we need.
10 */
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080011 movq $(STUB_DATA >> 32), %rbx
Jeff Diked67b5692005-07-07 17:56:49 -070012 salq $32, %rbx
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080013 movq $(STUB_DATA & 0xffffffff), %rcx
Jeff Diked67b5692005-07-07 17:56:49 -070014 or %rcx, %rbx
15 movq %rax, (%rbx)
16 int3
Jeff Dikec5600492005-09-03 15:57:36 -070017
18 .globl batch_syscall_stub
19batch_syscall_stub:
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080020 mov $(STUB_DATA >> 32), %rbx
Bodo Stroesser07bf7312005-09-03 15:57:50 -070021 sal $32, %rbx
Jeff Dike4bdf8bc2008-02-04 22:30:44 -080022 mov $(STUB_DATA & 0xffffffff), %rax
Bodo Stroesser07bf7312005-09-03 15:57:50 -070023 or %rax, %rbx
24 /* load pointer to first operation */
25 mov %rbx, %rsp
26 add $0x10, %rsp
27again:
28 /* load length of additional data */
29 mov 0x0(%rsp), %rax
30
31 /* if(length == 0) : end of list */
32 /* write possible 0 to header */
33 mov %rax, 8(%rbx)
34 cmp $0, %rax
35 jz done
36
37 /* save current pointer */
38 mov %rsp, 8(%rbx)
39
40 /* skip additional data */
41 add %rax, %rsp
42
43 /* load syscall-# */
44 pop %rax
45
46 /* load syscall params */
Jeff Dikec5600492005-09-03 15:57:36 -070047 pop %rdi
48 pop %rsi
49 pop %rdx
50 pop %r10
51 pop %r8
52 pop %r9
Bodo Stroesser07bf7312005-09-03 15:57:50 -070053
54 /* execute syscall */
Jeff Dikec5600492005-09-03 15:57:36 -070055 syscall
Bodo Stroesser07bf7312005-09-03 15:57:50 -070056
57 /* check return value */
58 pop %rcx
59 cmp %rcx, %rax
60 je again
61
62done:
63 /* save return value */
Jeff Dikec5600492005-09-03 15:57:36 -070064 mov %rax, (%rbx)
Bodo Stroesser07bf7312005-09-03 15:57:50 -070065
66 /* stop */
67 int3