summaryrefslogtreecommitdiff
path: root/kc/core/cpu/cpu_thread.S
blob: c4d04e184297bc4da420dcb4f7dd516a775f2b1a (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
.section .text

.extern arch_terminate_thread

.global arch_begin_thread
arch_begin_thread:
	movq %rdi, %rax
	movq %rsi, %rdi
	pushq %rdx
	pushq %rbp
	movq %rsp, %rbp
	andq $-16, %rsp
	callq *%rax
	movq %rax, %rdi
	movq 8(%rbp), %rsi
	callq arch_terminate_thread

.global arch_swap_thread_stack
arch_swap_thread_stack:
	pushq %rsp
	pushq %rbp
	pushq %rax
	pushq %rbx
	pushq %rcx
	pushq %rdx
	pushq %rdi
	pushq %rsi
	pushq %r8
	pushq %r9
	pushq %r10
	pushq %r11
	pushq %r12
	pushq %r13
	pushq %r14
	pushq %r15
	movq %rsp, (%rdi)
	.Lenter_thread:
	movq %rsi, %rsp
	popq %r15
	popq %r14
	popq %r13
	popq %r12
	popq %r11
	popq %r10
	popq %r9
	popq %r8
	popq %rsi
	popq %rdi
	popq %rdx
	popq %rcx
	popq %rbx
	popq %rax
	popq %rbp
	popq %rsp
	retq