diff --git a/I7000/i7000_cdp.c b/I7000/i7000_cdp.c index e471cce..e7f1f8b 100644 --- a/I7000/i7000_cdp.c +++ b/I7000/i7000_cdp.c @@ -189,6 +189,8 @@ t_stat cdp_srv(UNIT *uptr) { int chan = UNIT_G_CHAN(uptr->flags); int u = (uptr - cdp_unit); + uint16 *image = (uint16 *)(uptr->up7); + /* Waiting for disconnect */ if (uptr->u5 & URCSTA_WDISCO) { if (chan_stat(chan, DEV_DISCO)) { @@ -209,9 +211,9 @@ cdp_srv(UNIT *uptr) { if (uptr->u5 & URCSTA_FULL) { #ifdef STACK_DEV switch(sim_punch_card(uptr, - &stack_unit[(u * 10) + ((uptr->u5 >> 16) & 0xf)])) { + &stack_unit[(u * 10) + ((uptr->u5 >> 16) & 0xf)], image)) { #else - switch(sim_punch_card(uptr, NULL)) { + switch(sim_punch_card(uptr, NULL, image)) { #endif case SCPE_EOF: case SCPE_UNATT: @@ -240,11 +242,8 @@ cdp_srv(UNIT *uptr) { /* Copy next column over */ if (uptr->u5 & URCSTA_WRITE && uptr->u4 < 80) { - struct _card_data *data; uint8 ch = 0; - data = (struct _card_data *)uptr->up7; - switch(chan_read_char(chan, &ch, 0)) { case TIME_ERROR: case END_RECORD: @@ -257,7 +256,7 @@ cdp_srv(UNIT *uptr) { else if (ch == 020) ch = 0; sim_debug(DEBUG_DATA, &cdp_dev, "%d: Char < %02o\n", u, ch); - data->image[uptr->u4++] = sim_bcd_to_hol(ch); + image[uptr->u4++] = sim_bcd_to_hol(ch); if (uptr->u4 == 80) { chan_set(chan, DEV_REOR); uptr->u5 |= URCSTA_WDISCO|URCSTA_BUSY|URCSTA_FULL; @@ -278,24 +277,32 @@ cdp_ini(UNIT *uptr, t_bool f) { t_stat cdp_attach(UNIT * uptr, CONST char *file) { - t_stat r; + t_stat r; if ((r = sim_card_attach(uptr, file)) != SCPE_OK) return r; - uptr->u5 = 0; + if (uptr->up7 == 0) { + uptr->up7 = calloc(80, sizeof(uint16)); + uptr->u5 = 0; + } return SCPE_OK; } t_stat cdp_detach(UNIT * uptr) { + uint16 *image = (uint16 *)(uptr->up7); + if (uptr->u5 & URCSTA_FULL) #ifdef STACK_DEV sim_punch_card(uptr, &stack_unit[ - ((uptr - cdp_unit) * 10) + ((uptr->u5 >> 16) & 0xf)]); + ((uptr - cdp_unit) * 10) + ((uptr->u5 >> 16) & 0xf)], image); #else - sim_punch_card(uptr, NULL); + sim_punch_card(uptr, NULL, image); #endif + if (uptr->up7 == 0) + free(uptr->up7); + uptr->up7 = 0; return sim_card_detach(uptr); } diff --git a/I7000/i7000_cdr.c b/I7000/i7000_cdr.c index 17063a9..ba61c8f 100644 --- a/I7000/i7000_cdr.c +++ b/I7000/i7000_cdr.c @@ -34,8 +34,7 @@ #include "sim_defs.h" #ifdef NUM_DEVS_CDR -#define UNIT_CDR UNIT_ATTABLE | UNIT_RO | UNIT_DISABLE | \ - UNIT_ROABLE | MODE_026 +#define UNIT_CDR UNIT_ATTABLE | UNIT_RO | UNIT_DISABLE | MODE_026 /* Flags for punch and reader. */ #define ATTENA (1 << (UNIT_V_UF+7)) @@ -91,7 +90,7 @@ MTAB cdr_mod[] = { DEVICE cdr_dev = { "CDR", cdr_unit, NULL, cdr_mod, NUM_DEVS_CDR, 8, 15, 1, 8, 8, - NULL, NULL, NULL, &cdr_boot, &cdr_attach, &sim_card_detach, + NULL, NULL, NULL, &cdr_boot, &cdr_attach, &cdr_detach, &cdr_dib, DEV_DISABLE | DEV_DEBUG, 0, crd_debug, NULL, NULL, &cdr_help, NULL, NULL, &cdr_description }; @@ -169,9 +168,7 @@ t_stat cdr_srv(UNIT *uptr) { int chan = UNIT_G_CHAN(uptr->flags); int u = (uptr - cdr_unit); - struct _card_data *data; - - data = (struct _card_data *)uptr->up7; + uint16 *image = (uint16 *)(uptr->up7); /* Waiting for disconnect */ if (uptr->u5 & URCSTA_WDISCO) { @@ -201,7 +198,7 @@ cdr_srv(UNIT *uptr) { /* Check if new card requested. */ if (uptr->u4 == 0 && uptr->u5 & URCSTA_READ && (uptr->u5 & URCSTA_CARD) == 0) { - switch(sim_read_card(uptr)) { + switch(sim_read_card(uptr, image)) { case SCPE_EOF: sim_debug(DEBUG_DETAIL, &cdr_dev, "%d: EOF\n", u); /* Fall through */ @@ -229,7 +226,7 @@ cdr_srv(UNIT *uptr) { } #ifdef I7070 /* Check if load card. */ - if (uptr->capac && (data->image[uptr->capac-1] & 0x800)) { + if (uptr->capac && (image[uptr->capac-1] & 0x800)) { uptr->u5 |= URCSTA_LOAD; chan_set_load_mode(chan); } else { @@ -249,7 +246,7 @@ cdr_srv(UNIT *uptr) { #ifdef I7080 /* Detect RSU */ - if (data->image[uptr->u4] == 0x924) { + if (image[uptr->u4] == 0x924) { uptr->u5 &= ~URCSTA_READ; uptr->u5 |= URCSTA_WDISCO; chan_set(chan, DEV_REOR); @@ -258,7 +255,7 @@ cdr_srv(UNIT *uptr) { } #endif - ch = sim_hol_to_bcd(data->image[uptr->u4]); + ch = sim_hol_to_bcd(image[uptr->u4]); /* Handle invalid punch */ if (ch == 0x7f) { @@ -321,14 +318,31 @@ cdr_attach(UNIT * uptr, CONST char *file) if ((r = sim_card_attach(uptr, file)) != SCPE_OK) return r; - uptr->u5 &= URCSTA_BUSY|URCSTA_WDISCO; - uptr->u4 = 0; - uptr->u6 = 0; + if (uptr->up7 == 0) { + uptr->up7 = malloc(sizeof(uint16)*80); + uptr->u5 &= URCSTA_BUSY|URCSTA_WDISCO; + uptr->u4 = 0; + uptr->u6 = 0; + } #ifdef I7010 chan_set_attn_urec(UNIT_G_CHAN(uptr->flags), cdr_dib.addr); #endif return SCPE_OK; } + +t_stat +cdr_detach(UNIT * uptr) +{ + t_stat r; + + if ((r = sim_card_detach(uptr)) != SCPE_OK) + return r; + if (uptr->up7 != 0) + free(uptr->up7); + uptr->up7 = 0; + return SCPE_OK; +} + #ifdef I7070 t_stat cdr_setload(UNIT *uptr, int32 val, CONST char *cptr, void *desc) diff --git a/I7000/i7000_ht.c b/I7000/i7000_ht.c index 69743ed..42adbcb 100644 --- a/I7000/i7000_ht.c +++ b/I7000/i7000_ht.c @@ -959,7 +959,7 @@ ht_attach(UNIT * uptr, CONST char *file) { t_stat r; - if ((r = sim_tape_attach(uptr, file)) != SCPE_OK) + if ((r = sim_tape_attach_ex(uptr, file, 0, 0)) != SCPE_OK) return r; uptr->u5 = HT_BOT /*|HT_ATTN */ ; return SCPE_OK; diff --git a/I7000/i7000_mt.c b/I7000/i7000_mt.c index a9f4244..678bbf4 100644 --- a/I7000/i7000_mt.c +++ b/I7000/i7000_mt.c @@ -1354,7 +1354,7 @@ mt_attach(UNIT * uptr, CONST char *file) { t_stat r; - if ((r = sim_tape_attach(uptr, file)) != SCPE_OK) + if ((r = sim_tape_attach_ex(uptr, file, 0, 0)) != SCPE_OK) return r; uptr->u3 = 0; uptr->u5 |= MT_RDY; diff --git a/I7000/i7090_cdp.c b/I7000/i7090_cdp.c index 8682672..b079517 100644 --- a/I7000/i7090_cdp.c +++ b/I7000/i7090_cdp.c @@ -121,19 +121,19 @@ t_stat cdp_srv(UNIT * uptr) { int chan = UNIT_G_CHAN(uptr->flags); int u = (uptr - cdp_unit); + uint16 *image = (uint16 *)(uptr->up7); int pos; t_uint64 wd; int bit; t_uint64 mask; int b; int col; - struct _card_data *data; /* Channel has disconnected, abort current card. */ if (uptr->u5 & URCSTA_CMD && chan_stat(chan, DEV_DISCO)) { if ((uptr->u5 & CDPSTA_POSMASK) != 0) { sim_debug(DEBUG_DETAIL, &cdp_dev, "punch card\n"); - sim_punch_card(uptr, NULL); + sim_punch_card(uptr, NULL, image); uptr->u5 &= ~CDPSTA_PUNCH; } uptr->u5 &= ~(URCSTA_WRITE | URCSTA_CMD | CDPSTA_POSMASK); @@ -189,7 +189,7 @@ t_stat cdp_srv(UNIT * uptr) sim_debug(DEBUG_CHAN, &cdp_dev, "unit=%d disconnect\n", u); } sim_debug(DEBUG_DETAIL, &cdp_dev, "punch card full\n"); - sim_punch_card(uptr, NULL); + sim_punch_card(uptr, NULL, image); uptr->u5 |= URCSTA_IDLE; uptr->u5 &= ~(URCSTA_WRITE | CDPSTA_POSMASK | CDPSTA_PUNCH); uptr->wait = 85; @@ -201,7 +201,6 @@ t_stat cdp_srv(UNIT * uptr) sim_debug(DEBUG_DATA, &cdp_dev, "unit=%d write column %d ", u, pos); wd = 0; - data = (struct _card_data *)uptr->up7; switch (chan_read(chan, &wd, 0)) { case DATA_OK: sim_debug(DEBUG_DATA, &cdp_dev, " %012llo\n", wd); @@ -212,7 +211,7 @@ t_stat cdp_srv(UNIT * uptr) for (col = 35; col >= 0; mask <<= 1, col--) { if (wd & mask) - data->image[col + b] |= bit; + image[col + b] |= bit; } pos++; uptr->wait = 0; @@ -258,13 +257,19 @@ cdp_attach(UNIT * uptr, CONST char *file) if ((r = sim_card_attach(uptr, file)) != SCPE_OK) return r; - uptr->u5 = CDPSTA_POSMASK; + if (uptr->up7 == 0) { + uptr->up7 = calloc(80, sizeof(uint16)); + uptr->u5 = CDPSTA_POSMASK; + } return SCPE_OK; } t_stat cdp_detach(UNIT * uptr) { + if (uptr->up7 != 0) + free(uptr->up7); + uptr->up7 = 0; return sim_card_detach(uptr); } diff --git a/I7000/i7090_cdr.c b/I7000/i7090_cdr.c index e82938f..a59f98d 100644 --- a/I7000/i7090_cdr.c +++ b/I7000/i7090_cdr.c @@ -28,8 +28,7 @@ #ifdef NUM_DEVS_CDR -#define UNIT_CDR UNIT_ATTABLE | UNIT_RO | UNIT_DISABLE | UNIT_ROABLE |\ - MODE_026 +#define UNIT_CDR UNIT_ATTABLE | UNIT_RO | UNIT_DISABLE | MODE_026 /* std devices. data structures @@ -119,9 +118,9 @@ t_stat cdr_srv(UNIT * uptr) int chan = UNIT_G_CHAN(uptr->flags); int u = (uptr - cdr_unit); int pos, col, b; + uint16 *image = (uint16 *)(uptr->up7); uint16 bit; t_uint64 mask, wd; - struct _card_data *data; /* Channel has disconnected, abort current read. */ if (uptr->u5 & URCSTA_CMD && chan_stat(chan, DEV_DISCO)) { @@ -164,7 +163,7 @@ t_stat cdr_srv(UNIT * uptr) pos = (uptr->u5 & CDRPOSMASK) >> CDRPOSSHIFT; if (pos == (CDRPOSMASK >> CDRPOSSHIFT)) { - switch (sim_read_card(uptr)) { + switch (sim_read_card(uptr, image)) { case SCPE_UNATT: case SCPE_IOERR: sim_debug(DEBUG_EXP, &cdr_dev, "unit=%d Setting ATTN\n", u); @@ -197,7 +196,6 @@ t_stat cdr_srv(UNIT * uptr) return SCPE_OK; } - data = (struct _card_data *)uptr->up7; /* Bit flip into read buffer */ bit = 1 << (pos / 2); mask = 1; @@ -205,7 +203,7 @@ t_stat cdr_srv(UNIT * uptr) b = (pos & 1)?36:0; for (col = 35; col >= 0; mask <<= 1) { - if (data->image[col-- + b] & bit) + if (image[col-- + b] & bit) wd |= mask; } @@ -247,7 +245,7 @@ cdr_boot(int32 unit_num, DEVICE * dptr) int chan = UNIT_G_CHAN(uptr->flags); t_stat r; int pos; - struct _card_data *data; + uint16 *image = (uint16 *)(uptr->up7); if ((uptr->flags & UNIT_ATT) == 0) return SCPE_UNATT; /* attached? */ @@ -255,12 +253,11 @@ cdr_boot(int32 unit_num, DEVICE * dptr) /* Init for a read */ if (cdr_cmd(uptr, IO_RDS, cdr_dib.addr) != SCPE_OK) return STOP_IONRDY; - r = sim_read_card(uptr); + r = sim_read_card(uptr, image); if (r != SCPE_OK) return r; /* Copy first three records. */ - data = (struct _card_data *)uptr->up7; uptr->u5 &= ~CDRPOSMASK; for(pos = 0; pos <3; pos++) { uint16 bit = 1 << (pos / 2); @@ -272,7 +269,7 @@ cdr_boot(int32 unit_num, DEVICE * dptr) break; M[pos] = 0; for (col = 35; col >= 0; mask <<= 1) { - if (data->image[col-- + b] & bit) + if (image[col-- + b] & bit) M[pos] |= mask; } sim_debug(DEBUG_DATA, &cdr_dev, "boot read row %d %012llo\n", @@ -296,14 +293,20 @@ cdr_attach(UNIT * uptr, CONST char *file) if ((r = sim_card_attach(uptr, file)) != SCPE_OK) return r; - uptr->u5 = 0; - uptr->u4 = 0; + if (uptr->up7 == 0) { + uptr->up7 = malloc(sizeof(uint16)*80); + uptr->u5 = 0; + uptr->u4 = 0; + } return SCPE_OK; } t_stat cdr_detach(UNIT * uptr) { + if (uptr->up7 != 0) + free(uptr->up7); + uptr->up7 = 0; return sim_card_detach(uptr); }