1
0
mirror of https://github.com/prirun/p50em.git synced 2026-03-06 02:38:57 +00:00

BS rvec, memory accesses; order of RPH/RPL is byte-order dependent,

fix bug in get32 when -DFAST isn't used
This commit is contained in:
Jim
2011-10-17 22:14:55 -04:00
parent 7b150eed02
commit fa097d21fc
5 changed files with 34 additions and 18 deletions

15
em.c
View File

@@ -610,10 +610,10 @@ static jmp_buf bootjmp; /* for longjumps to the fetch loop */
static unsigned short physmem[MEMSIZE]; /* system's physical memory */
#define get16mem(phyaddr) MEM[(phyaddr)]
#define put16mem(phyaddr, val) MEM[(phyaddr)] = (val)
#define get32mem(phyaddr) *(unsigned int *)(MEM+phyaddr)
#define put32mem(phyaddr, val) *(unsigned int *)(MEM+phyaddr) = (val)
#define get16mem(phyaddr) swap16(MEM[(phyaddr)])
#define put16mem(phyaddr, val) MEM[(phyaddr)] = swap16((val))
#define get32mem(phyaddr) swap32(*(unsigned int *)(MEM+phyaddr))
#define put32mem(phyaddr, val) *(unsigned int *)(MEM+phyaddr) = swap32((val))
#define MAKEVA(seg,word) ((((int)(seg))<<16) | (word))
@@ -1282,6 +1282,7 @@ static unsigned int get32m(ea_t ea) {
static inline unsigned int get32(ea_t ea) {
pa_t pa;
unsigned short access;
#ifdef DBG
if (ea & 0x80000000) {
@@ -4830,10 +4831,12 @@ main (int argc, char **argv) {
perror("Error opening boot file");
fatal(NULL);
}
if (read(bootfd, rvec, 18) != 18) { //BS
if (read(bootfd, rvec, 18) != 18) {
perror("Error reading boot file's rvec header");
fatal(NULL);
}
for (i=0; i<9; i++)
rvec[i] = swap16(rvec[i]);
} else {
@@ -4929,7 +4932,7 @@ a filename, CPU registers and keys are loaded from the runfile header.\n\
/* read memory image from SA to EA inclusive */
nw = rvec[1]-rvec[0]+1;
if ((nw2=read(bootfd, MEM+rvec[0], nw*2)) == -1) { //BS
if ((nw2=read(bootfd, MEM+rvec[0], nw*2)) == -1) {
perror("Error reading memory image");
fatal(NULL);
}

View File

@@ -1789,8 +1789,10 @@ int devdisk (int class, int func, int device) {
dc[dx].state = S_HALT;
dc[dx].status = 0100000;
dc[dx].usel = -1;
#ifdef HOBBY
if (geomcksum != geomhash((char *)geom, sizeof(geom)))
RP=MAKEVA(01000,0);
#endif
for (u=0; u<MAXDRIVES; u++) {
dc[dx].unit[u].rtfd = -1;
dc[dx].unit[u].heads = -1;

2
geom.h
View File

@@ -62,6 +62,4 @@
24, "1G", 31, 254, 65, /* MODEL_4734 */
25, "2G", 31, 254, 122, /* MODEL_4736 */
};
static int geomcksum = -622216695;
#endif

View File

@@ -20,12 +20,12 @@ debug: # gdb
trace: # tracing + gdb
cc -arch ppc -DREV=\"${REV}\" -DNOREGS -g -O0 -DFAST -c em.c -fobey-inline -mdynamic-no-pic -I../dongle/mx/ppc/api;g++ -arch ppc -o em em.o ../dongle/mx/ppc/api/libmxmac260.a -framework IOKit -framework CoreFoundation
cc -arch ppc -DREV=\"${REV}\" -DNOREGS -g -O0 -DNOFAST -c em.c -fobey-inline -mdynamic-no-pic -I../dongle/mx/ppc/api;g++ -arch ppc -o em em.o ../dongle/mx/ppc/api/libmxmac260.a -framework IOKit -framework CoreFoundation
tracei: # tracing + gdb (Intel)
cc -arch i386 -DREV=\"${REV}\" -DNOREGS -g -O0 -DFAST -c em.c -fobey-inline -mdynamic-no-pic -I../dongle/mx/Universal/api;g++ -arch i386 -o em em.o ../dongle/mx/Universal/api/libmxmac260.a -framework IOKit -framework CoreFoundation
cc -arch i386 -DREV=\"${REV}\" -DNOREGS -g -O0 -DNOFAST -c em.c -fobey-inline -mdynamic-no-pic -I../dongle/mx/Universal/api;g++ -arch i386 -o em em.o ../dongle/mx/Universal/api/libmxmac260.a -framework IOKit -framework CoreFoundation
vfy: # prod + tracing to verify em changes

29
regs.h
View File

@@ -189,16 +189,17 @@ static union {
static unsigned int grp; /* global RP for restore after longjmp */
register union {
struct {
#ifdef __BIG_ENDIAN__
unsigned short rph;
unsigned short rpl;
#else
unsigned short rpl;
unsigned short rph;
#endif
} s;
unsigned int ul;
} rpreg asm ("r29");
#define RP rpreg.ul
#define RPH rpreg.s.rph
#define RPL rpreg.s.rpl
static unsigned int *gcrsl; /* global crs pointer for restore after longjmp */
register union {
short *i16;
@@ -211,11 +212,19 @@ register union {
#else
/* the live program counter register is aka microcode scratch register TR7 */
union {
struct {
#ifdef __BIG_ENDIAN__
unsigned short rph;
unsigned short rpl;
#else
unsigned short rpl;
unsigned short rph;
#endif
} s;
unsigned int ul;
} rpreg;
#define RP regs.sym.tr7
#define RPH regs.u16[14]
#define RPL regs.u16[15]
#define grp RP /* turns grp assignments into dummies */
#define gcrsl crsl /* turns gcrsl assignments into dummies */
@@ -232,6 +241,10 @@ static union {
#define crs cr.u16
#define crsl cr.u32
#define RP rpreg.ul
#define RPH rpreg.s.rph
#define RPL rpreg.s.rpl
/************ 16-bit offset macros: *************/
/* fetch 16-bit unsigned at 16-bit offset */