summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-15 21:24:36 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-15 21:24:36 +0200
commitf8dd9dd71ab603af23e008f1147f652b429c9296 (patch)
tree316bbf3585b9baeb55ca2b870e7be4724ce4936c /src/boot
parent48f0fe5954a445ba890b6a3633bbbf46cddd07c9 (diff)
downloadabaos-f8dd9dd71ab603af23e008f1147f652b429c9296.tar.gz
abaos-f8dd9dd71ab603af23e008f1147f652b429c9296.tar.bz2
increased size of stage 2 bootloader by 1024 bytes
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/boot.asm11
-rw-r--r--src/boot/stage1_functions.asm7
-rw-r--r--src/boot/stage2_check_magic.asm10
-rw-r--r--src/boot/stage2_real_functions.asm10
4 files changed, 24 insertions, 14 deletions
diff --git a/src/boot/boot.asm b/src/boot/boot.asm
index c3cb57e..75ad05e 100644
--- a/src/boot/boot.asm
+++ b/src/boot/boot.asm
@@ -106,7 +106,7 @@ stage2:
call print_string
-; load kernel to 0x8400 (directly after stage 2
+; load kernel to 0x8800 (directly after stage 2
; of the boot loader)
mov dl, [BOOT_DRIVE]
call read_from_disk
@@ -220,8 +220,11 @@ MESSAGE_HALTED:
%include "boot/stage2_check_magic.asm"
; make sure we have full sectors, stage 1 is 512 bytes, so we
-; have to will up 3 sectors
-times 2048-($-$$) db 0
+; have to will up 5 sectors (gives 6 in total for stage 1 and 2)
+times 3070-($-$$) db 0
-; position is 0x8400 now for the C entry
+; magic number of stage 2
+dw 0xAABB
+
+; position is 0x8800 now for the C entry
kernel_main:
diff --git a/src/boot/stage1_functions.asm b/src/boot/stage1_functions.asm
index bdb2aac..f1d229b 100644
--- a/src/boot/stage1_functions.asm
+++ b/src/boot/stage1_functions.asm
@@ -1,3 +1,6 @@
+; NOF_SECTORS_STAGE2
+NOF_SECTORS_STAGE2 equ 5
+
; IN dx: hex value to print
print_hex:
push bx
@@ -88,7 +91,7 @@ current_row:
read_stage2_from_disk:
mov ah, 0x02 ; read sectors from drive
- mov al, 3 ; read 3 sectors of stage 2
+ mov al, NOF_SECTORS_STAGE2 ; read sectors of stage 2
mov ch, 0 ; select first cylinder
mov dh, 0 ; first head
mov cl, 2 ; second sector after boot sector
@@ -101,7 +104,7 @@ read_stage2_from_disk:
jc .read_error
- cmp al, 3 ; 3 sectors read?
+ cmp al, NOF_SECTORS_STAGE2 ; correct number of sectors read?
jne .short_read ; if not, short read
ret
diff --git a/src/boot/stage2_check_magic.asm b/src/boot/stage2_check_magic.asm
index 1deaf05..7339a89 100644
--- a/src/boot/stage2_check_magic.asm
+++ b/src/boot/stage2_check_magic.asm
@@ -8,7 +8,7 @@ check_magic:
push edi
mov eax, NOF_LOAD_SECTORS ; number of 512-byte sectors
shl eax, 9 ; 512 bytes per sector
- mov edx, 0x8400 ; offset of kernel
+ mov edx, 0x8800 ; offset of kernel
add edx, eax
sub edx, MAGICLEN ; subtract the length of the magic string
mov esi, edx ; now use edx as first string address to compare to
@@ -20,12 +20,16 @@ check_magic:
.ok:
mov si, MAGIC_OK_MSG
call pm_print_string
+ mov edx, esi
+ call pm_print_hex
call pm_print_newline
xor eax, eax
jmp .end
.mismatch:
mov si, MAGIC_NOT_OK_MSG
call pm_print_string
+ mov edx, esi
+ call pm_print_hex
call pm_print_newline
xor eax, eax
mov eax, 1
@@ -42,7 +46,7 @@ db "ABAOS", %[MAGIC], 0
MAGICLEN equ $ - COMPARE_MAGIC
MAGIC_NOT_OK_MSG:
-db "Magic signature found", 0
+db "Magic signature found at ", 0
MAGIC_OK_MSG:
-db "Magic signature not found!", 0
+db "Magic signature not found at ", 0
diff --git a/src/boot/stage2_real_functions.asm b/src/boot/stage2_real_functions.asm
index 87642c2..84713d5 100644
--- a/src/boot/stage2_real_functions.asm
+++ b/src/boot/stage2_real_functions.asm
@@ -1,8 +1,8 @@
; number of sectors to be read for the kernel itself
; (note: the first sector gets loaded by the BIOS, the
-; next 3 sectors are read by the simple stage 1 loader,
-; so subtract 3 here!)
-NOF_LOAD_SECTORS equ 44
+; next 5 sectors are read by the simple stage 1 loader,
+; so subtract 5 here!)
+NOF_LOAD_SECTORS equ 42
; data sections used for reading the kernel from disk
SECTORS_PER_CYLINDER:
@@ -13,7 +13,7 @@ NOF_HEADS:
SECTORS_TO_LOAD:
db NOF_LOAD_SECTORS ; load NOF_LOAD_SECTORS sectors in total
CURRENT_SECTOR:
- db 5 ; first sector after stage 2
+ db 7 ; first sector after stage 2
CURRENT_CYLINDER:
db 0
CURRENT_HEAD:
@@ -90,7 +90,7 @@ read_from_disk:
mov bx, 0 ; where to store the data
mov es, bx
- mov bx, 0x8400 ; 2'048 bytes after first sector
+ mov bx, 0x8800 ; 3072 bytes after first sector
.read_next_sector: