summaryrefslogtreecommitdiff
path: root/arch/x64/linux/syscall.S
blob: 9261d8731e3c0b06bf23df3a95d9d419649cbef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
The kernel uses the following registers:
%rdi, %rsi, %rdx, %r8, %r9, %r10

The number of the syscall is passed in %rax.

A syscall clobbers:
%rax, %rcx, %r11

The returned value is placed in %rax.
*/
	.text

	.globl syscall1
	.type syscall1, @function

syscall1:
	movq %rsi, %rax // Syscall number.

	syscall

	ret


	.globl syscall2
	.type syscall2, @function

syscall2:
	// Store registers.
	movq %rdi, %r8

	movq %rdx, %rax // Syscall number.

	// Syscall arguments.
	movq %rsi, %rdi
	movq %r8, %rsi

	syscall

	// Restore registers.
	movq %rdi, %rsi
	movq %r8, %rdi

	ret


	.globl syscall3
	.type syscall3, @function

syscall3:
	// Store registers.
	movq %rdi, %r8

	movq %rcx, %rax // Syscall number.

	// Syscall arguments.
	movq %rdx, %rdi
	movq %r8, %rdx

	syscall

	// Restore registers.
	movq %r8, %rdi

	ret