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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [cpu/] [or1k/] [except.c] - Diff between revs 19 and 552

Show entire file | Details | Blame | View Log

Rev 19 Rev 552
Line 34... Line 34...
#include "debug.h"
#include "debug.h"
#include "spr-defs.h"
#include "spr-defs.h"
#include "execute.h"
#include "execute.h"
#include "debug-unit.h"
#include "debug-unit.h"
 
 
#if DYNAMIC_EXECUTION
 
#include "sched.h"
 
#include "op-support.h"
 
#endif
 
 
 
extern void op_join_mem_cycles(void);
extern void op_join_mem_cycles(void);
 
 
 
 
 
 
int except_pending = 0;
int except_pending = 0;
Line 56... Line 51...
  oraddr_t except_vector;
  oraddr_t except_vector;
 
 
  if (debug_ignore_exception (except))
  if (debug_ignore_exception (except))
    return;
    return;
 
 
#if !(DYNAMIC_EXECUTION)
 
  /* In the dynamic recompiler, this function never returns, so this is not
  /* In the dynamic recompiler, this function never returns, so this is not
   * needed.  Ofcourse we could set it anyway, but then all code that checks
   * needed.  Ofcourse we could set it anyway, but then all code that checks
   * this variable would break, since it is never reset */
   * this variable would break, since it is never reset */
  except_pending = 1;
  except_pending = 1;
#endif
 
 
 
  except_vector =
  except_vector =
    except + (cpu_state.sprs[SPR_SR] & SPR_SR_EPH ? 0xf0000000 : 0x00000000);
    except + (cpu_state.sprs[SPR_SR] & SPR_SR_EPH ? 0xf0000000 : 0x00000000);
 
 
#if !(DYNAMIC_EXECUTION)
 
  pcnext = except_vector;
  pcnext = except_vector;
#endif
 
 
 
  cpu_state.sprs[SPR_EEAR_BASE] = ea;
  cpu_state.sprs[SPR_EEAR_BASE] = ea;
  cpu_state.sprs[SPR_ESR_BASE] = cpu_state.sprs[SPR_SR];
  cpu_state.sprs[SPR_ESR_BASE] = cpu_state.sprs[SPR_SR];
 
 
  cpu_state.sprs[SPR_SR] &= ~SPR_SR_OVE;        /* Disable overflow flag exception. */
  cpu_state.sprs[SPR_SR] &= ~SPR_SR_OVE;        /* Disable overflow flag exception. */
Line 81... Line 72...
  cpu_state.sprs[SPR_SR] &= ~(SPR_SR_IEE | SPR_SR_TEE); /* Disable interrupts. */
  cpu_state.sprs[SPR_SR] &= ~(SPR_SR_IEE | SPR_SR_TEE); /* Disable interrupts. */
 
 
  /* Address translation is always disabled when starting exception. */
  /* Address translation is always disabled when starting exception. */
  cpu_state.sprs[SPR_SR] &= ~SPR_SR_DME;
  cpu_state.sprs[SPR_SR] &= ~SPR_SR_DME;
 
 
#if DYNAMIC_EXECUTION
 
  /* If we were called from do_scheduler and there were more jobs scheduled to
 
   * run after this, they won't run unless the following call is made since this
 
   * function never returns.  (If we weren't called from do_scheduler, then the
 
   * job at the head of the queue will still have some time remaining) */
 
  if (scheduler.job_queue->time <= 0)
 
    do_scheduler ();
 
#endif
 
 
 
  switch (except)
  switch (except)
    {
    {
      /* EPCR is irrelevent */
      /* EPCR is irrelevent */
    case EXCEPT_RESET:
    case EXCEPT_RESET:
      break;
      break;
      /* EPCR is loaded with address of instruction that caused the exception */
      /* EPCR is loaded with address of instruction that caused the exception */
    case EXCEPT_ITLBMISS:
    case EXCEPT_ITLBMISS:
    case EXCEPT_IPF:
    case EXCEPT_IPF:
      cpu_state.sprs[SPR_EPCR_BASE] = ea - (cpu_state.delay_insn ? 4 : 0);
      cpu_state.sprs[SPR_EPCR_BASE] = ea - (cpu_state.delay_insn ? 4 : 0);
#if DYNAMIC_EXECUTION
 
      op_join_mem_cycles ();
 
#endif
 
      break;
      break;
    case EXCEPT_BUSERR:
    case EXCEPT_BUSERR:
    case EXCEPT_DPF:
    case EXCEPT_DPF:
    case EXCEPT_ALIGN:
    case EXCEPT_ALIGN:
    case EXCEPT_ILLEGAL:
    case EXCEPT_ILLEGAL:
    case EXCEPT_DTLBMISS:
    case EXCEPT_DTLBMISS:
    case EXCEPT_RANGE:
    case EXCEPT_RANGE:
    case EXCEPT_TRAP:
    case EXCEPT_TRAP:
      /* All these exceptions happen during a simulated instruction */
      /* All these exceptions happen during a simulated instruction */
#if DYNAMIC_EXECUTION
 
      /* Since these exceptions happen during a simulated instruction and this
 
       * function jumps out to the exception vector the scheduler would never have
 
       * a chance to run, therefore run it now */
 
      run_sched_out_of_line ();
 
#endif
 
      cpu_state.sprs[SPR_EPCR_BASE] =
      cpu_state.sprs[SPR_EPCR_BASE] =
        cpu_state.pc - (cpu_state.delay_insn ? 4 : 0);
        cpu_state.pc - (cpu_state.delay_insn ? 4 : 0);
      break;
      break;
      /* EPCR is loaded with address of next not-yet-executed instruction */
      /* EPCR is loaded with address of next not-yet-executed instruction */
    case EXCEPT_SYSCALL:
    case EXCEPT_SYSCALL:
Line 131... Line 104...
       * simulated, therefore the pc already points to the *next* instruction */
       * simulated, therefore the pc already points to the *next* instruction */
    case EXCEPT_TICK:
    case EXCEPT_TICK:
    case EXCEPT_INT:
    case EXCEPT_INT:
      cpu_state.sprs[SPR_EPCR_BASE] =
      cpu_state.sprs[SPR_EPCR_BASE] =
        cpu_state.pc - (cpu_state.delay_insn ? 4 : 0);
        cpu_state.pc - (cpu_state.delay_insn ? 4 : 0);
#if !(DYNAMIC_EXECUTION)
 
      /* If we don't update the pc now, then it will only happen *after* the next
      /* If we don't update the pc now, then it will only happen *after* the next
       * instruction (There would be serious problems if the next instruction just
       * instruction (There would be serious problems if the next instruction just
       * happens to be a branch), when it should happen NOW. */
       * happens to be a branch), when it should happen NOW. */
      cpu_state.pc = pcnext;
      cpu_state.pc = pcnext;
      pcnext += 4;
      pcnext += 4;
#endif
 
      break;
      break;
    }
    }
 
 
  /* Address trnaslation is here because run_sched_out_of_line calls
  /* Address trnaslation is here because run_sched_out_of_line calls
   * eval_insn_direct which checks out the immu for the address translation but
   * eval_insn_direct which checks out the immu for the address translation but
Line 153... Line 124...
   * exist and thus cpu_state.delay_insn would stick in the exception handler
   * exist and thus cpu_state.delay_insn would stick in the exception handler
   * causeing grief if the first instruction of the exception handler is also in
   * causeing grief if the first instruction of the exception handler is also in
   * the delay slot of the previous instruction */
   * the delay slot of the previous instruction */
  cpu_state.delay_insn = 0;
  cpu_state.delay_insn = 0;
 
 
#if DYNAMIC_EXECUTION
 
  do_jump (except_vector);
 
#endif
 
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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