-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot_main.asm
More file actions
54 lines (40 loc) · 1.4 KB
/
boot_main.asm
File metadata and controls
54 lines (40 loc) · 1.4 KB
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
[org 0x7e00] ; this is from second sector
section .text
mov bp, 0x9000 ; set stack
mov sp, bp
mov bx, IN_REAL_MODE_MESSAGE
call print_16
call switch_to_pm ; this function call switches to 32 bit protected mode
jmp $
%include "./utilities/print_16.asm"
%include "./utilities/hex_print.asm"
%include "./utilities/disk_load.asm"
%include "./utilities/print_32.asm"
%include "gdt.asm"
%include "gdt64.asm"
%include "switch_to_pm.asm"
%include "./utilities/error.asm"
%include "./utilities/check_64.asm"
%include "paging.asm"
%include "init64.asm"
[bits 32]
BEGIN_PM:
; in 32 bit protected mode now, but need to move to 64 bit long mode
; Move to 64 bit and then call KERNEL_OFFSET
; call check_multiboot ; disable this if you are testing in qemu
call check_cpuid
call check_long_mode
mov ebx, CHANGING_TO_64_BIT
call print_32
call setup_page_tables
call enable_paging ; after paging enabled, the CPU is in 64 bit mode
lgdt [gdt64.pointer]
jmp gdt64.code:start_os_64
; These are declared to be global
IN_PROT_MODE_MESSAGE db "This is in protected mode now", 0
IN_REAL_MODE_MESSAGE db "This is in real mode now", 0
CHANGING_TO_64_BIT db "Xhanged from 32 bit to 64 bit! Boot is now complete ...", 0
LOADING_C_KERNEL db "Loading C kernel into memory at 0x8001", 0
times 1024 - ($-$$) db 0
%include "bss.asm"
; https://pdos.csail.mit.edu/6.828/2005/readings/i386/s05_01.htm