1
0
mirror of https://github.com/simh/simh.git synced 2026-03-08 03:39:54 +00:00

Merge remote-tracking branch 'github-simh/master' into KDP

This commit is contained in:
Mark Pizzolato
2013-06-02 16:50:03 -07:00
34 changed files with 1675 additions and 86 deletions

View File

@@ -1,6 +1,6 @@
/* pdp11_cpu.c: PDP-11 CPU simulator
Copyright (c) 1993-2012, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,7 @@
cpu PDP-11 CPU
10-Apr-13 RMS MMR1 does not track PC changes (Johnny Billquist)
29-Apr-12 RMS Fixed compiler warning (Mark Pizzolato)
19-Mar-12 RMS Fixed declaration of sim_switches (Mark Pizzolato)
29-Dec-08 RMS Fixed failure to clear cpu_bme on RESET (Walter Mueller)
@@ -689,7 +690,8 @@ if (abortval != 0) {
if ((trapea > 0) && stop_vecabort)
reason = STOP_VECABORT;
if ((trapea < 0) && /* stack push abort? */
(CPUT (STOP_STKA) || stop_spabort)) reason = STOP_SPABORT;
(CPUT (STOP_STKA) || stop_spabort))
reason = STOP_SPABORT;
if (trapea == ~MD_KER) { /* kernel stk abort? */
setTRAP (TRAP_RED);
setCPUERR (CPUE_RED);
@@ -715,7 +717,7 @@ while (reason == 0) {
cpu_astop = 0;
reason = SCPE_STOP;
break;
}
}
AIO_CHECK_EVENT;
if (sim_interval <= 0) { /* intv cnt expired? */
@@ -809,7 +811,7 @@ while (reason == 0) {
if (sim_brk_summ && sim_brk_test (PC, SWMASK ('E'))) { /* breakpoint? */
reason = STOP_IBKPT; /* stop simulation */
continue;
}
}
if (update_MM) { /* if mm not frozen */
MMR1 = 0;
@@ -907,7 +909,8 @@ while (reason == 0) {
trap_req = calc_ints (ipl, trap_req);
JMP_PC (src);
if (CPUT (HAS_RTT) && tbit && /* RTT impl? */
(IR == 000002)) setTRAP (TRAP_TRC); /* RTI immed trap */
(IR == 000002))
setTRAP (TRAP_TRC); /* RTI immed trap */
break;
case 7: /* MFPT */
if (CPUT (HAS_MFPT)) /* implemented? */
@@ -1352,7 +1355,8 @@ while (reason == 0) {
}
else {
dst = srcreg? R[srcspec]: ReadW (GeteaW (srcspec));
if (!dstreg) ea = GeteaW (dstspec);
if (!dstreg)
ea = GeteaW (dstspec);
}
N = GET_SIGN_W (dst);
Z = GET_Z (dst);
@@ -1888,6 +1892,7 @@ while (reason == 0) {
R[dstspec] = (R[dstspec] & 0177400) | dst;
else PWriteB (dst, last_pa);
break;
/* Notes:
- MTPS cannot alter the T bit
- MxPD must mask GeteaW returned address, dspace is from cm not pm
@@ -1981,7 +1986,8 @@ while (reason == 0) {
}
else {
dst = srcreg? R[srcspec] & 0377: ReadB (GeteaB (srcspec));
if (!dstreg) ea = GeteaB (dstspec);
if (!dstreg)
ea = GeteaB (dstspec);
}
N = GET_SIGN_B (dst);
Z = GET_Z (dst);
@@ -2161,20 +2167,20 @@ switch (spec >> 3) { /* decode spec<5:3> */
case 2: /* (R)+ */
R[reg] = ((adr = R[reg]) + 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 (020 | reg);
return (adr | ds);
case 3: /* @(R)+ */
R[reg] = ((adr = R[reg]) + 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 (020 | reg);
adr = ReadW (adr | ds);
return (adr | dsenable);
case 4: /* -(R) */
adr = R[reg] = (R[reg] - 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 (0360 | reg);
if ((reg == 6) && (cm == MD_KER) && (adr < (STKLIM + STKL_Y)))
set_stack_trap (adr);
@@ -2182,7 +2188,7 @@ switch (spec >> 3) { /* decode spec<5:3> */
case 5: /* @-(R) */
adr = R[reg] = (R[reg] - 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 (0360 | reg);
if ((reg == 6) && (cm == MD_KER) && (adr < (STKLIM + STKL_Y)))
set_stack_trap (adr);
@@ -2219,13 +2225,13 @@ switch (spec >> 3) { /* decode spec<5:3> */
case 2: /* (R)+ */
delta = 1 + (reg >= 6); /* 2 if R6, PC */
R[reg] = ((adr = R[reg]) + delta) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 ((delta << 3) | reg);
return (adr | ds);
case 3: /* @(R)+ */
R[reg] = ((adr = R[reg]) + 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 (020 | reg);
adr = ReadW (adr | ds);
return (adr | dsenable);
@@ -2233,7 +2239,7 @@ switch (spec >> 3) { /* decode spec<5:3> */
case 4: /* -(R) */
delta = 1 + (reg >= 6); /* 2 if R6, PC */
adr = R[reg] = (R[reg] - delta) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 ((((-delta) & 037) << 3) | reg);
if ((reg == 6) && (cm == MD_KER) && (adr < (STKLIM + STKL_Y)))
set_stack_trap (adr);
@@ -2241,7 +2247,7 @@ switch (spec >> 3) { /* decode spec<5:3> */
case 5: /* @-(R) */
adr = R[reg] = (R[reg] - 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = calc_MMR1 (0360 | reg);
if ((reg == 6) && (cm == MD_KER) && (adr < (STKLIM + STKL_Y)))
set_stack_trap (adr);

145
PDP11/pdp11_ddcmp.h Normal file
View File

@@ -0,0 +1,145 @@
/* pdp11_ddcmp.h: Digital Data Communications Message Protocol support
Copyright (c) 2013, Mark Pizzolato
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Robert M Supnik shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
Digital Data Communications Message Protocol - DDCMP support routines
29-May-13 MP Initial implementation
*/
#ifndef PDP11_DDCMP_H_
#define PDP11_DDCMP_H_ 0
/* DDCMP packet types */
#define DDCMP_SYN 0226u /* Sync character on synchronous links */
#define DDCMP_DEL 0377u /* Sync character on asynchronous links */
#define DDCMP_SOH 0201u /* Numbered Data Message Identifier */
#define DDCMP_ENQ 0005u /* Control Message Identifier */
#define DDCMP_DLE 0220u /* Maintenance Message Identifier */
/* Support routines */
/* crc16 polynomial x^16 + x^15 + x^2 + 1 (0xA001) CCITT LSB */
static uint16 crc16_nibble[16] = {
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400,
};
static uint16 ddcmp_crc16(uint16 crc, const void* vbuf, size_t len)
{
const unsigned char* buf = (const unsigned char*)vbuf;
while(0 != len--) {
crc = (crc>>4) ^ crc16_nibble[(*buf ^ crc) & 0xF];
crc = (crc>>4) ^ crc16_nibble[((*buf++)>>4 ^ crc) & 0xF];
};
return(crc);
}
/* Debug routines */
#include <ctype.h>
static void ddcmp_packet_trace (uint32 reason, DEVICE *dptr, const char *txt, const uint8 *msg, int32 len, t_bool detail)
{
if (sim_deb && dptr && (reason & dptr->dctrl)) {
sim_debug(reason, dptr, "%s len: %d\n", txt, len);
if (detail) {
int i, same, group, sidx, oidx;
char outbuf[80], strbuf[18];
static char hex[] = "0123456789ABCDEF";
switch (msg[0]) {
case DDCMP_SOH: /* Data Message */
sim_debug (reason, dptr, "Data Message, Link: %d, Count: %d, Resp: %d, Num: %d, HDRCRC: %s, DATACRC: %s\n", msg[2]>>6, ((msg[2] & 0x3F) << 8)|msg[1], msg[3], msg[4],
(0 == ddcmp_crc16 (0, msg, 8)) ? "OK" : "BAD", (0 == ddcmp_crc16 (0, msg+8, 2+(((msg[2] & 0x3F) << 8)|msg[1]))) ? "OK" : "BAD");
break;
case DDCMP_ENQ: /* Control Message */
sim_debug (reason, dptr, "Control: Type: %d ", msg[1]);
switch (msg[1]) {
case 1: /* ACK */
sim_debug (reason, dptr, "(ACK) ACKSUB: %d, Link: %d, Resp: %d\n", msg[2] & 0x3F, msg[2]>>6, msg[3]);
break;
case 2: /* NAK */
sim_debug (reason, dptr, "(NAK) Reason: %d, Link: %d, Resp: %d\n", msg[2] & 0x3F, msg[2]>>6, msg[3]);
break;
case 3: /* REP */
sim_debug (reason, dptr, "(REP) REPSUB: %d, Link: %d, Num: %d\n", msg[2] & 0x3F, msg[2]>>6, msg[4]);
break;
case 6: /* STRT */
sim_debug (reason, dptr, "(STRT) STRTSUB: %d, Link: %d\n", msg[2] & 0x3F, msg[2]>>6);
break;
case 7: /* STACK */
sim_debug (reason, dptr, "(STACK) STCKSUB: %d, Link: %d\n", msg[2] & 0x3F, msg[2]>>6);
break;
default: /* Unknown */
sim_debug (reason, dptr, "(Unknown=0%o)\n", msg[1]);
break;
}
if (len != 8) {
sim_debug (reason, dptr, "Unexpected Control Message Length: %d expected 8\n", len);
}
if (0 != ddcmp_crc16 (0, msg, len)) {
sim_debug (reason, dptr, "Unexpected Message CRC\n");
}
break;
case DDCMP_DLE: /* Maintenance Message */
sim_debug (reason, dptr, "Maintenance Message, Link: %d, Count: %d, HDRCRC: %s, DATACRC: %s\n", msg[2]>>6, ((msg[2] & 0x3F) << 8)| msg[1],
(0 == ddcmp_crc16 (0, msg, 8)) ? "OK" : "BAD", (0 == ddcmp_crc16 (0, msg+8, 2+(((msg[2] & 0x3F) << 8)| msg[1]))) ? "OK" : "BAD");
break;
}
for (i=same=0; i<len; i += 16) {
if ((i > 0) && (0 == memcmp(&msg[i], &msg[i-16], 16))) {
++same;
continue;
}
if (same > 0) {
sim_debug(reason, dptr, "%04X thru %04X same as above\n", i-(16*same), i-1);
same = 0;
}
group = (((len - i) > 16) ? 16 : (len - i));
for (sidx=oidx=0; sidx<group; ++sidx) {
outbuf[oidx++] = ' ';
outbuf[oidx++] = hex[(msg[i+sidx]>>4)&0xf];
outbuf[oidx++] = hex[msg[i+sidx]&0xf];
if (isprint(msg[i+sidx]))
strbuf[sidx] = msg[i+sidx];
else
strbuf[sidx] = '.';
}
outbuf[oidx] = '\0';
strbuf[sidx] = '\0';
sim_debug(reason, dptr, "%04X%-48s %s\n", i, outbuf, strbuf);
}
if (same > 0) {
sim_debug(reason, dptr, "%04X thru %04X same as above\n", i-(16*same), len-1);
}
}
}
}
uint16 ddcmp_crc16(uint16 crc, const void* vbuf, size_t len);
#endif /* PDP11_DDCMP_H_ */

View File

@@ -482,6 +482,7 @@ typedef struct {
#define VH_MUXES 4 /* max # of VH muxes */
#define DLX_LINES 16 /* max # of KL11/DL11's */
#define DCX_LINES 16 /* max # of DC11's */
#define DUP_LINES 8 /* max # of DUP11/DPV11's */
#define MT_MAXFR (1 << 16) /* magtape max rec */
#define AUTO_LNT 34 /* autoconfig ranks */
#define DIB_MAX 100 /* max DIBs */
@@ -601,6 +602,8 @@ typedef struct pdp_dib DIB;
#define INT_V_DMCTX 19
#define INT_V_KMCA 20
#define INT_V_KMCB 21
#define INT_V_DUPRX 20
#define INT_V_DUPTX 21
#define INT_V_PIR4 0 /* BR4 */
#define INT_V_TTI 1
@@ -648,6 +651,8 @@ typedef struct pdp_dib DIB;
#define INT_DMCTX (1u << INT_V_DMCTX)
#define INT_KMCA (1u << INT_V_KMCA)
#define INT_KMCB (1u << INT_V_KMCB)
#define INT_DUPRX (1u << INT_V_DUPRX)
#define INT_DUPTX (1u << INT_V_DUPTX)
#define INT_PIR4 (1u << INT_V_PIR4)
#define INT_TTI (1u << INT_V_TTI)
#define INT_TTO (1u << INT_V_TTO)
@@ -698,6 +703,8 @@ typedef struct pdp_dib DIB;
#define IPL_DMCTX 5
#define IPL_KMCA 5
#define IPL_KMCB 5
#define IPL_DUPRX 5
#define IPL_DUPTX 5
#define IPL_PTR 4
#define IPL_PTP 4
#define IPL_TTI 4

1174
PDP11/pdp11_dup.c Normal file

File diff suppressed because it is too large Load Diff

50
PDP11/pdp11_dup.h Normal file
View File

@@ -0,0 +1,50 @@
/* pdp11_dup.h: PDP-11 DUP11 bit synchronous shared device packet interface interface
Copyright (c) 2013, Mark Pizzolato
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Robert M Supnik shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
dup DUP11 Unibus/DPV11 Qbus bit synchronous interface
This module describes the interfaces exposed by the dup device for use by
a packet delivery devices (i.e. KMC11).
31-May-13 MP Initial implementation
*/
#ifndef PDP11_DUP_H_
#define PDP11_DUP_H_ 0
typedef void (*PACKET_RECEIVE_CALLBACK)(int32 dup, uint8 *buf, size_t len);
typedef void (*PACKET_TRANSMIT_COMPLETE_CALLBACK)(int32 dup, int status);
int32 dup_get_line_speed (int32 dup);
int32 dup_get_DCD (int32 dup);
t_stat dup_set_DTR (int32 dup, t_bool state);
t_stat dup_set_DDCMP (int32 dup, t_bool state);
int32 dup_csr_to_linenum (int32 CSRPA);
void dup_set_callback_mode (int32 dup, PACKET_RECEIVE_CALLBACK receive, PACKET_TRANSMIT_COMPLETE_CALLBACK transmit);
t_bool dup_put_msg_bytes (int32 dup, uint8 *bytes, size_t len, t_bool start, t_bool end);
#endif /* PDP11_DUP_H_ */

View File

@@ -1,6 +1,6 @@
/* pdp11_fp.c: PDP-11 floating point simulator (32b version)
Copyright (c) 1993-2008, Robert M Supnik
Copyright (c) 1993-2013, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,7 @@
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
20-Apr-13 RMS MMR1 does not track PC changes (Johnny Billquist)
22-Sep-05 RMS Fixed declarations (Sterling Garwood)
04-Oct-04 RMS Added FIS instructions
19-Jan-03 RMS Changed mode definitions for Apple Dev Kit conflict
@@ -584,20 +585,20 @@ switch (spec >> 3) { /* case on spec */
if (reg == 7)
len = 2;
R[reg] = ((adr = R[reg]) + len) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = (len << 3) | reg;
return (adr | ds);
case 3: /* @(R)+ */
R[reg] = ((adr = R[reg]) + 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = 020 | reg;
adr = ReadW (adr | ds);
return (adr | dsenable);
case 4: /* -(R) */
adr = R[reg] = (R[reg] - len) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = (((-len) & 037) << 3) | reg;
if ((reg == 6) && (cm == MD_KER) && (adr < (STKLIM + STKL_Y)))
set_stack_trap (adr);
@@ -605,7 +606,7 @@ switch (spec >> 3) { /* case on spec */
case 5: /* @-(R) */
adr = R[reg] = (R[reg] - 2) & 0177777;
if (update_MM)
if (update_MM && (reg != 7))
MMR1 = 0360 | reg;
if ((reg == 6) && (cm == MD_KER) && (adr < (STKLIM + STKL_Y)))
set_stack_trap (adr);

View File

@@ -440,7 +440,7 @@ AUTO_CON auto_tab[] = {/*c #v am vm fxa fxv */
{ { NULL }, 1, 2, 0, 8,
{012400} }, /* KW11W */
{ { NULL }, 1, 2, 8, 8 }, /* DU11 */
{ { "DUP0", "DUP1" },1, 2, 8, 8 }, /* DUP11 */
{ { "DUP" }, 1, 2, 8, 8 }, /* DUP11 */
{ { NULL }, 1, 3, 0, 8,
{015000, 015040, 015100, 015140, }}, /* DV11 */
{ { NULL }, 1, 2, 8, 8 }, /* LK11A */
@@ -468,7 +468,7 @@ AUTO_CON auto_tab[] = {/*c #v am vm fxa fxv */
{ { NULL }, 1, 1, 8, 4,
{012410, 012410}, {0124} }, /* DR11B - fx CSRs,vec */
{ { "DMP" }, 1, 2, 8, 8 }, /* DMP11 */
{ { NULL }, 1, 2, 8, 8 }, /* DPV11 */
{ { "DPV" }, 1, 2, 8, 8 }, /* DPV11 */
{ { NULL }, 1, 2, 8, 8 }, /* ISB11 */
{ { NULL }, 1, 2, 16, 8 }, /* DMV11 */
{ { "XU", "XUB" }, 1, 1, 8, 4,

View File

@@ -103,8 +103,9 @@ extern DEVICE xu_dev, xub_dev;
extern DEVICE ke_dev;
extern DEVICE kg_dev;
extern DEVICE dmc_dev[];
extern DEVICE dup_dev;
extern DEVICE dpv_dev;
extern DEVICE kmc_dev;
extern DEVICE dup_dev[];
extern UNIT cpu_unit;
extern REG cpu_reg[];
extern uint16 *M;
@@ -169,13 +170,13 @@ DEVICE *sim_devices[] = {
&xub_dev,
&ke_dev,
&kg_dev,
&dmc_dev[0],
&dmc_dev[1],
&dmc_dev[2],
&dmc_dev[3],
&dmc_dev[0],
&dmc_dev[1],
&dmc_dev[2],
&dmc_dev[3],
&kmc_dev,
&dup_dev[0],
&dup_dev[1],
&dup_dev,
&dpv_dev,
NULL
};