Implement calculation for FAT position
This commit is contained in:
parent
2cb39a4ff1
commit
1b42f1a480
@ -18,7 +18,7 @@
|
|||||||
; stack size
|
; stack size
|
||||||
%define stacks 512
|
%define stacks 512
|
||||||
|
|
||||||
banner: db "rdos", 0xA, 0xD, '$'
|
banner: db "rdos loaded", 0xA, 0xD, '$'
|
||||||
|
|
||||||
; Alias for Int 21h,AH=0h
|
; Alias for Int 21h,AH=0h
|
||||||
int20h: xor ah, ah
|
int20h: xor ah, ah
|
||||||
@ -194,6 +194,7 @@ fputc: push ax
|
|||||||
iret
|
iret
|
||||||
|
|
||||||
%include "kernel/diskio.asm"
|
%include "kernel/diskio.asm"
|
||||||
|
%include "kernel/fat.asm"
|
||||||
|
|
||||||
vects: dw int20h, int21h, retf, retf
|
vects: dw int20h, int21h, retf, retf
|
||||||
dw retf, retf, retf, int20h
|
dw retf, retf, retf, int20h
|
||||||
@ -224,6 +225,7 @@ intlp: movsw
|
|||||||
call dnconv
|
call dnconv
|
||||||
mov al, dl
|
mov al, dl
|
||||||
call select
|
call select
|
||||||
|
call load_bpb
|
||||||
|
|
||||||
loop: int 0x28
|
loop: int 0x28
|
||||||
jmp loop
|
jmp loop
|
||||||
|
68
kernel/fat.asm
Normal file
68
kernel/fat.asm
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
section .bss
|
||||||
|
|
||||||
|
; the sector numbers have the partition offset already included
|
||||||
|
|
||||||
|
fat_offset:
|
||||||
|
resd 1
|
||||||
|
fat_size:
|
||||||
|
resd 1
|
||||||
|
fat_num: ; a byte would be enough, but i want to work with cx
|
||||||
|
resw 1
|
||||||
|
|
||||||
|
rootdir_offset:
|
||||||
|
resd 1
|
||||||
|
rootdir_size:
|
||||||
|
resw 1
|
||||||
|
|
||||||
|
clusters_offset:
|
||||||
|
resd 1
|
||||||
|
clusters_num:
|
||||||
|
resd 1
|
||||||
|
|
||||||
|
section .text
|
||||||
|
|
||||||
|
; invoked after disk select
|
||||||
|
load_bpb:
|
||||||
|
; read word for "sectors per fat"
|
||||||
|
mov ax, [disk_buffer+0x016]
|
||||||
|
xor dx, dx
|
||||||
|
; if zero, we need to check dword in BPB 7.1
|
||||||
|
test ax, ax
|
||||||
|
jnz .short_sf
|
||||||
|
; fail if BPB 7.1 signature is not present
|
||||||
|
mov cl, [disk_buffer+0x042]
|
||||||
|
or cl, 1
|
||||||
|
cmp cl, 0x29
|
||||||
|
jne .err
|
||||||
|
; load dword
|
||||||
|
mov ax, [disk_buffer+0x024]
|
||||||
|
mov dx, [disk_buffer+0x026]
|
||||||
|
.short_sf:
|
||||||
|
; store local value
|
||||||
|
mov [fat_size], ax
|
||||||
|
mov [fat_size+2], dx
|
||||||
|
|
||||||
|
; copy number of fat's
|
||||||
|
xor ah, ah
|
||||||
|
mov al, [disk_buffer+0x010]
|
||||||
|
mov [fat_num], ax
|
||||||
|
|
||||||
|
mov ax, [part_offset]
|
||||||
|
mov dx, [part_offset+2]
|
||||||
|
add ax, [disk_buffer+0x0B+bpb_rsc]
|
||||||
|
adc ax, 0
|
||||||
|
mov [fat_offset], ax
|
||||||
|
mov [fat_offset+2], dx
|
||||||
|
|
||||||
|
int 3
|
||||||
|
|
||||||
|
; add FAT size * FAT number
|
||||||
|
mov cx, [fat_num]
|
||||||
|
.floop: add ax, [fat_size]
|
||||||
|
adc dx, [fat_size+2]
|
||||||
|
loop .floop
|
||||||
|
|
||||||
|
int 3
|
||||||
|
ret
|
||||||
|
.err: stc
|
||||||
|
ret
|
Loading…
Reference in New Issue
Block a user