From c45878feb32d589b7b40e06d0a6e8a2fbf8f4de2 Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Mon, 8 Feb 2016 17:08:06 -0500 Subject: [PATCH] B5500: Added macros to detect buffer empty to remove compiler warnings. b5500_mt.c: Changed checking of hwmark from -1 to 0xfffffff. --- B5500/b5500_mt.c | 85 +++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/B5500/b5500_mt.c b/B5500/b5500_mt.c index c43772ef..901f62cc 100644 --- a/B5500/b5500_mt.c +++ b/B5500/b5500_mt.c @@ -37,10 +37,10 @@ #include "b5500_defs.h" #include "sim_tape.h" -#if (NUM_DEVS_MT > 0) +#if (NUM_DEVS_MT > 0) #define BUFFSIZE 10240 -#define UNIT_MT UNIT_ATTABLE | UNIT_DISABLE | UNIT_ROABLE +#define UNIT_MT UNIT_ATTABLE | UNIT_DISABLE | UNIT_ROABLE #define HT 500 /* Time per char high density */ /* in u3 is device address */ @@ -76,6 +76,9 @@ #define MT_LOADED 0040000 /* Tape loaded, return ready */ +#define BUF_EMPTY(u) (u->hwmark == 0xFFFFFFFF) +#define CLR_BUF(u) u->hwmark = 0xFFFFFFFF + t_stat mt_srv(UNIT *); t_stat mt_attach(UNIT *, char *); t_stat mt_detach(UNIT *); @@ -128,7 +131,7 @@ MTAB mt_mod[] = { &sim_tape_set_fmt, &sim_tape_show_fmt, NULL, "Set/Display tape format (SIMH, E11, TPC, P7B)" }, {MTAB_XTD | MTAB_VUN, 0, "LENGTH", "LENGTH", - &sim_tape_set_capac, &sim_tape_show_capac, NULL, + &sim_tape_set_capac, &sim_tape_show_capac, NULL, "Set unit n capacity to arg MB (0 = unlimited)" }, {MTAB_XTD | MTAB_VUN, 0, "DENSITY", "DENSITY", NULL, &sim_tape_show_dens, NULL}, @@ -161,7 +164,7 @@ mt_cmd(uint16 cmd, uint16 dev, uint8 chan, uint16 *wc) uptr = &mt_unit[unit]; /* If unit disabled return error */ - if (uptr->flags & UNIT_DIS) + if (uptr->flags & UNIT_DIS) return SCPE_NODEV; if ((uptr->flags & UNIT_ATT) == 0) @@ -172,42 +175,42 @@ mt_cmd(uint16 cmd, uint16 dev, uint8 chan, uint16 *wc) return SCPE_UNATT; /* Check if drive is ready to recieve a command */ - if ((uptr->u5 & MT_BSY) != 0) + if ((uptr->u5 & MT_BSY) != 0) return SCPE_BUSY; /* Determine actual command */ uptr->u5 &= ~(MT_RDY|MT_CHAN|MT_CMD|MT_BIN); uptr->u5 |= chan; - if (cmd & URCSTA_BINARY) + if (cmd & URCSTA_BINARY) uptr->u5 |= MT_BIN; if (cmd & URCSTA_READ) { - if ((cmd & URCSTA_WC) && *wc == 0) + if ((cmd & URCSTA_WC) && *wc == 0) uptr->u5 |= MT_FSR; else uptr->u5 |= MT_RD; } else { /* Erase gap not supported on sim, treat as write of null record */ - if ((cmd & URCSTA_WC) && *wc == 0) + if ((cmd & URCSTA_WC) && *wc == 0) uptr->u5 |= MT_INT; else uptr->u5 |= MT_WR; } *wc = 0; /* So no overide occurs */ - + /* Convert command to correct type */ if (cmd & URCSTA_DIRECT) uptr->u5 |= MT_BACK; uptr->u6 = 0; - uptr->hwmark = -1; - sim_debug(DEBUG_CMD, &mt_dev, "Command %d %o %o\n\r", unit, uptr->u5, cmd); + CLR_BUF(uptr); + sim_debug(DEBUG_CMD, &mt_dev, "Command %d %o %o\n", unit, uptr->u5, cmd); if ((uptr->u5 & MT_IDLE) == 0) { sim_activate(uptr,50000); } return SCPE_OK; } - + /* Map simH errors into machine errors */ @@ -281,14 +284,14 @@ t_stat mt_srv(UNIT * uptr) if (uptr->u5 & MT_LOADED) { uptr->u5 &= ~MT_LOADED; uptr->u5 |= MT_BSY|MT_RDY; - sim_debug(DEBUG_DETAIL, dptr, "Unit=%d Loaded\n\r", unit); + sim_debug(DEBUG_DETAIL, dptr, "Unit=%d Loaded\n", unit); sim_activate(uptr, 50000); return SCPE_OK; } if (uptr->u5 & MT_BSY) { uptr->u5 &= ~MT_BSY; - sim_debug(DEBUG_DETAIL, dptr, "Unit=%d Online\n\r", unit); + sim_debug(DEBUG_DETAIL, dptr, "Unit=%d Online\n", unit); iostatus |= 1 << (uptr - mt_unit); if (uptr->u5 & MT_IDLE) sim_activate(uptr, 50000); @@ -298,10 +301,10 @@ t_stat mt_srv(UNIT * uptr) if (uptr->u5 & MT_IDLE) { uptr->u5 &= ~MT_IDLE; if (uptr->u5 & MT_RDY) { - sim_debug(DEBUG_DETAIL, dptr, "Unit=%d idling\n\r", unit); + sim_debug(DEBUG_DETAIL, dptr, "Unit=%d idling\n", unit); return SCPE_OK; } - sim_debug(DEBUG_DETAIL, dptr, "Unit=%d start %02o\n\r", unit, cmd); + sim_debug(DEBUG_DETAIL, dptr, "Unit=%d start %02o\n", unit, cmd); } switch (cmd) { @@ -312,12 +315,12 @@ t_stat mt_srv(UNIT * uptr) uptr->u5 &= ~(MT_CMD|MT_BIN); uptr->u5 |= MT_RDY; chan_set_end(chan); - sim_debug(DEBUG_DETAIL, dptr, "Status\n\r"); + sim_debug(DEBUG_DETAIL, dptr, "Status\n"); return SCPE_OK; case MT_RD: /* Read */ /* If at end of record, fill buffer */ - if (uptr->hwmark == -1) { + if (BUF_EMPTY(uptr)) { sim_debug(DEBUG_DETAIL, dptr, "Read unit=%d %s ", unit, (uptr->u5 & MT_BIN)? "bin": "bcd"); if (sim_tape_eot(uptr)) { @@ -327,12 +330,12 @@ t_stat mt_srv(UNIT * uptr) r = sim_tape_rdrecf(uptr, &mt_buffer[chan][0], &reclen, BUFFSIZE); if (r != MTSE_OK) { if (r == MTSE_TMK) { - sim_debug(DEBUG_DETAIL, dptr, "TM\n\r"); + sim_debug(DEBUG_DETAIL, dptr, "TM\n"); ch = 017; (void)chan_write_char(chan, &ch, 1); sim_activate(uptr, 4000); } else { - sim_debug(DEBUG_DETAIL, dptr, "r=%d\n\r", r); + sim_debug(DEBUG_DETAIL, dptr, "r=%d\n", r); sim_activate(uptr, 5000); } return mt_error(uptr, chan, r, dptr); @@ -340,7 +343,7 @@ t_stat mt_srv(UNIT * uptr) uptr->u5 &= ~(MT_BOT|MT_EOT); uptr->hwmark = reclen; } - sim_debug(DEBUG_DETAIL, dptr, "%d chars\n\r", uptr->hwmark); + sim_debug(DEBUG_DETAIL, dptr, "%d chars\n", uptr->hwmark); uptr->u6 = 0; if ((uptr->u5 & MT_BIN) == 0) mode = 0100; @@ -368,12 +371,12 @@ t_stat mt_srv(UNIT * uptr) if (chan_write_char(chan, &ch, (((uint32)uptr->u6) >= uptr->hwmark) ? 1 : 0)) { - sim_debug(DEBUG_DATA, dptr, "Read unit=%d %d EOR\n\r", unit, + sim_debug(DEBUG_DATA, dptr, "Read unit=%d %d EOR\n", unit, uptr->hwmark-uptr->u6); sim_activate(uptr, 4000); return mt_error(uptr, chan, MTSE_OK, dptr); } else { - sim_debug(DEBUG_DATA, dptr, "Read data unit=%d %d %03o\n\r", + sim_debug(DEBUG_DATA, dptr, "Read data unit=%d %d %03o\n", unit, uptr->u6, ch); sim_activate(uptr, HT); } @@ -381,7 +384,7 @@ t_stat mt_srv(UNIT * uptr) case MT_RDBK: /* Read Backword */ /* If at end of record, fill buffer */ - if (uptr->hwmark == -1) { + if (BUF_EMPTY(uptr)) { sim_debug(DEBUG_DETAIL, dptr, "Read back unit=%d %s ", unit, (uptr->u5 & MT_BIN)? "bin": "bcd"); if (sim_tape_bot(uptr)) { @@ -391,13 +394,13 @@ t_stat mt_srv(UNIT * uptr) r = sim_tape_rdrecr(uptr, &mt_buffer[chan][0], &reclen, BUFFSIZE); if (r != MTSE_OK) { if (r == MTSE_TMK) { - sim_debug(DEBUG_DETAIL, dptr, "TM\n\r"); + sim_debug(DEBUG_DETAIL, dptr, "TM\n"); ch = 017; (void)chan_write_char(chan, &ch, 1); sim_activate(uptr, 4000); } else { uptr->u5 |= MT_BSY; - sim_debug(DEBUG_DETAIL, dptr, "r=%d\n\r", r); + sim_debug(DEBUG_DETAIL, dptr, "r=%d\n", r); sim_activate(uptr, 100); } return mt_error(uptr, chan, r, dptr); @@ -405,7 +408,7 @@ t_stat mt_srv(UNIT * uptr) uptr->u5 &= ~(MT_BOT|MT_EOT); uptr->hwmark = reclen; } - sim_debug(DEBUG_DETAIL, dptr, "%d chars\n\r", uptr->hwmark); + sim_debug(DEBUG_DETAIL, dptr, "%d chars\n", uptr->hwmark); uptr->u6 = uptr->hwmark; if ((uptr->u5 & MT_BIN) == 0) mode = 0100; @@ -432,12 +435,12 @@ t_stat mt_srv(UNIT * uptr) } if (chan_write_char(chan, &ch, (uptr->u6 > 0) ? 0 : 1)) { - sim_debug(DEBUG_DATA, dptr, "Read back unit=%d %d EOR\n\r", + sim_debug(DEBUG_DATA, dptr, "Read back unit=%d %d EOR\n", unit, uptr->hwmark-uptr->u6); sim_activate(uptr, 100); return mt_error(uptr, chan, MTSE_OK, dptr); } else { - sim_debug(DEBUG_DATA, dptr, "Read back data unit=%d %d %03o\n\r", + sim_debug(DEBUG_DATA, dptr, "Read back data unit=%d %d %03o\n", unit, uptr->u6, ch); sim_activate(uptr, HT); } @@ -454,16 +457,16 @@ t_stat mt_srv(UNIT * uptr) reclen = uptr->u6; /* If no transfer, then either erase */ if (reclen == 0) { - sim_debug(DEBUG_DETAIL, dptr, "Erase\n\r"); + sim_debug(DEBUG_DETAIL, dptr, "Erase\n"); r = MTSE_OK; } else if ((reclen == 1) && (cmd & MT_BIN) == 0 && (mt_buffer[chan][0] == 017)) { /* Check if write rtape mark */ - sim_debug(DEBUG_DETAIL, dptr, "Write Mark unit=%d\n\r", unit); + sim_debug(DEBUG_DETAIL, dptr, "Write Mark unit=%d\n", unit); r = sim_tape_wrtmk(uptr); - } else { + } else { sim_debug(DEBUG_DETAIL, dptr, - "Write unit=%d Block %d %s chars\n\r", unit, reclen, + "Write unit=%d Block %d %s chars\n", unit, reclen, (uptr->u5 & MT_BIN)? "bin": "bcd"); r = sim_tape_wrrecf(uptr, &mt_buffer[chan][0], reclen); } @@ -479,7 +482,7 @@ t_stat mt_srv(UNIT * uptr) /* Don't write out even parity zeros */ if (ch != 0) mt_buffer[chan][uptr->u6++] = ch; - sim_debug(DEBUG_DATA, dptr, "Write data unit=%d %d %03o\n\r", + sim_debug(DEBUG_DATA, dptr, "Write data unit=%d %d %03o\n", unit, uptr->u6, ch); uptr->hwmark = uptr->u6; } @@ -487,12 +490,12 @@ t_stat mt_srv(UNIT * uptr) return SCPE_OK; case MT_FSR: /* Space forward one record */ - if (uptr->hwmark == -1) { + if (BUF_EMPTY(uptr)) { /* If at end of record, fill buffer */ sim_debug(DEBUG_DETAIL, dptr, "Space unit=%d ", unit); if (sim_tape_eot(uptr)) { uptr->u5 &= ~MT_BOT; - sim_debug(DEBUG_DETAIL, dptr, "EOT\r\n"); + sim_debug(DEBUG_DETAIL, dptr, "EOT\n"); sim_activate(uptr, 4000); return mt_error(uptr, chan, MTSE_EOM, dptr); } @@ -509,7 +512,7 @@ t_stat mt_srv(UNIT * uptr) } uptr->u5 &= ~(MT_BOT|MT_EOT); uptr->hwmark = reclen; - sim_debug(DEBUG_DETAIL, dptr, "%d chars\n\r", uptr->hwmark); + sim_debug(DEBUG_DETAIL, dptr, "%d chars\n", uptr->hwmark); sim_activate(uptr, uptr->hwmark * HT); return SCPE_OK; } @@ -517,11 +520,11 @@ t_stat mt_srv(UNIT * uptr) return mt_error(uptr, chan, MTSE_OK, dptr); case MT_BSR: /* Backspace record */ - if (uptr->hwmark == -1) { + if (BUF_EMPTY(uptr)) { /* If at end of record, fill buffer */ sim_debug(DEBUG_DETAIL, dptr, "backspace unit=%d ", unit); if (sim_tape_bot(uptr)) { - sim_debug(DEBUG_DETAIL, dptr, "BOT\n\r"); + sim_debug(DEBUG_DETAIL, dptr, "BOT\n"); sim_activate(uptr, 100); return mt_error(uptr, chan, MTSE_BOT, dptr); } @@ -538,7 +541,7 @@ t_stat mt_srv(UNIT * uptr) } uptr->u5 &= ~(MT_BOT|MT_EOT); uptr->hwmark = reclen; - sim_debug(DEBUG_DETAIL, dptr, "%d chars\n\r", uptr->hwmark); + sim_debug(DEBUG_DETAIL, dptr, "%d chars\n", uptr->hwmark); sim_activate(uptr, uptr->hwmark * HT); return SCPE_OK; } @@ -546,7 +549,7 @@ t_stat mt_srv(UNIT * uptr) return mt_error(uptr, chan, MTSE_OK, dptr); case MT_REW: /* Rewind */ - sim_debug(DEBUG_DETAIL, dptr, "Rewind unit=%d pos=%d\n\r", unit, + sim_debug(DEBUG_DETAIL, dptr, "Rewind unit=%d pos=%d\n", unit, uptr->pos); uptr->u5 &= ~(MT_CMD | MT_BIN | MT_IDLE | MT_RDY); uptr->u5 |= MT_BSY|MT_RDY;