add PCI driver interface enumeration routine

This commit is contained in:
Markus Fröschle
2015-11-20 19:25:57 +00:00
parent 3fc79b9c84
commit 54cd5c8151
10 changed files with 396 additions and 151 deletions

View File

@@ -14,8 +14,11 @@
volatile int32_t time, start, end;
int i;
void do_tests(void)
void do_tests(struct pci_native_driver_interface *pci)
{
#define PCI_READ_CONFIG_LONGWORD(a, b) pci->pci_read_config_longword(a, b)
#define PCI_WRITE_CONFIG_LONGWORD(a, b) pci->pci_write_config_longword(a, b)
start = MCF_SLT0_SCNT;
hexdump((uint8_t *) 0, 64);
end = MCF_SLT0_SCNT;
@@ -24,56 +27,74 @@ void do_tests(void)
xprintf("finished (took %f seconds).\r\n", time / 1000.0);
}
void wait_for_jtag(void)
struct driver_table *get_bas_drivers(void)
{
long i;
struct driver_table *ret = NULL;
do_tests();
__asm__ __volatile__(
" bra.s do_trap \n\t"
" .dc.l 0x5f424153 \n\t" // '_BAS'
"do_trap: trap #0 \n\t"
" move.l d0,%[ret] \n\t"
: [ret] "=m" (ret) /* output */
: /* no inputs */
: /* clobbered */
);
xprintf("wait a little to let things settle...\r\n");
for (i = 0; i < 100000L; i++);
return ret;
}
xprintf("INFO: endless loop now. Press reset to reboot\r\n");
while (1)
;
void pci_test(void)
{
struct driver_table *bas_drivers;
struct generic_interface *ifc;
bool pci_driver_found = false;
struct pci_native_driver_interface *pci_driver = NULL;
bas_drivers = get_bas_drivers();
printf("BaS version: %ld.%02ld\r\n", (long) bas_drivers->bas_version, (long) bas_drivers->bas_revision);
ifc = bas_drivers->interfaces;
do {
struct generic_interface *pci_driver_interface = NULL;
printf("interface type: %ld\r\n", (long) ifc[i].type);
printf("interface version: %ld.%02ld\r\n", (long) ifc[i].version, (long) ifc[i].revision);
printf("interface name: %s\r\n", ifc[i].name);
printf("interface description: %s\r\n", ifc[i].description);
if (ifc[i].type == PCI_NATIVE_DRIVER)
{
pci_driver_found = true;
if (!pci_driver_interface || (ifc[i].version > pci_driver_interface->version ||
(ifc[i].version == pci_driver_interface->version && ifc[i].revision > pci_driver_interface->revision)))
{
/*
* either no PCI driver interface found yet or with lower version or with lower version and higher revision
*
* replace it
*/
pci_driver = ifc[i].interface.pci_native;
pci_driver_interface = &ifc[i];
printf("PCI native driver interface v%d.%02d found\r\n", pci_driver_interface->version, pci_driver_interface->revision);
}
}
} while (ifc[++i].type != END_OF_DRIVERS);
if (pci_driver_found)
{
do_tests(pci_driver);
}
}
int main(int argc, char *argv[])
{
printf("FPGA JTAG configuration support\r\n");
printf("test FPGA DDR RAM controller\r\n");
printf("\xbd 2014 M. F\x94schle\r\n");
printf("PCI test routines\r\n");
printf("\xbd 2014 M. Fr\x94schle\r\n");
printf("You may now savely load a new FPGA configuration through the JTAG interface\r\n"
"and your Firebee will reboot once finished using that new configuration.\r\n");
if (argc == 2)
{
/*
* we got an argument. This is supposed to be the address that we need to jump to after JTAG
* configuration has been finished. Meant to support BaS in RAM testing
*/
char *addr_str = argv[1];
char *addr = NULL;
char *end = NULL;
addr = (char *) strtol(addr_str, &end, 16);
if (addr != NULL && addr <= (char *) 0xe0000000 && addr >= (char *) 0x10000000)
{
/*
* seems to be a valid address
*/
// bas_start = (long) addr;
// printf("BaS start address set to %p\r\n", (void *) bas_start);
}
else
{
// printf("\r\nNote: BaS start address %p not valid. Stick to %p.\r\n", addr, (void *) bas_start);
}
}
Supexec(wait_for_jtag);
Supexec(pci_test);
return 0; /* just to make the compiler happy, we will never return */
}