2023-11-09 22:42:47 +02:00
|
|
|
.code16
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
#
|
|
|
|
# STAGE 1 BOOTLOADER
|
|
|
|
#
|
|
|
|
# its sole purpose is to load stage2 from
|
|
|
|
# bios boot partition
|
|
|
|
#
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
.section .stage1
|
|
|
|
|
2023-11-14 03:26:03 +02:00
|
|
|
.global stage1_main
|
2023-11-11 22:49:00 +02:00
|
|
|
stage1_main:
|
2023-11-09 22:42:47 +02:00
|
|
|
# setup segments
|
|
|
|
movw $0, %ax
|
|
|
|
movw %ax, %ds
|
|
|
|
movw %ax, %es
|
|
|
|
|
|
|
|
# setup stack
|
|
|
|
movw %ax, %ss
|
2023-11-13 18:55:48 +02:00
|
|
|
movl $0x7C00, %esp
|
2023-11-09 22:42:47 +02:00
|
|
|
|
|
|
|
# save boot disk number
|
2023-11-14 03:26:03 +02:00
|
|
|
call read_stage2_into_memory
|
2023-11-13 18:55:48 +02:00
|
|
|
|
2023-11-11 22:49:00 +02:00
|
|
|
jmp stage2_main
|
2023-11-09 22:42:47 +02:00
|
|
|
|
2023-11-14 03:26:03 +02:00
|
|
|
.global print_and_halt
|
2023-11-09 22:42:47 +02:00
|
|
|
print_and_halt:
|
|
|
|
call puts
|
|
|
|
halt:
|
|
|
|
hlt
|
|
|
|
jmp halt
|
|
|
|
|
|
|
|
|
|
|
|
#########################################
|
|
|
|
#
|
|
|
|
# STAGE 2 BOOTLOADER
|
|
|
|
#
|
|
|
|
#########################################
|
|
|
|
|
|
|
|
.section .stage2
|
2023-11-11 22:49:00 +02:00
|
|
|
|
2023-11-13 18:55:48 +02:00
|
|
|
stage2_main:
|
|
|
|
# clear screen and enter 80x25 text mode
|
|
|
|
movb $0x03, %al
|
|
|
|
movb $0x00, %ah
|
|
|
|
int $0x10
|
|
|
|
|
|
|
|
# print hello message
|
|
|
|
movw $hello_msg, %si
|
|
|
|
call puts; call print_newline
|
|
|
|
|
|
|
|
call get_memory_map
|
2023-11-14 03:26:03 +02:00
|
|
|
call read_user_command_line
|
2023-11-13 18:55:48 +02:00
|
|
|
|
|
|
|
call print_newline
|
|
|
|
|
|
|
|
movw $start_kernel_load_msg, %si
|
|
|
|
call puts; call print_newline
|
|
|
|
|
|
|
|
call print_memory_map
|
|
|
|
|
|
|
|
call find_root_disk
|
|
|
|
call find_root_partition
|
|
|
|
|
2023-11-14 03:26:03 +02:00
|
|
|
call print_root_partition_info
|
2023-11-15 16:36:53 +02:00
|
|
|
call print_newline
|
|
|
|
|
|
|
|
call has_ext2_filesystem
|
|
|
|
testb %al, %al
|
|
|
|
jz print_and_halt
|
|
|
|
|
|
|
|
call ext2_find_kernel
|
2023-11-11 22:49:00 +02:00
|
|
|
|
|
|
|
jmp halt
|
2023-11-09 22:42:47 +02:00
|
|
|
|
|
|
|
hello_msg:
|
|
|
|
.asciz "This is banan-os bootloader"
|
|
|
|
|
2023-11-11 22:49:00 +02:00
|
|
|
start_kernel_load_msg:
|
|
|
|
.asciz "Starting to load kernel"
|