more Radeon work.

Get PLL info from BIOS emulator
This commit is contained in:
Markus Fröschle
2016-11-13 20:23:06 +00:00
parent 804c755889
commit 28e8ac7f05
13 changed files with 150 additions and 139 deletions

View File

@@ -1,9 +1,9 @@
#set disassemble-next-line on
define tr
#!killall m68k-bdm-gdbserver
#target remote | m68k-bdm-gdbserver pipe /dev/bdmcf3
target remote | m68k-bdm-gdbserver pipe /dev/bdmcf3
#target remote localhost:1234
target remote | m68k-bdm-gdbserver pipe /dev/tblcf2
#target remote | m68k-bdm-gdbserver pipe /dev/tblcf2
#target dbug /dev/ttyS0
#monitor bdm-reset
end

View File

@@ -669,9 +669,6 @@ int dma_init(void)
dma_channel[i].handler = NULL;
}
// test
dma_memcpy((void *) 0x10000, (void *) 0x03e00000, 0x00100000); /* copy one megabyte of flash to RAM */
return 0;
}

View File

@@ -649,11 +649,11 @@ void basflash(void)
/*
* load file
*/
if (srec_load(path) != OK)
{
xprintf("failed to load file %s\r\n", path);
srec_load(path);
// {
// xprintf("failed to load file %s\r\n", path);
// error handling
}
// }
}
}
else

View File

@@ -31,8 +31,12 @@
#include "diskio.h"
#include "ff.h"
#include "s19reader.h"
#include "dma.h"
#include "cache.h"
#define DEBUG
#include "debug.h"
/*
* Yes, I know. The following doesn't really look like code should look like...
*
@@ -192,6 +196,7 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
FRESULT fres;
FIL file;
err_t ret = OK;
uint32_t length = 0;
if ((fres = f_open(&file, filename, FA_READ) == FR_OK))
{
@@ -202,11 +207,14 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
bool found_block_end = false;
bool found_block_data = false;
*actual_length = 0;
while (ret == OK && (uint8_t *) f_gets((char *) line, sizeof(line), &file) != NULL)
{
lineno++;
uint8_t vector[80];
memset(vector, 0, sizeof(vector));
line_to_vector(line, vector); /* vector now contains the decoded contents of line, from line[1] on */
if (line[0] == 'S')
@@ -233,10 +241,11 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
case 2: /* three byte address field data record */
if (!found_block_header || found_block_end)
{
xprintf("S3 record found before S0 or after S7: S-records corrupt?\r\n");
xprintf("S2 record found before S0 or after S7: S-records corrupt?\r\n");
ret = FAIL;
}
ret = callback((uint8_t *) SREC_ADDR24(vector), SREC_DATA24(vector), SREC_DATA24_SIZE(vector));
length += SREC_DATA24_SIZE(vector);
data_records++;
break;
@@ -246,6 +255,7 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
xprintf("S3 record found before S0 or after S7: S-records corrupt?\r\n");
ret = FAIL;
}
length += SREC_DATA32_SIZE(vector);
ret = callback((uint8_t *) SREC_ADDR32(vector), SREC_DATA32(vector), SREC_DATA32_SIZE(vector));
data_records++;
break;
@@ -259,7 +269,7 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
{
// xprintf("S7 record (end) found after %d valid data blocks\r\n", data_records);
*start_address = (void *) SREC_ADDR32(vector);
xprintf("found start address %p\r\n", *start_address);
xprintf("%d blocks read. Found start address %p\r\n", data_records, *start_address);
}
break;
@@ -270,7 +280,7 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
}
else
{
// xprintf("S7 record (end) found after %d valid data blocks\r\n", data_records);
// xprintf("S8 record (end) found after %d valid data blocks\r\n", data_records);
*start_address = (void *) SREC_ADDR24(vector);
}
break;
@@ -297,6 +307,7 @@ err_t read_srecords(char *filename, void **start_address, uint32_t *actual_lengt
xprintf("could not open file %s\r\n", filename);
ret = FILE_OPEN;
}
*actual_length = length;
return ret;
}
@@ -351,6 +362,9 @@ err_t srec_memcpy(uint8_t *dst, uint8_t *src, size_t n)
{
err_t e = OK;
xprintf(".");
dbg("\r\ncopy from %p to %p, length %d", src, dst, n);
// dma_memcpy((void *) dst, (void *) src, n);
memcpy((void *) dst, (void *) src, n);
return e;
}
@@ -386,7 +400,7 @@ void srec_execute(char *flasher_filename)
if (err == OK)
{
/* next pass: copy data to destination */
xprintf("OK.\r\ncopy/flash data: ");
xprintf("OK (start address=%p, length = %ld).\r\ncopy data: ", start_address, length);
err = read_srecords(flasher_filename, &start_address, &length, srec_memcpy);
if (err == OK)
{
@@ -396,6 +410,7 @@ void srec_execute(char *flasher_filename)
if (err == OK)
{
xprintf("OK.\r\n");
typedef void void_func(void);
void_func *func;
xprintf("target successfully written and verified. Start address: %p\r\n", start_address);

View File

@@ -28,5 +28,24 @@ enum {
extern int x86_pcibios_handler(struct X86EMU *emu);
#define USE_SDRAM
#define DIRECT_ACCESS
#define MEM_WB(where, what) emu->emu_wrb(emu, where, what)
#define MEM_WW(where, what) emu->emu_wrw(emu, where, what)
#define MEM_WL(where, what) emu->emu_wrl(emu, where, what)
#define MEM_RB(where) emu->emu_rdb(emu, where)
#define MEM_RW(where) emu->emu_rdw(emu, where)
#define MEM_RL(where) emu->emu_rdl(emu, where)
#define PCI_VGA_RAM_IMAGE_START 0xC0000
#define PCI_RAM_IMAGE_START 0xD0000
#define SYS_BIOS 0xF0000
#define SIZE_EMU 0x100000
#define BIOS_MEM 0x0UL
#endif /* PCI_BIOS_H */

View File

@@ -360,7 +360,6 @@ static int radeon_map_ROM(struct radeonfb_info *rinfo)
temp = inreg(MPP_TB_CONFIG);
dbg("temp=%d\r\n", temp);
temp &= 0x00ffffffu;
temp |= 0x04 << 24;
OUTREG(MPP_TB_CONFIG, temp);
@@ -1669,15 +1668,24 @@ int radeonfb_set_par(struct fb_info *info)
struct radeonfb_info *rinfo = info->par;
struct fb_var_screeninfo *mode = &info->var;
struct radeon_regs *newmode;
int hTotal, vTotal, hSyncStart, hSyncEnd, vSyncStart, vSyncEnd;
int hTotal;
int vTotal;
int hSyncStart;
int hSyncEnd;
int vSyncStart;
int vSyncEnd;
// FIXME: int hSyncPol; this is not used anywhere
// FIXME: int vSyncPol; this is not used anywhere
// FIXME: int cSync; this is not used anywhere
static uint8_t hsync_adj_tab[] = {0, 0x12, 9, 9, 6, 5};
static uint8_t hsync_fudge_fp[] = {2, 2, 0, 0, 5, 5};
uint32_t sync, h_sync_pol, v_sync_pol, dotClock, pixClock;
static uint8_t hsync_adj_tab[] = { 0, 0x12, 9, 9, 6, 5 };
static uint8_t hsync_fudge_fp[] = { 2, 2, 0, 0, 5, 5 };
uint32_t sync;
uint32_t h_sync_pol;
uint32_t v_sync_pol;
uint32_t dotClock;
uint32_t pixClock;
int i;
int freq;
int format = 0;
@@ -1686,14 +1694,20 @@ int radeonfb_set_par(struct fb_info *info)
int hsync_fudge;
// int bytpp; FIXME: this doesn't seem to be used anywhere
int hsync_wid, vsync_wid;
int hsync_wid;
int vsync_wid;
int primary_mon = PRIMARY_MONITOR(rinfo);
int depth = var_to_depth(mode);
int use_rmx = 0;
dbg("depth=%d\r\n", depth);
newmode = (struct radeon_regs *) driver_mem_alloc(sizeof(struct radeon_regs));
if (!newmode)
return -1; //-ENOMEM;
{
err("driver_mem_alloc() failed (ret=%p)\r\n", newmode);
return -1;
}
/*
* We always want engine to be idle on a mode switch, even
@@ -1701,6 +1715,8 @@ int radeonfb_set_par(struct fb_info *info)
*/
radeon_engine_idle();
dbg("xres=%d yres=%d\r\n", mode->xres, mode->yres);
hSyncStart = mode->xres + mode->right_margin;
hSyncEnd = hSyncStart + mode->hsync_len;
hTotal = hSyncEnd + mode->left_margin;
@@ -1709,7 +1725,11 @@ int radeonfb_set_par(struct fb_info *info)
vSyncEnd = vSyncStart + mode->vsync_len;
vTotal = vSyncEnd + mode->upper_margin;
dbg("pixel clock = %d\r\n", mode->pixclock);
pixClock = mode->pixclock;
dbg("sync = %d\r\n", mode->sync);
sync = mode->sync;
h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
@@ -1746,6 +1766,9 @@ int radeonfb_set_par(struct fb_info *info)
dotClock = 1000000000 / pixClock;
freq = dotClock / 10; /* x100 */
dbg("dotClock=%ld, freq = %ld\r\n", dotClock, freq);
hsync_wid = (hSyncEnd - hSyncStart) / 8;
if (hsync_wid == 0)
@@ -1753,6 +1776,8 @@ int radeonfb_set_par(struct fb_info *info)
else if (hsync_wid > 0x3f) /* max */
hsync_wid = 0x3f;
dbg("hsync_wid=%d\r\n", hsync_wid);
if (mode->vmode & FB_VMODE_DOUBLE)
{
vSyncStart <<= 1;
@@ -1766,18 +1791,21 @@ int radeonfb_set_par(struct fb_info *info)
else if (vsync_wid > 0x1f) /* max */
vsync_wid = 0x1f;
dbg("vsync_wid=%d\r\n", vsync_wid);
// FIXME: this doesn't seem to be used anywhere hSyncPol = mode->sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
// FIXME: this doesn't seem to be used anywhere vSyncPol = mode->sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
// FIXME: this doesn't seem to be used anywhere cSync = mode->sync & FB_SYNC_COMP_HIGH_ACT ? (1 << 4) : 0;
format = radeon_get_dstbpp(depth);
dbg("format=%d\r\n", format);
// FIXME: this doesn't seem to be used anywhere bytpp = mode->bits_per_pixel >> 3;
if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD))
hsync_fudge = hsync_fudge_fp[format-1];
hsync_fudge = hsync_fudge_fp[format - 1];
else
hsync_fudge = hsync_adj_tab[format-1];
hsync_fudge = hsync_adj_tab[format - 1];
if (mode->vmode & FB_VMODE_DOUBLE)
hsync_fudge = 0; /* todo: need adjust */
@@ -1961,7 +1989,7 @@ int radeonfb_set_par(struct fb_info *info)
}
/* Update fix */
info->fix.line_length = rinfo->pitch*64;
info->fix.line_length = rinfo->pitch * 64;
info->fix.visual = rinfo->depth == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
driver_mem_free(newmode);

View File

@@ -26,7 +26,7 @@ static struct fb_var_screeninfo radeonfb_default_var =
.activate = FB_ACTIVATE_NOW,
.height = -1,
.width = -1,
.pixclock = 39721,
.pixclock = 9295,
.left_margin = 40,
.right_margin = 24,
.upper_margin = 32,

View File

@@ -423,7 +423,7 @@ void BaS(void)
xprintf("copy EmuTOS: ");
/* copy EMUTOS */
src = (uint8_t *) EMUTOS;
dma_memcpy(dst, src, EMUTOS_SIZE);
memcpy(dst, src, EMUTOS_SIZE);
xprintf("finished\r\n");
xprintf("initialize exception vector table: ");

View File

@@ -26,9 +26,8 @@
void *memcpy(void *dst, const void *src, size_t n)
{
uint8_t *to = dst;
while (to < (uint8_t *) dst + n)
void *to = dst;
while (size--)
*to++ = * (uint8_t *) src++;
return dst;

View File

@@ -82,6 +82,7 @@ int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW)
{
memcpy(&info->var, var, sizeof(struct fb_var_screeninfo));
dbg("fb_set_par() = %p\r\n", info->fbops->fb_set_par);
info->fbops->fb_set_par(info);
fb_pan_display(info, &info->var);
}

View File

@@ -15,7 +15,8 @@
#include "bas_string.h"
#include "fb.h"
#undef DEBUG
#define DEBUG
#include "debug.h"
/* MD - Memory Descriptor */
@@ -183,13 +184,9 @@ long offscreen_free(struct fb_info *info, long addr)
{
MD *p,**q;
MPB *mpb;
#ifdef DEBUG
char buf[10];
Funcs_puts("radeon_offscreen_free(0x");
Funcs_ltoa(buf, addr, 16);
Funcs_puts(buf);
Funcs_puts("\r\n");
#endif
dbg("%p\r\n", addr);
//*vblsem = 0;
mpb = &pmd;
for (p = *(q = &mpb->mp_mal); p; p = *(q = &p->m_link))
@@ -212,41 +209,27 @@ long offscreen_alloc(struct fb_info *info, long amount)
{
long ret;
MD *m;
#ifdef DEBUG
char buf[10];
Funcs_puts("radeon_offscreen_alloc(0x");
Funcs_ltoa(buf, amount, 16);
Funcs_puts(buf);
Funcs_puts(") = 0x");
#endif
// *vblsem = 0;
if(amount == -1L)
if (amount == -1L)
{
ret = (long)ffit(-1L,&pmd);
ret = (long) ffit(-1L, &pmd);
// *vblsem = 1;
return(ret);
return ret;
}
if(amount <= 0 )
if (amount <= 0 )
{
// *vblsem = 1;
return(0);
}
if((amount & 1))
if ((amount & 1))
amount++;
m = ffit(amount,&pmd);
if(m == NULL)
m = ffit(amount, &pmd);
if (m == NULL)
{
#ifdef DEBUG
Funcs_puts("0\r\n");
#endif
// *vblsem = 1;
return(0);
}
#ifdef DEBUG
Funcs_ltoa(buf, m->m_start, 16);
Funcs_puts(buf);
Funcs_puts("\r\n");
#endif
ret = (long)m->m_start;
// *vblsem = 1;
return(ret);
@@ -259,36 +242,28 @@ long offscren_reserved(struct fb_info *info)
void offscreen_init(struct fb_info *info)
{
#ifdef DEBUG
char buf[10];
#endif
long size_screen, max_offscreen_size;
long size_screen;
long max_offscreen_size;
wrap = (long) info->var.xres_virtual * (long)(info->var.bits_per_pixel / 8);
size_screen = (long)info->var.yres_virtual * wrap;
if(!size_screen)
if (!size_screen)
size_screen = (long)info->screen_size;
pmd.mp_mfl = pmd.mp_rover = &tab_md[0];
tab_md[0].m_link = (MD *)NULL;
tab_md[0].m_start = (long)((unsigned long)info->ram_base + (unsigned long)size_screen);
tab_md[0].m_length = (long)info->ram_size - size_screen;
tab_md[0].m_own = (void *)1L;
max_offscreen_size = ((long)info->var.xres_virtual * 8192L * (long)(info->var.bits_per_pixel / 8)) - size_screen;
if(max_offscreen_size < 0)
if (max_offscreen_size < 0)
max_offscreen_size = 0;
if(tab_md[0].m_length > max_offscreen_size)
if (tab_md[0].m_length > max_offscreen_size)
tab_md[0].m_length = max_offscreen_size;
#ifdef DEBUG
Funcs_puts("offscreen_init start 0x");
Funcs_ltoa(buf, tab_md[0].m_start, 16);
Funcs_puts(buf);
Funcs_puts(", length 0x");
Funcs_ltoa(buf, tab_md[0].m_length, 16);
Funcs_puts(buf);
Funcs_puts(", ram_size 0x");
Funcs_ltoa(buf, (long)info->ram_size, 16);
Funcs_puts(buf);
Funcs_puts("\r\n");
#endif
dbg("offscreen_init start %p, length 0x%ld, ram size 0x%ld\r\n",
tab_md[0].m_start, tab_md[0].m_length, (long) info->ram_size);
pmd.mp_mal = (MD *)NULL;
}

View File

@@ -283,34 +283,26 @@ static struct radeonfb_info rfb =
static struct fb_var_screeninfo default_fb =
{
.xres = 1280,
.yres = 1024,
.xres_virtual = 2560,
.yres_virtual = 2048,
.xoffset = 0,
.yoffset = 0,
.xres = 640,
.yres = 480,
.xres_virtual = 640,
.yres_virtual = 480,
.bits_per_pixel = 8,
.grayscale = 0,
.red = { 0, 0, 0 },
.green = { 0, 0, 0 },
.blue = { 0, 0, 0 },
.transp = { 0, 0, 0 },
.nonstd = 0,
.activate = FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW,
.height = 1024,
.width = 1280,
.accel_flags = 0L,
.pixclock = 70 * 10000000L,
.left_margin = 0,
.right_margin = 0,
.upper_margin = 0,
.lower_margin = 0,
.hsync_len = 0,
.vsync_len = 0,
.sync = FB_SYNC_HOR_HIGH_ACT,
.vmode = FB_VMODE_CONUPDATE,
.rotate = 0,
.refresh = 60,
.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 struct fb_info fb =
@@ -342,14 +334,14 @@ int16_t ignore_edid;
struct mode_option resolution =
{
.used = 1,
.width = 1280,
.height = 1024,
.used = 0,
.width = 640,
.height = 480,
.bpp = 8,
.freq = 60,
.flags = 0
};
int16_t force_measure_pll;
int16_t force_measure_pll = 0;
void install_vbl_timer(void *func, int remove)
{
@@ -406,6 +398,9 @@ void video_init(void)
if (radeonfb_pci_register(handle, board) >= 0)
{
info_fb->fbops->fb_check_modes(info_fb, &resolution);
fb_set_var(info_fb, &default_fb);
inf("RADEON video card found and registered\r\n");
}

View File

@@ -13,23 +13,6 @@
#define DEBUG
#include "debug.h"
#define USE_SDRAM
#define DIRECT_ACCESS
#define MEM_WB(where, what) emu->emu_wrb(emu, where, what)
#define MEM_WW(where, what) emu->emu_wrw(emu, where, what)
#define MEM_WL(where, what) emu->emu_wrl(emu, where, what)
#define MEM_RB(where) emu->emu_rdb(emu, where)
#define MEM_RW(where) emu->emu_rdw(emu, where)
#define MEM_RL(where) emu->emu_rdl(emu, where)
#define PCI_VGA_RAM_IMAGE_START 0xC0000
#define PCI_RAM_IMAGE_START 0xD0000
#define SYS_BIOS 0xF0000
#define SIZE_EMU 0x100000
struct rom_header
{
uint16_t signature;
@@ -223,7 +206,7 @@ static void do_int(struct X86EMU *emu, int num)
dbg("string to output at 0x%04x:0x%04x length=0x%04x\r\n", seg, off, num_chars);
for (i = 0; i < num_chars; i++)
xprintf("%c", * (char *)(0x0100000 + str + i));
xprintf("%c", * (char *)(BIOS_MEM + str + i));
}
if (getIntVect(emu, num) == 0x0000)
@@ -291,7 +274,6 @@ void run_bios(struct radeonfb_info *rinfo)
struct pci_data *rom_data;
unsigned long rom_size = 0;
unsigned long image_size = 0;
void *biosmem = (void *) 0x0100000; /* when run_bios() is called, SDRAM is valid but not added to the system */
unsigned long addr;
unsigned short initialcs;
unsigned short initialip;
@@ -341,16 +323,16 @@ void run_bios(struct radeonfb_info *rinfo)
if (PCI_CLASS_DISPLAY_VGA == BIOS_IN16((long) &rom_data->class_hi))
{
memset((char *) biosmem, 0, SIZE_EMU);
setup_system_bios((char *) biosmem);
memset((char *) BIOS_MEM, 0, SIZE_EMU);
setup_system_bios((char *) BIOS_MEM);
dbg("Copying VGA ROM Image from %p to %p (0x%lx bytes)\r\n",
dbg("Copyg VGA ROM Image from %p to %p (0x%lx bytes)\r\n",
(uintptr_t) rinfo->bios_seg + (uintptr_t) rom_header,
biosmem + PCI_VGA_RAM_IMAGE_START, rom_size);
BIOS_MEM + PCI_VGA_RAM_IMAGE_START, rom_size);
{
long bytes_align = (uintptr_t) rom_header & 3;
ptr = (uint8_t *) biosmem;
ptr = (uint8_t *) BIOS_MEM;
i = (long) rom_header;
j = PCI_VGA_RAM_IMAGE_START;
@@ -368,14 +350,14 @@ void run_bios(struct radeonfb_info *rinfo)
}
else
{
memset((uint8_t *) biosmem, 0, SIZE_EMU);
setup_system_bios((char *) biosmem);
memset((uint8_t *) BIOS_MEM, 0, SIZE_EMU);
setup_system_bios((char *) BIOS_MEM);
dbg("Copying non-VGA ROM Image from %p to %p (0x%lx bytes)\r\n",
dbg("Copy non-VGA ROM Image from %p to %p (0x%lx bytes)\r\n",
(uintptr_t) rinfo->bios_seg + (uintptr_t) rom_header,
biosmem + PCI_RAM_IMAGE_START,
BIOS_MEM + PCI_RAM_IMAGE_START,
rom_size);
ptr = (uint8_t *) biosmem;
ptr = (uint8_t *) BIOS_MEM;
for (i = (long) rom_header, j = PCI_RAM_IMAGE_START; i < (long) rom_header + rom_size; ptr[j++] = BIOS_IN8(i++));
addr = PCI_RAM_IMAGE_START;
}
@@ -386,7 +368,7 @@ void run_bios(struct radeonfb_info *rinfo)
/*
* set emulator memory
*/
emu.mem_base = biosmem;
emu.mem_base = (void *) BIOS_MEM;
emu.mem_size = SIZE_EMU;
for (i = 0; i < 256; i++)
@@ -447,5 +429,5 @@ void run_bios(struct radeonfb_info *rinfo)
/*
* clear emulator memory once we are finished
*/
memset((char *) biosmem, 0, SIZE_EMU);
memset((char *) BIOS_MEM, 0, SIZE_EMU);
}