mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-27 00:30:26 +00:00
Factor out would-accept-interrupt test, per uncertainty re: level 7.
This commit is contained in:
parent
6fcaf3571e
commit
02b6ea6c46
@ -53,7 +53,7 @@ void Executor<model, BusHandler>::signal_bus_error(FunctionCode code, uint32_t a
|
||||
template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::set_interrupt_level(int level) {
|
||||
state_.interrupt_input_ = level;
|
||||
state_.stopped &= state_.interrupt_input_ <= state_.status.interrupt_level;
|
||||
state_.stopped &= !state_.status.would_accept_interrupt(level);
|
||||
}
|
||||
|
||||
template <Model model, typename BusHandler>
|
||||
@ -324,7 +324,7 @@ template <Model model, typename BusHandler>
|
||||
void Executor<model, BusHandler>::State::run(int &count) {
|
||||
while(count--) {
|
||||
// Check for a new interrupt.
|
||||
if(interrupt_input > status.interrupt_level) {
|
||||
if(status.would_accept_interrupt(interrupt_input)) {
|
||||
const int vector = bus_handler_.acknowlege_interrupt(interrupt_input);
|
||||
if(vector >= 0) {
|
||||
raise_exception<false>(vector);
|
||||
|
@ -113,7 +113,7 @@ struct Status {
|
||||
}
|
||||
|
||||
/// Evaluates @c condition.
|
||||
bool evaluate_condition(Condition condition) {
|
||||
constexpr bool evaluate_condition(Condition condition) const {
|
||||
switch(condition) {
|
||||
default:
|
||||
case Condition::True: return true;
|
||||
@ -138,6 +138,13 @@ struct Status {
|
||||
return !zero_result || (negative_flag && !overflow_flag) || (!negative_flag && overflow_flag);
|
||||
}
|
||||
}
|
||||
|
||||
/// @returns @c true if an interrupt at level @c level should be accepted; @c false otherwise.
|
||||
constexpr bool would_accept_interrupt(int level) const {
|
||||
// TODO: is level seven really non-maskable? If so then what mechanism prevents
|
||||
// rapid stack overflow upon a level-seven interrupt?
|
||||
return level > interrupt_level;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
||||
BeginState(STOP):
|
||||
IdleBus(1);
|
||||
captured_interrupt_level_ = bus_interrupt_level_;
|
||||
if(captured_interrupt_level_ > status_.interrupt_level) {
|
||||
if(status_.would_accept_interrupt(captured_interrupt_level_)) {
|
||||
MoveToStateSpecific(DoInterrupt);
|
||||
}
|
||||
MoveToStateSpecific(STOP);
|
||||
@ -596,7 +596,7 @@ void Processor<BusHandler, dtack_is_implicit, permit_overrun, signal_will_perfor
|
||||
ReloadInstructionAddress();
|
||||
|
||||
// Head off into an interrupt if one is found.
|
||||
if(captured_interrupt_level_ > status_.interrupt_level) {
|
||||
if(status_.would_accept_interrupt(captured_interrupt_level_)) {
|
||||
MoveToStateSpecific(DoInterrupt);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user