1
0
mirror of https://github.com/prirun/p50em.git synced 2026-01-19 09:08:33 +00:00

Only use 28 bits of physical address in mapva to correct CPUT4

emulator seg fault after LPSW near label RXM in CPUT4.

CPUT4 activates Ring 3 by loading the ring bits of the program
counter.  However, it does not enable segmentation, so we're still
accessing memory by physical location - no address mapping occurs.
mapva used the entire 32-bit program counter as an offset in the MEM
array (physical memory), and because of the ring bits, this caused a
Unix seg fault.

mapva was changed to only use 28 bits of the address when VA mapping
is disabled (28 bits matches the size of the MEM array).  Technically,
a more accurate mask should be applied based on the CPU model.  For
example, a P750 could only access 8MB of memory.
This commit is contained in:
Jim 2011-08-06 09:01:16 -04:00
parent 8ad786dc42
commit 23b8cd9892

5
em.c
View File

@ -568,8 +568,9 @@ static jmp_buf bootjmp; /* for longjumps to the fetch loop */
speed up system boots and diagnostics during emulator testing.
*/
#define MAXMB 512
#define MAXMB 512 /* must be a power of 2 */
#define MEMSIZE MAXMB/2*1024*1024
#define MEMMASK MEMSIZE-1
#define MEM physmem
static unsigned short physmem[MEMSIZE]; /* system's physical memory */
@ -1034,7 +1035,7 @@ static pa_t mapva(ea_t ea, ea_t rp, short intacc, unsigned short *access) {
pa = stlbp->ppa | (ea & 0x3FF);
TRACE(T_MAP," for ea %o/%o, iacc=%d, stlbix=%d, pa=%o loaded at #%lu\n", ea>>16, ea&0xffff, intacc, stlbix, pa, stlbp->load_ic);
} else {
pa = ea;
pa = ea & MEMMASK;
}
stopwatch_pop(&sw_mapva);
#ifndef NOMEM