Commit 52744cce by triazo

Add more useful output for pci enumeration

parent 6a365bd5
Showing with 39 additions and 17 deletions
......@@ -7,7 +7,7 @@
#include "serial.h"
// reads a word from the io port using the pci addressing scheme
uint16_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset)
uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset)
{
uint32_t address;
uint32_t lbus = (uint32_t)bus;
......@@ -19,10 +19,25 @@ uint16_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offs
(lfunc << 8) |
(offset & 0xfc) |
((uint32_t)0x80000000));
outl(PCI_CONFIG_OUT, address);
outl(PCI_CONFIG_ACCESS, address);
// return the contents of the address clipped
return (uint16_t)((inl(0xCFC) >> ((offset & 2) * 8)) & 0xffff);
uint32_t data = inl(PCI_CONFIG_DATA);
if (data != -1)
{
serial_writestring("address 0x");
serial_hexword(address);
serial_writestring(" returned 0x");
serial_hexword(data);
serial_writestring(" on bus ");
serial_hexbyte(bus);
serial_writestring(" device ");
serial_hexbyte(slot);
serial_writestring(" function ");
serial_hexbyte(func);
serial_writechar('\n');
}
return data;
}
// Check function also prints out stuff
......@@ -34,13 +49,7 @@ void checkFunction(uint8_t bus, uint8_t device, uint8_t function) {
// Print out information about the device
serial_writestring("0x");
serial_hexhword(class);
serial_writestring(" on bus ");
serial_hexbyte(bus);
serial_writestring(" device ");
serial_hexbyte(bus);
serial_writestring(" function ");
serial_hexbyte(function);
serial_writestring("\n");
}
void checkDevice(uint8_t bus, uint8_t device)
......@@ -55,12 +64,16 @@ void checkDevice(uint8_t bus, uint8_t device)
checkFunction(bus, device, function);
uint8_t headerType = (pciConfigReadWord(bus, device, function, 0x0C) & 0xff00) >> 8;
/* serial_writestring("Header type: "); */
/* serial_hexhword(pciConfigReadWord(bus, device, function, 0x0C)); */
/* serial_writestring("\n"); */
if( (headerType & 0x80) != 0)
{
// It is a multi-function device, so check remaining functions
for(function = 1; function < 8; function++)
for(function = 0; function < 8; function++)
{
if(pciConfigReadWord(bus, device, function, 2) != 0xFFFF)
serial_writestring("found a function\n");
if(pciConfigReadWord(bus, device, function, 0) != 0x0000FFFF)
{
checkFunction(bus, device, function);
}
......@@ -71,14 +84,24 @@ void checkDevice(uint8_t bus, uint8_t device)
void checkAllBuses(void)
{
serial_writestring("Enumerating PCI busses\n");
uint8_t bus;
uint8_t device;
uint8_t function;
for(bus = 0; bus < 255; bus++)
{
for(device = 0; device < 32; device++)
{
checkDevice(bus, device);
for (function = 0; function < 8; function++)
{
if (pciConfigReadWord(bus, device, function, 0) != 0xffffffff)
{
serial_writestring("- - - - - - - - - - - - - - - - - - - -\n");
pciConfigReadWord(bus, device, function, 8);
serial_writestring("=======================================\n");
}
}
}
}
}
......@@ -9,12 +9,11 @@
#include "asm.h"
#define PCI_CONFIG_OUT 0xCF8
#define PCI_CONFIG_IN 0xCF8
#define PCI_CONFIG_ACCESS 0xCF8
#define PCI_CONFIG_DATA 0xCFC
uint16_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
uint32_t pciConfigReadWord(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
uint16_t pciCheckVendor(uint8_t bus, uint8_t slot);
void checkAllBuses(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment