Updating bootloader

This commit is contained in:
notsomeidiot123 2025-03-24 23:05:06 -04:00
parent bb4692b00b
commit 6d4f541a01
2 changed files with 24 additions and 51 deletions

View File

@ -8,7 +8,7 @@ OBJS := $(patsubst src/kernel/%.c, bin/kernel/%.o, $(SRCS))
all: bootloader tools kernel all: bootloader tools kernel
cp bin/bootloader.bin image.bin cp bin/bootloader.bin image.bin
qemu-img resize -f raw image.bin 512M qemu-img resize -f raw image.bin 512M
./diskwrite -v -l kernel.elf idm.elf -o image.bin ./diskwrite -v -l idm.elf kernel.elf -o image.bin
# ./diskwrite -v idm.elf -o image.bin # ./diskwrite -v idm.elf -o image.bin
qemu-system-i386 -hda image.bin --no-reboot --no-shutdown -m 32m -smp 2 -serial mon:stdio -D intlog.txt -d int qemu-system-i386 -hda image.bin --no-reboot --no-shutdown -m 32m -smp 2 -serial mon:stdio -D intlog.txt -d int
tools: tools:

View File

@ -461,8 +461,8 @@ open_file:
;esi = ptr to load file ;esi = ptr to load file
;eax = return value (first cluster) ;eax = return value (first cluster)
;edx = return value (file size) ;edx = return value (file size)
; push esi ;!TODO: RE-WRITE FUNCTION FROM GROUND UP
;!TODO: return file size in edx push edi
xor esi, esi xor esi, esi
xor ecx, ecx xor ecx, ecx
xor edx, edx xor edx, edx
@ -470,62 +470,35 @@ open_file:
add si, [fat_bpb.reserved_sectors] add si, [fat_bpb.reserved_sectors]
mov cl, [fat_bpb.fat_count] mov cl, [fat_bpb.fat_count]
mov dx, [fat_ebpb32.sectors_per_fat] mov dx, [fat_ebpb32.sectors_per_fat]
.addlp:
add esi, edx mov ax, dx
dec ecx
or ecx, ecx
jnz .addlp
xor dx, dx xor dx, dx
mov ecx, [fat_ebpb32.root_dir_cluster] mul cx
mov dl, [fat_bpb.sectors_per_cluster] add si, ax
.addlp1:
add esi, edx mov byte [DAP.segment], 0
dec ecx
or ecx, ecx
jnz .addlp1
mov [DAP.sector_start], esi mov [DAP.sector_start], esi
mov [DAP.read_count], dx mov word [DAP.read_count], 8
; pop esi mov word [DAP.offset], root_dir
mov [DAP.offset], word 0x1000
mov [DAP.segment], word 0x0000
mov dx, [DAP.read_count]
push 0
pop ds
push 0
pop es
mov ah, 0x42
mov dl, byte [data.boot_disc]
mov si, DAP mov si, DAP
mov ah, 0x42
mov dl, [data.boot_disc]
int 0x13 int 0x13
jc load_fail jc .not_found_ret
; debug
xor ecx, ecx xor ecx, ecx
; pop edi lea esi, [root_dir - 0x20]
.chklp: .chklp:
lea esi, [ecx + root_dir] add esi, 0x20
cmp byte [si], 0 mov edi, [esp]
je .not_found_ret mov ecx, 11
repe cmpsb rep cmpsb
mov ax, [si] jne .chklp
cmp ax, [di] .found:
jne .not_found debug
lea esi, [ecx + root_dir]
xor eax, eax
xor edx, edx
mov ax, [esi + 20]
shl eax, 16
mov ax, [esi + 26]
mov edx,[esi + 28]
; debug
ret
.not_found:
add ecx, 32
jmp .chklp
.not_found_ret: .not_found_ret:
pop edi
mov eax, -1 mov eax, -1
ret ret
jmp $ jmp $