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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_34/] [or1ksim/] [peripheral/] [fb.c] - Diff between revs 1308 and 1350

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1308 Rev 1350
Line 16... Line 16...
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
#include <stdio.h>
#include <stdio.h>
 
 
 
#include "config.h"
 
 
 
#ifdef HAVE_INTTYPES_H
 
#include <inttypes.h>
 
#endif
 
 
 
#include "port.h"
 
#include "arch.h"
#include "sim-config.h"
#include "sim-config.h"
#include "abstract.h"
#include "abstract.h"
#include "fb.h"
#include "fb.h"
#include "sched.h"
#include "sched.h"
 
 
Line 28... Line 37...
static unsigned long pal[256];
static unsigned long pal[256];
static int fb_ctrl = 0;
static int fb_ctrl = 0;
static int fb_pic = 0;
static int fb_pic = 0;
static int fb_in_refresh = 1;
static int fb_in_refresh = 1;
static int fb_refresh_count = 0;
static int fb_refresh_count = 0;
static unsigned long fb_addr = 0;
static oraddr_t fb_addr = 0;
static unsigned long cam_addr = 0;
static oraddr_t cam_addr = 0;
static int camerax = 0, cameray = 0, camera_pos = 0;
static int camerax = 0, cameray = 0, camera_pos = 0;
 
 
static void change_buf_addr (unsigned long addr)
static void change_buf_addr (oraddr_t addr)
{
{
  fb_addr = addr;
  fb_addr = addr;
}
}
 
 
/* Write a register */
/* Write a register */
void fb_write32 (unsigned long addr, unsigned long value)
void fb_write32 (oraddr_t addr, uint32_t value)
{
{
  int a = (addr - config.fb.baseaddr);
  int a = (addr - config.fb.baseaddr);
  switch (a) {
  switch (a) {
    case FB_CTRL:    fb_ctrl = value; break;
    case FB_CTRL:    fb_ctrl = value; break;
    case FB_BUFADDR: change_buf_addr (value); break;
    case FB_BUFADDR: change_buf_addr (value); break;
Line 53... Line 62...
                     break;
                     break;
    default:
    default:
      a -= FB_PAL;
      a -= FB_PAL;
      a /= 4;
      a /= 4;
      if (a < 0 || a >= 256) {
      if (a < 0 || a >= 256) {
        fprintf (stderr, "Write out of palette buffer (0x%08lx)!\n", addr);
        fprintf (stderr, "Write out of palette buffer (0x%"PRIxADDR")!\n", addr);
        runtime.sim.cont_run = 0;
        runtime.sim.cont_run = 0;
      } else pal[a] = value;
      } else pal[a] = value;
      break;
      break;
  }
  }
}
}
 
 
/* Read a register */
/* Read a register */
unsigned long fb_read32 (unsigned long addr)
oraddr_t fb_read32 (oraddr_t addr)
{
{
  int a = (addr - config.fb.baseaddr);
  int a = (addr - config.fb.baseaddr);
  switch (a) {
  switch (a) {
    case FB_CTRL:
    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);
Line 75... Line 84...
    case FB_CAMPOSADDR: return camera_pos; break;
    case FB_CAMPOSADDR: return camera_pos; break;
    default:
    default:
      a -= FB_PAL;
      a -= FB_PAL;
      a /= 4;
      a /= 4;
      if (a < 0 || a >= 256) {
      if (a < 0 || a >= 256) {
        fprintf (stderr, "Read out of palette buffer (0x%08lx)!\n", addr);
        fprintf (stderr, "Read out of palette buffer (0x%"PRIxADDR")!\n", addr);
        runtime.sim.cont_run = 0;
        runtime.sim.cont_run = 0;
        return 0;
        return 0;
      } else return pal[a];
      } else return pal[a];
  }
  }
}
}

powered by: WebSVN 2.1.0

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