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.
794 lines
22 KiB
C
794 lines
22 KiB
C
/* pdp10_ksio.c: PDP-10 KS10 I/O subsystem 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.
|
||
|
||
uba Unibus adapters
|
||
|
||
10-Oct-02 RMS Revised for dynamic table generation
|
||
Added SHOW IOSPACE routine
|
||
29-Sep-02 RMS Added variable vector, central map support
|
||
25-Jan-02 RMS Revised for multiple DZ11's
|
||
06-Jan-02 RMS Revised enable/disable support
|
||
23-Sep-01 RMS New IO page address constants
|
||
07-Sep-01 RMS Revised device disable mechanism
|
||
25-Aug-01 RMS Enabled DZ11
|
||
21-Aug-01 RMS Updated DZ11 disable
|
||
01-Jun-01 RMS Updated DZ11 vectors
|
||
12-May-01 RMS Fixed typo
|
||
|
||
The KS10 uses the PDP-11 Unibus for its I/O, via adapters. While
|
||
nominally four adapters are supported, in practice only 1 and 3
|
||
are implemented. The disks are placed on adapter 1, the rest of
|
||
the I/O devices on adapter 3.
|
||
|
||
In theory, we should maintain completely separate Unibuses, with
|
||
distinct PI systems. In practice, this simulator has so few devices
|
||
that we can get away with a single PI system, masking for which
|
||
devices are on adapter 1, and which on adapter 3. The Unibus
|
||
implementation is modeled on the Qbus in the PDP-11 simulator and
|
||
is described there.
|
||
|
||
The I/O subsystem is programmed by I/O instructions which create
|
||
Unibus operations (read, read pause, write, write byte). DMA is
|
||
the responsibility of the I/O device simulators, which also implement
|
||
Unibus to physical memory mapping.
|
||
|
||
The priority interrupt subsystem (and other privileged functions)
|
||
is programmed by I/O instructions with internal devices codes
|
||
(opcodes 700-702). These are dispatched here, although many are
|
||
handled in the memory management unit or elsewhere.
|
||
|
||
The ITS instructions are significantly different from the TOPS-10/20
|
||
instructions. They do not use the extended address calculation but
|
||
instead provide instruction variants (Q for Unibus adapter 1, I for
|
||
Unibus adapter 3) which insert the Unibus adapter number into the
|
||
effective address.
|
||
*/
|
||
|
||
#include "pdp10_defs.h"
|
||
#include <setjmp.h>
|
||
|
||
#define XBA_MBZ 0400000 /* ba mbz */
|
||
#define eaRB (ea & ~1)
|
||
#define GETBYTE(ea,x) ((((ea) & 1)? (x) >> 8: (x)) & 0377)
|
||
#define UBNXM_FAIL(pa,op) \
|
||
n = iocmap[GET_IOUBA (pa)]; \
|
||
if (n >= 0) ubcs[n] = ubcs[n] | UBCS_TMO | UBCS_NXD; \
|
||
pager_word = PF_HARD | PF_VIRT | PF_IO | \
|
||
((op == WRITEB)? PF_BYTE: 0) | \
|
||
(TSTF (F_USR)? PF_USER: 0) | (pa); \
|
||
ABORT (PAGE_FAIL)
|
||
|
||
/* Unibus adapter data */
|
||
|
||
int32 ubcs[UBANUM] = { 0 }; /* status registers */
|
||
int32 ubmap[UBANUM][UMAP_MEMSIZE] = { 0 }; /* Unibus maps */
|
||
int32 int_req = 0; /* interrupt requests */
|
||
|
||
/* Map IO controller numbers to Unibus adapters: -1 = non-existent */
|
||
|
||
static int iocmap[IO_N_UBA] = { /* map I/O ext to UBA # */
|
||
-1, 0, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
|
||
|
||
static const int32 ubabr76[UBANUM] = {
|
||
INT_UB1 & (INT_IPL7 | INT_IPL6), INT_UB3 & (INT_IPL7 | INT_IPL6) };
|
||
static const int32 ubabr54[UBANUM] = {
|
||
INT_UB1 & (INT_IPL5 | INT_IPL4), INT_UB3 & (INT_IPL5 | INT_IPL4) };
|
||
static const int32 ubashf[4] = { 18, 26, 0, 8 };
|
||
|
||
extern d10 *M; /* main memory */
|
||
extern d10 *ac_cur;
|
||
extern d10 pager_word;
|
||
extern int32 flags, pi_l2bit[8];
|
||
extern UNIT cpu_unit;
|
||
extern FILE *sim_log;
|
||
extern jmp_buf save_env;
|
||
extern DEVICE *sim_devices[];
|
||
|
||
extern d10 Read (a10 ea);
|
||
extern void pi_eval ();
|
||
extern int32 rp_inta (void);
|
||
extern int32 tu_inta (void);
|
||
extern int32 lp20_inta (void);
|
||
extern int32 dz_rxinta (void);
|
||
extern int32 dz_txinta (void);
|
||
|
||
t_stat ubmap_rd (int32 *data, int32 addr, int32 access);
|
||
t_stat ubmap_wr (int32 data, int32 addr, int32 access);
|
||
t_stat ubs_rd (int32 *data, int32 addr, int32 access);
|
||
t_stat ubs_wr (int32 data, int32 addr, int32 access);
|
||
t_stat rd_zro (int32 *data, int32 addr, int32 access);
|
||
t_stat wr_nop (int32 data, int32 addr, int32 access);
|
||
t_stat uba_ex (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw);
|
||
t_stat uba_dep (t_value val, t_addr addr, UNIT *uptr, int32 sw);
|
||
t_stat uba_reset (DEVICE *dptr);
|
||
d10 ReadIO (a10 ea);
|
||
void WriteIO (a10 ea, d10 val, int32 mode);
|
||
|
||
/* Unibus adapter data structures
|
||
|
||
uba_dev UBA device descriptor
|
||
uba_unit UBA units
|
||
uba_reg UBA register list
|
||
*/
|
||
|
||
DIB ubmp1_dib = { IOBA_UBMAP1, IOLN_UBMAP1, &ubmap_rd, &ubmap_wr, 0 };
|
||
DIB ubmp3_dib = { IOBA_UBMAP3, IOLN_UBMAP3, &ubmap_rd, &ubmap_wr, 0 };
|
||
DIB ubcs1_dib = { IOBA_UBCS1, IOLN_UBCS1, &ubs_rd, &ubs_wr, 0 };
|
||
DIB ubcs3_dib = { IOBA_UBCS3, IOLN_UBCS3, &ubs_rd, &ubs_wr, 0 };
|
||
DIB ubmn1_dib = { IOBA_UBMNT1, IOLN_UBMNT1, &rd_zro, &wr_nop, 0 };
|
||
DIB ubmn3_dib = { IOBA_UBMNT3, IOLN_UBMNT3, &rd_zro, &wr_nop, 0 };
|
||
DIB msys_dib = { 00100000, 1, &rd_zro, &wr_nop, 0 };
|
||
|
||
UNIT uba_unit[] = {
|
||
{ UDATA (NULL, UNIT_FIX, UMAP_MEMSIZE) },
|
||
{ UDATA (NULL, UNIT_FIX, UMAP_MEMSIZE) } };
|
||
|
||
REG uba_reg[] = {
|
||
{ ORDATA (INTREQ, int_req, 32), REG_RO },
|
||
{ ORDATA (UB1CS, ubcs[0], 18) },
|
||
{ ORDATA (UB3CS, ubcs[1], 18) },
|
||
{ NULL } };
|
||
|
||
DEVICE uba_dev = {
|
||
"UBA", uba_unit, uba_reg, NULL,
|
||
UBANUM, 8, UMAP_ASIZE, 1, 8, 32,
|
||
&uba_ex, &uba_dep, &uba_reset,
|
||
NULL, NULL, NULL,
|
||
NULL, 0 };
|
||
|
||
/* PDP-11 I/O structures */
|
||
|
||
DIB *dib_tab[DIB_MAX]; /* run-time DIBs */
|
||
|
||
int32 (*int_ack[32])(void); /* int ack routines */
|
||
|
||
int32 int_vec[32]; /* int vectors */
|
||
|
||
DIB *std_dib[] = { /* standard DIBs */
|
||
&ubmp1_dib,
|
||
&ubmp3_dib,
|
||
&ubcs1_dib,
|
||
&ubcs3_dib,
|
||
&ubmn1_dib,
|
||
&ubmn3_dib,
|
||
&msys_dib,
|
||
NULL };
|
||
|
||
/* IO 710 (DEC) TIOE - test I/O word, skip if zero
|
||
(ITS) IORDI - read word from Unibus 3
|
||
returns TRUE if skip, FALSE otherwise
|
||
*/
|
||
|
||
t_bool io710 (int32 ac, a10 ea)
|
||
{
|
||
d10 val;
|
||
|
||
if (ITS) AC(ac) = ReadIO (IO_UBA3 | ea); /* IORDI */
|
||
else { /* TIOE */
|
||
val = ReadIO (ea); /* read word */
|
||
if ((AC(ac) & val) == 0) return TRUE; }
|
||
return FALSE;
|
||
}
|
||
|
||
/* IO 711 (DEC) TION - test I/O word, skip if non-zero
|
||
(ITS) IORDQ - read word from Unibus 1
|
||
returns TRUE if skip, FALSE otherwise
|
||
*/
|
||
|
||
t_bool io711 (int32 ac, a10 ea)
|
||
{
|
||
d10 val;
|
||
|
||
if (ITS) AC(ac) = ReadIO (IO_UBA1 | ea); /* IORDQ */
|
||
else { /* TION */
|
||
val = ReadIO (ea); /* read word */
|
||
if ((AC(ac) & val) != 0) return TRUE; }
|
||
return FALSE;
|
||
}
|
||
|
||
/* IO 712 (DEC) RDIO - read I/O word, addr in ea
|
||
(ITS) IORD - read I/O word, addr in M[ea]
|
||
*/
|
||
|
||
d10 io712 (a10 ea)
|
||
{
|
||
return ReadIO (ea); /* RDIO, IORD */
|
||
}
|
||
|
||
/* IO 713 (DEC) WRIO - write I/O word, addr in ea
|
||
(ITS) IOWR - write I/O word, addr in M[ea]
|
||
*/
|
||
|
||
void io713 (d10 val, a10 ea)
|
||
{
|
||
WriteIO (ea, val & 0177777, WRITE); /* WRIO, IOWR */
|
||
return;
|
||
}
|
||
|
||
/* IO 714 (DEC) BSIO - set bit in I/O address
|
||
(ITS) IOWRI - write word to Unibus 3
|
||
*/
|
||
|
||
void io714 (d10 val, a10 ea)
|
||
{
|
||
d10 temp;
|
||
|
||
val = val & 0177777;
|
||
if (ITS) WriteIO (IO_UBA3 | ea, val, WRITE); /* IOWRI */
|
||
else {
|
||
temp = ReadIO (ea); /* BSIO */
|
||
temp = temp | val;
|
||
WriteIO (ea, temp, WRITE); }
|
||
return;
|
||
}
|
||
|
||
/* IO 715 (DEC) BCIO - clear bit in I/O address
|
||
(ITS) IOWRQ - write word to Unibus 1
|
||
*/
|
||
|
||
void io715 (d10 val, a10 ea)
|
||
{
|
||
d10 temp;
|
||
|
||
val = val & 0177777;
|
||
if (ITS) WriteIO (IO_UBA1 | ea, val, WRITE); /* IOWRQ */
|
||
else {
|
||
temp = ReadIO (ea); /* BCIO */
|
||
temp = temp & ~val;
|
||
WriteIO (ea, temp, WRITE); }
|
||
return;
|
||
}
|
||
|
||
/* IO 720 (DEC) TIOEB - test I/O byte, skip if zero
|
||
(ITS) IORDBI - read byte from Unibus 3
|
||
returns TRUE if skip, FALSE otherwise
|
||
*/
|
||
|
||
t_bool io720 (int32 ac, a10 ea)
|
||
{
|
||
d10 val;
|
||
|
||
if (ITS) { /* IORDBI */
|
||
val = ReadIO (IO_UBA3 | eaRB);
|
||
AC(ac) = GETBYTE (ea, val); }
|
||
else { /* TIOEB */
|
||
val = ReadIO (eaRB);
|
||
val = GETBYTE (ea, val);
|
||
if ((AC(ac) & val) == 0) return TRUE; }
|
||
return FALSE;
|
||
}
|
||
|
||
/* IO 721 (DEC) TIONB - test I/O word, skip if non-zero
|
||
(ITS) IORDBQ - read word from Unibus 1
|
||
returns TRUE if skip, FALSE otherwise
|
||
*/
|
||
|
||
t_bool io721 (int32 ac, a10 ea)
|
||
{
|
||
d10 val;
|
||
|
||
if (ITS) { /* IORDBQ */
|
||
val = ReadIO (IO_UBA1 | eaRB);
|
||
AC(ac) = GETBYTE (ea, val); }
|
||
else { /* TIONB */
|
||
val = ReadIO (eaRB);
|
||
val = GETBYTE (ea, val);
|
||
if ((AC(ac) & val) != 0) return TRUE; }
|
||
return FALSE;
|
||
}
|
||
|
||
/* IO 722 (DEC) RDIOB - read I/O byte, addr in ea
|
||
(ITS) IORDB - read I/O byte, addr in M[ea]
|
||
*/
|
||
|
||
d10 io722 (a10 ea)
|
||
{
|
||
d10 val;
|
||
|
||
val = ReadIO (eaRB); /* RDIOB, IORDB */
|
||
return GETBYTE (ea, val);
|
||
}
|
||
|
||
/* IO 723 (DEC) WRIOB - write I/O byte, addr in ea
|
||
(ITS) IOWRB - write I/O byte, addr in M[ea]
|
||
*/
|
||
|
||
void io723 (d10 val, a10 ea)
|
||
{
|
||
WriteIO (ea, val & 0377, WRITEB); /* WRIOB, IOWRB */
|
||
return;
|
||
}
|
||
|
||
/* IO 724 (DEC) BSIOB - set bit in I/O byte address
|
||
(ITS) IOWRBI - write byte to Unibus 3
|
||
*/
|
||
|
||
void io724 (d10 val, a10 ea)
|
||
{
|
||
d10 temp;
|
||
|
||
val = val & 0377;
|
||
if (ITS) WriteIO (IO_UBA3 | ea, val, WRITEB); /* IOWRBI */
|
||
else {
|
||
temp = ReadIO (eaRB); /* BSIOB */
|
||
temp = GETBYTE (ea, temp);
|
||
temp = temp | val;
|
||
WriteIO (ea, temp, WRITEB); }
|
||
return;
|
||
}
|
||
|
||
/* IO 725 (DEC) BCIOB - clear bit in I/O byte address
|
||
(ITS) IOWRBQ - write byte to Unibus 1
|
||
*/
|
||
|
||
void io725 (d10 val, a10 ea)
|
||
{
|
||
d10 temp;
|
||
|
||
val = val & 0377;
|
||
if (ITS) WriteIO (IO_UBA1 | ea, val, WRITEB); /* IOWRBQ */
|
||
else {
|
||
temp = ReadIO (eaRB); /* BCIOB */
|
||
temp = GETBYTE (ea, temp);
|
||
temp = temp & ~val;
|
||
WriteIO (ea, temp, WRITEB); }
|
||
return;
|
||
}
|
||
|
||
/* Read and write I/O devices.
|
||
These routines are the linkage between the 64b world of the main
|
||
simulator and the 32b world of the device simulators.
|
||
*/
|
||
|
||
d10 ReadIO (a10 ea)
|
||
{
|
||
uint32 pa = (uint32) ea;
|
||
int32 i, n, val;
|
||
DIB *dibp;
|
||
|
||
for (i = 0; dibp = dib_tab[i]; i++ ) {
|
||
if ((pa >= dibp->ba) &&
|
||
(pa < (dibp->ba + dibp->lnt))) {
|
||
dibp->rd (&val, pa, READ);
|
||
pi_eval ();
|
||
return ((d10) val); } }
|
||
UBNXM_FAIL (pa, READ);
|
||
}
|
||
|
||
void WriteIO (a10 ea, d10 val, int32 mode)
|
||
{
|
||
uint32 pa = (uint32) ea;
|
||
int32 i, n;
|
||
DIB *dibp;
|
||
|
||
for (i = 0; dibp = dib_tab[i]; i++ ) {
|
||
if ((pa >= dibp->ba) &&
|
||
(pa < (dibp->ba + dibp->lnt))) {
|
||
dibp->wr ((int32) val, pa, mode);
|
||
pi_eval ();
|
||
return; } }
|
||
UBNXM_FAIL (pa, mode);
|
||
}
|
||
|
||
/* Mapped read and write routines - used by word-oriented Unibus devices */
|
||
|
||
a10 Map_Addr10 (a10 ba, int32 ub)
|
||
{
|
||
a10 pa10;
|
||
int32 vpn = PAG_GETVPN (ba >> 2); /* get PDP-10 page number */
|
||
|
||
if ((vpn >= UMAP_MEMSIZE) || (ba & XBA_MBZ) ||
|
||
((ubmap[ub][vpn] & UMAP_VLD) == 0)) return -1; /* invalid map? */
|
||
pa10 = (ubmap[ub][vpn] + PAG_GETOFF (ba >> 2)) & PAMASK;
|
||
return pa10;
|
||
}
|
||
|
||
int32 Map_ReadB (t_addr ba, int32 bc, uint8 *buf, t_bool ub)
|
||
{
|
||
t_addr lim;
|
||
a10 pa10;
|
||
|
||
lim = ba + bc;
|
||
for ( ; ba < lim; ba++) { /* by bytes */
|
||
pa10 = Map_Addr10 (ba, ub); /* map addr */
|
||
if ((pa10 < 0) || MEM_ADDR_NXM (pa10)) { /* inv map or NXM? */
|
||
ubcs[ub] = ubcs[ub] | UBCS_TMO; /* UBA times out */
|
||
return (lim - ba); } /* return bc */
|
||
*buf++ = (uint8) ((M[pa10] >> ubashf[ba & 3]) & 0377);
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int32 Map_ReadW (t_addr ba, int32 bc, uint16 *buf, t_bool ub)
|
||
{
|
||
t_addr lim;
|
||
a10 pa10;
|
||
|
||
ba = ba & ~01; /* align start */
|
||
lim = ba + (bc & ~01);
|
||
for ( ; ba < lim; ba = ba + 2) { /* by words */
|
||
pa10 = Map_Addr10 (ba, ub); /* map addr */
|
||
if ((pa10 < 0) || MEM_ADDR_NXM (pa10)) { /* inv map or NXM? */
|
||
ubcs[ub] = ubcs[ub] | UBCS_TMO; /* UBA times out */
|
||
return (lim - ba); } /* return bc */
|
||
*buf++ = (uint16) ((M[pa10] >> ((ba & 2)? 0: 18)) & 0177777);
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int32 Map_WriteB (t_addr ba, int32 bc, uint8 *buf, t_bool ub)
|
||
{
|
||
t_addr lim;
|
||
a10 pa10;
|
||
static d10 mask = 0377;
|
||
|
||
lim = ba + bc;
|
||
for ( ; ba < lim; ba++) { /* by bytes */
|
||
pa10 = Map_Addr10 (ba, ub); /* map addr */
|
||
if ((pa10 < 0) || MEM_ADDR_NXM (pa10)) { /* inv map or NXM? */
|
||
ubcs[ub] = ubcs[ub] | UBCS_TMO; /* UBA times out */
|
||
return (lim - ba); } /* return bc */
|
||
M[pa10] = (M[pa10] & ~(mask << ubashf[ba & 3])) |
|
||
(((d10) *buf++) << ubashf[ba & 3]); }
|
||
return 0;
|
||
}
|
||
|
||
int32 Map_WriteW (t_addr ba, int32 bc, uint16 *buf, t_bool ub)
|
||
{
|
||
t_addr lim;
|
||
a10 pa10;
|
||
d10 val;
|
||
|
||
ba = ba & ~01; /* align start */
|
||
lim = ba + (bc & ~01);
|
||
for ( ; ba < lim; ba++) { /* by bytes */
|
||
pa10 = Map_Addr10 (ba, ub); /* map addr */
|
||
if ((pa10 < 0) || MEM_ADDR_NXM (pa10)) { /* inv map or NXM? */
|
||
ubcs[ub] = ubcs[ub] | UBCS_TMO; /* UBA times out */
|
||
return (lim - ba); } /* return bc */
|
||
val = *buf++; /* get data */
|
||
if (ba & 2) M[pa10] = (M[pa10] & 0777777600000) | val;
|
||
else M[pa10] = (M[pa10] & 0600000777777) | (val << 18);
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
/* Evaluate Unibus priority interrupts */
|
||
|
||
int32 pi_ub_eval ()
|
||
{
|
||
int32 i, lvl;
|
||
|
||
for (i = lvl = 0; i < UBANUM; i++) {
|
||
if (int_req & ubabr76[i])
|
||
lvl = lvl | pi_l2bit[UBCS_GET_HI (ubcs[i])];
|
||
if (int_req & ubabr54[i])
|
||
lvl = lvl | pi_l2bit[UBCS_GET_LO (ubcs[i])]; }
|
||
return lvl;
|
||
}
|
||
|
||
/* Return Unibus device vector
|
||
|
||
Takes as input the request level calculated by pi_eval
|
||
If there is an interrupting Unibus device at that level, return its vector,
|
||
otherwise, returns 0
|
||
*/
|
||
|
||
int32 pi_ub_vec (int32 rlvl, int32 *uba)
|
||
{
|
||
int32 i, masked_irq;
|
||
|
||
for (i = masked_irq = 0; i < UBANUM; i++) {
|
||
if ((rlvl == UBCS_GET_HI (ubcs[i])) && /* req on hi level? */
|
||
(masked_irq = int_req & ubabr76[i])) break;
|
||
if ((rlvl == UBCS_GET_LO (ubcs[i])) && /* req on lo level? */
|
||
(masked_irq = int_req & ubabr54[i])) break; }
|
||
*uba = (i << 1) + 1; /* store uba # */
|
||
for (i = 0; (i < 32) && masked_irq; i++) { /* find hi pri req */
|
||
if ((masked_irq >> i) & 1) {
|
||
int_req = int_req & ~(1u << i); /* clear req */
|
||
if (int_ack[i]) return int_ack[i]();
|
||
return int_vec[i]; } } /* return vector */
|
||
return 0;
|
||
}
|
||
|
||
/* Unibus adapter map routines */
|
||
|
||
t_stat ubmap_rd (int32 *val, int32 pa, int32 mode)
|
||
{
|
||
int32 n = iocmap[GET_IOUBA (pa)];
|
||
|
||
if (n < 0) ABORT (STOP_ILLIOC);
|
||
*val = ubmap[n][pa & UMAP_AMASK];
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat ubmap_wr (int32 val, int32 pa, int32 mode)
|
||
{
|
||
int32 n = iocmap[GET_IOUBA (pa)];
|
||
|
||
if (n < 0) ABORT (STOP_ILLIOC);
|
||
ubmap[n][pa & UMAP_AMASK] = UMAP_POSFL (val) | UMAP_POSPN (val);
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Unibus adapter control/status routines */
|
||
|
||
t_stat ubs_rd (int32 *val, int32 pa, int32 mode)
|
||
{
|
||
int32 n = iocmap[GET_IOUBA (pa)];
|
||
|
||
if (n < 0) ABORT (STOP_ILLIOC);
|
||
if (int_req & ubabr76[n]) ubcs[n] = ubcs[n] | UBCS_HI;
|
||
if (int_req & ubabr54[n]) ubcs[n] = ubcs[n] | UBCS_LO;
|
||
*val = ubcs[n] = ubcs[n] & ~UBCS_RDZ;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat ubs_wr (int32 val, int32 pa, int32 mode)
|
||
{
|
||
int32 n = iocmap[GET_IOUBA (pa)];
|
||
|
||
if (n < 0) ABORT (STOP_ILLIOC);
|
||
if (val & UBCS_INI) {
|
||
reset_all (5); /* start after UBA */
|
||
ubcs[n] = val & UBCS_DXF; }
|
||
else ubcs[n] = val & UBCS_RDW;
|
||
if (int_req & ubabr76[n]) ubcs[n] = ubcs[n] | UBCS_HI;
|
||
if (int_req & ubabr54[n]) ubcs[n] = ubcs[n] | UBCS_LO;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Unibus adapter read zero/write ignore routines */
|
||
|
||
t_stat rd_zro (int32 *val, int32 pa, int32 mode)
|
||
{
|
||
*val = 0;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat wr_nop (int32 val, int32 pa, int32 mode)
|
||
{
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat uba_ex (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw)
|
||
{
|
||
int32 uba = uptr - uba_unit;
|
||
|
||
if (addr >= UMAP_MEMSIZE) return SCPE_NXM;
|
||
*vptr = ubmap[uba][addr];
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat uba_dep (t_value val, t_addr addr, UNIT *uptr, int32 sw)
|
||
{
|
||
int32 uba = uptr - uba_unit;
|
||
|
||
if (addr >= UMAP_MEMSIZE) return SCPE_NXM;
|
||
ubmap[uba][addr] = (int32) val & UMAP_MASK;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat uba_reset (DEVICE *dptr)
|
||
{
|
||
int32 i, uba;
|
||
|
||
int_req = 0;
|
||
for (uba = 0; uba < UBANUM; uba++) {
|
||
ubcs[uba] = 0;
|
||
for (i = 0; i < UMAP_MEMSIZE; i++) ubmap[uba][i] = 0; }
|
||
pi_eval ();
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Change device address */
|
||
|
||
t_stat set_addr (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||
{
|
||
DEVICE *dptr;
|
||
DIB *dibp;
|
||
uint32 newba;
|
||
t_stat r;
|
||
|
||
if (cptr == NULL) return SCPE_ARG;
|
||
if ((val == 0) || (uptr == NULL)) return SCPE_IERR;
|
||
dptr = find_dev_from_unit (uptr);
|
||
if (dptr == NULL) return SCPE_IERR;
|
||
dibp = (DIB *) dptr->ctxt;
|
||
if (dibp == NULL) return SCPE_IERR;
|
||
newba = (uint32) get_uint (cptr, 8, PAMASK, &r); /* get new */
|
||
if ((r != SCPE_OK) || (newba == dibp->ba)) return r;
|
||
if (GET_IOUBA (newba) != GET_IOUBA (dibp->ba)) return SCPE_ARG;
|
||
if (newba % ((uint32) val)) return SCPE_ARG; /* check modulus */
|
||
if (GET_IOUBA (newba) != GET_IOUBA (dibp->ba)) return SCPE_ARG;
|
||
dibp->ba = newba; /* store */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Show device address */
|
||
|
||
t_stat show_addr (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||
{
|
||
DEVICE *dptr;
|
||
DIB *dibp;
|
||
|
||
if (uptr == NULL) return SCPE_IERR;
|
||
dptr = find_dev_from_unit (uptr);
|
||
if (dptr == NULL) return SCPE_IERR;
|
||
dibp = (DIB *) dptr->ctxt;
|
||
if ((dibp == NULL) || (dibp->ba <= IOPAGEBASE)) return SCPE_IERR;
|
||
fprintf (st, "address=%07o", dibp->ba);
|
||
if (dibp->lnt > 1)
|
||
fprintf (st, "-%07o", dibp->ba + dibp->lnt - 1);
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Change device vector */
|
||
|
||
t_stat set_vec (UNIT *uptr, int32 arg, char *cptr, void *desc)
|
||
{
|
||
DEVICE *dptr;
|
||
DIB *dibp;
|
||
uint32 newvec;
|
||
t_stat r;
|
||
|
||
if (cptr == NULL) return SCPE_ARG;
|
||
if (uptr == NULL) return SCPE_IERR;
|
||
dptr = find_dev_from_unit (uptr);
|
||
if (dptr == NULL) return SCPE_IERR;
|
||
dibp = (DIB *) dptr->ctxt;
|
||
if (dibp == NULL) return SCPE_IERR;
|
||
newvec = (uint32) get_uint (cptr, 8, VEC_Q + 01000, &r);
|
||
if ((r != SCPE_OK) || (newvec <= VEC_Q) ||
|
||
((newvec + (dibp->vnum * 4)) >= (VEC_Q + 01000)) ||
|
||
(newvec & ((dibp->vnum > 1)? 07: 03))) return SCPE_ARG;
|
||
dibp->vec = newvec;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Show device vector */
|
||
|
||
t_stat show_vec (FILE *st, UNIT *uptr, int32 arg, void *desc)
|
||
{
|
||
DEVICE *dptr;
|
||
DIB *dibp;
|
||
uint32 vec, numvec;
|
||
|
||
if (uptr == NULL) return SCPE_IERR;
|
||
dptr = find_dev_from_unit (uptr);
|
||
if (dptr == NULL) return SCPE_IERR;
|
||
dibp = (DIB *) dptr->ctxt;
|
||
if (dibp == NULL) return SCPE_IERR;
|
||
vec = dibp->vec;
|
||
if (arg) numvec = arg;
|
||
else numvec = dibp->vnum;
|
||
if (vec == 0) fprintf (st, "no vector");
|
||
else { fprintf (st, "vector=%o", vec);
|
||
if (numvec > 1) fprintf (st, "-%o", vec + (4 * (numvec - 1))); }
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Test for conflict in device addresses */
|
||
|
||
t_bool dev_conflict (DIB *curr)
|
||
{
|
||
uint32 i, end;
|
||
DEVICE *dptr;
|
||
DIB *dibp;
|
||
|
||
end = curr->ba + curr->lnt - 1; /* get end */
|
||
for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru dev */
|
||
dibp = (DIB *) dptr->ctxt; /* get DIB */
|
||
if ((dibp == NULL) || (dibp == curr) ||
|
||
(dptr->flags & DEV_DIS)) continue;
|
||
if (((curr->ba >= dibp->ba) && /* overlap start? */
|
||
(curr->ba < (dibp->ba + dibp->lnt))) ||
|
||
((end >= dibp->ba) && /* overlap end? */
|
||
(end < (dibp->ba + dibp->lnt)))) {
|
||
printf ("Device %s address conflict at %08o\n", dptr->name, dibp->ba);
|
||
if (sim_log) fprintf (sim_log,
|
||
"Device %s address conflict at %08o\n", dptr->name, dibp->ba);
|
||
return TRUE; } }
|
||
return FALSE;
|
||
}
|
||
|
||
/* Build interrupt tables */
|
||
|
||
void build_int_vec (int32 vloc, int32 ivec, int32 (*iack)(void) )
|
||
{
|
||
if (iack != NULL) int_ack[vloc] = iack;
|
||
else int_vec[vloc] = ivec;
|
||
return;
|
||
}
|
||
|
||
/* Build dib_tab from device list */
|
||
|
||
t_bool build_dib_tab (void)
|
||
{
|
||
int32 i, j, k;
|
||
DEVICE *dptr;
|
||
DIB *dibp;
|
||
|
||
for (i = 0; i < 32; i++) { /* clear intr tables */
|
||
int_vec[i] = 0;
|
||
int_ack[i] = NULL; }
|
||
for (i = j = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru dev */
|
||
dibp = (DIB *) dptr->ctxt; /* get DIB */
|
||
if (dibp && !(dptr->flags & DEV_DIS)) { /* defined, enabled? */
|
||
if (dibp->vnum > VEC_DEVMAX) return SCPE_IERR;
|
||
for (k = 0; k < dibp->vnum; k++) /* loop thru vec */
|
||
build_int_vec (dibp->vloc + k, /* add vector */
|
||
dibp->vec + (k * 4), dibp->ack[k]);
|
||
if (dibp->lnt != 0) { /* I/O addresses? */
|
||
dib_tab[j++] = dibp; /* add DIB to dib_tab */
|
||
if (j >= DIB_MAX) return SCPE_IERR; } /* too many? */
|
||
} /* end if enabled */
|
||
} /* end for */
|
||
for (i = 0; (dibp = std_dib[i]) != NULL; i++) { /* loop thru std */
|
||
dib_tab[j++] = dibp; /* add to dib_tab */
|
||
if (j >= DIB_MAX) return SCPE_IERR; } /* too many? */
|
||
dib_tab[j] = NULL; /* end with NULL */
|
||
for (i = 0; (dibp = dib_tab[i]) != NULL; i++) { /* test built dib_tab */
|
||
if (dev_conflict (dibp)) return SCPE_STOP; } /* for conflicts */
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Show dib_tab */
|
||
|
||
t_stat show_iospace (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||
{
|
||
int32 i, j, done = 0;
|
||
DEVICE *dptr;
|
||
DIB *dibt;
|
||
|
||
build_dib_tab (); /* build table */
|
||
while (done == 0) { /* sort ascending */
|
||
done = 1; /* assume done */
|
||
for (i = 0; dib_tab[i + 1] != NULL; i++) { /* check table */
|
||
if (dib_tab[i]->ba > dib_tab[i + 1]->ba) { /* out of order? */
|
||
dibt = dib_tab[i]; /* interchange */
|
||
dib_tab[i] = dib_tab[i + 1];
|
||
dib_tab[i + 1] = dibt;
|
||
done = 0; } } /* not done */
|
||
} /* end while */
|
||
for (i = 0; dib_tab[i] != NULL; i++) { /* print table */
|
||
for (j = 0, dptr = NULL; sim_devices[j] != NULL; j++) {
|
||
if (((DIB*) sim_devices[j]->ctxt) == dib_tab[i]) {
|
||
dptr = sim_devices[j];
|
||
break; } }
|
||
fprintf (st, "%07o - %07o\t%s\n", dib_tab[i]->ba,
|
||
dib_tab[i]->ba + dib_tab[i]->lnt - 1,
|
||
dptr? dptr->name: "CPU");
|
||
}
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Stub auto-configure */
|
||
|
||
t_stat auto_config (uint32 rank, uint32 num)
|
||
{
|
||
return SCPE_OK;
|
||
}
|