1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-04-12 07:05:28 +00:00

KA10: Fixed issues with Tops 20 V5-V7 with DLUSER.

This commit is contained in:
Richard Cornwell
2019-12-05 23:16:37 -05:00
parent 4d79f225a8
commit 79bf7cff9d
3 changed files with 139 additions and 75 deletions

View File

@@ -301,6 +301,7 @@ typedef struct {
uint32 flags;
uint64 mb;
uint64 fmb;
uint16 prev_sect;
} InstHistory;
int32 hst_p = 0; /* history pointer */
@@ -2325,11 +2326,11 @@ int page_lookup(t_addr addr, int flag, t_addr *loc, int wr, int cur_context, int
uf = (FLAGS & USERIO) != 0;
pub = (FLAGS & PRV_PUB) != 0;
#if KLB
// if (QKLB && glb_sect && (((xct_flag & 014) == 04 && !BYF5 && !ptr_flg) ||
// ((xct_flag & 03) == 01 && BYF5)))
// sect = prev_sect;
// if (QKLB && (!glb_sect || (((xct_flag & 014) == 04 && !BYF5 && !ptr_flg) ||
// ((xct_flag & 03) == 01 && BYF5))) && !extend)
// sect = prev_sect;
if (QKLB && (!glb_sect /*|| ((xct_flag & 4) != 0 && prev_sect == 0)*/) && !extend)
sect = prev_sect;
sect = prev_sect;
//fprintf(stderr, " ps=%o os%o", prev_sect, sect);
#endif
}
@@ -2541,6 +2542,7 @@ int Mem_read(int flag, int cur_context, int fetch) {
if (!page_lookup(AB, flag, &addr, 0, cur_context, fetch))
return 1;
if (addr >= (int)MEMSIZE) {
//fprintf(stderr, "NXM error r %08o\n\r", addr);
irq_flags |= 02000;
return 1;
}
@@ -2588,6 +2590,7 @@ int Mem_write(int flag, int cur_context) {
if (!page_lookup(AB, flag, &addr, 1, cur_context, 0))
return 1;
if (addr >= (int)MEMSIZE) {
//fprintf(stderr, "NXM error w %08o\n\r", addr);
irq_flags |= 02000;
return 1;
}
@@ -3933,6 +3936,7 @@ int Mem_read_nopage() {
MB = get_reg(AB);
} else {
if (AB >= (int)MEMSIZE) {
//fprintf(stderr, "NXM non-page error r %08o\n\r", AB);
#if KL
irq_flags |= 02000;
#else
@@ -3956,6 +3960,7 @@ int Mem_write_nopage() {
set_reg(AB, MB);
} else {
if (AB >= (int)MEMSIZE) {
//fprintf(stderr, "NXM non-page error w %08o\n\r", AB);
#if KL
irq_flags |= 02000;
#else
@@ -4103,9 +4108,11 @@ fetch:
}
#endif
if (Mem_read(pi_cycle | uuo_cycle, 1, 1)) {
#if !KL
pi_rq = check_irq_level();
if (pi_rq)
goto st_pi;
#endif
#if KL
if (((fault_data >> 30) & 037) == 021)
PC = (PC + 1) & RMASK;
@@ -4149,9 +4156,13 @@ no_fetch:
#if KL && KLB
/* If we are doing a PXCT with E1 or E2 set, change section */
if (QKLB && t20_page) {
if (((xct_flag & 8) != 0 && (FLAGS & USER) == 0 && !ptr_flg) ||
((xct_flag & 2) != 0 && (FLAGS & USER) == 0 && ptr_flg))
sect = cur_sect = prev_sect;
if (xct_flag != 0 && (FLAGS & USER) == 0) {
if (((xct_flag & 8) != 0 && !ptr_flg) ||
((xct_flag & 2) != 0 && ptr_flg) ||
((xct_flag & 014) == 04 && !BYF5/* && !ptr_flg*/) ||
((xct_flag & 03) == 01 && BYF5))
sect = cur_sect = prev_sect;
}
/* Short cut for extended pointer address */
if (ptr_flg && (glb_sect || cur_sect != 0) && (AR & BIT12) != 0) { /* Full pointer */
ind = 1; /* Allow us to read word, xDB has already bumped AB */
@@ -4377,6 +4388,9 @@ st_pi:
#endif
;
#if KL && KLB
hst[hst_p].prev_sect = prev_sect;
#endif
hst[hst_p].ac = get_reg(AC);
}
@@ -4484,11 +4498,18 @@ unasign:
/* Save Opcode */
#if KL & KLB
if (QKLB && t20_page) {
AR = (((uint64)cur_sect) << 18) | (uint64)AB; /* Save address */
AR = (uint64)AB; /* Save address */
if (pc_sect != 0) {
if (glb_sect == 0 && AB < 020)
AR |= BIT17;
else
AR |= ((uint64)cur_sect) << 18;
}
MB = (((uint64)((IR << 9) | (AC << 5))) | ((uint64)(FLAGS) << 23)) & FMASK;
if ((FLAGS & USER) == 0) {
MB &= ~SMASK;
MB |= (FLAGS & PRV_PUB) ? SMASK : 0;
MB |= (uint64)(prev_sect);
}
} else
#endif
@@ -4535,14 +4556,14 @@ unasign:
#endif
/* Save context */
AB ++;
MB = SMASK|
MB = SMASK|BIT2|
((uint64)(fm_sel & 0160) << 23) |
((uint64)(prev_ctx & 0160) << 20) |
(ub_ptr >> 9);
#if KLB
if (QKLB && t20_page /*&& (FLAGS & USER) == 0*/)
MB |= BIT1|((uint64)(prev_sect & 037) << 18);
if (QKLB && t20_page && (FLAGS & USER) != 0)
if (QKLB && t20_page /* && (FLAGS & USER) != 0*/)
prev_sect = pc_sect;
#endif
Mem_write_nopage();
@@ -4569,13 +4590,16 @@ unasign:
if ((FLAGS & USER) == 0) {
if ((AB & 4) != 0)
FLAGS |= USERIO;
#if KL
if ((AB & 2))
FLAGS |= PRV_PUB;
#else
//#if KL
// if ((AB & 2))
// FLAGS |= PRV_PUB;
//#if KLB
// if ((!QKLB || !t20_page) && (FLAGS & OVR) != 0)
// FLAGS |= PRV_PUB;
//#else
if ((AB & 2 || (FLAGS & OVR) != 0))
FLAGS |= PRV_PUB|OVR;
#endif
//#endif
}
PC = MB & RMASK;
f_pc_inh = 1;
@@ -7280,7 +7304,7 @@ xjrstf:
#if KLB
if (QKLB && t20_page) {
pc_sect = (AR >> 18) & 07777;
if ((FLAGS & USER) == 0 && ((BR >> 23) & USER) == 0)
if (AC != 07 && (FLAGS & USER) == 0 && ((BR >> 23) & USER) == 0)
prev_sect = BR & 037;
}
#endif
@@ -7340,15 +7364,15 @@ jrstf:
case 007: /* XPCW */
//fprintf(stderr, "XPCW %06o %06o %06o %06o\r\n", pc_sect, AB, PC, FLAGS << 5);
MB = ((((uint64)FLAGS) << 23)
#if KLB
| (prev_sect & 037)
#endif
) & FMASK;
MB = (((uint64)FLAGS) << 23) & FMASK;
/* Save Previous Public context */
if ((FLAGS & USER) == 0) {
MB &= ~SMASK;
MB |= (FLAGS & PRV_PUB) ? SMASK : 0;
#if KLB
if (QKLB && t20_page)
MB |= (uint64)(prev_sect & 037);
#endif
}
if (uuo_cycle | pi_cycle) {
FLAGS &= ~(USER|PUBLIC); /* Clear USER */
@@ -7382,14 +7406,14 @@ jrstf:
break;
case 014: /* SFM */
#if KLB
MB = ((((uint64)FLAGS) << 23) | (uint64)(prev_sect & 037)) & FMASK;
#else
MB = (((uint64)FLAGS) << 23) & FMASK;
#endif
if ((FLAGS & USER) == 0) {
MB &= ~SMASK;
MB |= (FLAGS & PRV_PUB) ? SMASK : 0;
#if KLB
if (QKLB && t20_page)
MB |= (uint64)(prev_sect & 037);
#endif
}
(void)Mem_write(0, 0);
goto last;
@@ -7715,6 +7739,8 @@ jrstf:
}
#endif
AB = AR & RMASK;
if (hst_lnt)
hst[hst_p].mb = MB;
if (Mem_write(uuo_cycle | pi_cycle, 0))
goto last;
#if !PDP6
@@ -7769,6 +7795,8 @@ jrstf:
#if KLB
}
#endif
if (hst_lnt)
hst[hst_p].mb = MB;
if (Mem_write(0, 0))
goto last;
break;
@@ -7794,6 +7822,8 @@ jrstf:
AB = AR & RMASK;
if (Mem_read(0, 0, 0))
goto last;
if (hst_lnt)
hst[hst_p].mb = MB;
AB = BR & RMASK;
#if KL
BYF5 = 0; /* Now back to data */
@@ -7848,6 +7878,8 @@ jrstf:
if (Mem_read(0, 0, 0))
goto last;
if (hst_lnt)
hst[hst_p].mb = MB;
#if ITS | KL_ITS
if (QITS && (FLAGS & USER)) {
jpc = PC;
@@ -8686,10 +8718,6 @@ last:
/* Handle page fault and traps */
if (page_enable && page_fault) {
page_fault = 0;
if (pi_cycle) {
pi_cycle = 0;
set_pi_hold(); /* Hold off all lower interrupts */
}
//fprintf(stderr, "Page fault %06o %012llo %06o\n\r", PC, fault_data, FLAGS << 5);
BYF5 = 0;
#if KL_ITS
@@ -8706,9 +8734,16 @@ last:
MB = fault_data;
Mem_write_nopage();
AB++;
/* If fault on trap, kill the pi_cycle flag */
if (trap_flag)
pi_cycle = 0;
FLAGS |= trap_flag & (TRP1|TRP2);
trap_flag = (TRP1|TRP2);
MB = (((uint64)(FLAGS) << 23) & LMASK);
if ((FLAGS & USER) == 0) {
MB &= ~SMASK;
MB |= (FLAGS & PRV_PUB) ? SMASK : 0;
}
#if KLB
if (QKLB && t20_page) {
if ((FLAGS & USER) == 0)
@@ -8716,10 +8751,6 @@ last:
} else
#endif
MB |= (PC & RMASK);
if ((FLAGS & USER) == 0) {
MB &= ~SMASK;
MB |= (FLAGS & PRV_PUB) ? SMASK : 0;
}
Mem_write_nopage();
AB++;
#if KLB
@@ -8742,10 +8773,12 @@ last:
#endif
FLAGS = (MB >> 23) & 017777;
/* If transistioning from user to executive adjust flags */
if ((FLAGS & USER) == 0 && flag1)
FLAGS |= USERIO;
if ((FLAGS & USER) == 0 && flag3)
FLAGS |= PRV_PUB;
if ((FLAGS & USER) == 0) {
if (flag1)
FLAGS |= USERIO;
if (flag3)
FLAGS |= PRV_PUB;
}
PC = MB & RMASK;
#if KLB
if (QKLB && t20_page)
@@ -8754,11 +8787,29 @@ last:
xct_flag = 0;
f_load_pc = 1;
f_pc_inh = 1;
if (pi_cycle) {
//fprintf(stderr, "Page fault trap %06o\n\r", PC);
pi_cycle = 0;
irq_flags |= 01000;
FM[(7 << 4) | 2] = fault_data;
pi_enable = 0;
// pi_rq = check_irq_level();
// goto st_pi;
}
// if (pi_cycle) {
// pi_cycle = 0;
// set_pi_hold(); /* Hold off all lower interrupts */
// pi_restore = 1; /* Release the pending IRQ */
// }
}
#endif
#if KI
/* Handle page fault and traps */
if (page_enable && page_fault) {
if (pi_cycle) {
//fprintf(stderr, "Page fault trap %06o\n\r", PC);
inout_fail = 1;
}
page_fault = 0;
AB = ub_ptr + ((FLAGS & USER) ? 0427 : 0426);
MB = fault_data;
@@ -8793,27 +8844,12 @@ last:
/* Dismiss an interrupt */
if (pi_cycle) {
#if KI | KL
if (page_enable && page_fault) {
page_fault = 0;
//fprintf(stderr, "Page fault trap %06o\n\r", PC);
pi_cycle = 0;
#if KI
inout_fail = 1;
#else
irq_flags |= 01000;
FM[(7 << 4) | 2] = fault_data;
#endif
check_apr_irq();
pi_rq = check_irq_level();
goto st_pi;
}
if (trap_flag != 0) {
pi_hold = pi_ov = 0;
f_pc_inh = 0;
trap_flag = 0;
}
#endif
if ((IR & 0700) == 0700 && ((AC & 04) == 0)) {
pi_hold = pi_ov;
if ((!pi_hold) & f_inst_fetch) {
@@ -10569,6 +10605,9 @@ for (k = 0; k < lnt; k++) { /* print specified */
fputs (" ", st);
#if KI | KL
fprintf (st, "%c%06o ", ((h->flags & (PRV_PUB << 5))? 'p':' '), h->flags & 0777777);
#if KLB
fprintf (st, "%02o ", h->prev_sect);
#endif
#else
fprintf (st, "%06o ", h->flags);
#endif

View File

@@ -539,23 +539,25 @@ void rh_writecw(struct rh_if *rhc, int nxm) {
if (wc != 0 || (rhc->status & RH20_XEND) == 0 ||
(rhc->ptcr & BIT10) != 0 || nxm) {
uint64 wrd1 = SMASK|(uint64)(rhc->ccw);
if ((rhc->ptcr & BIT10) == 0 && (rhc->status & RH20_DR_EXC) != 0)
if ((rhc->ptcr & BIT10) == 0 || (rhc->status & RH20_DR_EXC) != 0)
return;
if (nxm) {
wrd1 |= RH20_NXM_ERR;
rhc->status |= RH20_CHAN_ERR;
}
if (wc != 0) {
wrd1 |= RH20_NOT_WC0;
if (rhc->status & RH20_XEND) {
wrd1 |= RH20_LONG_STS;
if ((rhc->ptcr & 070) == 060) /* Write command */
rhc->status |= RH20_CHAN_ERR|RH20_LONG_WC;
}
wrd1 |= RH20_NOT_WC0;
if (rhc->status & RH20_XEND) {
wrd1 |= RH20_LONG_STS;
if ((rhc->ptcr & 070) == 060) { /* Write command */
rhc->status |= RH20_LONG_WC|RH20_CHAN_ERR;
}
}
} else if ((rhc->status & RH20_XEND) == 0) {
wrd1 |= RH20_SHRT_STS;
if ((rhc->ptcr & 070) == 060) /* Write command */
rhc->status |= RH20_SHRT_WC|RH20_CHAN_ERR;
wrd1 |= RH20_SHRT_STS;
if ((rhc->ptcr & 070) == 060) { /* Write command */
rhc->status |= RH20_SHRT_WC|RH20_CHAN_ERR;
}
}
/* No error and not storing */
if ((rhc->status & RH20_CHAN_ERR) == 0 && (rhc->ptcr & BIT10) == 0)
@@ -588,7 +590,8 @@ void rh_finish_op(struct rh_if *rhc, int nxm) {
rh_setirq(rhc);
#if KL
if (rhc->imode == 2 &&
(rhc->status & (RH20_SCR_FULL|RH20_PCR_FULL)) == (RH20_SCR_FULL))
(rhc->status & (RH20_SCR_FULL|RH20_PCR_FULL)) == (RH20_SCR_FULL) &&
(rhc->status & (RH20_DR_EXC|RH20_CHAN_ERR)) == 0)
rh20_setup(rhc);
#endif
}

View File

@@ -277,19 +277,30 @@ tu_write(DEVICE *dptr, struct rh_if *rhc, int reg, uint32 data) {
case FNC_READ: /* read */
case FNC_READREV: /* read w/ headers */
tu_frame[ctlr] = 0;
tu_tcr[ctlr] |= TC_FCS;
/* Fall through */
case FNC_WRITE: /* write */
case FNC_SPACEF: /* Space forward */
case FNC_SPACEB: /* Space backward */
if ((tu_tcr[ctlr] & TC_FCS) == 0) {
uptr->STATUS |= ER1_NEF;
break;
}
/* Fall through */
case FNC_ERASE: /* Erase gap */
case FNC_WRITE: /* write */
case FNC_WTM: /* Write tape mark */
case FNC_SPACEF: /* Space forward */
case FNC_SPACEB: /* Space backward */
case FNC_WCHK: /* write check */
case FNC_REWIND: /* rewind */
case FNC_UNLOAD: /* unload */
case FNC_WCHKREV: /* write w/ headers */
uptr->CMD |= CS_PIP|CS1_GO;
uptr->CMD &= ~CS_TM;
rhc->attn = 0;
for (i = 0; i < 8; i++) {
if (dptr->units[i].CMD & CS_ATA)
rhc->attn = 1;
}
CLR_BUF(uptr);
uptr->DATAPTR = 0;
sim_activate(uptr, 100);
@@ -333,6 +344,7 @@ tu_write(DEVICE *dptr, struct rh_if *rhc, int reg, uint32 data) {
break;
case 005: /* frame count */
tu_frame[ctlr] = data & 0177777;
tu_tcr[ctlr] |= TC_FCS;
break;
case 006: /* drive type */
case 007: /* look ahead */
@@ -368,12 +380,12 @@ tu_read(DEVICE *dptr, struct rh_if *rhc, int reg) {
break;
case 001: /* status */
temp = DS_DPR;
if (rhc->attn != 0)
if (uptr->CMD & CS_ATA)
temp |= DS_ATA;
if (uptr->CMD & CS_CHANGE)
temp |= DS_SSC;
if ((uptr->STATUS & 0177777) != 0)
temp |= DS_ERR|DS_ATA;
temp |= DS_ERR;
if ((uptr->flags & UNIT_ATT) != 0) {
temp |= DS_MOL;
if (uptr->CMD & CS_TM)
@@ -471,7 +483,7 @@ void tu_error(UNIT * uptr, t_stat r)
}
if (uptr->CMD & CS_ATA)
rh_setattn(rhc, 0);
if (uptr->CMD & (CS_ATA | CS_TM))
if (GET_FNC(uptr->CMD) >= FNC_XFER && uptr->CMD & (CS_ATA | CS_TM))
rh_error(rhc);
uptr->CMD &= ~(CS_MOTION|CS_PIP|CS1_GO);
sim_debug(DEBUG_EXP, dptr, "Setting status %d\n", r);
@@ -589,6 +601,8 @@ t_stat tu_srv(UNIT * uptr)
if ((r = sim_tape_rdrecf(uptr, &tu_buf[ctlr][0], &reclen,
TU_NUMFR)) != MTSE_OK) {
sim_debug(DEBUG_DETAIL, dptr, "%s%o read error %d\n", dptr->name, unit, r);
if (r == MTSE_TMK)
uptr->STATUS |= ER1_FCE;
tu_error(uptr, r);
rh_finish_op(rhc, 0);
} else {
@@ -620,16 +634,18 @@ t_stat tu_srv(UNIT * uptr)
rh_finish_op(rhc, 0);
return SCPE_OK;
}
sim_debug(DEBUG_DATA, dptr, "%s%o read %012llo\n",
dptr->name, unit, rhc->buf);
sim_debug(DEBUG_DATA, dptr, "%s%o read %012llo %d\n",
dptr->name, unit, rhc->buf, uptr->DATAPTR);
rhc->buf = 0;
}
} else {
if (uptr->CPOS != 0) {
sim_debug(DEBUG_DATA, dptr, "%s%o read %012llo\n",
sim_debug(DEBUG_DATA, dptr, "%s%o readf %012llo\n",
dptr->name, unit, rhc->buf);
rh_write(rhc);
}
if (tu_frame[ctlr] != 0)
uptr->STATUS |= ER1_FCE;
tu_error(uptr, MTSE_OK);
(void)rh_blkend(rhc);
rh_finish_op(rhc, 0);
@@ -681,8 +697,10 @@ t_stat tu_srv(UNIT * uptr)
uptr->CPOS &= 010;
}
tu_frame[ctlr] = 0177777 & (tu_frame[ctlr] + 1);
if (tu_frame[ctlr] == 0)
if (tu_frame[ctlr] == 0) {
uptr->CPOS = 010;
tu_tcr[ctlr] &= ~(TC_FCS);
}
}
if (uptr->CPOS == 010) {
/* Write out the block */
@@ -750,6 +768,8 @@ t_stat tu_srv(UNIT * uptr)
case MTSE_EOM: /* end of medium */
if (tu_frame[ctlr] != 0)
uptr->STATUS |= ER1_FCE;
else
tu_tcr[ctlr] &= ~(TC_FCS);
uptr->CMD |= CS_ATA;
/* Stop motion if we recieve any of these */
tu_error(uptr, r);
@@ -759,8 +779,10 @@ t_stat tu_srv(UNIT * uptr)
uptr->CMD |= CS_ATA;
tu_error(uptr, MTSE_OK);
return SCPE_OK;
} else
} else {
tu_tcr[ctlr] &= ~(TC_FCS);
sim_activate(uptr, reclen * 50);
}
return SCPE_OK;
}
sim_activate(uptr, 50);