diff --git a/SEL32/sel32_disk.c b/SEL32/sel32_disk.c index 4737d26..29155ce 100644 --- a/SEL32/sel32_disk.c +++ b/SEL32/sel32_disk.c @@ -41,7 +41,6 @@ extern uint32 SPAD[]; /* cpu SPAD memory */ #define GET_TYPE(x) ((UNIT_TYPE & (x)) >> UNIT_V_TYPE) #define SET_TYPE(x) (UNIT_TYPE & ((x) << UNIT_V_TYPE)) -//#define UNIT_DISK UNIT_ATTABLE | UNIT_DISABLE | UNIT_ROABLE | UNIT_FIX | UNIT_IDLE #define UNIT_DISK UNIT_ATTABLE | UNIT_IDLE /* INCH command information */ @@ -50,14 +49,14 @@ WD 0 - Data address WD 1 - Flags - 0 -36 byte count Data - 224 word INCH buffer address -WD 1 Drive 0 Attribute register -WD 2 Drive 1 Attribute register -WD 3 Drive 2 Attribute register -WD 4 Drive 3 Attribute register -WD 5 Drive 4 Attribute register -WD 6 Drive 5 Attribute register -WD 7 Drive 6 Attribute register -WD 8 Drive 7 Attribute register +WD 1 Drive 0 Attribute register +WD 2 Drive 1 Attribute register +WD 3 Drive 2 Attribute register +WD 4 Drive 3 Attribute register +WD 5 Drive 4 Attribute register +WD 6 Drive 5 Attribute register +WD 7 Drive 6 Attribute register +WD 8 Drive 7 Attribute register Memory attribute register layout bits 0-7 - Flags @@ -70,7 +69,8 @@ bits 0-7 - Flags bit 7 - 0=Reserved bits 8-15 - sector count (sectors per track)(F16=16, F20=20) bits 16-23 - MHD Head count (number of heads on MHD) -bits 24-31 - FHD head count (number of heads on FHD or number head on FHD option of mini-module) +bits 24-31 - FHD head count (number of heads on FHD or number head on FHD option of + mini-module) */ @@ -80,90 +80,94 @@ bits 24-31 - FHD head count (number of heads on FHD or number head on FHD option /* 26 words of scratchpad */ /* 4 words of label buffer registers */ +#define CMD u3 /* u3 */ /* in u3 is device command code and status */ -#define DSK_CMDMSK 0x00ff /* Command being run */ -#define DSK_STAR 0x0100 /* STAR value in u4 */ -#define DSK_NU2 0x0200 /* */ -#define DSK_READDONE 0x0400 /* Read finished, end channel */ -#define DSK_ENDDSK 0x0800 /* Sensed end of disk */ -#define DSK_SEEKING 0x1000 /* Disk is currently seeking */ -#define DSK_READING 0x2000 /* Disk is reading data */ -#define DSK_WRITING 0x4000 /* Disk is writing data */ -#define DSK_BUSY 0x8000 /* Flag to send a CUE */ +#define DSK_CMDMSK 0x00ff /* Command being run */ +#define DSK_STAR 0x0100 /* STAR value in u4 */ +#define DSK_NU2 0x0200 /* */ +#define DSK_READDONE 0x0400 /* Read finished, end channel */ +#define DSK_ENDDSK 0x0800 /* Sensed end of disk */ +#define DSK_SEEKING 0x1000 /* Disk is currently seeking */ +#define DSK_READING 0x2000 /* Disk is reading data */ +#define DSK_WRITING 0x4000 /* Disk is writing data */ +#define DSK_BUSY 0x8000 /* Flag to send a CUE */ /* commands */ -#define DSK_INCH 0x00 /* Initialize channel */ -#define DSK_WD 0x01 /* Write data */ -#define DSK_RD 0x02 /* Read data */ -#define DSK_NOP 0x03 /* No operation */ -#define DSK_SNS 0x04 /* Sense */ -#define DSK_SCK 0x07 /* Seek cylinder, track, sector */ -#define DSK_TIC 0x08 /* Transfer in channel */ -#define DSK_FNSK 0x0B /* Format for no skip */ -#define DSK_LPL 0x13 /* Lock protected label */ -#define DSK_LMR 0x1F /* Load mode register */ -#define DSK_RES 0x23 /* Reserve */ -#define DSK_WSL 0x31 /* Write sector label */ -#define DSK_RSL 0x32 /* Read sector label */ -#define DSK_REL 0x33 /* Release */ -#define DSK_XEZ 0x37 /* Rezero */ -#define DSK_POR 0x43 /* Priority Override */ -#define DSK_IHA 0x47 /* Increment head address */ -#define DSK_SRM 0x4F /* Set reserve track mode */ -#define DSK_WTL 0x51 /* Write track label */ -#define DSK_RTL 0x52 /* Read track label */ -#define DSK_XRM 0x5F /* Reset reserve track mode */ -#define DSK_RAP 0xA2 /* Read angular positions */ -#define DSK_TESS 0xAB /* Test STAR (subchannel target address register) */ -#define DSK_ICH 0xFF /* Initialize Controller */ +#define DSK_INCH 0x00 /* Initialize channel */ +#define DSK_WD 0x01 /* Write data */ +#define DSK_RD 0x02 /* Read data */ +#define DSK_NOP 0x03 /* No operation */ +#define DSK_SNS 0x04 /* Sense */ +#define DSK_SCK 0x07 /* Seek cylinder, track, sector */ +#define DSK_TIC 0x08 /* Transfer in channel */ +#define DSK_FNSK 0x0B /* Format for no skip */ +#define DSK_LPL 0x13 /* Lock protected label */ +#define DSK_LMR 0x1F /* Load mode register */ +#define DSK_RES 0x23 /* Reserve */ +#define DSK_WSL 0x31 /* Write sector label */ +#define DSK_RSL 0x32 /* Read sector label */ +#define DSK_REL 0x33 /* Release */ +#define DSK_XEZ 0x37 /* Rezero */ +#define DSK_POR 0x43 /* Priority Override */ +#define DSK_IHA 0x47 /* Increment head address */ +#define DSK_SRM 0x4F /* Set reserve track mode */ +#define DSK_WTL 0x51 /* Write track label */ +#define DSK_RTL 0x52 /* Read track label */ +#define DSK_XRM 0x5F /* Reset reserve track mode */ +#define DSK_RAP 0xA2 /* Read angular positions */ +#define DSK_TESS 0xAB /* Test STAR (subchannel target address register) */ +#define DSK_ICH 0xFF /* Initialize Controller */ +#define STAR u4 /* u4 - sector target address register (STAR) */ /* Holds the current cylinder, head(track), sector */ -#define DISK_CYL 0xFFFF0000 /* cylinder mask */ -#define DISK_TRACK 0x0000FF00 /* track mask */ -#define DISK_SECTOR 0x000000ff /* sector mask */ +#define DISK_CYL 0xFFFF0000 /* cylinder mask */ +#define DISK_TRACK 0x0000FF00 /* track mask */ +#define DISK_SECTOR 0x000000ff /* sector mask */ +#define SNS u5 /* u5 */ /* Sense byte 0 - mode register */ -#define SNS_DROFF 0x80000000 /* Drive Carriage will be offset */ -#define SNS_TRKOFF 0x40000000 /* Track offset: 0=positive, 1=negative */ -#define SNS_RDTMOFF 0x20000000 /* Read timing offset = 1 */ -#define SNS_RDSTRBT 0x10000000 /* Read strobe timing: 1=positive, 0=negative */ -#define SNS_DIAGMOD 0x08000000 /* Diagnostic Mode ECC Code generation and checking */ -#define SNS_RSVTRK 0x04000000 /* Reserve Track mode: 1=OK to write, 0=read only */ -#define SNS_FHDOPT 0x02000000 /* FHD or FHD option = 1 */ -#define SNS_RESERV 0x01000000 /* Reserved */ +#define SNS_DROFF 0x80000000 /* Drive Carriage will be offset */ +#define SNS_TRKOFF 0x40000000 /* Track offset: 0=positive, 1=negative */ +#define SNS_RDTMOFF 0x20000000 /* Read timing offset = 1 */ +#define SNS_RDSTRBT 0x10000000 /* Read strobe timing: 1=positive, 0=negative */ +#define SNS_DIAGMOD 0x08000000 /* Diagnostic Mode ECC Code generation and checking */ +#define SNS_RSVTRK 0x04000000 /* Reserve Track mode: 1=OK to write, 0=read only */ +#define SNS_FHDOPT 0x02000000 /* FHD or FHD option = 1 */ +#define SNS_RESERV 0x01000000 /* Reserved */ /* Sense byte 1 */ -#define SNS_CMDREJ 0x800000 /* Command reject */ -#define SNS_INTVENT 0x400000 /* Unit intervention required */ -#define SNS_SPARE1 0x200000 /* Spare */ -#define SNS_EQUCHK 0x100000 /* Equipment check */ -#define SNS_DATCHK 0x080000 /* Data Check */ -#define SNS_OVRRUN 0x040000 /* Data overrun/underrun */ -#define SNS_DSKFERR 0x020000 /* Disk format error */ -#define SNS_DEFTRK 0x010000 /* Defective track encountered */ +#define SNS_CMDREJ 0x800000 /* Command reject */ +#define SNS_INTVENT 0x400000 /* Unit intervention required */ +#define SNS_SPARE1 0x200000 /* Spare */ +#define SNS_EQUCHK 0x100000 /* Equipment check */ +#define SNS_DATCHK 0x080000 /* Data Check */ +#define SNS_OVRRUN 0x040000 /* Data overrun/underrun */ +#define SNS_DSKFERR 0x020000 /* Disk format error */ +#define SNS_DEFTRK 0x010000 /* Defective track encountered */ /* Sense byte 2 */ -#define SNS_LAST 0x8000 /* Last track flag encountered */ -#define SNS_AATT 0x4000 /* At Alternate track */ -#define SNS_WPER 0x2000 /* Write protection error */ -#define SNS_WRL 0x1000 /* Write lock error */ -#define SNS_MOCK 0x0800 /* Mode check */ -#define SNS_INAD 0x0400 /* Invalid memory address */ -#define SNS_RELF 0x0200 /* Release fault */ -#define SNS_CHER 0x0100 /* Chaining error */ +#define SNS_LAST 0x8000 /* Last track flag encountered */ +#define SNS_AATT 0x4000 /* At Alternate track */ +#define SNS_WPER 0x2000 /* Write protection error */ +#define SNS_WRL 0x1000 /* Write lock error */ +#define SNS_MOCK 0x0800 /* Mode check */ +#define SNS_INAD 0x0400 /* Invalid memory address */ +#define SNS_RELF 0x0200 /* Release fault */ +#define SNS_CHER 0x0100 /* Chaining error */ /* Sense byte 3 */ -#define SNS_REVL 0x80 /* Revolution lost */ -#define SNS_DADE 0x40 /* Disc addressing or seek error */ -#define SNS_BUCK 0x20 /* Buffer check */ -#define SNS_ECCS 0x10 /* ECC error in sector label */ -#define SNS_ECCD 0x08 /* ECC error iin data */ -#define SNS_ECCT 0x04 /* ECC error in track label */ -#define SNS_RTAE 0x02 /* Reserve track access error */ -#define SNS_UESS 0x01 /* Uncorrectable ECC error */ +#define SNS_REVL 0x80 /* Revolution lost */ +#define SNS_DADE 0x40 /* Disc addressing or seek error */ +#define SNS_BUCK 0x20 /* Buffer check */ +#define SNS_ECCS 0x10 /* ECC error in sector label */ +#define SNS_ECCD 0x08 /* ECC error iin data */ +#define SNS_ECCT 0x04 /* ECC error in track label */ +#define SNS_RTAE 0x02 /* Reserve track access error */ +#define SNS_UESS 0x01 /* Uncorrectable ECC error */ +#define ATTR u6 /* u6 */ /* u6 holds drive attribute entry */ /* provided by inch command for controller */ @@ -178,9 +182,11 @@ bits 0-7 - Flags bit 7 - 0=Reserved bits 8-15 - sector count (sectors per track)(F16=16, F20=20) bits 16-23 - MHD Head count (number of heads on MHD) -bits 24-31 - FHD head count (number of heads on FHD or number head on FHD option of mini-module) +bits 24-31 - FHD head count (number of heads on FHD or number head on FHD option of + mini-module) */ +#define DDATA up7 /* Pointer held in up7 */ /* sects/cylinder = sects/track * numhds */ /* allocated during attach command for each unit defined */ @@ -188,13 +194,11 @@ struct ddata_t { uint8 rbuf[1024]; /* read buffer, Sector buffer 768 or 1024 */ uint8 wbuf[1024]; /* write buffer, Sector buffer 768 or 1024 */ - uint32 cpos; /* Position of head of cylinder in file */ uint32 tstart; /* Location of start of cyl/track/sect in data */ - uint32 spare; /* drive register spare */ uint16 tsize; /* Size of one track in byte */ uint16 ssize; /* Size of one sector in bytes */ - uint16 ccyl; /* Current Cylinder number */ - uint16 cyl; /* Cylinder head at */ + int16 ccyl; /* Current Cylinder number */ + int16 cyl; /* Cylinder head at */ uint16 tpos; /* Track position */ uint16 spos; /* Sector position */ uint16 dlen; /* remaining in data */ @@ -246,26 +250,26 @@ disk_type[] = #if 0 ***************************************************************** -* DEVICE ID TABLE +* DEVICE ID TABLE ***************************************************************** - SPACE - BOUND 1W -DID.TBL EQU $ -* -*DEVICE ID NAME.................................................. -*TOTAL ALLOC. UNITS..................................... : -*BIT MAP SIZE .............................. : : -*NO. OF HEADS ........................ : : : -*SECTOR SIZE ................... : : : : -*SECTORS/TRACK .............. : : : : : -*SECTORS/ALOC. UNIT.......... : : : : : : -*SECTORS/BLOCK ....... : : : : : : : -*OLD DEVICE ID NAME.... : : : : : : : : -* : : : : : : : : : -* ......:..:..:...:....:....:.....:......:........: -DID FORM 32, 8, 8, 8, 8, 16, 16, 32, 64 - SPACE -* CLASS 'E' DISC DEVICES + SPACE + BOUND 1W +DID.TBL EQU $ +* +*DEVICE ID NAME.................................................. +*TOTAL ALLOC. UNITS..................................... : +*BIT MAP SIZE .............................. : : +*NO. OF HEADS ........................ : : : +*SECTOR SIZE ................... : : : : +*SECTORS/TRACK .............. : : : : : +*SECTORS/ALOC. UNIT.......... : : : : : : +*SECTORS/BLOCK ....... : : : : : : : +*OLD DEVICE ID NAME.... : : : : : : : : +* : : : : : : : : : +* ......:..:..:...:....:....:.....:......:........: +DID FORM 32, 8, 8, 8, 8, 16, 16, 32, 64 + SPACE +* CLASS 'E' DISC DEVICES DID C'DE01', 1, 1, 23, 192, 256, 184, 5888, C'FE004' DID C'DE02', 2, 1, 16, 96, 2, 200, 12800, C'CE010' DID C'DE04', 1, 2, 23, 192, 5, 719, 23000, C'ME040' @@ -327,30 +331,27 @@ UNIT dda_unit[] = { {UDATA(&disk_srv, UNIT_DISK|SET_TYPE(9), 0), 0, UNIT_ADDR(0x807)}, /* 7 */ }; -//DIB dda_dib = {NULL, disk_startcmd, NULL, NULL, disk_ini, dda_unit, dda_chp, NUM_UNITS_DISK, 0x0f, 0x0800, 0, 0, 0}; - DIB dda_dib = { - disk_preio, /* uint8 (*pre_io)(UNIT *uptr, uint16 chan)*/ /* Pre start I/O */ - disk_startcmd, /* uint8 (*start_cmd)(UNIT *uptr, uint16 chan, uint8 cmd)*/ /* Start a command */ - NULL, /* uint8 (*halt_io)(UNIT *uptr) */ /* Stop I/O */ - NULL, /* uint8 (*test_io)(UNIT *uptr) */ /* Test I/O */ - NULL, /* uint8 (*post_io)(UNIT *uptr) */ /* Post I/O */ - disk_ini, /* void (*dev_ini)(UNIT *, t_bool) */ /* init function */ - dda_unit, /* UNIT* units */ /* Pointer to units structure */ - dda_chp, /* CHANP* chan_prg */ /* Pointer to chan_prg structure */ - NUM_UNITS_DISK, /* uint8 numunits */ /* number of units defined */ - 0x0f, /* uint8 mask */ /* 16 devices - device mask */ - 0x0800, /* uint16 chan_addr */ /* parent channel address */ - 0, /* uint32 chan_fifo_in */ /* fifo input index */ - 0, /* uint32 chan_fifo_out */ /* fifo output index */ - 0, /* uint32 chan_fifo[FIFO_SIZE] */ /* interrupt status fifo for channel */ + disk_preio, /* Pre start I/O */ + disk_startcmd, /* Start a command */ + NULL, /* Stop I/O */ + NULL, /* Test I/O */ + NULL, /* Post I/O */ + disk_ini, /* init function */ + dda_unit, /* Pointer to units structure */ + dda_chp, /* Pointer to chan_prg structure */ + NUM_UNITS_DISK, /* number of units defined */ + 0x0f, /* 16 devices - device mask */ + 0x0800, /* parent channel address */ + 0, /* fifo input index */ + 0, /* fifo output index */ + 0, /* interrupt status fifo for channel */ }; DEVICE dda_dev = { "DMA", dda_unit, NULL, disk_mod, NUM_UNITS_DISK, 16, 24, 4, 16, 32, NULL, NULL, &disk_reset, &disk_boot, &disk_attach, &disk_detach, -// &dda_dib, DEV_BUF_NUM(0)|DEV_DISABLE|DEV_DEBUG, 0, dev_debug, &dda_dib, DEV_DISABLE|DEV_DEBUG, 0, dev_debug, NULL, NULL, &disk_help, NULL, NULL, &disk_description }; @@ -371,30 +372,28 @@ UNIT ddb_unit[] = { {UDATA(&disk_srv, UNIT_DISK|SET_TYPE(9), 0), 0, UNIT_ADDR(0xC07)}, /* 7 */ }; -//DIB ddb_dib = {disk_startcmd, NULL, NULL, NULL, disk_ini, ddb_unit, ddb_chp, NUM_UNITS_DISK, 0x0f, 0x0C00, 0, 0, 0}; DIB ddb_dib = { - disk_preio, /* uint8 (*start_io)(UNIT *uptr, uint16 chan)*/ /* Pre Start I/O */ - disk_startcmd, /* uint8 (*start_cmd)(UNIT *uptr, uint16 chan, uint8 cmd)*/ /* Start a command SIO */ - NULL, /* uint8 (*halt_io)(UNIT *uptr) */ /* Stop I/O HIO */ - NULL, /* uint8 (*test_io)(UNIT *uptr) */ /* Test I/O TIO */ - NULL, /* uint8 (*post_io)(UNIT *uptr) */ /* Post I/O */ - disk_ini, /* void (*dev_ini)(UNIT *, t_bool) */ /* init function */ - ddb_unit, /* UNIT* units */ /* Pointer to units structure */ - ddb_chp, /* CHANP* chan_prg */ /* Pointer to chan_prg structure */ - NUM_UNITS_DISK, /* uint8 numunits */ /* number of units defined */ - 0x0f, /* uint8 mask */ /* 16 devices - device mask */ - 0x0C00, /* uint16 chan_addr */ /* parent channel address */ - 0, /* uint32 chan_fifo_in */ /* fifo input index */ - 0, /* uint32 chan_fifo_out */ /* fifo output index */ - 0, /* uint32 chan_fifo[FIFO_SIZE] */ /* interrupt status fifo for channel */ + disk_preio, /* Pre Start I/O */ + disk_startcmd, /* Start a command SIO */ + NULL, /* Stop I/O HIO */ + NULL, /* Test I/O TIO */ + NULL, /* Post I/O */ + disk_ini, /* init function */ + ddb_unit, /* Pointer to units structure */ + ddb_chp, /* Pointer to chan_prg structure */ + NUM_UNITS_DISK, /* number of units defined */ + 0x0f, /* 16 devices - device mask */ + 0x0C00, /* parent channel address */ + 0, /* fifo input index */ + 0, /* fifo output index */ + 0, /* interrupt status fifo for channel */ }; DEVICE ddb_dev = { "DMB", ddb_unit, NULL, disk_mod, NUM_UNITS_DISK, 16, 24, 4, 16, 32, NULL, NULL, &disk_reset, &disk_boot, &disk_attach, &disk_detach, -// &ddb_dib, DEV_BUF_NUM(1)|DEV_DISABLE|DEV_DEBUG, 0, dev_debug, &ddb_dib, DEV_DISABLE|DEV_DEBUG, 0, dev_debug, NULL, NULL, &disk_help, NULL, NULL, &disk_description }; @@ -406,7 +405,7 @@ uint8 disk_preio(UNIT *uptr, uint16 chan) DEVICE *dptr = find_dev_from_unit(uptr); int unit = (uptr - dptr->units); - if ((uptr->u3 & 0xff00) != 0) { /* just return if busy */ + if ((uptr->CMD & 0xff00) != 0) { /* just return if busy */ return SNS_BSY; } @@ -416,23 +415,23 @@ uint8 disk_preio(UNIT *uptr, uint16 chan) uint8 disk_startcmd(UNIT *uptr, uint16 chan, uint8 cmd) { - uint16 addr = GET_UADDR(uptr->u3); + uint16 addr = GET_UADDR(uptr->CMD); DEVICE *dptr = find_dev_from_unit(uptr); int unit = (uptr - dptr->units); uint8 ch; - sim_debug(DEBUG_CMD, dptr, "disk_startcmd unit %d cmd %x u3 %x\n", unit, cmd, uptr->u3); + sim_debug(DEBUG_CMD, dptr, "disk_startcmd unit %d cmd %x CMD %x\n", unit, cmd, uptr->CMD); if ((uptr->flags & UNIT_ATT) == 0) { /* unit attached status */ - uptr->u5 |= SNS_INTVENT; /* unit intervention required */ + uptr->SNS |= SNS_INTVENT; /* unit intervention required */ if (cmd != DSK_SNS) /* we are completed with unit check status */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; } - if ((uptr->u3 & DSK_CMDMSK) != 0) { - uptr->u3 |= DSK_BUSY; /* Flag we we are busy */ + if ((uptr->CMD & DSK_CMDMSK) != 0) { + uptr->CMD |= DSK_BUSY; /* Flag we we are busy */ return SNS_BSY; } - if ((uptr->u3 & 0xff00) != 0) { /* if any status info, we are busy */ + if ((uptr->CMD & 0xff00) != 0) { /* if any status info, we are busy */ return SNS_BSY; } sim_debug(DEBUG_CMD, dptr, "disk_startcmd CMD continue unit=%d %02x\n", unit, cmd); @@ -441,56 +440,65 @@ uint8 disk_startcmd(UNIT *uptr, uint16 chan, uint8 cmd) if (cmd == DSK_SNS) { /* not attached, is cmd Sense 0x04 */ dosns: sim_debug(DEBUG_CMD, dptr, "disk_startcmd CMD sense\n"); - /* bytes 0,1 - Cyl entry from STAR reg in u4 */ - ch = (uptr->u4 >> 24) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b0 unit=%d 1 %x\n", unit, ch); + /* bytes 0,1 - Cyl entry from STAR reg in STAR */ + ch = (uptr->STAR >> 24) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b0 unit=%d 1 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - ch = (uptr->u4 >> 16) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b1 unit=%d 1 %x\n", unit, ch); + ch = (uptr->STAR >> 16) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b1 unit=%d 1 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - /* byte 2 - Track entry from STAR reg in u4 */ - ch = (uptr->u4 >> 8) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b2 unit=%d 1 %x\n", unit, ch); + /* byte 2 - Track entry from STAR reg in STAR */ + ch = (uptr->STAR >> 8) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b2 unit=%d 1 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - /* byte 3 - Sector entry from STAR reg in u4 */ - ch = (uptr->u4) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b3 unit=%d 1 %x\n", unit, ch); + /* byte 3 - Sector entry from STAR reg in STAR */ + ch = (uptr->STAR) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense STAR b3 unit=%d 1 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - /* bytes 4 - mode reg, byte 0 of u5 */ - ch = (uptr->u5 >> 24) & 0xff; /* return the sense data for device */ - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 1 %x\n", unit, ch); + /* bytes 4 - mode reg, byte 0 of SNS */ + ch = (uptr->SNS >> 24) & 0xff; /* return the sense data for device */ + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 1 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - /* bytes 5-7 - status bytes, bytes 1-3 of u5 */ - ch = (uptr->u5 >> 16) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 2 %x\n", unit, ch); + /* bytes 5-7 - status bytes, bytes 1-3 of SNS */ + ch = (uptr->SNS >> 16) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 2 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - ch = (uptr->u5 >> 8) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 3 %x\n", unit, ch); + ch = (uptr->SNS >> 8) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 3 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - ch = (uptr->u5) & 0xff; - sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 4 %x\n", unit, ch); + ch = (uptr->SNS) & 0xff; + sim_debug(DEBUG_DETAIL, dptr, "disk_startcmd sense unit=%d 4 %x\n", + unit, ch); chan_write_byte(addr, &ch) ; - /* bytes 8-11 - drive attribute register (DATR) entries from uptr->u6 via INCH cmd */ - ch = (uptr->u6 >> 24) & 0xff; + /* bytes 8-11 - drive attribute register (DATR) entries from uptr->ATTR via + * INCH cmd */ + ch = (uptr->ATTR >> 24) & 0xff; chan_write_byte(addr, &ch) ; - ch = (uptr->u6 >> 16) & 0xff; + ch = (uptr->ATTR >> 16) & 0xff; chan_write_byte(addr, &ch) ; - ch = (uptr->u6 >> 8 ) & 0xff; + ch = (uptr->ATTR >> 8 ) & 0xff; chan_write_byte(addr, &ch) ; - ch = (uptr->u6 >> 0) & 0xff; + ch = (uptr->ATTR >> 0) & 0xff; chan_write_byte(addr, &ch) ; /* bytes 12 & 13 contain drive related status */ ch = 0; /* zero for now */ chan_write_byte(addr, &ch) ; chan_write_byte(addr, &ch) ; - uptr->u5 &= 0xff000000; /* clear status bytes, but leave mode data */ + uptr->SNS &= 0xff000000; /* clear status bytes, but leave mode data */ return SNS_CHNEND|SNS_DEVEND; } if (cmd == 0x0) /* INCH cmd gives unit check here */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; - - uptr->u5 |= (SNS_INTVENT|SNS_CMDREJ); /* set new error status */ + + uptr->SNS |= (SNS_INTVENT|SNS_CMDREJ); /* set new error status */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; /* we done */ } @@ -499,72 +507,77 @@ dosns: case DSK_INCH: /* INCH 0x00 */ { - uint32 mema; /* memory address */ + uint32 mema; /* memory address */ uint32 i; UNIT *up = dptr->units; /* first unit for this device */ - sim_debug(DEBUG_CMD, dptr, "disk_startcmd starting inch cmd addr %x u4 %x\n", addr, uptr->u4); - /* u4 has IOCD word 1 contents. For the disk processor it contains */ + sim_debug(DEBUG_CMD, dptr, "disk_startcmd starting inch cmd addr %x STAR %x\n", + addr, uptr->STAR); + /* STAR has IOCD word 1 contents. For the disk processor it contains */ /* a pointer to the INCH buffer followed by 8 drive attribute words that */ /* contains the flags, sector count, MHD head count, and FHD count */ /* us9 has the byte count from IOCD wd2 and should be 0x24 (36) */ - /* the INCH buffer address must be returned in u4 and us9 left non-zero */ + /* the INCH buffer address must be returned in STAR and us9 left non-zero */ /* just return OK and channel software will use up8 as status buffer */ - mema = (uint32)uptr->u4; /* get memory address of buffer */ - uptr->u4 = M[mema>>2]; /* get status buffer address for XIO return status */ - sim_debug(DEBUG_CMD, dptr, "disk_startcmd starting inch cmd addr %x u4 %x mema %x units %d\n", - addr, uptr->u4, mema, dptr->numunits); + mema = (uint32)uptr->STAR; /* get memory address of buffer */ + uptr->STAR = M[mema>>2]; /* get status buffer address for XIO return status */ + sim_debug(DEBUG_CMD, dptr, + "disk_startcmd starting inch cmd addr %x STAR %x mema %x units %d\n", + addr, uptr->STAR, mema, dptr->numunits); /* the next 8 words have drive data for each unit */ /* WARNING 8 drives must be defined for this controller */ /* so we will not have a map fault */ for (i=0; inumunits && i<8; i++) { /* process all drives */ - up->u6 = M[(mema>>2)+i+1]; /* save each unit's drive data */ + up->ATTR = M[(mema>>2)+i+1]; /* save each unit's drive data */ up++; /* next unit for this device */ } sim_debug(DEBUG_CMD, dptr, "disk_startcmd done inch cmd addr %x\n", addr); - uptr->u3 |= DSK_CMDMSK; /* use 0xff for inch, just need int */ + uptr->CMD |= DSK_CMDMSK; /* use 0xff for inch, just need int */ sim_activate(uptr, 20); /* start things off */ return 0; } case DSK_SCK: /* Seek command 0x07 */ case DSK_XEZ: /* Rezero & Read IPL record 0x1f */ - uptr->u3 &= ~(DSK_STAR); /* show we do not have seek STAR in u4 */ + uptr->CMD &= ~(DSK_STAR); /* show we do not have seek STAR in STAR */ case DSK_WD: /* Write command 0x01 */ case DSK_RD: /* Read command 0x02 */ case DSK_LMR: /* read mode register */ - uptr->u3 |= cmd; /* save cmd */ - sim_debug(DEBUG_CMD, dptr, "disk_startcmd starting disk seek r/w cmd %x addr %x\n", cmd, addr); - sim_activate(uptr, 20); /* start things off */ + uptr->CMD |= cmd; /* save cmd */ + sim_debug(DEBUG_CMD, dptr, + "disk_startcmd starting disk seek r/w cmd %x addr %x\n", cmd, addr); + sim_activate(uptr, 20); /* start things off */ return 0; case DSK_NOP: /* NOP 0x03 */ - uptr->u3 |= cmd; /* save cmd */ - sim_activate(uptr, 20); /* start things off */ + uptr->CMD |= cmd; /* save cmd */ + sim_activate(uptr, 20); /* start things off */ return 0; case DSK_SNS: /* Sense 0x04 */ - uptr->u3 |= cmd; /* save cmd */ - sim_activate(uptr, 20); /* start things off */ -// goto dosns; /* use code above */ + uptr->CMD |= cmd; /* save cmd */ + sim_activate(uptr, 20); /* start things off */ break; } - sim_debug(DEBUG_CMD, dptr, "disk_startcmd done with disk_startcmd %x addr %x u5 %x\n", cmd, addr, uptr->u5); - if (uptr->u5 & 0xff) /* any other cmd is error */ + sim_debug(DEBUG_CMD, dptr, + "disk_startcmd done with disk_startcmd %x addr %x SNS %x\n", + cmd, addr, uptr->SNS); + if (uptr->SNS & 0xff) /* any other cmd is error */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; - sim_activate(uptr, 20); /* start things off */ + sim_activate(uptr, 20); /* start things off */ return SNS_CHNEND|SNS_DEVEND; } /* Handle processing of disk requests. */ t_stat disk_srv(UNIT * uptr) { - uint16 chsa = GET_UADDR(uptr->u3); + uint16 chsa = GET_UADDR(uptr->CMD); DEVICE *dptr = find_dev_from_unit(uptr); - DIB *dibp = (DIB *)dptr->ctxt; /* get pointer to Dev Info Blk for this device */ + DIB *dibp = (DIB *)dptr->ctxt; + /* get pointer to Dev Info Blk for this device */ CHANP *chp = (CHANP *)dibp->chan_prg; /* get pointer to channel program */ - struct ddata_t *data = (struct ddata_t *)(uptr->up7); - int cmd = uptr->u3 & DSK_CMDMSK; + struct ddata_t *data = (struct ddata_t *)(uptr->DDATA); + int cmd = uptr->CMD & DSK_CMDMSK; int type = GET_TYPE(uptr->flags); int count = data->count; uint32 trk, cyl; @@ -574,35 +587,35 @@ t_stat disk_srv(UNIT * uptr) uint8 buf2[768]; uint8 buf[768]; - sim_debug(DEBUG_DETAIL, &dda_dev, "disk_srv entry unit %d cmd %x chsa %x chan %x count %x\n", - unit, cmd, chsa, chsa>>8, chp->ccw_count); + sim_debug(DEBUG_DETAIL, &dda_dev, + "disk_srv entry unit %d cmd %x chsa %x chan %x count %x\n", + unit, cmd, chsa, chsa>>8, chp->ccw_count); -// if ((uptr->flags & UNIT_ATT) == 0) { /* unit attached status */ -// return SCPE_OK; -// } - if ((uptr->flags & UNIT_ATT) == 0) { /* unit attached status */ - uptr->u5 |= SNS_INTVENT; /* unit intervention required */ - if (cmd != DSK_SNS) /* we are completed with unit check status */ + if ((uptr->flags & UNIT_ATT) == 0) { /* unit attached status */ + uptr->SNS |= SNS_INTVENT; /* unit intervention required */ + if (cmd != DSK_SNS) /* we are completed with unit check status */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; } - sim_debug(DEBUG_CMD, dptr, "disk_srv cmd=%x chsa %04x count %x\n", cmd, chsa, chp->ccw_count); + sim_debug(DEBUG_CMD, dptr, "disk_srv cmd=%x chsa %04x count %x\n", + cmd, chsa, chp->ccw_count); switch (cmd) { case 0: /* No command, stop disk */ break; case DSK_CMDMSK: /* use 0xff for inch, just need int */ case DSK_NOP: /* NOP 0x03 */ - uptr->u3 &= ~(0xffff); /* remove old cmd */ - sim_debug(DEBUG_CMD, dptr, "disk_srv cmd=%x chsa %04x count %x completed\n", cmd, chsa, chp->ccw_count); + uptr->CMD &= ~(0xffff); /* remove old cmd */ + sim_debug(DEBUG_CMD, dptr, "disk_srv cmd=%x chsa %04x count %x completed\n", + cmd, chsa, chp->ccw_count); chan_end(chsa, SNS_CHNEND|SNS_DEVEND); /* return OK */ break; case DSK_SNS: /* 0x4 */ - ch = uptr->u5 & 0xff; + ch = uptr->SNS & 0xff; sim_debug(DEBUG_DETAIL, dptr, "dsk_srv sense unit=%d 1 %x\n", unit, ch); chan_write_byte(chsa, &ch) ; - ch = (uptr->u5 >> 8) & 0xff; + ch = (uptr->SNS >> 8) & 0xff; sim_debug(DEBUG_DETAIL, dptr, "dsk_srv sense unit=%d 2 %x\n", unit, ch); chan_write_byte(chsa, &ch) ; ch = 0; @@ -612,30 +625,31 @@ t_stat disk_srv(UNIT * uptr) sim_debug(DEBUG_DETAIL, dptr, "dsk_srv sense unit=%d 4 %x\n", unit, ch); chan_write_byte(chsa, &ch) ; ch = 4; - uptr->u3 &= ~(0xff00); + uptr->CMD &= ~(0xff00); chan_end(chsa, SNS_CHNEND|SNS_DEVEND); break; case DSK_SCK: /* Seek cylinder, track, sector 0x07 */ /* If we are waiting on seek to finish, check if there yet. */ - if (uptr->u3 & DSK_SEEKING) { + if (uptr->CMD & DSK_SEEKING) { /* see if on cylinder yet */ - if ((uptr->u4 >> 16) == data->cyl) { + if ((uptr->STAR >> 16) == data->cyl) { /* we are on cylinder, seek is done */ sim_debug(DEBUG_CMD, dptr, "dsk_srv seek on cylinder unit=%d %d %d\n", - unit, uptr->u4 >> 16, data->cyl); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + unit, uptr->STAR >> 16, data->cyl); + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ set_devattn(chsa, SNS_DEVEND); /* start the operation */ sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek end unit=%d %x %x\n", - unit, uptr->u4 >> 16, data->cyl); + unit, uptr->STAR >> 16, data->cyl); sim_activate(uptr, 20); break; } else { /* Compute delay based of difference. */ /* Set next state = index */ - i = (uptr->u4 >> 16) - data->cyl; - sim_debug(DEBUG_CMD, dptr, "dsk_srv seek unit=%d %x %x\n", unit, uptr->u4 >> 16, i); + i = (uptr->STAR >> 16) - data->cyl; + sim_debug(DEBUG_CMD, dptr, "dsk_srv seek unit=%d %x %x\n", unit, + uptr->STAR >> 16, i); if (i > 0 ) { if (i > 50) { data->cyl += 50; /* seek 50 cyl */ @@ -665,7 +679,8 @@ t_stat disk_srv(UNIT * uptr) if (data->cyl < 0) /* test for less than zero */ data->cyl = 0; /* make zero */ } - sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek next unit=%d %d %d\n", unit, uptr->u4 >> 16, + sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek next unit=%d %d %d\n", + unit, uptr->STAR >> 16, data->cyl); sim_activate(uptr, 2); break; @@ -677,8 +692,8 @@ t_stat disk_srv(UNIT * uptr) for (i = 0; i < 4; i++) { if (chan_read_byte(chsa, &buf[i])) { /* we have error, bail out */ - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ - uptr->u5 |= SNS_CMDREJ|SNS_EQUCHK; + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ + uptr->SNS |= SNS_CMDREJ|SNS_EQUCHK; chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } @@ -686,25 +701,30 @@ t_stat disk_srv(UNIT * uptr) rezero: sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek unit=%d star %02d%02d %02d %02d\n", unit, buf[0], buf[1], buf[2], buf[3]); - /* save STAR (target sector) data in u4 */ - uptr->u4 = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); - cyl = uptr->u4 >> 16; /* get the cylinder */ + /* save STAR (target sector) data in STAR */ + uptr->STAR = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | (buf[3]); + cyl = uptr->STAR >> 16; /* get the cylinder */ trk = buf[2]; /* get the track */ - sim_debug(DEBUG_DETAIL, dptr, "dsk_srv SEEK cyl %d trk %d sec %d unit=%d\n", cyl&0xffff, trk, buf[3], unit); + sim_debug(DEBUG_DETAIL, dptr, + "dsk_srv SEEK cyl %d trk %d sec %d unit=%d\n", cyl&0xffff, trk, buf[3], unit); /* FIXME do something with FHD here */ /* Check if seek valid */ - if (cyl > disk_type[type].cyl || trk >= disk_type[type].nhds || buf[3] > disk_type[type].spt) { - sim_debug(DEBUG_CMD, dptr, "dsk_srv seek ERROR cyl %x trk %x sec %x unit=%d\n", cyl, trk, buf[3], unit); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ - uptr->u5 |= SNS_CMDREJ|SNS_EQUCHK; /* set error status */ + if (cyl > disk_type[type].cyl || + trk >= disk_type[type].nhds || + buf[3] > disk_type[type].spt) { + sim_debug(DEBUG_CMD, dptr, + "dsk_srv seek ERROR cyl %x trk %x sec %x unit=%d\n", + cyl, trk, buf[3], unit); + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ + uptr->SNS |= SNS_CMDREJ|SNS_EQUCHK; /* set error status */ /* we have an error, tell user */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); /* end command */ break; } - uptr->u3 |= DSK_STAR; /* show we have seek STAR in u4 */ + uptr->CMD |= DSK_STAR; /* show we have seek STAR in STAR */ /* calc the sector address of data */ /* calculate file position in bytes of requested sector */ data->tstart = (cyl * disk_type[type].nhds * data->tsize) + @@ -713,22 +733,25 @@ rezero: data->spos = buf[3]; /* save the sector number */ data->count = 0; /* no data seen yet */ data->rec = 0; /* number of bytes in this sector */ - sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek start %x trk %x sec %x\n", data->tstart, trk, buf[3]); + sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek start %x trk %x sec %x\n", + data->tstart, trk, buf[3]); if ((sim_fseek(uptr->fileref, data->tstart, SEEK_SET)) != 0) { /* seek home */ sim_debug(DEBUG_DETAIL, dptr, "dsk_srv Error on seek to %x\n", data->tstart); } - /* Check if already on correct cylinder */ - if (trk != data->cyl) { + /* Check if already on correct cylinder */ + if (trk != data->cyl) { /* Do seek */ - uptr->u3 |= DSK_SEEKING; /* show we are seeking */ - sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek unit=%d trk %x cyl %x\n", unit, trk, data->cyl); + uptr->CMD |= DSK_SEEKING; /* show we are seeking */ + sim_debug(DEBUG_DETAIL, dptr, "dsk_srv seek unit=%d trk %x cyl %x\n", + unit, trk, data->cyl); sim_activate(uptr, 20); chan_end(chsa, SNS_CHNEND); } else { sim_debug(DEBUG_DETAIL, dptr, - "dsk_srv calc sect addr seek start %x trk %x sec %x\n", data->tstart, trk, buf[3]); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + "dsk_srv calc sect addr seek start %x trk %x sec %x\n", + data->tstart, trk, buf[3]); + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ sim_activate(uptr, 20); chan_end(chsa, SNS_DEVEND|SNS_CHNEND); } @@ -738,16 +761,16 @@ rezero: sim_debug(DEBUG_CMD, dptr, "RD REZERO IPL unit=%d seek 0\n", unit); /* Do a seek to 0 */ - uptr->u4 = 0; /* set STAR to 0, 0, 0 */ - uptr->u3 &= ~(0xffff); /* remove old cmd */ - uptr->u3 |= DSK_SCK; /* show as seek command */ + uptr->STAR = 0; /* set STAR to 0, 0, 0 */ + uptr->CMD &= ~(0xffff); /* remove old cmd */ + uptr->CMD |= DSK_SCK; /* show as seek command */ data->tstart = 0; /* byte offset is 0 */ data->dlen = 0; /* no data written yet */ /* Read in 1 dummy character for length to inhibit SLI posting */ if (chan_read_byte(chsa, &buf[0])) { /* we have error, bail out */ - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ - uptr->u5 |= SNS_CMDREJ|SNS_EQUCHK; + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ + uptr->SNS |= SNS_CMDREJ|SNS_EQUCHK; chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } @@ -761,38 +784,40 @@ rezero: /* Read in 1 character of mode data */ if (chan_read_byte(chsa, &buf[0])) { /* we have error, bail out */ - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ - uptr->u5 |= SNS_CMDREJ|SNS_EQUCHK; + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ + uptr->SNS |= SNS_CMDREJ|SNS_EQUCHK; chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } - uptr->u3 &= ~(0xffff); /* remove old cmd */ - uptr->u5 &= 0x00ffffff; /* clear old mode data */ - uptr->u5 |= (buf[0] << 24); /* save mode value */ + uptr->CMD &= ~(0xffff); /* remove old cmd */ + uptr->SNS &= 0x00ffffff; /* clear old mode data */ + uptr->SNS |= (buf[0] << 24);/* save mode value */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND); break; case DSK_RD: /* Read Data */ /* data->tstart has start of sector address in bytes */ - if ((uptr->u3 & DSK_READING) == 0) { /* see if we are reading data */ - uptr->u3 |= DSK_READING; /* read from disk starting */ - data->dlen = 0; /* no data read yet */ + if ((uptr->CMD & DSK_READING) == 0) { /* see if we are reading data */ + uptr->CMD |= DSK_READING; /* read from disk starting */ + data->dlen = 0; /* no data read yet */ sim_debug(DEBUG_CMD, dptr, - "DISK READ starting unit=%d u3 %x count %d rec %d\n", unit, uptr->u3, count, data->rec); + "DISK READ starting unit=%d CMD %x count %d rec %d\n", + unit, uptr->CMD, count, data->rec); } - if (uptr->u3 & DSK_READING) { /* see if we are reading data */ + if (uptr->CMD & DSK_READING) { /* see if we are reading data */ /* read in a sector of data from disk */ if ((count=sim_fread(buf, 1, data->ssize, uptr->fileref)) != data->ssize) { - sim_debug(DEBUG_CMD, dptr, "Error %d on read %d of diskfile cyl %d hds %d sec %d\n", - count, data->ssize, data->cyl, data->tpos, data->spos); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ -// sim_activate(uptr, 20); + sim_debug(DEBUG_CMD, dptr, + "Error %d on read %d of diskfile cyl %d hds %d sec %d\n", + count, data->ssize, data->cyl, data->tpos, data->spos); + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } - sim_debug(DEBUG_CMD, dptr, "disk_srv after READ chsa %04x count %x\n", chsa, chp->ccw_count); + sim_debug(DEBUG_CMD, dptr, + "disk_srv after READ chsa %04x count %x\n", chsa, chp->ccw_count); /* process the next sector of data */ data->rec = count; /* no bytes in sector yet */ count = 0; /* used here as a flag for short write */ @@ -800,17 +825,18 @@ rezero: ch = buf[i]; /* get a char from buffer */ if (chan_write_byte(chsa, &ch)) { /* put a byte to memory */ sim_debug(DEBUG_DATAIO, dptr, - "DISK Read %d bytes from dskfile cyl %d hds %d sec %d tstart %x\r\n", - data->dlen+i, data->cyl, data->tpos, data->spos, data->tstart); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + "DISK Read %d bytes from dskfile cyl %d hds %d sec %d tstart %x\n", + data->dlen+i, data->cyl, data->tpos, data->spos, data->tstart); + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND); - goto rddone; } + goto rddone; + } } data->dlen += data->rec; /* add byte read to total count */ sim_debug(DEBUG_CMD, dptr, - "DISK READ from sec end %d bytes end %d from diskfile cyl %d hds %d sec %d tstart %x\n", - data->dlen, data->ssize, data->cyl, data->tpos, data->spos, data->tstart); +"DISK READ from sec end %d bytes end %d from diskfile cyl %d hds %d sec %d tstart %x\n", + data->dlen, data->ssize, data->cyl, data->tpos, data->spos, data->tstart); data->spos++; /* set sector to read next one */ if (data->spos >= (disk_type[type].spt)) { @@ -821,10 +847,7 @@ rezero: data->cyl++; /* cylinder position */ if (data->cyl >= (disk_type[type].cyl)) { /* EOM reached, abort */ -// sim_debug(DEBUG_CMD, dptr, "Error %d on read %d from diskfile cyl %d hds %d sec %d\n", -// i, data->ssize, data->cyl, data->tpos, data->spos); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ -// sim_activate(uptr, 20); + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } @@ -833,13 +856,12 @@ rezero: /* see if we are done reading data */ if (test_write_byte_end(chsa)) { sim_debug(DEBUG_DATAIO, dptr, - "DISK Read complete Read %d bytes from diskfile cyl %d hds %d sec %d tstart %x\n", + "DISK Read complete Read %d bytes from diskfile cyl %d hds %d sec %d tstart %x\n", data->dlen, data->cyl, data->tpos, data->spos, data->tstart); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND); } rddone: -// sim_activate(uptr, 20); sim_activate(uptr, 10); /* wait to read next sector */ break; } @@ -847,13 +869,14 @@ rddone: case DSK_WD: /* Write Data */ /* data->tstart has start of sector address in bytes */ - if ((uptr->u3 & DSK_WRITING) == 0) { /* see if we are writing data */ - uptr->u3 |= DSK_WRITING; /* write to disk starting */ + if ((uptr->CMD & DSK_WRITING) == 0) { /* see if we are writing data */ + uptr->CMD |= DSK_WRITING; /* write to disk starting */ data->dlen = 0; /* no data written yet */ - sim_debug(DEBUG_CMD, dptr, "DISK WRITE starting unit=%d u3 %x bytes %d rec %d\n", - unit, uptr->u3, data->dlen, data->rec); + sim_debug(DEBUG_CMD, dptr, + "DISK WRITE starting unit=%d CMD %x bytes %d rec %d\n", + unit, uptr->CMD, data->dlen, data->rec); } - if (uptr->u3 & DSK_WRITING) { /* see if we are writing data */ + if (uptr->CMD & DSK_WRITING) { /* see if we are writing data */ /* process the next sector of data */ data->rec = 0; /* no bytes in sector yet */ count = 0; /* used here as a flag for short read */ @@ -861,9 +884,9 @@ rddone: if (chan_read_byte(chsa, &ch)) { /* get a byte from memory */ /* if error on reading 1st byte, we are done writing */ if (i == 0) { - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ sim_debug(DEBUG_CMD, dptr, - "DISK Wrote %d bytes to diskfile cyl %d hds %d sec %d tstart %x\n", + "DISK Wrote %d bytes to diskfile cyl %d hds %d sec %d tstart %x\n", data->dlen, data->cyl, data->tpos, data->spos, data->tstart); chan_end(chsa, SNS_CHNEND|SNS_DEVEND); goto wrdone; @@ -876,9 +899,10 @@ rddone: data->dlen += data->ssize; /* add 1 sector of bytes */ /* write the sector to disk */ if ((i=sim_fwrite(buf2, 1, data->ssize, uptr->fileref)) != data->ssize) { - sim_debug(DEBUG_CMD, dptr, "Error %d on write %d to diskfile cyl %d hds %d sec %d\n", + sim_debug(DEBUG_CMD, dptr, + "Error %d on write %d to diskfile cyl %d hds %d sec %d\n", i, data->ssize, data->cyl, data->tpos, data->spos); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } @@ -886,13 +910,13 @@ rddone: sim_debug(DEBUG_DATAIO, dptr, "DISK WroteB %d bytes to diskfile cyl %d hds %d sec %d tstart %x\n", data->dlen, data->cyl, data->tpos, data->spos, data->tstart); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND); /* we done */ break; } sim_debug(DEBUG_CMD, dptr, - "DISK WR to sec end %d bytes end %d to diskfile cyl %d hds %d sec %d tstart %x\n", - data->dlen, data->ssize, data->cyl, data->tpos, data->spos, data->tstart); + "DISK WR to sec end %d bytes end %d to diskfile cyl %d hds %d sec %d tstart %x\n", + data->dlen, data->ssize, data->cyl, data->tpos, data->spos, data->tstart); data->spos++; if (data->spos >= (disk_type[type].spt)) { data->spos = 0; /* number of sectors per track */ @@ -902,16 +926,16 @@ rddone: data->cyl++; /* cylinder position */ if (data->cyl >= (disk_type[type].cyl)) { /* EOM reached, abort */ - sim_debug(DEBUG_DETAIL, dptr, "Error %d on write %d to diskfile cyl %d hds %d sec %d\n", + sim_debug(DEBUG_DETAIL, dptr, + "Error %d on write %d to diskfile cyl %d hds %d sec %d\n", i, data->ssize, data->cyl, data->tpos, data->spos); - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } } } wrdone: -// sim_activate(uptr, 20); sim_activate(uptr, 10); break; } @@ -919,12 +943,13 @@ wrdone: default: sim_debug(DEBUG_DETAIL, dptr, "invalid command=%d %x\n", unit, cmd); - uptr->u5 |= SNS_CMDREJ; - uptr->u3 &= ~(0xffff); /* remove old status bits & cmd */ + uptr->SNS |= SNS_CMDREJ; + uptr->CMD &= ~(0xffff); /* remove old status bits & cmd */ chan_end(chsa, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } - sim_debug(DEBUG_DETAIL, dptr, "disk_srv done cmd=%x chsa %04x count %x\n", cmd, chsa, chp->ccw_count); + sim_debug(DEBUG_DETAIL, dptr, "disk_srv done cmd=%x chsa %04x count %x\n", + cmd, chsa, chp->ccw_count); return SCPE_OK; } @@ -934,13 +959,13 @@ void disk_ini(UNIT *uptr, t_bool f) DEVICE *dptr = find_dev_from_unit(uptr); int i = GET_TYPE(uptr->flags); - uptr->u3 &= ~0xffff; /* clear out the flags but leave ch/sa */ + uptr->CMD &= ~0xffff; /* clear out the flags but leave ch/sa */ /* capacity is total allocation units time sectors per allocation unit */ /* total sectors on disk */ uptr->capac = disk_type[i].taus * disk_type[i].spau; sim_debug(DEBUG_EXP, &dda_dev, "DMA init device %s on unit DMA%.1x cap %x\n", - dptr->name, GET_UADDR(uptr->u3), uptr->capac); + dptr->name, GET_UADDR(uptr->CMD), uptr->capac); } t_stat disk_reset(DEVICE * dptr) @@ -949,59 +974,10 @@ t_stat disk_reset(DEVICE * dptr) return SCPE_OK; } -/* create the disk file for the specified device */ -int disk_format(UNIT *uptr) { - struct ddata_t *data = (struct ddata_t *)uptr->up7; - uint16 addr = GET_UADDR(uptr->u3); - int type = GET_TYPE(uptr->flags); - DEVICE *dptr = find_dev_from_unit(uptr); - uint16 tsize = data->tsize; /* get track size in bytes */ - uint16 cyl; - uint16 hds; - uint16 spc = disk_type[type].nhds * disk_type[type].spt; /* sectors/cyl */ - uint8 *buff; - - /* see if user wants to initialize the disk */ - if (!get_yn("Initialize disk? [Y] ", TRUE)) { - return 1; - } - - /* seek to sector 0 */ - if ((sim_fseek(uptr->fileref, 0, SEEK_SET)) != 0) { /* seek home */ - fprintf(stderr, "Error on seek to 0\r\n"); - } - - /* get buffer for track data */ - if ((buff = (uint8 *)calloc(tsize, sizeof(uint8))) == 0) { - detach_unit(uptr); - return SCPE_ARG; - } - sim_debug(DEBUG_CMD, dptr, "Creating disk file of capacity %d\n", - data->tsize * disk_type[type].cyl * disk_type[type].nhds); - /* write zeros to each track of the disk */ - for (cyl = 0; cyl < disk_type[type].cyl; cyl++) { - for (hds=0; hds < disk_type[type].nhds; hds++) { - if ((sim_fwrite(buff, 1, data->tsize, uptr->fileref)) != data->tsize) { - sim_debug(DEBUG_CMD, dptr, "Error on write to diskfile cyl %d hds %d\n", cyl, hds); - } - } - if ((cyl % 20) == 0) - fputc('.', stderr); - } - /* seek home again */ - sim_fseek(uptr->fileref, 0, SEEK_SET); /* seek home */ - free(buff); /* free cylinder buffer */ - data->cpos = 0; - data->ccyl = 0; - set_devattn(addr, SNS_DEVEND); /* start us up */ -// sim_activate(uptr, 100); - return 0; -} - /* attach the selected file to the disk */ t_stat disk_attach(UNIT *uptr, CONST char *file) { - uint16 addr = GET_UADDR(uptr->u3); + uint16 addr = GET_UADDR(uptr->CMD); int type = GET_TYPE(uptr->flags); DEVICE *dptr = find_dev_from_unit(uptr); t_stat r; @@ -1009,7 +985,6 @@ t_stat disk_attach(UNIT *uptr, CONST char *file) uint16 ssize; /* sector size in bytes */ struct ddata_t *data; uint8 buff[1024]; -// int i; /* have simulator attach the file to the unit */ if ((r = attach_unit(uptr, file)) != SCPE_OK) @@ -1027,39 +1002,19 @@ t_stat disk_attach(UNIT *uptr, CONST char *file) return SCPE_FMT; } - uptr->up7 = (void *)data; /* save pointer to structure in up7 */ + uptr->DDATA = (void *)data; /* save pointer to structure in DDATA */ /* track size in bytes is sectors/track times words/sector time 4 bytse/word */ tsize = disk_type[type].spt * disk_type[type].ssiz * 4; /* get track size in bytes */ data->tsize = tsize; /* save size of track in bytes */ - uptr->capac = disk_type[type].taus * disk_type[type].spau; /* disk capacity in sectors */ + uptr->capac = disk_type[type].taus * disk_type[type].spau; + /* disk capacity in sectors */ ssize = disk_type[type].ssiz * 4; /* disk sector size in bytes */ uptr->capac *= ssize; /* disk capacity in bytes */ data->ssize = ssize; /* save sector size bytes */ sim_debug(DEBUG_CMD, dptr, "Disk taus %d spau %d ssiz %d cap %d\n", - disk_type[type].taus, disk_type[type].spau, disk_type[type].ssiz * 4, uptr->capac); /* disk capacity */ - - if ((sim_fseek(uptr->fileref, 0, SEEK_SET)) != 0) { /* seek home */ - detach_unit(uptr); /* if no space, error */ - return SCPE_FMT; /* error */ - } - - /* read in the 1st sector of the 'disk' */ - if ((r = sim_fread(&buff[0], sizeof(uint8), ssize, uptr->fileref) != ssize)) { - sim_debug(DEBUG_CMD, &dda_dev, "Disk format fread ret = %x\n", r); - goto fmt; - } - - if ((buff[0] | buff[1] | buff[2] | buff[3]) == 0) { - sim_debug(DEBUG_CMD, &dda_dev, "Disk format buf0 %x buf1 %x buf2 %x buf3 %x\n", - buff[0], buff[1], buff[2], buff[3]); -fmt: - /* format the drive */ - if (disk_format(uptr)) { - detach_unit(uptr); /* if no space, error */ - return SCPE_FMT; /* error */ - } - } + disk_type[type].taus, disk_type[type].spau, disk_type[type].ssiz * 4, + uptr->capac); /* disk capacity */ if ((sim_fseek(uptr->fileref, 0, SEEK_SET)) != 0) { /* seek home */ detach_unit(uptr); /* if no space, error */ @@ -1068,46 +1023,38 @@ fmt: data->ssize = ssize; /* save sector size in bytes */ data->tsize = tsize; /* save track size in bytes */ - data->cpos = 0; /* current read/write position in cylinder*/ data->ccyl = 0; /* current cylinder number */ data->tpos = 0; /* current track position */ data->spos = 0; /* current sector position */ data->rec = 0; /* record length */ data->count = 0; /* clear count value */ -// sim_debug(DEBUG_CMD, &dda_dev, "Attach %8s hds %d spt %d spc %d cyl %d capacity %d\n", -// disk_type[type].name, disk_type[type].nhds, disk_type[type].spt, -// disk_type[type].nhds * disk_type[type].spt, -// disk_type[type].cyl, uptr->capac); -// sim_debug(DEBUG_CMD, &dda_dev, "File %s attached to %s\r\n", file, disk_type[type].name); - set_devattn(addr, SNS_DEVEND); -// sim_activate(uptr, 100); return SCPE_OK; } /* detach a disk device */ t_stat disk_detach(UNIT * uptr) { - struct ddata_t *data = (struct ddata_t *)uptr->up7; + struct ddata_t *data = (struct ddata_t *)uptr->DDATA; if (data != 0) { free(data); /* free disk data structure */ } - uptr->up7 = 0; /* no pointer to disk data */ - uptr->u3 &= ~0xffff; /* no cmd and flags */ + uptr->DDATA = 0; /* no pointer to disk data */ + uptr->CMD &= ~0xffff; /* no cmd and flags */ return detach_unit(uptr); /* tell simh we are done with disk */ } /* boot from the specified disk unit */ t_stat disk_boot(int32 unit_num, DEVICE * dptr) { - UNIT *uptr = &dptr->units[unit_num]; /* find disk unit number */ + UNIT *uptr = &dptr->units[unit_num]; /* find disk unit number */ - sim_debug(DEBUG_CMD, &dda_dev, "Disk Boot dev/unit %x\n", GET_UADDR(uptr->u3)); - SPAD[0xf4] = GET_UADDR(uptr->u3); /* put boot device chan/sa into spad */ - SPAD[0xf8] = 0xF000; /* show as F class device */ + sim_debug(DEBUG_CMD, &dda_dev, "Disk Boot dev/unit %x\n", GET_UADDR(uptr->CMD)); + SPAD[0xf4] = GET_UADDR(uptr->CMD); /* put boot device chan/sa into spad */ + SPAD[0xf8] = 0xF000; /* show as F class device */ if ((uptr->flags & UNIT_ATT) == 0) - return SCPE_UNATT; /* attached? */ - return chan_boot(GET_UADDR(uptr->u3), dptr); /* boot the ch/sa */ + return SCPE_UNATT; /* attached? */ + return chan_boot(GET_UADDR(uptr->CMD), dptr); /* boot the ch/sa */ } /* Disk option setting commands */ diff --git a/SEL32/sel32_mt.c b/SEL32/sel32_mt.c index 0fa2510..c3da0da 100644 --- a/SEL32/sel32_mt.c +++ b/SEL32/sel32_mt.c @@ -49,7 +49,7 @@ extern uint32 SPAD[]; /* cpu SPAD */ #ifdef NUM_DEVS_MT #define BUFFSIZE (64 * 1024) -#define UNIT_MT UNIT_ATTABLE | UNIT_DISABLE | UNIT_ROABLE +#define UNIT_MT UNIT_ATTABLE | UNIT_DISABLE | UNIT_ROABLE #define DEV_BUF_NUM(x) (((x) & 07) << DEV_V_UF) #define GET_DEV_BUF(x) (((x) >> DEV_V_UF) & 07) @@ -117,6 +117,7 @@ OTAB EQU $ SPACE 3 #endif +#define CMD u3 /* BTP tape commands */ #define MT_INCH 0x00 /* Initialize channel command */ #define MT_WRITE 0x01 /* Write command */ @@ -142,7 +143,7 @@ OTAB EQU $ #define MT_MDEN_800 0x40 /* =0 select 800 BPI NRZI mode 9 track only */ #define MT_MDEN_1600 0x40 /* =1 select 1600 BPI PE mode 9 track only */ #define MT_MDEN_6250 0x20 /* =0 Use mode from bit one for NRZI/PE */ -#define MT_MDEN_6250 0x20 /* =1 6250 BPI GCR mode 9 track only */ +#define MT_MDEN_6250 0x20 /* =1 6250 BPI GCR mode 9 track only */ #define MT_MDEN_SCATGR 0x01 /* =1 HSTP scatter/gather mode */ #define MT_MDEN_MSK 0xc0 /* Density mask */ @@ -161,8 +162,10 @@ OTAB EQU $ #define MT_CONV 0x4000 /* Data converter on ignored 9 track */ #define MT_BUSY 0x8000 /* Flag to send a CUE */ +#define POS u4 /* in u4 is current buffer position */ +#define SNS u5 /* in u5 packs sense byte 0, 1, 2 and 3 */ /* Sense byte 0 */ #define SNS_CMDREJ 0x80000000 /* Command reject */ @@ -332,8 +335,8 @@ MTAB mt_mod[] = { "Write ring in place"}, {MTUF_WLK, MTUF_WLK, "write locked", "LOCKED", NULL, NULL, NULL, "No write ring in place"}, - {MTAB_XTD|MTAB_VUN|MTAB_VALR, 0, "DENSITY", "DENSITY", - &sim_tape_set_dens, &sim_tape_show_dens, &valid_dens, + {MTAB_XTD|MTAB_VUN|MTAB_VALR, 0, "DENSITY", "DENSITY", + &sim_tape_set_dens, &sim_tape_show_dens, &valid_dens, "Set tape density"}, {MTAB_XTD | MTAB_VUN, 0, "FORMAT", "FORMAT", &sim_tape_set_fmt, &sim_tape_show_fmt, NULL, @@ -359,20 +362,20 @@ UNIT mta_unit[] = { CHANP mta_chp[NUM_UNITS_MT] = {0}; DIB mta_dib = { - NULL, /* uint8 (*pre_io)(UNIT *, uint16)*/ /* Pre Start I/O */ - mt_startcmd, /* uint8 (*start_cmd)(UNIT *, uint16, uint8)*/ /* Start a command */ - NULL, /* uint8 (*halt_io)(UNIT *) */ /* Stop I/O */ - NULL, /* uint8 (*test_io)(UNIT *) */ /* Test I/O */ - NULL, /* uint8 (*post_io)(UNIT *) */ /* Post I/O */ - mt_ini, /* void (*dev_ini)(UNIT *, t_bool) */ /* init function */ - mta_unit, /* UNIT* units */ /* Pointer to units structure */ - mta_chp, /* CHANP* chan_prg */ /* Pointer to chan_prg structure */ - NUM_UNITS_MT, /* uint8 numunits */ /* number of units defined */ - 0xFF, /* uint8 mask */ /* 256 devices - device mask */ - 0x1000, /* uint16 chan_addr */ /* parent channel address */ - 0, /* uint32 chan_fifo_in */ /* fifo input index */ - 0, /* uint32 chan_fifo_out */ /* fifo output index */ - 0, /* uint32 chan_fifo[FIFO_SIZE] */ /* interrupt status fifo for channel */ + NULL, /* Pre Start I/O */ + mt_startcmd, /* Start a command */ + NULL, /* Stop I/O */ + NULL, /* Test I/O */ + NULL, /* Post I/O */ + mt_ini, /* init function */ + mta_unit, /* Pointer to units structure */ + mta_chp, /* Pointer to chan_prg structure */ + NUM_UNITS_MT, /* number of units defined */ + 0xFF, /* 256 devices - device mask */ + 0x1000, /* parent channel address */ + 0, /* fifo input index */ + 0, /* fifo output index */ + 0, /* interrupt status fifo for channel */ }; DEVICE mta_dev = { @@ -401,20 +404,20 @@ UNIT mtb_unit[] = { /* device information block */ DIB mtb_dib = { - NULL, /* uint8 (*pre_io)(UNIT *, uint16)*/ /* Pre Start I/O */ - mt_startcmd, /* uint8 (*start_cmd)(UNIT *, uint16, uint8)*/ /* Start a command */ - NULL, /* uint8 (*halt_io)(UNIT *) */ /* Stop I/O */ - NULL, /* uint8 (*test_io)(UNIT *) */ /* Test I/O */ - NULL, /* uint8 (*post_io)(UNIT *) */ /* Post I/O */ - mt_ini, /* void (*dev_ini)(UNIT *, t_bool) */ /* init function */ - mtb_unit, /* UNIT* units */ /* Pointer to units structure */ - mtb_chp, /* CHANP* chan_prg */ /* Pointer to chan_prg structure */ - NUM_UNITS_MT, /* uint8 numunits */ /* number of units defined */ - 0xFF, /* uint8 mask */ /* 256 devices - device mask */ - 0x1000, /* uint16 chan_addr */ /* parent channel address */ - 0, /* uint32 chan_fifo_in */ /* fifo input index */ - 0, /* uint32 chan_fifo_out */ /* fifo output index */ - 0, /* uint32 chan_fifo[FIFO_SIZE] */ /* interrupt status fifo for channel */ + NULL, /* Pre Start I/O */ + mt_startcmd, /* Start a command */ + NULL, /* Stop I/O */ + NULL, /* Test I/O */ + NULL, /* Post I/O */ + mt_ini, /* init function */ + mtb_unit, /* Pointer to units structure */ + mtb_chp, /* Pointer to chan_prg structure */ + NUM_UNITS_MT, /* number of units defined */ + 0xFF, /* 256 devices - device mask */ + 0x1000, /* parent channel address */ + 0, /* fifo input index */ + 0, /* fifo output index */ + 0, /* interrupt status fifo for channel */ }; DEVICE mtb_dev = { @@ -433,7 +436,7 @@ uint8 mt_startcmd(UNIT *uptr, uint16 chan, uint8 cmd) int unit = (uptr - dptr->units); sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd entry chan %x cmd %x\n", chan, cmd); - if (mt_busy[GET_DEV_BUF(dptr->flags)] != 0 || (uptr->u3 & MT_CMDMSK) != 0) { + if (mt_busy[GET_DEV_BUF(dptr->flags)] != 0 || (uptr->CMD & MT_CMDMSK) != 0) { sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd busy chan %x cmd %x\n", chan, cmd); uptr->flags |= MT_BUSY; /* Flag we need to send CUE */ return SNS_BSY; @@ -442,51 +445,53 @@ uint8 mt_startcmd(UNIT *uptr, uint16 chan, uint8 cmd) sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd processing unit %x cmd %x\n", unit, cmd); switch (cmd & 0xF) { - case 0x0: /* INCH command */ - /* u4 has INCH buffer address and us9 the count */ - /* just return OK and channel software will use u4 as status buffer */ - sim_debug(DEBUG_DETAIL, &mta_dev, "mt_startcmd INCH done unit %x cmd %x\n", unit, cmd); + case 0x0: /* INCH command */ + /* POS has INCH buffer address and us9 the count */ + /* just return OK and channel software will use POS as status buffer */ + sim_debug(DEBUG_DETAIL, &mta_dev, "mt_startcmd INCH done unit %x cmd %x\n", + unit, cmd); /* UTX_needs_interrupt */ - cmd = MT_CMDMSK; /* insert INCH cmd as 0xff */ + cmd = MT_CMDMSK; /* insert INCH cmd as 0xff */ /* fall through */ - case 0x3: /* Tape motion commands */ + case 0x3: /* Tape motion commands */ /* UTX_needs_interrupt */ /* fall through */ - case 0x1: /* Write command */ - case 0x2: /* Read command */ - case 0xc: /* Read backward */ - if (cmd != 0x03) /* if this is a nop do not zero status */ - uptr->u5 = (uptr->u5 & 0x0000ff00); /* clear all but byte 2 */ - uptr->u5 |= (SNS_RDY|SNS_ONLN); /* set ready status */ + case 0x1: /* Write command */ + case 0x2: /* Read command */ + case 0xc: /* Read backward */ + if (cmd != 0x03) /* if this is a nop do not zero status */ + uptr->SNS = (uptr->SNS & 0x0000ff00); /* clear all but byte 2 */ + uptr->SNS |= (SNS_RDY|SNS_ONLN); /* set ready status */ if (sim_tape_wrp(uptr)) - uptr->u5 |= (SNS_WRP); /* write protected */ + uptr->SNS |= (SNS_WRP); /* write protected */ if (sim_tape_bot(uptr)) - uptr->u5 |= (SNS_LOAD); /* tape at load point */ + uptr->SNS |= (SNS_LOAD); /* tape at load point */ if (sim_tape_eot(uptr)) - uptr->u5 |= (SNS_EOT); /* tape at EOM */ + uptr->SNS |= (SNS_EOT); /* tape at EOM */ /* Fall through */ case 0x4: /* Sense */ - uptr->u3 &= ~(MT_CMDMSK); /* clear out last cmd */ - uptr->u3 |= cmd & MT_CMDMSK; /* insert new cmd */ - CLR_BUF(uptr); /* buffer is empty */ - /* INCH cmd has iNCH buffer address in u4, so leave it */ + uptr->CMD &= ~(MT_CMDMSK); /* clear out last cmd */ + uptr->CMD |= cmd & MT_CMDMSK; /* insert new cmd */ + CLR_BUF(uptr); /* buffer is empty */ + /* INCH cmd has iNCH buffer address in POS, so leave it */ if (cmd != MT_CMDMSK) - uptr->u4 = 0; /* reset buffer position pointer */ - sim_activate(uptr, 100); /* Start unit off */ - mt_busy[GET_DEV_BUF(dptr->flags)] = 1; /* show we are busy */ - sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd sense return 0 chan %x cmd %x\n", chan, cmd); + uptr->POS = 0; /* reset buffer position pointer */ + sim_activate(uptr, 100); /* Start unit off */ + mt_busy[GET_DEV_BUF(dptr->flags)] = 1; /* show we are busy */ + sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd sense return 0 chan %x cmd %x\n", + chan, cmd); return 0; default: /* invalid command */ - sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd CMDREJ return chan %d cmd %x\n", chan, cmd); - uptr->u5 |= SNS_CMDREJ; + sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd CMDREJ return chan %d cmd %x\n", chan, cmd); + uptr->SNS |= SNS_CMDREJ; break; } - if (uptr->u5 & 0xff000000) /* errors? */ + if (uptr->SNS & 0xff000000) /* errors? */ return SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK; - sim_debug(DEBUG_EXP, &mta_dev, "mt_startcmd ret CHNEND|DEVEND chan %d unit %x cmd %x\n", - chan, unit, cmd); + sim_debug(DEBUG_EXP, &mta_dev, + "mt_startcmd ret CHNEND|DEVEND chan %d unit %x cmd %x\n", chan, unit, cmd); return SNS_CHNEND|SNS_DEVEND; } @@ -502,17 +507,17 @@ t_stat mt_error(UNIT *uptr, uint16 addr, t_stat r, DEVICE *dptr) case MTSE_TMK: /* tape mark */ sim_debug(DEBUG_CMD, &mta_dev, "FILE MARK\n"); - uptr->u5 |= SNS_FMRKDT; /* file mark detected */ + uptr->SNS |= SNS_FMRKDT; /* file mark detected */ chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; case MTSE_WRP: /* write protected */ - uptr->u5 |= SNS_WRP; /* write protected */ + uptr->SNS |= SNS_WRP; /* write protected */ sim_debug(DEBUG_CMD, &mta_dev, "WRITE PROTECT %d ", r); /* operator intervention */ break; case MTSE_UNATT: /* unattached */ - uptr->u5 |= SNS_INTVENT; /* unit intervention required */ + uptr->SNS |= SNS_INTVENT; /* unit intervention required */ sim_debug(DEBUG_CMD, &mta_dev, "ATTENTION %d ", r); /* operator intervention */ chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITEXP); break; @@ -524,13 +529,13 @@ t_stat mt_error(UNIT *uptr, uint16 addr, t_stat r, DEVICE *dptr) break; case MTSE_BOT: /* beginning of tape */ - uptr->u5 |= SNS_LOAD; /* tape at BOT */ + uptr->SNS |= SNS_LOAD; /* tape at BOT */ sim_debug(DEBUG_CMD, &mta_dev, "BOT "); break; case MTSE_INVRL: /* invalid rec lnt */ case MTSE_EOM: /* end of medium */ - uptr->u5 |= SNS_EOT; /* tape at EOT */ + uptr->SNS |= SNS_EOT; /* tape at EOT */ sim_debug(DEBUG_CMD, &mta_dev, "EOT "); chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITEXP); break; @@ -542,10 +547,10 @@ t_stat mt_error(UNIT *uptr, uint16 addr, t_stat r, DEVICE *dptr) /* Handle processing of tape requests. */ t_stat mt_srv(UNIT *uptr) { - uint16 addr = GET_UADDR(uptr->u3); + uint16 addr = GET_UADDR(uptr->CMD); DEVICE *dptr = find_dev_from_unit(uptr); int unit = (uptr - dptr->units); - int cmd = uptr->u3 & MT_CMDMSK; + int cmd = uptr->CMD & MT_CMDMSK; int bufnum = GET_DEV_BUF(dptr->flags); t_mtrlnt reclen; t_stat r = SCPE_ARG; /* Force error if not set */ @@ -553,7 +558,7 @@ t_stat mt_srv(UNIT *uptr) sim_debug(DEBUG_DATA, &mta_dev, "mt_srv unit %d cmd %x\n", unit, cmd); if ((uptr->flags & UNIT_ATT) == 0) { /* unit attached status */ - uptr->u5 |= SNS_INTVENT; /* unit intervention required */ + uptr->SNS |= SNS_INTVENT; /* unit intervention required */ mt_busy[bufnum] &= ~1; /* make our buffer not busy */ if (cmd != MT_SENSE) { /* we are completed with unit check status */ chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); @@ -562,55 +567,56 @@ t_stat mt_srv(UNIT *uptr) } switch (cmd) { - case MT_CMDMSK: /* 0x0ff for inch 0x00 */ /* INCH is for channel, nothing for us */ - /* uptr->u4 has INCH buffer address, just leave it */ + case MT_CMDMSK: /* 0x0ff for inch 0x00 */ /* INCH is for channel, nothing for us */ + /* uptr->POS has INCH buffer address, just leave it */ sim_debug(DEBUG_CMD, &mta_dev, "mt_srv cmd 0 INCH unit=%d\n", unit); - uptr->u3 &= ~MT_CMDMSK; /* clear the cmd */ - mt_busy[bufnum] &= ~1; /* make our buffer not busy */ - chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ + uptr->CMD &= ~MT_CMDMSK; /* clear the cmd */ + mt_busy[bufnum] &= ~1; /* make our buffer not busy */ + chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ break; - case MT_NOP: /* 0x03 */ /* NOP motion command */ - uptr->u3 &= ~MT_CMDMSK; /* clear the cmd */ - mt_busy[bufnum] &= ~1; /* make our buffer not busy */ - chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ + case MT_NOP: /* 0x03 */ /* NOP motion command */ + uptr->CMD &= ~MT_CMDMSK; /* clear the cmd */ + mt_busy[bufnum] &= ~1; /* make our buffer not busy */ + chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ break; - case MT_SENSE: /* 0x04 */ /* get sense data */ + case MT_SENSE: /* 0x04 */ /* get sense data */ sim_debug(DEBUG_CMD, &mta_dev, "mt_srv cmd 4 SENSE unit=%d\n", unit); - ch = (uptr->u5 >> 24) & 0xff; /* get sense byte 0 status */ + ch = (uptr->SNS >> 24) & 0xff; /* get sense byte 0 status */ sim_debug(DEBUG_DETAIL, &mta_dev, "sense unit %d byte 0 %x\n", unit, ch); - chan_write_byte(addr, &ch); /* write byte 0 */ - ch = (uptr->u5 >> 16) & 0xff; /* get sense byte 1 status */ + chan_write_byte(addr, &ch); /* write byte 0 */ + ch = (uptr->SNS >> 16) & 0xff; /* get sense byte 1 status */ sim_debug(DEBUG_DETAIL, &mta_dev, "sense unit %d byte 1 %x\n", unit, ch); - chan_write_byte(addr, &ch); /* write byte 1 */ - ch = (uptr->u5 >> 8) & 0xff; /* get sense byte 2 status */ + chan_write_byte(addr, &ch); /* write byte 1 */ + ch = (uptr->SNS >> 8) & 0xff; /* get sense byte 2 status */ sim_debug(DEBUG_DETAIL, &mta_dev, "sense unit %d byte 2 %x\n", unit, ch); - chan_write_byte(addr, &ch); /* write byte 2 */ - ch = (uptr->u5 >> 0) & 0xff; /* get sense byte 3 status */ + chan_write_byte(addr, &ch); /* write byte 2 */ + ch = (uptr->SNS >> 0) & 0xff; /* get sense byte 3 status */ sim_debug(DEBUG_DETAIL, &mta_dev, "sense unit %d byte 3 %x\n", unit, ch); - chan_write_byte(addr, &ch); /* write byte 3 */ + chan_write_byte(addr, &ch); /* write byte 3 */ ch = 4; - uptr->u3 &= ~MT_CMDMSK; /* clear the cmd */ - mt_busy[bufnum] &= ~1; /* make our buffer not busy */ - chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ - sim_debug(DEBUG_CMD, &mta_dev, "mt_srv SENSE %x char complete unit=%d\n", uptr->u4, - unit); + uptr->CMD &= ~MT_CMDMSK; /* clear the cmd */ + mt_busy[bufnum] &= ~1; /* make our buffer not busy */ + chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ + sim_debug(DEBUG_CMD, &mta_dev, "mt_srv SENSE %x char complete unit=%d\n", + uptr->POS, unit); break; case MT_READ: /* 0x02 */ /* read a record from the device */ sim_debug(DEBUG_DATA, &mta_dev, "mt_srv cmd 2 READ unit=%d\n", unit); - if (uptr->u3 & MT_READDONE) { /* is the read complete */ - uptr->u5 &= ~(SNS_LOAD|SNS_EOT); /* reset BOT & EOT */ + if (uptr->CMD & MT_READDONE) { /* is the read complete */ + uptr->SNS &= ~(SNS_LOAD|SNS_EOT); /* reset BOT & EOT */ if (sim_tape_eot(uptr)) { /* see if at EOM */ - uptr->u5 |= SNS_EOT; /* set EOT status */ + uptr->SNS |= SNS_EOT; /* set EOT status */ } - uptr->u3 &= ~(MT_CMDMSK|MT_READDONE); /* clear all but readdone & cmd */ - uptr->u3 &= ~MT_CMDMSK; /* clear the cmd */ + uptr->CMD &= ~(MT_CMDMSK|MT_READDONE); /* clear all but readdone & cmd */ + uptr->CMD &= ~MT_CMDMSK; /* clear the cmd */ mt_busy[bufnum] &= ~1; /* not busy anymore */ chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* set chan end, dev end status */ - sim_debug(DEBUG_CMD, &mta_dev, "mt_srv READ %x char complete unit=%d sense %x\n", - uptr->u4, unit, uptr->u5); + sim_debug(DEBUG_CMD, &mta_dev, + "mt_srv READ %x char complete unit=%d sense %x\n", + uptr->POS, unit, uptr->SNS); break; } /* read is not completed, get an input char */ @@ -619,47 +625,50 @@ t_stat mt_srv(UNIT *uptr) /* buffer is empty, so fill it with next record data */ if ((r = sim_tape_rdrecf(uptr, &mt_buffer[bufnum][0], &reclen, BUFFSIZE)) != MTSE_OK) { sim_debug(DEBUG_DETAIL, &mta_dev, "mt_srv READ fill buffer unit=%d\n", unit); - uptr->u3 &= ~(MT_CMDMSK|MT_READDONE); /* clear all but readdone & cmd */ + uptr->CMD &= ~(MT_CMDMSK|MT_READDONE); /* clear all but readdone & cmd */ return mt_error(uptr, addr, r, dptr); /* process any error & return status */ } - uptr->u5 &= ~(SNS_LOAD|SNS_EOT); /* reset BOT & EOT */ - uptr->u4 = 0; /* reset buffer position */ + uptr->SNS &= ~(SNS_LOAD|SNS_EOT); /* reset BOT & EOT */ + uptr->POS = 0; /* reset buffer position */ uptr->hwmark = reclen; /* set buffer chars read in */ sim_debug(DEBUG_DETAIL, &mta_dev, "mt_srv READ fill buffer complete count %x\n", reclen); } /* get a char from the buffer */ - ch = mt_buffer[bufnum][uptr->u4++]; + ch = mt_buffer[bufnum][uptr->POS++]; /* Send character over to channel */ if (chan_write_byte(addr, &ch)) { - sim_debug(DEBUG_CMD, &mta_dev, "Read unit %d EOR cnt %x\n", unit, uptr->u4); + sim_debug(DEBUG_CMD, &mta_dev, "Read unit %d EOR cnt %x\n", unit, uptr->POS); /* If not read whole record, skip till end */ - if ((uint32)uptr->u4 < uptr->hwmark) { + if ((uint32)uptr->POS < uptr->hwmark) { /* Send dummy character to force SLI */ chan_write_byte(addr, &ch); /* write the byte */ sim_debug(DEBUG_CMD, &mta_dev, "Read unit %d send dump SLI\n", unit); - sim_activate(uptr, (uptr->hwmark-uptr->u4) * 10); /* wait again */ - uptr->u3 |= MT_READDONE; /* read is done */ + sim_activate(uptr, (uptr->hwmark-uptr->POS) * 10); /* wait again */ + uptr->CMD |= MT_READDONE; /* read is done */ break; } sim_debug(DEBUG_CMD, &mta_dev, - "Read data @1 unit %d cnt %x ch %02x hwm %x\n", unit, uptr->u4, ch, uptr->hwmark); - uptr->u3 &= ~MT_CMDMSK; /* clear the cmd */ + "Read data @1 unit %d cnt %x ch %02x hwm %x\n", unit, uptr->POS, + ch, uptr->hwmark); + uptr->CMD &= ~MT_CMDMSK; /* clear the cmd */ mt_busy[bufnum] &= ~1; /* set not busy */ chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* return end status */ } else { sim_debug(DEBUG_DATA, &mta_dev, - "Read data @2 unit %d cnt %x ch %02x hwm %x\n", unit, uptr->u4, ch, uptr->hwmark); - if ((uint32)uptr->u4 >= uptr->hwmark) { /* In IRG */ + "Read data @2 unit %d cnt %x ch %02x hwm %x\n", unit, uptr->POS, ch, + uptr->hwmark); + if ((uint32)uptr->POS >= uptr->hwmark) { /* In IRG */ /* Handle end of data record */ - sim_debug(DEBUG_CMD, &mta_dev, "Read data out of data unit %d cnt %x ch %02x hwm %x\n", - unit, uptr->u4, ch, uptr->hwmark); + sim_debug(DEBUG_CMD, &mta_dev, + "Read data out of data unit %d cnt %x ch %02x hwm %x\n", + unit, uptr->POS, ch, uptr->hwmark); #ifdef UTX_EOF_CHANGE - uptr->u3 &= ~MT_CMDMSK; /* clear the cmd */ + uptr->CMD &= ~MT_CMDMSK; /* clear the cmd */ mt_busy[bufnum] &= ~1; /* set not busy */ chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* return end status */ #else - uptr->u3 |= MT_READDONE; /* read is done */ + uptr->CMD |= MT_READDONE; /* read is done */ sim_activate(uptr, 20); /* wait again */ #endif } else @@ -671,21 +680,23 @@ t_stat mt_srv(UNIT *uptr) sim_debug(DEBUG_CMD, &mta_dev, "mt_srv cmd 0x83 SETM unit=%d\n", unit); /* Grab data until channel has no more */ if (chan_read_byte(addr, &ch)) { - if (uptr->u4 > 0) { /* Only if data in record */ + if (uptr->POS > 0) { /* Only if data in record */ reclen = uptr->hwmark; /* set record length */ ch = mt_buffer[bufnum][0]; /* get the first byte read */ - sim_debug(DEBUG_CMD, &mta_dev, "Write mode data done unit %d chars %d char %x\n", unit, reclen, ch); - /* put mode bits into byte 2 of u5 */ - uptr->u5 = (uptr->u5 & 0xffff00ff) | (ch << 8); - uptr->u4 = 0; /* no bytes anymore */ - uptr->u3 &= ~MT_CMDMSK; /* no cmd to do */ + sim_debug(DEBUG_CMD, &mta_dev, + "Write mode data done unit %d chars %d char %x\n", unit, reclen, ch); + /* put mode bits into byte 2 of SNS */ + uptr->SNS = (uptr->SNS & 0xffff00ff) | (ch << 8); + uptr->POS = 0; /* no bytes anymore */ + uptr->CMD &= ~MT_CMDMSK; /* no cmd to do */ mt_busy[bufnum] &= ~1; /* set not busy */ chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* return end status */ } } else { - mt_buffer[bufnum][uptr->u4++] = ch; /* save the character read in */ - sim_debug(DEBUG_CMD, &mta_dev, "Write mode data in unit %d u4 %d ch %0x\n", unit, uptr->u4, ch); - uptr->hwmark = uptr->u4; /* set high water mark */ + mt_buffer[bufnum][uptr->POS++] = ch; /* save the character read in */ + sim_debug(DEBUG_CMD, &mta_dev, "Write mode data in unit %d POS %d ch %0x\n", + unit, uptr->POS, ch); + uptr->hwmark = uptr->POS; /* set high water mark */ sim_activate(uptr, 20); /* wait time */ } break; @@ -693,8 +704,8 @@ t_stat mt_srv(UNIT *uptr) case MT_WRITE: /* 0x01 */ /* write record */ /* Check if write protected */ if (sim_tape_wrp(uptr)) { - uptr->u5 |= SNS_CMDREJ; - uptr->u3 &= ~MT_CMDMSK; + uptr->SNS |= SNS_CMDREJ; + uptr->CMD &= ~MT_CMDMSK; mt_busy[bufnum] &= ~1; sim_debug(DEBUG_DETAIL, &mta_dev, "Write write protected unit=%d\n", unit); chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); @@ -703,25 +714,27 @@ t_stat mt_srv(UNIT *uptr) /* Grab data until channel has no more */ if (chan_read_byte(addr, &ch)) { - if (uptr->u4 > 0) { /* Only if data in record */ + if (uptr->POS > 0) { /* Only if data in record */ reclen = uptr->hwmark; - sim_debug(DEBUG_DETAIL, &mta_dev, "Write unit=%d Block %d chars\n", unit, reclen); + sim_debug(DEBUG_DETAIL, &mta_dev, "Write unit=%d Block %d chars\n", + unit, reclen); r = sim_tape_wrrecf(uptr, &mt_buffer[bufnum][0], reclen); - uptr->u4 = 0; - uptr->u3 &= ~MT_CMDMSK; + uptr->POS = 0; + uptr->CMD &= ~MT_CMDMSK; mt_error(uptr, addr, r, dptr); /* Record errors */ } } else { - mt_buffer[bufnum][uptr->u4++] = ch; - sim_debug(DEBUG_DATA, &mta_dev, "Write data unit=%d %d %02x\n", unit, uptr->u4, ch); - uptr->hwmark = uptr->u4; + mt_buffer[bufnum][uptr->POS++] = ch; + sim_debug(DEBUG_DATA, &mta_dev, "Write data unit=%d %d %02x\n", + unit, uptr->POS, ch); + uptr->hwmark = uptr->POS; } sim_activate(uptr, 20); break; case MT_RDBK: /* 0x0C */ /* Read Backwards */ - if (uptr->u3 & MT_READDONE) { - uptr->u3 &= ~(MT_CMDMSK|MT_READDONE); + if (uptr->CMD & MT_READDONE) { + uptr->CMD &= ~(MT_CMDMSK|MT_READDONE); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND); return SCPE_OK; @@ -730,38 +743,40 @@ t_stat mt_srv(UNIT *uptr) /* If at end of record, fill buffer */ if (BUF_EMPTY(uptr)) { if (sim_tape_bot(uptr)) { - uptr->u3 &= ~MT_CMDMSK; + uptr->CMD &= ~MT_CMDMSK; mt_busy[GET_DEV_BUF(dptr->flags)] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); return SCPE_OK; } sim_debug(DEBUG_DETAIL, &mta_dev, "Read backward unit=%d\n", unit); if ((r = sim_tape_rdrecr(uptr, &mt_buffer[bufnum][0], &reclen, BUFFSIZE)) != MTSE_OK) { - uptr->u3 &= ~(MT_CMDMSK|MT_READDONE); + uptr->CMD &= ~(MT_CMDMSK|MT_READDONE); return mt_error(uptr, addr, r, dptr); } - uptr->u4 = reclen; + uptr->POS = reclen; uptr->hwmark = reclen; sim_debug(DEBUG_DETAIL, &mta_dev, "Binary Block %d chars\n", reclen); } - ch = mt_buffer[bufnum][--uptr->u4]; + ch = mt_buffer[bufnum][--uptr->POS]; if (chan_write_byte(addr, &ch)) { - sim_debug(DEBUG_DATA, &mta_dev, "Read unit=%d EOR cnt %x\n", unit, uptr->u4); + sim_debug(DEBUG_DATA, &mta_dev, "Read unit=%d EOR cnt %x\n", unit, + uptr->POS); /* If not read whole record, skip till end */ - if (uptr->u4 >= 0) { - sim_activate(uptr, (uptr->u4) * 20); - uptr->u3 |= MT_READDONE; + if (uptr->POS >= 0) { + sim_activate(uptr, (uptr->POS) * 20); + uptr->CMD |= MT_READDONE; return SCPE_OK; } - uptr->u3 &= ~MT_CMDMSK; + uptr->CMD &= ~MT_CMDMSK; mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND); } else { - sim_debug(DEBUG_DATA, &mta_dev, "Read data unit=%d %d %02o\n", unit, uptr->u4, ch); - if (uptr->u4 == 0) { /* In IRG */ - uptr->u3 &= ~MT_CMDMSK; + sim_debug(DEBUG_DATA, &mta_dev, "Read data unit=%d %d %02o\n", + unit, uptr->POS, ch); + if (uptr->POS == 0) { /* In IRG */ + uptr->CMD &= ~MT_CMDMSK; mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND); } else @@ -770,19 +785,19 @@ t_stat mt_srv(UNIT *uptr) break; case MT_WTM: /* 0x93 */ /* Write tape filemark */ - if (uptr->u4 == 0) { + if (uptr->POS == 0) { if (sim_tape_wrp(uptr)) { - uptr->u5 |= SNS_CMDREJ; - uptr->u3 &= ~MT_CMDMSK; + uptr->SNS |= SNS_CMDREJ; + uptr->CMD &= ~MT_CMDMSK; mt_busy[GET_DEV_BUF(dptr->flags)] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); return SCPE_OK; } - uptr->u4 ++; + uptr->POS ++; sim_activate(uptr, 500); } else { sim_debug(DEBUG_DETAIL, &mta_dev, "Write Mark unit=%d\n", unit); - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); r = sim_tape_wrtmk(uptr); chan_end(addr, SNS_DEVEND); mt_busy[bufnum] &= ~1; @@ -790,25 +805,27 @@ t_stat mt_srv(UNIT *uptr) break; case MT_BSR: /* 0x53 */ /* Backspace record */ - sim_debug(DEBUG_DETAIL, &mta_dev, "mt_srv cmd 0x53 BSR unit %d u4 %x\n", unit, uptr->u4); - switch (uptr->u4 ) { + sim_debug(DEBUG_DETAIL, &mta_dev, "mt_srv cmd 0x53 BSR unit %d POS %x\n", + unit, uptr->POS); + switch (uptr->POS ) { case 0: if (sim_tape_bot(uptr)) { - uptr->u3 &= ~MT_CMDMSK; + uptr->CMD &= ~MT_CMDMSK; mt_busy[GET_DEV_BUF(dptr->flags)] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); return SCPE_OK; } - uptr->u4++; + uptr->POS++; sim_activate(uptr, 50); break; case 1: - uptr->u4++; - sim_debug(DEBUG_DETAIL, &mta_dev, "Backspace rec unit %x u4 %x\n", unit, uptr->u4); + uptr->POS++; + sim_debug(DEBUG_DETAIL, &mta_dev, "Backspace rec unit %x POS %x\n", + unit, uptr->POS); r = sim_tape_sprecr(uptr, &reclen); /* We don't set EOF on BSR */ if (r == MTSE_TMK) { - uptr->u4++; + uptr->POS++; sim_debug(DEBUG_DETAIL, &mta_dev, "MARK\n"); sim_activate(uptr, 50); } else { @@ -817,12 +834,12 @@ t_stat mt_srv(UNIT *uptr) } break; case 2: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND); break; case 3: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND|SNS_UNITEXP); break; @@ -831,38 +848,38 @@ t_stat mt_srv(UNIT *uptr) case MT_BSF: /* 0x73 */ /* Backspace file */ sim_debug(DEBUG_DETAIL, &mta_dev, "mt_srv cmd 0x73 BSF unit %d\n", unit); - switch(uptr->u4) { + switch(uptr->POS) { case 0: if (sim_tape_bot(uptr)) { - uptr->u3 &= ~MT_CMDMSK; + uptr->CMD &= ~MT_CMDMSK; mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND|SNS_UNITCHK); break; } - uptr->u4++; + uptr->POS++; sim_activate(uptr, 500); break; case 1: sim_debug(DEBUG_DETAIL, &mta_dev, "Backspace file unit=%d\n", unit); r = sim_tape_sprecr(uptr, &reclen); if (r == MTSE_TMK) { - uptr->u4++; + uptr->POS++; sim_debug(DEBUG_DETAIL, &mta_dev, "MARK\n"); sim_activate(uptr, 50); } else if (r == MTSE_BOT) { - uptr->u4+= 2; + uptr->POS+= 2; sim_activate(uptr, 50); } else { sim_activate(uptr, 20); } break; case 2: /* File Mark */ - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND); break; case 3: /* BOT */ - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND); break; @@ -870,41 +887,42 @@ t_stat mt_srv(UNIT *uptr) break; case MT_FSR: /* 0x43 */ /* Advance record */ - switch(uptr->u4) { + switch(uptr->POS) { case 0: sim_debug(DEBUG_DETAIL, &mta_dev, "Skip rec entry unit=%d ", unit); - uptr->u4++; + uptr->POS++; sim_activate(uptr, 50); break; case 1: - uptr->u4++; + uptr->POS++; sim_debug(DEBUG_DETAIL, &mta_dev, "Skip rec unit=%d ", unit); r = sim_tape_sprecf(uptr, &reclen); if (r == MTSE_TMK) { - uptr->u4 = 3; + uptr->POS = 3; sim_debug(DEBUG_DETAIL, &mta_dev, "FSR MARK\n"); sim_activate(uptr, 50); } else if (r == MTSE_EOM) { - uptr->u4 = 4; + uptr->POS = 4; sim_activate(uptr, 50); } else { - sim_debug(DEBUG_DETAIL, &mta_dev, "FSR skipped %d byte record\n", reclen); + sim_debug(DEBUG_DETAIL, &mta_dev, "FSR skipped %d byte record\n", + reclen); sim_activate(uptr, 10 + (10 * reclen)); } break; case 2: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND); break; case 3: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND|SNS_UNITEXP); sim_debug(DEBUG_DETAIL, &mta_dev, "Skip record Completed\n"); break; case 4: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND|SNS_UNITCHK); break; @@ -912,23 +930,23 @@ t_stat mt_srv(UNIT *uptr) break; case MT_FSF: /* 0x63 */ /* advance filemark */ - switch(uptr->u4) { + switch(uptr->POS) { case 0: sim_debug(DEBUG_DETAIL, &mta_dev, "Skip file entry unit=%d\n", unit); - uptr->u4++; + uptr->POS++; sim_activate(uptr, 50); break; case 1: sim_debug(DEBUG_DETAIL, &mta_dev, "Skip file unit=%d\n", unit); r = sim_tape_sprecf(uptr, &reclen); if (r == MTSE_TMK) { - uptr->u4++; - uptr->u5 |= SNS_FMRKDT; /* file mark detected */ + uptr->POS++; + uptr->SNS |= SNS_FMRKDT; /* file mark detected */ sim_debug(DEBUG_DETAIL, &mta_dev, "FSF MARK\n"); sim_activate(uptr, 50); } else if (r == MTSE_EOM) { - uptr->u5 |= SNS_EOT; /* set EOT status */ - uptr->u4+= 2; + uptr->SNS |= SNS_EOT; /* set EOT status */ + uptr->POS+= 2; sim_activate(uptr, 50); } else { sim_debug(DEBUG_DETAIL, &mta_dev, "FSF skipped %d byte record\n", reclen); @@ -936,13 +954,13 @@ t_stat mt_srv(UNIT *uptr) } break; case 2: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ sim_debug(DEBUG_DETAIL, &mta_dev, "Skip file done unit=%d\n", unit); break; case 3: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND|SNS_UNITCHK|SNS_UNITCHK); break; @@ -950,15 +968,15 @@ t_stat mt_srv(UNIT *uptr) break; case MT_ERG: /* 0xA3 */ /* Erace 3.5 in tape */ - switch (uptr->u4) { + switch (uptr->POS) { case 0: if (sim_tape_wrp(uptr)) { - uptr->u5 |= SNS_CMDREJ; - uptr->u3 &= ~MT_CMDMSK; + uptr->SNS |= SNS_CMDREJ; + uptr->CMD &= ~MT_CMDMSK; mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND|SNS_UNITCHK); } else { - uptr->u4 ++; + uptr->POS ++; sim_activate(uptr, 500); } break; @@ -966,38 +984,38 @@ t_stat mt_srv(UNIT *uptr) sim_debug(DEBUG_DETAIL, &mta_dev, "Erase unit=%d\n", unit); r = sim_tape_wrgap(uptr, 35); sim_activate(uptr, 5000); - uptr->u4++; + uptr->POS++; break; case 2: - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); mt_busy[bufnum] &= ~1; chan_end(addr, SNS_DEVEND); } break; case MT_REW: /* 0x23 */ /* rewind tape */ - if (uptr->u4 == 0) { - uptr->u4++; + if (uptr->POS == 0) { + uptr->POS++; sim_debug(DEBUG_DETAIL, &mta_dev, "Start rewind unit %d\n", unit); sim_activate(uptr, 1500); } else { sim_debug(DEBUG_DETAIL, &mta_dev, "Rewind complete unit %d\n", unit); - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); r = sim_tape_rewind(uptr); - uptr->u5 |= SNS_LOAD; /* set BOT */ + uptr->SNS |= SNS_LOAD; /* set BOT */ mt_busy[bufnum] &= ~1; chan_end(addr, SNS_CHNEND|SNS_DEVEND); /* we are done dev|chan end */ } break; case MT_RUN: /* 0x33 */ /* Rewind and unload tape */ - if (uptr->u4 == 0) { - uptr->u4++; + if (uptr->POS == 0) { + uptr->POS++; mt_busy[bufnum] &= ~1; sim_activate(uptr, 30000); } else { sim_debug(DEBUG_DETAIL, &mta_dev, "Unload unit=%d\n", unit); - uptr->u3 &= ~(MT_CMDMSK); + uptr->CMD &= ~(MT_CMDMSK); r = sim_tape_detach(uptr); } break; @@ -1012,11 +1030,12 @@ void mt_ini(UNIT *uptr, t_bool f) if (MT_DENS(uptr->dynflags) == 0) uptr->dynflags |= MT_DENS_6250 << UNIT_S_DF_TAPE; - uptr->u3 &= ~0xffff; /* clear out the flags but leave ch/sa */ - uptr->u5 = 0; /* clear sense data */ - uptr->u5 |= (SNS_RDY|SNS_ONLN|SNS_LOAD); /* set initial status */ - mt_busy[GET_DEV_BUF(dptr->flags)] = 0; /* set not busy */ - sim_debug(DEBUG_EXP, dptr, "MT init device %s unit %x\n", dptr->name, GET_UADDR(uptr->u3)); + uptr->CMD &= ~0xffff; /* clear out the flags but leave ch/sa */ + uptr->SNS = 0; /* clear sense data */ + uptr->SNS |= (SNS_RDY|SNS_ONLN|SNS_LOAD); /* set initial status */ + mt_busy[GET_DEV_BUF(dptr->flags)] = 0; /* set not busy */ + sim_debug(DEBUG_EXP, dptr, "MT init device %s unit %x\n", dptr->name, + GET_UADDR(uptr->CMD)); } /* reset the mag tape */ @@ -1030,10 +1049,11 @@ t_stat mt_reset(DEVICE *dptr) /* attach the specified file to the tape device */ t_stat mt_attach(UNIT *uptr, CONST char *file) { - uint16 addr = GET_UADDR(uptr->u3); /* get address of mt device */ + uint16 addr = GET_UADDR(uptr->CMD); /* get address of mt device */ t_stat r; - if ((r = sim_tape_attach(uptr, file)) != SCPE_OK) { /* mount the specified file to the MT */ + /* mount the specified file to the MT */ + if ((r = sim_tape_attach(uptr, file)) != SCPE_OK) { sim_debug(DEBUG_EXP, &mta_dev, "mt_attach ERROR filename %s status %x\n", file, r); return r; /* report any error */ } @@ -1046,28 +1066,26 @@ t_stat mt_attach(UNIT *uptr, CONST char *file) t_stat mt_detach(UNIT *uptr) { sim_debug(DEBUG_EXP, &mta_dev, "mt_detach\n"); - uptr->u3 = 0; + uptr->CMD = 0; return sim_tape_detach(uptr); } /* boot from the specified tape unit */ t_stat mt_boot(int32 unit_num, DEVICE *dptr) { - UNIT *uptr = &dptr->units[unit_num]; /* find tape unit pointer */ + UNIT *uptr = &dptr->units[unit_num]; /* find tape unit pointer */ - sim_debug(DEBUG_EXP, &mta_dev, "MT Boot dev/unit %x\n", GET_UADDR(uptr->u3)); - if ((uptr->flags & UNIT_ATT) == 0) { /* Is MT device already attached? */ - sim_debug(DEBUG_EXP, &mta_dev, "MT Boot attach error dev/unit %x\n", GET_UADDR(uptr->u3)); - return SCPE_UNATT; /* not attached, return error */ + sim_debug(DEBUG_EXP, &mta_dev, "MT Boot dev/unit %x\n", GET_UADDR(uptr->CMD)); + if ((uptr->flags & UNIT_ATT) == 0) { /* Is MT device already attached? */ + sim_debug(DEBUG_EXP, &mta_dev, "MT Boot attach error dev/unit %x\n", + GET_UADDR(uptr->CMD)); + return SCPE_UNATT; /* not attached, return error */ } - SPAD[0xf4] = GET_UADDR(uptr->u3); /* put boot device chan/sa into spad */ - SPAD[0xf8] = 0xF000; /* show as F class device */ + SPAD[0xf4] = GET_UADDR(uptr->CMD); /* put boot device chan/sa into spad */ + SPAD[0xf8] = 0xF000; /* show as F class device */ -// if ((uptr->flags & MTUF_9TR) == 0) { /* is tape a 9 track? */ - uptr->u3 &= ~0xffff; /* clear out old status */ -// uptr->u3 |= MT_ODD|MT_CONV|MT_MDEN_800; /* set 800bpi & odd parity */ -// } - return chan_boot(GET_UADDR(uptr->u3), dptr); /* boot the ch/sa */ + uptr->CMD &= ~0xffff; /* clear out old status */ + return chan_boot(GET_UADDR(uptr->CMD), dptr); /* boot the ch/sa */ } t_stat mt_help(FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr)