Some confusing stuff when dealing with ATAPI devices

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
nbdd0121
Member
Member
Posts: 60
Joined: Thu Jul 25, 2013 8:10 am

Some confusing stuff when dealing with ATAPI devices

Post 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
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Some confusing stuff when dealing with ATAPI devices

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Some confusing stuff when dealing with ATAPI devices

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Some confusing stuff when dealing with ATAPI devices

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Post Reply