PCI: Host/PCI Bridge HeaderTyp == 0?

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
sebihepp
Member
Member
Posts: 194
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

PCI: Host/PCI Bridge HeaderTyp == 0?

Post by sebihepp »

Hello,

I am experimenting with the PCI-Bus. So far I can enumerate Bus 0.
On Bochs I get one Host to PCI Bridge, one PCI to ISA Bridge and one
VGA Card(Cirrus). If I search for anything on Bus 1, 2, ... I get nothing.
That's clear: I didn't tell each Bridge the primary, secondary and last bus number.
So the first Bridge I think is the Host to PCI bridge. But she returns a zero as header type.
So there is no field for the bus numbers. Should I trust the Classcode or the Headertype?

My Code for reading and writing PCI:

Code: Select all

volatile unsigned int ReadPCI(unsigned char pBus, unsigned char pDevice,
	unsigned char pRegister)
{
	outl(0xCF8, 0x80000000 | (pBus << 16) | ((pDevice & 0x0F) << 11) |
		(0 << 8) | pRegister);
	return inl(0xCFC);
}

volatile void WritePCI(unsigned char pBus, unsigned char pDevice,
	unsigned char pRegister, unsigned int pValue)
{
	outl(0xCF8, 0x80000000 | (pBus << 16) | ((pDevice & 0x0F) << 11) |
		(0 << 8) | pRegister);
	outl(0xCFC, pValue);
}
Testing Classcode:

Code: Select all

if ((unsigned int)((ReadPCI(Bus, Device, 0x0C) >> 16) &
    0x7F) == (unsigned int)0x00) {
And am I right, if I say every Perihperal can be accessed through PCI? DMA controller, PIC, PIT,
just everything. The only reason why we can access them with Ports too, is that the BIOS
initializes every PCI-device and set the standard I/O-Ports, right?

best regards
sebihepp
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: Host/PCI Bridge HeaderTyp == 0?

Post by Combuster »

the PCI specification only governs PCI-to-PCI bridges. Bochs has no AGP nor PCIe (which are software compatible with PCI), therefore no secondary PCI buses, and therefore no PCI-to-PCI bridges.

The host-to-pci bridge you see is the piece of hardware that controls access to the PCI bus from whatever system architecture is above it. That bridge is the piece of hardware that listens to ports 0xCF8/0xCFC, and looks at the system bus sending the appropriate data onto that bus. There is nothing in there that you want to configure unless you are writing drivers for your specific chipset - the BIOS sets it up for you.
"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 ]
sebihepp
Member
Member
Posts: 194
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: PCI: Host/PCI Bridge HeaderTyp == 0?

Post by sebihepp »

Well, I want to write some specific drivers. =)

But how can I access the ISA-bus? For example the floppy disc controller?
Therefore I had to programm the PCI/ISA-bridge and specify the busnumbers.
But I read all zero.

cheers
sebihepp
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: Host/PCI Bridge HeaderTyp == 0?

Post by Combuster »

sebihepp wrote:But how can I access the ISA-bus?
By just doing it - the bios configures the chipset with sane values. How do you think you programmed the PIC/PIT?

Again, only pci-to-pci bridges can be configured as one. There is no "isa" in "pci-to-pci bridge". They follow a different standard (be creative and read the PCI docs)
"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 ]
Post Reply