diff --git a/IBM360/ibm360_cdp.c b/IBM360/ibm360_cdp.c index ff6eec5..ec720fd 100644 --- a/IBM360/ibm360_cdp.c +++ b/IBM360/ibm360_cdp.c @@ -77,6 +77,7 @@ cdp_mod Card Punch modifiers list */ +uint8 cdp_startio(UNIT *uptr); uint8 cdp_startcmd(UNIT *, uint8); void cdp_ini(UNIT *, t_bool); t_stat cdp_srv(UNIT *); @@ -108,7 +109,7 @@ MTAB cdp_mod[] = { {0} }; -struct dib cdp_dib = { 0xFF, 1, NULL, cdp_startcmd, NULL, cdp_unit, NULL}; +struct dib cdp_dib = { 0xFF, 1, cdp_startio, cdp_startcmd, NULL, cdp_unit, NULL}; DEVICE cdp_dev = { "CDP", cdp_unit, NULL, cdp_mod, @@ -120,6 +121,20 @@ DEVICE cdp_dev = { +/* + * Check if device ready to start commands. + */ + +uint8 cdp_startio(UNIT *uptr) { + DEVICE *dptr = find_dev_from_unit(uptr); + + /* Check if unit is free */ + if ((uptr->CMD & (CDP_CARD|CDP_CMDMSK)) != 0) { + return SNS_BSY; + } + sim_debug(DEBUG_CMD, dptr, "start io\n"); + return 0; +} /* * Start the card punch to punch one card. @@ -129,11 +144,8 @@ uint8 cdp_startcmd(UNIT *uptr, uint8 cmd) { DEVICE *dptr = find_dev_from_unit(uptr); int unit = (uptr - dptr->units); - if ((uptr->CMD & (CDP_CARD|CDP_CMDMSK)) != 0) { - if ((uptr->flags & UNIT_ATT) != 0) - return SNS_BSY; - return SNS_DEVEND|SNS_UNITCHK; - } + if ((uptr->CMD & (CDP_CARD|CDP_CMDMSK)) != 0) + return SNS_BSY; sim_debug(DEBUG_CMD, dptr, "CMD unit=%d %x\n", unit, cmd); switch (cmd & 0x7) { @@ -181,6 +193,7 @@ cdp_srv(UNIT *uptr) { /* Handle sense */ if ((uptr->CMD & CDP_CMDMSK) == 0x4) { uint8 ch = uptr->SNS; + uptr->CMD &= ~(CDP_CMDMSK); chan_write_byte(addr, &ch); chan_end(addr, SNS_DEVEND|SNS_CHNEND); return SCPE_OK; @@ -193,7 +206,7 @@ cdp_srv(UNIT *uptr) { switch(sim_punch_card(uptr, image)) { /* If we get here, something is wrong */ default: - sim_debug(DEBUG_DETAIL, &cdp_dev, "unit=%d:punch error\n", u); + sim_debug(DEBUG_DETAIL, &cdp_dev, "unit=%d:punch error\n", u); set_devattn(addr, SNS_DEVEND|SNS_UNITCHK); break; case CDSE_OK: diff --git a/IBM360/ibm360_cdr.c b/IBM360/ibm360_cdr.c index 42fdda1..b21ef5d 100644 --- a/IBM360/ibm360_cdr.c +++ b/IBM360/ibm360_cdr.c @@ -125,23 +125,25 @@ uint8 cdr_startcmd(UNIT *uptr, uint8 cmd) { DEVICE *dptr = find_dev_from_unit(uptr); int unit = (uptr - dptr->units); - if ((uptr->CMD & CDR_CMDMSK) != 0) { - if ((uptr->flags & UNIT_ATT) != 0) - return SNS_BSY; - return SNS_DEVEND; - } + if ((uptr->CMD & CDR_CMDMSK) != 0) + return SNS_BSY; sim_debug(DEBUG_CMD, dptr, "CMD unit=%d %x\n", unit, cmd); + + /* Check if not sense and end of file */ if (cmd != 4 && sim_card_eof(uptr) == 1) { uint16 *image = (uint16 *)(uptr->up7); uptr->SNS = SNS_INTVENT; sim_read_card(uptr, image); /* Read in the EOF */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; } + + /* If not attached and not sense, return error */ if (cmd != 4 && (uptr->flags & UNIT_ATT) == 0) { uptr->SNS = SNS_INTVENT; return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; } + switch (cmd & 0x7) { case 2: /* Read command */ if ((cmd & 0xc0) != 0xc0) @@ -283,6 +285,7 @@ cdr_attach(UNIT * uptr, CONST char *file) uptr->up7 = malloc(sizeof(uint16)*80); set_devattn(addr, SNS_DEVEND); uptr->CMD &= ~(CDR_CARD); + uptr->SNS = 0; uptr->COL = 0; uptr->u6 = 0; return SCPE_OK; diff --git a/IBM360/ibm360_chan.c b/IBM360/ibm360_chan.c index 24def42..2e60d0f 100644 --- a/IBM360/ibm360_chan.c +++ b/IBM360/ibm360_chan.c @@ -841,6 +841,8 @@ startio(uint16 addr) { /* Check for any pending status for this device */ if (dev_status[addr] != 0) { + if (dev_status[addr] & SNS_DEVEND) + dev_status[addr] |= SNS_BSY; M[0x44 >> 2] = (((uint32)dev_status[addr]) << 24); M[0x40 >> 2] = 0; key[0] |= 0x6; @@ -854,8 +856,11 @@ startio(uint16 addr) { /* If device has start_io function run it */ if (dibp->start_io != NULL) { status = dibp->start_io(uptr) << 8; - if (status & STATUS_BUSY) + sim_debug(DEBUG_CMD, &cpu_dev, "SIO %03x %x\n", addr, status); + if (status & STATUS_BUSY) { + sim_debug(DEBUG_CMD, &cpu_dev, "SIO %03x busy cc=2\n", addr); return 2; + } if (status != 0) { M[0x44 >> 2] = ((uint32)status<<16) | (M[0x44 >> 2] & 0xffff); sim_debug(DEBUG_EXP, &cpu_dev, "Channel store csw %03x %08x\n", @@ -878,14 +883,14 @@ startio(uint16 addr) { if (load_ccw(chan, 0)) { M[0x44 >> 2] = ((uint32)chan->chan_status<<16) | (M[0x44 >> 2] & 0xffff); key[0] |= 0x6; - sim_debug(DEBUG_CMD, &cpu_dev, "SIO %03x %02x %x cc=2\n", addr, + sim_debug(DEBUG_CMD, &cpu_dev, "SIO %03x %02x %x cc=1\n", addr, chan->ccw_cmd, chan->ccw_flags); chan->chan_status = 0; chan->ccw_cmd = 0; dev_status[addr] = 0; chan->daddr = NO_DEV; chan->dev = NULL; - return 1; + return ((uptr->flags & UNIT_ATT) == 0) ? 3 : 1; } /* If channel returned busy save CSW and return cc=1 */ @@ -951,7 +956,6 @@ int testio(uint16 addr) { sim_debug(DEBUG_CMD, &cpu_dev, "TIO %03x %03x %02x %x cc=1a\n", addr, chan->daddr, chan->ccw_cmd, chan->ccw_flags); store_csw(chan); -// dev_status[addr] = 0; chan->daddr = NO_DEV; chan->dev = NULL; return 1; @@ -990,18 +994,20 @@ int testio(uint16 addr) { status = dibp->start_cmd(uptr, 0) << 8; /* If no status and unattached device return cc=3 */ - if (status == 0 && (uptr->flags & UNIT_ATT) == 0) { - sim_debug(DEBUG_CMD, &cpu_dev, "TIO %03x %03x %02x %x cc=1c\n", addr, - chan->daddr, chan->ccw_cmd, chan->ccw_flags); - return 3; +#if 0 + if (status != 0 && (uptr->flags & UNIT_ATT) == 0) { + sim_debug(DEBUG_CMD, &cpu_dev, "TIO %03x %03x %02x %x %x cc=1c\n", addr, + chan->daddr, chan->ccw_cmd, chan->ccw_flags, status); + return 0; } +#endif /* If we get a error, save csw and return cc=1 */ if (status & ERROR_STATUS) { - M[0x44 >> 2] = ((uint32)status<<24) | (M[0x44 >> 2] & 0xffff); + M[0x44 >> 2] = ((uint32)status<<16) | (M[0x44 >> 2] & 0xffff); key[0] |= 0x6; - sim_debug(DEBUG_CMD, &cpu_dev, "TIO %03x %03x %02x %x cc=1d\n", addr, - chan->daddr, chan->ccw_cmd, chan->ccw_flags); + sim_debug(DEBUG_CMD, &cpu_dev, "TIO %03x %03x %02x %x %x cc=1d\n", addr, + chan->daddr, chan->ccw_cmd, chan->ccw_flags, status); return 1; } diff --git a/IBM360/ibm360_cpu.c b/IBM360/ibm360_cpu.c index b7d60aa..d726e35 100644 --- a/IBM360/ibm360_cpu.c +++ b/IBM360/ibm360_cpu.c @@ -2210,23 +2210,25 @@ save_dbl: dest = cregs[reg1]; break; case 0x8: /* Partitioning register */ - dest = 0x88888888; + dest = 0x8c8c8c8c; break; case 0x9: /* Partitioning register */ /* Compute amount of memory and assign in 256k blocks to CPU 1 */ - dest = 0x88884444; + dest = 0x8c8c0000; break; case 0xA: /* Partitioning register */ /* Address each 256k bank to 0-0xF */ dest = 0x02468ace; break; case 0xB: /* Partitioning register */ - dest = 0x80000000; + dest = 0x88000000; break; case 0xC: /* Partitioning register */ + dest = 0xFFFFFFFF; + break; case 0xD: /* Partitioning register */ - dest = 0xAAAAAAAA; + dest = 0xFFFFFFFF; break; case 0xE: /* Partitioning register */ dest = 0x00000200; diff --git a/IBM360/ibm360_dasd.c b/IBM360/ibm360_dasd.c index 3361be6..e9d5a43 100644 --- a/IBM360/ibm360_dasd.c +++ b/IBM360/ibm360_dasd.c @@ -387,7 +387,7 @@ uint8 dasd_startio(UNIT *uptr) { if ((uptr->flags & UNIT_ATT) != 0) { struct dasd_t *data = (struct dasd_t *)(uptr->up7); data->filemsk = 0; - sim_debug(DEBUG_CMD, dptr, "start io unit=%d %d %d %d\n", unit, data->tstart, + sim_debug(DEBUG_CMD, dptr, "start io unit=%d %d %d %d\n", unit, data->tstart, data->tpos, data->rpos); } sim_debug(DEBUG_CMD, dptr, "start io unit=%d\n", unit); @@ -406,75 +406,13 @@ uint8 dasd_startcmd(UNIT *uptr, uint8 cmd) { sim_debug(DEBUG_CMD, dptr, "CMD unit=%d %02x\n", unit, cmd); if ((uptr->flags & UNIT_ATT) == 0) { - if (cmd == 0x4) { /* Sense */ - int type = GET_TYPE(uptr->flags); - int i; - sim_debug(DEBUG_CMD, dptr, "CMD sense\n"); - ch = uptr->SNS & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 1 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = (uptr->SNS >> 8) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 2 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = 0; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 3 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - if (disk_type[type].sen_cnt > 6) { - ch = (unit & 07) | ((~unit & 07) << 3); - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 4 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = unit; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 5 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = (uptr->CCH >> 8) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 6 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = (uptr->CCH & 0x1f) | ((uptr->CCH & 0x10000) ? 0x40 : 0); - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 7 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = 0; /* Compute message code */ - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 8 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - i = 8; - } else { - if (disk_type[type].dev_type == 0x11) - ch = 0xc8; - else - ch = 0x40; - if ((uptr->CCH >> 8) & SNS_ENDCYL) - ch |= 4; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 4 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - ch = unit; - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 5 %x\n", unit, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - i = 5; - } - ch = 0; - for (; i < disk_type[type].sen_cnt; i++) { - sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d %d %x\n", unit, i, ch); - if (chan_write_byte(addr, &ch)) - goto sense_end; - } -sense_end: - uptr->SNS = 0; - return SNS_CHNEND|SNS_DEVEND; - } - if (cmd == 0x0) - return 0; - - uptr->SNS = SNS_INTVENT|SNS_CMDREJ; - return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; + if (cmd != 0) { // if ((cmd & 0xF) == 0x4) { /* Sense */ + uptr->CMD |= cmd; + sim_activate(uptr, 10); + return 0; + } + sim_debug(DEBUG_CMD, dptr, "CMD unit=%d disco\n", unit); + return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; } switch (cmd & 0x3) { @@ -587,8 +525,8 @@ t_stat dasd_srv(UNIT * uptr) int unit = (uptr - dptr->units); int cmd = uptr->CMD & 0x7f; int type = GET_TYPE(uptr->flags); - int state = data->state; - int count = data->count; + int state; + int count; int trk; int i; int rd = ((cmd & 0x3) == 0x1) | ((cmd & 0x3) == 0x2); @@ -597,6 +535,78 @@ t_stat dasd_srv(UNIT * uptr) uint8 ch; uint8 buf[8]; + if ((uptr->flags & UNIT_ATT) == 0) { + if (cmd == 0x4) { /* Sense */ + int type = GET_TYPE(uptr->flags); + int i; + sim_debug(DEBUG_CMD, dptr, "CMD sense\n"); + ch = SNS_INTVENT; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 1 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = 0; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 2 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = 0; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 3 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + if (disk_type[type].sen_cnt > 6) { + ch = (unit & 07) | ((~unit & 07) << 3); + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 4 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = unit; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 5 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = (uptr->CCH >> 8) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 6 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = (uptr->CCH & 0x1f) | ((uptr->CCH & 0x10000) ? 0x40 : 0); + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 7 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = 0; /* Compute message code */ + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 8 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + i = 8; + } else { + if (disk_type[type].dev_type == 0x11) + ch = 0xc8; + else + ch = 0x40; + if ((uptr->CCH >> 8) & SNS_ENDCYL) + ch |= 4; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 4 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + ch = unit; + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d 5 %x\n", unit, ch); + if (chan_write_byte(addr, &ch)) + goto sns_end; + i = 5; + } + ch = 0; + for (; i < disk_type[type].sen_cnt; i++) { + sim_debug(DEBUG_DETAIL, dptr, "sense unit=%d %d %x\n", unit, i, ch); + if (chan_write_byte(addr, &ch)) + break; + } +sns_end: + chan_end(addr, SNS_CHNEND|SNS_DEVEND); + } else { + chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); + } + uptr->CMD &= ~(0xff); + return SCPE_OK; + } + + state = data->state; + count = data->count; /* Check if read or write command, if so grab correct cylinder */ if (state != DK_POS_SEEK && rd && data->cyl != data->ccyl) { uint32 tsize = data->tsize * disk_type[type].heads; @@ -679,6 +689,8 @@ ntrack: uptr->CMD &= ~DK_SRCOK; data->tstart = data->tsize * (uptr->CCH & 0xff); data->tpos = data->rpos = 0; + rec = &data->cbuf[data->rpos + data->tstart]; + da = &data->cbuf[data->tpos + data->tstart]; data->state = DK_POS_HA; data->rec = 0; sim_activate(uptr, 50); diff --git a/IBM360/ibm360_lpr.c b/IBM360/ibm360_lpr.c index c1fd5ac..8939e1e 100644 --- a/IBM360/ibm360_lpr.c +++ b/IBM360/ibm360_lpr.c @@ -292,13 +292,14 @@ print_line(UNIT * uptr) } +/* + * Check if device ready to start commands. + */ + uint8 lpr_startio(UNIT *uptr) { - if ((uptr->CMD & LPR_CMDMSK) != 0) { - if ((uptr->flags & UNIT_ATT) != 0) - return SNS_BSY; - return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; - } + if ((uptr->CMD & LPR_CMDMSK) != 0) + return SNS_BSY; sim_debug(DEBUG_CMD, &lpr_dev, "start io unit\n"); return 0; }