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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [common/] [abstract.c] - Diff between revs 1308 and 1319

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

Rev 1308 Rev 1319
Line 184... Line 184...
    cur_area->delayr = delayr;
    cur_area->delayr = delayr;
    cur_area->delayw = delayw;
    cur_area->delayw = delayw;
  }
  }
}
}
 
 
 
/* for cpu accesses
 
 *
 
 * STATISTICS: check cpu/common/parse.c
 
 */
inline unsigned long evalsim_mem32(unsigned long memaddr)
inline unsigned long evalsim_mem32(unsigned long memaddr)
{
{
  unsigned long temp;
        return(evalsim_mem32_atomic(memaddr, 1));
 
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do */
 
inline unsigned long evalsim_mem32_void(unsigned long memaddr)
 
{
 
        return(evalsim_mem32_atomic(memaddr, 0));
 
}
 
 
 
unsigned long evalsim_mem32_atomic(unsigned long memaddr, int cpu_access)
 
{
 
  unsigned long temp = 0;
 
 
  if (verify_memoryarea(memaddr)) {
  if (verify_memoryarea(memaddr)) {
    switch(cur_area->granularity) {
    switch(cur_area->granularity) {
    case 4:
    case 4:
      temp = cur_area->readfunc(memaddr);
      temp = cur_area->readfunc(memaddr);
      runtime.sim.mem_cycles += cur_area->delayr;
 
      break;
      break;
    case 1:
    case 1:
      temp = cur_area->readfunc(memaddr) << 24;
      temp = cur_area->readfunc(memaddr) << 24;
      temp |= cur_area->readfunc(memaddr + 1) << 16;
      temp |= cur_area->readfunc(memaddr + 1) << 16;
      temp |= cur_area->readfunc(memaddr + 2) << 8;
      temp |= cur_area->readfunc(memaddr + 2) << 8;
      temp |= cur_area->readfunc(memaddr + 3);
      temp |= cur_area->readfunc(memaddr + 3);
      runtime.sim.mem_cycles += cur_area->delayr * 4;
 
      break;
      break;
    case 2:
    case 2:
      temp = cur_area->readfunc(memaddr) << 16;
      temp = cur_area->readfunc(memaddr) << 16;
      temp |= cur_area->readfunc(memaddr + 2);
      temp |= cur_area->readfunc(memaddr + 2);
      runtime.sim.mem_cycles += cur_area->delayr * 2;
 
      break;
      break;
 
    default:
 
      /* if you add new memory granularity be sure to check the formula
 
       * below for the read delay and fix it if necessery
 
       */
 
      PRINTF("unknown/unhandled memory granularuty\n");
 
      exit(-1);
    }
    }
 
    if (cpu_access)
 
      runtime.sim.mem_cycles += cur_area->delayr * (4 / cur_area->granularity);
  }
  }
  return temp;
  return temp;
}
}
 
 
unsigned short evalsim_mem16(unsigned long memaddr)
/* for cpu accesses */
 
inline unsigned short evalsim_mem16(unsigned long memaddr)
{
{
  unsigned long temp;
        return(evalsim_mem16_atomic(memaddr, 1));
 
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do */
 
inline unsigned short evalsim_mem16_void(unsigned long memaddr)
 
{
 
        return(evalsim_mem16_atomic(memaddr, 0));
 
}
 
 
 
unsigned short evalsim_mem16_atomic(unsigned long memaddr, int cpu_access)
 
{
 
  unsigned long temp = 0;
 
 
  if (verify_memoryarea(memaddr)) {
  if (verify_memoryarea(memaddr)) {
    switch(cur_area->granularity) {
    switch(cur_area->granularity) {
    case 1:
    case 1:
      temp = cur_area->readfunc(memaddr) << 8;
      temp = cur_area->readfunc(memaddr) << 8;
      temp |= cur_area->readfunc(memaddr + 1);
      temp |= cur_area->readfunc(memaddr + 1);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayr * 2;
      runtime.sim.mem_cycles += cur_area->delayr * 2;
      break;
      break;
    case 2:
    case 2:
      temp = cur_area->readfunc(memaddr);
      temp = cur_area->readfunc(memaddr);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayr;
      runtime.sim.mem_cycles += cur_area->delayr;
      break;
      break;
    case 4:
    case 4:
      temp = evalsim_mem32 (memaddr & ~3ul);
      temp = evalsim_mem32_atomic (memaddr & ~3ul, cpu_access);
      if (memaddr & 2)
      if (memaddr & 2)
        temp &= 0xffff;
        temp &= 0xffff;
      else
      else
        temp >>= 16;
        temp >>= 16;
      break;
      break;
 
    default:
 
      /* if you add new memory granularity be sure to check the formula
 
       * below for the read delay and fix it if necessery
 
       */
 
      PRINTF("unknown/unhandled memory granularuty\n");
 
      exit(-1);
    }
    }
  }
  }
  return temp;
  return temp;
}
}
 
 
unsigned char evalsim_mem8(unsigned long memaddr)
/* for cpu accesses */
 
inline unsigned char evalsim_mem8(unsigned long memaddr)
{
{
  unsigned long temp;
        return(evalsim_mem8_atomic(memaddr, 1));
 
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do */
 
inline unsigned char evalsim_mem8_void(unsigned long memaddr)
 
{
 
        return(evalsim_mem8_atomic(memaddr, 0));
 
}
 
 
 
unsigned char evalsim_mem8_atomic(unsigned long memaddr, int cpu_access)
 
{
 
  unsigned long temp = 0;
 
 
  if (verify_memoryarea(memaddr)) {
  if (verify_memoryarea(memaddr)) {
    switch(cur_area->granularity) {
    switch(cur_area->granularity) {
    case 1:
    case 1:
      temp = cur_area->readfunc(memaddr);
      temp = cur_area->readfunc(memaddr);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayr;
      runtime.sim.mem_cycles += cur_area->delayr;
      break;
      break;
    case 2:
    case 2:
      temp = evalsim_mem16 (memaddr & ~1ul);
      temp = evalsim_mem16_atomic (memaddr & ~1ul, cpu_access);
      if (memaddr & 1)
      if (memaddr & 1)
        temp &= 0xff;
        temp &= 0xff;
      else
      else
        temp >>= 8;
        temp >>= 8;
      break;
      break;
    case 4:
    case 4:
      temp = evalsim_mem32 (memaddr & ~3ul);
      temp = evalsim_mem32_atomic (memaddr & ~3ul, cpu_access);
      temp >>= 8 * (3 - (memaddr & 3));
      temp >>= 8 * (3 - (memaddr & 3));
      temp &= 0xff;
      temp &= 0xff;
      break;
      break;
 
    default:
 
      /* if you add new memory granularity be sure to check the formula
 
       * below for the read delay and fix it if necessery
 
       */
 
      PRINTF("unknown/unhandled memory granularuty\n");
 
      exit(-1);
    }
    }
  }
  }
  return temp;
  return temp;
}
}
 
 
/* Returns 32-bit values from mem array. Big endian version. */
/* Returns 32-bit values from mem array. Big endian version.
 
 *
 
 * this function is only used in dump_memory() below, so it's
 
 * safe to asume it's for simulator purposes access only,
 
 * hence the use of eval_mem32_void()
 
 *
 
 * STATISTICS OK.
 
 */
unsigned long read_mem(unsigned long memaddr,int* breakpoint)
unsigned long read_mem(unsigned long memaddr,int* breakpoint)
{
{
  unsigned long temp;
  unsigned long temp;
 
 
  cur_vadd = memaddr;
  cur_vadd = memaddr;
  if (config.debug.enabled)
  if (config.debug.enabled)
    *breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
    *breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
  temp = evalsim_mem32(memaddr);
  temp = evalsim_mem32_void(memaddr);
  if (!cur_area) {
  if (!cur_area) {
    PRINTF("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
    PRINTF("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
    except_handle(EXCEPT_BUSERR, cur_vadd);
    except_handle(EXCEPT_BUSERR, cur_vadd);
    temp = 0;
    temp = 0;
  }
  }
Line 287... Line 353...
  if (config.debug.enabled)
  if (config.debug.enabled)
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
  return temp;
  return temp;
}
}
 
 
/* Returns 32-bit values from mem array. Big endian version. */
/* Returns 32-bit values from mem array. Big endian version.
 
 *
 
 * STATISTICS OK (only used for cpu_access, that is architectural access)
 
 */
unsigned long eval_mem32(unsigned long memaddr,int* breakpoint)
unsigned long eval_mem32(unsigned long memaddr,int* breakpoint)
{
{
 
 
  unsigned long temp;
  unsigned long temp;
 
 
  if (config.sim.mprofile)
  if (config.sim.mprofile)
    mprofile (memaddr, MPROF_32 | MPROF_READ);
    mprofile (memaddr, MPROF_32 | MPROF_READ);
 
 
Line 326... Line 394...
  if (config.debug.enabled)
  if (config.debug.enabled)
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
  return temp;
  return temp;
}
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do
 
 *
 
 * STATISTICS OK
 
 */
unsigned long eval_direct32(unsigned long memaddr, int *breakpoint,
unsigned long eval_direct32(unsigned long memaddr, int *breakpoint,
                            int through_mmu, int through_dc)
                            int through_mmu, int through_dc)
{
{
  unsigned long temp;
  unsigned long temp;
 
 
Line 344... Line 416...
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
 
 
  if (through_dc)
  if (through_dc)
    temp = dc_simulate_read(memaddr, 4);
    temp = dc_simulate_read(memaddr, 4);
  else {
  else {
    temp = evalsim_mem32(memaddr);
    temp = evalsim_mem32_void(memaddr);
    if (!cur_area) {
    if (!cur_area) {
      PRINTF("EXCEPTION: read out of memory (32-bit access to %.8lx) in eval_direct32()\n", memaddr);
      PRINTF("EXCEPTION: read out of memory (32-bit access to %.8lx) in eval_direct32()\n", memaddr);
      except_handle(EXCEPT_BUSERR, cur_vadd);
      except_handle(EXCEPT_BUSERR, cur_vadd);
      temp = 0;
      temp = 0;
    }
    }
Line 356... Line 428...
 
 
  return temp;
  return temp;
}
}
 
 
 
 
/* Returns 32-bit values from mem array. Big endian version. */
/* Returns 32-bit values from mem array. Big endian version.
 
 *
 
 * STATISTICS OK (only used for cpu_access, that is architectural access)
 
 */
unsigned long eval_insn(unsigned long memaddr,int* breakpoint)
unsigned long eval_insn(unsigned long memaddr,int* breakpoint)
{
{
  unsigned long temp;
  unsigned long temp;
 
 
  if (config.sim.mprofile)
  if (config.sim.mprofile)
Line 390... Line 465...
//  if (config.debug.enabled)
//  if (config.debug.enabled)
//    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
//    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
  return temp;
  return temp;
}
}
 
 
/* Returns 16-bit values from mem array. Big endian version. */
/* Returns 16-bit values from mem array. Big endian version.
 
 *
 
 * STATISTICS OK (only used for cpu_access, that is architectural access)
 
 */
unsigned short eval_mem16(unsigned long memaddr,int* breakpoint)
unsigned short eval_mem16(unsigned long memaddr,int* breakpoint)
{
{
  unsigned short temp;
  unsigned short temp;
 
 
  if (config.sim.mprofile)
  if (config.sim.mprofile)
Line 429... Line 506...
  if (config.debug.enabled)
  if (config.debug.enabled)
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
  return temp;
  return temp;
}
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do
 
 *
 
 * STATISTICS OK.
 
 */
unsigned short eval_direct16(unsigned long memaddr, int *breakpoint,
unsigned short eval_direct16(unsigned long memaddr, int *breakpoint,
                             int through_mmu, int through_dc)
                             int through_mmu, int through_dc)
{
{
  unsigned long temp;
  unsigned long temp;
 
 
Line 447... Line 528...
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
 
 
  if (through_dc)
  if (through_dc)
    temp = dc_simulate_read(memaddr, 2);
    temp = dc_simulate_read(memaddr, 2);
  else {
  else {
    temp = evalsim_mem16(memaddr);
    temp = evalsim_mem16_void(memaddr);
    if (!cur_area) {
    if (!cur_area) {
      PRINTF("EXCEPTION: read out of memory (16-bit access to %.8lx) in eval_direct16()\n", memaddr);
      PRINTF("EXCEPTION: read out of memory (16-bit access to %.8lx) in eval_direct16()\n", memaddr);
      except_handle(EXCEPT_BUSERR, cur_vadd);
      except_handle(EXCEPT_BUSERR, cur_vadd);
      temp = 0;
      temp = 0;
    }
    }
Line 459... Line 540...
 
 
  return temp;
  return temp;
}
}
 
 
 
 
/* Returns 8-bit values from mem array. */
/* Returns 8-bit values from mem array.
 
 *
 
 * STATISTICS OK (only used for cpu_access, that is architectural access)
 
 */
unsigned char eval_mem8(unsigned long memaddr,int* breakpoint)
unsigned char eval_mem8(unsigned long memaddr,int* breakpoint)
{
{
  unsigned char temp;
  unsigned char temp;
 
 
  if (config.sim.mprofile)
  if (config.sim.mprofile)
Line 493... Line 576...
  if (config.debug.enabled)
  if (config.debug.enabled)
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
    *breakpoint += CheckDebugUnit(DebugLoadData,temp);  /* MM170901 */
  return temp;
  return temp;
}
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do
 
 *
 
 * STATISTICS OK.
 
 */
unsigned char eval_direct8(unsigned long memaddr, int *breakpoint,
unsigned char eval_direct8(unsigned long memaddr, int *breakpoint,
                           int through_mmu, int through_dc)
                           int through_mmu, int through_dc)
{
{
  unsigned char temp;
  unsigned char temp;
 
 
Line 511... Line 598...
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
 
 
  if (through_dc)
  if (through_dc)
    temp = (unsigned char)dc_simulate_read(memaddr, 1);
    temp = (unsigned char)dc_simulate_read(memaddr, 1);
  else {
  else {
    temp = evalsim_mem8(memaddr);
    temp = evalsim_mem8_void(memaddr);
    if (!cur_area) {
    if (!cur_area) {
      PRINTF("EXCEPTION: read out of memory (8-bit access to %.8lx) in eval_direct8()\n", memaddr);
      PRINTF("EXCEPTION: read out of memory (8-bit access to %.8lx) in eval_direct8()\n", memaddr);
      except_handle(EXCEPT_BUSERR, cur_vadd);
      except_handle(EXCEPT_BUSERR, cur_vadd);
      temp = 0;
      temp = 0;
    }
    }
  }
  }
  return temp;
  return temp;
}
}
 
 
 
/* for cpu accesses */
 
inline void setsim_mem32(unsigned long memaddr, unsigned long value)
 
{
 
  return(setsim_mem32_atomic(memaddr, value, 1));
 
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do */
 
inline void setsim_mem32_void(unsigned long memaddr, unsigned long value)
 
{
 
  return(setsim_mem32_atomic(memaddr, value, 0));
 
}
 
 
void setsim_mem32(unsigned long memaddr, unsigned long value)
void setsim_mem32_atomic(unsigned long memaddr, unsigned long value, int cpu_access)
{
{
  if (verify_memoryarea(memaddr)) {
  if (verify_memoryarea(memaddr)) {
    switch(cur_area->granularity) {
    switch(cur_area->granularity) {
    case 4:
    case 4:
      cur_area->writefunc(memaddr, value);
      cur_area->writefunc(memaddr, value);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayw;
      runtime.sim.mem_cycles += cur_area->delayw;
      break;
      break;
    case 1:
    case 1:
      cur_area->writefunc(memaddr    , (value >> 24) & 0xFF);
      cur_area->writefunc(memaddr    , (value >> 24) & 0xFF);
      cur_area->writefunc(memaddr + 1, (value >> 16) & 0xFF);
      cur_area->writefunc(memaddr + 1, (value >> 16) & 0xFF);
      cur_area->writefunc(memaddr + 2, (value >>  8) & 0xFF);
      cur_area->writefunc(memaddr + 2, (value >>  8) & 0xFF);
      cur_area->writefunc(memaddr + 3, (value      ) & 0xFF);
      cur_area->writefunc(memaddr + 3, (value      ) & 0xFF);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayw * 4;
      runtime.sim.mem_cycles += cur_area->delayw * 4;
      break;
      break;
    case 2:
    case 2:
      cur_area->writefunc(memaddr, (value >> 16) & 0xFFFF);
      cur_area->writefunc(memaddr, (value >> 16) & 0xFFFF);
      cur_area->writefunc(memaddr + 2, value & 0xFFFF);
      cur_area->writefunc(memaddr + 2, value & 0xFFFF);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayw * 2;
      runtime.sim.mem_cycles += cur_area->delayw * 2;
      break;
      break;
 
    default:
 
      /* if you add new memory granularity be sure to check the formula
 
       * below for the read delay and fix it if necessery
 
       */
 
      PRINTF("unknown/unhandled memory granularuty\n");
 
      exit(-1);
    }
    }
  } else {
  } else {
    PRINTF("EXCEPTION: write out of memory (32-bit access to %.8lx)\n", memaddr);
    PRINTF("EXCEPTION: write out of memory (32-bit access to %.8lx)\n", memaddr);
    except_handle(EXCEPT_BUSERR, cur_vadd);
    except_handle(EXCEPT_BUSERR, cur_vadd);
  }
  }
}
}
 
 
void setsim_mem16(unsigned long memaddr, unsigned short value)
/* for cpu accesses */
 
inline void setsim_mem16(unsigned long memaddr, unsigned short value)
 
{
 
  return(setsim_mem16_atomic(memaddr, value, 1));
 
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do */
 
inline void setsim_mem16_void(unsigned long memaddr, unsigned short value)
 
{
 
  return(setsim_mem16_atomic(memaddr, value, 0));
 
}
 
 
 
void setsim_mem16_atomic(unsigned long memaddr, unsigned short value, int cpu_access)
{
{
  unsigned long temp;
  unsigned long temp;
  if (verify_memoryarea(memaddr)) {
  if (verify_memoryarea(memaddr)) {
    switch(cur_area->granularity) {
    switch(cur_area->granularity) {
    case 1:
    case 1:
      cur_area->writefunc(memaddr, (value >> 8) & 0xFF);
      cur_area->writefunc(memaddr, (value >> 8) & 0xFF);
      cur_area->writefunc(memaddr + 1, value & 0xFF);
      cur_area->writefunc(memaddr + 1, value & 0xFF);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayw * 2;
      runtime.sim.mem_cycles += cur_area->delayw * 2;
      break;
      break;
    case 2:
    case 2:
      cur_area->writefunc(memaddr, value & 0xFFFF);
      cur_area->writefunc(memaddr, value & 0xFFFF);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayw;
      runtime.sim.mem_cycles += cur_area->delayw;
      break;
      break;
    case 4:
    case 4:
      temp = evalsim_mem32 (memaddr & ~3ul);
      temp = evalsim_mem32_void(memaddr & ~3ul);
      temp &= 0xffff << ((memaddr & 2) ? 16 : 0);
      temp &= 0xffff << ((memaddr & 2) ? 16 : 0);
      temp |= (unsigned long)(value & 0xffff) << ((memaddr & 2) ? 0 : 16);
      temp |= (unsigned long)(value & 0xffff) << ((memaddr & 2) ? 0 : 16);
      setsim_mem32 (memaddr & ~3ul, temp);
      setsim_mem32_atomic(memaddr & ~3ul, temp, cpu_access);
      break;
      break;
 
    default:
 
      /* if you add new memory granularity be sure to check the formula
 
       * below for the read delay and fix it if necessery
 
       */
 
      PRINTF("unknown/unhandled memory granularuty\n");
 
      exit(-1);
    }
    }
  } else {
  } else {
    PRINTF("EXCEPTION: write out of memory (16-bit access to %.8lx)\n", memaddr);
    PRINTF("EXCEPTION: write out of memory (16-bit access to %.8lx)\n", memaddr);
    except_handle(EXCEPT_BUSERR, cur_vadd);
    except_handle(EXCEPT_BUSERR, cur_vadd);
  }
  }
}
}
 
 
void setsim_mem8(unsigned long memaddr, unsigned char value)
/* for cpu accesses */
 
inline void setsim_mem8(unsigned long memaddr, unsigned char value)
 
{
 
  return(setsim_mem8_atomic(memaddr, value, 1));
 
}
 
 
 
/* for simulator accesses, the ones that cpu wouldn't do */
 
inline void setsim_mem8_void(unsigned long memaddr, unsigned char value)
 
{
 
  return(setsim_mem8_atomic(memaddr, value, 0));
 
}
 
 
 
void setsim_mem8_atomic(unsigned long memaddr, unsigned char value, int cpu_access)
{
{
  unsigned long temp;
  unsigned long temp;
  if (verify_memoryarea(memaddr)) {
  if (verify_memoryarea(memaddr)) {
    switch (cur_area->granularity) {
    switch (cur_area->granularity) {
    case 1:
    case 1:
      cur_area->writefunc(memaddr, value);
      cur_area->writefunc(memaddr, value);
 
      if (cpu_access)
      runtime.sim.mem_cycles += cur_area->delayw;
      runtime.sim.mem_cycles += cur_area->delayw;
      break;
      break;
    case 2:
    case 2:
      temp = evalsim_mem16 (memaddr & ~1ul);
      temp = evalsim_mem16_void (memaddr & ~1ul);
      temp &= 0xff << ((memaddr & 1) ? 8 : 0);
      temp &= 0xff << ((memaddr & 1) ? 8 : 0);
      temp |= (unsigned short)(value & 0xff) << ((memaddr & 1) ? 0 : 8);
      temp |= (unsigned short)(value & 0xff) << ((memaddr & 1) ? 0 : 8);
      setsim_mem16 (memaddr & ~1ul, temp);
      setsim_mem16_atomic (memaddr & ~1ul, temp, cpu_access);
      break;
      break;
    case 4:
    case 4:
      temp = evalsim_mem32 (memaddr & ~3ul);
      temp = evalsim_mem32_void (memaddr & ~3ul);
      temp &= ~(0xff << (8 * (3 - (memaddr & 3))));
      temp &= ~(0xff << (8 * (3 - (memaddr & 3))));
      temp |= (unsigned long)(value & 0xff) << (8 * (3 - (memaddr & 3)));
      temp |= (unsigned long)(value & 0xff) << (8 * (3 - (memaddr & 3)));
      setsim_mem32 (memaddr & ~3ul, temp);
      setsim_mem32_atomic (memaddr & ~3ul, temp, cpu_access);
      break;
      break;
    }
    }
  } else {
  } else {
    PRINTF("EXCEPTION: write out of memory (8-bit access to %.8lx)\n", memaddr);
    PRINTF("EXCEPTION: write out of memory (8-bit access to %.8lx)\n", memaddr);
    except_handle(EXCEPT_BUSERR, cur_vadd);
    except_handle(EXCEPT_BUSERR, cur_vadd);
  }
  }
}
}
 
 
/* Set mem, 32-bit. Big endian version. */
/* Set mem, 32-bit. Big endian version.
 
 *
 
 * STATISTICS OK. (the only suspicious usage is in toplevel.c,
 
 *                 where this instruction is used for patching memory,
 
 *                 wether this is cpu or architectual access is yet to
 
 *                 be decided)
 
 */
void set_mem32(unsigned long memaddr, unsigned long value,int* breakpoint)
void set_mem32(unsigned long memaddr, unsigned long value,int* breakpoint)
{
{
  if (config.sim.mprofile)
  if (config.sim.mprofile)
    mprofile (memaddr, MPROF_32 | MPROF_WRITE);
    mprofile (memaddr, MPROF_32 | MPROF_WRITE);
 
 
Line 633... Line 778...
 
 
  if (cur_area && cur_area->log)
  if (cur_area && cur_area->log)
    fprintf (cur_area->log, "[%08lx] -> write %08lx\n", memaddr, value);
    fprintf (cur_area->log, "[%08lx] -> write %08lx\n", memaddr, value);
}
}
 
 
 
/*
 
 * STATISTICS NOT OK.
 
 */
void set_direct32(unsigned long memaddr, unsigned long value,int* breakpoint,
void set_direct32(unsigned long memaddr, unsigned long value,int* breakpoint,
                  int through_mmu, int through_dc)
                  int through_mmu, int through_dc)
{
{
 
 
  if (memaddr & 3) {
  if (memaddr & 3) {
Line 651... Line 799...
     */
     */
    memaddr = peek_into_dtlb(memaddr, 1, through_dc);
    memaddr = peek_into_dtlb(memaddr, 1, through_dc);
  }
  }
 
 
 
 
  /* __PHX__ fixme: in principle we should write around the cache if
  /* __PHX__ fixme: we'll get cache hit/miss delay added to cycles count,
   *                through_dc is set, but i believe we this will work
   *                and possibly also memory access times.
   *                just fine anyway
 
   */
   */
 
  if (!through_dc)
 
    PRINTF("WARNING: statistics might not be OK\n");
  dc_simulate_write(memaddr, value, 4);
  dc_simulate_write(memaddr, value, 4);
 
 
  if (cur_area && cur_area->log)
  if (cur_area && cur_area->log)
    fprintf (cur_area->log, "[%08lx] -> write %08lx\n", memaddr, value);
    fprintf (cur_area->log, "[%08lx] -> write %08lx\n", memaddr, value);
}
}
Line 691... Line 840...
 
 
  if (cur_area && cur_area->log)
  if (cur_area && cur_area->log)
    fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
    fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
}
}
 
 
 
/*
 
 * STATISTICS NOT OK.
 
 */
void set_direct16(unsigned long memaddr, unsigned short value, int* breakpoint,
void set_direct16(unsigned long memaddr, unsigned short value, int* breakpoint,
                  int through_mmu, int through_dc)
                  int through_mmu, int through_dc)
{
{
 
 
  if (memaddr & 3) {
  if (memaddr & 3) {
Line 708... Line 860...
    /* 0 - no write access, we do not want a DPF exception do we ;)
    /* 0 - no write access, we do not want a DPF exception do we ;)
     */
     */
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
  }
  }
 
 
  /* __PHX__ fixme: in principle we should write around the cache if
  /* __PHX__ fixme: we'll get cache hit/miss delay added to cycles count,
   *                through_dc is set, but i believe we this will work
   *                and possibly also memory access times.
   *                just fine anyway
 
   */
   */
 
  if (!through_dc)
 
    PRINTF("WARNING: statistics might not be OK\n");
  dc_simulate_write(memaddr, value, 2);
  dc_simulate_write(memaddr, value, 2);
 
 
  if (cur_area && cur_area->log)
  if (cur_area && cur_area->log)
    fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
    fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
}
}
Line 741... Line 894...
 
 
  if (cur_area && cur_area->log)
  if (cur_area && cur_area->log)
    fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
    fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
}
}
 
 
 
/*
 
 * STATISTICS NOT OK.
 
 */
void set_direct8(unsigned long memaddr, unsigned char value, int* breakpoint,
void set_direct8(unsigned long memaddr, unsigned char value, int* breakpoint,
                 int through_mmu, int through_dc)
                 int through_mmu, int through_dc)
{
{
 
 
  if (memaddr & 3) {
  if (memaddr & 3) {
Line 758... Line 914...
    /* 0 - no write access, we do not want a DPF exception do we ;)
    /* 0 - no write access, we do not want a DPF exception do we ;)
     */
     */
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
    memaddr = peek_into_dtlb(memaddr, 0, through_dc);
  }
  }
 
 
  /* __PHX__ fixme: in principle we should write around the cache if
  /* __PHX__ fixme: we'll get cache hit/miss delay added to cycles count,
   *                through_dc is set, but i believe we this will work
   *                and possibly also memory access times.
   *                just fine anyway
 
   */
   */
 
  if (!through_dc)
 
    PRINTF("WARNING: statistics might not be OK\n");
  dc_simulate_write(memaddr, value, 1);
  dc_simulate_write(memaddr, value, 1);
 
 
  if (cur_area && cur_area->log)
  if (cur_area && cur_area->log)
    fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
    fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
}
}
 
 
 
 
 
 
void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl)
void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl)
{
{
  unsigned int i, j;
  unsigned int i, j;
  struct label_entry *tmp;
  struct label_entry *tmp;
  int ilen = disasm ? 4 : 16;
  int ilen = disasm ? 4 : 16;

powered by: WebSVN 2.1.0

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