OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1368 to Rev 1369
    Reverse comparison

Rev 1368 → Rev 1369

/trunk/or1ksim/sim-config.h
71,13 → 71,6
} gpios[MAX_GPIOS];
 
struct {
int enabled; /* Whether frame buffer is enabled */
unsigned long baseaddr; /* Base address of frame buffer register */
int refresh_rate; /* Number of clocks per refresh */
char filename[STR_SIZE]; /* Base file name; suffix of ####.bmp is added */
} fb;
struct {
int enabled; /* Is keyboard enabled? */
unsigned long baseaddr; /* Base address of frame buffer register */
int irq; /* Irq number of this device */
/trunk/or1ksim/sim.cfg
803,9 → 803,6
This section configures the frame buffer
enabled = 0/1
whether frame buffer is enabled
baseaddr = <hex_value>
base address of frame buffer
820,7 → 817,6
*/
 
section fb
enabled = 1
baseaddr = 0x97000000
refresh_rate = 1000000
filename = "primary"
/trunk/or1ksim/peripheral/fb.c
18,6 → 18,7
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
#include <stdio.h>
#include <string.h>
 
#include "config.h"
 
34,31 → 35,42
 
#define FB_WRAP (512*1024)
 
static unsigned long pal[256];
static int fb_ctrl = 0;
static int fb_pic = 0;
static int fb_in_refresh = 1;
static int fb_refresh_count = 0;
static oraddr_t fb_addr = 0;
static oraddr_t cam_addr = 0;
static int camerax = 0, cameray = 0, camera_pos = 0;
struct fb_state {
unsigned long pal[256];
int ctrl;
int pic;
int in_refresh;
int refresh_count;
oraddr_t addr;
oraddr_t cam_addr;
int camerax;
int cameray;
int camera_pos;
oraddr_t baseaddr;
int refresh;
int refresh_rate;
char *filename;
};
 
static void change_buf_addr (oraddr_t addr)
static void change_buf_addr (struct fb_state *fb, oraddr_t addr)
{
fb_addr = addr;
fb->addr = addr;
}
 
/* Write a register */
void fb_write32 (oraddr_t addr, uint32_t value, void *dat)
{
int a = (addr - config.fb.baseaddr);
struct fb_state *fb = dat;
 
oraddr_t a = (addr - fb->baseaddr);
 
switch (a) {
case FB_CTRL: fb_ctrl = value; break;
case FB_BUFADDR: change_buf_addr (value); break;
case FB_CAMBUFADDR: cam_addr = value; break;
case FB_CAMPOSADDR: camera_pos = value;
camerax = value % FB_SIZEX;
cameray = value / FB_SIZEX;
case FB_CTRL: fb->ctrl = value; break;
case FB_BUFADDR: change_buf_addr (fb, value); break;
case FB_CAMBUFADDR: fb->cam_addr = value; break;
case FB_CAMPOSADDR: fb->camera_pos = value;
fb->camerax = value % FB_SIZEX;
fb->cameray = value / FB_SIZEX;
break;
default:
a -= FB_PAL;
66,7 → 78,7
if (a < 0 || a >= 256) {
fprintf (stderr, "Write out of palette buffer (0x%"PRIxADDR")!\n", addr);
runtime.sim.cont_run = 0;
} else pal[a] = value;
} else fb->pal[a] = value;
break;
}
}
74,14 → 86,17
/* Read a register */
oraddr_t fb_read32 (oraddr_t addr, void *dat)
{
int a = (addr - config.fb.baseaddr);
struct fb_state *fb = dat;
 
oraddr_t a = (addr - fb->baseaddr);
 
switch (a) {
case FB_CTRL:
return fb_ctrl & ~0xff000000| (fb_in_refresh ? 0x80000000 : 0) | ((unsigned long)(fb_refresh_count & 0x7f) << 24);
return fb->ctrl & ~0xff000000| (fb->in_refresh ? 0x80000000 : 0) | ((unsigned long)(fb->refresh_count & 0x7f) << 24);
break;
case FB_BUFADDR: return fb_addr; break;
case FB_CAMBUFADDR: return cam_addr; break;
case FB_CAMPOSADDR: return camera_pos; break;
case FB_BUFADDR: return fb->addr; break;
case FB_CAMBUFADDR: return fb->cam_addr; break;
case FB_CAMPOSADDR: return fb->camera_pos; break;
default:
a -= FB_PAL;
a /= 4;
89,7 → 104,7
fprintf (stderr, "Read out of palette buffer (0x%"PRIxADDR")!\n", addr);
runtime.sim.cont_run = 0;
return 0;
} else return pal[a];
} else return fb->pal[a];
}
}
 
109,7 → 124,7
#endif
 
/* Dumps a bmp file, based on current image */
static int fb_dump_image8 (char *filename)
static int fb_dump_image8 (struct fb_state *fb, char *filename)
{
int sx = FB_SIZEX;
int sy = FB_SIZEY;
155,7 → 170,7
 
for (i = 0; i < 256; i++) {
unsigned long val, d;
d = pal[i];
d = fb->pal[i];
#if 1
val = ((d >> 0) & 0x1f) << 3; /* Blue */
val |= ((d >> 5) & 0x3f) << 10; /* Green */
174,7 → 189,7
int add;
while (align < 0) align += 4;
for (x = 0; x < sx; x++) {
add = (fb_addr & ~(FB_WRAP - 1)) | ((fb_addr + y * sx + x) & (FB_WRAP - 1));
add = (fb->addr & ~(FB_WRAP - 1)) | ((fb->addr + y * sx + x) & (FB_WRAP - 1));
fputc (evalsim_mem8 (add), fo);
}
if (align && !fwrite (&zero, align, 1, fo)) return 1;
186,7 → 201,7
}
 
/* Dumps a bmp file, based on current image */
static int fb_dump_image24 (char *filename)
static int fb_dump_image24 (struct fb_state *fb, char *filename)
{
int sx = FB_SIZEX;
int sy = FB_SIZEY;
235,15 → 250,15
for (y = sy - 1; y >= 0; y--) {
unsigned char line[FB_SIZEX][3];
for (x = 0; x < sx; x++)
if (y >= cameray && x >= camerax && y < cameray + CAM_SIZEY && x < camerax + CAM_SIZEX) {
int add = (cam_addr + (x - camerax + (y - cameray) * CAM_SIZEX) * 2) ^ 2;
if (y >= fb->cameray && x >= fb->camerax && y < fb->cameray + CAM_SIZEY && x < fb->camerax + CAM_SIZEX) {
int add = (fb->cam_addr + (x - fb->camerax + (y - fb->cameray) * CAM_SIZEX) * 2) ^ 2;
unsigned short d = evalsim_mem16 (add);
line[x][0] = ((d >> 0) & 0x1f) << 3; /* Blue */
line[x][1] = ((d >> 5) & 0x3f) << 2; /* Green */
line[x][2] = ((d >> 11) & 0x1f) << 3; /* Red */
} else {
int add = (fb_addr & ~(FB_WRAP - 1)) | ((fb_addr + y * sx + x) & (FB_WRAP - 1));
unsigned short d = pal[evalsim_mem8 (add)];
int add = (fb->addr & ~(FB_WRAP - 1)) | ((fb->addr + y * sx + x) & (FB_WRAP - 1));
unsigned short d = fb->pal[evalsim_mem8 (add)];
line[x][0] = ((d >> 0) & 0x1f) << 3; /* Blue */
line[x][1] = ((d >> 5) & 0x3f) << 2; /* Green */
line[x][2] = ((d >> 11) & 0x1f) << 3; /* Red */
256,71 → 271,105
return 0;
}
 
void fb_job (int param)
void fb_job (void *dat)
{
if (param) {
struct fb_state *fb = dat;
 
if (fb->refresh) {
/* dump the image? */
if (fb_ctrl & 1) {
if (fb->ctrl & 1) {
char temp[STR_SIZE];
sprintf (temp, "%s%04i.bmp", &config.fb.filename[0], fb_pic);
if (fb_ctrl & 2) fb_dump_image24 (temp);
else fb_dump_image8 (temp);
fb_pic++;
sprintf (temp, "%s%04i.bmp", fb->filename, fb->pic);
if (fb->ctrl & 2) fb_dump_image24 (fb, temp);
else fb_dump_image8 (fb, temp);
fb->pic++;
}
SCHED_ADD(fb_job, 0, runtime.sim.cycles + config.fb.refresh_rate - config.fb.refresh_rate / REFRESH_DIVIDER);
fb_in_refresh = 0;
SCHED_ADD(fb_job, dat, runtime.sim.cycles + fb->refresh_rate - fb->refresh_rate / REFRESH_DIVIDER);
fb->in_refresh = 0;
fb->refresh = 0;
} else {
fb_refresh_count++;
SCHED_ADD(fb_job, 1, runtime.sim.cycles + config.fb.refresh_rate / REFRESH_DIVIDER);
fb->refresh_count++;
fb->refresh = 1;
SCHED_ADD(fb_job, dat, runtime.sim.cycles + fb->refresh_rate / REFRESH_DIVIDER);
}
}
 
/* Reset all VGAs */
void fb_reset ()
void fb_reset (void *dat)
{
struct fb_state *fb = dat;
int i;
 
if (config.fb.enabled) {
fb_pic = 0;
fb_addr = 0;
fb_ctrl = 0;
fb->pic = 0;
fb->addr = 0;
fb->ctrl = 0;
 
for (i = 0; i < 256; i++)
pal[i] = (i << 16) | (i << 8) | (i << 0);
for (i = 0; i < 256; i++)
fb->pal[i] = (i << 16) | (i << 8) | (i << 0);
 
if (config.fb.baseaddr)
register_memoryarea(config.fb.baseaddr, FB_PAL + 256*4, 4, 0, fb_read32, fb_write32, NULL);
SCHED_ADD(fb_job, 0, runtime.sim.cycles + config.fb.refresh_rate);
}
SCHED_ADD(fb_job, dat, runtime.sim.cycles + fb->refresh_rate);
fb->refresh = 0;
}
 
/*-----------------------------------------------------[ FB configuration ]---*/
void fb_enabled(union param_val val, void *dat)
{
config.fb.enabled = val.int_val;
}
 
void fb_baseaddr(union param_val val, void *dat)
{
config.fb.baseaddr = val.addr_val;
struct fb_state *fb = dat;
fb->baseaddr = val.addr_val;
}
 
void fb_refresh_rate(union param_val val, void *dat)
{
config.fb.refresh_rate = val.int_val;
struct fb_state *fb = dat;
fb->refresh_rate = val.int_val;
}
 
void fb_filename(union param_val val, void *dat)
{
strcpy(config.fb.filename, val.str_val);
struct fb_state *fb = dat;
if(!(fb->filename = strdup(val.str_val))) {
fprintf(stderr, "Peripheral FB: Run out of memory\n");
exit(-1);
}
}
 
void *fb_sec_start(void)
{
struct fb_state *new = malloc(sizeof(struct fb_state));
 
if(!new) {
fprintf(stderr, "Peripheral FB: Run out of memory\n");
exit(-1);
}
 
new->baseaddr = 0;
new->ctrl = 0;
new->pic = 0;
new->in_refresh = 1;
new->refresh_count = 0;
new->addr = 0;
new->cam_addr = 0;
new->camerax = 0;
new->cameray = 0;
new->camera_pos = 0;
 
return new;
}
 
void fb_sec_end(void *dat)
{
struct fb_state *fb = dat;
 
if (fb->baseaddr)
register_memoryarea(fb->baseaddr, FB_PAL + 256*4, 4, 0, fb_read32, fb_write32, dat);
 
reg_sim_reset(fb_reset, dat);
}
 
void reg_fb_sec(void)
{
struct config_section *sec = reg_config_sec("fb", NULL, NULL);
struct config_section *sec = reg_config_sec("fb", fb_sec_start, fb_sec_end);
 
reg_config_param(sec, "enabled", paramt_int, fb_enabled);
reg_config_param(sec, "baseaddr", paramt_addr, fb_baseaddr);
reg_config_param(sec, "refresh_rate", paramt_int, fb_refresh_rate);
reg_config_param(sec, "filename", paramt_str, fb_filename);
/trunk/or1ksim/peripheral/fb.h
37,7 → 37,4
#define FB_CAMPOSADDR 0x000c
#define FB_PAL 0x0400
 
/* Reset all frame buffers */
void fb_reset ();
 
#endif /* _VGA_H_ */
/trunk/or1ksim/toplevel.c
48,7 → 48,6
#include "spr_defs.h"
#include "sprs.h"
#include "dma.h"
#include "fb.h"
#include "ps2kbd.h"
#include "vapi.h"
#include "gdbcomm.h"
74,7 → 73,7
#include "cuc.h"
 
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.109 $";
const char rcsrev[] = "$Revision: 1.110 $";
 
inline void debug(int level, const char *format, ...)
{
173,7 → 172,6
dma_reset();
eth_reset();
gpio_reset();
fb_reset ();
kbd_reset ();
tick_reset();
pm_reset();
/trunk/or1ksim/sim-config.c
127,9 → 127,6
/* DMAs */
config.ndmas = 0;
/* Frame buffer */
config.fb.enabled = 0;
/* CPU */
config.cpu.superscalar = 0;
config.sim.history = 0;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.