ATA: CD-R or HD?

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
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

ATA: CD-R or HD?

Post by sebihepp »

Hello,

I just read some articles about ATA, because I want to access the CD-Drive and the Harddisc in
PMode. I think of a FloppyImage, with a Bootrecord wich loads the second boot loader on the image
and giving control, next it initialize basic PMode and IDT just to load the OS from the CD. This image
will be on the CD, so it is bootable.

But on the IDE-Port you can have CD-Drives and HDs. Most modern PCs uses SATA for HDs but some
old doesn't. But how do I determine, wich is a CD-Drive and wich is a HD (or something else)?

Greetings
Sebihepp
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: ATA: CD-R or HD?

Post by kmtdk »

well
this requries that you send a "IDENTIFY PACKET DEVICE information".
This will return a Lot of usefull data, also what device type. You shuld see the ATA-ATAPI 6 for a describing over this command.
If you are trying to use the "IDENTIFY DEVICE" command ( or what it is called), you can see if the device is removeable, but due to usb hdd's and that kind, this is not a good enouhgt way to insure that it is a CD-ROM or HDD

KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: ATA: CD-R or HD?

Post by quok »

Also I think it needs to be pointed out that there are SATA CD and DVD drives out there as well. I've got one of those myself, as I have a computer that doesn't have a traditional IDE (PATA) controller.
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: ATA: CD-R or HD?

Post by sebihepp »

okay, thanks.
Is it possible to access the CD-Drive in Real Mode?
I read something about in the wiki with the BIOS int 13h extensions.
But I didn't found any docu for the extensions. Is there any?
And which drive-number (dl) have I to use?

Thanks
Sebihepp
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: ATA: CD-R or HD?

Post by kmtdk »

well
use "Ralf Brown's interupt table"
but if it is supoosed to support more than one drives, and just a few feature, you will have to program the controller.
if the boot device is a CD-ROM, then "DL" contains the drive number.
and yes, bios can read from a CD-ROM with the right drive number (DL).


KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: ATA: CD-R or HD?

Post by sebihepp »

I thought if I boot from CD, then a floppy-drive is emulated.
This means, I can only access the Boot-Catalog in the CD.

Hmmm, I fear, that a floppy is to small for my os. That's the only reason I want
to support CDs. And sometimes I think, I would never use the complete capacity
of a Floppy. :D

I just want to Support Floppy, HD, text based UI(Console).
There are drivers for each part (and more, like file system, memory management, ...).
Each driver has its own Segment (PMode) and the Kernel is the link between
everything. Then you should be able to run Programms (the shell is a programm to,
that is loaded from the kernel at start), wich can use functions provided from drivers/kernel.

Sebihepp
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: ATA: CD-R or HD?

Post by sebihepp »

So, an PATAPI/SATAPI-Device is nearly always a CD-Drive and a PATA/SATA-Device is
mostly a HD, right?
Can I use ATA Commands to communicate with ATAPI-Devices?

TIA Sebihepp
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: ATA: CD-R or HD?

Post by kmtdk »

well
Correct me if im worng, but if i rember currect, it is the same commands for hdd, and cd's ( ATAPI commands)
But you will still need to know what device, because you can not write on a cd.

ALso, to test is, to be sure, use bochs, and a real computer, cause you cant do that much worng.


KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
pcmattman
Member
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: ATA: CD-R or HD?

Post by pcmattman »

No, CD's use packet commands (ie, you run IDENTIFY DEVICE, it puts into all the registers a specific value that tells you it's a packet device, you run IDENTIFY PACKET DEVICE), HD's use the standard commands.

ATAPI = AT attachment packet interface. This is basically a different way of doing things and is typically used for CDs. The ATA/ATAPI spec covers both.
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: ATA: CD-R or HD?

Post by sebihepp »

Thanks for the quick reply.
Yes, of course I will check the device type first, before writing to it, because you can't write to a
cd (without burning... :D ).

So I need to write at least two different drivers, one for HD and one for CD? Hmpf... :?
It would be easier, if I can use the "read PIO sector"-Command from the ATA-Standard to read
one sector in both cases. A CD-driver would be then only an "advanced" HD-driver with some extra
functions. :wink:

I know, that a sector on HD is 512 byte and on a cd normally 2048 byte.
But do I really have to use the packet interface commands for ATAPI-devices?

Cheers
Sebihepp
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: ATA: CD-R or HD?

Post by Owen »

There are other ATAPI devices. I have an old ATAPI ZIP drive! :P

(Unfortunately, that relic is unplugged because I've only got one PATA channel - shared between half of my RAID array and my CD drive)
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: ATA: CD-R or HD?

Post by Dex »

As well as floppy emulation you can use hdd emulation, that means you can use a hdd image that will fit on a CD-R and is bootable.
Emulation only works in realmode ( hooks into int 13h ), but i use the go to and from realmode to pmode method, which works fine.
Post Reply