Line 37... |
Line 37... |
#include "pic.h"
|
#include "pic.h"
|
#include "spr_defs.h"
|
#include "spr_defs.h"
|
#include "except.h"
|
#include "except.h"
|
#include "sprs.h"
|
#include "sprs.h"
|
#include "debug.h"
|
#include "debug.h"
|
|
#include "sched.h"
|
|
|
extern int cont_run;
|
extern int cont_run;
|
|
|
/* Reset. It initializes PIC registers. */
|
/* Reset. It initializes PIC registers. */
|
void pic_reset()
|
void pic_reset()
|
Line 49... |
Line 50... |
mtspr(SPR_PICMR, 0);
|
mtspr(SPR_PICMR, 0);
|
mtspr(SPR_PICPR, 0);
|
mtspr(SPR_PICPR, 0);
|
mtspr(SPR_PICSR, 0);
|
mtspr(SPR_PICSR, 0);
|
}
|
}
|
|
|
/* Simulation hook. Must be called every clock cycle to simulate PIC
|
/* Simulation hook. Called when interrupts are masked. */
|
It does internal functional PIC simulation. */
|
void pic_clock(int i)
|
inline void pic_clock()
|
|
{
|
{
|
/* Don't do anything if interrupts not currently enabled or
|
/* Don't do anything if interrupts not currently enabled */
|
higher priority exception was allready reported */
|
if(testsprbits (SPR_SR, SPR_SR_IEE))
|
if(mfspr(SPR_PICSR) && testsprbits (SPR_SR, SPR_SR_IEE) && !pending.valid)
|
|
except_handle(EXCEPT_INT, mfspr(SPR_EEAR_BASE));
|
except_handle(EXCEPT_INT, mfspr(SPR_EEAR_BASE));
|
|
else
|
|
SCHED_ADD(pic_clock, 0, 1);
|
}
|
}
|
|
|
|
/* WARNING: Don't eaven try and call this function *during* a simulated
|
|
* instruction!! (as in during a read_mem or write_mem callback). except_handle
|
|
* assumes that this is the case, it breaks otherwise. */
|
/* Asserts interrupt to the PIC. */
|
/* Asserts interrupt to the PIC. */
|
void report_interrupt(int line)
|
void report_interrupt(int line)
|
{
|
{
|
setsprbits(SPR_PMR, SPR_PMR_DME, 0); /* Disable doze mode */
|
setsprbits(SPR_PMR, SPR_PMR_DME, 0); /* Disable doze mode */
|
setsprbits(SPR_PMR, SPR_PMR_SME, 0); /* Disable sleep mode */
|
setsprbits(SPR_PMR, SPR_PMR_SME, 0); /* Disable sleep mode */
|
|
|
debug(4, "Asserting interrupt %d (%s).\n", line, getsprbit(SPR_PICMR, line) ? "Unmasked" : "Masked");
|
debug(4, "Asserting interrupt %d (%s).\n", line, getsprbit(SPR_PICMR, line) ? "Unmasked" : "Masked");
|
|
|
if (getsprbit(SPR_PICMR, line) || line < 2)
|
if (getsprbit(SPR_PICMR, line) || line < 2) {
|
setsprbit(SPR_PICSR, line, 1);
|
setsprbit(SPR_PICSR, line, 1);
|
|
/* Don't do anything if interrupts not currently enabled */
|
|
if (testsprbits (SPR_SR, SPR_SR_IEE))
|
|
except_handle(EXCEPT_INT, mfspr(SPR_EEAR_BASE));
|
|
else
|
|
/* Interrupts not currently enabled, retry next clock cycle */
|
|
SCHED_ADD(pic_clock, 0, runtime.sim.cycles + 1);
|
|
}
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|