From 8c0439feaa976c6a4cec11b024dddd694c71edb9 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 24 Jun 2018 03:21:22 -0700 Subject: [PATCH] PDP11, VAX: Fix RQ and TQ Get Unit Status to properly report no more units As reported in #592 --- PDP11/pdp11_rq.c | 6 +++++- PDP11/pdp11_tq.c | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/PDP11/pdp11_rq.c b/PDP11/pdp11_rq.c index 4ffc22f3..c8bb0c6c 100644 --- a/PDP11/pdp11_rq.c +++ b/PDP11/pdp11_rq.c @@ -813,6 +813,7 @@ typedef struct { struct uq_ring cq; /* cmd ring */ struct uq_ring rq; /* rsp ring */ struct rqpkt pak[RQ_NPKTS]; /* packet queue */ + uint16 max_plug; /* highest unit plug number */ } MSC; /* debugging bitmaps */ @@ -1798,7 +1799,7 @@ UNIT *uptr; sim_debug (DBG_TRC, rq_devmap[cp->cnum], "rq_gus\n"); if (cp->pak[pkt].d[CMD_MOD] & MD_NXU) { /* next unit? */ - if (lu == 65535) { /* end of range? */ + if (lu > cp->max_plug) { /* beyond last unit plug? */ lu = 0; /* reset to 0 */ cp->pak[pkt].d[RSP_UN] = lu; } @@ -3006,6 +3007,9 @@ for (i = 0; i < (RQ_NUMDR + 2); i++) { /* init units */ if (uptr->rqxb == NULL) return SCPE_MEM; } +for (i=cp->max_plug=0; iunits[i].unit_plug > cp->max_plug) + cp->max_plug = (uint16)dptr->units[i].unit_plug; return auto_config (0, 0); /* run autoconfig */ } diff --git a/PDP11/pdp11_tq.c b/PDP11/pdp11_tq.c index 9a17f9c2..3bfbddb0 100644 --- a/PDP11/pdp11_tq.c +++ b/PDP11/pdp11_tq.c @@ -256,8 +256,9 @@ uint32 tq_pip = 0; /* poll in progress */ struct uq_ring tq_cq = { 0 }; /* cmd ring */ struct uq_ring tq_rq = { 0 }; /* rsp ring */ struct tqpkt tq_pkt[TQ_NPKTS]; /* packet queue */ -uint16 tq_freq = 0; /* free list */ -uint16 tq_rspq = 0; /* resp list */ +uint16 tq_freq = 0; /* free list */ +uint16 tq_rspq = 0; /* resp list */ +uint16 tq_max_plug; /* highest unit plug number */ uint32 tq_pbsy = 0; /* #busy pkts */ uint32 tq_credits = 0; /* credits */ uint32 tq_hat = 0; /* host timer */ @@ -1019,7 +1020,7 @@ UNIT *uptr; sim_debug(DBG_TRC, &tq_dev, "tq_gus\n"); if (tq_pkt[pkt].d[CMD_MOD] & MD_NXU) { /* next unit? */ - if (lu == 65535) { /* end of range? */ + if (lu > tq_max_plug) { /* beyond last unit plug? */ lu = 0; /* reset to 0 */ tq_pkt[pkt].d[RSP_UN] = (uint16)lu; } @@ -2068,6 +2069,9 @@ int32 i, j; UNIT *uptr; static t_bool plugs_inited = FALSE; +for (i=tq_max_plug=0; iunits[i].unit_plug > tq_max_plug) + tq_max_plug = (uint16)dptr->units[i].unit_plug; if (!plugs_inited ) { uint32 d; char uname[16];