problem reading more than 1 track
Posted: Wed Apr 04, 2012 9:07 am
First I need to tell you that my bootloader does'nt search for my kernel but instead loads sectors from the SECOND sector (end of bootloader) where my kernel is included in the code with a incbin "kernel.asm".
Anyway, my bootloader loads 1 track (18 sectors in fat12) but my kernel recently expanded to be more than 1 track in size so I needed to make the bootloader load more tracks:
But when I booted it up it seemd like if it only loaded 1 track still becaous the things at the end of the kernel didn't work.
Anyway, my bootloader loads 1 track (18 sectors in fat12) but my kernel recently expanded to be more than 1 track in size so I needed to make the bootloader load more tracks:
Code: Select all
read:
pusha
mov ah,2 ; read
mov al,18 ; 1 track at a time
mov ch,0 ; start at track 0
mov cl,2 ; start sector 2 = end of bootloader and start of kernel
mov dh,0 ; head 0
mov dl,byte[bootdev] ; boot device passed to us from BIOS st startup
mov bx,0x2000 ; load segment
mov es,bx
mov bx,0
.do:
int 0x13 ; read
jc .error ; if error ...
mov cl,0 ; all other reads start from sector 0
inc ch ; next track
cmp ch,3 ; read 3 tracks just to be safe
jne .do
.done:
mov ax,0x07c0 ; set es back to 0x07c0
mov es,ax
popa
ret
.error:
mov si,.msg
call printerr ; print error message in red
jmp error ; reboot
.msg: db 10,13,'Disk read error!!!',10,13,0