#define __ARCH_SPARC_INTERRUPT_HH__
#include "arch/sparc/faults.hh"
+#include "cpu/thread_context.hh"
+
namespace SparcISA
{
class Interrupts
{
protected:
- Fault interrupts[NumInterruptLevels];
- bool requested[NumInterruptLevels];
+
public:
Interrupts()
{
- for(int x = 0; x < NumInterruptLevels; x++)
- {
- interrupts[x] = new InterruptLevelN(x);
- requested[x] = false;
- }
+
}
void post(int int_num, int index)
{
- if(int_num < 0 || int_num >= NumInterruptLevels)
- panic("int_num out of bounds\n");
- requested[int_num] = true;
}
void clear(int int_num, int index)
{
- requested[int_num] = false;
+
}
void clear_all()
{
- for(int x = 0; x < NumInterruptLevels; x++)
- requested[x] = false;
+
}
bool check_interrupts(ThreadContext * tc) const
{
- return true;
+ // so far only handle softint interrupts
+ int int_level = InterruptLevel(tc->readMiscReg(MISCREG_SOFTINT));
+ if (int_level)
+ return true;
+ else
+ return false;
}
Fault getInterrupt(ThreadContext * tc)
{
- return NoFault;
+ // conditioning the softint interrups
+ if (tc->readMiscReg(MISCREG_HPSTATE) & hpriv) {
+ // if running in privileged mode, then pend the interrupt
+ return NoFault;
+ } else {
+ int int_level = InterruptLevel(tc->readMiscReg(MISCREG_SOFTINT));
+ if ((int_level <= tc->readMiscReg(MISCREG_PIL)) ||
+ !(tc->readMiscReg(MISCREG_PSTATE) & ie)) {
+ // if PIL or no interrupt enabled, then pend the interrupt
+ return NoFault;
+ } else {
+ return new InterruptLevelN(int_level);
+ }
+ }
}
void updateIntrInfo(ThreadContext * tc)
ThreadContext *tc)
{
int64_t time;
- int oldLevel, newLevel;
switch (miscReg) {
/* Full system only ASRs */
case MISCREG_SOFTINT:
// Check if we are going to interrupt because of something
- oldLevel = InterruptLevel(softint);
- newLevel = InterruptLevel(val);
setReg(miscReg, val);
- if (newLevel > oldLevel)
- ; // MUST DO SOMETHING HERE TO TELL CPU TO LOOK FOR INTERRUPTS XXX
- //tc->getCpuPtr()->checkInterrupts = true;
- panic("SOFTINT not implemented\n");
+ tc->getCpuPtr()->checkInterrupts = true;
break;
case MISCREG_SOFTINT_CLR:
sTickCompare->schedule(time * tc->getCpuPtr()->cycles(1));
break;
+ case MISCREG_PSTATE:
+ if (val & ie && !(pstate & ie)) {
+ tc->getCpuPtr()->checkInterrupts = true;
+ }
+ setReg(miscReg, val);
+
case MISCREG_PIL:
+ if (val < pil) {
+ tc->getCpuPtr()->checkInterrupts = true;
+ }
setReg(miscReg, val);
- //tc->getCpuPtr()->checkInterrupts;
- // MUST DO SOMETHING HERE TO TELL CPU TO LOOK FOR INTERRUPTS XXX
- panic("PIL not implemented\n");
break;
case MISCREG_HVER:
break;
case MISCREG_HPSTATE:
+ // T1000 spec says impl. dependent val must always be 1
+ setReg(miscReg, val | id);
+
case MISCREG_HTSTATE:
case MISCREG_STRAND_STS_REG:
setReg(miscReg, val);
break;
default:
- panic("Invalid write to FS misc register\n");
+ panic("Invalid write to FS misc register %s\n", getMiscRegName(miscReg));
}
}