diff --git a/BaS_gcc/include/pci.h b/BaS_gcc/include/pci.h index b912dd6..af27656 100644 --- a/BaS_gcc/include/pci.h +++ b/BaS_gcc/include/pci.h @@ -198,11 +198,11 @@ typedef struct /* structure of address conversion */ #define PCI_STATUS(i) ((i) & 0xffff) #define PCI_COMMAND(i) (((i) >> 16) & 0xffff) -/* register 0x08 macros */ -#define PCI_CLASS_CODE(i) (((i) & 0xff000000) >> 24) -#define PCI_SUBCLASS(i) (((i) & 0x00ff0000) >> 16) -#define PCI_PROG_IF(i) (((i) & 0x0000ff00) >> 8) -#define PCI_REVISION_ID(i) (((i) & 0x000000ff)) +/* register 0x08 macros (use on little endian value!) */ +#define PCI_CLASS_CODE(i) (((i) & 0x00ff0000) >> 16) +#define PCI_SUBCLASS(i) (((i) & 0x0000ff00) >> 8) +#define PCI_PROG_IF(i) (((i) & 0x000000ff) >> 0) +#define PCI_REVISION_ID(i) (((i) & 0xff000000) >> 24) /* register 0x0c macros */ #define PCI_BIST(i) (((i) & 0xff000000) >> 24) diff --git a/BaS_gcc/include/radeonfb.h b/BaS_gcc/include/radeonfb.h index 6f12093..5e2735b 100644 --- a/BaS_gcc/include/radeonfb.h +++ b/BaS_gcc/include/radeonfb.h @@ -12,6 +12,8 @@ #include "wait.h" #include "video.h" +#define RADEON_TILING + //#include "radeon_theatre.h" #include "radeon_reg.h" diff --git a/BaS_gcc/pci/pci.c b/BaS_gcc/pci/pci.c index 694af1c..58a1db1 100644 --- a/BaS_gcc/pci/pci.c +++ b/BaS_gcc/pci/pci.c @@ -34,7 +34,7 @@ #include "interrupts.h" #include "wait.h" -// // #define DEBUG +#define DEBUG #include "debug.h" #define pci_config_wait() do { __asm__ __volatile("tpf" ::: "memory"); } while (0) @@ -513,81 +513,55 @@ int32_t pci_find_device(uint16_t device_id, uint16_t vendor_id, int index) */ int32_t pci_find_classcode(uint32_t classcode, int index) { - uint16_t bus; - uint16_t device; - uint16_t function = 0; - uint16_t n = 0; - int32_t handle; + int i; + uint32_t handle; + uint32_t ret = PCI_DEVICE_NOT_FOUND; + int n = 0; + uint8_t find_mask; + uint32_t value; + int cmp; + bool match = false; - for (bus = 0; bus < 2; bus++) + classcode = swpl(classcode); + find_mask = classcode & 0xff; + classcode >>= 8; + + do { - for (device = 10; device < 31; device++) + for (i = 0; (handle = handles[i]) != -1; i++) { - uint32_t value; - uint8_t htr; - - handle = PCI_HANDLE(bus, device, 0); - dbg("check handle %d\r\n", handle); - - value = swpl(pci_read_config_longword(handle, PCIIDR)); - - if (value != 0xffffffff) /* device found */ + match = false; + for (cmp = 0; cmp < 3; cmp++) { - value = swpl(pci_read_config_longword(handle, PCICCR)); - - dbg("classcode to search for=%x\r\n", classcode); - dbg("PCI_CLASSCODE found=%02x\r\n", PCI_CLASS_CODE(value)); - dbg("PCI_SUBCLASS found=%02x\r\n", PCI_SUBCLASS(value)); - dbg("PCI_PROG_IF found=%02x\r\n", PCI_PROG_IF(value)); - - if ((classcode & (1 << 26) ? ((PCI_CLASS_CODE(value) == (classcode & 0xff))) : true) && - (classcode & (1 << 25) ? ((PCI_SUBCLASS(value) == ((classcode & 0xff00) >> 8))) : true) && - (classcode & (1 << 24) ? ((PCI_PROG_IF(value) == ((classcode & 0xff0000) >> 16))) : true)) + if ((find_mask >> cmp) & 1) { - if (n == index) + value = swpl(pci_read_config_longword(handle, PCICCR)); + dbg("compare classcode (0x%x), 0x%x against value (0x%x) 0x%x\r\n", + classcode, (classcode >> (cmp * 8)) & 0xff, value, (value >> (cmp * 8)) & 0xff); + if (((classcode >> (cmp * 8)) & 0xff) == ((value >> (cmp * 8)) & 0xff)) { - dbg("found device at handle %d\r\n", handle); - return handle; + if (n == index) + return handle; + n++; } - n++; - } - - /* - * there is a device at this position, but not the one we are looking for. - * Check to see if it is a multi-function device. We need to look "behind" it - * for the other functions in that case. - */ - if ((htr = pci_read_config_byte(handle, PCI_LANESWAP_B(PCIHTR))) & 0x80) - { - /* yes, this is a multi-function device, look for more functions */ - - for (function = 1; function < 8; function++) + else { - handle = PCI_HANDLE(bus, device, function); - value = pci_read_config_longword(handle, PCIIDR); - - if (value != 0xffffffff) /* device found */ - { - value = swpl(pci_read_config_longword(handle, PCICCR)); - - if ((classcode & PCI_FIND_BASE_CLASS ? ((PCI_CLASS_CODE(value) == (classcode & 0xff))) : true) && - (classcode & PCI_FIND_SUB_CLASS ? ((PCI_SUBCLASS(value) == ((classcode & 0xff00) >> 8))) : true) && - (classcode & PCI_FIND_PROG_IF ? ((PCI_PROG_IF(value) == ((classcode & 0xff0000) >> 16))) : true)) - { - if (n == index) - { - dbg("found device with handle %d\n", handle); - return handle; - } - n++; - } - } + match = false; + goto next; } } + else + match = true; } + +next: + ; } - } - return PCI_DEVICE_NOT_FOUND; + } while (n < index); + + if (match) + ret = handle; + return ret; } int32_t pci_hook_interrupt(int32_t handle, void *handler, void *parameter) diff --git a/BaS_gcc/radeon/radeon_base.c b/BaS_gcc/radeon/radeon_base.c index 3792b62..ae1f13f 100644 --- a/BaS_gcc/radeon/radeon_base.c +++ b/BaS_gcc/radeon/radeon_base.c @@ -1982,7 +1982,7 @@ int radeonfb_set_par(struct fb_info *info) #endif memcpy(&rinfo->state, newmode, sizeof(*newmode)); #ifdef RADEON_TILING - rinfo->tilingEnabled = (mode->vmode & (FB_VMODE_DOUBLE | FB_VMODE_INTERLACED)) ? FALSE : TRUE; + rinfo->tilingEnabled = (mode->vmode & (FB_VMODE_DOUBLE | FB_VMODE_INTERLACED)) ? false : true; #endif radeon_write_mode(rinfo, newmode, 0); /* (re)initialize the engine */ diff --git a/BaS_gcc/sys/mmu.c b/BaS_gcc/sys/mmu.c index 15a7574..a8ccd5f 100644 --- a/BaS_gcc/sys/mmu.c +++ b/BaS_gcc/sys/mmu.c @@ -3,7 +3,7 @@ #include "exceptions.h" #include "pci.h" -#define DEBUG +// #define DEBUG #include "debug.h" /* diff --git a/BaS_gcc/sys/sysinit.c b/BaS_gcc/sys/sysinit.c index c4ea315..653ab7e 100644 --- a/BaS_gcc/sys/sysinit.c +++ b/BaS_gcc/sys/sysinit.c @@ -53,7 +53,7 @@ #include "usb.h" #include "video.h" -// // #define DEBUG +#define DEBUG #include "debug.h" #define UNUSED(x) (void)(x) /* Unused variable */ @@ -588,11 +588,11 @@ void init_usb(void) int usb_found = 0; int index = 0; - xprintf("USB controller initialization:\r\n"); + inf("USB controller initialization:\r\n"); do { - handle = pci_find_classcode(PCI_CLASS_SERIAL_USB | PCI_FIND_BASE_CLASS | PCI_FIND_SUB_CLASS, index++); + handle = pci_find_classcode(PCI_CLASS_SERIAL_USB | PCI_FIND_BASE_CLASS | PCI_FIND_SUB_CLASS | PCI_FIND_PROG_IF, index++); dbg("handle 0x%02x\r\n", handle); if (handle > 0) { diff --git a/BaS_gcc/usb/usb.c b/BaS_gcc/usb/usb.c index 55d636b..acb8834 100644 --- a/BaS_gcc/usb/usb.c +++ b/BaS_gcc/usb/usb.c @@ -54,7 +54,7 @@ #include "usb.h" #include "usb_hub.h" -// // #define DEBUG +// #define DEBUG #include "debug.h" struct hci diff --git a/BaS_gcc/video/video.c b/BaS_gcc/video/video.c index c0f0ac8..164da5a 100644 --- a/BaS_gcc/video/video.c +++ b/BaS_gcc/video/video.c @@ -286,7 +286,7 @@ static struct fb_var_screeninfo default_fb = .xres = 1280, .yres = 1024, .xres_virtual = 1280, - .yres_virtual = 1024, + .yres_virtual = 1024 * 2, /* ensure we have accel offscreen space */ .bits_per_pixel = 8, .grayscale = 0, .red = { .length = 8 }, @@ -364,11 +364,6 @@ void video_init(void) int32_t id; bool radeon_found = false; - dbg("\r\n"); - - /* FIXME: we currently just return here because the PCI configuration of ATI cards does not (yet) work */ - //return; - do { /*