More debugging for VMs.
[akaros.git] / kern / arch / x86 / ros / syscall32.h
1 #ifndef ROS_INC_ARCH_SYSCALL32_H
2 #define ROS_INC_ARCH_SYSCALL32_H
3
4 #ifndef ROS_INC_ARCH_SYSCALL_H
5 #error "Do not include include ros/arch/syscall32.h directly"
6 #endif
7
8 #define T_SYSCALL       0x80
9
10 #ifndef ROS_KERNEL
11
12 #include <sys/types.h>
13 #include <stdint.h>
14 #include <ros/common.h>
15 #include <assert.h>
16
17 static inline intreg_t __syscall_sysenter(uintreg_t a0, uintreg_t a1)
18 {
19         /* The kernel clobbers ecx, so we save it manually. */
20         intreg_t ret = 0;
21         asm volatile ("  pushl %%ecx;        "
22                       "  pushl %%edx;        "
23                       "  pushl %%ebp;        "
24                       "  movl %%esp, %%ebp;  "
25                       "  leal 1f, %%edx;     "
26                       "  sysenter;           "
27                       "1:                    "
28                       "  popl %%ebp;         "
29                       "  popl %%edx;         "
30                       "  popl %%ecx;         "
31                       : "=a" (ret)
32                       : "a" (a0),
33                         "S" (a1)
34                       : "cc", "memory");
35         return ret;
36 }
37
38 static inline intreg_t __syscall_trap(uintreg_t a0, uintreg_t a1)
39 {
40         intreg_t ret;
41
42         /* If you change this, change pop_user_ctx() */
43         asm volatile("int %1"
44                      : "=a" (ret)
45                      : "i" (T_SYSCALL),
46                        "a" (a0),
47                        "d" (a1)
48                      : "cc", "memory");
49         return ret;
50 }
51
52 #endif
53
54 #endif /* ROS_INC_ARCH_SYSCALL32_H */