fixed bootloader/main.s:open_file
This commit is contained in:
parent
6d4f541a01
commit
a6636df6fa
1
makefile
1
makefile
|
|
@ -10,6 +10,7 @@ all: bootloader tools kernel
|
||||||
qemu-img resize -f raw image.bin 512M
|
qemu-img resize -f raw image.bin 512M
|
||||||
./diskwrite -v -l idm.elf kernel.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
|
||||||
|
# ./diskwrite -v -l kernel.elf 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:
|
||||||
$(CC) tools/diskwrite.c -o diskwrite
|
$(CC) tools/diskwrite.c -o diskwrite
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,7 @@ part_2:
|
||||||
; debug
|
; debug
|
||||||
mov edi, kernel_file
|
mov edi, kernel_file
|
||||||
call open_file
|
call open_file
|
||||||
|
; debug
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je file_not_found
|
je file_not_found
|
||||||
add edx, 0x40000;is 1mb enough for a filesystem diver and a disk driver?
|
add edx, 0x40000;is 1mb enough for a filesystem diver and a disk driver?
|
||||||
|
|
@ -320,21 +321,25 @@ part_2:
|
||||||
; debug
|
; debug
|
||||||
mov esi, [kload_paddr]
|
mov esi, [kload_paddr]
|
||||||
call load_elf
|
call load_elf
|
||||||
|
; debug
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
mov edi, disk_module_file
|
mov edi, disk_module_file
|
||||||
call open_file
|
call open_file
|
||||||
|
; debug
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je .find_fs_driver_no_disk
|
je .find_fs_driver_no_disk
|
||||||
mov eax, esi
|
mov eax, esi
|
||||||
and edx, 0xfffffc00
|
and edx, 0xfffffc00
|
||||||
add edx, 0x1000
|
add edx, 0x1000
|
||||||
add [kload_paddr], edx
|
add [kload_paddr], edx
|
||||||
|
; debug
|
||||||
|
|
||||||
mov edi, edx
|
; mov edi, edx
|
||||||
|
debug
|
||||||
mov [disk_module_struct.ptr], edi
|
mov [disk_module_struct.ptr], edi
|
||||||
call read_file
|
call read_file
|
||||||
|
debug
|
||||||
jc load_fail
|
jc load_fail
|
||||||
.find_fs_driver_no_disk:
|
.find_fs_driver_no_disk:
|
||||||
mov ax, 0xe44
|
mov ax, 0xe44
|
||||||
|
|
@ -458,10 +463,9 @@ paging_en:
|
||||||
open_file:
|
open_file:
|
||||||
;only looks in the root directory
|
;only looks in the root directory
|
||||||
;edi = file_to_search
|
;edi = file_to_search
|
||||||
;esi = ptr to load file
|
;esi = ptr to load file [TODO: IMPLEMENT]
|
||||||
;eax = return value (first cluster)
|
;eax = return value (first cluster)
|
||||||
;edx = return value (file size)
|
;edx = return value (file size)
|
||||||
;!TODO: RE-WRITE FUNCTION FROM GROUND UP
|
|
||||||
push edi
|
push edi
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
|
|
@ -475,7 +479,12 @@ open_file:
|
||||||
xor dx, dx
|
xor dx, dx
|
||||||
mul cx
|
mul cx
|
||||||
add si, ax
|
add si, ax
|
||||||
|
xor cx, cx
|
||||||
|
mov ax, [fat_ebpb32.root_dir_cluster]
|
||||||
|
mov cl, [fat_bpb.sectors_per_cluster]
|
||||||
|
mul cx
|
||||||
|
add si, ax
|
||||||
|
; jmp $
|
||||||
mov byte [DAP.segment], 0
|
mov byte [DAP.segment], 0
|
||||||
mov [DAP.sector_start], esi
|
mov [DAP.sector_start], esi
|
||||||
mov word [DAP.read_count], 8
|
mov word [DAP.read_count], 8
|
||||||
|
|
@ -484,18 +493,37 @@ open_file:
|
||||||
mov si, DAP
|
mov si, DAP
|
||||||
mov ah, 0x42
|
mov ah, 0x42
|
||||||
mov dl, [data.boot_disc]
|
mov dl, [data.boot_disc]
|
||||||
|
; jmp $
|
||||||
int 0x13
|
int 0x13
|
||||||
jc .not_found_ret
|
jc .not_found_ret
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
lea esi, [root_dir - 0x20]
|
lea esi, [root_dir]
|
||||||
|
push word 0
|
||||||
|
pop es
|
||||||
.chklp:
|
.chklp:
|
||||||
add esi, 0x20
|
; add esi, 0x20
|
||||||
mov edi, [esp]
|
mov edi, [esp]
|
||||||
|
cmp byte [esi], 0
|
||||||
|
mov ax, [esi]
|
||||||
|
je .not_found_ret
|
||||||
mov ecx, 11
|
mov ecx, 11
|
||||||
rep cmpsb
|
push esi
|
||||||
jne .chklp
|
repe cmpsb
|
||||||
|
pop esi
|
||||||
|
; jmp $
|
||||||
|
je .found
|
||||||
|
add esi, 0x20
|
||||||
|
jmp .chklp
|
||||||
.found:
|
.found:
|
||||||
debug
|
pop edi
|
||||||
|
;eax = first cluster
|
||||||
|
;edx = file size
|
||||||
|
mov ax, [esi + 20]
|
||||||
|
shl eax, 16
|
||||||
|
mov ax, [esi + 26]
|
||||||
|
mov edx, [esi + 28]
|
||||||
|
; jmp $
|
||||||
|
ret
|
||||||
|
|
||||||
.not_found_ret:
|
.not_found_ret:
|
||||||
pop edi
|
pop edi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue