Page 1 of 1
Some confusing stuff when dealing with ATAPI devices
Posted: Thu Jul 10, 2014 6:07 am
by nbdd0121
I try to read the capacity of a medium, so I read the SCSI Command set and try to use Read Capacity(10), however, when I was trying to read the capacity, I found when I only send 10bytes(5words) to the bus, I didn't get the capacity. When I send one more words, the function works. I read the spec carefully and didn't find anything wrong. Can anyone help me to walk this out?
PS. the two param of ASM_outsw/insw in my code is measured in bytes
The code
Re: Some confusing stuff when dealing with ATAPI devices
Posted: Tue Jul 15, 2014 10:44 pm
by SpyderTL
I checked my code, and I'm sending 12 bytes as well.
It's been a few years since I wrote it, so I can't remember why I'm sending 12 instead of 10. I went through all of my documentation as well, and I can't see anything about sending additional bytes, but I'll keep looking.
Re: Some confusing stuff when dealing with ATAPI devices
Posted: Tue Jul 15, 2014 11:23 pm
by SpyderTL
I think I figured it out... The SCSI CD-ROM specs say that the READ CAPACITY command takes 10 bytes, but the ATAPI CD-ROM specs say that the READ CAPACITY command (along with all other commands) take 12 bytes. Also, the ATAPI specs state that the ATAPI commands are "based on" the SCSI commands, but, apparently, not identical. The two additional bytes are reserved, however.
So, unless you get your hands on an old SCSI CD-ROM, you need to be using the ATAPI specs, instead.
Re: Some confusing stuff when dealing with ATAPI devices
Posted: Tue Jul 15, 2014 11:34 pm
by SpyderTL
Also, it's right here on the
ATAPI page.
Then send the ATAPI command as 6 words, to the data port.
Code: Select all
outw (0x1F0, Command1)
outw (0x1F0, Command2)
outw (0x1F0, Command3)
outw (0x1F0, Command4)
outw (0x1F0, Command5)
outw (0x1F0, Command6)
Edit: I updated the Wiki page to include the ATAPI packet padding at the end. Hopefully this saves someone else the trouble of figuring this out.