From 6d2c26f1ee44783f16b78e1cb65f0032b5ac9093 Mon Sep 17 00:00:00 2001 From: d0p1 Date: Mon, 2 Sep 2024 10:56:21 +0200 Subject: [PATCH] feat(tools): mkfs bootsector load indirect --- tools/mkfs/boot.asm | 51 ++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/tools/mkfs/boot.asm b/tools/mkfs/boot.asm index 41593dd..c31fbcb 100644 --- a/tools/mkfs/boot.asm +++ b/tools/mkfs/boot.asm @@ -83,7 +83,7 @@ start: jc .reset_disk ; read superblock - mov ax, DISK_BUFFER + mov ax, DISK_BUFFER/0x10 mov es, ax ; load two sector in memory @@ -108,16 +108,14 @@ start: mov dword [uFsize], eax ; copy data to LOADER_BASE - mov ax, LOADER_BASE + mov ax, LOADER_BASE/0x10 mov es, ax ; direct read xor edx, edx + xor ebx, ebx .direct_loop: - mov ax, es - movzx ecx, ax - sub ecx, LOADER_BASE - cmp ecx, [uFsize] + cmp ebx, [uFsize] jg .all_read mov eax, edx @@ -129,21 +127,46 @@ start: ; copy block mov eax, [eax] mov cx, 1 - xor bx, bx call disk_read_sectors pop edx - mov ax, es - add ax, BLOCK_SIZE - mov es, ax + add ebx, BLOCK_SIZE inc edx - cmp edx, 8 + cmp edx, 7 jbe .direct_loop .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: @@ -204,10 +227,10 @@ disk_packet: db 0 .sectors: dw 0 -.segment: - dw 0 .offset: dw 0 +.segment: + dw 0 .lba: dd 0 dd 0