Get Media Status in ATAPI?
- iocoder
- Member
- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Get Media Status in ATAPI?
Hello All,
All i want to know: How to know whether there is a medium in the CD-ROM or not?
While trying to get the status of mediums in an ATAPI Drive supporting Removable Media Feature Set, i failed getting it work, as i tried to send a NOP command, and read the error register, and it doesn't return other than 'Command Aborted' as usual. i tried to send 'GET MEDIA STATUS' Command, but it is obsolete and doesn't work with neither VMware 7 nor my real computer.
What can i do? would any one help me plzzzzzzzzzzzzzz?
All i want to know: How to know whether there is a medium in the CD-ROM or not?
thanks all.
Regards,
Mostafa.
All i want to know: How to know whether there is a medium in the CD-ROM or not?
While trying to get the status of mediums in an ATAPI Drive supporting Removable Media Feature Set, i failed getting it work, as i tried to send a NOP command, and read the error register, and it doesn't return other than 'Command Aborted' as usual. i tried to send 'GET MEDIA STATUS' Command, but it is obsolete and doesn't work with neither VMware 7 nor my real computer.
What can i do? would any one help me plzzzzzzzzzzzzzz?
All i want to know: How to know whether there is a medium in the CD-ROM or not?
thanks all.
Regards,
Mostafa.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Get Media Status in ATAPI?
Look at the sense data. IIRC the ATAPI (or possibly SCSI, can't remember) spec has a table listing all the different variations of sense data. One of these, off the top of my head, relates to media presence. I could be wrong though.
I'm unable to access any of the specs at the moment otherwise I'd post something a little more useful to you .
I'm unable to access any of the specs at the moment otherwise I'd post something a little more useful to you .
Re: Get Media Status in ATAPI?
A quick Google found a reference in the AROS source here. Though I have little knowledge on ATAPI, it may help you.
JAL
JAL
- iocoder
- Member
- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Re: Get Media Status in ATAPI?
Thank you both pcmattman and JAL for helping me. i have found the way according to your helpings.
Here is the method of media insert/remove Sense in Quafios:
Every 1000 millisecond, a specific function is called in the IDE Driver, when it is called, it searches for connected drives which are ATAPI [almost all ATAPI Drives use Removable Media Feature Set] and whose channels aren't not active. Then the function sends a 'SCSI Read Capacity' Command after an ATA_PACKET Command, the 'SCSI Read Capacity' Command shall return the number of last LBA in the inserted medium. if there isn't a medium, an error is occured.
This helped me in mainly three thigns:
- Detecting whether there is a medium or not.
- Detecting medium changes (if errors stop, so a new medium is inserted, if errors return, the medium is removed)
- Detecting the size of the medium.
http://en.wikipedia.org/wiki/SCSI_Read_Capacity_Command
Thank you all for helping me,
Regards,
Mostafa.
Here is the method of media insert/remove Sense in Quafios:
Every 1000 millisecond, a specific function is called in the IDE Driver, when it is called, it searches for connected drives which are ATAPI [almost all ATAPI Drives use Removable Media Feature Set] and whose channels aren't not active. Then the function sends a 'SCSI Read Capacity' Command after an ATA_PACKET Command, the 'SCSI Read Capacity' Command shall return the number of last LBA in the inserted medium. if there isn't a medium, an error is occured.
This helped me in mainly three thigns:
- Detecting whether there is a medium or not.
- Detecting medium changes (if errors stop, so a new medium is inserted, if errors return, the medium is removed)
- Detecting the size of the medium.
http://en.wikipedia.org/wiki/SCSI_Read_Capacity_Command
Thank you all for helping me,
Regards,
Mostafa.
Re: Get Media Status in ATAPI?
Glad we were of help. All this should be added to the wiki, but I haven't got time now...
JAL
JAL
- iocoder
- Member
- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Re: Get Media Status in ATAPI?
I'll try to add them myself in the right location in the wiki .jal wrote: All this should be added to the wiki, but I haven't got time now...
Regards,
Mostafa.
Re: Get Media Status in ATAPI?
That would be great! There's an ATAPI article, but I don't think it mentions this.mostafazizo wrote:I'll try to add them myself in the right location in the wiki
JAL
- iocoder
- Member
- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Re: Get Media Status in ATAPI?
Now it mentions this.jal wrote: That would be great! There's an ATAPI article, but I don't think it mentions this.
http://wiki.osdev.org/ATAPI#Detecting_a ... s_Capacity
But Could I ask another question?
I would want to know what about Floppy Disk Controller? i wanted to sense media status in FDC but i couldn't, i'm searching for a command that doesn't need to activate the drive's motor, as i will send it each 1, 2 or 4 seconds. but i couldn't find such an one. anyone has an idea about this????
Thanks and Regards,
Mostafa.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Get Media Status in ATAPI?
There is none.
Well, there "is", kinda. It's not really a command; more a sequence which will eventually tell you whether the disk is inserted or not.
It has a problem: Some drives return a 1 for disk inserted, others return a 0.
In English: It's useless.
Well, there "is", kinda. It's not really a command; more a sequence which will eventually tell you whether the disk is inserted or not.
It has a problem: Some drives return a 1 for disk inserted, others return a 0.
In English: It's useless.
Re: Get Media Status in ATAPI?
You remember that in the old days, on computer startup the floppy drive came alive? That's because it is not possible in any reliable way (or, as far as old floppy controllers are concerned, in any way) to get an insert status or a change status. The only way is to read and see if you succeed.mostafazizo wrote:I would want to know what about Floppy Disk Controller? i wanted to sense media status in FDC but i couldn't, i'm searching for a command that doesn't need to activate the drive's motor
JAL
Re: Get Media Status in ATAPI?
Not necessarily. Though disk may be swapped, the chances of a disk drive being swapped are little to none. So you start reading, then do your magic sequence, and see if it returns a 1 or a 0. Not that I'd recommend it, floppies are a thing of the past anyway, and you'll get bad results doing it on an emulated CD or memory stick.Owen wrote:It has a problem: Some drives return a 1 for disk inserted, others return a 0. (...) It's useless.
JAL
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Get Media Status in ATAPI?
"I swapped my floppy drive and now the disk status is inverted. HELP!"jal wrote:Not necessarily. Though disk may be swapped, the chances of a disk drive being swapped are little to none. So you start reading, then do your magic sequence, and see if it returns a 1 or a 0. Not that I'd recommend it, floppies are a thing of the past anyway, and you'll get bad results doing it on an emulated CD or memory stick.Owen wrote:It has a problem: Some drives return a 1 for disk inserted, others return a 0. (...) It's useless.
JAL
Oh, and some drives don't support it at all.
Emulation isn't a problem since it involves talking directly to the FDC
Re: Get Media Status in ATAPI?
I wrote as much as I could on the media sensing issue in the Floppy Disk Controller wiki article. Yes, you have to turn on the motor flag in the DOR. But it is for less than a millisecond. Modern drives do not even start the actual drive motor until you send a read or write command. A human will never even see the light flash. Especially since you only have to keep trying to sense new media when you already have a good idea that there is none. So you are only doing the motor on/test/motor off sequence on an empty drive.
- iocoder
- Member
- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Re: Get Media Status in ATAPI?
Thank you Owen, JAL, bewing for your helpful posts.
the floppy lump is truned on, strange voice is listened 'like music' and Quafiso [My OS] is stopped working, because this happens when it does seek in order to clear the bit, but seek takes more than a minute, and the function is called every minute, so that Quafios is stopped working.
i tried to make the function called every 5 minutes, but the problem that seek doesn't work correctly on my real machine when there is no disk. i don't know why. i think all of these problems because of my floppy disk drive and your method has no mistake.
Thank you all and regards,
Mostafa
Thank you very much for the article, notice that i had read it before, and i focused on the part of 'DIR register, Disk Change bit', then i said to myself 'why don't i try the written method?' and myself replied 'and why not?' then i wrote the code. it works perfectly on VMware 7, Bochs, but on my real machine happens great problems:bewing wrote: I wrote as much as I could on the media sensing issue in the Floppy Disk Controller wiki article.
the floppy lump is truned on, strange voice is listened 'like music' and Quafiso [My OS] is stopped working, because this happens when it does seek in order to clear the bit, but seek takes more than a minute, and the function is called every minute, so that Quafios is stopped working.
i tried to make the function called every 5 minutes, but the problem that seek doesn't work correctly on my real machine when there is no disk. i don't know why. i think all of these problems because of my floppy disk drive and your method has no mistake.
and because of that, i decided to stop supporting Floppy disk in my operating system and to start enhancing USB as a replacement.JAL wrote: floppies are a thing of the past anyway
Thank you all and regards,
Mostafa