reworked page access control

This commit is contained in:
folkert van heusden 2024-04-13 02:10:40 +02:00
parent 3d4dbbc1c2
commit 3b2e65a8a7
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1

54
bus.cpp
View file

@ -588,26 +588,32 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
{ {
const int access_control = pages[run_mode][d][apf].pdr & 7; const int access_control = pages[run_mode][d][apf].pdr & 7;
bool do_trap = false; enum { T_PROCEED, T_ABORT_4, T_TRAP_250 } trap_action { T_PROCEED };
if (is_write && access_control != 6) // write if (access_control == 0)
do_trap = true; trap_action = T_ABORT_4;
else if (!is_write && (access_control == 0 || access_control == 1 || access_control == 3 || access_control == 4 || access_control == 7)) { // read else if (access_control == 1)
do_trap = true; trap_action = is_write ? T_ABORT_4 : T_TRAP_250;
} else if (access_control == 2) {
if (is_write)
if (do_trap) { trap_action = T_ABORT_4;
bool do_trap_250 = false; }
else if (access_control == 3)
if ((MMR0 & 0xf000) == 0) { trap_action = T_ABORT_4;
DOLOG(debug, false, "TRAP(0250) (throw 5) for access_control %d on address %06o, run mode %d", access_control, a, run_mode); else if (access_control == 4)
trap_action = T_TRAP_250;
do_trap_250 = true; else if (access_control == 5) {
} if (is_write)
else { trap_action = T_TRAP_250;
DOLOG(debug, false, "A.C.F. triggger for %d on address %06o, run mode %d", access_control, a, run_mode); }
else if (access_control == 6) {
// proceed
}
else if (access_control == 7) {
trap_action = T_ABORT_4;
} }
if (trap_action != T_PROCEED) {
if (is_write) if (is_write)
pages[run_mode][d][apf].pdr |= 1 << 7; pages[run_mode][d][apf].pdr |= 1 << 7;
@ -631,8 +637,17 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
DOLOG(debug, false, "MMR0: %06o", MMR0); DOLOG(debug, false, "MMR0: %06o", MMR0);
if (do_trap_250) { if (trap_action == T_TRAP_250) {
c->trap(0250); // invalid address DOLOG(debug, false, "Page access %d: trap 0250", access_control);
c->trap(0250); // trap
throw 5;
}
else { // T_ABORT_4
DOLOG(debug, false, "Page access %d: trap 004", access_control);
c->trap(004); // abort
throw 5; throw 5;
} }
@ -684,6 +699,7 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
MMR0 &= ~(3 << 5); MMR0 &= ~(3 << 5);
MMR0 |= run_mode << 5; MMR0 |= run_mode << 5;
MMR0 &= ~(1 << 4);
MMR0 |= d << 4; MMR0 |= d << 4;
} }