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
|
.section .stack, "aw", @nobits
.align 16
.global stack_top
stack_bottom: .skip 1 << 20
stack_top:
stack_size = stack_top - stack_bottom
.section .bss, "aw", @nobits
//! A structure containing information gathered during the bootstrap process.
//! Expected layout (as described by teachos::boot::information):
//!
//! struct
//! {
//! multiboot2::information_view const * mbi;
//! std::size_t vga_buffer_index;
//! }
.global bootstrap_information
bootstrap_information: .skip 16
.section .boot_text, "ax", @progbits
.code64
.global _entry64
_entry64:
mov $global_descriptor_table_data, %rax
mov %rax, %ss
mov %rax, %ds
mov %rax, %es
mov %rax, %fs
mov %rax, %gs
mov $stack_top, %rsp
mov %rsp, %rbp
mov multiboot_information_pointer, %rax
or $TEACHOS_VMA, %rax
mov vga_buffer_pointer, %rdx
sub $0xb8000, %rdx
mov %rax, (bootstrap_information)
mov %rdx, (bootstrap_information + 8)
call invoke_global_constructors
xor %rax, %rax
mov %rax, %rbp
mov %rax, %rdx
mov %rax, %rsi
mov $stack_size, %rcx
shr $3, %rcx
lea (stack_bottom), %rdi
rep stosq
mov %rax, %rdi
call main
1:
hlt
jmp 1b
|