removed debug printout

incorporated EmuTOS byte swap routines for PCI access
This commit is contained in:
Markus Fröschle
2013-10-27 06:24:16 +00:00
parent 554b30faa6
commit b738de7f41
4 changed files with 81 additions and 6 deletions

View File

@@ -30,15 +30,82 @@
#include "bas_printf.h"
#include "util.h"
uint32_t pci_read_config_longword(uint16_t slot, uint16_t function, uint16_t offset)
uint16_t pci_read_config_word(uint16_t slot, uint16_t function, uint16_t offset)
{
return 0;
uint16_t value;
/* initiate PCI configuration access to device */
MCF_PCI_PCICAR = MCF_PCI_PCICAR_E | /* enable configuration access special cycle */
MCF_PCI_PCICAR_DEVNUM(slot + 10) | /* device number, devices 0 - 9 are reserved */
MCF_PCI_PCICAR_FUNCNUM(function) | /* function number */
MCF_PCI_PCICAR_DWORD(offset);
value = * (volatile uint16_t *) PCI_IO_OFFSET; /* access device */
/* finish config cycle */
MCF_PCI_PCICAR = MCF_PCI_PCICAR_DEVNUM(slot + 10) |
MCF_PCI_PCICAR_FUNCNUM(function) |
MCF_PCI_PCICAR_DWORD(0);
swpw(value);
return value;
}
uint16_t pci_read_config_word(uint16_t slot, uint16_t function, uint16_t offset)
uint32_t pci_read_config_longword(uint16_t bus, uint16_t slot, uint16_t function, uint16_t offset)
{
return 0;
uint32_t value;
/* initiate PCI configuration access to device */
MCF_PCI_PCICAR = MCF_PCI_PCICAR_E | /* enable configuration access special cycle */
MCF_PCI_PCICAR_DEVNUM(slot + 10) | /* device number, devices 0 - 9 are reserved */
MCF_PCI_PCICAR_FUNCNUM(function) | /* function number */
MCF_PCI_PCICAR_DWORD(offset);
value = * (volatile uint32_t *) PCI_IO_OFFSET; /* access device */
/* finish config cycle */
MCF_PCI_PCICAR = MCF_PCI_PCICAR_DEVNUM(slot + 10) |
MCF_PCI_PCICAR_FUNCNUM(function) |
MCF_PCI_PCICAR_DWORD(0);
swpl(value);
return value;
}
void pci_scan(void)
{
uint16_t bus;
uint16_t slot;
uint16_t function;
xprintf("PCI bus scan\r\n");
for (bus = 0; bus < 1; bus++)
{
for (slot = 0; slot < 16; slot++)
{
for (function = 0; function < 8; function++)
{
uint32_t value;
value = pci_read_config_longword(bus, slot, function, 0);
if (value != 0xffffffff)
{
xprintf("[%02x] [%02x] [%02x]: %08x\r\n", bus, slot, function, value);
}
/* test for multi-function device to avoid ghost device detects */
value = pci_read_config_longword(bus, slot, function, 0x0c);
if (!(((value & 0xff00) >> 16) & 0x80)) /* no multi function device */
function = 8;
}
}
}
xprintf("finished\r\n");
}
/* start of PCI initialization code */
@@ -106,5 +173,7 @@ void init_pci(void)
MCF_PCI_PCIGSCR &= ~MCF_PCI_PCIGSCR_PR;
xprintf("finished\r\n");
pci_scan();
}