# SATA is ATA?



## Seeker (Dec 4, 2009)

```
ad4: 156334MB <Maxtor 6Y160M0 YAR511W0> at ata2-master SATA150
```

But it is sata HD, connected with sata cable to mainboard.
So..., shouldn't it be *da* instead *ad* driver?

Same thing on my laptop: SATA is ATA
??


----------



## Voltar (Dec 4, 2009)

All my IDE/SATA drives use/show *ad*, my SCSI drives and USB mass storage *da*. It has always been like that in my experience.


----------



## Beastie (Dec 4, 2009)

IDE/EIDE/ATA/P(arallel)ATA and S(erial)ATA are both ATA. They use the same AT Attachment standard commands. The only real difference is cabling.
So they are both detected by ad, not da.


----------



## Seeker (Dec 4, 2009)

Ah, I see.
And it works in AHCI mode?


----------



## Beastie (Dec 4, 2009)

Since I have no SATA here to test the new AHCI driver, I can't tell. But it seems SATA disks should be detected as ada instead of ad, if using the new driver.

You can read more on the blog of Ivan Voras.

Also, from the detailed 8.0 release notes:


> The FreeBSD CAM SCSI subsystem ( cam(4)) now includes experimental support for ATA/SATA/AHCI-compliant devices. This is disabled by default. To enable this, adding the following kernel options to your kernel configuration file and rebuild the kernel:
> device    ahci
> device    siis
> 
> The current implementation supports AHCI-compliant controllers and SiliconImage SiI3124/SiI3132/SiI3531 controllers. The device node of an ATA drive is ada and an ATAPI drive is cd.


----------



## phoenix (Dec 4, 2009)

Seeker said:
			
		

> ```
> ad4: 156334MB <Maxtor 6Y160M0 YAR511W0> at ata2-master SATA150
> ```
> 
> ...



Serial-ATA is ATA.  It's the next step up from Parallel-ATA.

Under FreeBSD < 8.0, all SATA devices will show up as ATA devices, unless they are attached to a SATA controller with a driver that uses the SCSI CAM system (like RAID controllers).

Under FreeBSD > 8.0, all PATA, ATAPI, and SATA devices will show up as SCSI devices, as all PATA/ATAPI/SATA device drivers will be part of the SCSI CAM system.

Thus, under the ATA subsystem, SATA devices show up as adX.  And under the CAM subsystem, SATA devices show up as daX, while PATA devices will show up as adaX.

FreeBSD 8.0 will be a bit of a hybrid, where the ATA subsystem is used by default.  But, if you have an AHCI-compliant SATA controller, you can load the ahci(4) driver and use the CAM subsystem to access your SATA devices.  And FreeBSD 8.1 should be the first to use CAM for everything (PATA, ATAPI, SATA, SCSI, SAS, USB, etc).


----------



## Seeker (Dec 4, 2009)

To sum it:
There are 2 subsystem:
ATA subsystem (Soon will be legacy)
CAM subsystem (Soon will be standard->future)

Regarding AHCI-compliant SATA controller...
Will this expose it's capability?

```
# pciconf -lv | grep -i ahci
```


----------



## phoenix (Dec 7, 2009)

That, I do not know.  Not sure if it shows up in pciconf or dmesg or not.

I think you have to load the ataahci.ko (for AHCI support using ATA subsystem) or the ahci.ko (for AHCI support using CAM subsystem) to see if it's detected or not.

There's also usually a BIOS option for how the SATA controller works (PATA emulation, SATA, or AHCI).


----------



## Seeker (Feb 12, 2010)

Ok guys, I finally tested this on my laptop.
In BIOS my sata HDD was set up to work in AHCI mode.

In 8.0, ataahci is already loaded into kernel.
So, when I kldloaded ahci, nothing happened in /dev.

So I added ahci_load="YES" in loader.conf and on reboot, voila!
I was greeted with mountroot> 
? listed what could be loaded, in my search quest, for root load.

In my case ad4 got renamed to ada0, so I picked up ada0s3c and volia.
I was thrown in a single user mode. 
Then I edited fstab to accommodate new changes and rebooted once again and all is well now.


Now, from ahci(4) man:


> Driver features include support for Serial ATA and ATAPI devices.
> Connected ATA disks are handled by the ATA protocol disk peripheral driver ada(4).
> ATAPI devices are handled by the SCSI protocol peripheral drivers cd(4), da(4), sa(4), etc.



So..., why is my DVD/RW device, still appeared as acd0 instead of cd0?
I get cd0, when I kldload atapicam, but that is not a point here.
I thought just because of kldloaded ahci, optical device will be listed in /dev as cd0


----------



## SirDice (Feb 12, 2010)

Seeker said:
			
		

> So..., why is my DVD/RW device, still appeared as acd0 instead of cd0?
> I get cd0, when I kldload atapicam, but that is not a point here.


Is it an IDE drive or SATA? If it's IDE it'll show as acd0, or if you have atapicam as cd0.


----------



## Seeker (Feb 12, 2010)

DVD/RW is connected with P(arallel)ATA cable and is working by ATAPI protocol.
So..., it is an ATAPI device and considered this:


> ATAPI devices are handled by the SCSI protocol peripheral drivers cd(4), da(4), sa(4), etc.


I expected it to appear as cd0, that is, same as if I would kldload atapicam.
So is this because of experimental AHCI's status or somehing else.
PS: Also there is no man for *ada*


----------



## SirDice (Feb 12, 2010)

Seeker said:
			
		

> So is this because of experimental AHCI's status or somehing else.


See ahci(4):



> *NAME*
> ahci -- Serial ATA Advanced Host Controller Interface driver



Where does it state that the ahci driver handles P-ATA?


----------



## Seeker (Feb 12, 2010)

SirDice said:
			
		

> See ahci(4):
> Where does it state that the ahci driver handles P-ATA?


Nowhere! 
It mentions that the ahci driver handles *ATAPI*.
So if optical device is conected with PATA or SATA cable, in either way it *talks ATAPI protocol*, while HDD no matter of cabling too; SATA or PATA, it talks ATA protocol.
Thus ATA/ATAPI standard

Do you wana say, that, under ahci driver:
Optical ATAPI device, connected via PATA cable - shows as acd0
Optical ATAPI device, connected via SATA cable - shows as cd0

In that case ahci(4) statement:

```
ATAPI devices are handled by the SCSI protocol peripheral drivers cd(4), da(4), sa(4), etc.
```
is ambiguous.
And should be:

```
ATAPI devices, connected via SATA cable, are handled by the SCSI protocol peripheral drivers cd(4), da(4), sa(4), etc.
```

PS: Yes, I know that it is not just a cabling, but a controler too.


----------



## SirDice (Feb 12, 2010)

Seeker said:
			
		

> Nowhere!
> It mentions that the ahci driver handles *ATAPI*.
> So if optical device is conected with PATA or SATA cable, in either way it *talks ATAPI protocol*, while HDD no matter of cabling too; SATA or PATA, it talks ATA protocol.
> Thus ATA/ATAPI standard


No, it mentions that it handles ATAPI devices on SATA controllers. Not ATAPI on any controller.



> Do you wana say, that, under ahci driver:
> Optical ATAPI device, connected via PATA cable - shows as acd0
> Optical ATAPI device, connected via SATA cable - shows as cd0


AHCI doesn't support PATA at all. PATA uses a different controller (ata(4)).


----------



## Seeker (Feb 12, 2010)

SirDice said:
			
		

> No, it mentions that it handles ATAPI devices on SATA controllers. Not ATAPI on any controller.


Then my statement is true;
*Optical ATAPI device, connected via SATA cable*, which of course, implies sata controler.


			
				SirDice said:
			
		

> AHCI doesn't support PATA at all. PATA uses a different controller (ata(4)).


PATA and SATA both talk ata(4) and are recognized through it.
ahci(4) just _"extends"_ SATA, and unleashes it's true power. --> HDDs


----------

