diff --git a/bas.lk.in b/bas.lk.in index 8803ac4..534ec24 100644 --- a/bas.lk.in +++ b/bas.lk.in @@ -69,7 +69,7 @@ SECTIONS /* * if we compile to RAM anyway, there is no need to copy anything */ -#if COMPILE_RAM +#ifdef COMPILE_RAM . = ALIGN(16); __BAS_DATA_START = .; *(.data) @@ -82,7 +82,7 @@ SECTIONS *(.rodata) *(.rodata.*) #endif -#if COMPILE_RAM +#ifdef COMPILE_RAM . = ALIGN(16); _usb_buffer = .; #endif /* COMPILE_RAM */ @@ -98,7 +98,6 @@ SECTIONS */ AT (ALIGN(ADDR(.text) + SIZEOF(.text), 4)) { - . = ALIGN(16); __BAS_DATA_START = .; *(.data) __BAS_DATA_END = .; diff --git a/include/pci.h b/include/pci.h index 0c42262..4c669bd 100644 --- a/include/pci.h +++ b/include/pci.h @@ -242,8 +242,8 @@ extern int32_t pci_unhook_interrupt(int32_t handle); ((device << 8) | \ (function)) -#define PCI_HANDLE(bus, slot, function) (0 | ((bus & 0xff) << 8 | (slot & 0x1f) << 3 | (function & 7))) -#define PCI_BUS_FROM_HANDLE(h) (((h) & 0xff00) >> 8) +#define PCI_HANDLE(bus, slot, function) (0 | ((bus & 0xff) << 10 | (slot & 0x1f) << 3 | (function & 7))) +#define PCI_BUS_FROM_HANDLE(h) (((h) & 0xff00) >> 10) #define PCI_DEVICE_FROM_HANDLE(h) (((h) & 0xf8) >> 3) #define PCI_FUNCTION_FROM_HANDLE(h) (((h) & 0x7)) diff --git a/sources/BaS.c b/sources/BaS.c index 5387614..dc85db2 100644 --- a/sources/BaS.c +++ b/sources/BaS.c @@ -258,8 +258,6 @@ void BaS(void) NOP(); /* force pipeline sync */ xprintf("finished\r\n"); - init_usb(); - #ifdef MACHINE_FIREBEE xprintf("IDE reset: "); /* IDE reset */ diff --git a/sources/ehci-hcd.c b/sources/ehci-hcd.c index 87bbac0..66de0b5 100644 --- a/sources/ehci-hcd.c +++ b/sources/ehci-hcd.c @@ -902,12 +902,12 @@ int ehci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void ** return(-1); } memcpy(gehci.descriptor, &rom_descriptor, sizeof(struct descriptor)); - if ((long)pci_rsc_desc >= 0) + if ((long) pci_rsc_desc >= 0) { unsigned short flags; do { - debug("PCI USB descriptors: flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx\r\n", + debug("PCI USB descriptors (at %p): flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx\r\n", pci_rsc_desc, pci_rsc_desc->flags, pci_rsc_desc->start, pci_rsc_desc->offset, pci_rsc_desc->dmaoffset, pci_rsc_desc->length); if (!(pci_rsc_desc->flags & FLG_IO)) { diff --git a/sources/ohci-hcd.c b/sources/ohci-hcd.c index 122687b..738dee7 100644 --- a/sources/ohci-hcd.c +++ b/sources/ohci-hcd.c @@ -2016,7 +2016,7 @@ int ohci_usb_lowlevel_init(int32_t handle, const struct pci_device_id *ent, void unsigned short flags; do { - xprintf("\r\nPCI USB descriptors: flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx\r\n", + xprintf("\r\nPCI USB descriptors (at %p): flags 0x%04x start 0x%08lx \r\n offset 0x%08lx dmaoffset 0x%08lx length 0x%08lx\r\n", pci_rsc_desc, pci_rsc_desc->flags, pci_rsc_desc->start, pci_rsc_desc->offset, pci_rsc_desc->dmaoffset, pci_rsc_desc->length); if (!(pci_rsc_desc->flags & FLG_IO)) { diff --git a/sources/pci.c b/sources/pci.c index c657cc1..422aeaf 100644 --- a/sources/pci.c +++ b/sources/pci.c @@ -33,7 +33,7 @@ #include "interrupts.h" #include "wait.h" -// #define DEBUG_PCI +//#define DEBUG_PCI #ifdef DEBUG_PCI #define debug_printf(format, arg...) do { xprintf("DEBUG: " format "\r\n", ##arg); } while (0) #else @@ -130,8 +130,10 @@ static int handle2index(int32_t handle) { int i; + debug_printf("handle2int: handles[] is at %p\r\n", &handles[0]); for (i = 0; i < NUM_CARDS; i++) { + debug_printf("handle2index: handles[%d] = %x (%x)\r\n", i, handles[i], handle); if (handles[i] == handle) { return i; @@ -361,11 +363,17 @@ void pci_print_device_config(int32_t handle) struct pci_rd *pci_get_resource(int32_t handle) { int index = -1; + struct pci_rd *ret; index = handle2index(handle); if (index == -1) - return NULL; - return resource_descriptors[index]; + ret = NULL; + else + ret = &resource_descriptors[index][0]; + + debug_printf("pci_get_resource: resource struct for handle %lx (index %d) is at %p\r\n", handle, index, ret); + + return ret; } /* @@ -465,7 +473,7 @@ int32_t pci_unhook_interrupt(int32_t handle) static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) { uint32_t address; - uint16_t handle; + int32_t handle; int16_t index = - 1; struct pci_rd *descriptors; int i;