1. New Features in 2.10-2 The build procedures have changed. There is only one UNIX makefile. To compile without Ethernet support, simply type gmake {target|all} To compile with Ethernet support, type gmake USE_NETWORK=1 {target|all} The Mingw batch files require Mingw release 2 and invoke the Unix makefile. There are still separate batch files for compilation with or without Ethernet support. 1.1 SCP and Libraries - The EVAL command will evaluate a symbolic type-in and display it in numeric form. - The ! command (with no arguments) will launch the host operating system command shell. The ! command (with an argument) executes the argument as a host operating system command. (Code from Mark Pizzolato) - Telnet sessions now recognize BREAK. How a BREAK is transmitted dependent on the particular Telnet client. (Code from Mark Pizzolato) - The sockets library includes code for active connections as well as listening connections. - The RESTORE command will restore saved memory size, if the simulator supports dynamic memory resizing. 1.2 PDP-1 - The PDP-1 supports the Type 24 serial drum (based on recently discovered documents). 1.3 18b PDP's - The PDP-4 supports the Type 24 serial drum (based on recently discovered documents). 1.4 PDP-11 - The PDP-11 implements a stub DEUNA/DELUA (XU). The real XU module will be included in a later release. 1.5 PDP-10 - The PDP-10 implements a stub DEUNA/DELUA (XU). The real XU module will be included in a later release. 1.6 HP 2100 - The IOP microinstruction set is supported for the 21MX as well as the 2100. - The HP2100 supports the Access Interprocessor Link (IPL). 1.7 VAX - If the VAX console is attached to a Telnet session, BREAK is interpreted as console halt. - The SET/SHOW HISTORY commands enable and display a history of the most recently executed instructions. (Code from Mark Pizzolato) 1.8 Terminals Multiplexors - BREAK detection was added to the HP, DEC, and Interdata terminal multiplexors. 1.9 Interdata 16b and 32b - First release. UNIX is not yet working. 1.10 SDS 940 - First release. 2. Bugs Fixed in 2.10-2 - PDP-11 console must default to 7b for early UNIX compatibility. - PDP-11/VAX TMSCP emulator was using the wrong packet length for read/write end packets. - Telnet IAC+IAC processing was fixed, both for input and output (found by Mark Pizzolato). - PDP-11/VAX Ethernet setting flag bits wrong for chained descriptors (found by Mark Pizzolato). 3. New Features in 2.10 vs prior releases 3.1 SCP and Libraries - The VT emulation package has been replaced by the capability to remote the console to a Telnet session. Telnet clients typically have more complete and robust VT100 emulation. - Simulated devices may now have statically allocated buffers, in addition to dynamically allocated buffers or disk-based data stores. - The DO command now takes substitutable arguments (max 9). In command files, %n represents substitutable argument n. - The initial command line is now interpreted as the command name and substitutable arguments for a DO command. This is backward compatible to prior versions. - The initial command line parses switches. -Q is interpreted as quiet mode; informational messages are suppressed. - The HELP command now takes an optional argument. HELP <cmd> types help on the specified command. - Hooks have been added for implementing GUI-based consoles, as well as simulator-specific command extensions. A few internal data structures and definitions have changed. - Two new routines (tmxr_open_master, tmxr_close_master) have been added to sim_tmxr.c. The calling sequence for sim_accept_conn has been changed in sim_sock.c. - The calling sequence for the VM boot routine has been modified to add an additional parameter. - SAVE now saves, and GET now restores, controller and unit flags. - Library sim_ether.c has been added for Ethernet support. 3.2 VAX - Non-volatile RAM (NVR) can behave either like a memory or like a disk-based peripheral. If unattached, it behaves like memory and is saved and restored by SAVE and RESTORE, respectively. If attached, its contents are loaded from disk by ATTACH and written back to disk at DETACH and EXIT. - SHOW <device> VECTOR displays the device's interrupt vector. A few devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The TK50 (TMSCP tape) has been added. - The DEQNA/DELQA (Qbus Ethernet controllers) have been added. - Autoconfiguration support has been added. - The paper tape reader has been removed from vax_stddev.c and now references a common implementation file, dec_pt.h. - Examine and deposit switches now work on all devices, not just the CPU. - Device address conflicts are not detected until simulation starts. 3.3 PDP-11 - SHOW <device> VECTOR displays the device's interrupt vector. Most devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The TK50 (TMSCP tape), RK611/RK06/RK07 (cartridge disk), RX211 (double density floppy), and KW11P programmable clock have been added. - The DEQNA/DELQA (Qbus Ethernet controllers) have been added. - Autoconfiguration support has been added. - The paper tape reader has been removed from pdp11_stddev.c and now references a common implementation file, dec_pt.h. - Device bootstraps now use the actual CSR specified by the SET ADDRESS command, rather than just the default CSR. Note that PDP-11 operating systems may NOT support booting with non-standard addresses. - Specifying more than 256KB of memory, or changing the bus configuration, causes all peripherals that are not compatible with the current bus configuration to be disabled. - Device address conflicts are not detected until simulation starts. 3.4 PDP-10 - SHOW <device> VECTOR displays the device's interrupt vector. A few devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The RX211 (double density floppy) has been added; it is off by default. - The paper tape now references a common implementation file, dec_pt.h. - Device address conflicts are not detected until simulation starts. 3.5 PDP-1 - DECtape (then known as MicroTape) support has been added. - The line printer and DECtape can be disabled and enabled. 3.6 PDP-8 - The RX28 (double density floppy) has been added as an option to the existing RX8E controller. - SHOW <device> DEVNO displays the device's device number. Most devices allow the device number to be changed with SET <device> DEVNO=nnn. - Device number conflicts are not detected until simulation starts. 3.7 IBM 1620 - The IBM 1620 simulator has been released. 3.8 AltairZ80 - A hard drive has been added for increased storage. - Several bugs have been fixed. 3.9 HP 2100 - The 12845A has been added and made the default line printer (LPT). The 12653A has been renamed LPS and is off by default. It also supports the diagnostic functions needed to run the DCPC and DMS diagnostics. - The 12557A/13210A disk defaults to the 13210A (7900/7901). - The 12559A magtape is off by default. - New CPU options (EAU/NOEAU) enable/disable the extended arithmetic instructions for the 2116. These instructions are standard on the 2100 and 21MX. - New CPU options (MPR/NOMPR) enable/disable memory protect for the 2100 and 21MX. - New CPU options (DMS/NODMS) enable/disable the dynamic mapping instructions for the 21MX. - The 12539 timebase generator autocalibrates. 3.10 Simulated Magtapes - Simulated magtapes recognize end of file and the marker 0xFFFFFFFF as end of medium. Only the TMSCP tape simulator can generate an end of medium marker. - The error handling in simulated magtapes was overhauled to be consistent through all simulators. 3.11 Simulated DECtapes - Added support for RT11 image file format (256 x 16b) to DECtapes. 4. Bugs Fixed in 2.10 vs prior releases - TS11/TSV05 was not simulating the XS0_MOT bit, causing failures under VMS. In addition, two of the CTL options were coded interchanged. - IBM 1401 tape was not setting a word mark under group mark for load mode reads. This caused the diagnostics to crash. - SCP bugs in ssh_break and set_logon were fixed (found by Dave Hittner). - Numerous bugs in the HP 2100 extended arithmetic, floating point, 21MX, DMS, and IOP instructions were fixed. Bugs were also fixed in the memory protect and DMS functions. The moving head disks (DP, DQ) were revised to simulate the hardware more accurately. Missing functions in DQ (address skip, read address) were added. - PDP-10 tape wouldn't boot, and then wouldn't read (reported by Michael Thompson and Harris Newman, respectively) - PDP-1 typewriter is half duplex, with only one shift state for both input and output (found by Derek Peschel) 5. General Notes WARNING: V2.10 has reorganized and renamed some of the definition files for the PDP-10, PDP-11, and VAX. Be sure to delete all previous source files before you unpack the Zip archive, or unpack it into a new directory structure. WARNING: V2.10 has a new, more comprehensive save file format. Restoring save files from previous releases will cause 'invalid register' errors and loss of CPU option flags, device enable/ disable flags, unit online/offline flags, and unit writelock flags. WARNING: If you are using Visual Studio .NET through the IDE, be sure to turn off the /Wp64 flag in the project settings, or dozens of spurious errors will be generated. WARNING: Compiling Ethernet support under Windows requires extra steps; see the Ethernet readme file. Ethernet support is currently available only for Windows, Linux, NetBSD, and OpenBSD.
598 lines
20 KiB
C
598 lines
20 KiB
C
/* pdp10_lp20.c: PDP-10 LP20 line printer simulator
|
||
|
||
Copyright (c) 1993-2002, Robert M Supnik
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a
|
||
copy of this software and associated documentation files (the "Software"),
|
||
to deal in the Software without restriction, including without limitation
|
||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
and/or sell copies of the Software, and to permit persons to whom the
|
||
Software is furnished to do so, subject to the following conditions:
|
||
|
||
The above copyright notice and this permission notice shall be included in
|
||
all copies or substantial portions of the Software.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
|
||
Except as contained in this notice, the name of Robert M Supnik shall not
|
||
be used in advertising or otherwise to promote the sale, use or other dealings
|
||
in this Software without prior written authorization from Robert M Supnik.
|
||
|
||
lp20 line printer
|
||
|
||
29-Sep-02 RMS Added variable vector support
|
||
Modified to use common Unibus routines
|
||
New data structures
|
||
30-May-02 RMS Widened POS to 32b
|
||
06-Jan-02 RMS Added enable/disable support
|
||
30-Nov-01 RMS Added extended SET/SHOW support
|
||
*/
|
||
|
||
#include "pdp10_defs.h"
|
||
|
||
#define UNIT_DUMMY (1 << UNIT_V_UF)
|
||
#define LP_WIDTH 132 /* printer width */
|
||
|
||
/* DAVFU RAM */
|
||
|
||
#define DV_SIZE 143 /* DAVFU size */
|
||
#define DV_DMASK 077 /* data mask per byte */
|
||
#define DV_TOF 0 /* top of form channel */
|
||
#define DV_MAX 11 /* max channel number */
|
||
|
||
/* Translation RAM */
|
||
|
||
#define TX_SIZE 256 /* translation RAM */
|
||
#define TX_AMASK (TX_SIZE - 1)
|
||
#define TX_DMASK 07777
|
||
#define TX_V_FL 8 /* flags */
|
||
#define TX_M_FL 017
|
||
/* define TX_INTR 04000 /* interrupt */
|
||
#define TX_DELH 02000 /* delimiter */
|
||
/* define TX_XLAT 01000 /* translate */
|
||
/* define TX_DVFU 00400 /* DAVFU */
|
||
#define TX_SLEW 00020 /* chan vs slew */
|
||
#define TX_VMASK 00017 /* spacing mask */
|
||
#define TX_CHR 0 /* states: pr char */
|
||
#define TX_RAM 1 /* pr translation */
|
||
#define TX_DVU 2 /* DAVFU action */
|
||
#define TX_INT 3 /* interrupt */
|
||
#define TX_GETFL(x) (((x) >> TX_V_FL) & TX_M_FL)
|
||
|
||
/* LPCSRA (765400) */
|
||
|
||
#define CSA_GO 0000001 /* go */
|
||
#define CSA_PAR 0000002 /* parity enable NI */
|
||
#define CSA_V_FNC 2 /* function */
|
||
#define CSA_M_FNC 03
|
||
#define FNC_PR 0 /* print */
|
||
#define FNC_TST 1 /* test */
|
||
#define FNC_DVU 2 /* load DAVFU */
|
||
#define FNC_RAM 3 /* load translation RAM */
|
||
#define FNC_INTERNAL 1 /* internal function */
|
||
#define CSA_FNC (CSA_M_FNC << CSA_V_FNC)
|
||
#define CSA_V_UAE 4 /* Unibus addr extension */
|
||
#define CSA_UAE (03 << CSA_V_UAE)
|
||
#define CSA_IE 0000100 /* interrupt enable */
|
||
#define CSA_DONE 0000200 /* done */
|
||
#define CSA_INIT 0000400 /* init */
|
||
#define CSA_ECLR 0001000 /* clear errors */
|
||
#define CSA_DELH 0002000 /* delimiter hold */
|
||
#define CSA_ONL 0004000 /* online */
|
||
#define CSA_DVON 0010000 /* DAVFU online */
|
||
#define CSA_UNDF 0020000 /* undefined char */
|
||
#define CSA_PZRO 0040000 /* page counter zero */
|
||
#define CSA_ERR 0100000 /* error */
|
||
#define CSA_RW (CSA_DELH | CSA_IE | CSA_UAE | CSA_FNC | CSA_PAR | CSA_GO)
|
||
#define CSA_MBZ (CSA_ECLR | CSA_INIT)
|
||
#define CSA_GETUAE(x) (((x) & CSA_UAE) << (16 - CSA_V_UAE))
|
||
#define CSA_GETFNC(x) (((x) >> CSA_V_FNC) & CSA_M_FNC)
|
||
|
||
/* LPCSRB (765402) */
|
||
|
||
#define CSB_GOE 0000001 /* go error */
|
||
#define CSB_DTE 0000002 /* DEM timing error NI */
|
||
#define CSB_MTE 0000004 /* MSYN error (Ubus timeout) */
|
||
#define CSB_RPE 0000010 /* RAM parity error NI */
|
||
#define CSB_MPE 0000020 /* MEM parity error NI */
|
||
#define CSB_LPE 0000040 /* LPT parity error NI */
|
||
#define CSB_DVOF 0000100 /* DAVFU not ready */
|
||
#define CSB_OFFL 0000200 /* offline */
|
||
#define CSB_TEST 0003400 /* test mode */
|
||
#define CSB_OVFU 0004000 /* optical VFU NI */
|
||
#define CSB_PBIT 0010000 /* data parity bit NI */
|
||
#define CSB_NRDY 0020000 /* printer error NI */
|
||
#define CSB_LA180 0040000 /* LA180 printer NI */
|
||
#define CSB_VLD 0100000 /* valid data NI */
|
||
#define CSB_ECLR (CSB_GOE | CSB_DTE | CSB_MTE | CSB_RPE | CSB_MPE | CSB_LPE)
|
||
#define CSB_ERR (CSB_ECLR | CSB_DVOF | CSB_OFFL)
|
||
#define CSB_RW CSB_TEST
|
||
#define CSB_MBZ (CSB_DTE | CSB_RPE | CSB_MPE | CSB_LPE | CSB_OVFU |\
|
||
CSB_PBIT | CSB_NRDY | CSB_LA180 | CSB_VLD)
|
||
|
||
/* LPBA (765404) */
|
||
|
||
/* LPBC (765506) */
|
||
|
||
#define BC_MASK 0007777 /* <15:12> MBZ */
|
||
|
||
/* LPPAGC (765510) */
|
||
|
||
#define PAGC_MASK 0007777 /* <15:12> MBZ */
|
||
|
||
/* LPRDAT (765512) */
|
||
|
||
#define RDAT_MASK 0007777 /* <15:12> MBZ */
|
||
|
||
/* LPCOLC/LPCBUF (765514) */
|
||
|
||
/* LPCSUM/LPPDAT (765516) */
|
||
|
||
extern d10 *M; /* main memory */
|
||
extern int32 int_req;
|
||
extern int32 int_vec[32];
|
||
extern int32 ubcs[UBANUM]; /* UBA csr */
|
||
extern int32 ubmap[UBANUM][UMAP_MEMSIZE]; /* UBA map */
|
||
|
||
int32 lpcsa = 0; /* control/status A */
|
||
int32 lpcsb = 0; /* control/status B */
|
||
int32 lpba = 0; /* bus address */
|
||
int32 lpbc = 0; /* byte count */
|
||
int32 lppagc = 0; /* page count */
|
||
int32 lprdat = 0; /* RAM data */
|
||
int32 lpcbuf = 0; /* character buffer */
|
||
int32 lpcolc = 0; /* column count */
|
||
int32 lppdat = 0; /* printer data */
|
||
int32 lpcsum = 0; /* checksum */
|
||
int32 dvptr = 0; /* davfu pointer */
|
||
int32 dvlnt = 0; /* davfu length */
|
||
int32 lp20_irq = 0; /* int request */
|
||
int32 lp20_stopioe = 0; /* stop on error */
|
||
int16 txram[TX_SIZE] = { 0 }; /* translation RAM */
|
||
int16 davfu[DV_SIZE] = { 0 }; /* DAVFU */
|
||
|
||
DEVICE lp20_dev;
|
||
t_stat lp20_rd (int32 *data, int32 pa, int32 access);
|
||
t_stat lp20_wr (int32 data, int32 pa, int32 access);
|
||
int32 lp20_inta (void);
|
||
t_stat lp20_svc (UNIT *uptr);
|
||
t_stat lp20_reset (DEVICE *dptr);
|
||
t_stat lp20_attach (UNIT *uptr, char *ptr);
|
||
t_stat lp20_detach (UNIT *uptr);
|
||
t_stat lp20_clear_vfu (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||
t_bool lp20_print (int32 c);
|
||
t_bool lp20_adv (int32 c, t_bool advdvu);
|
||
t_bool lp20_davfu (int32 c);
|
||
void update_lpcs (int32 flg);
|
||
|
||
/* LP data structures
|
||
|
||
lp20_dev LPT device descriptor
|
||
lp20_unit LPT unit descriptor
|
||
lp20_reg LPT register list
|
||
*/
|
||
|
||
DIB lp20_dib = { IOBA_LP20, IOLN_LP20, &lp20_rd, &lp20_wr,
|
||
1, IVCL (LP20), VEC_LP20, { &lp20_inta } };
|
||
|
||
UNIT lp20_unit = {
|
||
UDATA (&lp20_svc, UNIT_SEQ+UNIT_ATTABLE, 0), SERIAL_OUT_WAIT };
|
||
|
||
REG lp20_reg[] = {
|
||
{ ORDATA (LPCSA, lpcsa, 16) },
|
||
{ ORDATA (LPCSB, lpcsb, 16) },
|
||
{ ORDATA (LPBA, lpba, 16) },
|
||
{ ORDATA (LPBC, lpbc, 12) },
|
||
{ ORDATA (LPPAGC, lppagc, 12) },
|
||
{ ORDATA (LPRDAT, lprdat, 12) },
|
||
{ ORDATA (LPCBUF, lpcbuf, 8) },
|
||
{ ORDATA (LPCOLC, lpcolc, 8) },
|
||
{ ORDATA (LPPDAT, lppdat, 8) },
|
||
{ ORDATA (LPCSUM, lpcsum, 8) },
|
||
{ ORDATA (DVPTR, dvptr, 7) },
|
||
{ ORDATA (DVLNT, dvlnt, 7), REG_RO + REG_NZ },
|
||
{ FLDATA (INT, int_req, INT_V_LP20) },
|
||
{ FLDATA (IRQ, lp20_irq, 0) },
|
||
{ FLDATA (ERR, lpcsa, CSR_V_ERR) },
|
||
{ FLDATA (DONE, lpcsa, CSR_V_DONE) },
|
||
{ FLDATA (IE, lpcsa, CSR_V_IE) },
|
||
{ DRDATA (POS, lp20_unit.pos, 32), PV_LEFT },
|
||
{ DRDATA (TIME, lp20_unit.wait, 24), PV_LEFT },
|
||
{ FLDATA (STOP_IOE, lp20_stopioe, 0) },
|
||
{ BRDATA (TXRAM, txram, 8, 12, TX_SIZE) },
|
||
{ BRDATA (DAVFU, davfu, 8, 12, DV_SIZE) },
|
||
{ ORDATA (DEVADDR, lp20_dib.ba, 32), REG_HRO },
|
||
{ ORDATA (DEVVEC, lp20_dib.vec, 16), REG_HRO },
|
||
{ NULL } };
|
||
|
||
MTAB lp20_mod[] = {
|
||
{ UNIT_DUMMY, 0, NULL, "VFUCLEAR", &lp20_clear_vfu },
|
||
{ MTAB_XTD|MTAB_VDV, 004, "ADDRESS", "ADDRESS",
|
||
&set_addr, &show_addr, NULL },
|
||
{ MTAB_XTD|MTAB_VDV, 0, "VECTOR", "VECTOR",
|
||
&set_vec, &show_vec, NULL },
|
||
{ 0 } };
|
||
|
||
DEVICE lp20_dev = {
|
||
"LP20", &lp20_unit, lp20_reg, lp20_mod,
|
||
1, 10, 31, 1, 8, 8,
|
||
NULL, NULL, &lp20_reset,
|
||
NULL, &lp20_attach, &lp20_detach,
|
||
&lp20_dib, DEV_DISABLE | DEV_UBUS };
|
||
|
||
/* Line printer routines
|
||
|
||
lp20_rd I/O page read
|
||
lp20_wr I/O page write
|
||
lp20_svc process event (printer ready)
|
||
lp20_reset process reset
|
||
lp20_attach process attach
|
||
lp20_detach process detach
|
||
*/
|
||
|
||
t_stat lp20_rd (int32 *data, int32 pa, int32 access)
|
||
{
|
||
update_lpcs (0); /* update csr's */
|
||
switch ((pa >> 1) & 07) { /* case on PA<3:1> */
|
||
case 00: /* LPCSA */
|
||
*data = lpcsa = lpcsa & ~CSA_MBZ;
|
||
break;
|
||
case 01: /* LPCSB */
|
||
*data = lpcsb = lpcsb & ~CSB_MBZ;
|
||
break;
|
||
case 02: /* LPBA */
|
||
*data = lpba;
|
||
break;
|
||
case 03: /* LPBC */
|
||
*data = lpbc = lpbc & BC_MASK;
|
||
break;
|
||
case 04: /* LPPAGC */
|
||
*data = lppagc = lppagc & PAGC_MASK;
|
||
break;
|
||
case 05: /* LPRDAT */
|
||
*data = lprdat = lprdat & RDAT_MASK;
|
||
break;
|
||
case 06: /* LPCOLC/LPCBUF */
|
||
*data = (lpcolc << 8) | lpcbuf;
|
||
break;
|
||
case 07: /* LPCSUM/LPPDAT */
|
||
*data = (lpcsum << 8) | lppdat;
|
||
break; } /* end case PA */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat lp20_wr (int32 data, int32 pa, int32 access)
|
||
{
|
||
update_lpcs (0); /* update csr's */
|
||
switch ((pa >> 1) & 07) { /* case on PA<3:1> */
|
||
case 00: /* LPCSA */
|
||
if (access == WRITEB) data = (pa & 1)?
|
||
(lpcsa & 0377) | (data << 8): (lpcsa & ~0377) | data;
|
||
if (data & CSA_ECLR) { /* error clear? */
|
||
lpcsa = (lpcsa | CSA_DONE) & ~CSA_GO; /* set done, clr go */
|
||
lpcsb = lpcsb & ~CSB_ECLR; /* clear err */
|
||
sim_cancel (&lp20_unit); } /* cancel I/O */
|
||
if (data & CSA_INIT) lp20_reset (&lp20_dev); /* init? */
|
||
if (data & CSA_GO) { /* go set? */
|
||
if ((lpcsa & CSA_GO) == 0) { /* not set before? */
|
||
if (lpcsb & CSB_ERR) lpcsb = lpcsb | CSB_GOE;
|
||
lpcsum = 0; /* clear checksum */
|
||
sim_activate (&lp20_unit, lp20_unit.time); } }
|
||
else sim_cancel (&lp20_unit); /* go clr, stop DMA */
|
||
lpcsa = (lpcsa & ~CSA_RW) | (data & CSA_RW);
|
||
break;
|
||
case 01: /* LPCSB */
|
||
break; /* ignore writes to TEST */
|
||
case 02: /* LPBA */
|
||
if (access == WRITEB) data = (pa & 1)?
|
||
(lpba & 0377) | (data << 8): (lpba & ~0377) | data;
|
||
lpba = data;
|
||
break;
|
||
case 03: /* LPBC */
|
||
if (access == WRITEB) data = (pa & 1)?
|
||
(lpbc & 0377) | (data << 8): (lpbc & ~0377) | data;
|
||
lpbc = data & BC_MASK;
|
||
lpcsa = lpcsa & ~CSA_DONE;
|
||
break;
|
||
case 04: /* LPPAGC */
|
||
if (access == WRITEB) data = (pa & 1)?
|
||
(lppagc & 0377) | (data << 8): (lppagc & ~0377) | data;
|
||
lppagc = data & PAGC_MASK;
|
||
break;
|
||
case 05: /* LPRDAT */
|
||
if (access == WRITEB) data = (pa & 1)?
|
||
(lprdat & 0377) | (data << 8): (lprdat & ~0377) | data;
|
||
lprdat = data & RDAT_MASK;
|
||
txram[lpcbuf & TX_AMASK] = lprdat; /* load RAM */
|
||
break;
|
||
case 06: /* LPCOLC/LPCBUF */
|
||
if ((access == WRITEB) && (pa & 1)) /* odd byte */
|
||
lpcolc = data & 0377;
|
||
else {
|
||
lpcbuf = data & 0377; /* even byte, word */
|
||
if (access == WRITE) lpcolc = (data >> 8) & 0377; }
|
||
break;
|
||
case 07: /* LPCSUM/LPPDAT */
|
||
break; } /* read only */
|
||
update_lpcs (0);
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Line printer service
|
||
|
||
The translation RAM case table is derived from the LP20 spec and
|
||
verified against the LP20 RAM simulator in TOPS10 7.04 LPTSPL.
|
||
The equations are:
|
||
|
||
flags := inter, delim, xlate, paper, delim_hold (from CSRA)
|
||
actions : = print_input, print_xlate, davfu_action, interrupt
|
||
|
||
if (inter) {
|
||
if (!xlate || delim || delim_hold) interrupt;
|
||
else if (paper) davfu_action;
|
||
else print_xlate; }
|
||
else if (paper) {
|
||
if (xlate || delim || delim_hold) davfu_action;
|
||
else print_input; }
|
||
else {
|
||
if (xlate || delim || delim_hold) print_xlate;
|
||
else print_input; }
|
||
*/
|
||
|
||
t_stat lp20_svc (UNIT *uptr)
|
||
{
|
||
int32 fnc, i, tbc, temp, txst;
|
||
int32 dvld = -2; /* must be even */
|
||
int32 err = 0;
|
||
uint16 wd10;
|
||
t_bool cont;
|
||
a10 ba;
|
||
|
||
static const uint32 txcase[32] = {
|
||
TX_CHR, TX_RAM, TX_CHR, TX_DVU, TX_RAM, TX_RAM, TX_DVU, TX_DVU,
|
||
TX_RAM, TX_RAM, TX_DVU, TX_DVU, TX_RAM, TX_RAM, TX_DVU, TX_DVU,
|
||
TX_INT, TX_INT, TX_INT, TX_INT, TX_RAM, TX_INT, TX_DVU, TX_INT,
|
||
TX_INT, TX_INT, TX_INT, TX_INT, TX_INT, TX_INT, TX_INT, TX_INT };
|
||
|
||
lpcsa = lpcsa & ~CSA_GO;
|
||
ba = CSA_GETUAE (lpcsa) | lpba;
|
||
fnc = CSA_GETFNC (lpcsa);
|
||
tbc = 010000 - lpbc;
|
||
if (((fnc & FNC_INTERNAL) == 0) && ((lp20_unit.flags & UNIT_ATT) == 0)) {
|
||
update_lpcs (CSA_ERR);
|
||
IORETURN (lp20_stopioe, SCPE_UNATT); }
|
||
if ((fnc == FNC_PR) && (dvlnt == 0)) {
|
||
update_lpcs (CSA_ERR);
|
||
return SCPE_OK; }
|
||
|
||
for (i = 0, cont = TRUE; (i < tbc) && cont; ba++, i++) {
|
||
if (Map_ReadW (ba, 2, &wd10, MAP)) { /* get word, err? */
|
||
lpcsb = lpcsb | CSB_MTE; /* set NXM error */
|
||
update_lpcs (CSA_ERR); /* set done */
|
||
break; }
|
||
lpcbuf = (wd10 >> ((ba & 1)? 8: 0)) & 0377; /* get character */
|
||
lpcsum = (lpcsum + lpcbuf) & 0377; /* add into checksum */
|
||
switch (fnc) { /* switch on function */
|
||
|
||
/* Translation RAM load */
|
||
|
||
case FNC_RAM: /* RAM load */
|
||
txram[(i >> 1) & TX_AMASK] = wd10 & TX_DMASK;
|
||
break;
|
||
|
||
/* DAVFU RAM load. The DAVFU RAM is actually loaded in bytes, delimited by
|
||
a start (354 to 356) and stop (357) byte pair. If the number of bytes
|
||
loaded is odd, or no bytes are loaded, the DAVFU is invalid.
|
||
*/
|
||
|
||
case FNC_DVU: /* DVU load */
|
||
if ((lpcbuf >= 0354) && (lpcbuf <= 0356)) /* start DVU load? */
|
||
dvld = dvlnt = 0; /* reset lnt */
|
||
else if (lpcbuf == 0357) { /* stop DVU load? */
|
||
dvptr = 0; /* reset ptr */
|
||
if (dvld & 1) dvlnt = 0; } /* if odd, invalid */
|
||
else if (dvld == 0) { /* even state? */
|
||
temp = lpcbuf & DV_DMASK;
|
||
dvld = 1; }
|
||
else if (dvld == 1) { /* odd state? */
|
||
if (dvlnt < DV_SIZE) davfu[dvlnt++] =
|
||
temp | ((lpcbuf & DV_DMASK) << 6);
|
||
dvld = 0; }
|
||
break;
|
||
|
||
/* Print characters */
|
||
|
||
case FNC_PR: /* print */
|
||
lprdat = txram[lpcbuf]; /* get RAM char */
|
||
txst = (TX_GETFL (lprdat) << 1) | /* get state */
|
||
((lpcsa & CSA_DELH)? 1: 0); /* plus delim hold */
|
||
if (lprdat & TX_DELH) lpcsa = lpcsa | CSA_DELH;
|
||
else lpcsa = lpcsa & ~CSA_DELH;
|
||
lpcsa = lpcsa & ~CSA_UNDF; /* assume char ok */
|
||
switch (txcase[txst]) { /* case on state */
|
||
case TX_CHR: /* take char */
|
||
cont = lp20_print (lpcbuf);
|
||
break;
|
||
case TX_RAM: /* take translation */
|
||
cont = lp20_print (lprdat);
|
||
break;
|
||
case TX_DVU: /* DAVFU action */
|
||
if (lprdat & TX_SLEW)
|
||
cont = lp20_adv (lprdat & TX_VMASK, TRUE);
|
||
else cont = lp20_davfu (lprdat & TX_VMASK);
|
||
break;
|
||
case TX_INT: /* interrupt */
|
||
lpcsa = lpcsa | CSA_UNDF; /* set flag */
|
||
cont = FALSE; /* force stop */
|
||
break; } /* end case char state */
|
||
break;
|
||
case FNC_TST: /* test */
|
||
break; } /* end case function */
|
||
} /* end for */
|
||
lpba = ba & 0177777;
|
||
lpcsa = (lpcsa & ~CSA_UAE) | ((ba >> (16 - CSA_V_UAE)) & CSA_UAE);
|
||
lpbc = (lpbc + i) & BC_MASK;
|
||
if (lpbc) update_lpcs (CSA_MBZ); /* intr, but not done */
|
||
else update_lpcs (CSA_DONE); /* intr and done */
|
||
if ((fnc == FNC_PR) && ferror (lp20_unit.fileref)) {
|
||
perror ("LP I/O error");
|
||
clearerr (uptr->fileref);
|
||
return SCPE_IOERR; }
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Print routines
|
||
|
||
lp20_print print a character
|
||
lp20_adv advance n lines
|
||
lp20_davfu advance to channel on VFU
|
||
|
||
Return TRUE to continue printing, FALSE to stop
|
||
*/
|
||
|
||
t_bool lp20_print (int32 c)
|
||
{
|
||
t_bool r = TRUE;
|
||
int32 i, rpt = 1;
|
||
|
||
lppdat = c & 0177; /* mask char to 7b */
|
||
if (lppdat == 000) return TRUE; /* NUL? no op */
|
||
if (lppdat == 012) return lp20_adv (1, TRUE); /* LF? adv carriage */
|
||
if (lppdat == 014) return lp20_davfu (DV_TOF); /* FF? top of form */
|
||
if (lppdat == 015) lpcolc = 0; /* CR? reset col cntr */
|
||
else if (lppdat == 011) { /* TAB? simulate */
|
||
lppdat = ' '; /* with spaces */
|
||
if (lpcolc >= 128) {
|
||
r = lp20_adv (1, TRUE); /* eol? adv carriage */
|
||
rpt = 8; } /* adv to col 9 */
|
||
else rpt = 8 - (lpcolc & 07); } /* else adv 1 to 8 */
|
||
else { if (lppdat < 040) lppdat = ' '; /* cvt non-prnt to spc */
|
||
if (lpcolc >= LP_WIDTH) /* line full? */
|
||
r = lp20_adv (1, TRUE); } /* adv carriage */
|
||
for (i = 0; i < rpt; i++) putc (lppdat, lp20_unit.fileref);
|
||
lp20_unit.pos = lp20_unit.pos + rpt;
|
||
lpcolc = lpcolc + rpt;
|
||
return r;
|
||
}
|
||
|
||
t_bool lp20_adv (int32 cnt, t_bool dvuadv)
|
||
{
|
||
int32 i;
|
||
|
||
if (cnt == 0) return TRUE;
|
||
lpcolc = 0; /* reset col cntr */
|
||
for (i = 0; i < cnt; i++) putc ('\n', lp20_unit.fileref);
|
||
lp20_unit.pos = lp20_unit.pos + cnt; /* print 'n' newlines */
|
||
if (dvuadv) dvptr = (dvptr + cnt) % dvlnt; /* update DAVFU ptr */
|
||
if (davfu[dvptr] & (1 << DV_TOF)) { /* at top of form? */
|
||
if (lppagc = (lppagc - 1) & PAGC_MASK) { /* decr page cntr */
|
||
lpcsa = lpcsa & ~CSA_PZRO; /* update status */
|
||
return TRUE; }
|
||
else {
|
||
lpcsa = lpcsa | CSA_PZRO; /* stop if zero */
|
||
return FALSE; } }
|
||
return TRUE;
|
||
}
|
||
|
||
t_bool lp20_davfu (int32 cnt)
|
||
{
|
||
int i;
|
||
|
||
if (cnt > DV_MAX) cnt = 7; /* inval chan? */
|
||
for (i = 0; i < dvlnt; i++) { /* search DAVFU */
|
||
dvptr = dvptr + 1; /* adv DAVFU ptr */
|
||
if (dvptr >= dvlnt) dvptr = 0; /* wrap at end */
|
||
if (davfu[dvptr] & (1 << cnt)) { /* channel stop set? */
|
||
if (cnt) return lp20_adv (i + 1, FALSE); /* ~TOF, adv */
|
||
if (lpcolc) lp20_adv (1, FALSE); /* TOF, need newline? */
|
||
putc ('\f', lp20_unit.fileref); /* print form feed */
|
||
lp20_unit.pos = lp20_unit.pos + 1;
|
||
if (lppagc = (lppagc - 1) & PAGC_MASK) { /* decr page cntr */
|
||
lpcsa = lpcsa & ~CSA_PZRO; /* update status */
|
||
return TRUE; }
|
||
else {
|
||
lpcsa = lpcsa | CSA_PZRO; /* stop if zero */
|
||
return FALSE; } }
|
||
} /* end for */
|
||
dvlnt = 0; /* DAVFU error */
|
||
return FALSE;
|
||
}
|
||
|
||
/* Update LPCSA, optionally request interrupt */
|
||
|
||
void update_lpcs (int32 flg)
|
||
{
|
||
if (flg) lp20_irq = 1; /* set int req */
|
||
lpcsa = (lpcsa | flg) & ~(CSA_MBZ | CSA_ERR | CSA_ONL | CSA_DVON);
|
||
lpcsb = (lpcsb | CSB_OFFL | CSB_DVOF) & ~CSB_MBZ;
|
||
if (lp20_unit.flags & UNIT_ATT) {
|
||
lpcsa = lpcsa | CSA_ONL;
|
||
lpcsb = lpcsb & ~CSB_OFFL; }
|
||
else lpcsa = lpcsa & ~CSA_DONE;
|
||
if (dvlnt) {
|
||
lpcsa = lpcsa | CSA_DVON;
|
||
lpcsb = lpcsb & ~CSB_DVOF; }
|
||
if (lpcsb & CSB_ERR) lpcsa = lpcsa | CSA_ERR;
|
||
if ((lpcsa & CSA_IE) && lp20_irq) int_req = int_req | INT_LP20;
|
||
else int_req = int_req & ~INT_LP20;
|
||
return;
|
||
}
|
||
|
||
/* Acknowledge interrupt (clear internal request) */
|
||
|
||
int32 lp20_inta (void)
|
||
{
|
||
lp20_irq = 0; /* clear int req */
|
||
return lp20_dib.vec;
|
||
}
|
||
|
||
t_stat lp20_reset (DEVICE *dptr)
|
||
{
|
||
lpcsa = CSA_DONE;
|
||
lpcsb = 0;
|
||
lpba = lpbc = lppagc = lpcolc = 0; /* clear registers */
|
||
lprdat = lppdat = lpcbuf = lpcsum = 0;
|
||
lp20_irq = 0; /* clear int req */
|
||
dvptr = 0; /* reset davfu ptr */
|
||
sim_cancel (&lp20_unit); /* deactivate unit */
|
||
update_lpcs (0); /* update status */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat lp20_attach (UNIT *uptr, char *cptr)
|
||
{
|
||
t_stat reason;
|
||
|
||
reason = attach_unit (uptr, cptr); /* attach file */
|
||
if (lpcsa & CSA_ONL) return reason; /* just file chg? */
|
||
if (sim_is_active (&lp20_unit)) update_lpcs (0); /* busy? no int */
|
||
else update_lpcs (CSA_MBZ); /* interrupt */
|
||
return reason;
|
||
}
|
||
|
||
t_stat lp20_detach (UNIT *uptr)
|
||
{
|
||
t_stat reason;
|
||
|
||
reason = detach_unit (uptr);
|
||
sim_cancel (&lp20_unit);
|
||
lpcsa = lpcsa & ~CSA_GO;
|
||
update_lpcs (CSA_MBZ);
|
||
return reason;
|
||
}
|
||
|
||
t_stat lp20_clear_vfu (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||
{
|
||
int i;
|
||
|
||
if (!get_yn ("Clear DAVFU? [N]", FALSE)) return SCPE_OK;
|
||
for (i = 0; i < DV_SIZE; i++) davfu[i] = 0;
|
||
dvlnt = dvptr = 0;
|
||
update_lpcs (0);
|
||
return SCPE_OK;
|
||
}
|