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.
409 lines
14 KiB
C
409 lines
14 KiB
C
/* pdp8_rk.c: RK8E cartridge disk 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.
|
||
|
||
rk RK8E/RK05 cartridge disk
|
||
|
||
04-Oct-02 RMS Added DIB, device number support
|
||
06-Jan-02 RMS Changed enable/disable support
|
||
30-Nov-01 RMS Added read only unit, extended SET/SHOW support
|
||
24-Nov-01 RMS Converted FLG to array, made register names consistent
|
||
25-Apr-01 RMS Added device enable/disable support
|
||
29-Jun-96 RMS Added unit enable/disable support
|
||
*/
|
||
|
||
#include "pdp8_defs.h"
|
||
|
||
/* Constants */
|
||
|
||
#define RK_NUMSC 16 /* sectors/surface */
|
||
#define RK_NUMSF 2 /* surfaces/cylinder */
|
||
#define RK_NUMCY 203 /* cylinders/drive */
|
||
#define RK_NUMWD 256 /* words/sector */
|
||
#define RK_SIZE (RK_NUMCY * RK_NUMSF * RK_NUMSC * RK_NUMWD) /* words/drive */
|
||
#define RK_NUMDR 4 /* drives/controller */
|
||
#define RK_M_NUMDR 03
|
||
|
||
/* Flags in the unit flags word */
|
||
|
||
#define UNIT_V_HWLK (UNIT_V_UF + 0) /* hwre write lock */
|
||
#define UNIT_V_SWLK (UNIT_V_UF + 1) /* swre write lock */
|
||
#define UNIT_HWLK (1 << UNIT_V_HWLK)
|
||
#define UNIT_SWLK (1 << UNIT_V_SWLK)
|
||
#define UNIT_WPRT (UNIT_HWLK|UNIT_SWLK|UNIT_RO) /* write protect */
|
||
|
||
/* Parameters in the unit descriptor */
|
||
|
||
#define CYL u3 /* current cylinder */
|
||
#define FUNC u4 /* function */
|
||
|
||
/* Status register */
|
||
|
||
#define RKS_DONE 04000 /* transfer done */
|
||
#define RKS_HMOV 02000 /* heads moving */
|
||
#define RKS_SKFL 00400 /* drive seek fail */
|
||
#define RKS_NRDY 00200 /* drive not ready */
|
||
#define RKS_BUSY 00100 /* control busy error */
|
||
#define RKS_TMO 00040 /* timeout error */
|
||
#define RKS_WLK 00020 /* write lock error */
|
||
#define RKS_CRC 00010 /* CRC error */
|
||
#define RKS_DLT 00004 /* data late error */
|
||
#define RKS_STAT 00002 /* drive status error */
|
||
#define RKS_CYL 00001 /* cyl address error */
|
||
#define RKS_ERR (RKS_BUSY+RKS_TMO+RKS_WLK+RKS_CRC+RKS_DLT+RKS_STAT+RKS_CYL)
|
||
|
||
/* Command register */
|
||
|
||
#define RKC_M_FUNC 07 /* function */
|
||
#define RKC_READ 0
|
||
#define RKC_RALL 1
|
||
#define RKC_WLK 2
|
||
#define RKC_SEEK 3
|
||
#define RKC_WRITE 4
|
||
#define RKC_WALL 5
|
||
#define RKC_V_FUNC 9
|
||
#define RKC_IE 00400 /* interrupt enable */
|
||
#define RKC_SKDN 00200 /* int on seek done */
|
||
#define RKC_HALF 00100 /* 128W sector */
|
||
#define RKC_MEX 00070 /* memory extension */
|
||
#define RKC_V_MEX 3
|
||
#define RKC_M_DRV 03 /* drive select */
|
||
#define RKC_V_DRV 1
|
||
#define RKC_CYHI 00001 /* high cylinder addr */
|
||
|
||
#define GET_FUNC(x) (((x) >> RKC_V_FUNC) & RKC_M_FUNC)
|
||
#define GET_DRIVE(x) (((x) >> RKC_V_DRV) & RKC_M_DRV)
|
||
#define GET_MEX(x) (((x) & RKC_MEX) << (12 - RKC_V_MEX))
|
||
|
||
/* Disk address */
|
||
|
||
#define RKD_V_SECT 0 /* sector */
|
||
#define RKD_M_SECT 017
|
||
#define RKD_V_SUR 4 /* surface */
|
||
#define RKD_M_SUR 01
|
||
#define RKD_V_CYL 5 /* cylinder */
|
||
#define RKD_M_CYL 0177
|
||
#define GET_CYL(x,y) ((((x) & RKC_CYHI) << (12-RKD_V_CYL)) | \
|
||
(((y) >> RKD_V_CYL) & RKD_M_CYL))
|
||
#define GET_DA(x,y) ((((x) & RKC_CYHI) << 12) | y)
|
||
|
||
/* Reset commands */
|
||
|
||
#define RKX_CLS 0 /* clear status */
|
||
#define RKX_CLC 1 /* clear control */
|
||
#define RKX_CLD 2 /* clear drive */
|
||
#define RKX_CLSA 3 /* clear status alt */
|
||
|
||
#define RK_INT_UPDATE \
|
||
if (((rk_sta & (RKS_DONE + RKS_ERR)) != 0) && \
|
||
((rk_cmd & RKC_IE) != 0)) int_req = int_req | INT_RK; \
|
||
else int_req = int_req & ~INT_RK
|
||
#define RK_MIN 10
|
||
#define MAX(x,y) (((x) > (y))? (x): (y))
|
||
|
||
extern uint16 M[];
|
||
extern int32 int_req, stop_inst;
|
||
extern UNIT cpu_unit;
|
||
|
||
int32 rk_busy = 0; /* controller busy */
|
||
int32 rk_sta = 0; /* status register */
|
||
int32 rk_cmd = 0; /* command register */
|
||
int32 rk_da = 0; /* disk address */
|
||
int32 rk_ma = 0; /* memory address */
|
||
int32 rk_swait = 10, rk_rwait = 10; /* seek, rotate wait */
|
||
int32 rk_stopioe = 1; /* stop on error */
|
||
|
||
DEVICE rk_dev;
|
||
int32 rk (int32 IR, int32 AC);
|
||
t_stat rk_svc (UNIT *uptr);
|
||
t_stat rk_reset (DEVICE *dptr);
|
||
t_stat rk_boot (int32 unitno, DEVICE *dptr);
|
||
void rk_go (int32 function, int32 cylinder);
|
||
|
||
/* RK-8E data structures
|
||
|
||
rk_dev RK device descriptor
|
||
rk_unit RK unit list
|
||
rk_reg RK register list
|
||
rk_mod RK modifiers list
|
||
*/
|
||
|
||
DIB rk_dib = { DEV_RK, 1, { &rk } };
|
||
|
||
UNIT rk_unit[] = {
|
||
{ UDATA (&rk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+
|
||
UNIT_ROABLE, RK_SIZE) },
|
||
{ UDATA (&rk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+
|
||
UNIT_ROABLE, RK_SIZE) },
|
||
{ UDATA (&rk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+
|
||
UNIT_ROABLE, RK_SIZE) },
|
||
{ UDATA (&rk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE+
|
||
UNIT_ROABLE, RK_SIZE) } };
|
||
|
||
REG rk_reg[] = {
|
||
{ ORDATA (RKSTA, rk_sta, 12) },
|
||
{ ORDATA (RKCMD, rk_cmd, 12) },
|
||
{ ORDATA (RKDA, rk_da, 12) },
|
||
{ ORDATA (RKMA, rk_ma, 12) },
|
||
{ FLDATA (BUSY, rk_busy, 0) },
|
||
{ FLDATA (INT, int_req, INT_V_RK) },
|
||
{ DRDATA (STIME, rk_swait, 24), PV_LEFT },
|
||
{ DRDATA (RTIME, rk_rwait, 24), PV_LEFT },
|
||
{ FLDATA (STOP_IOE, rk_stopioe, 0) },
|
||
{ ORDATA (DEVNUM, rk_dib.dev, 6), REG_HRO },
|
||
{ NULL } };
|
||
|
||
MTAB rk_mod[] = {
|
||
{ UNIT_HWLK, 0, "write enabled", "WRITEENABLED", NULL },
|
||
{ UNIT_HWLK, UNIT_HWLK, "write locked", "LOCKED", NULL },
|
||
{ MTAB_XTD|MTAB_VDV, 0, "DEVNO", "DEVNO",
|
||
&set_dev, &show_dev, NULL },
|
||
{ 0 } };
|
||
|
||
DEVICE rk_dev = {
|
||
"RK", rk_unit, rk_reg, rk_mod,
|
||
RK_NUMDR, 8, 24, 1, 8, 12,
|
||
NULL, NULL, &rk_reset,
|
||
&rk_boot, NULL, NULL,
|
||
&rk_dib, DEV_DISABLE };
|
||
|
||
/* IOT routine */
|
||
|
||
int32 rk (int32 IR, int32 AC)
|
||
{
|
||
int32 i;
|
||
UNIT *uptr;
|
||
|
||
switch (IR & 07) { /* decode IR<9:11> */
|
||
case 0: /* unused */
|
||
return (stop_inst << IOT_V_REASON) + AC;
|
||
case 1: /* DSKP */
|
||
return (rk_sta & (RKS_DONE + RKS_ERR))? /* skip on done, err */
|
||
IOT_SKP + AC: AC;
|
||
case 2: /* DCLR */
|
||
rk_sta = 0; /* clear status */
|
||
switch (AC & 03) { /* decode AC<10:11> */
|
||
case RKX_CLS: /* clear status */
|
||
if (rk_busy != 0) rk_sta = rk_sta | RKS_BUSY;
|
||
case RKX_CLSA: /* clear status alt */
|
||
break;
|
||
case RKX_CLC: /* clear control */
|
||
rk_cmd = rk_busy = 0; /* clear registers */
|
||
rk_ma = rk_da = 0;
|
||
for (i = 0; i < RK_NUMDR; i++) sim_cancel (&rk_unit[i]);
|
||
break;
|
||
case RKX_CLD: /* reset drive */
|
||
if (rk_busy != 0) rk_sta = rk_sta | RKS_BUSY;
|
||
else rk_go (RKC_SEEK, 0); /* seek to 0 */
|
||
break; } /* end switch AC */
|
||
break;
|
||
case 3: /* DLAG */
|
||
if (rk_busy != 0) rk_sta = rk_sta | RKS_BUSY;
|
||
else {
|
||
rk_da = AC; /* load disk addr */
|
||
rk_go (GET_FUNC (rk_cmd), GET_CYL (rk_cmd, rk_da)); }
|
||
break;
|
||
case 4: /* DLCA */
|
||
if (rk_busy != 0) rk_sta = rk_sta | RKS_BUSY;
|
||
else rk_ma = AC; /* load curr addr */
|
||
break;
|
||
case 5: /* DRST */
|
||
uptr = rk_dev.units + GET_DRIVE (rk_cmd); /* selected unit */
|
||
rk_sta = rk_sta & ~(RKS_HMOV + RKS_NRDY); /* clear dynamic */
|
||
if ((uptr->flags & UNIT_ATT) == 0) rk_sta = rk_sta | RKS_NRDY;
|
||
if (sim_is_active (uptr)) rk_sta = rk_sta | RKS_HMOV;
|
||
return rk_sta;
|
||
case 6: /* DLDC */
|
||
if (rk_busy != 0) rk_sta = rk_sta | RKS_BUSY;
|
||
else {
|
||
rk_cmd = AC; /* load command */
|
||
rk_sta = 0; } /* clear status */
|
||
break;
|
||
case 7: /* DMAN */
|
||
break; } /* end case pulse */
|
||
RK_INT_UPDATE; /* update int req */
|
||
return 0; /* clear AC */
|
||
}
|
||
|
||
/* Initiate new function
|
||
|
||
Called with function, cylinder, to allow recalibrate as well as
|
||
load and go to be processed by this routine.
|
||
|
||
Assumes that the controller is idle, and that updating of interrupt
|
||
request will be done by the caller.
|
||
*/
|
||
|
||
void rk_go (int32 func, int32 cyl)
|
||
{
|
||
int32 t;
|
||
UNIT *uptr;
|
||
|
||
if (func == RKC_RALL) func = RKC_READ; /* all? use standard */
|
||
if (func == RKC_WALL) func = RKC_WRITE;
|
||
uptr = rk_dev.units + GET_DRIVE (rk_cmd); /* selected unit */
|
||
if ((uptr->flags & UNIT_ATT) == 0) { /* not attached? */
|
||
rk_sta = rk_sta | RKS_DONE | RKS_NRDY | RKS_STAT;
|
||
return; }
|
||
if (sim_is_active (uptr) || (cyl >= RK_NUMCY)) { /* busy or bad cyl? */
|
||
rk_sta = rk_sta | RKS_DONE | RKS_STAT;
|
||
return; }
|
||
if ((func == RKC_WRITE) && (uptr->flags & UNIT_WPRT)) {
|
||
rk_sta = rk_sta | RKS_DONE | RKS_WLK; /* write and locked? */
|
||
return; }
|
||
if (func == RKC_WLK) { /* write lock? */
|
||
uptr->flags = uptr->flags | UNIT_SWLK;
|
||
rk_sta = rk_sta | RKS_DONE;
|
||
return; }
|
||
t = abs (cyl - uptr->CYL) * rk_swait; /* seek time */
|
||
if (func == RKC_SEEK) { /* seek? */
|
||
sim_activate (uptr, MAX (RK_MIN, t)); /* schedule */
|
||
rk_sta = rk_sta | RKS_DONE; } /* set done */
|
||
else { sim_activate (uptr, t + rk_rwait); /* schedule */
|
||
rk_busy = 1; } /* set busy */
|
||
uptr->FUNC = func; /* save func */
|
||
uptr->CYL = cyl; /* put on cylinder */
|
||
return;
|
||
}
|
||
|
||
/* Unit service
|
||
|
||
If seek, complete seek command
|
||
Else complete data transfer command
|
||
|
||
The unit control block contains the function and cylinder address for
|
||
the current command.
|
||
|
||
Note that memory addresses wrap around in the current field.
|
||
*/
|
||
|
||
static uint16 fill[RK_NUMWD/2] = { 0 };
|
||
t_stat rk_svc (UNIT *uptr)
|
||
{
|
||
int32 err, wc, wc1, awc, swc, pa, da;
|
||
UNIT *seluptr;
|
||
|
||
if (uptr->FUNC == RKC_SEEK) { /* seek? */
|
||
seluptr = rk_dev.units + GET_DRIVE (rk_cmd); /* see if selected */
|
||
if ((uptr == seluptr) && ((rk_cmd & RKC_SKDN) != 0)) {
|
||
rk_sta = rk_sta | RKS_DONE;
|
||
RK_INT_UPDATE; }
|
||
return SCPE_OK; }
|
||
|
||
if ((uptr->flags & UNIT_ATT) == 0) { /* not att? abort */
|
||
rk_sta = rk_sta | RKS_DONE | RKS_NRDY | RKS_STAT;
|
||
rk_busy = 0;
|
||
RK_INT_UPDATE;
|
||
return IORETURN (rk_stopioe, SCPE_UNATT); }
|
||
|
||
if ((uptr->FUNC == RKC_WRITE) && (uptr->flags & UNIT_WPRT)) {
|
||
rk_sta = rk_sta | RKS_DONE | RKS_WLK; /* write and locked? */
|
||
rk_busy = 0;
|
||
RK_INT_UPDATE;
|
||
return SCPE_OK; }
|
||
|
||
pa = GET_MEX (rk_cmd) | rk_ma; /* phys address */
|
||
da = GET_DA (rk_cmd, rk_da) * RK_NUMWD * sizeof (int16);/* disk address */
|
||
swc = wc = (rk_cmd & RKC_HALF)? RK_NUMWD / 2: RK_NUMWD; /* get transfer size */
|
||
if ((wc1 = ((rk_ma + wc) - 010000)) > 0) wc = wc - wc1; /* if wrap, limit */
|
||
err = fseek (uptr->fileref, da, SEEK_SET); /* locate sector */
|
||
|
||
if ((uptr->FUNC == RKC_READ) && (err == 0) && MEM_ADDR_OK (pa)) { /* read? */
|
||
awc = fxread (&M[pa], sizeof (int16), wc, uptr->fileref);
|
||
for ( ; awc < wc; awc++) M[pa + awc] = 0; /* fill if eof */
|
||
err = ferror (uptr->fileref);
|
||
if ((wc1 > 0) && (err == 0)) { /* field wraparound? */
|
||
pa = pa & 070000; /* wrap phys addr */
|
||
awc = fxread (&M[pa], sizeof (int16), wc1, uptr->fileref);
|
||
for ( ; awc < wc1; awc++) M[pa + awc] = 0; /* fill if eof */
|
||
err = ferror (uptr->fileref); } }
|
||
|
||
if ((uptr->FUNC == RKC_WRITE) && (err == 0)) { /* write? */
|
||
fxwrite (&M[pa], sizeof (int16), wc, uptr->fileref);
|
||
err = ferror (uptr->fileref);
|
||
if ((wc1 > 0) && (err == 0)) { /* field wraparound? */
|
||
pa = pa & 070000; /* wrap phys addr */
|
||
fxwrite (&M[pa], sizeof (int16), wc1, uptr->fileref);
|
||
err = ferror (uptr->fileref); }
|
||
if ((rk_cmd & RKC_HALF) && (err == 0)) { /* fill half sector */
|
||
fxwrite (fill, sizeof (int16), RK_NUMWD/2, uptr->fileref);
|
||
err = ferror (uptr->fileref); } }
|
||
|
||
rk_ma = (rk_ma + swc) & 07777; /* incr mem addr reg */
|
||
rk_sta = rk_sta | RKS_DONE; /* set done */
|
||
rk_busy = 0;
|
||
RK_INT_UPDATE;
|
||
|
||
if (err != 0) {
|
||
perror ("RK I/O error");
|
||
clearerr (uptr->fileref);
|
||
return SCPE_IOERR; }
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Reset routine */
|
||
|
||
t_stat rk_reset (DEVICE *dptr)
|
||
{
|
||
int32 i;
|
||
UNIT *uptr;
|
||
|
||
rk_cmd = rk_ma = rk_da = rk_sta = rk_busy = 0;
|
||
int_req = int_req & ~INT_RK; /* clear interrupt */
|
||
for (i = 0; i < RK_NUMDR; i++) { /* stop all units */
|
||
uptr = rk_dev.units + i;
|
||
sim_cancel (uptr);
|
||
uptr->flags = uptr->flags & ~UNIT_SWLK;
|
||
uptr->CYL = uptr->FUNC = 0; }
|
||
return SCPE_OK;
|
||
}
|
||
|
||
/* Bootstrap routine */
|
||
|
||
#define BOOT_START 023
|
||
#define BOOT_UNIT 032
|
||
#define BOOT_LEN (sizeof (boot_rom) / sizeof (int16))
|
||
|
||
static const uint16 boot_rom[] = {
|
||
06007, /* 23, CAF */
|
||
06744, /* 24, DLCA ; addr = 0 */
|
||
01032, /* 25, TAD UNIT ; unit no */
|
||
06746, /* 26, DLDC ; command, unit */
|
||
06743, /* 27, DLAG ; disk addr, go */
|
||
01032, /* 30, TAD UNIT ; unit no, for OS */
|
||
05031, /* 31, JMP . */
|
||
00000 /* UNIT, 0 ; in bits <9:10> */
|
||
};
|
||
|
||
t_stat rk_boot (int32 unitno, DEVICE *dptr)
|
||
{
|
||
int32 i;
|
||
extern int32 saved_PC;
|
||
|
||
if (rk_dib.dev != DEV_RK) return STOP_NOTSTD; /* only std devno */
|
||
for (i = 0; i < BOOT_LEN; i++) M[BOOT_START + i] = boot_rom[i];
|
||
M[BOOT_UNIT] = (unitno & RK_M_NUMDR) << 1;
|
||
saved_PC = BOOT_START;
|
||
return SCPE_OK;
|
||
}
|