feat(tools): mkfs bootsector load indirect

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-09-02 10:56:21 +02:00
parent e71ac0e1b1
commit 8165ea664f

View file

@ -83,7 +83,7 @@ start:
jc .reset_disk jc .reset_disk
; read superblock ; read superblock
mov ax, DISK_BUFFER mov ax, DISK_BUFFER/0x10
mov es, ax mov es, ax
; load two sector in memory ; load two sector in memory
@ -108,16 +108,14 @@ start:
mov dword [uFsize], eax mov dword [uFsize], eax
; copy data to LOADER_BASE ; copy data to LOADER_BASE
mov ax, LOADER_BASE mov ax, LOADER_BASE/0x10
mov es, ax mov es, ax
; direct read ; direct read
xor edx, edx xor edx, edx
xor ebx, ebx
.direct_loop: .direct_loop:
mov ax, es cmp ebx, [uFsize]
movzx ecx, ax
sub ecx, LOADER_BASE
cmp ecx, [uFsize]
jg .all_read jg .all_read
mov eax, edx mov eax, edx
@ -129,21 +127,46 @@ start:
; copy block ; copy block
mov eax, [eax] mov eax, [eax]
mov cx, 1 mov cx, 1
xor bx, bx
call disk_read_sectors call disk_read_sectors
pop edx pop edx
mov ax, es add ebx, BLOCK_SIZE
add ax, BLOCK_SIZE
mov es, ax
inc edx inc edx
cmp edx, 8 cmp edx, 7
jbe .direct_loop jb .direct_loop
.indirect_read: .indirect_read:
; TODO push ebx
mov ax, DISK_BUFFER/10
mov es, ax
mov eax, [DISK_BUFFER + 512 + INODE_SIZE * 2 + inode.zones + 28] ;zones[7] == indirect
mov cx, 1
xor bx, bx
call disk_read_sectors
mov ax, LOADER_BASE/10
mov es, ax
pop ebx
xor edx, edx
.indirect_loop:
cmp ebx, [uFsize]
jg .all_read
mov eax, edx
shl eax, 2
add eax, DISK_BUFFER
mov eax, [eax]
mov cx, 1
call disk_read_sectors
add ebx, BLOCK_SIZE
inc edx
cmp edx, 128
jbe .indirect_loop
.all_read: .all_read:
@ -204,10 +227,10 @@ disk_packet:
db 0 db 0
.sectors: .sectors:
dw 0 dw 0
.segment:
dw 0
.offset: .offset:
dw 0 dw 0
.segment:
dw 0
.lba: .lba:
dd 0 dd 0
dd 0 dd 0