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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
;; /*
;; * ========================================================
;; *
;; * ZKA
;; * Copyright (C) 2024, Theater Quality Corp, all rights reserved., all rights reserved.
;; *
;; * ========================================================
;; */
section .text
extern rt_wait_400ns
global rt_out8
global rt_out16
global rt_out32
global rt_in8
global rt_in16
global rt_in32
rt_out8:
mov al, dl
mov dx, cx
out dx, al
ret
rt_out16:
mov ax, dx
mov dx, cx
out dx, ax
ret
rt_out32:
mov eax, edx
mov edx, ecx
out dx, eax
ret
rt_in8:
mov dx, cx
in al, dx
ret
rt_in16:
mov edx, ecx
in ax, dx
ret
rt_in32:
mov rdx, rcx
in eax, dx
ret
extern hal_system_call_enter
global mp_system_call_handler
mp_system_call_handler:
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
jmp hal_system_call_enter
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
o64 sysret
[bits 16]
section .text
global hal_ap_start
hal_ap_start:
mov ax, 0x0
mov ss, ax
mov esp, 0x7000
cli
mov eax, cr0
or eax, 1
mov cr0, eax
jmp .flush
.flush:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
mov eax, cr3
mov cr3, eax
mov ecx, 0xC0000080
rdmsr
or eax, 1
wrmsr
mov eax, cr0
or eax, (1 << 31)
mov cr0, eax
jmp 0x08:hal_ap_64bit_entry
[bits 64]
; 64-bit entry point
section .text
global hal_ap_64bit_entry
hal_ap_64bit_entry:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov rsp, 0x8001000 ; Stack Address for scheduler AP.
jmp hal_ap_64bit_entry_loop
hal_ap_64bit_entry_loop:
jmp $
|