I am having a problem with function 48h int 13h work.
I am trying to get the information for a qcow2 drive on qemu within my bootloader.
Here is my code:
Code: Select all
[ORG 0x7c00]
jmp bootloader
;--------------------------------------------------------
BiosPrint:
push eax
ch_loop:
lodsb
or al, al
jz done
mov ah, 0x0E
int 0x10
jmp ch_loop
done:
pop eax
ret
;--------------------------------------------------------
printNum: ;Print a number (ax)
push ecx
push edx
push ebx
mov ecx,000Ah ;divide by 10
mov bx, sp
getDigit:
mov edx,0 ;puting 0 in the high part of the divided number (DX:AX)
div ecx ;DX:AX/cx. ax=dx:ax/cx and dx=dx:ax%cx(modulus)
push edx
cmp eax,0
jne getDigit
printNmb:
pop eax
add al, 30h ;adding the '0' char for printing
mov ah,0eh ;print char interrupt
int 10h
cmp bx, sp
jne printNmb
pop ebx
pop edx
pop ecx
RET
;------------------------------------------------------------------
getDiskInfo:
mov ah,41h ; Check if Extended Functions are supported
mov dl,80h
mov bx,0xAA55
int 13h
jc getDiskInfoNotSupport
mov ah,48h ; Read Disk Extended Information
mov al,1
mov dl,80h
mov si,disk_info
int 13h
jc getDiskInfoError ; Jump on error to print error number
; The carry is always raises (THIS IS MY PROBLEM)
mov ax,[disk_info]
call printNum
mov si,comma
call BiosPrint
mov ax,[disk_info+2]
call printNum
mov si,comma
call BiosPrint
mov eax,[disk_info+4]
call printNum
mov si,comma
call BiosPrint
jmp getDiskInfoExit
getDiskInfoError: ; It always branch to here and prints (Disk Error: 1)
mov si,disk_error
call BiosPrint
mov al,ah
xor ah,ah
call printNum
jmp getDiskInfoExit
getDiskInfoNotSupport:
mov si,disk_info_not_supported
call BiosPrint
getDiskInfoExit:
ret
bootloader:
call getDiskInfo
halt:
jmp halt
disk_info_not_supported db 'Disk Info not supported !!!!', 13, 10, 0
disk_error db 'Disk Error: ', 0
disk_info times 200 db 0
times 510-($-$$) db 0
db 0x55
db 0xAA
I have created a 1 GB qcow2 disk image with the following command:
Code: Select all
qemu-img create -f raw hwdetect.raw 1G
Code: Select all
qemu-system-x86_64 -m 4096 -fda hwdetect.img -boot a -hda hwdetect.img
Kindly if anyone can see what it the problem pleas let me know.
Thanks
Karim