From 6f4e718fdaa6ff1702b02c03946941fbcc442899 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 3 Nov 2013 13:08:17 -0800 Subject: [PATCH] PDP8: Refinement to prior fix for issue #86. Avoid data loss if prior character hasn't been read yet when a poll event happens. --- PDP8/pdp8_tt.c | 2 ++ PDP8/pdp8_ttx.c | 24 ++++++++++++++++++++++-- sim_console.c | 2 ++ sim_tmxr.c | 1 + sim_tmxr.h | 10 ++++++---- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/PDP8/pdp8_tt.c b/PDP8/pdp8_tt.c index 729f81f6..a22d7ab1 100644 --- a/PDP8/pdp8_tt.c +++ b/PDP8/pdp8_tt.c @@ -179,6 +179,8 @@ t_stat tti_svc (UNIT *uptr) int32 c; sim_clock_coschedule (uptr, tmxr_poll); /* continue poll */ +if (dev_done & INT_TTI) /* prior character still pending? */ + return SCPE_OK; if ((c = sim_poll_kbd ()) < SCPE_KFLAG) /* no char or error? */ return c; if (c & SCPE_BREAK) /* break? */ diff --git a/PDP8/pdp8_ttx.c b/PDP8/pdp8_ttx.c index 198c28ff..b967a821 100644 --- a/PDP8/pdp8_ttx.c +++ b/PDP8/pdp8_ttx.c @@ -119,12 +119,29 @@ MTAB ttix_mod[] = { { 0 } }; +/* debugging bitmaps */ +#define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ +#define DBG_RCV TMXR_DBG_RCV /* display Received Data */ +#define DBG_RET TMXR_DBG_RET /* display Returned Received Data */ +#define DBG_CON TMXR_DBG_CON /* display connection activities */ +#define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */ + +DEBTAB ttx_debug[] = { + {"XMT", DBG_XMT}, + {"RCV", DBG_RCV}, + {"RET", DBG_RET}, + {"CON", DBG_CON}, + {"TRC", DBG_TRC}, + {0} +}; + DEVICE ttix_dev = { "TTIX", &ttix_unit, ttix_reg, ttix_mod, 1, 10, 31, 1, 8, 8, &tmxr_ex, &tmxr_dep, &ttix_reset, NULL, &ttx_attach, &ttx_detach, - &ttix_dib, DEV_MUX | DEV_DISABLE, + &ttix_dib, DEV_MUX | DEV_DISABLE | DEV_DEBUG, + 0, ttx_debug }; /* TTOx data structures @@ -170,7 +187,8 @@ DEVICE ttox_dev = { 4, 10, 31, 1, 8, 8, NULL, NULL, &ttox_reset, NULL, NULL, NULL, - NULL, DEV_DISABLE + NULL, DEV_DISABLE | DEV_DEBUG, + 0, ttx_debug }; /* Terminal input: IOT routine */ @@ -236,6 +254,8 @@ if (ln >= 0) /* got one? rcv enb*/ tmxr_poll_rx (&ttx_desc); /* poll for input */ for (ln = 0; ln < TTX_LINES; ln++) { /* loop thru lines */ if (ttx_ldsc[ln].conn) { /* connected? */ + if (dev_done & (INT_TTI1 << ln)) /* Last character still pending? */ + continue; if ((temp = tmxr_getc_ln (&ttx_ldsc[ln]))) { /* get char */ if (temp & SCPE_BREAK) /* break? */ c = 0; diff --git a/sim_console.c b/sim_console.c index 3e204ad3..8d222a99 100644 --- a/sim_console.c +++ b/sim_console.c @@ -162,12 +162,14 @@ UNIT sim_con_unit = { UDATA (&sim_con_poll_svc, 0, 0) }; /* console connectio #define DBG_TRC TMXR_DBG_TRC /* trace routine calls */ #define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ #define DBG_RCV TMXR_DBG_RCV /* display Received Data */ +#define DBG_RET TMXR_DBG_RET /* display Returned Received Data */ #define DBG_ASY TMXR_DBG_ASY /* asynchronous thread activity */ static DEBTAB sim_con_debug[] = { {"TRC", DBG_TRC}, {"XMT", DBG_XMT}, {"RCV", DBG_RCV}, + {"RET", DBG_RET}, {"ASY", DBG_ASY}, {0} }; diff --git a/sim_tmxr.c b/sim_tmxr.c index e7474e73..691bc0e5 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -1317,6 +1317,7 @@ if (lp->conn && lp->rcve) { /* conn & enb? */ } /* end if conn */ if (lp->rxbpi == lp->rxbpr) /* empty? zero ptrs */ lp->rxbpi = lp->rxbpr = 0; +tmxr_debug_return(lp, val); return val; } diff --git a/sim_tmxr.h b/sim_tmxr.h index 03a536d5..e498513d 100644 --- a/sim_tmxr.h +++ b/sim_tmxr.h @@ -68,10 +68,11 @@ typedef int SERHANDLE; #define TMXR_DBG_XMT 0x010000 /* Debug Transmit Data */ #define TMXR_DBG_RCV 0x020000 /* Debug Received Data */ -#define TMXR_DBG_MDM 0x040000 /* Debug Modem Signals */ -#define TMXR_DBG_CON 0x080000 /* Debug Connection Activities */ -#define TMXR_DBG_ASY 0x100000 /* Debug Asynchronous Activities */ -#define TMXR_DBG_TRC 0x200000 /* Debug trace routine calls */ +#define TMXR_DBG_RET 0x040000 /* Debug Returned Received Data */ +#define TMXR_DBG_MDM 0x080000 /* Debug Modem Signals */ +#define TMXR_DBG_CON 0x100000 /* Debug Connection Activities */ +#define TMXR_DBG_ASY 0x200000 /* Debug Asynchronous Activities */ +#define TMXR_DBG_TRC 0x400000 /* Debug trace routine calls */ /* Modem Control Bits */ @@ -203,6 +204,7 @@ t_stat tmxr_stop_poll (void); void _tmxr_debug (uint32 dbits, TMLN *lp, const char *msg, char *buf, int bufsize); extern FILE *sim_deb; /* debug file */ #define tmxr_debug(dbits, lp, msg, buf, bufsize) if (sim_deb && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) _tmxr_debug (dbits, lp, msg, buf, bufsize); else (void)0 +#define tmxr_debug_return(lp, val) if (sim_deb && (val) && (lp)->mp->dptr && (TMXR_DBG_RET & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_RET, (lp)->mp->dptr, "Ln%d: 0x%x\n", (int)((lp)-(lp)->mp->ldsc), val); else (void)0 #define tmxr_debug_trace(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_TRC & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, mp->dptr, "%s\n", (msg)); else (void)0 #define tmxr_debug_trace_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_TRC & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, (lp)->mp->dptr, "Ln%d:%s\n", (int)((lp)-(lp)->mp->ldsc), (msg)); else (void)0 #define tmxr_debug_connect(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_CON & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_CON, mp->dptr, "%s\n", (msg)); else (void)0