mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-26 03:29:40 +00:00
Start trying to return preauthorisation testability.
This commit is contained in:
@@ -150,6 +150,8 @@ template <InstructionSet::x86::Model model, typename Enable = void> struct Linea
|
||||
|
||||
template <InstructionSet::x86::Model model>
|
||||
struct LinearMemory<model, std::enable_if_t<model <= InstructionSet::x86::Model::i80186>>: public SplitHolder, public LinearPool<1 << 20> {
|
||||
static constexpr bool RequiresPreauthorisation = false;
|
||||
|
||||
template <typename IntT, AccessType type>
|
||||
typename InstructionSet::x86::Accessor<IntT, type>::type access(
|
||||
uint32_t address,
|
||||
@@ -227,6 +229,8 @@ struct LinearMemory<model, std::enable_if_t<model <= InstructionSet::x86::Model:
|
||||
|
||||
template <>
|
||||
struct LinearMemory<InstructionSet::x86::Model::i80286>: public LinearPool<1 << 24> {
|
||||
static constexpr bool RequiresPreauthorisation = true;
|
||||
|
||||
LinearMemory() {
|
||||
set_a20_enabled(true);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
namespace PCCompatible {
|
||||
|
||||
// TODO: the following need to apply linear memory semantics, including potential A20 wrapping.
|
||||
template <InstructionSet::x86::Model model, typename LinearMemoryT> struct ProgramFetcher {
|
||||
std::pair<const uint8_t *, size_t> next_code(
|
||||
const InstructionSet::x86::Registers<model> ®isters,
|
||||
@@ -47,7 +46,6 @@ template <InstructionSet::x86::Model model, typename LinearMemoryT> struct Progr
|
||||
std::min<size_t>(0x1'0000, 1 + descriptor.bounds().end - base)
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <InstructionSet::x86::Model model, typename LinearMemoryT> class SegmentedMemory;
|
||||
@@ -68,7 +66,7 @@ public:
|
||||
registers_(registers), segments_(segments), linear_memory_(linear_memory) {}
|
||||
|
||||
//
|
||||
// Preauthorisation call-ins. Since only an 8088 is currently modelled, all accesses are implicitly authorised.
|
||||
// Preauthorisation call-ins.
|
||||
//
|
||||
void preauthorise_stack_write(uint32_t) {}
|
||||
void preauthorise_stack_read(uint32_t) {}
|
||||
@@ -145,6 +143,7 @@ public:
|
||||
uint16_t(registers_.sp())
|
||||
);
|
||||
}
|
||||
|
||||
void preauthorise_stack_read(const uint32_t size) {
|
||||
const auto &descriptor = segments_.descriptors[InstructionSet::x86::Source::SS];
|
||||
descriptor.template authorise<InstructionSet::x86::AccessType::Read, uint16_t>(
|
||||
@@ -154,7 +153,6 @@ public:
|
||||
}
|
||||
|
||||
void preauthorise_read(InstructionSet::x86::Source, uint16_t, uint32_t) {}
|
||||
|
||||
void preauthorise_write(InstructionSet::x86::Source, uint16_t, uint32_t) {}
|
||||
|
||||
// TODO: perform authorisation checks.
|
||||
|
||||
@@ -141,11 +141,11 @@ private:
|
||||
std::unordered_set<uint32_t> preauthorisations;
|
||||
std::unordered_map<uint32_t, Tag> tags;
|
||||
|
||||
void preauthorise(uint32_t address) {
|
||||
void preauthorise(const uint32_t address) {
|
||||
preauthorisations.insert(address);
|
||||
}
|
||||
bool test_preauthorisation(uint32_t address) {
|
||||
auto authorisation = preauthorisations.find(address);
|
||||
bool test_preauthorisation(const uint32_t address) {
|
||||
const auto authorisation = preauthorisations.find(address);
|
||||
if(authorisation == preauthorisations.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user