summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootloader.asm13
-rwxr-xr-xbuild_helpers/compile.sh14
2 files changed, 19 insertions, 8 deletions
diff --git a/bootloader.asm b/bootloader.asm
index c9ed98b..7d218eb 100644
--- a/bootloader.asm
+++ b/bootloader.asm
@@ -13,7 +13,7 @@ start:
call verify_read
mov si, READ_NERR
call write_str
- jmp 0x7e00
+ jmp word [0x7dfc]
jmp hang
read_err:
@@ -23,17 +23,18 @@ hang:
jmp hang
verify_read:
+ mov bx, word [0x7dfc]
mov al, 0x66
- cmp al, [0x7e00]
+ cmp al, byte [bx]
jne read_err
mov al, 0x55
- cmp al, [0x7e01]
+ cmp al, byte [bx+1]
jne read_err
mov al, 0x66
- cmp al, [0x7e02]
+ cmp al, byte [bx+2]
jne read_err
mov al, 0x89
- cmp al, [0x7e03]
+ cmp al, byte [bx+3]
jne read_err
ret
@@ -106,7 +107,7 @@ LBA_DISK_READ_PACKET:
db 0x10
db 0
dw 32 ; number of blocks to read, reset to # actually read when done
- dw 0x7e00 ; read destination address
+ dw 0x7dfc ; read destination address
dw 0x0000
dd 1 ; lba to read from
dd 0 ; for extended lba adresses (not really used here)
diff --git a/build_helpers/compile.sh b/build_helpers/compile.sh
index 40cd293..f00549f 100755
--- a/build_helpers/compile.sh
+++ b/build_helpers/compile.sh
@@ -10,8 +10,18 @@ OUTNAME="src._kernel._main"
echo -n "[*] Building '$INPATH' to 'tmp/$OUTNAME'... "
gcc -T linker.ld -m32 -Wl,--build-id=none -nostartfiles -nostdlib -ffreestanding $INPATH -o "tmp/$OUTNAME".o
echo " OK!"
+echo -n "[+] Start address is... "
+BIN_START=$(objdump tmp/src._kernel._main.o -f | grep start | cut -b 15-)
+echo "$BIN_START"
+# this actually writes three extra nulls, not sure why...
+echo "$BIN_START" | xxd -r - | od -t x --endian=little | head | xxd -r - > "bin/$OUTNAME".bin
echo -n "[+] Stripping unnecessary sections... "
-objcopy -R .note.gnu.build-id -R .comment -O binary "tmp/$OUTNAME".o "bin/$OUTNAME".bin
+objcopy -R .note.gnu.build-id -R .comment -O binary "tmp/$OUTNAME".o "tmp/converted_$OUTNAME".bin
echo " OK!"
-rm "tmp/$OUTNAME".o
+
+echo -n "[+] Joining kernel and start address... "
+# adjust for the three extra nulls above
+dd if="tmp/converted_$OUTNAME".bin of="bin/$OUTNAME".bin seek=4 oflag=seek_bytes conv=notrunc 2>/dev/null
+echo " OK!"
+#rm "tmp/$OUTNAME".o