mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2025-12-17 20:34:36 +03:00
lesson 14
This commit is contained in:
1
14-checkpoint/boot/32bit_print.asm
Symbolic link
1
14-checkpoint/boot/32bit_print.asm
Symbolic link
@@ -0,0 +1 @@
|
||||
../../08-32bit-print/32bit-print.asm
|
||||
51
14-checkpoint/boot/bootsect.asm
Normal file
51
14-checkpoint/boot/bootsect.asm
Normal file
@@ -0,0 +1,51 @@
|
||||
; Identical to lesson 13's boot sector, but the %included files have new paths
|
||||
[org 0x7c00]
|
||||
KERNEL_OFFSET equ 0x1000 ; The same one we used when linking the kernel
|
||||
|
||||
mov [BOOT_DRIVE], dl ; Remember that the BIOS sets us the boot drive in 'dl' on boot
|
||||
mov bp, 0x9000
|
||||
mov sp, bp
|
||||
|
||||
mov bx, MSG_REAL_MODE
|
||||
call print
|
||||
call print_nl
|
||||
|
||||
call load_kernel ; read the kernel from disk
|
||||
call switch_to_pm ; disable interrupts, load GDT, etc. Finally jumps to 'BEGIN_PM'
|
||||
jmp $ ; Never executed
|
||||
|
||||
%include "boot/print.asm"
|
||||
%include "boot/print_hex.asm"
|
||||
%include "boot/disk.asm"
|
||||
%include "boot/gdt.asm"
|
||||
%include "boot/32bit_print.asm"
|
||||
%include "boot/switch_pm.asm"
|
||||
|
||||
[bits 16]
|
||||
load_kernel:
|
||||
mov bx, MSG_LOAD_KERNEL
|
||||
call print
|
||||
call print_nl
|
||||
|
||||
mov bx, KERNEL_OFFSET ; Read from disk and store in 0x1000
|
||||
mov dh, 2
|
||||
mov dl, [BOOT_DRIVE]
|
||||
call disk_load
|
||||
ret
|
||||
|
||||
[bits 32]
|
||||
BEGIN_PM:
|
||||
mov ebx, MSG_PROT_MODE
|
||||
call print_string_pm
|
||||
call KERNEL_OFFSET ; Give control to the kernel
|
||||
jmp $ ; Stay here when the kernel returns control to us (if ever)
|
||||
|
||||
|
||||
BOOT_DRIVE db 0 ; It is a good idea to store it in memory because 'dl' may get overwritten
|
||||
MSG_REAL_MODE db "Started in 16-bit Real Mode", 0
|
||||
MSG_PROT_MODE db "Landed in 32-bit Protected Mode", 0
|
||||
MSG_LOAD_KERNEL db "Loading kernel into memory", 0
|
||||
|
||||
; padding
|
||||
times 510 - ($-$$) db 0
|
||||
dw 0xaa55
|
||||
BIN
14-checkpoint/boot/bootsect.bin
Normal file
BIN
14-checkpoint/boot/bootsect.bin
Normal file
Binary file not shown.
1
14-checkpoint/boot/disk.asm
Symbolic link
1
14-checkpoint/boot/disk.asm
Symbolic link
@@ -0,0 +1 @@
|
||||
../../07-bootsector-disk/boot_sect_disk.asm
|
||||
1
14-checkpoint/boot/gdt.asm
Symbolic link
1
14-checkpoint/boot/gdt.asm
Symbolic link
@@ -0,0 +1 @@
|
||||
../../09-32bit-gdt/32bit-gdt.asm
|
||||
1
14-checkpoint/boot/kernel_entry.asm
Symbolic link
1
14-checkpoint/boot/kernel_entry.asm
Symbolic link
@@ -0,0 +1 @@
|
||||
../../13-kernel-barebones/kernel_entry.asm
|
||||
BIN
14-checkpoint/boot/kernel_entry.o
Normal file
BIN
14-checkpoint/boot/kernel_entry.o
Normal file
Binary file not shown.
1
14-checkpoint/boot/switch_pm.asm
Symbolic link
1
14-checkpoint/boot/switch_pm.asm
Symbolic link
@@ -0,0 +1 @@
|
||||
../../10-32bit-enter/32bit-switch.asm
|
||||
Reference in New Issue
Block a user