1. New Features 1.1 Directory and documentation - Only common files (SCP and libraries) are in the top level directory. Individual simulator files are in their individual directories. - simh_doc.txt has been split up. simh_doc.txt now documents only SCP. The individual simulators are documented in separate text files in their own directories. - mingw_build.bat is a batch file for the MINGW/gcc environment that will build all the simulators, assuming the root directory structure is at c:\sim. - Makefile is a UNIX make file for the gcc environment that will build all the simulators, assuming the root directory is at c:\sim. 1.2 SCP - DO <file name> executes the SCP commands in the specified file. - Replicated registers in unit structures can now be declared as arrays for examine, modify, save, and restore. Most replicated unit registers (for example, mag tape position registers) have been changed to arrays. - The ADD/REMOVE commands have been replaced by SET unit ONLINE and SET unit OFFLINE, respectively. - Register names that are unique within an entire simulator do not have to be prefaced with the device name. - The ATTACH command can attach files read only, either under user option (-r), or because the attached file is ready only. - The SET/SHOW capabilities have been extended. New forms include: SET <dev> param{=value}{ param ...} SET <unit> param{=value}{ param ...} SHOW <dev> {param param ...} SHOW <unit> {param param ...} - Multiple breakpoints have been implemented. Breakpoints are set/cleared/displayed by: BREAK addr_list{[count]} NOBREAK addr_list SHOW BREAK addr_list 1.3 PDP-11 simulator - Unibus map implemented, with 22b RP controller (URH70) or 18b RP controller (URH11) (in debug). - All DMA peripherals rewritten to use map. - Many peripherals modified for source sharing with VAX. - RQDX3 implemented. - Bugs fixed in RK11 and RL11 write check. 1.4 PDP-10 simulator - ITS 1-proceed implemented. - Bugs fixed in ITS PC sampling and LPMR 1.5 18b PDP simulator - Interrupts split out to multiple levels to allow easier expansion. 1.5 IBM System 3 Simulator - Written by Charles (Dutch) Owen. 1.6 VAX Simulator (in debug) - Simulates MicroVAX 3800 (KA655) with 16MB-64MB memory, RQDX3, RLV12, TSV11, DZV11, LPV11, PCV11. - CDROM capability has been added to the RQDX3, to allow testing with VMS hobbyist images. 1.7 SDS 940 Simulator (not tested) - Simulates SDS 940, 16K-64K memory, fixed and moving head disk, magtape, line printer, console. 1.8 Altair Z80 - Revised from Charles (Dutch) Owen's original by Peter Schorn. - MITS 8080 with full Z80 simulation. - 4K and 8K BASIC packages, Prolog package. 1.9 Interdata The I4 simulator has been withdrawn for major rework. Look for a complete 16b/32b Interdata simulator sometime next year. 2. Release Notes 2.1 SCP SCP now allows replicated registers in unit structures to be modelled as arrays. All replicated register declarations have been replaced by register array declarations. As a result, save files from prior revisions will generate errors after restoring main memory. 2.2 PDP-11 The Unibus map code is in debug. The map was implemented primarily to allow source sharing with the VAX, which requires a DMA map. DMA devices work correctly with the Unibus map disabled. The RQDX3 simulator has run a complete RSTS/E SYSGEN, with multiple drives, and booted the completed system from scratch. 2.3 VAX The VAX simulator will run the boot code up to the >>> prompt. It can successfully process a SHOW DEVICE command. It runs the HCORE instruction diagnostic. It can boot the hobbyist CD through SYSBOOT and through the date/time dialog and restore the hobbyist CD, using standalone backup. On the boot of the restored disk, it gets to the date/time dialog, and then crashes. 2.4 SDS 940 The SDS 940 is untested, awaiting real code. 2.5 GCC Optimization At -O2 and above, GCC does not correctly compile the simulators which use setjmp-longjmp (PDP-11, PDP-10, VAX). A working hypothesis is that optimized state maintained in registers is being used in the setjmp processing routine. On the PDP-11 and PDP-10, all of this state has been either made global, or volatile, to encourage GCC to keep the state up to date in memory. The VAX is still vulnerable. 3. Work list 3.1 SCP - Better ENABLE/DISABLE. 3.2 PDP-11 RQDX3 Software mapped mode, RCT read simulation, VMS debug.
345 lines
11 KiB
C
345 lines
11 KiB
C
/* altair_dsk.c: MITS Altair 88-DISK Simulator
|
|
|
|
The 88_DISK is a 8-inch floppy controller which can control up
|
|
to 16 daisy-chained Pertec FD-400 hard-sectored floppy drives.
|
|
Each diskette has physically 77 tracks of 32 137-byte sectors
|
|
each.
|
|
|
|
The controller is interfaced to the CPU by use of 3 I/O addreses,
|
|
standardly, these are device numbers 10, 11, and 12 (octal).
|
|
|
|
Address Mode Function
|
|
------- ---- --------
|
|
|
|
10 Out Selects and enables Controller and Drive
|
|
10 In Indicates status of Drive and Controller
|
|
11 Out Controls Disk Function
|
|
11 In Indicates current sector position of disk
|
|
12 Out Write data
|
|
12 In Read data
|
|
|
|
Drive Select Out (Device 10 OUT):
|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
| C | X | X | X | Device |
|
|
+---+---+---+---+---+---+---+---+
|
|
|
|
C = If this bit is 1, the disk controller selected by 'device' is
|
|
cleared. If the bit is zero, 'device' is selected as the
|
|
device being controlled by subsequent I/O operations.
|
|
X = not used
|
|
Device = value zero thru 15, selects drive to be controlled.
|
|
|
|
Drive Status In (Device 10 IN):
|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
| R | Z | I | X | X | H | M | W |
|
|
+---+---+---+---+---+---+---+---+
|
|
|
|
W - When 0, write circuit ready to write another byte.
|
|
M - When 0, head movement is allowed
|
|
H - When 0, indicates head is loaded for read/write
|
|
X - not used (will be 0)
|
|
I - When 0, indicates interrupts enabled (not used this simulator)
|
|
Z - When 0, indicates head is on track 0
|
|
R - When 0, indicates that read circuit has new byte to read
|
|
|
|
Drive Control (Device 11 OUT):
|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
| W | C | D | E | U | H | O | I |
|
|
+---+---+---+---+---+---+---+---+
|
|
|
|
I - When 1, steps head IN one track
|
|
O - When 1, steps head OUT out track
|
|
H - When 1, loads head to drive surface
|
|
U - When 1, unloads head
|
|
E - Enables interrupts (ignored this simulator)
|
|
D - Disables interrupts (ignored this simulator)
|
|
C - When 1 lowers head current (ignored this simulator)
|
|
W - When 1, starts Write Enable sequence: W bit on device 10
|
|
(see above) will go 1 and data will be read from port 12
|
|
until 137 bytes have been read by the controller from
|
|
that port. The W bit will go off then, and the sector data
|
|
will be written to disk. Before you do this, you must have
|
|
stepped the track to the desired number, and waited until
|
|
the right sector number is presented on device 11 IN, then
|
|
set this bit.
|
|
|
|
Sector Position (Device 11 IN):
|
|
|
|
As the sectors pass by the read head, they are counted and the
|
|
number of the current one is available in this register.
|
|
|
|
+---+---+---+---+---+---+---+---+
|
|
| X | X | Sector Number | T |
|
|
+---+---+---+---+---+---+---+---+
|
|
|
|
X = Not used
|
|
Sector number = binary of the sector number currently under the
|
|
head, 0-31.
|
|
T = Sector True, is a 1 when the sector is positioned to read or
|
|
write.
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "altair_defs.h"
|
|
|
|
#define UNIT_V_ENABLE (UNIT_V_UF + 0) /* Write Enable */
|
|
#define UNIT_ENABLE (1 << UNIT_V_ENABLE)
|
|
|
|
#define DSK_SECTSIZE 137
|
|
#define DSK_SECT 32
|
|
#define DSK_TRACSIZE 4384
|
|
#define DSK_SURF 1
|
|
#define DSK_CYL 77
|
|
#define DSK_SIZE (DSK_SECT * DSK_SURF * DSK_CYL * DSK_SECTSIZE)
|
|
|
|
t_stat dsk_svc (UNIT *uptr);
|
|
t_stat dsk_reset (DEVICE *dptr);
|
|
void writebuf();
|
|
|
|
extern int32 sim_activate (UNIT *uptr, int32 interval);
|
|
extern int32 sim_cancel (UNIT *uptr);
|
|
extern int32 PCX;
|
|
|
|
/* Global data on status */
|
|
|
|
int32 cur_disk = 8; /* Currently selected drive */
|
|
int32 cur_track[9] = {0, 0, 0, 0, 0, 0, 0, 0, 377};
|
|
int32 cur_sect[9] = {0, 0, 0, 0, 0, 0, 0, 0, 377};
|
|
int32 cur_byte[9] = {0, 0, 0, 0, 0, 0, 0, 0, 377};
|
|
int32 cur_flags[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
char dskbuf[137]; /* Data Buffer */
|
|
int32 dirty = 0; /* 1 when buffer has unwritten data in it */
|
|
UNIT *dptr; /* fileref to write dirty buffer to */
|
|
|
|
int32 dsk_rwait = 100; /* rotate latency */
|
|
|
|
|
|
/* 88DSK Standard I/O Data Structures */
|
|
|
|
UNIT dsk_unit[] = {
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) },
|
|
{ UDATA (&dsk_svc, UNIT_FIX+UNIT_ATTABLE+UNIT_DISABLE, DSK_SIZE) }
|
|
};
|
|
|
|
REG dsk_reg[] = {
|
|
{ ORDATA (DISK, cur_disk, 4) },
|
|
{ NULL } };
|
|
|
|
DEVICE dsk_dev = {
|
|
"DSK", dsk_unit, dsk_reg, NULL,
|
|
8, 10, 31, 1, 8, 8,
|
|
NULL, NULL, &dsk_reset,
|
|
NULL, NULL, NULL };
|
|
|
|
/* Service routines to handle simlulator functions */
|
|
|
|
/* service routine - actually gets char & places in buffer */
|
|
|
|
t_stat dsk_svc (UNIT *uptr)
|
|
{
|
|
return SCPE_OK;
|
|
}
|
|
|
|
/* Reset routine */
|
|
|
|
t_stat dsk_reset (DEVICE *dptr)
|
|
{
|
|
cur_disk = 0;
|
|
return SCPE_OK;
|
|
}
|
|
|
|
/* I/O instruction handlers, called from the CPU module when an
|
|
IN or OUT instruction is issued.
|
|
|
|
Each function is passed an 'io' flag, where 0 means a read from
|
|
the port, and 1 means a write to the port. On input, the actual
|
|
input is passed as the return value, on output, 'data' is written
|
|
to the device.
|
|
*/
|
|
|
|
/* Disk Controller Status/Select */
|
|
|
|
/* IMPORTANT: The status flags read by port 8 IN instruction are
|
|
INVERTED, that is, 0 is true and 1 is false. To handle this, the
|
|
simulator keeps it's own status flags as 0=false, 1=true; and
|
|
returns the COMPLEMENT of the status flags when read. This makes
|
|
setting/testing of the flag bits more logical, yet meets the
|
|
simulation requirement that they are reversed in hardware.
|
|
*/
|
|
|
|
int32 dsk10(int32 io, int32 data)
|
|
{
|
|
|
|
if (io == 0) { /* IN: return flags */
|
|
return ((~cur_flags[cur_disk]) & 0xFF); /* Return the COMPLEMENT! */
|
|
}
|
|
|
|
/* OUT: Controller set/reset/enable/disable */
|
|
|
|
if (dirty == 1)
|
|
writebuf();
|
|
|
|
/*printf("\n[%o] OUT 10: %x", PCX, data);*/
|
|
cur_disk = data & 0x0F;
|
|
if (data & 0x80) {
|
|
cur_flags[cur_disk] = 0; /* Disable drive */
|
|
cur_sect[cur_disk = 0377];
|
|
cur_byte[cur_disk = 0377];
|
|
return (0);
|
|
}
|
|
cur_flags[cur_disk] = 0x1A; /* Enable: head move true */
|
|
cur_sect[cur_disk] = 0377; /* reset internal counters */
|
|
cur_byte[cur_disk] = 0377;
|
|
if (cur_track[cur_disk] == 0)
|
|
cur_flags[cur_disk] |= 0x40; /* track 0 if there */
|
|
return (0);
|
|
}
|
|
|
|
/* Disk Drive Status/Functions */
|
|
|
|
int32 dsk11(int32 io, int32 data)
|
|
{
|
|
int32 stat;
|
|
|
|
if (io == 0) { /* Read sector position */
|
|
/*printf("\n[%o] IN 11", PCX);*/
|
|
if (dirty == 1)
|
|
writebuf();
|
|
if (cur_flags[cur_disk] & 0x04) { /* head loaded? */
|
|
cur_sect[cur_disk]++;
|
|
if (cur_sect[cur_disk] > 31)
|
|
cur_sect[cur_disk] = 0;
|
|
cur_byte[cur_disk] = 0377;
|
|
stat = cur_sect[cur_disk] << 1;
|
|
stat &= 0x3E; /* return 'sector true' bit = 0 (true) */
|
|
stat |= 0xC0; /* set on 'unused' bits */
|
|
return (stat);
|
|
} else {
|
|
return (0); /* head not loaded - return 0 */
|
|
}
|
|
}
|
|
|
|
/* Drive functions */
|
|
|
|
if (cur_disk > 7)
|
|
return (0); /* no drive selected - can do nothin */
|
|
|
|
/*printf("\n[%o] OUT 11: %x", PCX, data);*/
|
|
if (data & 0x01) { /* Step head in */
|
|
cur_track[cur_disk]++;
|
|
if (cur_track[cur_disk] > 76 )
|
|
cur_track[cur_disk] = 76;
|
|
if (dirty == 1)
|
|
writebuf();
|
|
cur_sect[cur_disk] = 0377;
|
|
cur_byte[cur_disk] = 0377;
|
|
}
|
|
|
|
if (data & 0x02) { /* Step head out */
|
|
cur_track[cur_disk]--;
|
|
if (cur_track[cur_disk] < 0) {
|
|
cur_track[cur_disk] = 0;
|
|
cur_flags[cur_disk] |= 0x40; /* track 0 if there */
|
|
}
|
|
if (dirty == 1)
|
|
writebuf();
|
|
cur_sect[cur_disk] = 0377;
|
|
cur_byte[cur_disk] = 0377;
|
|
}
|
|
|
|
if (dirty == 1)
|
|
writebuf();
|
|
|
|
if (data & 0x04) { /* Head load */
|
|
cur_flags[cur_disk] |= 0x04; /* turn on head loaded bit */
|
|
cur_flags[cur_disk] |= 0x80; /* turn on 'read data available */
|
|
}
|
|
|
|
if (data & 0x08) { /* Head Unload */
|
|
cur_flags[cur_disk] &= 0xFB; /* off on 'head loaded' */
|
|
cur_flags[cur_disk] &= 0x7F; /* off on 'read data avail */
|
|
cur_sect[cur_disk] = 0377;
|
|
cur_byte[cur_disk] = 0377;
|
|
}
|
|
|
|
/* Interrupts & head current are ignored */
|
|
|
|
if (data & 0x80) { /* write sequence start */
|
|
cur_byte[cur_disk] = 0;
|
|
cur_flags[cur_disk] |= 0x01; /* enter new write data on */
|
|
}
|
|
|
|
}
|
|
|
|
/* Disk Data In/Out*/
|
|
|
|
int32 dsk12(int32 io, int32 data)
|
|
{
|
|
static int32 rtn, i;
|
|
static long pos;
|
|
UNIT *uptr;
|
|
|
|
uptr = dsk_dev.units + cur_disk;
|
|
if (io == 0) {
|
|
if ((i = cur_byte[cur_disk]) < 138) { /* just get from buffer */
|
|
cur_byte[cur_disk]++;
|
|
return (dskbuf[i] & 0xFF);
|
|
}
|
|
/* physically read the sector */
|
|
/*printf("\n[%o] IN 12 (READ) T%d S%d", PCX, cur_track[cur_disk],
|
|
cur_sect[cur_disk]);*/
|
|
pos = DSK_TRACSIZE * cur_track[cur_disk];
|
|
pos += DSK_SECTSIZE * cur_sect[cur_disk];
|
|
rtn = fseek(uptr -> fileref, pos, 0);
|
|
rtn = fread(dskbuf, 137, 1, uptr -> fileref);
|
|
cur_byte[cur_disk] = 1;
|
|
return (dskbuf[0] & 0xFF);
|
|
} else {
|
|
if (cur_byte[cur_disk] > 136) {
|
|
i = cur_byte[cur_disk];
|
|
dskbuf[i] = data & 0xFF;
|
|
writebuf();
|
|
return (0);
|
|
}
|
|
i = cur_byte[cur_disk];
|
|
dirty = 1;
|
|
dptr = uptr;
|
|
dskbuf[i] = data & 0xFF;
|
|
cur_byte[cur_disk]++;
|
|
return (0);
|
|
}
|
|
}
|
|
|
|
void writebuf()
|
|
{
|
|
long pos;
|
|
int32 rtn, i;
|
|
|
|
i = cur_byte[cur_disk]; /* null-fill rest of sector if any */
|
|
while (i < 138) {
|
|
dskbuf[i] = 0;
|
|
i++;
|
|
}
|
|
/*printf("\n[%o] OUT 12 (WRITE) T%d S%d", PCX, cur_track[cur_disk],
|
|
cur_sect[cur_disk]); i = getch(); */
|
|
pos = DSK_TRACSIZE * cur_track[cur_disk]; /* calc file pos */
|
|
pos += DSK_SECTSIZE * cur_sect[cur_disk];
|
|
rtn = fseek(dptr -> fileref, pos, 0);
|
|
rtn = fwrite(dskbuf, 137, 1, dptr -> fileref);
|
|
cur_flags[cur_disk] &= 0xFE; /* ENWD off */
|
|
cur_byte[cur_disk] = 0377;
|
|
dirty = 0;
|
|
return;
|
|
}
|