Page 1 of 1

Disk geometry (Int 13h AH=08h) problem

Posted: Fri Aug 19, 2011 6:41 am
by chargh
Currently I'm making my boot-loader a little bit more fancy. Now a problem arises when I try to acquire the disc geometry. I call bios interrupt 13h AH=08h (in 16bit mode) for the first hard drive (which is a 1mb image loaded with qemu 'qemu <image_name>'). The max head number is 15, the max sector number is 63 and the max cylinder number is 0. If I'm correct this results in a disk smaller then 1mb? I use my own assembler which is non-English, but I know for sure that the code I wrote is the code that is written, here is the result from ndisasm:

Code: Select all

mov ax,0x0
mov es,ax
mov di,0x0
mov ah,0x8
mov dl,[0x8227] ;here is the drive id stored (0h80)
int 0x13
jc error
cmp dl, 0
je error
After this code I call my print number routine which tells me that cx contains the number 63, so cylinder count == 0. So what is wrong with this code? Is there a other way to acquire the disk geometry (the disk doesn't have a MBR because I use a different layout that I designed myself). I searched for a way to force the bios to use LBA (since some places hinted at the existence of such functionality) but could not find any information, is it possible?

Re: Int 13h AH=08h

Posted: Fri Aug 19, 2011 6:52 am
by chargh
I tried AH=48h, but it gives me a error (sets the carry).

EDIT: Never mind, if I increase the disk size it works.

Re: Disk geometry (Int 13h AH=08h) problem

Posted: Fri Aug 19, 2011 1:35 pm
by egos
If max cylinder number is 0 then cylinder count = 1. That's alright.

You should ignore "max cylinder number" value when using this service for large disks. Only SPT and Heads values are useful for bootloaders to convert LBA to CHS.