Page 1 of 1

ATA: CD-R or HD?

Posted: Thu Dec 11, 2008 7:42 am
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

Re: ATA: CD-R or HD?

Posted: Thu Dec 11, 2008 8:28 am
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

Re: ATA: CD-R or HD?

Posted: Thu Dec 11, 2008 9:06 am
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.

Re: ATA: CD-R or HD?

Posted: Thu Dec 11, 2008 9:18 am
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

Re: ATA: CD-R or HD?

Posted: Thu Dec 11, 2008 10:37 am
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

Re: ATA: CD-R or HD?

Posted: Thu Dec 11, 2008 3:22 pm
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

Re: ATA: CD-R or HD?

Posted: Fri Dec 19, 2008 3:27 am
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

Re: ATA: CD-R or HD?

Posted: Fri Dec 19, 2008 3:47 am
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

Re: ATA: CD-R or HD?

Posted: Fri Dec 19, 2008 5:09 am
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.

Re: ATA: CD-R or HD?

Posted: Fri Dec 19, 2008 9:37 am
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

Re: ATA: CD-R or HD?

Posted: Fri Dec 19, 2008 10:10 am
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)

Re: ATA: CD-R or HD?

Posted: Fri Dec 19, 2008 12:58 pm
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.