Hi, I am currently working on an os, and I would like the os to reconize the type of disk that it is on...
I was looking through the Bios Interrupts and found an interrupt that gets the disks parameters.. here is how it looks
DISK - GET DRIVE PARAMETERS (PC,XT286,CONV,PS,ESDI,SCSI)
AH = 08h
DL = drive (bit 7 set for hard disk)
ES:DI = 0000h:0000h to guard against BIOS bugs
Return:
CF set on error
AH = status (07h)
CF clear if successful
AH = 00h
AL = 00h on at least some BIOSes
BL = drive type (AT/PS2 floppies only)
CH = low eight bits of maximum cylinder number
CL = maximum sector number (bits 5-0)
high two bits of maximum cylinder number (bits 7-6)
DH = maximum head number
DL = number of drives
ES:DI -> drive parameter table (floppies only)
What I want to know I guess is how to use this to get the type of disk. Below I have listed the possible codes for BL:
Values for diskette drive type:
01h 360K
02h 1.2M
03h 720K
04h 1.44M
05h ??? (reportedly an obscure drive type shipped on some IBM machines).
2.88M on some machines (at least AMI 486 BIOS)
06h 2.88M
10h ATAPI Removable Media Device
Any help appriciated...
Finding the type of floppy that the OS is on.
RE:Finding the type of floppy that the OS is on.
That shouldn't be so hard.
The most important thing you have to know is that these BIOS routines only work in real-mode.
If you saved the boot floppy to a variable, then use it to set up DL, otherwise, if your boot code doesn't use it before, it already contains the boot drive. Then set up AX/AH to 8 and set ES and DI to 0. Call the interrupt (it looks like a 0x13 int) and check the carry flag. If the carry flag is 0 (= cleared) the call worked and you can read BL to determine to floppy type. In asm, it should look like this:
mov ax, 8
mov bx, 0
mov es, bx
mov di, bx
mov bl, <boot drive>
int 0x13
jc error
<now your code to handle the different types, maybe:>
cmp bl, 1
je drv360k
cmp bl, 2
je drv1_2m
...
jmp done
error:
<code to handle the error, you may wish to retry it>
done:
That's it. I hope this works
Eous
The most important thing you have to know is that these BIOS routines only work in real-mode.
If you saved the boot floppy to a variable, then use it to set up DL, otherwise, if your boot code doesn't use it before, it already contains the boot drive. Then set up AX/AH to 8 and set ES and DI to 0. Call the interrupt (it looks like a 0x13 int) and check the carry flag. If the carry flag is 0 (= cleared) the call worked and you can read BL to determine to floppy type. In asm, it should look like this:
mov ax, 8
mov bx, 0
mov es, bx
mov di, bx
mov bl, <boot drive>
int 0x13
jc error
<now your code to handle the different types, maybe:>
cmp bl, 1
je drv360k
cmp bl, 2
je drv1_2m
...
jmp done
error:
<code to handle the error, you may wish to retry it>
done:
That's it. I hope this works
Eous
RE:Finding the type of floppy that the OS is on.
Ok, I know the address to the drive, its 00h.. the code however doesnt want to work... I am unsure why.. Maybe I will take a look into some other BIOS Interrupts
RE:Finding the type of floppy that the OS is on.
INT 13h AH=08h does not give reliable geometry/size info for floppy disks.
If you put in a 1.68 meg disk (21 sectors per track), INT 13h AH=08h will say 18 sectors per track.
If it's a DOS (FAT12) floppy, you can read the disk geometry and size from sector zero.
If you put in a 1.68 meg disk (21 sectors per track), INT 13h AH=08h will say 18 sectors per track.
If it's a DOS (FAT12) floppy, you can read the disk geometry and size from sector zero.