1

Imagine a system with one SATA controller. If controller operates in IDE mode it will show up in device manager like this:

Windows XP:

IDE controller's name
Primary IDE Channel
Secondary IDE Channel

Windows >= Vista:

IDE controller's name
ATA Channel 0
ATA Channel 1

And if controller operates in AHCI mode it will show up like "SATA AHCI controller" on both XP and >= Vista.

SATA controller in AHCI mode supports up to 32 devices (32 bit mask indicates device connection). I think it is just software limitation, given that each device requires separate channel, it is unlikely that such system exist where SATA controller is "wired" with all 32 channels. But I think 32 is a number that implies that controller can deal with more than two devices and thus has more than two channels. So, I want to ask how many channels SATA controller often has in practice. ATA controller has two channels, so does it mean that SATA controller has the same number of channels for software compatibility in IDE mode? Or maybe it has more than two channels, but in IDE mode only first two channels will be available? (at least on XP because "primary" channel and "secondary" channel greatly reduce the possibility of "third" channel which is not the case with "0" channel, "1" channel, "2" channel and so on)

igntec
  • 1,006
  • 10
  • 24
  • You haven't mentioned any programming related reason why you need to know this. – Ross Ridge Jan 31 '15 at 20:30
  • I want to figure out what ports particular hard drive uses and try to issue some ATA command (without any ioctls). We can get resource information by enumerating disk controllers. And to properly write some code I need to know whether controller is limited to two channels, like ATA Channel 0 and ATA Channel 1 or it can have more channels when operating in IDE mode. – igntec Jan 31 '15 at 20:42
  • 1
    I don't see how the actual number physical SATA ports should matter in that case. How are you issuing ATA commands without ioctls? In any case, you seem to be assuming that only 0 or 1 drives can be attached, but in reality SATA port multipliers can be used to attach up to 15 drives to a physical port. Also you seem to be assuming a standardized device hierarchy in Windows for SATA controller drivers, but this doesn't seem to be the case. My Marvel AHCI controller has "ATA Channel 0" child nodes, but my Intel AHCI controller has the drives as direct children. – Ross Ridge Jan 31 '15 at 21:09
  • Thanks for the info about Marvel AHCI controller hierarchy, so their controller "reports" two ATA Channels apart from itself, thus providing Windows with a way to change such options like enable/disable DMA mode. So when you check DMA box Windows reports it to Marvel driver and driver lets the controller know what mode it should be using for some particular device, albeit driver works with controller through AHCI-defined interface (which implies only DMA mode), so it is obviously some vendor-specific non-standard stuff going on here. – igntec Feb 01 '15 at 13:27
  • Also can you tell me what is the maximum number of ATA Channels that SATA controller can have? And the thing I am especially interested in is whether the set of registers for SATA port multipliers is the same as for SATA hard drives and cd-roms. – igntec Feb 01 '15 at 13:34
  • Again you're making false assumptions. The implementation of the Marvel AHCI controller driver doesn't work the way you describe. AHCI controller *hardware* doesn't support any actual ATA channels. You can download the AHCI spec from Intel to learn how AHCI controllers are implemented. You need to update your question with the actual reason why want to do this or it will be closed for being off-topic. – Ross Ridge Feb 01 '15 at 16:54

1 Answers1

2

A bit later but maybe would be useful for others.

Let's add some clarifications. There is SATA Host Controller with AHCI interface (Advanced Host Controller Interface). And there is SATA drive (or any other device with AHCI interface).

SATA Host Controller (HC) has a number of ports. Theoretically there could be up to 32 SATA ports but not less than 1 (well w/o any port HC itself doesn't make any sense). The number of actual ports depends on implementation. General HC chips used in PC more likely to have 1 or 2 ports. SATA drives are connected to ports. So if SATA HC has 2 ports than up to 2 SATA drives/devices could be attached.

In real life everything is even more interesting. As @Ross Ridge mentioned in comments, port multipliers could be used. Port Multiplier is to increase the number of devices that can be attached. Again port multiplier is device connected to SATA HC port (not to Host Controller itself). One multiplier to one port. Second multiplier could be connected to other port, etc. The support of multipliers is implementation defined. Some HC could work with them, some might not. Multipliers have 16 ports. Port '0xF' is special control port of multiplier. So up to 15 devices could be connected.

So all above is about SATA specification. Considering the listed questions itself:

  • OS drivers could enumerate and name drives by it's own way. Like you mentioned Secondary IDE Channel or ATA Channel 1. First name more likely is legacy from drives w/ parallel interfaces. In fact the word 'channel' even is not in SATA AHCI specification. There are ports :)

  • Some fu... drivers could imply "software limitations" like do not support multipliers or work only with one port. Regularly update drivers.

  • thus providing Windows with a way to change such options like enable/disable DMA mode. Windows DMA mode has nothing to do with SATA drive. SATA Host Controller use special buffers to allocate data received from drives. DMA mode in this case more like how OS get access to these buffers but not how HC communicate with attached drives.

  • Also can you tell me what is the maximum number of ATA Channels that SATA controller can have?. There are ports. The number of ports is implementation defined. If you know the address of SATA Host Controller on your motherboard read CAP register, 4 low bits are Number of Ports - 1. PS: you will need a driver to get direct access to physical memory so...

user3124812
  • 1,861
  • 3
  • 18
  • 39