summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/boot64.S
blob: f7ec60e1eac7ca09be8a8bb8e07f264e57e705d1 (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
.global boot64
boot64:
	lgdt (GdtPointer) // try reloading gdt again
	mov $(6 << 3 | 3), %ax // SEG_TSS
	ltr %ax

	push %rdi // preserve multiboot struct
	call sysenter_setup
	pop %rdi

	// multiboot struct in %rdi
	jmp kmain_early


.section .shared
/* https://wiki.osdev.org/Task_State_Segment#Long_Mode */
.global TSS
.align 8
TSS:
	.4byte 0 /* reserved */
	.rept 3
	.8byte _isr_mini_stack /* stacks for privilege level changes */
	.endr
	.8byte 0 /* reserved */
	.rept 7
	.8byte _isr_mini_stack /* IST - stack pointer loaded for interrupts */
	.endr
	.8byte 0 /* reserved */
	.4byte 0 /* reserved + IOPB (unused) */
	.if . - TSS != 104
		.error "bad tss size"
		.abort
	.endif