Page 1 of 1
PCI device set-up
Posted: Sun Jan 04, 2009 1:37 am
by LoseThos
So far, I haven't had to use PCI devices -- I use PS/2 kbdmouse; VGA graphics; PIO ATA/ATAPI hard drive/ CD-ROM; internal PC speaker...
However, now, I'm going to be getting a machine with HD Audio. It says to set-up PCI devices as the first step in HD Audio. Does someone have the exact name of the Intel datasheet I need for seting-up PCI devices? Maybe, you could also give an overview or warn me of any tricky things.
thanks,
Re: PCI device set-up
Posted: Sun Jan 04, 2009 2:35 am
by geppy
search on this forum will help you lazy one
Re: PCI device set-up
Posted: Sun Jan 04, 2009 8:31 am
by LoseThos
Wikipedia was a big help
Okay, 256 possible busses, 32 possible devices, 8 possible functions.
0xF0000000 + bus<<20 + device<<15 + function<<12
I scan them all and get crazy data for bus>0xE0. What's the correct thing to do about these crazy devices?
Do you guys scan all 256 busses? There's an APIC in there, too. Is that a PCI device?
Boy, was I confused. Things are making a lot more sense with a big-picture of memory.
I called the BIOS memory routine -- 015h 0e820. It has some #2 ranges. Am I supposed to figure-out which PCI busses are valid from that? God only knows what different BIOS's return.
I have been reading PCI devices without realizing it. The ICH is PCI. I thought that device function stuff was just ICH.
Umm... back to HD Audio, I guess I have to do something about interrupts. PCI has 4 lines that are connected in strange order to each slot? There's undoubtedly a ICH config register for IRQ line number. I've got to discover how PCI interrupts work. What numbers do they generate and how to you acknowlege them and stuff? You can probably configure the number, huh?
Re: PCI device set-up
Posted: Sun Jan 04, 2009 9:25 am
by Combuster
The good way to do this is to scan the first bus (#0) for PCI bridges, and record the bus numbers they refer to, then recursively enumerate those buses too.
A quick and dirty way is to enumerate each bus until you find one or two subsequent buses that are empty.
And you should grab the PCI spec if you can.
Re: PCI device set-up
Posted: Sun Jan 04, 2009 9:38 am
by LoseThos
Thanks!
Re: PCI device set-up
Posted: Sun Jan 04, 2009 11:54 am
by 01000101
http://wiki.osdev.org/PCI
also, for the chipset that you'll be programming for (and also the vendor_id and device_id), you need to either A: look on the HD card and find the programmable chip, or lookup your device on the manufacturers website and it normally will list the chipset, from there, you can look up that chipset's datasheet and its register functions. If it's an Intel chipset, expect an extremely lengthy (yet detailed) datasheet with a huge portion of register descriptions and a near-nonexistant portion on actually programming it (but that would take the fun out of it now wouldn't it!). =)
Re: PCI device set-up
Posted: Sun Jan 04, 2009 2:42 pm
by geppy
largest PCI bus # can be found with PCI BIOS call
ax=0b101h, int 1ah if supported. Not necessary that every bus within the range will be valid or present. It's also likely that one of the bus will be ISA.
IOAPIC located on motherboard, LocalAPIC located inside CPU. Neither are PCI devices. They can be found thru ACPI tables. On most (if not all) x86-64 CPUs LocalAPIC can be found with CPUID and its mem mapped addr with 'rdmsr' instruction where MSR=1bh
this is one of the most useful threads about APIC and interrupts
Intel makes datasheets available for everything they make. So there must be one for your audio device. I think intel HD audio integrated in ICH but still gets listed as PCI. Here is link
http://www.intel.com/design/chipsets/hdaudio.htm
PCI does have 4 lines (INTA,INTB,INTC,INTD) but you dont get to choose them, insted you read "Interrupt Line" & "Interrupt Pin" from PCI config space
BARs located at offsets 10h,14h,18h,1ch,20h,24h of pci config space. These are used to determine IO pots, whenever ports are memory mapped or not, and range.