Set bit 12 to 1 if trap
This commit is contained in:
parent
8432071f9f
commit
4b788bb620
4 changed files with 15 additions and 7 deletions
12
bus.cpp
12
bus.cpp
|
@ -318,6 +318,14 @@ void bus::setMMR0(int value)
|
||||||
MMR0 = value;
|
MMR0 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bus::setMMR0Bit(const int bit)
|
||||||
|
{
|
||||||
|
assert(bit != 10 && bit != 11);
|
||||||
|
assert(bit < 16 && bit >= 0);
|
||||||
|
|
||||||
|
MMR0 |= 1 << bit;
|
||||||
|
}
|
||||||
|
|
||||||
void bus::setMMR2(const uint16_t value)
|
void bus::setMMR2(const uint16_t value)
|
||||||
{
|
{
|
||||||
MMR2 = value;
|
MMR2 = value;
|
||||||
|
@ -350,8 +358,6 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
|
||||||
|
|
||||||
MMR0 |= 1 << 13; // read-only
|
MMR0 |= 1 << 13; // read-only
|
||||||
|
|
||||||
MMR0 |= 1 << 12; // trap
|
|
||||||
|
|
||||||
MMR0 &= ~(3 << 5);
|
MMR0 &= ~(3 << 5);
|
||||||
MMR0 |= run_mode << 5; // TODO: kernel-mode or user-mode when a trap occurs in user-mode?
|
MMR0 |= run_mode << 5; // TODO: kernel-mode or user-mode when a trap occurs in user-mode?
|
||||||
|
|
||||||
|
@ -367,8 +373,6 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
|
||||||
|
|
||||||
MMR0 |= 1 << 13; // read-only
|
MMR0 |= 1 << 13; // read-only
|
||||||
|
|
||||||
MMR0 |= 1 << 12; // trap
|
|
||||||
|
|
||||||
MMR0 &= ~(3 << 5);
|
MMR0 &= ~(3 << 5);
|
||||||
MMR0 |= run_mode << 5;
|
MMR0 |= run_mode << 5;
|
||||||
|
|
||||||
|
|
1
bus.h
1
bus.h
|
@ -84,6 +84,7 @@ public:
|
||||||
void clearMMR1();
|
void clearMMR1();
|
||||||
void addToMMR1(const int8_t delta, const uint8_t reg);
|
void addToMMR1(const int8_t delta, const uint8_t reg);
|
||||||
void setMMR0(int value);
|
void setMMR0(int value);
|
||||||
|
void setMMR0Bit(const int bit);
|
||||||
void setMMR2(const uint16_t value);
|
void setMMR2(const uint16_t value);
|
||||||
|
|
||||||
uint16_t get_switch_register() const { return switch_register; }
|
uint16_t get_switch_register() const { return switch_register; }
|
||||||
|
|
7
cpu.cpp
7
cpu.cpp
|
@ -280,7 +280,7 @@ bool cpu::check_queued_interrupts()
|
||||||
|
|
||||||
DOLOG(debug, true, "Invoking interrupt vector %o (IPL %d, current: %d)", v, i, current_level);
|
DOLOG(debug, true, "Invoking interrupt vector %o (IPL %d, current: %d)", v, i, current_level);
|
||||||
|
|
||||||
trap(v, i);
|
trap(v, i, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1647,7 +1647,7 @@ void cpu::schedule_trap(const uint16_t vector)
|
||||||
scheduled_trap = vector;
|
scheduled_trap = vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu::trap(const uint16_t vector, const int new_ipl)
|
void cpu::trap(const uint16_t vector, const int new_ipl, const bool is_interrupt)
|
||||||
{
|
{
|
||||||
uint16_t before_psw = getPSW();
|
uint16_t before_psw = getPSW();
|
||||||
uint16_t before_pc = getPC();
|
uint16_t before_pc = getPC();
|
||||||
|
@ -1661,6 +1661,9 @@ void cpu::trap(const uint16_t vector, const int new_ipl)
|
||||||
b->addToMMR1(-2, 6);
|
b->addToMMR1(-2, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_interrupt)
|
||||||
|
b->setMMR0Bit(12); // it's a trap
|
||||||
|
|
||||||
setPC(b->readWord(vector + 0));
|
setPC(b->readWord(vector + 0));
|
||||||
|
|
||||||
// switch to kernel mode & update 'previous mode'
|
// switch to kernel mode & update 'previous mode'
|
||||||
|
|
2
cpu.h
2
cpu.h
|
@ -96,7 +96,7 @@ public:
|
||||||
void queue_interrupt(const uint8_t level, const uint8_t vector);
|
void queue_interrupt(const uint8_t level, const uint8_t vector);
|
||||||
|
|
||||||
void busError();
|
void busError();
|
||||||
void trap(const uint16_t vector, const int new_ipl = -1);
|
void trap(const uint16_t vector, const int new_ipl = -1, const bool is_interrupt = false);
|
||||||
void schedule_trap(const uint16_t vector);
|
void schedule_trap(const uint16_t vector);
|
||||||
|
|
||||||
void setEmulateMFPT(const bool v) { emulateMFPT = v; }
|
void setEmulateMFPT(const bool v) { emulateMFPT = v; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue