detecting drives in real mode + lidt

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

detecting drives in real mode + lidt

Post by anon19287473 »

how can i detect drives in real mode? I tried attempting to read from all the drive numbers, w/o actually reading any memory, and reporting whether or not there was an error, but that didnt yield resutls. Any ideas?

How does load an idt in real mode? do you just use lidt and it is immediately active? Do i load it, then enter PM then go back to RM? what do i use as the offest in the table entires (idt)?
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

how can i detect drives in real mode? I tried attempting to read from all the drive numbers
Well, you can use INT 13h with AH=08h and AH=15h.

AH=08h:

required to fill:
AH=08h
DL=drive number (00-first FDD,01-second FDD,80h:first HDD,81h:second HDD)
INT 13h
you'll get:
CF=1 on error (maybe...)
CH=the maximal number of cylinders of the drive DECREMENTED by 1
CL=the maximal number of sectors (per track?)
DH=number of heads (surfaces)
DL=the number of devices connected to the controller

Beware that this function may return curious results, if you for example, have one harddisk in your PC and you are getting info for second HDD..

AH=15h:

required to fill:
AH=15h
DL=drive number
INT 13h
you'll get:
AH=status:
00 - drive in DL does not exist
01 - diskette without indication of removability (?)
02 - diskette (or any removable media) with indication of removability (?)
03 - hard disk
CX:DX= if AH is nonzero, then it is the total number of sectors in medium
How does load an idt in real mode? do you just use lidt and it is immediately active?
Should be...

inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

Post by anon19287473 »

Thanks a bunch! :) :D
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Post by mathematician »

You don't need the LIDT instruction in real mode, because the interrupt vector table always occupies the first 1kb of memory.
Post Reply