19b21423fe3c3a0425603299f1c904e7d4512c47
[reactos.git] / include / asm / syscalls.inc
1
2 #ifdef _M_IX86
3 EXTERN _KiSystemService:PROC
4 #define KUSER_SHARED_SYSCALL HEX(7ffe0300)
5 #define KGDT_R0_CODE 8
6 MACRO(STUBCODE_U, SyscallId, StackBytes)
7 mov eax, SyscallId
8 mov ecx, KUSER_SHARED_SYSCALL
9 call dword ptr [ecx]
10 ret StackBytes
11 ENDM
12 MACRO(STUBCODE_K, SyscallId, StackBytes)
13 mov eax, SyscallId
14 lea edx, [esp + 4]
15 pushf
16 push KGDT_R0_CODE
17 call _KiSystemService
18 ret StackBytes
19 ENDM
20 #elif defined(_M_AMD64)
21 EXTERN KiSystemService:PROC
22 MACRO(STUBCODE_U, SyscallId, StackBytes)
23 mov eax, SyscallId
24 mov r10, rcx
25 syscall
26 ret StackBytes
27 ENDM
28 MACRO(STUBCODE_K, SyscallId, StackBytes)
29 mov eax, SyscallId
30 call KiSystemService
31 ret StackBytes
32 ENDM
33 #elif defined(_M_ARM)
34 MACRO(STUBCODE_U, SyscallId, StackBytes)
35 swi #SyscallId
36 bx lr
37 ENDM
38 MACRO(STUBCODE_K, SyscallId, StackBytes)
39 mov ip, lr
40 swi #SyscallId
41 bx ip
42 ENDM
43 #elif defined(_M_PPC)
44 MACRO(STUBCODE_U, SyscallId, StackBytes)
45 stwu 1,-16(1)
46 mflr 0
47 stw 0,0(1)
48 li 0, SyscallId
49 sc
50 lwz 0,0(1)
51 mtlr 0
52 addi 1,1,16
53 blr
54 ENDM
55 #define STUBCODE_K STUBCODE_U
56 #elif defined(_M_MIPS)
57 MACRO(STUBCODE_U, SyscallId, StackBytes)
58 li $8, KUSER_SHARED_SYSCALL
59 lw $8,0($8)
60 j $8
61 nop
62 ENDM
63 MACRO(STUBCODE_K, SyscallId, StackBytes)
64 j KiSystemService
65 nop
66 ENDM
67 #else
68 #error unsupported architecture
69 #endif
70
71 #ifdef _M_IX86
72 MACRO(MAKE_LABEL, Name, Stackbytes)
73 PUBLIC _&Name&@&Stackbytes
74 _&Name&@&Stackbytes:
75 ENDM
76 #else
77 MACRO(MAKE_LABEL, Name, Stackbytes)
78 PUBLIC &Name
79 &Name:
80 ENDM
81 #endif
82
83 MACRO(STUB_U, Name, ArgCount)
84 Stackbytes = 4 * &ArgCount
85 MAKE_LABEL Zw&Name, %Stackbytes
86 MAKE_LABEL Nt&Name, %Stackbytes
87 STUBCODE_U SyscallId, %Stackbytes
88 SyscallId = SyscallId + 1
89 ENDM
90
91 MACRO(STUB_K, Name, ArgCount)
92 Stackbytes = 4 * &ArgCount
93 MAKE_LABEL Zw&Name, %Stackbytes
94 STUBCODE_K SyscallId, %Stackbytes
95 SyscallId = SyscallId + 1
96 ENDM