Anyway, I'm writing a no-emulation El-Torito bootloader and while it boots as expected, I can't seem to load additional sectors. I've tried (in Bochs) different variations of the Int 13h extensions and the (perhaps non-standard) Int 2Fh CD-ROM commands. The carry flag is never set afterward, and there is every indication that the operation was successful, except that the data isn't loaded. I've tried waiting a few seconds for the virtual read to take place, but still nothing.
I know you want code, so here it is ATM:
Code: Select all
[ORG 0x7C00]
use16
;I just like 0:7C00 more than 7C0:0
jmp word 0:DEFINED_ADDRESS
DEFINED_ADDRESS:
;zero registers & save boot drive number
xor ax,ax
mov ds,ax
mov ss,ax
mov es,ax
mov [boot_drv],dl
xor bx,bx
xor cx,cx
xor dx,dx
xor si,si
xor di,di
xor bp,bp
;clear screen
mov ah,0Fh
int 10h
mov ah,0
int 10h
;set sp & test for old machine (sp method)
mov sp,0x600
push sp
pop sp
cmp sp,0x600
jne pre_268
;test for old machine (invalid opcode method)
cli
mov word[ds:(6*4) ],pre_386 ;Offset
mov word[ds:(6*4)+2],0 ;Segment
sti
xor eax,eax
;output: cpu is good
mov di,cpu_good
call print
;A20 enable
call test_A20
jnc A20_good
mov ax,0x2401
int 15h
cmp ah,0
je A20_good
call enable_A20
call test_A20
jnc A20_good
call A20_FAIL
A20_good:
;read CD volume descriptors (incomplete)
mov [0x600],byte 10h
mov [0x601],byte 0
mov [0x602],word 1
mov [0x604],word 0
mov [0x606],word 0x500
mov [0x608],dword 10h
mov [0x60C],dword 0
mov ah,42h
mov dl,[boot_drv]
mov si,0x600
int 13h
jmp $
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;fatal error
A20_FAIL:
mov di,a20_failed
call print
jmp $
;from OS Dev site
;consumes: al
enable_A20:
cli
call .a20wait
mov al,0xAD
out 0x64,al
call .a20wait
mov al,0xD0
out 0x64,al
call .a20wait2
in al,0x60
push ax
call .a20wait
mov al,0xD1
out 0x64,al
call .a20wait
pop ax
or al,2
out 0x60,al
call .a20wait
mov al,0xAE
out 0x64,al
call .a20wait
sti
ret
.a20wait:
in al,0x64
test al,2
jnz .a20wait
ret
.a20wait2:
in al,0x64
test al,1
jz .a20wait2
ret
;consumes: ax, bx, [0x7C00]
test_A20:
mov bx,0xFFFF
mov es,bx
mov ax,[ds:0x7C00]
mov bx,[es:0x7C10]
cmp ax,bx
jne .enabled
xor [ds:0x7C00],word 0xFFFF
mov ax,[ds:0x7C00]
mov bx,[es:0x7C10]
cmp ax,bx
jne .enabled
stc
ret
.enabled:
clc
ret
;called if old machine is detected
pre_268:
pre_386:
mov di,cpu_bad
call print
jmp $
;di=string
;consumes: ax, di
print:
.loop1:
mov al,[di]
cmp al,0
je .break1
mov ah,0Eh
int 10h
inc di
jmp .loop1
.break1:
ret
cpu_good: db 'Supported CPU',13,10,0
cpu_bad: db 'Unsupported CPU',0
a20_failed: db "A20 line couldn't be enabled",0
boot_drv: db 0