PCI Question(s)

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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: PCI Question(s)

Post by Brynet-Inc »

Omega wrote:All I can say is... OMG!!! That code is so f-ed up!! It looks like I am going to be stripping the hell out of this one. I'll be back in about a month, maybe longer. lol

thanks for the help guys.

P.s. Google is your Friend too. ;)
Wow, a single search via google found a potential datasheet for the device... did you even search?

http://www.sci-worx.com/products/product.aspx?id=63

As for your "google" crack, I'm aware.. I just wasn't going to feed you a direct link. :roll:

EDIT: *sigh* There is no datasheet listed, but a similar model, the 3114, has a datasheet.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: PCI Question(s)

Post by Omega »

Been using Google like this for months, so its cool to pass direct links if you want. I'm trying to get this done before I die, so direct link me up bro.

Quick thought: Why is it necessary to have the specs of the device? Can I not treat each mass storage device the same, even if they are indeed not the same? What actually prevents me from talking to this device? It isn't that I can not write to its registers, because I can and I can read them too. What makes each device have to have a different driver? I assume that if I know it's BARs, Command/Status Registers, and IRQ, then I should be able to issue commands to the device and it should respond. I confess I know nothing about the differences between two devices programmatically, so I am wondering what causes this affect.

I suppose my understanding of PCI does too limit me greatly. I visualize it as a toll booth where the little man inside shouts across the bridge every command I issue, he then hears the response, writes it down, places it in a bucket, and I reach in and decode his message. And, if the device acts the same as me, then can I not just send it a SEEK command via the PCI toll booth operator and have it return?

I also contemplate this same issue on the IDE Bus, is it true that I will need multi-drivers there too? I just don't see why one can not just write one driver to rule them all. Please elaborate. Sorry if this sounds dumb.
Free energy is indeed evil for it absorbs the light.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: PCI Question(s)

Post by bewing »

The IDE bus is standardized. Therefore, you only need to make one driver for that. RAID is NOT standardized. You will need a new driver for each new RAID controller. That is the difference. SATA is only partially standardized. SATA RAID is going to be rather messy, guaranteed. The only way you will get off easy is if you can turn off the RAID feature of the controller, and just use the board as a standardized ATA interface to the SATA drive.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: PCI Question(s)

Post by Omega »

I'd have to do that manually right? I couldn't achieve that with code could I? Good news then, at least I haven't to worry about IDE, thanks a lot for making that clear. I suppose it is because of the chipsets being different which causes such a fuss. I don't have much time to work as I have class in the morning, but I managed to strip out 7000 + lines and from the 1000 + left I can see how one speaks to the sii3112 controller, which is helpful. I think I might just support sii3112 and sii3114, and ACER chipsets when I finalize my OS; I don't really want to spend much more time digging up specs. I suppose I could write a C++ DLL and have it scan the live system to see if the OS will run before users download the OS, so I can perhaps avoid grievance that way. Gosh, this really f-ing sucks.

Thanks a lot for your time.
Free energy is indeed evil for it absorbs the light.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: PCI Question(s)

Post by bewing »

Omega wrote:I'd have to do that manually right? I couldn't achieve that with code could I?
Manual configuration is a thing of the past. All boards these days are fully software configurable -- just so long as you can find the specs for how to do the configuration. It always comes back around to finding and digging through the specs.

And once you verify your understanding of how to speak to this board of yours, make sure to post it in the wiki. :wink:
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: PCI Question(s)

Post by Brendan »

Hi,
bewing wrote:The IDE bus is standardized. Therefore, you only need to make one driver for that. RAID is NOT standardized. You will need a new driver for each new RAID controller. That is the difference. SATA is only partially standardized. SATA RAID is going to be rather messy, guaranteed. The only way you will get off easy is if you can turn off the RAID feature of the controller, and just use the board as a standardized ATA interface to the SATA drive.
In some cases I wouldn't be surprised if the RAID controller transparently makes logical drives (consisting of multiple physical drives) look like physical drives to software, so that the OS can treat (for e.g.) an array of 4 disk drives the same as the OS would treat a single (non-RAID) physical drive connected to a (non-RAID) SATA controller. This would make sense from a "backward compatibility" perspective, and if this is the case you wouldn't need a driver specifically for your RAID controller (unless you were changing the way physical drives were mapped to logical drives, implementing proper hot-plug support or doing something else that relies on RAID).

I'm only guessing, so you should probably ignore me (but it'd still be interesting to see if Linux uses a special device driver for your card, or if it's using a plain/generic SATA driver).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: PCI Question(s)

Post by Omega »

If I find the time to figure it out and actually do, I will certainly post my understanding of it in the wiki. I'll even send the full working code straight to you guys who have helped me if you wish.

You know I don't think it does that with RAID, but I do believe it does that with ATA. Mine is for sure sii3112 as the specs match my MB and Device perfectly, plus that is what Windows tells me in the Device Manager (sii3112). I think this thing is sitting right behind the RAID controller ready to go. When I find more time I am going to start testing some commands to see what happens before trying to switch off RAID, which I don't think is on. I will check my BIOS and let you know later.

As far as Linux, here is what I can form from looking at some drivers: It has a driver specifically for my card, with default chipsets just in case which might not work (like the BSD drivers do). Untested/Unsure; just conversation.
Free energy is indeed evil for it absorbs the light.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: PCI Question(s)

Post by bewing »

I would agree with Brendan that the RAID controller pretends that the array of attached drives is just one big drive -- and it decodes accesses to the one virtual drive internally into SATA commads to the individual drives.

But the question is "what interface does the RAID controller present to the CPU"? Does the controller pretend that it is just an additional ATA bus with a big drive attached? Does it pretend that it is a SCSI bus with a big drive attached?

If it really created a "virtual ATA bus" then it should probably have been detected during the normal ATA bus detection phase (assuming that the code actually tried to detect ATA bus #3 and #4). This would also present problems with 48bit LBA addressing limitations. Therefore, I would think it unlikely that a board manufacturer would do this. However, the BSD driver Brynet found is called pciide -- which suggests it really does act like an IDE. :-k

Since SCSI does not have the 48bit LBA limitation, I would have instead expected any RAID controller to use that interface.

When it comes to RAID, however, the board cannot just present a simple interface. At the very least, the controller would have to have one additional command to do a rebuild if one of the array drives goes bad, and is replaced with a blank drive.

And yes, RAID can just do a simple 1-1 mapping with no fancy RAID "striping" -- a 1-1 mapping is called "RAID level 1". Basically, that means that RAID is "off".
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: PCI Question(s)

Post by quok »

bewing wrote: And yes, RAID can just do a simple 1-1 mapping with no fancy RAID "striping" -- a 1-1 mapping is called "RAID level 1". Basically, that means that RAID is "off".
Perhaps I'm confused, but by "simple 1-1 mapping" do you mean exposing the individiual disks behind the controller as well.. seperately addressable individual disks instead of as one virtual device? That's typically called JBOD - Just a Bunch Of Disks.

Or do you mean the situation where 1 disk is mapped to another by the RAID controller... which is RAID 1, but that's RAID Mirroring, with no "fancy striping". When I hear somebody say "RAID is off" I tend to think they are talking about JBOD.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: PCI Question(s)

Post by bewing »

Actually, I messed up. What I meant was "RAID 0" not RAID 1.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: PCI Question(s)

Post by quok »

bewing wrote:Actually, I messed up. What I meant was "RAID 0" not RAID 1.
Ah.

However, RAID 0 is striping. To oversimplify it, RAID 0 just concatenates two disks so they appear as one larger disk. There's no parity information stored at all, and thus no redundancy. If one disk fails, all your data is gone. Hope you have a backup. :)

Perhaps this will help: http://en.wikipedia.org/wiki/RAID
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: PCI Question(s)

Post by Omega »

OK, I wanted to know for sure if my Hard Disk was being controlled by the sil3112 SATA Controller, so I went into my BIOS and disabled that controller, reboot, and we get an error, "NO BOOTABLE DISK FOUND.". I go back into the BIOS, re-enable that controller, and here we are utilizing my disk again, so I am pretty sure now that I have been going after the right controller. My controller supports (1/0) RAID and I think it is setup to do 0, since I only have one disk. It is good to know my disk is behind the controller I have been working with all this time, now I suppose I should start trying to port that BSD driver. Any more thoughts?
Free energy is indeed evil for it absorbs the light.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: PCI Question(s)

Post by Omega »

More Information:

I confirm that my Hard Disk is behind the SATA Controller for sure. Its specs:
Primary: (My Disk is Here)
IDE Base is : 9800 (BAR 0)
Alt Base is : 9C02 (BAR 1)
DMA Base : A800 (BAR 4)

Secondary: (Nothing Here)
IDE Base : A000 (BAR 2)
Alt Base: A402 (BAR 3)
DMA Base: A808 (BAR 4)

* BAR 5 is a Memory Address of 200h size
So, it is clear now that BAR 0 - 1 belongs to the Primary Device, so I do all my I/O stuff there I suppose. Can someone elaborate on DMA Base? I don't have a RAID Array, so perhaps working with my Hard Disk Device may be easier than we initially thought, any ideas?

Furthermore, can someone please do me a huge favor and illustrate (in theory/pseudo) how one would (using the above information) may interact with the device attached to this controller?

Like for example:

Identify Device:
01. Issue Command XXX to BAR 0
02. Read Response XXX from BAR 5
...
...

I would really appreciate it. I am just looking for some simple steps to follow so to setup this device for programmatic interaction. Thanks in advance.
Free energy is indeed evil for it absorbs the light.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: PCI Question(s)

Post by quok »

Meh, I got bored so I figured I'd go the extra mile here, and I'll even be extra nice at the risk of being accused of being aggressive again. :roll:

You say you have one drive hooked up to the controller? In that case, I would think that even RAID 0 is not being used. My reasoning for that is 1) all RAID levels require at least 2 disks, and 2) I happen to have a Sil3512, a newer version of that same card. The 3512 is a 2 port SATA2 controller that can handle JBOD, RAID 0 and 1. When I had one drive hooked up to mine, the card wouldn't allow me to specify a RAID level and just exported that single disk. When I had two drives hooked up to the controller, I could select a RAID level. JBOD wasn't one of the options I believe, but that's fine, because JBOD technically isn't RAID anyway. :) In that case, the card exported both disks individually. Once I created a logical drive and specified a RAID level, the card once again exported a single (this time logical) disk.

This was all under Linux 2.6.25, btw. With a single drive connected, the disk was exported as /dev/sda. When two drives were connected, but no logical drives defined, I had /dev/sda and /dev/sdb. After I created a RAID mirror, I then had /dev/sda again, but this time since it is RAID-1, /dev/sda reflected the logical drive, and not the physical drives behind it. With RAID defined, there's no way to get to the individual drives behind the device. (Technically there is, but that is not important here.)

The way my card is set up currently, it just exports both disks. I don't use the RAID features of it at all, I prefer software RAID for most cases. I only point that out so you can better understand this snippet of my dmesg:

Code: Select all

sata_sil 0000:00:08.0: version 2.3                                                                              
scsi0 : sata_sil                                                                                                
scsi1 : sata_sil                                                                                                
ata1: SATA max UDMA/100 mmio m512@0xec000000 tf 0xec000080 irq 16                                               
ata2: SATA max UDMA/100 mmio m512@0xec000000 tf 0xec0000c0 irq 16
...
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)                                                          
ata1.00: ATA-7: ST3750640AS, 3.AAE, max UDMA/133                                                                
ata1.00: 1465149168 sectors, multi 16: LBA48 NCQ (depth 0/32)                                                   
ata1.00: configured for UDMA/100                                                                                
ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 310)                                                          
ata2.00: ATA-7: ST3750640AS, 3.AAE, max UDMA/133                                                                
ata2.00: 1465149168 sectors, multi 16: LBA48 NCQ (depth 0/32)                                                   
ata2.00: configured for UDMA/100                                                                                
scsi 0:0:0:0: Direct-Access     ATA      ST3750640AS      3.AA PQ: 0 ANSI: 5                                    
scsi 1:0:0:0: Direct-Access     ATA      ST3750640AS      3.AA PQ: 0 ANSI: 5                                    
sd 0:0:0:0: [sda] 1465149168 512-byte hardware sectors (750156 MB)                                              
sd 0:0:0:0: [sda] Write Protect is off                                                                          
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00                                                                       
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA                         
sd 0:0:0:0: [sda] 1465149168 512-byte hardware sectors (750156 MB)                                              
sd 0:0:0:0: [sda] Write Protect is off                                                                          
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00                                                                       
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA                         
sda: unknown partition table                                                                                   
sd 0:0:0:0: [sda] Attached SCSI disk                                                                            
sd 1:0:0:0: [sdb] 1465149168 512-byte hardware sectors (750156 MB)                                              
sd 1:0:0:0: [sdb] Write Protect is off                                                                          
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00                                                                       
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA                         
sd 1:0:0:0: [sdb] 1465149168 512-byte hardware sectors (750156 MB)                                              
sd 1:0:0:0: [sdb] Write Protect is off                                                                          
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00                                                                       
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA                         
sdb: sdb1                                                                                                      
sd 1:0:0:0: [sdb] Attached SCSI disk                             
Here's the output of lspci on that machine. The SATA RAID card is the 3rd line.

Code: Select all

00:00.0 Host bridge: VIA Technologies, Inc. P4M266 Host Bridge
00:01.0 PCI bridge: VIA Technologies, Inc. VT8633 [Apollo Pro266 AGP]
00:08.0 RAID bus controller: Silicon Image, Inc. SiI 3512 [SATALink/SATARaid] Serial ATA Controller (rev 01)
00:0f.0 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.3 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 86)
00:10.5 Network controller: VIA Technologies, Inc. VT8237 Integrated Fast Ethernet Controller
00:11.0 ISA bridge: VIA Technologies, Inc. VT8237 ISA bridge [KT600/K8T800/K8T890 South]
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 60)
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 78)
01:00.0 VGA compatible controller: S3 Inc. VT8375 [ProSavage8 KM266/KL266]
Anyway, depending on what I stated above you can pretty easily determine how your card is set up. You could also simply check the card's BIOS by hitting ALT+S during boot.

And finally, under linux 2.6.26, both the 3112 and 3512 chipsets are handled by the sata_sil driver, which can be found in linux-2.6.26/drivers/ata/sata_sil.c. Looking at the first couple lines of that file, I found this comment:

Code: Select all

/*
 *  Documentation for SiI 3112:
 *  http://gkernel.sourceforge.net/specs/sii/3112A_SiI-DS-0095-B2.pdf.bz2
 *
 *  Other errata and documentation available under NDA.
 */
There you go, that looks like a datasheet for your card. You may also want to look at the libata documentation, there might be additional documentation there.

So, given all this information, and especially that datasheet, you should be able to write a driver for this card now. If I was doing that myself, I'd probably try to write it based solely off the 3112A datasheet. And don't forget to update the Wiki with implementation details. I'll go create a page for both cards and add a link to the datasheet now. I wonder if there's a datasheet for the 3512 as well. They may even be register compatible, who knows.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: PCI Question(s)

Post by Omega »

I can not express in words how much I appreciate you taking the time to track that down for me. Your boredom has decreased my stress levels, expanded my life expectancy, and most of all increased the likelihood of me actually writing this driver and having it described in the wiki. And, like I said, you guys are candidates for fully working code at which time is TBA. Thank you very, very much! I'm off to do some reading.
Free energy is indeed evil for it absorbs the light.
Post Reply