mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-26 19:17:52 +00:00
Fully transfer faulting logic.
This commit is contained in:
@@ -583,12 +583,6 @@ template <
|
||||
context.memory.template write_back<IntT>();
|
||||
}
|
||||
|
||||
//
|
||||
// Public function; just a trampoline into a version of perform templated on data and address size.
|
||||
//
|
||||
// Which, yes, means there's an outer switch leading to an inner switch, which could be reduced to one big switch.
|
||||
// It'd be a substantial effort to find the most neat expression of that, I think, so it is not currently done.
|
||||
//
|
||||
template <
|
||||
InstructionType type,
|
||||
typename ContextT
|
||||
@@ -653,7 +647,40 @@ void perform(
|
||||
|
||||
// This is reachable only if the data and address size combination in use isn't available
|
||||
// on the processor model nominated.
|
||||
assert(false);
|
||||
assert(false);}
|
||||
|
||||
//
|
||||
// Public function; just indirects into a trampoline into a version of perform templated on data and address size.
|
||||
//
|
||||
// Which, yes, means there's an outer switch leading to an inner switch, which could be reduced to one big switch.
|
||||
// It'd be a substantial effort to find the most neat expression of that, I think, so it is not currently done.
|
||||
//
|
||||
template <
|
||||
InstructionType type,
|
||||
typename ContextT
|
||||
>
|
||||
requires is_context<ContextT>
|
||||
void perform(
|
||||
const Instruction<type> &instruction,
|
||||
ContextT &context,
|
||||
uint32_t source_ip
|
||||
) {
|
||||
if constexpr (uses_8086_exceptions(ContextT::model)) {
|
||||
InstructionSet::x86::perform(
|
||||
instruction,
|
||||
context
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
InstructionSet::x86::perform(
|
||||
instruction,
|
||||
context
|
||||
);
|
||||
return;
|
||||
} catch (const InstructionSet::x86::Exception exception) {
|
||||
fault(exception, context, source_ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
|
||||
@@ -258,7 +258,7 @@ template <
|
||||
typename ContextT
|
||||
>
|
||||
requires is_context<ContextT>
|
||||
void perform(const Instruction<type> &, ContextT &);
|
||||
void perform(const Instruction<type> &, ContextT &, uint32_t source_ip);
|
||||
|
||||
/// Performs an Exception, which includes those generated by external sources.
|
||||
/// @c source_ip is unused if the exception is an instance of `Exception::interrupt` but is required for other internal faults.
|
||||
|
||||
@@ -833,22 +833,11 @@ public:
|
||||
}
|
||||
|
||||
// Execute it.
|
||||
if constexpr (uses_8086_exceptions(x86_model)) {
|
||||
InstructionSet::x86::perform(
|
||||
decoded_.second,
|
||||
context_
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
InstructionSet::x86::perform(
|
||||
decoded_.second,
|
||||
context_
|
||||
);
|
||||
return;
|
||||
} catch (const InstructionSet::x86::Exception exception) {
|
||||
InstructionSet::x86::fault(exception, context_, decoded_ip_);
|
||||
}
|
||||
}
|
||||
InstructionSet::x86::perform(
|
||||
decoded_.second,
|
||||
context_,
|
||||
decoded_ip_
|
||||
);
|
||||
}
|
||||
|
||||
// MARK: - ScanProducer.
|
||||
|
||||
Reference in New Issue
Block a user