PCI device set-up

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.
Post Reply
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

PCI device set-up

Post 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,
geppy
Member
Member
Posts: 27
Joined: Wed Jun 11, 2008 5:30 pm

Re: PCI device set-up

Post by geppy »

search on this forum will help you lazy one
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: PCI device set-up

Post by LoseThos »

Wikipedia was a big help :oops:

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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: PCI device set-up

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: PCI device set-up

Post by LoseThos »

Thanks!
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: PCI device set-up

Post by 01000101 »

http://wiki.osdev.org/PCI
8)

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!). =)
geppy
Member
Member
Posts: 27
Joined: Wed Jun 11, 2008 5:30 pm

Re: PCI device set-up

Post 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.
Post Reply