From 3f071add1d63eb580823759be5d581b83719a1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Tue, 31 Dec 2013 13:13:25 +0000 Subject: [PATCH] RADEON card works mainly, the IO-space does not get properly detected yet, however --- flash_scripts/flash_m548x_bas.bdm | 1 + include/x86debug.h | 6 +- pci/pci.c | 65 +++++++++-------- radeon/radeon_base.c | 91 +++++++++++++----------- radeon/radeon_monitor.c | 113 +++++++++++++++--------------- video/video.c | 8 +++ x86emu/x86biosemu.c | 14 ++-- 7 files changed, 164 insertions(+), 134 deletions(-) diff --git a/flash_scripts/flash_m548x_bas.bdm b/flash_scripts/flash_m548x_bas.bdm index 6c4f547..98f0516 100755 --- a/flash_scripts/flash_m548x_bas.bdm +++ b/flash_scripts/flash_m548x_bas.bdm @@ -76,6 +76,7 @@ erase 0xE0000000 9 erase 0xE0000000 10 erase 0xE0000000 11 erase 0xE0000000 12 +erase 0xE0000000 13 #erase 0xE0000000 0x2000 #erase 0xE0000000 0x3000 #erase 0xE0000000 0x4000 diff --git a/include/x86debug.h b/include/x86debug.h index 16ce2c5..31d34cc 100644 --- a/include/x86debug.h +++ b/include/x86debug.h @@ -37,14 +37,14 @@ ****************************************************************************/ /* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/debug.h,v 1.4 2000/11/21 23:10:27 tsi Exp $ */ +#include +#include "bas_printf.h" + /* * for the X86 emulator, debug cannot be enabled and disabled on a per-file mode * as with all the other modules. It must be centrally enabled here. */ -#include -#include "bas_printf.h" - #define DBG_X86EMU #ifdef DBG_X86EMU diff --git a/pci/pci.c b/pci/pci.c index a41a4df..93804ad 100644 --- a/pci/pci.c +++ b/pci/pci.c @@ -33,11 +33,11 @@ #include "interrupts.h" #include "wait.h" -//#define DEBUG_PCI +#define DEBUG_PCI #ifdef DEBUG_PCI -#define debug_printf(format, arg...) do { xprintf("DEBUG: " format "", ##arg); } while (0) +#define dbg(format, arg...) do { xprintf("DEBUG: " format "", ##arg); } while (0) #else -#define debug_printf(format, arg...) do { ; } while (0) +#define dbg(format, arg...) do { ; } while (0) #endif /* DEBUG_PCI */ #if MACHINE_FIREBEE @@ -137,18 +137,18 @@ __attribute__((aligned(16))) void chip_errata_135(void) __attribute__((interrupt)) void pci_arb_interrupt(void) { - debug_printf("XLBARB slave error interrupt\r\n"); + dbg("XLBARB slave error interrupt\r\n"); MCF_XLB_XARB_SR |= ~MCF_XLB_XARB_SR_SEA; } __attribute__((interrupt)) void xlb_pci_interrupt(void) { - debug_printf("XLBPCI interrupt\r\n"); + dbg("XLBPCI interrupt\r\n"); } __attribute__((interrupt)) void pci_interrupt(void) { - debug_printf("PCI interrupt\r\n"); + dbg("PCI interrupt\r\n"); } static int32_t pci_get_interrupt_cause(int32_t *handles) @@ -166,7 +166,7 @@ static int32_t pci_get_interrupt_cause(int32_t *handles) return handle; } } - debug_printf("%s: no interrupt cause found\r\n", __FUNCTION__); + dbg("%s: no interrupt cause found\r\n", __FUNCTION__); return -1; } @@ -193,7 +193,7 @@ void irq5_handler(void) newvalue = pci_call_interrupt_chain(handle, value); if (newvalue == value) { - debug_printf("%s: interrupt not handled!\r\n", __FUNCTION__); + dbg("%s: interrupt not handled!\r\n", __FUNCTION__); } } } @@ -209,13 +209,13 @@ void irq7_handler(void) int32_t newvalue; MCF_EPORT_EPFR |= (1 << 7); - debug_printf("IRQ7!\r\n"); + dbg("IRQ7!\r\n"); if ((handle = pci_get_interrupt_cause(handles)) > 0) { newvalue = pci_call_interrupt_chain(handle, value); if (newvalue == value) { - debug_printf("%s: interrupt not handled!\r\n", __FUNCTION__); + dbg("%s: interrupt not handled!\r\n", __FUNCTION__); } } } @@ -425,7 +425,7 @@ struct pci_rd *pci_get_resource(int32_t handle) 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); + dbg("pci_get_resource: resource struct for handle %lx (index %d) is at %p\r\n", handle, index, ret); return ret; } @@ -579,7 +579,7 @@ int32_t pci_find_classcode(uint32_t classcode, int index) int32_t pci_hook_interrupt(int32_t handle, void *handler, void *parameter) { /* FIXME: implement */ - debug_printf("pci_hook_interrupt() still not implemented\r\n"); + dbg("pci_hook_interrupt() still not implemented\r\n"); return PCI_SUCCESSFUL; } @@ -587,7 +587,7 @@ int32_t pci_unhook_interrupt(int32_t handle) { /* FIXME: implement */ - debug_printf("pci_unhook_interrupt() still not implemented\r\n"); + dbg("pci_unhook_interrupt() still not implemented\r\n"); return PCI_SUCCESSFUL; } @@ -619,7 +619,7 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) if (index == -1) { - debug_printf("cannot find index for handle %d\r\n", handle); + dbg("cannot find index for handle %d\r\n", handle); return; } @@ -662,7 +662,7 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) { /* adjust base address to card's alignment requirements */ int size = ~(address & 0xfffffff0) + 1; - debug_printf("device 0x%x: BAR[%d] requests %d bytes of memory\r\n", handle, i / 4, size); + dbg("device 0x%x: BAR[%d] requests %d bytes of memory\r\n", handle, i / 4, size); /* calculate a valid map adress with alignment requirements */ address = (mem_address + size - 1) & ~(size - 1); @@ -673,7 +673,7 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) /* read it back, just to be sure */ value = swpl(pci_read_config_longword(handle, PCIBAR0 + i)) & ~1; - debug_printf("set PCIBAR%d on device 0x%02x to 0x%08x\r\n", + dbg("set PCIBAR%d on device 0x%02x to 0x%08x\r\n", i / 4, handle, value); /* fill resource descriptor */ @@ -695,13 +695,13 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) else if (IS_PCI_IO_BAR(value)) /* same as above for I/O resources */ { int size = ~(address & 0xfffffffc) + 1; - debug_printf("device 0x%x: BAR[%d] requests %d bytes of I/O space\r\n", handle, i, size); + dbg("device 0x%x: BAR[%d] requests %d bytes of I/O space\r\n", handle, i, size); address = (io_address + size - 1) & ~(size - 1); pci_write_config_longword(handle, PCIBAR0 + i, swpl(address | 1)); value = swpl(pci_read_config_longword(handle, PCIBAR0 + i)); - debug_printf("set PCIBAR%d on device 0x%02x to 0x%08x\r\n", + dbg("set PCIBAR%d on device 0x%02x to 0x%08x\r\n", i / 4, handle, value); rd->next = sizeof(struct pci_rd); @@ -737,15 +737,19 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) if (address & 1) { struct pci_rd *rd = &descriptors[barnum]; - int size = ~(address & 0xfffff800); + int size = ~(address & ~0x7ff); /* expansion ROM active and mapped */ /* calculate a valid map adress with alignment requirements */ address = (mem_address + size - 1) & ~(size - 1); - /* write it to PCIERBAR */ - pci_write_config_longword(handle, PCIERBAR, swpl(address)); + /* write it to PCIERBAR and enable ROM */ + pci_write_config_longword(handle, PCIERBAR, swpl(address | 1)); + dbg("%s: set PCIERBAR on device 0x%02x to 0x%08x\r\n", __FUNCTION__, handle, address | 1); + + /* read value back just to be sure */ + dbg("%s: PCIERBAR = %p\r\n", __FUNCTION__, swpl(pci_read_config_longword(handle, PCIERBAR))); rd->next = sizeof(struct pci_rd); @@ -755,6 +759,7 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) rd->length = size; rd->dmaoffset = 0; + mem_address += size; barnum++; } @@ -764,7 +769,7 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) /* check if device requests an interrupt */ il = pci_read_config_byte(handle, PCIIPR); - debug_printf("device requests interrupts on interrupt pin %d\r\n", il); + dbg("device requests interrupts on interrupt pin %d\r\n", il); /* if so, register interrupts */ @@ -782,7 +787,7 @@ static void pci_bridge_config(uint16_t bus, uint16_t device, uint16_t function) if (function != 0) { - debug_printf("trying to configure a multi-function bridge. Cancelled\r\n"); + dbg("trying to configure a multi-function bridge. Cancelled\r\n"); return; } handle = PCI_HANDLE(bus, device, function); @@ -908,10 +913,10 @@ void init_pci(void) (void) res; /* for now */ res = register_interrupt_handler(0, INT_SOURCE_PCIARB, 5, 5, pci_arb_interrupt); - debug_printf("registered interrupt handler for PCI arbiter: %s\r\n", + dbg("registered interrupt handler for PCI arbiter: %s\r\n", (res < 0 ? "failed" : "succeeded")); register_interrupt_handler(0, INT_SOURCE_XLBPCI, 5, 5, xlb_pci_interrupt); - debug_printf("registered interrupt handler for XLB PCI: %s\r\n", + dbg("registered interrupt handler for XLB PCI: %s\r\n", (res < 0 ? "failed" : "succeeded")); init_eport(); @@ -968,7 +973,7 @@ void init_pci(void) MCF_PCI_PCIIW0BTAR = (PCI_MEMORY_OFFSET | (((PCI_MEMORY_SIZE - 1) >> 8) & 0xffff0000)) | ((PCI_MEMORY_OFFSET >> 16) & 0xff00); - debug_printf("PCIIW0BTAR=0x%08x\r\n", MCF_PCI_PCIIW0BTAR); + dbg("PCIIW0BTAR=0x%08x\r\n", MCF_PCI_PCIIW0BTAR); /* initiator window 1 base / translation adress register */ MCF_PCI_PCIIW1BTAR = (PCI_IO_OFFSET | ((PCI_IO_SIZE - 1) >> 8)) & 0xffff0000; @@ -1009,7 +1014,7 @@ void init_pci(void) pci_scan(); -#ifdef DEBUG_PCI +#ifdef _NOT_USED_ int index = 0; int handle; @@ -1041,7 +1046,7 @@ void init_pci(void) handle = pci_find_device(0x0, 0xFFFF, ++index); } -#endif /* DEBUG_PCI */ +#endif /* _NOT_USED_ */ } @@ -1054,7 +1059,7 @@ void pci_print_device_abilities(int32_t handle) saved_value = pci_read_config_word(handle, PCICSR); pci_write_config_word(handle, PCICSR, 0xffff); value = swpw(pci_read_config_word(handle, PCICSR)); - debug_printf("IO: %1d MEM: %1d MSTR:%1d SPCC: %1d MEMW: %1d VGAS: %1d PERR: %1d STEP: %1d SERR: %1d FBTB: %1d\r\n", + dbg("IO: %1d MEM: %1d MSTR:%1d SPCC: %1d MEMW: %1d VGAS: %1d PERR: %1d STEP: %1d SERR: %1d FBTB: %1d\r\n", value & PCICSR_IO ? 1 : 0, value & PCICSR_MEMORY ? 1 : 0, value & PCICSR_MASTER ? 1 : 0, @@ -1074,7 +1079,7 @@ void pci_print_device_config(int32_t handle) uint16_t value; value = swpw(pci_read_config_word(handle, PCICSR + 2)); - debug_printf("66M: %1d UDF: %1d FB2B:%1d PERR: %1d TABR: %1d DABR: %1d SERR: %1d PPER: %1d\r\n", + dbg("66M: %1d UDF: %1d FB2B:%1d PERR: %1d TABR: %1d DABR: %1d SERR: %1d PPER: %1d\r\n", value & PCICSR_66MHZ ? 1 : 0, value & PCICSR_UDF ? 1 : 0, value & PCICSR_FAST_BTOB ? 1 : 0, diff --git a/radeon/radeon_base.c b/radeon/radeon_base.c index 314b142..d4f265c 100644 --- a/radeon/radeon_base.c +++ b/radeon/radeon_base.c @@ -412,7 +412,7 @@ static int radeon_map_ROM(struct radeonfb_info *rinfo) dbg("%s: Found Intel x86 BIOS ROM Image\r\n", __FUNCTION__); break; case 1: - dbg("%s: radeonfb: Found Open Firmware ROM Image\r\n", __FUNCTION__); + dbg("%s: Found Open Firmware ROM Image\r\n", __FUNCTION__); goto failed; case 2: dbg("%s: Found HP PA-RISC ROM Image\r\n", __FUNCTION__); @@ -424,15 +424,13 @@ static int radeon_map_ROM(struct radeonfb_info *rinfo) anyway: /* Locate the flat panel infos, do some sanity checking !!! */ rinfo->fp_bios_start = BIOS_IN16(0x48); - -// DPRINTVALHEX("radeonfb: BIOS start offset: ", BIOS_IN16(0x48)); -// DPRINT("\r\n"); + dbg("%s: BIOS start offset: %p\r\n", __FUNCTION__, BIOS_IN16(0x48)); /* Save BIOS PLL informations */ { uint16_t pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30); - dbg("radeonfb: BIOS PLL info block offset: %p\r\n", BIOS_IN16(rinfo->fp_bios_start + 0x30)); + dbg("%s: BIOS PLL info block offset: %p\r\n", __FUNCTION__, BIOS_IN16(rinfo->fp_bios_start + 0x30)); rinfo->bios_pll.sclk = BIOS_IN16(pll_info_block + 0x08); rinfo->bios_pll.mclk = BIOS_IN16(pll_info_block + 0x0a); rinfo->bios_pll.ref_clk = BIOS_IN16(pll_info_block + 0x0e); @@ -511,13 +509,13 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) set_ipl(ipl); hz = US_TO_TIMER(1000000.0) / (double)(stop_tv - start_tv); - dbg("%s: radeon_probe_pll_params hz %d\r\n", __FUNCTION__, (int32_t) hz); + dbg("%s:hz %d\r\n", __FUNCTION__, (int32_t) hz); hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8; vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1); - dbg(" hTotal=%d\r\n", hTotal); - dbg(" vTotal=%d\r\n", vTotal); + dbg("%s:hTotal=%d\r\n", __FUNCTION__, hTotal); + dbg("%s:vTotal=%d\r\n", __FUNCTION__, vTotal); vclk = (double) hTotal * (double) vTotal * hz; - dbg("vclk=0x%x\r\n", (int) vclk); + dbg("%s:vclk=%d\r\n", __FUNCTION__, (int) vclk); switch ((INPLL(PPLL_REF_DIV) & 0x30000) >> 16) { @@ -1964,8 +1962,8 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo) case CHIP_FAMILY_R420: dbg("R420"); break; default: dbg("UNKNOW"); break; } - dbg(" found %d", rinfo->video_ram / 1024); - dbg("KB of %s %d bits wide video RAM\r\n", rinfo->vram_ddr ? "DDR " : "SDRAM ", rinfo->vram_width); + dbg("%s: found %d KB of %s %d bits wide video RAM\r\n", __FUNCTION__, rinfo->video_ram / 1024, + rinfo->vram_ddr ? "DDR " : "SDRAM ", rinfo->vram_width); } int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) @@ -1995,22 +1993,22 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) rinfo->is_IGP = (ent->driver_data & CHIP_IS_IGP) != 0; /* Set base addrs */ - dbg("radeonfb: radeonfb_pci_register: Set base addrs\r\n"); + dbg("%s: Set base addrs\r\n", __FUNCTION__); rinfo->fb_base_phys = rinfo->mmio_base_phys = rinfo->io_base_phys = 0xFFFFFFFF; rinfo->mapped_vram = 0; rinfo->mmio_base = rinfo->io_base = NULL; rinfo->bios_seg = NULL; pci_rsc_desc = pci_get_resource(handle); - if ((int32_t)pci_rsc_desc >= 0) + if ((int32_t) pci_rsc_desc >= 0) { uint16_t flags; do { dbg("%s: flags %p\r\n", __FUNCTION__, pci_rsc_desc->flags); dbg("%s: start %p\r\n", __FUNCTION__, pci_rsc_desc->start); - dbg("%s: offset %x\r\n", __FUNCTION__, pci_rsc_desc->offset); - dbg("%s: length %x\r\n", __FUNCTION__, pci_rsc_desc->length); + dbg("%s: offset 0x%x\r\n", __FUNCTION__, pci_rsc_desc->offset); + dbg("%s: length 0x%x\r\n", __FUNCTION__, pci_rsc_desc->length); if (!(pci_rsc_desc->flags & FLG_IO)) { @@ -2023,12 +2021,12 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) if ((pci_rsc_desc->flags & FLG_ENDMASK) == ORD_MOTOROLA) { rinfo->big_endian = 0; /* host bridge make swapping intel -> motorola */ - dbg("%s: radeonfb: host bridge is big endian\r\n", __FUNCTION__); + dbg("%s: host bridge is big endian\r\n", __FUNCTION__); } else { rinfo->big_endian = 1; /* radeon make swapping intel -> motorola */ - dbg("%s: radeonfb: host bridge is little endian\r\n", __FUNCTION__); + dbg("%s: host bridge is little endian\r\n", __FUNCTION__); } } else if ((pci_rsc_desc->length >= RADEON_REGSIZE) && (pci_rsc_desc->length < 0x100000)) @@ -2036,14 +2034,21 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) if (pci_rsc_desc->flags & FLG_ROM) { dbg("%s: FLG_ROM resource descriptor found\r\n", __FUNCTION__); - dbg("%s: start = %p, size = 0x%x\r\n", __FUNCTION__, pci_rsc_desc->start, pci_rsc_desc->length); + dbg("%s: start = %p, size = 0x%x\r\n", __FUNCTION__, pci_rsc_desc->start, pci_rsc_desc->length); + dbg("%s: bios_seg = %p\r\n", __FUNCTION__, rinfo->bios_seg); + if (rinfo->bios_seg == NULL) { rinfo->bios_seg_phys = pci_rsc_desc->start; if (BIOS_IN16(0) == 0xaa55) rinfo->bios_seg = (void *) (pci_rsc_desc->offset + pci_rsc_desc->start); else - rinfo->bios_seg_phys = 0; + { + dbg("%s: BIOS_IN16(0) was %x (expected 0xaa55)\r\n", __FUNCTION__, BIOS_IN16(0)); + rinfo->bios_seg_phys = pci_rsc_desc->offset + pci_rsc_desc->start; + hexdump(rinfo->bios_seg_phys, 512); + //rinfo->bios_seg_phys = 0; + } } } else @@ -2065,7 +2070,7 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) } } flags = pci_rsc_desc->flags; - pci_rsc_desc = (struct pci_rd *)((uint32_t)pci_rsc_desc->next + (uint32_t)pci_rsc_desc); + pci_rsc_desc = (struct pci_rd *) ((uint32_t) pci_rsc_desc->next + (uint32_t) pci_rsc_desc); } while (!(flags & FLG_LAST)); } @@ -2073,21 +2078,21 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) dbg("%s: get_resource error\r\n", __FUNCTION__); /* map the regions */ - dbg("radeonfb: radeonfb_pci_register: map memory regions\r\n"); + dbg("%s: map memory regions\r\n", __FUNCTION__); if (rinfo->mmio_base == NULL) { - dbg("radeonfb: cannot map MMIO\r\n"); + dbg("%s: cannot map MMIO\r\n", __FUNCTION__); framebuffer_release(info); return -2; //(-EIO); } - dbg("radeonfb: %s: mmio_base_phys %p, mmio_base %p\r\n", __FUNCTION__, rinfo->mmio_base_phys, rinfo->mmio_base); - dbg("radeonfb: %s: io_base_phys %p, io_base %p\r\n", __FUNCTION__, rinfo->io_base_phys, rinfo->io_base); - dbg("radeonfb: %s: fb_base_phys %p, fb_base %p\r\n", __FUNCTION__, rinfo->fb_base_phys, rinfo->fb_base); + dbg("%s: mmio_base_phys %p, mmio_base %p\r\n", __FUNCTION__, rinfo->mmio_base_phys, rinfo->mmio_base); + dbg("%s: io_base_phys %p, io_base %p\r\n", __FUNCTION__, rinfo->io_base_phys, rinfo->io_base); + dbg("%s: fb_base_phys %p, fb_base %p\r\n", __FUNCTION__, rinfo->fb_base_phys, rinfo->fb_base); /* * Check for errata */ - dbg("radeonfb: radeonfb_pci_register: check for errata\r\n"); + dbg("%s: check for errata\r\n", __FUNCTION__); rinfo->errata = 0; if (rinfo->family == CHIP_FAMILY_R300 && (INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) == CFG_ATI_REV_A11) @@ -2103,16 +2108,20 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) * Map the BIOS ROM if any and retreive PLL parameters from * the BIOS. */ - dbg("radeonfb: %s: bios_seg_phys %p\r\n", __FUNCTION__, rinfo->bios_seg_phys); - dbg("radeonfb: %s: map the BIOS ROM\r\n", __FUNCTION__); + dbg("%s: bios_seg_phys %p\r\n", __FUNCTION__, rinfo->bios_seg_phys); + dbg("%s: map the BIOS ROM\r\n", __FUNCTION__); radeon_map_ROM(rinfo); /* Run VGA BIOS */ if ((rinfo->bios_seg != NULL)) { - dbg("radeonfb: %s: run VGA BIOS\r\n", __FUNCTION__); + dbg("%s: run VGA BIOS\r\n", __FUNCTION__); run_bios(rinfo); } + else + { + dbg("%s: could not run VGA bios - rinfo->bios_seg is NULL\r\n", __FUNCTION__); + } dbg("%s: fixup display base address \r\n", __FUNCTION__); @@ -2129,41 +2138,45 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) OUTREG(OV0_BASE_ADDR, 0); /* Get VRAM size and type */ - dbg("radeonfb: radeonfb_pci_register: get VRAM size\r\n"); + dbg("%s: get VRAM size\r\n", __FUNCTION__); radeon_identify_vram(rinfo); if ((rinfo->fb_base == NULL) - || ((rinfo->video_ram > rinfo->mapped_vram) && (rinfo->mapped_vram < MIN_MAPPED_VRAM*2))) + || ((rinfo->video_ram > rinfo->mapped_vram) && (rinfo->mapped_vram < MIN_MAPPED_VRAM * 2))) { - dbg("radeonfb: cannot map FB, video ram: %d KB\r\n", rinfo->mapped_vram / 1024); + dbg("%s: cannot map FB, video ram: %d KB\r\n", __FUNCTION__, rinfo->mapped_vram / 1024); framebuffer_release(info); return -2; //(-EIO); } + else + { + dbg("%s: %d KB of VRAM mapped to %p\r\n", __FUNCTION__, rinfo->mapped_vram / 1024, rinfo->fb_base); + } /* Get informations about the board's PLL */ - dbg("radeonfb: radeonfb_pci_register: get informations about the board's PLL\r\n"); + dbg("%s: get informations about the board's PLL\r\n", __FUNCTION__); radeon_get_pllinfo(rinfo); #ifdef CONFIG_FB_RADEON_I2C /* Register I2C bus */ - dbg("radeonfb: radeonfb_pci_register: register I2C bus\r\n"); + dbg("%s: register I2C bus\r\n", __FUNCTION__); radeon_create_i2c_busses(rinfo); #endif /* CONFIG_FB_RADEON_I2C */ /* set all the vital stuff */ - dbg("radeonfb: radeonfb_pci_register: set all the vital stuff\r\n"); + dbg("%s: set all the vital stuff\r\n", __FUNCTION__); radeon_set_fbinfo(rinfo); /* set offscreen memory descriptor */ - dbg("radeonfb: radeonfb_pci_register: set offscreen memory descriptor\r\n"); + dbg("%s: set offscreen memory descriptor\r\n", __FUNCTION__); offscreen_init(info); /* Probe screen types */ - dbg("radeonfb: radeonfb_pci_register: probe screen types, monitor_layout: 0x%x\r\n", monitor_layout); + dbg("%s: probe screen types, monitor_layout: 0x%x\r\n", __FUNCTION__, monitor_layout); radeon_probe_screens(rinfo, monitor_layout, (int) ignore_edid); /* Build mode list, check out panel native model */ - dbg("radeonfb: radeonfb_pci_register: build mode list\r\n"); + dbg("%s: build mode list\r\n", __FUNCTION__); radeon_check_modes(rinfo, &resolution); /* save current mode regs before we switch into the new one @@ -2177,7 +2190,7 @@ int32_t radeonfb_pci_register(int32_t handle, const struct pci_device_id *ent) // DPRINT("radeonfb: radeonfb_pci_register: setup power management\r\n"); // radeonfb_pm_init(rinfo, (int)default_dynclk); - dbg("radeonfb: radeonfb_pci_register: install VBL timer\r\n"); + dbg("%s: install VBL timer\r\n", __FUNCTION__); rinfo->lvds_timer = 0; #ifndef DRIVER_IN_ROM install_vbl_timer(radeon_timer_func, 1); /* remove old vector */ diff --git a/radeon/radeon_monitor.c b/radeon/radeon_monitor.c index c3e8dec..f359d3d 100644 --- a/radeon/radeon_monitor.c +++ b/radeon/radeon_monitor.c @@ -13,29 +13,30 @@ #endif /* DBG_MONITOR */ #ifndef INT_MAX -#define INT_MAX ((int)(~0U>>1)) +#define INT_MAX ((int) (~0U >> 1)) #endif -static struct fb_var_screeninfo radeonfb_default_var = { - .xres = 640, - .yres = 480, - .xres_virtual = 640, - .yres_virtual = 480, +static struct fb_var_screeninfo radeonfb_default_var = +{ + .xres = 640, + .yres = 480, + .xres_virtual = 640, + .yres_virtual = 480, .bits_per_pixel = 8, - .red = { .length = 8 }, - .green = { .length = 8 }, - .blue = { .length = 8 }, - .activate = FB_ACTIVATE_NOW, - .height = -1, - .width = -1, - .pixclock = 39721, - .left_margin = 40, - .right_margin = 24, - .upper_margin = 32, - .lower_margin = 11, - .hsync_len = 96, - .vsync_len = 2, - .vmode = FB_VMODE_NONINTERLACED + .red = { .length = 8 }, + .green = { .length = 8 }, + .blue = { .length = 8 }, + .activate = FB_ACTIVATE_NOW, + .height = -1, + .width = -1, + .pixclock = 39721, + .left_margin = 40, + .right_margin = 24, + .upper_margin = 32, + .lower_margin = 11, + .hsync_len = 96, + .vsync_len = 2, + .vmode = FB_VMODE_NONINTERLACED }; static char *radeon_get_mon_name(int type) @@ -73,9 +74,10 @@ static char *radeon_get_mon_name(int type) static int radeon_crt_is_connected(struct radeonfb_info *rinfo, int is_crt_dac) { int connected = 0; - /* the monitor either wasn't connected or it is a non-DDC CRT. + /* + * the monitor either wasn't connected or it is a non-DDC CRT. * try to probe it - */ + */ if (is_crt_dac) { unsigned long ulOrigVCLK_ECP_CNTL; @@ -84,12 +86,13 @@ static int radeon_crt_is_connected(struct radeonfb_info *rinfo, int is_crt_dac) unsigned long ulOrigCRTC_EXT_CNTL; unsigned long ulData; unsigned long ulMask; + ulOrigVCLK_ECP_CNTL = INPLL(VCLK_ECP_CNTL); ulData = ulOrigVCLK_ECP_CNTL; ulData &= ~(PIXCLK_ALWAYS_ONb | PIXCLK_DAC_ALWAYS_ONb); ulMask = ~(PIXCLK_ALWAYS_ONb | PIXCLK_DAC_ALWAYS_ONb); OUTPLLP(VCLK_ECP_CNTL, ulData, ulMask); - ulOrigCRTC_EXT_CNTL = INREG(CRTC_EXT_CNTL); + ulOrigCRTC_EXT_CNTL = INREG(CRTC_EXT_CNTL); ulData = ulOrigCRTC_EXT_CNTL; ulData |= CRTC_CRT_ON; OUTREG(CRTC_EXT_CNTL, ulData); @@ -98,11 +101,11 @@ static int radeon_crt_is_connected(struct radeonfb_info *rinfo, int is_crt_dac) ulData &= ~DAC_FORCE_DATA_MASK; ulData |= (DAC_FORCE_BLANK_OFF_EN | DAC_FORCE_DATA_EN | DAC_FORCE_DATA_SEL_MASK); if ((rinfo->family == CHIP_FAMILY_RV250) || (rinfo->family == CHIP_FAMILY_RV280)) - ulData |= (0x01b6 << DAC_FORCE_DATA_SHIFT); + ulData |= (0x01b6 << DAC_FORCE_DATA_SHIFT); else - ulData |= (0x01ac << DAC_FORCE_DATA_SHIFT); + ulData |= (0x01ac << DAC_FORCE_DATA_SHIFT); OUTREG(DAC_EXT_CNTL, ulData); - ulOrigDAC_CNTL = INREG(DAC_CNTL); + ulOrigDAC_CNTL = INREG(DAC_CNTL); ulData = ulOrigDAC_CNTL; ulData |= DAC_CMP_EN; ulData &= ~(DAC_RANGE_CNTL_MASK | DAC_PDWN); @@ -224,25 +227,25 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou * a layout for each card ? */ #ifdef CONFIG_FB_RADEON_I2C - dbg("radeonfb: radeon_probe_screens: use monitor layout\r\n"); + dbg("%s: use monitor layout\r\n", __FUNCTION__); if (!ignore_edid) { if (rinfo->mon1_type != MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n"); + dbg("%s: probe ddc_dvi on MON1\r\n", __FUNCTION__); if (!radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID)) { - dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n"); + dbg("%s: probe ddc_crt2 on MON1\r\n", __FUNCTION__); radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID); ddc_crt2_used = 1; } } if (rinfo->mon2_type != MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON2\r\n"); + dbg("%s: probe ddc_vga on MON2\r\n", __FUNCTION__); if (!radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID) && !ddc_crt2_used) { - dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON2\r\n"); + dbg("%s: probe ddc_crt2 on MON2\r\n", __FUNCTION__); radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID); } } @@ -258,7 +261,7 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou else { rinfo->mon1_type = MT_CRT; - dbg("radeonfb: No valid monitor, assuming CRT on first port\r\n"); + dbg("%s: No valid monitor, assuming CRT on first port\r\n", __FUNCTION__); } rinfo->mon2_type = MT_NONE; rinfo->mon2_EDID = NULL; @@ -270,7 +273,7 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou * Auto-detecting display type (well... trying to ...) */ #ifdef CONFIG_FB_RADEON_I2C - dbg("radeonfb: radeon_probe_screens: Auto-detecting\r\n"); + dbg("%s: Auto-detecting\r\n", __FUNCTION__); #endif #if 0 //#if DEBUG && defined(CONFIG_FB_RADEON_I2C) { @@ -289,17 +292,17 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou #ifdef CONFIG_FB_RADEON_I2C if (rinfo->mon1_type == MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n"); + dbg("%s: probe ddc_dvi on MON1\r\n", __FUNCTION__); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID); } if (rinfo->mon1_type == MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON1\r\n"); + dbg("%s: probe ddc_vga on MON1\r\n", __FUNCTION__); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon1_EDID); } if (rinfo->mon1_type == MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n"); + dbg("%s: probe ddc_crt2 on MON1\r\n", __FUNCTION__); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID); } #endif /* CONFIG_FB_RADEON_I2C */ @@ -313,22 +316,22 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou #ifdef CONFIG_FB_RADEON_I2C if (rinfo->mon1_type == MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_dvi on MON1\r\n"); + dbg("%s: probe ddc_dvi on MON1\r\n", __FUNCTION__); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID); } if (rinfo->mon1_type == MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON1\r\n"); + dbg("%s: probe ddc_crt2 on MON1\r\n", __FUNCTION__); rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID); if (rinfo->mon1_type != MT_NONE) ddc_crt2_used = 1; } #endif /* CONFIG_FB_RADEON_I2C */ if (rinfo->mon1_type == MT_NONE && rinfo->is_mobility - && (INREG(LVDS_GEN_CNTL) & LVDS_ON)) + && (INREG(LVDS_GEN_CNTL) & LVDS_ON)) { rinfo->mon1_type = MT_LCD; - dbg("Non-DDC laptop panel detected\r\n"); + dbg("%s: Non-DDC laptop panel detected\r\n", __FUNCTION__); } if (rinfo->mon1_type == MT_NONE) rinfo->mon1_type = radeon_crt_is_connected(rinfo, rinfo->reversed_DAC); @@ -338,12 +341,12 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou #ifdef CONFIG_FB_RADEON_I2C if (rinfo->mon2_type == MT_NONE) { - dbg("radeonfb: radeon_probe_screens: probe ddc_vga on MON2\r\n"); + dbg("%s: probe ddc_vga on MON2\r\n", __FUNCTION__); rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID); } if (rinfo->mon2_type == MT_NONE && !ddc_crt2_used) { - dbg("radeonfb: radeon_probe_screens: probe ddc_crt2 on MON2\r\n"); + dbg("%s: probe ddc_crt2 on MON2\r\n", __FUNCTION__); rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID); } #endif /* CONFIG_FB_RADEON_I2C */ @@ -396,18 +399,18 @@ void radeon_probe_screens(struct radeonfb_info *rinfo, const char *monitor_layou } bail: - dbg("radeonfb: Monitor 1 type %s found\r\n", radeon_get_mon_name(rinfo->mon1_type)); + dbg("%s: Monitor 1 type %s found\r\n", __FUNCTION__, radeon_get_mon_name(rinfo->mon1_type)); if (rinfo->mon1_EDID) { - dbg("radeonfb: EDID probed\r\n"); + dbg("%s: EDID probed\r\n", __FUNCTION__); } if (!rinfo->has_CRTC2) return; - dbg("radeonfb: Monitor 2 type %s\r\n", radeon_get_mon_name(rinfo->mon2_type)); + dbg("%s: Monitor 2 type %s\r\n", __FUNCTION__, radeon_get_mon_name(rinfo->mon2_type)); if (rinfo->mon2_EDID) { - dbg("radeonfb: EDID probed\r\n"); + dbg("%s: EDID probed\r\n", __FUNCTION__); } } @@ -439,7 +442,7 @@ static void radeon_var_to_panel_info(struct radeonfb_info *rinfo, struct fb_var_ } static void radeon_videomode_to_var(struct fb_var_screeninfo *var, - const struct fb_videomode *mode) + const struct fb_videomode *mode) { var->xres = mode->xres; var->yres = mode->yres; @@ -467,7 +470,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut struct fb_info *info = rinfo->info; int has_default_mode = 0; struct mode_option xres_yres; - dbg("radeonfb: radeon_check_modes\r\n"); + dbg("%s: radeon_check_modes\r\n", __FUNCTION__); /* * Fill default var first @@ -569,7 +572,7 @@ void radeon_check_modes(struct radeonfb_info *rinfo, struct mode_option *resolut xres_yres.height = rinfo->panel_info.yres; xres_yres.bpp = xres_yres.freq = 0; if (fb_find_mode(&info->var, info, &xres_yres, modedb, dbsize, NULL, - (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) == 0) + (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) == 0) { rinfo->mon1_type = MT_CRT; goto pickup_default; @@ -584,9 +587,9 @@ pickup_default: if (resolution->used) { if (fb_find_mode(&info->var, info, resolution, info->monspecs.modedb, - info->monspecs.modedb_len, NULL, (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) != 0) + info->monspecs.modedb_len, NULL, (resolution->bpp >= 8) ? (unsigned int)resolution->bpp : 8) != 0) has_default_mode = 1; - } + } /* * Still no mode, let's pick up a default from the db */ @@ -636,7 +639,7 @@ pickup_default: * the current fbcon doesn't quite mind ;) */ static int radeon_compare_modes(const struct fb_var_screeninfo *var, - const struct fb_videomode *mode) + const struct fb_videomode *mode) { int distance = 0; @@ -652,8 +655,8 @@ static int radeon_compare_modes(const struct fb_var_screeninfo *var, * We need something better ultimately. */ int radeon_match_mode(struct radeonfb_info *rinfo, - struct fb_var_screeninfo *dest, - const struct fb_var_screeninfo *src) + struct fb_var_screeninfo *dest, + const struct fb_var_screeninfo *src) { const struct fb_videomode *db = vesa_modes; int i, dbsize = 34; @@ -684,7 +687,7 @@ int radeon_match_mode(struct radeonfb_info *rinfo, || (src->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { /* We don't have an RMX, validate timings. If we don't have - * monspecs, we should be paranoid and not let use go above + * monspecs, we should be paranoid and not let use go above * 640x480-60, but I assume userland knows what it's doing here * (though I may be proven wrong...) */ diff --git a/video/video.c b/video/video.c index 6f26368..79301b5 100644 --- a/video/video.c +++ b/video/video.c @@ -288,6 +288,9 @@ void install_vbl_timer(void *func, int remove) dbg("%s: not implemented\r\n", __FUNCTION__); } +/* + * detect and initialise PCI graphics cards + */ void video_init(void) { /* @@ -298,6 +301,7 @@ void video_init(void) int32_t handle; struct pci_device_id *board; int32_t id; + bool radeon_found = false; dbg("%s\r\n", __FUNCTION__); do @@ -321,6 +325,8 @@ void video_init(void) dbg("%s: check %x %x against %08x\r\n", __FUNCTION__, board->device, board->vendor, id); if ((board->device == (id >> 16)) && (board->vendor == (id & 0xffff))) { + radeon_found = true; + dbg("%s: matched\r\n", __FUNCTION__); if (radeonfb_pci_register(handle, board) >= 0) { @@ -337,6 +343,8 @@ void video_init(void) } index++; } while (handle > 0); + dbg("%s: RADEON video card %sfound and %sregistered\r\n", __FUNCTION__, + (radeon_found ? "" : "not "), (radeon_found ? "" : "not ")); } diff --git a/x86emu/x86biosemu.c b/x86emu/x86biosemu.c index 585c57c..698d4b9 100644 --- a/x86emu/x86biosemu.c +++ b/x86emu/x86biosemu.c @@ -105,10 +105,10 @@ uint8_t inb(uint16_t port) if ((port >= offset_port) && (port <= offset_port + 0xFF)) { - dbg("inb("); + dbg("%s:\r\n", __FUNCTION__); val = *(uint8_t *)(offset_io+(uint32_t)port); - dbg("0x%x) = 0x%x\r\n", port, val); + dbg("%s: inb(0x%x) = 0x%x\r\n", __FUNCTION__, port, val); } return val; } @@ -537,7 +537,7 @@ void run_bios(struct radeonfb_info *rinfo) if ((rinfo->mmio_base == NULL) || (rinfo->io_base == NULL)) { - dbg("%s: rinfo->mmio_base = %p, rinfo->io_base = %p\r\n", __FUNCTION__); + dbg("%s: rinfo->mmio_base = %p, rinfo->io_base = %p\r\n", __FUNCTION__, rinfo->mmio_base, rinfo->io_base); return; } rinfo_biosemu = rinfo; @@ -573,7 +573,7 @@ void run_bios(struct radeonfb_info *rinfo) } memset((char *) biosmem, 0, SIZE_EMU); setup_system_bios((char *) biosmem); - dbg("Copying VGA ROM Image from %p to %p (0x%lx bytes)\r\n", (long) rinfo->bios_seg + (long) rom_header, + dbg("%s: Copying VGA ROM Image from %p to %p (0x%lx bytes)\r\n", __FUNCTION__, (long) rinfo->bios_seg + (long) rom_header, biosmem + PCI_VGA_RAM_IMAGE_START, rom_size); { long bytes_align = (long) rom_header & 3; @@ -605,7 +605,7 @@ void run_bios(struct radeonfb_info *rinfo) #endif /* USE_SDRAM */ setup_system_bios((char *)biosmem); memset((char *)biosmem, 0, SIZE_EMU); - dbg("Copying non-VGA ROM Image from %p to %p (0x%lx bytes)\r\n", + dbg("%s: Copying non-VGA ROM Image from %p to %p (0x%lx bytes)\r\n", __FUNCTION__, (long) rinfo->bios_seg + (long) rom_header, biosmem + PCI_RAM_IMAGE_START, rom_size); @@ -660,11 +660,11 @@ void run_bios(struct radeonfb_info *rinfo) X86EMU_trace_on(); X86EMU_set_debug(DEBUG_DECODE_F | DEBUG_TRACE_F); #endif - dbg("X86EMU entering emulator\r\n"); + dbg("%s: X86EMU entering emulator\r\n", __FUNCTION__); //*vblsem = 0; X86EMU_exec(); //*vblsem = 1; - dbg("X86EMU halted\r\n"); + dbg("%s: X86EMU halted\r\n", __FUNCTION__); // biosfn_set_video_mode(0x13); /* 320 x 200 x 256 colors */ #ifdef USE_SDRAM #if 0