x86: reorganizes IRQ/trap vectors (XCC)
[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 #ifndef ROS_KERNEL
9
10 #include <sys/types.h>
11 #include <stdint.h>
12 #include <ros/common.h>
13 #include <assert.h>
14
15 static inline intreg_t __syscall_sysenter(uintreg_t a0, uintreg_t a1)
16 {
17         /* The kernel clobbers ecx, so we save it manually. */
18         intreg_t ret = 0;
19         asm volatile ("  pushl %%ecx;        "
20                       "  pushl %%edx;        "
21                       "  pushl %%ebp;        "
22                       "  movl %%esp, %%ebp;  "
23                       "  leal 1f, %%edx;     "
24                       "  sysenter;           "
25                       "1:                    "
26                       "  popl %%ebp;         "
27                       "  popl %%edx;         "
28                       "  popl %%ecx;         "
29                       : "=a" (ret)
30                       : "a" (a0),
31                         "S" (a1)
32                       : "cc", "memory");
33         return ret;
34 }
35
36 static inline intreg_t __syscall_trap(uintreg_t a0, uintreg_t a1)
37 {
38         intreg_t ret;
39
40         /* If you change this, change pop_user_ctx() */
41         asm volatile("int %1"
42                      : "=a" (ret)
43                      : "i" (T_SYSCALL),
44                        "a" (a0),
45                        "d" (a1)
46                      : "cc", "memory");
47         return ret;
48 }
49
50 #endif
51
52 #endif /* ROS_INC_ARCH_SYSCALL32_H */