From 663391fff7fe10b26408e15e240514f76c6ddecb Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 28 Apr 2024 12:32:19 -0700 Subject: [PATCH] transplant https://github.com/gdwnldsKSC/es40/commit/dad191fb2f279164122654aba6da53acc1040d97 --- src/cpu_defs.hpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/cpu_defs.hpp b/src/cpu_defs.hpp index b7b96e1..d37aea2 100644 --- a/src/cpu_defs.hpp +++ b/src/cpu_defs.hpp @@ -424,15 +424,32 @@ inline u64 fsqrt64(u64 asig, s32 exp) { #define ALIGN_PHYS(a) (phys_address & ~((u64)((a)-1))) +/* Increase memory access page alignment checking to 8KB instead of + 4KB, 8KB minimum on AXP. Potentially should be dynamic in future, + resolves OpenVMS installation problems. Source: + https://www.openvmshobbyist.com/forum/viewthread.php?forum_id=161&thread_id=2801 + + https://github.com/gdwnldsKSC/es40/commit/dad191fb2f279164122654aba6da53acc1040d97 +*/ + #define DATA_PHYS(addr, flags, align) \ if ((addr) & (align)) { \ u64 a1 = (addr); \ u64 a2 = (addr) + (align); \ - if ((a1 ^ a2) & ~U64(0x1fff)) /*page boundary crossed*/ \ - pbc = true; \ + if ((a1 ^ a2) & ~U64(0x1fff)) /* 8K page boundary crossed*/ \ + { \ + state.fault_va = addr; \ + state.exc_sum = ((REG_1 &0x1f) << 8); \ + state.mm_stat = (I_GETOP(ins) << 4) | ((flags & ACCESS_WRITE) ? 1 : 0); \ + printf("unaligned addess %d, %d -> trap! ",flags,align); \ + printf("exc_sum = 0x%04" PRId64 "x, fault_va = 0x%016" PRId64 \ + "x, mm_stat = 0x%03" PRId64 "x.\n",state.exc_sum, state.fault_va, \ + state.mm_stat); \ + GO_PAL(UNALIGN); \ + return; \ + } \ } \ - if (virt2phys(addr, &phys_address, flags, NULL, ins)) \ - return; + DATA_PHYS_NT(addr, flags) // use the define above instead of duplicating /** * Normal variant of read action