Merge git://github.com/simh/simh

This commit is contained in:
Mark Emmer 2014-04-09 22:18:06 -05:00
commit fcbd91f146
62 changed files with 997 additions and 634 deletions

View file

@ -1,6 +1,6 @@
/* altairz80_cpu.c: MITS Altair CPU (8080 and Z80) /* altairz80_cpu.c: MITS Altair CPU (8080 and Z80)
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -6508,7 +6508,8 @@ static t_stat cpu_show(FILE *st, UNIT *uptr, int32 val, void *desc) {
static void cpu_clear(void) { static void cpu_clear(void) {
uint32 i; uint32 i;
for (i = 0; i < MAXMEMORY; i++) M[i] = 0; for (i = 0; i < MAXMEMORY; i++)
M[i] = 0;
for (i = 0; i < (MAXMEMORY >> LOG2PAGESIZE); i++) for (i = 0; i < (MAXMEMORY >> LOG2PAGESIZE); i++)
mmu_table[i] = RAM_PAGE; mmu_table[i] = RAM_PAGE;
for (i = (MEMORYSIZE >> LOG2PAGESIZE); i < (MAXMEMORY >> LOG2PAGESIZE); i++) for (i = (MEMORYSIZE >> LOG2PAGESIZE); i < (MAXMEMORY >> LOG2PAGESIZE); i++)
@ -6852,9 +6853,14 @@ static t_stat cpu_set_memory(UNIT *uptr, int32 value, char *cptr, void *desc) {
return SCPE_ARG; return SCPE_ARG;
} }
t_value altairz80_pc_value (void) {
return (t_value)PCX;
}
/* AltairZ80 Simulator initialization */ /* AltairZ80 Simulator initialization */
void altairz80_init(void) { void altairz80_init(void) {
cpu_clear(); cpu_clear();
sim_vm_pc_value = &altairz80_pc_value;
/* altairz80_print_tables(); */ /* altairz80_print_tables(); */
} }

View file

@ -1,6 +1,6 @@
/* altairz80_cpu_opt.c: MITS Altair CPU (8080 and Z80) /* altairz80_cpu_opt.c: MITS Altair CPU (8080 and Z80)
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,6 @@
/* altairz80_defs.h: MITS Altair simulator definitions /* altairz80_defs.h: MITS Altair simulator definitions
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

Binary file not shown.

View file

@ -1,6 +1,6 @@
/* altairz80_dsk.c: MITS Altair 88-DISK Simulator /* altairz80_dsk.c: MITS Altair 88-DISK Simulator
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -306,7 +306,9 @@ static t_stat dsk_reset(DEVICE *dptr) {
} }
void install_ALTAIRbootROM(void) { void install_ALTAIRbootROM(void) {
ASSURE(install_bootrom(bootrom_dsk, BOOTROM_SIZE_DSK, ALTAIR_ROM_LOW, TRUE) == SCPE_OK); const t_bool result = (install_bootrom(bootrom_dsk, BOOTROM_SIZE_DSK, ALTAIR_ROM_LOW, TRUE) ==
SCPE_OK);
assert(result);
} }
/* The boot routine modifies the boot ROM in such a way that subsequently /* The boot routine modifies the boot ROM in such a way that subsequently

View file

@ -1,6 +1,6 @@
/* altairz80_hdsk.c: simulated hard disk device to increase capacity /* altairz80_hdsk.c: simulated hard disk device to increase capacity
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -595,6 +595,7 @@ static int32 bootrom_hdsk[BOOTROM_SIZE_HDSK] = {
}; };
static t_stat hdsk_boot(int32 unitno, DEVICE *dptr) { static t_stat hdsk_boot(int32 unitno, DEVICE *dptr) {
t_bool installSuccessful;
if (MEMORYSIZE < 24*KB) { if (MEMORYSIZE < 24*KB) {
printf("Need at least 24KB RAM to boot from hard disk.\n"); printf("Need at least 24KB RAM to boot from hard disk.\n");
return SCPE_ARG; return SCPE_ARG;
@ -609,7 +610,9 @@ static t_stat hdsk_boot(int32 unitno, DEVICE *dptr) {
} }
install_ALTAIRbootROM(); /* install modified ROM */ install_ALTAIRbootROM(); /* install modified ROM */
} }
ASSURE(install_bootrom(bootrom_hdsk, BOOTROM_SIZE_HDSK, HDSK_BOOT_ADDRESS, FALSE) == SCPE_OK); installSuccessful = (install_bootrom(bootrom_hdsk, BOOTROM_SIZE_HDSK, HDSK_BOOT_ADDRESS,
FALSE) == SCPE_OK);
assert(installSuccessful);
*((int32 *) sim_PC -> loc) = HDSK_BOOT_ADDRESS; *((int32 *) sim_PC -> loc) = HDSK_BOOT_ADDRESS;
return SCPE_OK; return SCPE_OK;
} }

453
AltairZ80/altairz80_mhdsk.c Executable file
View file

@ -0,0 +1,453 @@
/* altairz80_mhdsk.c: MITS 88-HDSK Hard Disk simulator
Copyright (c) 2002-2014, Peter Schorn
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
PETER SCHORN 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 Peter Schorn shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Peter Schorn.
------------------------------------------------------------------------------
The 88-HDSK from MITS/Pertec consists of a 5mb removable platter and
a fixed 5mb platter. Each platter is double sided. Head 0 and 1 are the
top and bottom surface of the removable platter and head 2 and 3 are the
top and bottom surface of the fixed platter. Hard disk BASIC treats the
two platters as two separate drives. Each platter has 406 cylinders
with 24 sectors per track and 256 bytes per sector.
The disk image file starts with head 0, track 0, sector 0 (0,0,0) through
(0,0,23), followed by head 1, track 0, sector 0 (1,0,0) through (1,0,23).
The pattern then repeats starting with (0,1,0).
The external hard disk is accessed through eight ports of a 4-PIO card
at I/O addresses A0h-A7h.
Written by Mike Douglas March, 2014
Disk images provided by Martin Eberhard
-------------------------------------------------------------------------------
*/
#include "altairz80_defs.h"
#include <assert.h>
/** Typedefs & Defines **************************************/
#define HDSK_SECTOR_SIZE 256 /* size of sector */
#define HDSK_SECTORS_PER_TRACK 24 /* sectors per track */
#define HDSK_NUM_HEADS 2 /* heads per disk */
#define HDSK_NUM_TRACKS 406 /* tracks per surface */
#define HDSK_TRACK_SIZE (HDSK_SECTOR_SIZE * HDSK_SECTORS_PER_TRACK)
#define HDSK_CYLINDER_SIZE (HDSK_TRACK_SIZE * 2)
#define HDSK_CAPACITY (HDSK_CYLINDER_SIZE * HDSK_NUM_TRACKS)
#define HDSK_NUMBER 8 /* number of hard disks */
#define IO_IN 0 /* I/O operation is input */
#define IO_OUT 1 /* I/O operation is output */
#define UNIT_V_DSK_WLK (UNIT_V_UF + 0) /* write locked */
#define UNIT_DSK_WLK (1 << UNIT_V_DSK_WLK)
/* boot related */
#define BOOTROM_SIZE_MHDSK 256
#define MHDSK_BOOT_ADDRESS 0xfc00
static t_stat mhdsk_boot(int32 unitno, DEVICE *dptr);
extern t_stat install_bootrom(int32 bootrom[], int32 size, int32 addr, int32 makeROM);
// Disk controller commands are in upper nibble of command high byte.
#define CMD_SHIFT 4 // shift right 4 places
#define CMD_MASK 0x0f // mask after shifting
#define CMD_SEEK 0 // seek to track
#define CMD_WRITE_SEC 2 // write sector from buf n
#define CMD_READ_SEC 3 // read sector into buf n
#define CMD_WRITE_BUF 4 // load buffer n from CPU
#define CMD_READ_BUF 5 // read buffer n into CPU
#define CMD_READ_STATUS 6 // read controller IV byte
#define CMD_SET_IV_BYTE 8 // set controller IV byte
#define CMD_READ_UNFMT 10 // read unformatted sector
#define CMD_FORMAT 12
#define CMD_INITIALIZE 14
// Other disk controller bit fields
#define UNIT_SHIFT 2 // shift right 2 places
#define UNIT_MASK 0x03 // mask after shifting
#define BUFFER_MASK 0x03 // mask - no shift needed
#define TRACK_SHIFTH 8 // shift left 8 places into MSbyte
#define TRACK_MASKH 0x01 // msb of track number
#define TRACK_MASKL 0xff // entire lsb of track number
#define HEAD_SHIFT 5 // shift right 5 places
#define HEAD_MASK 0x03 // mask after shifting (no heads 4-7)
#define SECTOR_MASK 0x1f // mask - no shift needed
// Command status equates
#define CSTAT_WRITE_PROTECT 0x80 // disk is write protected
#define CSTAT_NOT_READY 0x01 // drive not ready
#define CSTAT_BAD_SECTOR 0x02 // invalid sector number
/** Module Globals - Private ********************************/
static uint32 selectedDisk = 0; // current active disk
static uint32 selectedSector = 0; // current sector
static uint32 selectedTrack = 0; // current track
static uint32 selectedHead = 0; // current head
static uint32 selectedBuffer = 0; // current buffer # in use
static uint32 bufferIdx = 0; // current index into selected buffer
static uint32 maxBufferIdx = 256; // maximum buffer index allowed
static uint32 cmdLowByte = 0; // low byte of command
// Controller status bytes
static uint8 cstat = 0; // command status from controller
// The hard disk controller support four 256 byte disk buffers */
static uint8 diskBuf1[HDSK_SECTOR_SIZE];
static uint8 diskBuf2[HDSK_SECTOR_SIZE];
static uint8 diskBuf3[HDSK_SECTOR_SIZE];
static uint8 diskBuf4[HDSK_SECTOR_SIZE];
static uint8 *diskBuf[] = { diskBuf1, diskBuf2, diskBuf3, diskBuf4 };
/** Forward and external Prototypes **************************************/
static int32 hdReturnReady(const int32 port, const int32 io, const int32 data);
static int32 hdCstat(const int32 port, const int32 io, const int32 data);
static int32 hdAcmd(const int32 port, const int32 io, const int32 data);
static int32 hdCdata(const int32 port, const int32 io, const int32 data);
static int32 hdAdata(const int32 port, const int32 io, const int32 data);
static void doRead(void);
static void doWrite(void);
static t_stat dsk_reset(DEVICE *dptr);
extern uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type,
int32 (*routine)(const int32, const int32, const int32), uint8 unmap);
/* 88DSK Standard I/O Data Structures */
static UNIT dsk_unit[] = {
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) },
{ UDATA (NULL, UNIT_FIX + UNIT_ATTABLE + UNIT_DISABLE + UNIT_ROABLE, HDSK_CAPACITY) }};
static MTAB dsk_mod[] = {
{ UNIT_DSK_WLK, 0, "WRTENB", "WRTENB", NULL },
{ UNIT_DSK_WLK, UNIT_DSK_WLK, "WRTLCK", "WRTLCK", NULL },
{ 0 }
};
DEVICE mhdsk_dev = {
"MHDSK", dsk_unit, NULL, dsk_mod,
HDSK_NUMBER, 10, 31, 1, 8, 8,
NULL, NULL, &dsk_reset,
&mhdsk_boot, NULL, NULL,
NULL, (DEV_DISABLE | DEV_DEBUG), 0,
NULL, NULL, "MITS Hard Disk MHDSK"
};
static int32 bootrom_mhdsk[BOOTROM_SIZE_MHDSK] = {
0xf3, 0x31, 0x00, 0xf8, 0x21, 0x1b, 0x41, 0x2b, /* fc00-fc07 */
0x7c, 0xb5, 0xc2, 0x07, 0xfc, 0xe5, 0xd3, 0xa0, /* fc08-fc0f */
0xd3, 0xa2, 0xd3, 0xa4, 0xd3, 0xa6, 0xd3, 0xa1, /* fc10-fc17 */
0xd3, 0xa5, 0x2f, 0xd3, 0xa3, 0xd3, 0xa7, 0x3e, /* fc18-fc1f */
0x2c, 0xd3, 0xa0, 0xd3, 0xa4, 0xd3, 0xa6, 0x3e, /* fc20-fc27 */
0x24, 0xd3, 0xa2, 0xdb, 0xa1, 0x3e, 0x03, 0xd3, /* fc28-fc2f */
0x10, 0x3e, 0x11, 0xd3, 0x10, 0xcd, 0xe5, 0xfc, /* fc30-fc37 */
0x0d, 0x0a, 0x48, 0x44, 0x42, 0x4c, 0x20, 0x31, /* fc38-fc3f */
0x2e, 0x30, 0xb1, 0xcd, 0x77, 0xfc, 0x11, 0x2c, /* fc40-fc47 */
0x00, 0x7a, 0xbb, 0xdb, 0xa5, 0xd2, 0x54, 0xfc, /* fc48-fc4f */
0x6c, 0x61, 0x48, 0x47, 0x14, 0xc2, 0x49, 0xfc, /* fc50-fc57 */
0xcd, 0xe5, 0xfc, 0x0d, 0x0a, 0x4c, 0x4f, 0x41, /* fc58-fc5f */
0x44, 0x49, 0x4e, 0xc7, 0xd1, 0xd5, 0xcd, 0x77, /* fc60-fc67 */
0xfc, 0xdb, 0xa5, 0x12, 0x13, 0x05, 0xc2, 0x69, /* fc68-fc6f */
0xfc, 0x23, 0x0d, 0xc2, 0x66, 0xfc, 0xc9, 0xe5, /* fc70-fc77 */
0xd5, 0xc5, 0x01, 0xd0, 0xff, 0x11, 0xff, 0xff, /* fc78-fc7f */
0x13, 0x09, 0xda, 0x80, 0xfc, 0x7d, 0xc6, 0x30, /* fc80-fc87 */
0xeb, 0xfe, 0x18, 0xda, 0x90, 0xfc, 0xc6, 0x08, /* fc88-fc8f */
0x47, 0xcd, 0xaf, 0xfc, 0x26, 0x30, 0xdb, 0xff, /* fc90-fc97 */
0xe6, 0x03, 0x0f, 0x0f, 0xb0, 0xcd, 0xb0, 0xfc, /* fc98-fc9f */
0xdb, 0xa5, 0xdb, 0xa3, 0xaf, 0xd3, 0xa7, 0x3e, /* fca0-fca7 */
0x50, 0xd3, 0xa3, 0xc1, 0xd1, 0xe1, 0xc9, 0x7d, /* fca8-fcaf */
0xd3, 0xa7, 0xdb, 0xa1, 0xdb, 0xa3, 0xdb, 0xff, /* fcb0-fcb7 */
0xe6, 0x00, 0xb4, 0xd3, 0xa3, 0xdb, 0xa0, 0x07, /* fcb8-fcbf */
0xd2, 0xbd, 0xfc, 0xdb, 0xa1, 0xe6, 0x7f, 0xc8, /* fcc0-fcc7 */
0xfb, 0xf5, 0xcd, 0xe5, 0xfc, 0x0d, 0x0a, 0x4c, /* fcc8-fccf */
0x4f, 0x41, 0x44, 0x20, 0x45, 0x52, 0x52, 0x4f, /* fcd0-fcd7 */
0x52, 0xba, 0x21, 0x00, 0xfd, 0x34, 0xca, 0xde, /* fcd8-fcdf */
0xfc, 0xe3, 0xc3, 0xcf, 0xfd, 0xe3, 0xdb, 0x10, /* fce0-fce7 */
0xe6, 0x02, 0xca, 0xe6, 0xfc, 0x7e, 0xe6, 0x7f, /* fce8-fcef */
0xd3, 0x11, 0xbe, 0x23, 0xca, 0xe6, 0xfc, 0xe3, /* fcf0-fcf7 */
0xc9, 0x70, 0x4a, 0x01, 0x00, 0xd4, 0xb4, 0x13, /* fcf8-fcff */
};
static t_stat mhdsk_boot(int32 unitno, DEVICE *dptr) {
const t_bool installSuccessful = (install_bootrom(bootrom_mhdsk, BOOTROM_SIZE_MHDSK,
MHDSK_BOOT_ADDRESS, FALSE) == SCPE_OK);
assert(installSuccessful);
*((int32 *) sim_PC -> loc) = MHDSK_BOOT_ADDRESS;
return SCPE_OK;
}
/*----------------------------------------------------------------------------------
dsk_reset - install I/O handlers and initialize variables.
----------------------------------------------------------------------------------*/
static t_stat dsk_reset(DEVICE *dptr) {
sim_map_resource(0xA0, 1, RESOURCE_TYPE_IO, &hdReturnReady, dptr->flags & DEV_DIS);
sim_map_resource(0xA1, 1, RESOURCE_TYPE_IO, &hdCstat, dptr->flags & DEV_DIS);
sim_map_resource(0xA2, 1, RESOURCE_TYPE_IO, &hdReturnReady, dptr->flags & DEV_DIS);
sim_map_resource(0xA3, 1, RESOURCE_TYPE_IO, &hdAcmd, dptr->flags & DEV_DIS);
sim_map_resource(0xA4, 1, RESOURCE_TYPE_IO, &hdReturnReady, dptr->flags & DEV_DIS);
sim_map_resource(0xA5, 1, RESOURCE_TYPE_IO, &hdCdata, dptr->flags & DEV_DIS);
sim_map_resource(0xA6, 1, RESOURCE_TYPE_IO, &hdReturnReady, dptr->flags & DEV_DIS);
sim_map_resource(0xA7, 1, RESOURCE_TYPE_IO, &hdAdata, dptr->flags & DEV_DIS);
selectedSector = 0; // current sector
selectedTrack = 0; // current track
selectedHead = 0; // current head
selectedBuffer = 0; // current buffer # in use
bufferIdx = 0; // current index into selected buffer
maxBufferIdx = 256; // maximum buffer index allowed
cmdLowByte = 0; // low byte of command
return SCPE_OK;
}
/*-------------------------------------------------------------------------------------
hdReturnReady - common I/O handler for several hard disk status ports which set
bit 7 when the corresponding hard disk function is ready. In the emulator,
we're always ready for the next step, so we simply return ready all the time.
0xA0 - CREADY register. Accessed through the status/control register of 4-PIO
port 1-A. Returns the "ready for command" status byte.
0xA2 - ACSTA register. Accessed through the status/control register of 4-PIO
port 1-B. Returns the "command received" status byte.
0xA4 - CDSTA register. Accessed through the status/control register of 4-PIO
port 2-A. Returns the "command data available" status byte.
0xA6 - ADSTA register. Accessed through the status/control register of 4-PIO
port 2-B. Returns the "available to write" status byte.
---------------------------------------------------------------------------------------*/
static int32 hdReturnReady(const int32 port, const int32 io, const int32 data)
{
return(0x80); // always indicate ready
// output operations have no effect
}
/*------------------------------------------------------------
hdCstat (0xA1) CSTAT register. Accessed through the
data register of 4-PIO port 1-A.
Comments: Returns error code byte of the most recent
operation. Reading this byte also clears
the CRDY bit, but this isn't actually done
in the emulation since we're always ready.
-------------------------------------------------------------*/
static int32 hdCstat(const int32 port, const int32 io, const int32 data)
{
return(cstat);
// output operations have no effect
}
/*------------------------------------------------------------
hdAcmd (0xA3) ACMD register. Accessed through the
data register of 4-PIO port 1-B.
Comments: The high byte of a command is written to
this register and initiates the command.
The low byte of a command is assumed to
have already been written and stored in
cmdLowByte;
-------------------------------------------------------------*/
static int32 hdAcmd(const int32 port, const int32 io, const int32 data)
{
uint32 command; // command field from command msb
uint32 unit; // unit number from command msb
uint32 buffer; // buffer number from command msb
// if not an OUT command, exit
if (io != IO_OUT)
return(0);
// extract command and possible unit and buffer fields.
cstat = 0; // assume command success
command = (data >> CMD_SHIFT) & CMD_MASK;
unit = (data >> UNIT_SHIFT) & UNIT_MASK;
buffer = data & BUFFER_MASK;
// SEEK command. Updated selectedTrack.
if (command == CMD_SEEK) {
selectedTrack = cmdLowByte + ((data & TRACK_MASKH) << TRACK_SHIFTH);
if (selectedTrack >= HDSK_NUM_TRACKS)
selectedTrack = HDSK_NUM_TRACKS-1;
}
// READ, READ UNFORMATTED or WRITE SECTOR command.
else if ((command==CMD_WRITE_SEC) || (command==CMD_READ_SEC) || (command==CMD_READ_UNFMT)) {
selectedHead = (cmdLowByte >> HEAD_SHIFT) & HEAD_MASK;
selectedDisk = (selectedHead >> 1) + unit * 2 ;
selectedSector = cmdLowByte & SECTOR_MASK;
selectedBuffer = buffer;
if (mhdsk_dev.units[selectedDisk].fileref == NULL) // make sure a file is attached
cstat = CSTAT_NOT_READY;
else {
if (command == CMD_WRITE_SEC)
doWrite();
else
doRead();
}
}
// READ or WRITE BUFFER command. Initiates reading/loading specified buffer.
else if ((command == CMD_WRITE_BUF) || (command == CMD_READ_BUF)) {
selectedBuffer = buffer;
maxBufferIdx = cmdLowByte;
if (maxBufferIdx == 0)
maxBufferIdx = 256;
bufferIdx = 0;
}
// READ STATUS command (read IV byte)
else if (command == CMD_READ_STATUS) {
}
// SET IV byte command
else if (command == CMD_SET_IV_BYTE) {
}
// FORMAT command
else if (command == CMD_FORMAT) {
}
// INITIALIZE command
else if (command == CMD_INITIALIZE) {
}
return(0);
}
/*------------------------------------------------------------
hdCdata (0xA5) Cdata register. Accessed through the
data register of 4-PIO port 1-B.
Comments: Returns data from the read buffer
-------------------------------------------------------------*/
static int32 hdCdata(const int32 port, const int32 io, const int32 data)
{
if (io == IO_IN) {
if (bufferIdx < maxBufferIdx)
return(diskBuf[selectedBuffer][bufferIdx++]);
}
return(0);
// output operations have no effect
}
/*------------------------------------------------------------
hdAdata (0xA7) ADATA register. Accessed through the
data register of 4-PIO port 2-B.
Comments: Accepts data into the current buffer
and is also the low byte of a command.
-------------------------------------------------------------*/
static int32 hdAdata(const int32 port, const int32 io, const int32 data)
{
if (io == IO_OUT) {
cmdLowByte = data & 0xff;
if (bufferIdx < maxBufferIdx)
diskBuf[selectedBuffer][bufferIdx++] = data;
}
return(0);
}
/*-- doRead -------------------------------------------------
Performs read from MITS Hard Disk image file
Params: nothing
Uses: selectedTrack, selectedHead, selectedSector
selectedDisk, diskBuf[], mhdsk_dev
Returns: nothing (updates cstat directly)
Comments:
-------------------------------------------------------------*/
static void doRead(void)
{
UNIT *uptr;
uint32 fileOffset;
uptr = mhdsk_dev.units + selectedDisk;
fileOffset = HDSK_CYLINDER_SIZE * selectedTrack +
HDSK_TRACK_SIZE * (selectedHead & 0x01) +
HDSK_SECTOR_SIZE * selectedSector;
if (sim_fseek(uptr->fileref, fileOffset, SEEK_SET))
cstat = CSTAT_NOT_READY; /* seek error */
else if (sim_fread(diskBuf[selectedBuffer], 1, HDSK_SECTOR_SIZE, uptr->fileref) != HDSK_SECTOR_SIZE)
cstat = CSTAT_NOT_READY; /* write error */
}
/*-- doWrite ------------------------------------------------
Performs write to MITS Hard Disk image file
Params: none
Uses: selectedTrack, selectedHead, selectedSector
selectedDisk, diskBuf[], mhdsk_dev
Returns: nothing (updates cstat directly)
Comments:
-------------------------------------------------------------*/
static void doWrite(void)
{
UNIT *uptr;
uint32 fileOffset;
uptr = mhdsk_dev.units + selectedDisk;
if (((uptr->flags) & UNIT_DSK_WLK) == 0) { /* write enabled */
fileOffset = HDSK_CYLINDER_SIZE * selectedTrack +
HDSK_TRACK_SIZE * (selectedHead & 0x01) +
HDSK_SECTOR_SIZE * selectedSector;
if (sim_fseek(uptr->fileref, fileOffset, SEEK_SET))
cstat = CSTAT_NOT_READY; /* seek error */
else if (sim_fwrite(diskBuf[selectedBuffer], 1, HDSK_SECTOR_SIZE, uptr->fileref) != HDSK_SECTOR_SIZE)
cstat = CSTAT_NOT_READY; /* write error */
}
else
cstat = CSTAT_WRITE_PROTECT;
}

View file

@ -1,6 +1,6 @@
/* altairz80_net.c: networking capability /* altairz80_net.c: networking capability
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,6 @@
/* altairz80_sio.c: MITS Altair serial I/O card /* altairz80_sio.c: MITS Altair serial I/O card
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,6 @@
/* altairz80_sys.c: MITS Altair system interface /* altairz80_sys.c: MITS Altair system interface
Copyright (c) 2002-2013, Peter Schorn Copyright (c) 2002-2014, Peter Schorn
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,8 @@
Based on work by Charles E Owen (c) 1997 Based on work by Charles E Owen (c) 1997
Disassembler from Marat Fayzullin ((c) 1995, 1996, 1997 - Commercial use prohibited) Disassembler from Marat Fayzullin ((c) 1995, 1996, 1997 - Commercial use prohibited)
03/27/14 -- MWD Add MITS Hard Disk device (mhdsk_dev)
*/ */
#include <ctype.h> #include <ctype.h>
@ -40,6 +42,7 @@ extern DEVICE simh_device;
extern DEVICE ptr_dev; extern DEVICE ptr_dev;
extern DEVICE ptp_dev; extern DEVICE ptp_dev;
extern DEVICE dsk_dev; extern DEVICE dsk_dev;
extern DEVICE mhdsk_dev;
extern DEVICE hdsk_dev; extern DEVICE hdsk_dev;
extern DEVICE net_dev; extern DEVICE net_dev;
@ -100,7 +103,7 @@ int32 sim_emax = SIM_EMAX;
DEVICE *sim_devices[] = { DEVICE *sim_devices[] = {
/* AltairZ80 Devices */ /* AltairZ80 Devices */
&cpu_dev, &sio_dev, &simh_device, &ptr_dev, &ptp_dev, &dsk_dev, &cpu_dev, &sio_dev, &simh_device, &ptr_dev, &ptp_dev, &dsk_dev,
&hdsk_dev, &net_dev, &mhdsk_dev, &hdsk_dev, &net_dev,
/* Advanced Digital (ADC) Devices */ /* Advanced Digital (ADC) Devices */
&adcs6_dev, &adcs6_dev,
&hdc1001_dev, &hdc1001_dev,
@ -360,6 +363,15 @@ void prepareInstructionMessage(const t_addr loc, const uint32 op) {
(chiptype == CHIP_TYPE_Z80 ? MnemonicsZ80[op & 0xff] : "???"), loc); (chiptype == CHIP_TYPE_Z80 ? MnemonicsZ80[op & 0xff] : "???"), loc);
} }
/* Ensure that hex number starts with a digit when printed */
static void printHex2(char* string, const uint32 value) {
sprintf(string, (value <= 0x9f ? "%02X" : "%03X"), value);
}
static void printHex4(char* string, const uint32 value) {
sprintf(string, (value <= 0x9fff ? "%04X" : "%05X"), value);
}
/* Symbolic disassembler /* Symbolic disassembler
Inputs: Inputs:
@ -416,7 +428,7 @@ static int32 DAsm(char *S, const uint32 *val, const int32 useZ80Mnemonics, const
if ( (P = strchr(T, '^')) ) { if ( (P = strchr(T, '^')) ) {
strncpy(R, T, P - T); strncpy(R, T, P - T);
R[P - T] = '\0'; R[P - T] = '\0';
sprintf(H, "%02X", val[B++]); printHex2(H, val[B++]);
strcat(R, H); strcat(R, H);
strcat(R, P + 1); strcat(R, P + 1);
} }
@ -431,7 +443,7 @@ static int32 DAsm(char *S, const uint32 *val, const int32 useZ80Mnemonics, const
if ( (P = strchr(R, '*')) ) { if ( (P = strchr(R, '*')) ) {
strncpy(S, R, P - R); strncpy(S, R, P - R);
S[P - R] = '\0'; S[P - R] = '\0';
sprintf(H, "%02X", val[B++]); printHex2(H, val[B++]);
strcat(S, H); strcat(S, H);
strcat(S, P + 1); strcat(S, P + 1);
} }
@ -442,7 +454,7 @@ static int32 DAsm(char *S, const uint32 *val, const int32 useZ80Mnemonics, const
Offset = val[B++]; Offset = val[B++];
strcat(S, Offset & 0x80 ? "-" : "+"); strcat(S, Offset & 0x80 ? "-" : "+");
J = Offset & 0x80 ? 256 - Offset : Offset; J = Offset & 0x80 ? 256 - Offset : Offset;
sprintf(H, "%02X", J); printHex2(H, J);
strcat(S, H); strcat(S, H);
strcat(S, P + 1); strcat(S, P + 1);
} }
@ -450,14 +462,14 @@ static int32 DAsm(char *S, const uint32 *val, const int32 useZ80Mnemonics, const
strncpy(S, R, P - R); strncpy(S, R, P - R);
S[P - R] = '\0'; S[P - R] = '\0';
Offset = val[B++]; Offset = val[B++];
sprintf(H, "%04X", (addr + 2 + (Offset & 0x80 ? (Offset - 256) : Offset)) & 0xFFFF); printHex4(H, (addr + 2 + (Offset & 0x80 ? (Offset - 256) : Offset)) & 0xFFFF);
strcat(S, H); strcat(S, H);
strcat(S, P + 1); strcat(S, P + 1);
} }
else if ( (P = strchr(R, '#')) ) { else if ( (P = strchr(R, '#')) ) {
strncpy(S, R, P - R); strncpy(S, R, P - R);
S[P - R] = '\0'; S[P - R] = '\0';
sprintf(H, "%04X", val[B] + 256 * val[B + 1]); printHex4(H, val[B] + 256 * val[B + 1]);
strcat(S, H); strcat(S, H);
strcat(S, P + 1); strcat(S, P + 1);
B += 2; B += 2;

View file

@ -2,7 +2,7 @@
IMSAI FIF Disk Controller by Ernie Price IMSAI FIF Disk Controller by Ernie Price
Based on altairz80_dsk.c, Copyright (c) 2002-2013, Peter Schorn Based on altairz80_dsk.c, Copyright (c) 2002-2014, Peter Schorn
Plug-n-Play added by Howard M. Harte Plug-n-Play added by Howard M. Harte

View file

@ -1548,10 +1548,7 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru dev */
(curr->ba < (dibp->ba + dibp->lnt))) || (curr->ba < (dibp->ba + dibp->lnt))) ||
((end >= dibp->ba) && /* overlap end? */ ((end >= dibp->ba) && /* overlap end? */
(end < (dibp->ba + dibp->lnt)))) { (end < (dibp->ba + dibp->lnt)))) {
printf ("Device %s address conflict at %08o\n", sim_printf ("Device %s address conflict at %08o\n",
sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Device %s address conflict at %08o\n",
sim_dname (dptr), dibp->ba); sim_dname (dptr), dibp->ba);
return TRUE; return TRUE;
} }

View file

@ -383,7 +383,7 @@ switch (fmt) { /* case fmt */
return load_exe (fileref); return load_exe (fileref);
} }
printf ("Can't determine load file format\n"); sim_printf ("Can't determine load file format\n");
return SCPE_FMT; return SCPE_FMT;
} }

View file

@ -1185,9 +1185,7 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) {
if ((dptr->flags & DEV_DISABLE) && /* disable-able? */ if ((dptr->flags & DEV_DISABLE) && /* disable-able? */
!(dptr->flags & DEV_DIS) && /* enabled? */ !(dptr->flags & DEV_DIS) && /* enabled? */
((dptr->flags & mask) == 0)) { /* not allowed? */ ((dptr->flags & mask) == 0)) { /* not allowed? */
printf ("Disabling %s\n", sim_dname (dptr)); sim_printf ("Disabling %s\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "Disabling %s\n", sim_dname (dptr));
dptr->flags = dptr->flags | DEV_DIS; dptr->flags = dptr->flags | DEV_DIS;
} }
} }

View file

@ -60,7 +60,7 @@
#define DDCMP_DBG_PXMT TMXR_DBG_PXMT /* Debug Transmitted Packet Header Contents */ #define DDCMP_DBG_PXMT TMXR_DBG_PXMT /* Debug Transmitted Packet Header Contents */
#define DDCMP_DBG_PRCV TMXR_DBG_PRCV /* Debug Received Packet Header Contents */ #define DDCMP_DBG_PRCV TMXR_DBG_PRCV /* Debug Received Packet Header Contents */
#define DDCMP_DBG_PDAT 0x1000000 /* Debug Packet Data */ #define DDCMP_DBG_PDAT 0x4000000 /* Debug Packet Data */
/* Support routines */ /* Support routines */

View file

@ -1149,7 +1149,7 @@ DEVICE dmc_dev =
#endif #endif
dmc_units, dmc_reg, dmc_mod, 3, DMC_RDX, 8, 1, DMC_RDX, 8, dmc_units, dmc_reg, dmc_mod, 3, DMC_RDX, 8, 1, DMC_RDX, 8,
NULL, NULL, &dmc_reset, NULL, &dmc_attach, &dmc_detach, NULL, NULL, &dmc_reset, NULL, &dmc_attach, &dmc_detach,
&dmc_dib, DEV_DISABLE | DEV_DIS | DEV_UBUS | DEV_DEBUG, 0, dmc_debug, &dmc_dib, DEV_DISABLE | DEV_DIS | DEV_UBUS | DEV_DEBUG | DEV_DONTAUTO, 0, dmc_debug,
NULL, NULL, &dmc_help, &dmc_help_attach, NULL, &dmc_description }; NULL, NULL, &dmc_help, &dmc_help_attach, NULL, &dmc_description };
/* /*
@ -1168,13 +1168,13 @@ DEVICE dmc_dev =
DEVICE dmp_dev = DEVICE dmp_dev =
{ "DMP", dmp_units, dmp_reg, dmp_mod, 3, DMC_RDX, 8, 1, DMC_RDX, 8, { "DMP", dmp_units, dmp_reg, dmp_mod, 3, DMC_RDX, 8, 1, DMC_RDX, 8,
NULL, NULL, &dmc_reset, NULL, &dmc_attach, &dmc_detach, NULL, NULL, &dmc_reset, NULL, &dmc_attach, &dmc_detach,
&dmp_dib, DEV_DISABLE | DEV_DIS | DEV_UBUS | DEV_DEBUG, 0, dmc_debug, &dmp_dib, DEV_DISABLE | DEV_DIS | DEV_UBUS | DEV_DEBUG | DEV_DONTAUTO, 0, dmc_debug,
NULL, NULL, &dmc_help, &dmc_help_attach, NULL, &dmp_description }; NULL, NULL, &dmc_help, &dmc_help_attach, NULL, &dmp_description };
DEVICE dmv_dev = DEVICE dmv_dev =
{ "DMV", dmp_units, dmp_reg, dmv_mod, 3, DMC_RDX, 8, 1, DMC_RDX, 8, { "DMV", dmp_units, dmp_reg, dmv_mod, 3, DMC_RDX, 8, 1, DMC_RDX, 8,
NULL, NULL, &dmc_reset, NULL, &dmc_attach, &dmc_detach, NULL, NULL, &dmc_reset, NULL, &dmc_attach, &dmc_detach,
&dmp_dib, DEV_DISABLE | DEV_DIS | DEV_QBUS | DEV_DEBUG, 0, dmc_debug, &dmp_dib, DEV_DISABLE | DEV_DIS | DEV_QBUS | DEV_DEBUG | DEV_DONTAUTO, 0, dmc_debug,
NULL, NULL, &dmc_help, &dmc_help_attach, NULL, &dmp_description }; NULL, NULL, &dmc_help, &dmc_help_attach, NULL, &dmp_description };
CTLR dmc_ctrls[DMC_NUMDEVICE + DMP_NUMDEVICE]; CTLR dmc_ctrls[DMC_NUMDEVICE + DMP_NUMDEVICE];
@ -1514,7 +1514,7 @@ controller->control_out_operations_completed = 0;
controller->ddcmp_control_packets_received = 0; controller->ddcmp_control_packets_received = 0;
controller->ddcmp_control_packets_sent = 0; controller->ddcmp_control_packets_sent = 0;
printf("Statistics reset\n" ); sim_printf("Statistics reset\n");
return SCPE_OK; return SCPE_OK;
} }
@ -1585,6 +1585,7 @@ dptr->units[newln].ctlr = &dmc_ctrls[(dptr == &dmc_dev) ? 0 : DMC_NUMDEVICE];
dptr->units[newln+1] = dmc_timer_unit_template; dptr->units[newln+1] = dmc_timer_unit_template;
dptr->units[newln+1].ctlr = &dmc_ctrls[(dptr == &dmc_dev) ? 0 : DMC_NUMDEVICE]; dptr->units[newln+1].ctlr = &dmc_ctrls[(dptr == &dmc_dev) ? 0 : DMC_NUMDEVICE];
mp->lines = newln; mp->lines = newln;
mp->uptr = dptr->units + newln; /* Identify polling unit */
return dmc_reset ((DEVICE *)desc); /* setup devices and auto config */ return dmc_reset ((DEVICE *)desc); /* setup devices and auto config */
} }
@ -2569,6 +2570,15 @@ if (!buffer) {
dmc_showddcmp (sim_log, controller->unit, 0, NULL); dmc_showddcmp (sim_log, controller->unit, 0, NULL);
fflush (sim_log); fflush (sim_log);
} }
if (sim_deb) {
fprintf (sim_deb, "DDCMP Buffer allocation failure.\n");
fprintf (sim_deb, "This is a fatal error which should never happen.\n");
fprintf (sim_deb, "Please submit this output when you report this bug.\n");
dmc_showqueues (sim_deb, controller->unit, 0, NULL);
dmc_showstats (sim_deb, controller->unit, 0, NULL);
dmc_showddcmp (sim_deb, controller->unit, 0, NULL);
fflush (sim_deb);
}
return buffer; return buffer;
} }
buffer->address = 0; buffer->address = 0;
@ -3676,6 +3686,8 @@ if (0 == dmc_units[0].flags) { /* First Time Initializations */
ans = auto_config (dptr->name, (dptr->flags & DEV_DIS) ? 0 : dptr->numunits - 2); ans = auto_config (dptr->name, (dptr->flags & DEV_DIS) ? 0 : dptr->numunits - 2);
if (!(dptr->flags & DEV_DIS)) { if (!(dptr->flags & DEV_DIS)) {
int32 attached = 0;
for (i = 0; i < DMC_NUMDEVICE + DMP_NUMDEVICE; i++) { for (i = 0; i < DMC_NUMDEVICE + DMP_NUMDEVICE; i++) {
if (dmc_ctrls[i].device == dptr) { if (dmc_ctrls[i].device == dptr) {
BUFFER *buffer; BUFFER *buffer;
@ -3709,12 +3721,16 @@ if (!(dptr->flags & DEV_DIS)) {
dmc_buffer_queue_init_all(controller); dmc_buffer_queue_init_all(controller);
dmc_clrinint(controller); dmc_clrinint(controller);
dmc_clroutint(controller); dmc_clroutint(controller);
for (j=0; j<dptr->numunits-1; j++) for (j=0; j<dptr->numunits-1; j++) {
sim_cancel (&dptr->units[j]); /* stop poll */ sim_cancel (&dptr->units[j]); /* stop poll */
if (dptr->units[j].flags & UNIT_ATT)
++attached;
}
dmc_process_master_clear(controller); dmc_process_master_clear(controller);
} }
} }
sim_activate_after (dptr->units+dptr->numunits-2, DMC_CONNECT_POLL*1000000);/* start poll */ if (attached)
sim_activate_after (dptr->units+(dptr->numunits-2), DMC_CONNECT_POLL*1000000);/* start poll */
} }
return ans; return ans;
@ -3735,9 +3751,7 @@ if (!cptr || !*cptr)
if (!(uptr->flags & UNIT_ATTABLE)) if (!(uptr->flags & UNIT_ATTABLE))
return SCPE_NOATT; return SCPE_NOATT;
if (!peer[0]) { if (!peer[0]) {
printf ("Peer must be specified before attach\n"); sim_printf ("Peer must be specified before attach\n");
if (sim_log)
fprintf (sim_log, "Peer must be specified before attach\n");
return SCPE_ARG; return SCPE_ARG;
} }
sprintf (attach_string, "Line=%d,Connect=%s,%s", dmc, peer, cptr); sprintf (attach_string, "Line=%d,Connect=%s,%s", dmc, peer, cptr);
@ -3748,7 +3762,7 @@ strncpy (port, cptr, CBUFSIZE-1);
uptr->filename = (char *)malloc (strlen(port)+1); uptr->filename = (char *)malloc (strlen(port)+1);
strcpy (uptr->filename, port); strcpy (uptr->filename, port);
uptr->flags |= UNIT_ATT; uptr->flags |= UNIT_ATT;
sim_activate_after (dptr->units+mp->lines, DMC_CONNECT_POLL*1000000);/* start poll */ sim_activate_after (dptr->units+(dptr->numunits-2), DMC_CONNECT_POLL*1000000);/* start poll */
return ans; return ans;
} }
@ -3759,6 +3773,7 @@ int32 dmc = (int32)(uptr-dptr->units);
TMXR *mp = (dptr == &dmc_dev) ? &dmc_desc : &dmp_desc; TMXR *mp = (dptr == &dmc_dev) ? &dmc_desc : &dmp_desc;
TMLN *lp = &mp->ldsc[dmc]; TMLN *lp = &mp->ldsc[dmc];
int32 i, attached; int32 i, attached;
t_stat r;
if (!(uptr->flags & UNIT_ATT)) /* attached? */ if (!(uptr->flags & UNIT_ATT)) /* attached? */
return SCPE_OK; return SCPE_OK;
@ -3767,11 +3782,14 @@ uptr->flags &= ~UNIT_ATT;
for (i=attached=0; i<mp->lines; i++) for (i=attached=0; i<mp->lines; i++)
if (dptr->units[i].flags & UNIT_ATT) if (dptr->units[i].flags & UNIT_ATT)
++attached; ++attached;
if (!attached) if (!attached) {
sim_cancel (dptr->units+mp->lines); /* stop poll on last detach */ sim_cancel (dptr->units+mp->lines); /* stop poll on last detach */
sim_cancel (dptr->units+(mp->lines+1)); /* stop timer on last detach */
}
r = tmxr_detach_ln (lp);
free (uptr->filename); free (uptr->filename);
uptr->filename = NULL; uptr->filename = NULL;
return tmxr_detach_ln (lp); return r;
} }
char *dmc_description (DEVICE *dptr) char *dmc_description (DEVICE *dptr)

View file

@ -414,7 +414,7 @@ static MTAB dup_mod[] = {
#define DBG_PKT (TMXR_DBG_PXMT|TMXR_DBG_PRCV) /* display packets */ #define DBG_PKT (TMXR_DBG_PXMT|TMXR_DBG_PRCV) /* display packets */
#define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ #define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */
#define DBG_RCV TMXR_DBG_RCV /* display Received Data */ #define DBG_RCV TMXR_DBG_RCV /* display Received Data */
#define DBG_MDM 0x0004 /* display Modem SignalTransitions */ #define DBG_MDM TMXR_DBG_MDM /* display Modem SignalTransitions */
#define DBG_CON TMXR_DBG_CON /* display connection activities */ #define DBG_CON TMXR_DBG_CON /* display connection activities */
#define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */ #define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */
#define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */ #define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */
@ -454,7 +454,7 @@ DEVICE dup_dev = {
2, 10, 31, 1, DEV_RDX, 8, 2, 10, 31, 1, DEV_RDX, 8,
NULL, NULL, &dup_reset, NULL, NULL, &dup_reset,
NULL, &dup_attach, &dup_detach, NULL, &dup_attach, &dup_detach,
&dup_dib, DEV_DIS | DEV_DISABLE | DEV_UBUS | DEV_DEBUG, 0, &dup_dib, DEV_DIS | DEV_DISABLE | DEV_UBUS | DEV_DEBUG | DEV_DONTAUTO, 0,
dup_debug, NULL, NULL, &dup_help, dup_help_attach, &dup_desc, dup_debug, NULL, NULL, &dup_help, dup_help_attach, &dup_desc,
&dup_description &dup_description
}; };
@ -464,7 +464,7 @@ DEVICE dpv_dev = {
2, 10, 31, 1, DEV_RDX, 8, 2, 10, 31, 1, DEV_RDX, 8,
NULL, NULL, &dup_reset, NULL, NULL, &dup_reset,
NULL, &dup_attach, &dup_detach, NULL, &dup_attach, &dup_detach,
&dup_dib, DEV_DIS | DEV_DISABLE | DEV_QBUS | DEV_DEBUG, 0, &dup_dib, DEV_DIS | DEV_DISABLE | DEV_QBUS | DEV_DEBUG | DEV_DONTAUTO, 0,
dup_debug, NULL, NULL, &dup_help, dup_help_attach, &dup_desc, dup_debug, NULL, NULL, &dup_help, dup_help_attach, &dup_desc,
&dup_description &dup_description
}; };
@ -1191,14 +1191,16 @@ return SCPE_OK;
static t_stat dup_reset (DEVICE *dptr) static t_stat dup_reset (DEVICE *dptr)
{ {
int32 i, ndev; t_stat r;
int32 i, ndev, attached = 0;
sim_debug(DBG_TRC, dptr, "dup_reset()\n"); sim_debug(DBG_TRC, dptr, "dup_reset()\n");
dup_desc.packet = TRUE; dup_desc.packet = TRUE;
dup_desc.buffered = 16384;
if ((UNIBUS) && (dptr == &dpv_dev)) { if ((UNIBUS) && (dptr == &dpv_dev)) {
if (!(dptr->flags & DEV_DIS)) { if (!(dptr->flags & DEV_DIS)) {
printf ("Can't enable Qbus device on Unibus system\n"); sim_printf ("Can't enable Qbus device on Unibus system\n");
dptr->flags |= DEV_DIS; dptr->flags |= DEV_DIS;
return SCPE_ARG; return SCPE_ARG;
} }
@ -1207,7 +1209,7 @@ if ((UNIBUS) && (dptr == &dpv_dev)) {
if ((!UNIBUS) && (dptr == &dup_dev)) { if ((!UNIBUS) && (dptr == &dup_dev)) {
if (!(dptr->flags & DEV_DIS)) { if (!(dptr->flags & DEV_DIS)) {
printf ("Can't enable Unibus device on Qbus system\n"); sim_printf ("Can't enable Unibus device on Qbus system\n");
dptr->flags |= DEV_DIS; dptr->flags |= DEV_DIS;
return SCPE_ARG; return SCPE_ARG;
} }
@ -1216,8 +1218,11 @@ if ((!UNIBUS) && (dptr == &dup_dev)) {
if (dup_ldsc == NULL) { /* First time startup */ if (dup_ldsc == NULL) { /* First time startup */
dup_desc.ldsc = dup_ldsc = (TMLN *)calloc (dup_desc.lines, sizeof(*dup_ldsc)); dup_desc.ldsc = dup_ldsc = (TMLN *)calloc (dup_desc.lines, sizeof(*dup_ldsc));
for (i = 0; i < dup_desc.lines; i++) /* init each line */ for (i = 0; i < dup_desc.lines; i++) { /* init each line */
dup_units[i] = dup_unit_template; dup_units[i] = dup_unit_template;
if (dup_units[i].flags & UNIT_ATT)
++attached;
}
dup_units[dup_desc.lines] = dup_poll_unit_template; dup_units[dup_desc.lines] = dup_poll_unit_template;
/* Initialize to standard factory Option Jumper Settings */ /* Initialize to standard factory Option Jumper Settings */
for (i = 0; i < DUP_LINES; i++) { for (i = 0; i < DUP_LINES; i++) {
@ -1226,8 +1231,11 @@ if (dup_ldsc == NULL) { /* First time startup */
dup_W6[i] = TRUE; dup_W6[i] = TRUE;
} }
} }
for (i = 0; i < dup_desc.lines; i++) /* init each line */ for (i = 0; i < dup_desc.lines; i++) { /* init each line */
dup_clear (i, TRUE); dup_clear (i, TRUE);
if (dup_units[i].flags & UNIT_ATT)
++attached;
}
dup_rxi = dup_txi = 0; /* clr master int */ dup_rxi = dup_txi = 0; /* clr master int */
CLR_INT (DUPRX); CLR_INT (DUPRX);
CLR_INT (DUPTX); CLR_INT (DUPTX);
@ -1237,9 +1245,10 @@ dup_desc.dptr = DUPDPTR; /* Connect appropriate d
dup_desc.uptr = dup_units+dup_desc.lines; /* Identify polling unit */ dup_desc.uptr = dup_units+dup_desc.lines; /* Identify polling unit */
sim_cancel (dup_units+dup_desc.lines); /* stop poll */ sim_cancel (dup_units+dup_desc.lines); /* stop poll */
ndev = ((dptr->flags & DEV_DIS)? 0: dup_desc.lines ); ndev = ((dptr->flags & DEV_DIS)? 0: dup_desc.lines );
if (ndev) r = auto_config (dptr->name, ndev); /* auto config */
sim_activate_after (dup_units+dup_desc.lines, DUP_CONNECT_POLL*1000000); if ((r == SCPE_OK) && (attached))
return auto_config (dptr->name, ndev); /* auto config */ sim_activate_after (dup_units+dup_desc.lines, DUP_CONNECT_POLL*1000000);/* start poll */
return r;
} }
static t_stat dup_attach (UNIT *uptr, char *cptr) static t_stat dup_attach (UNIT *uptr, char *cptr)
@ -1253,7 +1262,7 @@ if (!cptr || !*cptr)
return SCPE_ARG; return SCPE_ARG;
if (!(uptr->flags & UNIT_ATTABLE)) if (!(uptr->flags & UNIT_ATTABLE))
return SCPE_NOATT; return SCPE_NOATT;
sprintf (attach_string, "Line=%d,Buffered=16384,%s", dup, cptr); sprintf (attach_string, "Line=%d,%s", dup, cptr);
r = tmxr_open_master (&dup_desc, attach_string); /* open master socket */ r = tmxr_open_master (&dup_desc, attach_string); /* open master socket */
free (uptr->filename); free (uptr->filename);
uptr->filename = tmxr_line_attach_string(&dup_desc.ldsc[dup]); uptr->filename = tmxr_line_attach_string(&dup_desc.ldsc[dup]);
@ -1270,6 +1279,7 @@ DEVICE *dptr = DUPDPTR;
int32 dup = (int32)(uptr-dptr->units); int32 dup = (int32)(uptr-dptr->units);
TMLN *lp = &dup_ldsc[dup]; TMLN *lp = &dup_ldsc[dup];
int32 i, attached; int32 i, attached;
t_stat r;
if (!(uptr->flags & UNIT_ATT)) /* attached? */ if (!(uptr->flags & UNIT_ATT)) /* attached? */
return SCPE_OK; return SCPE_OK;
@ -1280,6 +1290,7 @@ for (i=attached=0; i<dup_desc.lines; i++)
++attached; ++attached;
if (!attached) if (!attached)
sim_cancel (dup_units+dup_desc.lines); /* stop poll on last detach */ sim_cancel (dup_units+dup_desc.lines); /* stop poll on last detach */
r = tmxr_detach_ln (lp);
free (uptr->filename); free (uptr->filename);
uptr->filename = NULL; uptr->filename = NULL;
free (dup_rcvpacket[dup]); free (dup_rcvpacket[dup]);
@ -1290,7 +1301,7 @@ free (dup_xmtpacket[dup]);
dup_xmtpacket[dup] = NULL; dup_xmtpacket[dup] = NULL;
dup_xmtpksize[dup] = 0; dup_xmtpksize[dup] = 0;
dup_xmtpkoffset[dup] = 0; dup_xmtpkoffset[dup] = 0;
return tmxr_detach_ln (lp); return r;
} }
/* SET/SHOW SPEED processor */ /* SET/SHOW SPEED processor */
@ -1450,6 +1461,7 @@ for (l=dup_desc.lines; l < newln; l++) {
} }
dup_units[newln] = dup_poll_unit_template; dup_units[newln] = dup_poll_unit_template;
dup_desc.lines = newln; dup_desc.lines = newln;
dup_desc.uptr = dptr->units + newln; /* Identify polling unit */
dptr->numunits = newln + 1; dptr->numunits = newln + 1;
return dup_reset (dptr); /* setup lines and auto config */ return dup_reset (dptr); /* setup lines and auto config */
} }

View file

@ -769,14 +769,10 @@ if (r != SCPE_OK) { /* error? */
} }
if (sim_switches & SWMASK ('M')) { /* modem control? */ if (sim_switches & SWMASK ('M')) { /* modem control? */
dz_mctl = 1; dz_mctl = 1;
printf ("Modem control activated\n"); sim_printf ("Modem control activated\n");
if (sim_log)
fprintf (sim_log, "Modem control activated\n");
if (sim_switches & SWMASK ('A')) { /* autodisconnect? */ if (sim_switches & SWMASK ('A')) { /* autodisconnect? */
dz_auto = 1; dz_auto = 1;
printf ("Auto disconnect activated\n"); sim_printf ("Auto disconnect activated\n");
if (sim_log)
fprintf (sim_log, "Auto disconnect activated\n");
} }
} }

View file

@ -313,16 +313,10 @@ if (vec && !(sim_switches & SWMASK ('P'))) {
if (!cdname) { if (!cdname) {
cdname = "CPU"; cdname = "CPU";
} }
printf ("Device %s interrupt vector conflict with %s at ", sim_printf ("Device %s interrupt vector conflict with %s at ",
sim_dname (dptr), cdname); sim_dname (dptr), cdname);
fprint_val (stdout, (t_value) dibp->vec, DEV_RDX, 32, PV_LEFT); sim_print_val ((t_value) dibp->vec, DEV_RDX, 32, PV_LEFT);
printf ("\n"); sim_printf ("\n");
if (sim_log) {
fprintf (sim_log, "Device %s interrupt vector conflict with %s at ",
sim_dname (dptr), cdname);
fprint_val (sim_log, (t_value) dibp->vec, DEV_RDX, 32, PV_LEFT);
fprintf (sim_log, "\n");
}
return SCPE_STOP; return SCPE_STOP;
} }
} }
@ -336,10 +330,7 @@ for (i = 0; i < dibp->vnum; i++) { /* loop thru vec */
(int_ack[ilvl][ibit] != dibp->ack[i])) || (int_ack[ilvl][ibit] != dibp->ack[i])) ||
(int_vec[ilvl][ibit] && vec && (int_vec[ilvl][ibit] && vec &&
(int_vec[ilvl][ibit] != vec))) { (int_vec[ilvl][ibit] != vec))) {
printf ("Device %s interrupt slot conflict at %d\n", sim_printf ("Device %s interrupt slot conflict at %d\n",
sim_dname (dptr), idx);
if (sim_log)
fprintf (sim_log, "Device %s interrupt slot conflict at %d\n",
sim_dname (dptr), idx); sim_dname (dptr), idx);
return SCPE_STOP; return SCPE_STOP;
} }
@ -373,15 +364,9 @@ for (i = 0; i < (int32) dibp->lnt; i = i + 2) { /* create entries */
if (!cdname) { if (!cdname) {
cdname = "CPU"; cdname = "CPU";
} }
printf ("Device %s address conflict with %s at ", sim_dname (dptr), cdname); sim_printf ("Device %s address conflict with %s at ", sim_dname (dptr), cdname);
fprint_val (stdout, (t_value) dibp->ba, DEV_RDX, 32, PV_LEFT); sim_print_val ((t_value) dibp->ba, DEV_RDX, 32, PV_LEFT);
printf ("\n"); sim_printf ("\n");
if (sim_log) {
fprintf (sim_log, "Device %s address conflict with %s at ", sim_dname (dptr),
cdname);
fprint_val (sim_log, (t_value) dibp->ba, DEV_RDX, 32, PV_LEFT);
fprintf (sim_log, "\n");
}
return SCPE_STOP; return SCPE_STOP;
} }
if (dibp->rd) /* set rd dispatch */ if (dibp->rd) /* set rd dispatch */
@ -812,9 +797,7 @@ for (autp = auto_tab; autp->numc >= 0; autp++) { /* loop thru table */
dptr->flags |= DEV_DIS; dptr->flags |= DEV_DIS;
if (sim_switches & SWMASK ('P')) if (sim_switches & SWMASK ('P'))
continue; continue;
printf ("%s device not compatible with system bus\n", sim_dname(dptr)); sim_printf ("%s device not compatible with system bus\n", sim_dname(dptr));
if (sim_log)
fprintf (sim_log, "%s device not compatible with system bus\n", sim_dname(dptr));
return SCPE_NOFNC; return SCPE_NOFNC;
} }
dibp = (DIB *) dptr->ctxt; /* get DIB */ dibp = (DIB *) dptr->ctxt; /* get DIB */

View file

@ -242,7 +242,7 @@ if ((ptr_unit.flags & UNIT_ATT) == 0)
if ((temp = getc (ptr_unit.fileref)) == EOF) { if ((temp = getc (ptr_unit.fileref)) == EOF) {
if (feof (ptr_unit.fileref)) { if (feof (ptr_unit.fileref)) {
if (ptr_stopioe) if (ptr_stopioe)
printf ("PTR end of file\n"); sim_printf ("PTR end of file\n");
else return SCPE_OK; else return SCPE_OK;
} }
else perror ("PTR I/O error"); else perror ("PTR I/O error");

View file

@ -908,10 +908,7 @@ if ((mbregR[idx] && dibp->rd && /* conflict? */
(mbregW[idx] != dibp->wr)) || (mbregW[idx] != dibp->wr)) ||
(mbabort[idx] && dibp->ack[0] && (mbabort[idx] && dibp->ack[0] &&
(mbabort[idx] != dibp->ack[0]))) { (mbabort[idx] != dibp->ack[0]))) {
printf ("Massbus %s assignment conflict at %d\n", sim_printf ("Massbus %s assignment conflict at %d\n",
sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Massbus %s assignment conflict at %d\n",
sim_dname (dptr), dibp->ba); sim_dname (dptr), dibp->ba);
return SCPE_STOP; return SCPE_STOP;
} }

View file

@ -1242,13 +1242,13 @@ if (uptr->filebuf == NULL) { /* can't alloc? */
return SCPE_MEM; return SCPE_MEM;
} }
fbuf = (uint32 *) uptr->filebuf; /* file buffer */ fbuf = (uint32 *) uptr->filebuf; /* file buffer */
printf ("%s%d: ", sim_dname (&dt_dev), u); sim_printf ("%s%d: ", sim_dname (&dt_dev), u);
if (uptr->flags & UNIT_8FMT) if (uptr->flags & UNIT_8FMT)
printf ("12b format"); sim_printf ("12b format");
else if (uptr->flags & UNIT_11FMT) else if (uptr->flags & UNIT_11FMT)
printf ("16b format"); sim_printf ("16b format");
else printf ("18b/36b format"); else sim_printf ("18b/36b format");
printf (", buffering file in memory\n"); sim_printf (", buffering file in memory\n");
uptr->io_flush = dt_flush; uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) { /* 12b? */ if (uptr->flags & UNIT_8FMT) { /* 12b? */
for (ba = 0; ba < uptr->capac; ) { /* loop thru file */ for (ba = 0; ba < uptr->capac; ) { /* loop thru file */
@ -1356,7 +1356,7 @@ if (sim_is_active (uptr)) { /* active? cancel op */
uptr->STATE = uptr->pos = 0; uptr->STATE = uptr->pos = 0;
} }
if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */ if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */
printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u);
dt_flush (uptr); dt_flush (uptr);
} /* end if hwmark */ } /* end if hwmark */
free (uptr->filebuf); /* release buf */ free (uptr->filebuf); /* release buf */

View file

@ -2705,8 +2705,7 @@ t_stat xq_attach(UNIT* uptr, char* cptr)
char buf[32]; char buf[32];
eth_mac_fmt(&xq->var->mac, buf); /* format ethernet mac address */ eth_mac_fmt(&xq->var->mac, buf); /* format ethernet mac address */
printf("%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", xq->dev->name, buf); sim_printf("%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", xq->dev->name, buf);
if (sim_log) fprintf (sim_log, "%s: MAC Address Conflict on LAN for address %s, change the MAC address to a unique value\n", xq->dev->name, buf);
eth_close(xq->var->etherface); eth_close(xq->var->etherface);
free(tptr); free(tptr);
free(xq->var->etherface); free(xq->var->etherface);

View file

@ -1078,7 +1078,7 @@ int32 xu_command(CTLR* xu)
break; break;
default: /* Unknown (unimplemented) command. */ default: /* Unknown (unimplemented) command. */
printf("%s: unknown ancilliary command 0%o requested !\n", xu->dev->name, fnc); sim_printf("%s: unknown ancilliary command 0%o requested !\n", xu->dev->name, fnc);
return PCSR0_PCEI; return PCSR0_PCEI;
break; break;
@ -1497,8 +1497,7 @@ void xu_port_command (CTLR* xu)
case CMD_BOOT: /* BOOT */ case CMD_BOOT: /* BOOT */
/* not implemented */ /* not implemented */
msg = "%s: BOOT command not implemented!\n"; msg = "%s: BOOT command not implemented!\n";
printf (msg, xu->dev->name); sim_printf (msg, xu->dev->name);
if (sim_log) fprintf(sim_log, msg, xu->dev->name);
xu->var->pcsr0 |= PCSR0_PCEI; xu->var->pcsr0 |= PCSR0_PCEI;
break; break;
@ -1660,8 +1659,7 @@ t_stat xu_attach(UNIT* uptr, char* cptr)
char buf[32]; char buf[32];
eth_mac_fmt(&xu->var->mac, buf); /* format ethernet mac address */ eth_mac_fmt(&xu->var->mac, buf); /* format ethernet mac address */
printf("%s: MAC Address Conflict on LAN for address %s\n", xu->dev->name, buf); sim_printf("%s: MAC Address Conflict on LAN for address %s\n", xu->dev->name, buf);
if (sim_log) fprintf (sim_log, "%s: MAC Address Conflict on LAN for address %s\n", xu->dev->name, buf);
eth_close(xu->var->etherface); eth_close(xu->var->etherface);
free(tptr); free(tptr);
free(xu->var->etherface); free(xu->var->etherface);
@ -1760,7 +1758,7 @@ void xu_dump_rxring (CTLR* xu)
{ {
int i; int i;
int rrlen = xu->var->rrlen; int rrlen = xu->var->rrlen;
printf ("receive ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->rdrb, xu->var->rrlen, xu->var->relen, xu->var->rxnext); sim_printf ("receive ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->rdrb, xu->var->rrlen, xu->var->relen, xu->var->rxnext);
for (i=0; i<rrlen; i++) { for (i=0; i<rrlen; i++) {
uint16 rxhdr[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; uint16 rxhdr[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
uint32 ba = xu->var->rdrb + (xu->var->relen * 2) * i; uint32 ba = xu->var->rdrb + (xu->var->relen * 2) * i;
@ -1769,7 +1767,7 @@ void xu_dump_rxring (CTLR* xu)
int len = rxhdr[0]; int len = rxhdr[0];
uint32 addr = rxhdr[1] + ((rxhdr[2] & 3) << 16); uint32 addr = rxhdr[1] + ((rxhdr[2] & 3) << 16);
if (rstatus == 0) if (rstatus == 0)
printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, rxhdr[0], rxhdr[1], rxhdr[2], rxhdr[3]); sim_printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, rxhdr[0], rxhdr[1], rxhdr[2], rxhdr[3]);
} }
} }
@ -1777,7 +1775,7 @@ void xu_dump_txring (CTLR* xu)
{ {
int i; int i;
int trlen = xu->var->trlen; int trlen = xu->var->trlen;
printf ("transmit ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->tdrb, xu->var->trlen, xu->var->telen, xu->var->txnext); sim_printf ("transmit ring[%s]: base address: %08x headers: %d, header size: %d, current: %d\n", xu->dev->name, xu->var->tdrb, xu->var->trlen, xu->var->telen, xu->var->txnext);
for (i=0; i<trlen; i++) { for (i=0; i<trlen; i++) {
uint16 txhdr[4]; uint16 txhdr[4];
uint32 ba = xu->var->tdrb + (xu->var->telen * 2) * i; uint32 ba = xu->var->tdrb + (xu->var->telen * 2) * i;
@ -1786,7 +1784,7 @@ void xu_dump_txring (CTLR* xu)
int len = txhdr[0]; int len = txhdr[0];
uint32 addr = txhdr[1] + ((txhdr[2] & 3) << 16); uint32 addr = txhdr[1] + ((txhdr[2] & 3) << 16);
if (tstatus == 0) if (tstatus == 0)
printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, txhdr[0], txhdr[1], txhdr[2], txhdr[3]); sim_printf (" header[%d]: own:%d, len:%d, address:%08x data:{%04x,%04x,%04x,%04x}\n", i, own, len, addr, txhdr[0], txhdr[1], txhdr[2], txhdr[3]);
} }
} }

View file

@ -2259,10 +2259,7 @@ for (i = p = 0; (dptr = sim_devices[i]) != NULL; i++) { /* add devices *
for (j = 0; j < dibp->num; j++) { /* loop thru disp */ for (j = 0; j < dibp->num; j++) { /* loop thru disp */
if (dibp->dsp[j]) { /* any dispatch? */ if (dibp->dsp[j]) { /* any dispatch? */
if (dev_tab[dibp->dev + j]) { /* already filled? */ if (dev_tab[dibp->dev + j]) { /* already filled? */
printf ("%s device number conflict at %02o\n", sim_printf ("%s device number conflict at %02o\n",
sim_dname (dptr), dibp->dev + j);
if (sim_log)
fprintf (sim_log, "%s device number conflict at %02o\n",
sim_dname (dptr), dibp->dev + j); sim_dname (dptr), dibp->dev + j);
return TRUE; return TRUE;
} }

View file

@ -1436,13 +1436,13 @@ if (uptr->filebuf == NULL) { /* can't alloc? */
return SCPE_MEM; return SCPE_MEM;
} }
fbuf = (uint32 *) uptr->filebuf; /* file buffer */ fbuf = (uint32 *) uptr->filebuf; /* file buffer */
printf ("%s%d: ", sim_dname (&dt_dev), u); sim_printf ("%s%d: ", sim_dname (&dt_dev), u);
if (uptr->flags & UNIT_8FMT) if (uptr->flags & UNIT_8FMT)
printf ("12b format"); sim_printf ("12b format");
else if (uptr->flags & UNIT_11FMT) else if (uptr->flags & UNIT_11FMT)
printf ("16b format"); sim_printf ("16b format");
else printf ("18b/36b format"); else sim_printf ("18b/36b format");
printf (", buffering file in memory\n"); sim_printf (", buffering file in memory\n");
uptr->io_flush = dt_flush; uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) { /* 12b? */ if (uptr->flags & UNIT_8FMT) { /* 12b? */
for (ba = 0; ba < uptr->capac; ) { /* loop thru file */ for (ba = 0; ba < uptr->capac; ) { /* loop thru file */
@ -1548,7 +1548,7 @@ if (sim_is_active (uptr)) {
uptr->STATE = uptr->pos = 0; uptr->STATE = uptr->pos = 0;
} }
if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */ if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { /* any data? */
printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u);
dt_flush (uptr); dt_flush (uptr);
} /* end if hwmark */ } /* end if hwmark */
free (uptr->filebuf); /* release buf */ free (uptr->filebuf); /* release buf */

View file

@ -573,7 +573,7 @@ if ((temp = getc (ptr_unit.fileref)) == EOF) { /* end of file? */
#endif #endif
if (feof (ptr_unit.fileref)) { if (feof (ptr_unit.fileref)) {
if (ptr_stopioe) if (ptr_stopioe)
printf ("PTR end of file\n"); sim_printf ("PTR end of file\n");
else return SCPE_OK; else return SCPE_OK;
} }
else perror ("PTR I/O error"); else perror ("PTR I/O error");

View file

@ -1499,10 +1499,7 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* add devices */
for (j = 0; j < dibp->num; j++) { /* loop thru disp */ for (j = 0; j < dibp->num; j++) { /* loop thru disp */
if (dibp->dsp[j]) { /* any dispatch? */ if (dibp->dsp[j]) { /* any dispatch? */
if (dev_tab[dibp->dev + j]) { /* already filled? */ if (dev_tab[dibp->dev + j]) { /* already filled? */
printf ("%s device number conflict at %02o\n", sim_printf ("%s device number conflict at %02o\n",
sim_dname (dptr), dibp->dev + j);
if (sim_log)
fprintf (sim_log, "%s device number conflict at %02o\n",
sim_dname (dptr), dibp->dev + j); sim_dname (dptr), dibp->dev + j);
return TRUE; return TRUE;
} }

View file

@ -1234,13 +1234,13 @@ if (uptr->filebuf == NULL) { /* can't alloc? */
return SCPE_MEM; return SCPE_MEM;
} }
fbuf = (uint16 *) uptr->filebuf; /* file buffer */ fbuf = (uint16 *) uptr->filebuf; /* file buffer */
printf ("%s%d: ", sim_dname (&dt_dev), u); sim_printf ("%s%d: ", sim_dname (&dt_dev), u);
if (uptr->flags & UNIT_8FMT) if (uptr->flags & UNIT_8FMT)
printf ("12b format"); sim_printf ("12b format");
else if (uptr->flags & UNIT_11FMT) else if (uptr->flags & UNIT_11FMT)
printf ("16b format"); sim_printf ("16b format");
else printf ("18b/36b format"); else sim_printf ("18b/36b format");
printf (", buffering file in memory\n"); sim_printf (", buffering file in memory\n");
uptr->io_flush = dt_flush; uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) /* 12b? */ if (uptr->flags & UNIT_8FMT) /* 12b? */
uptr->hwmark = fxread (uptr->filebuf, sizeof (uint16), uptr->hwmark = fxread (uptr->filebuf, sizeof (uint16),
@ -1332,7 +1332,7 @@ if (sim_is_active (uptr)) {
uptr->STATE = uptr->pos = 0; uptr->STATE = uptr->pos = 0;
} }
if (uptr->hwmark && ((uptr->flags & UNIT_RO)== 0)) { /* any data? */ if (uptr->hwmark && ((uptr->flags & UNIT_RO)== 0)) { /* any data? */
printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u); sim_printf ("%s%d: writing buffer to file\n", sim_dname (&dt_dev), u);
dt_flush (uptr); dt_flush (uptr);
} /* end if hwmark */ } /* end if hwmark */
free (uptr->filebuf); /* release buf */ free (uptr->filebuf); /* release buf */

View file

@ -196,12 +196,14 @@ int32 sections_read = 0;
for (;;) { for (;;) {
csum = origin = field = newf = 0; /* init */ csum = origin = field = newf = 0; /* init */
do { /* skip leader */ do { /* skip leader */
if ((hi = sim_bin_getc (fi, &newf)) == EOF) if ((hi = sim_bin_getc (fi, &newf)) == EOF) {
if (sections_read != 0) { if (sections_read != 0) {
printf ("%d sections sucessfully read\n\r", sections_read); sim_printf ("%d sections sucessfully read\n\r", sections_read);
return SCPE_OK; return SCPE_OK;
} else }
else
return SCPE_FMT; return SCPE_FMT;
}
} while ((hi == 0) || (hi >= 0200)); } while ((hi == 0) || (hi >= 0200));
for (;;) { /* data blocks */ for (;;) { /* data blocks */
if ((lo = sim_bin_getc (fi, &newf)) == EOF) /* low char */ if ((lo = sim_bin_getc (fi, &newf)) == EOF) /* low char */
@ -213,7 +215,7 @@ for (;;) {
if (hi == 0200) { /* end of tape? */ if (hi == 0200) { /* end of tape? */
if ((csum - wd) & 07777) { /* valid csum? */ if ((csum - wd) & 07777) { /* valid csum? */
if (sections_read != 0) if (sections_read != 0)
printf ("%d sections sucessfully read\n\r", sections_read); sim_printf ("%d sections sucessfully read\n\r", sections_read);
return SCPE_CSUM; return SCPE_CSUM;
} }
if (!(sim_switches & SWMASK ('A'))) /* Load all sections? */ if (!(sim_switches & SWMASK ('A'))) /* Load all sections? */

View file

@ -982,10 +982,7 @@ for (i = 0; (dptr = sim_devices[i]); i++) { /* loop thru devices */
for (j = 0; j < tplp->num; j++) { /* repeat as needed */ for (j = 0; j < tplp->num; j++) { /* repeat as needed */
doff = dev + tplp->off + j; /* get offset dnum */ doff = dev + tplp->off + j; /* get offset dnum */
if (dev_map[doff][ch]) { /* slot in use? */ if (dev_map[doff][ch]) { /* slot in use? */
printf ("Device number conflict, chan = %s, devno = %02o\n", sim_printf ("Device number conflict, chan = %s, devno = %02o\n",
chname[ch], doff);
if (sim_log)
fprintf (sim_log, "Device number conflict, chan = %s, dev = %02o\n",
chname[ch], doff); chname[ch], doff);
return TRUE; return TRUE;
} }

View file

@ -278,7 +278,7 @@ if ((temp = getc (ptr_unit.fileref)) == EOF) { /* end of file? */
ptr_set_err (); /* yes, err, disc */ ptr_set_err (); /* yes, err, disc */
if (feof (ptr_unit.fileref)) { /* end of file? */ if (feof (ptr_unit.fileref)) { /* end of file? */
if (ptr_stopioe) if (ptr_stopioe)
printf ("PTR end of file\n"); sim_printf ("PTR end of file\n");
else return SCPE_OK; else return SCPE_OK;
} }
else perror ("PTR I/O error"); /* I/O error */ else perror ("PTR I/O error"); /* I/O error */

View file

@ -379,9 +379,7 @@ t_stat r;
r = vax610_boot_parse (flag, ptr); /* parse the boot cmd */ r = vax610_boot_parse (flag, ptr); /* parse the boot cmd */
if (r != SCPE_OK) { /* error? */ if (r != SCPE_OK) { /* error? */
if (r >= SCPE_BASE) { /* message available? */ if (r >= SCPE_BASE) { /* message available? */
printf ("%s\n", sim_error_text (r)); sim_printf ("%s\n", sim_error_text (r));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (r));
r |= SCPE_NOMESSAGE; r |= SCPE_NOMESSAGE;
} }
return r; return r;
@ -504,9 +502,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */
(reset_all (0) != SCPE_OK) || /* reset the world */ (reset_all (0) != SCPE_OK) || /* reset the world */
(cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */
ABORT (STOP_BOOT); /* any error? */ ABORT (STOP_BOOT); /* any error? */
printf ("Rebooting...\n"); sim_printf ("Rebooting...\n");
if (sim_log)
fprintf (sim_log, "Rebooting...\n");
return cc; return cc;
} }

View file

@ -489,7 +489,7 @@ switch (opcode) {
case TD_OPDAT: case TD_OPDAT:
if (td_state != TD_WRITE1) { /* expecting data? */ if (td_state != TD_WRITE1) { /* expecting data? */
printf("TU58 protocol error 1\n"); sim_printf("TU58 protocol error 1\n");
return; return;
} }
if (td_ibptr < 2) { /* whole packet read? */ if (td_ibptr < 2) { /* whole packet read? */
@ -502,7 +502,7 @@ switch (opcode) {
case TD_OPCMD: case TD_OPCMD:
if (td_state != TD_IDLE) { /* expecting command? */ if (td_state != TD_IDLE) { /* expecting command? */
printf("TU58 protocol error 2\n"); sim_printf("TU58 protocol error 2\n");
return; return;
} }
if (td_ibptr < 2) { /* whole packet read? */ if (td_ibptr < 2) { /* whole packet read? */
@ -521,7 +521,7 @@ switch (opcode) {
break; break;
case TD_CMDINI: case TD_CMDINI:
printf("Warning: TU58 command 'INIT' not implemented\n"); sim_printf("Warning: TU58 command 'INIT' not implemented\n");
break; break;
case TD_CMDRD: case TD_CMDRD:
@ -543,11 +543,11 @@ switch (opcode) {
break; break;
case TD_CMDPOS: case TD_CMDPOS:
printf("Warning: TU58 command 'Position' not implemented\n"); sim_printf("Warning: TU58 command 'Position' not implemented\n");
break; break;
case TD_CMDDIA: case TD_CMDDIA:
printf("Warning: TU58 command 'Diagnose' not implemented\n"); sim_printf("Warning: TU58 command 'Diagnose' not implemented\n");
break; break;
case TD_CMDMRSP: /* MRSP supported? */ case TD_CMDMRSP: /* MRSP supported? */
@ -574,7 +574,7 @@ switch (opcode) {
case TD_OPBOO: case TD_OPBOO:
if (td_state != TD_IDLE) { if (td_state != TD_IDLE) {
printf("TU58 protocol error 3\n"); sim_printf("TU58 protocol error 3\n");
return; return;
} }
if (td_ibptr < 2) { /* whole packet read? */ if (td_ibptr < 2) { /* whole packet read? */

View file

@ -465,9 +465,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */
(reset_all (0) != SCPE_OK) || /* reset the world */ (reset_all (0) != SCPE_OK) || /* reset the world */
(cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */
ABORT (STOP_BOOT); /* any error? */ ABORT (STOP_BOOT); /* any error? */
printf ("Rebooting...\n"); sim_printf ("Rebooting...\n");
if (sim_log)
fprintf (sim_log, "Rebooting...\n");
return cc; return cc;
} }
@ -485,9 +483,7 @@ t_stat r;
r = vax730_boot_parse (flag, ptr); /* parse the boot cmd */ r = vax730_boot_parse (flag, ptr); /* parse the boot cmd */
if (r != SCPE_OK) { /* error? */ if (r != SCPE_OK) { /* error? */
if (r >= SCPE_BASE) { /* message available? */ if (r >= SCPE_BASE) { /* message available? */
printf ("%s\n", sim_error_text (r)); sim_printf ("%s\n", sim_error_text (r));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (r));
r |= SCPE_NOMESSAGE; r |= SCPE_NOMESSAGE;
} }
return r; return r;
@ -633,9 +629,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */
(nexusR[idx] != dibp->rd)) || (nexusR[idx] != dibp->rd)) ||
(nexusW[idx] && dibp->wr && (nexusW[idx] && dibp->wr &&
(nexusW[idx] != dibp->wr))) { (nexusW[idx] != dibp->wr))) {
printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
return SCPE_STOP; return SCPE_STOP;
} }
if (dibp->rd) /* set rd dispatch */ if (dibp->rd) /* set rd dispatch */

View file

@ -192,7 +192,7 @@ t_stat uba_rdreg (int32 *val, int32 pa, int32 lnt)
int32 idx, ofs; int32 idx, ofs;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt);
// **FIXME** - Set error bit? // **FIXME** - Set error bit?
return SCPE_OK; return SCPE_OK;
} }
@ -243,7 +243,7 @@ t_stat uba_wrreg (int32 val, int32 pa, int32 lnt)
int32 idx, ofs; int32 idx, ofs;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt);
// **FIXME** - Set error bit? // **FIXME** - Set error bit?
return SCPE_OK; return SCPE_OK;
} }
@ -335,7 +335,7 @@ if ((lnt == L_BYTE) || /* byte? */
iod = iod << 16; iod = iod << 16;
} }
else { else {
printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); sim_printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt);
// **FIXME** - Set error bit? // **FIXME** - Set error bit?
iod = 0; iod = 0;
} }
@ -360,7 +360,7 @@ if (lnt == L_BYTE) /* byte? DATOB */
else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */ else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */
WriteUb (pa, val, WRITE); /* DATO */ WriteUb (pa, val, WRITE); /* DATO */
else { else {
printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); sim_printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt);
// **FIXME** - Set error bit? // **FIXME** - Set error bit?
} }
SET_IRQL; /* update ints */ SET_IRQL; /* update ints */

View file

@ -549,9 +549,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */
(reset_all (0) != SCPE_OK) || /* reset the world */ (reset_all (0) != SCPE_OK) || /* reset the world */
(cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */
ABORT (STOP_BOOT); /* any error? */ ABORT (STOP_BOOT); /* any error? */
printf ("Rebooting...\n"); sim_printf ("Rebooting...\n");
if (sim_log)
fprintf (sim_log, "Rebooting...\n");
return cc; return cc;
} }
@ -569,9 +567,7 @@ t_stat r;
r = vax750_boot_parse (flag, ptr); /* parse the boot cmd */ r = vax750_boot_parse (flag, ptr); /* parse the boot cmd */
if (r != SCPE_OK) { /* error? */ if (r != SCPE_OK) { /* error? */
if (r >= SCPE_BASE) { /* message available? */ if (r >= SCPE_BASE) { /* message available? */
printf ("%s\n", sim_error_text (r)); sim_printf ("%s\n", sim_error_text (r));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (r));
r |= SCPE_NOMESSAGE; r |= SCPE_NOMESSAGE;
} }
return r; return r;
@ -720,9 +716,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */
(nexusR[idx] != dibp->rd)) || (nexusR[idx] != dibp->rd)) ||
(nexusW[idx] && dibp->wr && (nexusW[idx] && dibp->wr &&
(nexusW[idx] != dibp->wr))) { (nexusW[idx] != dibp->wr))) {
printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
return SCPE_STOP; return SCPE_STOP;
} }
if (dibp->rd) /* set rd dispatch */ if (dibp->rd) /* set rd dispatch */

View file

@ -487,7 +487,7 @@ switch (opcode) {
case TD_OPDAT: case TD_OPDAT:
if (td_state != TD_WRITE1) { /* expecting data? */ if (td_state != TD_WRITE1) { /* expecting data? */
printf("TU58 protocol error 1\n"); sim_printf("TU58 protocol error 1\n");
return; return;
} }
if (td_ibptr < 2) { /* whole packet read? */ if (td_ibptr < 2) { /* whole packet read? */
@ -500,7 +500,7 @@ switch (opcode) {
case TD_OPCMD: case TD_OPCMD:
if (td_state != TD_IDLE) { /* expecting command? */ if (td_state != TD_IDLE) { /* expecting command? */
printf("TU58 protocol error 2\n"); sim_printf("TU58 protocol error 2\n");
return; return;
} }
if (td_ibptr < 2) { /* whole packet read? */ if (td_ibptr < 2) { /* whole packet read? */
@ -518,7 +518,7 @@ switch (opcode) {
break; break;
case TD_CMDINI: case TD_CMDINI:
printf("Warning: TU58 command 'INIT' not implemented\n"); sim_printf("Warning: TU58 command 'INIT' not implemented\n");
break; break;
case TD_CMDRD: case TD_CMDRD:
@ -538,11 +538,11 @@ switch (opcode) {
break; break;
case TD_CMDPOS: case TD_CMDPOS:
printf("Warning: TU58 command 'Position' not implemented\n"); sim_printf("Warning: TU58 command 'Position' not implemented\n");
break; break;
case TD_CMDDIA: case TD_CMDDIA:
printf("Warning: TU58 command 'Diagnose' not implemented\n"); sim_printf("Warning: TU58 command 'Diagnose' not implemented\n");
break; break;
case TD_CMDMRSP: case TD_CMDMRSP:
@ -568,7 +568,7 @@ switch (opcode) {
case TD_OPBOO: case TD_OPBOO:
if (td_state != TD_IDLE) { if (td_state != TD_IDLE) {
printf("TU58 protocol error 3\n"); sim_printf("TU58 protocol error 3\n");
return; return;
} }
if (td_ibptr < 2) { /* whole packet read? */ if (td_ibptr < 2) { /* whole packet read? */

View file

@ -193,7 +193,7 @@ t_stat uba_rdreg (int32 *val, int32 pa, int32 lnt)
int32 idx, ofs; int32 idx, ofs;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt);
/* FIXME: set appropriate error bits */ /* FIXME: set appropriate error bits */
return SCPE_OK; return SCPE_OK;
} }
@ -242,7 +242,7 @@ t_stat uba_wrreg (int32 val, int32 pa, int32 lnt)
int32 idx, ofs; int32 idx, ofs;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt);
/* FIXME: set appropriate error bits */ /* FIXME: set appropriate error bits */
return SCPE_OK; return SCPE_OK;
} }
@ -339,7 +339,7 @@ if ((lnt == L_BYTE) || /* byte? */
iod = iod << 16; iod = iod << 16;
} }
else { else {
printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); sim_printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt);
/* FIXME: set appropriate error bits */ /* FIXME: set appropriate error bits */
iod = 0; iod = 0;
} }
@ -364,7 +364,7 @@ if (lnt == L_BYTE) /* byte? DATOB */
else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */ else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */
WriteUb (pa, val, WRITE); /* DATO */ WriteUb (pa, val, WRITE); /* DATO */
else { else {
printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); sim_printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt);
/* FIXME: set appropriate error bits */ /* FIXME: set appropriate error bits */
} }
SET_IRQL; /* update ints */ SET_IRQL; /* update ints */

View file

@ -168,7 +168,7 @@ int32 mctl, ofs;
t_bool extmem = MEMSIZE > MAXMEMSIZE; t_bool extmem = MEMSIZE > MAXMEMSIZE;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>MCTL: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>MCTL: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt);
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
return SCPE_OK; return SCPE_OK;
} }
@ -213,7 +213,7 @@ int32 mctl, ofs, mask;
t_bool extmem = MEMSIZE > MAXMEMSIZE; t_bool extmem = MEMSIZE > MAXMEMSIZE;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>MCTL: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>MCTL: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt);
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
return SCPE_OK; return SCPE_OK;
} }

View file

@ -615,9 +615,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */
(reset_all (0) != SCPE_OK) || /* reset the world */ (reset_all (0) != SCPE_OK) || /* reset the world */
(cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */
ABORT (STOP_BOOT); /* any error? */ ABORT (STOP_BOOT); /* any error? */
printf ("Rebooting...\n"); sim_printf ("Rebooting...\n");
if (sim_log)
fprintf (sim_log, "Rebooting...\n");
return cc; return cc;
} }
@ -635,9 +633,7 @@ t_stat r;
r = vax780_boot_parse (flag, ptr); /* parse the boot cmd */ r = vax780_boot_parse (flag, ptr); /* parse the boot cmd */
if (r != SCPE_OK) { /* error? */ if (r != SCPE_OK) { /* error? */
if (r >= SCPE_BASE) { /* message available? */ if (r >= SCPE_BASE) { /* message available? */
printf ("%s\n", sim_error_text (r)); sim_printf ("%s\n", sim_error_text (r));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (r));
r |= SCPE_NOMESSAGE; r |= SCPE_NOMESSAGE;
} }
return r; return r;
@ -792,9 +788,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */
(nexusR[idx] != dibp->rd)) || (nexusR[idx] != dibp->rd)) ||
(nexusW[idx] && dibp->wr && (nexusW[idx] && dibp->wr &&
(nexusW[idx] != dibp->wr))) { (nexusW[idx] != dibp->wr))) {
printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
return SCPE_STOP; return SCPE_STOP;
} }
if (dibp->rd) /* set rd dispatch */ if (dibp->rd) /* set rd dispatch */

View file

@ -304,7 +304,7 @@ t_stat uba_rdreg (int32 *val, int32 pa, int32 lnt)
int32 idx, ofs; int32 idx, ofs;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>UBA: invalid adapter read mask, pa = %X, lnt = %d\r\n", pa, lnt);
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
return SCPE_OK; return SCPE_OK;
} }
@ -393,7 +393,7 @@ t_stat uba_wrreg (int32 val, int32 pa, int32 lnt)
int32 idx, ofs, old_cr; int32 idx, ofs, old_cr;
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt); sim_printf (">>UBA: invalid adapter write mask, pa = %X, lnt = %d\r\n", pa, lnt);
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
return SCPE_OK; return SCPE_OK;
} }
@ -526,7 +526,7 @@ if ((lnt == L_BYTE) || /* byte? */
iod = iod << 16; iod = iod << 16;
} }
else { else {
printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt); sim_printf (">>UBA: invalid read mask, pa = %x, lnt = %d\n", pa, lnt);
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
iod = 0; iod = 0;
} }
@ -551,7 +551,7 @@ if (lnt == L_BYTE) /* byte? DATOB */
else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */ else if ((lnt == L_WORD) && ((pa & 1) == 0)) /* aligned word? */
WriteUb (pa, val, WRITE); /* DATO */ WriteUb (pa, val, WRITE); /* DATO */
else { else {
printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt); sim_printf (">>UBA: invalid write mask, pa = %x, lnt = %d\n", pa, lnt);
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
} }
SET_IRQL; /* update ints */ SET_IRQL; /* update ints */

View file

@ -366,7 +366,7 @@ t_stat r;
mb = NEXUS_GETNEX (pa) - TR_MBA0; /* get MBA */ mb = NEXUS_GETNEX (pa) - TR_MBA0; /* get MBA */
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>MBA%d: invalid adapter read mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt); sim_printf (">>MBA%d: invalid adapter read mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt);
#if defined(VAX_780) #if defined(VAX_780)
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
#endif #endif
@ -460,7 +460,7 @@ t_bool cs1dt;
mb = NEXUS_GETNEX (pa) - TR_MBA0; /* get MBA */ mb = NEXUS_GETNEX (pa) - TR_MBA0; /* get MBA */
if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */ if ((pa & 3) || (lnt != L_LONG)) { /* unaligned or not lw? */
printf (">>MBA%d: invalid adapter write mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt); sim_printf (">>MBA%d: invalid adapter write mask, pa = 0x%X, lnt = %d\r\n", mb, pa, lnt);
#if defined(VAX_780) #if defined(VAX_780)
sbi_set_errcnf (); /* err confirmation */ sbi_set_errcnf (); /* err confirmation */
#endif #endif
@ -935,10 +935,7 @@ if ((mbregR[idx] && dibp->rd && /* conflict? */
(mbregW[idx] != dibp->wr)) || (mbregW[idx] != dibp->wr)) ||
(mbabort[idx] && dibp->ack[0] && (mbabort[idx] && dibp->ack[0] &&
(mbabort[idx] != dibp->ack[0]))) { (mbabort[idx] != dibp->ack[0]))) {
printf ("Massbus %s assignment conflict at %d\n", sim_printf ("Massbus %s assignment conflict at %d\n",
sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Massbus %s assignment conflict at %d\n",
sim_dname (dptr), dibp->ba); sim_dname (dptr), dibp->ba);
return SCPE_STOP; return SCPE_STOP;
} }

View file

@ -682,9 +682,7 @@ if ((cpu_boot_cmd[0] == 0) || /* saved boot cmd? */
(reset_all (0) != SCPE_OK) || /* reset the world */ (reset_all (0) != SCPE_OK) || /* reset the world */
(cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */ (cpu_boot (0, NULL) != SCPE_OK)) /* set up boot code */
ABORT (STOP_BOOT); /* any error? */ ABORT (STOP_BOOT); /* any error? */
printf ("Rebooting...\n"); sim_printf ("Rebooting...\n");
if (sim_log)
fprintf (sim_log, "Rebooting...\n");
return cc; return cc;
} }
@ -702,9 +700,7 @@ t_stat r;
r = vax860_boot_parse (flag, ptr); /* parse the boot cmd */ r = vax860_boot_parse (flag, ptr); /* parse the boot cmd */
if (r != SCPE_OK) { /* error? */ if (r != SCPE_OK) { /* error? */
if (r >= SCPE_BASE) { /* message available? */ if (r >= SCPE_BASE) { /* message available? */
printf ("%s\n", sim_error_text (r)); sim_printf ("%s\n", sim_error_text (r));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (r));
r |= SCPE_NOMESSAGE; r |= SCPE_NOMESSAGE;
} }
return r; return r;

View file

@ -186,7 +186,7 @@ void sbia_wr (int32 pa, int32 val, int32 lnt)
break; break;
case 1: /* SBICSR */ case 1: /* SBICSR */
printf ("sbi_csr wr: %08X\n", val); sim_printf ("sbi_csr wr: %08X\n", val);
sbi_csr = sbi_csr & SBICSR_WR; sbi_csr = sbi_csr & SBICSR_WR;
break; break;
@ -350,9 +350,7 @@ if ((nexusR[idx] && dibp->rd && /* conflict? */
(nexusR[idx] != dibp->rd)) || (nexusR[idx] != dibp->rd)) ||
(nexusW[idx] && dibp->wr && (nexusW[idx] && dibp->wr &&
(nexusW[idx] != dibp->wr))) { (nexusW[idx] != dibp->wr))) {
printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba); sim_printf ("Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
if (sim_log)
fprintf (sim_log, "Nexus %s conflict at %d\n", sim_dname (dptr), dibp->ba);
return SCPE_STOP; return SCPE_STOP;
} }
if (dibp->rd) /* set rd dispatch */ if (dibp->rd) /* set rd dispatch */

View file

@ -558,7 +558,7 @@ switch (fnc) {
break; break;
default: default:
printf ("CS: Unknown Command: %d\n", fnc); sim_printf ("CS: Unknown Command: %d\n", fnc);
} }
} }
@ -1073,7 +1073,7 @@ else switch (lc_fnc) { /* idle, case */
break; break;
default: /* all others */ default: /* all others */
printf ("TTO3: Unknown console command: %X\n", lc_fnc); sim_printf ("TTO3: Unknown console command: %X\n", lc_fnc);
break; break;
} }
return SCPE_OK; return SCPE_OK;

View file

@ -3514,9 +3514,7 @@ t_stat cpu_load_bootcode (const char *filename, const unsigned char *builtin_cod
char args[CBUFSIZE]; char args[CBUFSIZE];
t_stat r; t_stat r;
printf ("Loading boot code from %s\n", filename); sim_printf ("Loading boot code from %s\n", filename);
if (sim_log)
fprintf (sim_log, "Loading boot code from %s\n", filename);
if (rom) if (rom)
sprintf (args, "-R %s", filename); sprintf (args, "-R %s", filename);
else else
@ -3527,14 +3525,10 @@ if (r != SCPE_OK) {
FILE *f; FILE *f;
if ((f = sim_fopen (filename, "wb"))) { if ((f = sim_fopen (filename, "wb"))) {
printf ("Saving boot code to %s\n", filename); sim_printf ("Saving boot code to %s\n", filename);
if (sim_log)
fprintf (sim_log, "Saving boot code to %s\n", filename);
sim_fwrite ((void *)builtin_code, 1, size, f); sim_fwrite ((void *)builtin_code, 1, size, f);
fclose (f); fclose (f);
printf ("Loading boot code from %s\n", filename); sim_printf ("Loading boot code from %s\n", filename);
if (sim_log)
fprintf (sim_log, "Loading boot code from %s\n", filename);
r = load_cmd (0, args); r = load_cmd (0, args);
} }
} }

View file

@ -354,7 +354,7 @@ if (lk_rbuf[0] & 1) { /* peripheral command */
break; break;
default: default:
printf ("lk: unknown cmd %02X\n", lk_rbuf[0]); sim_printf ("lk: unknown cmd %02X\n", lk_rbuf[0]);
break; break;
} }
} }

View file

@ -197,6 +197,10 @@
RelativePath="..\AltairZ80\altairz80_hdsk.c" RelativePath="..\AltairZ80\altairz80_hdsk.c"
> >
</File> </File>
<File
RelativePath="..\AltairZ80\altairz80_mhdsk.c"
>
</File>
<File <File
RelativePath="..\AltairZ80\altairz80_net.c" RelativePath="..\AltairZ80\altairz80_net.c"
> >

View file

@ -330,7 +330,7 @@ ALTAIRZ80_SOURCE2 = $(ALTAIRZ80_DIR)S100_DISK1A.C,$(ALTAIRZ80_DIR)S100_DISK2.C,\
$(ALTAIRZ80_DIR)S100_SCP300F.C,$(ALTAIRZ80_DIR)SIM_IMD.C,\ $(ALTAIRZ80_DIR)S100_SCP300F.C,$(ALTAIRZ80_DIR)SIM_IMD.C,\
$(ALTAIRZ80_DIR)WD179X.C,$(ALTAIRZ80_DIR)S100_DISK3.C,\ $(ALTAIRZ80_DIR)WD179X.C,$(ALTAIRZ80_DIR)S100_DISK3.C,\
$(ALTAIRZ80_DIR)S100_ADCS6.C,$(ALTAIRZ80_DIR)S100_HDC1001.C,\ $(ALTAIRZ80_DIR)S100_ADCS6.C,$(ALTAIRZ80_DIR)S100_HDC1001.C,\
$(ALTAIRZ80_DIR)S100_IF3.C $(ALTAIRZ80_DIR)S100_IF3.C,$(ALTAIRZ80_DIR)ALTAIRZ80_MHDSK.C
ALTAIRZ80_OPTIONS = /INCL=($(SIMH_DIR),$(ALTAIRZ80_DIR))/DEF=($(CC_DEFS)) ALTAIRZ80_OPTIONS = /INCL=($(SIMH_DIR),$(ALTAIRZ80_DIR))/DEF=($(CC_DEFS))
# #

View file

@ -1224,7 +1224,7 @@ point3(int i, int32 x1, int32 y1, int32 z1, int detect_edge)
edge_indic &= !ONSCREEN(x1, y1); /* second test */ edge_indic &= !ONSCREEN(x1, y1); /* second test */
edge_flag &= ONSCREEN(x1, y1); /* second test */ edge_flag &= ONSCREEN(x1, y1); /* second test */
edge_flag |= edge_indic; edge_flag |= edge_indic;
if (edge_flag) if (edge_flag) {
if (edge_intr_ena) { if (edge_intr_ena) {
edge_xpos = x1; edge_xpos = x1;
edge_ypos = y1; edge_ypos = y1;
@ -1236,12 +1236,14 @@ point3(int i, int32 x1, int32 y1, int32 z1, int detect_edge)
} else } else
edge_flag = 0; edge_flag = 0;
} }
if (i && ONSCREEN(x1, y1)) }
if (i && ONSCREEN(x1, y1)) {
if (menu) if (menu)
illum3(x1 + MENU_OFFSET, y1, z1); illum3(x1 + MENU_OFFSET, y1, z1);
else else
illum3(x1, y1, z1); illum3(x1, y1, z1);
} }
}
#define point2(i,x,y,e) point3(i, x, y, zpos, e) #define point2(i,x,y,e) point3(i, x, y, zpos, e)
/* the extra overhead if not depth cueing is not much */ /* the extra overhead if not depth cueing is not much */
@ -1262,7 +1264,7 @@ lpoint(int32 x, int32 y, int32 z)
{ {
int i, on = (line_type == SOLID) || stroking; /* on for sure */ int i, on = (line_type == SOLID) || stroking; /* on for sure */
if (!on) /* see if in visible portion of cycle */ if (!on) { /* see if in visible portion of cycle */
for (i = 0; i < reduce; ++i) { for (i = 0; i < reduce; ++i) {
switch (line_type) { switch (line_type) {
case LONG_DASH: case LONG_DASH:
@ -1279,10 +1281,13 @@ lpoint(int32 x, int32 y, int32 z)
&& !(line_counter & LC3)) || !(line_counter & LC4)) && !(line_counter & LC3)) || !(line_counter & LC4))
on = 1; on = 1;
break; break;
case SOLID:
break;
} }
--line_counter; --line_counter;
} }
}
if (on) if (on)
/* convert back from actual screen pixels to emulated CRT coordinates */ /* convert back from actual screen pixels to emulated CRT coordinates */
@ -1586,11 +1591,12 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
else if ( x1 < 0 ) else if ( x1 < 0 )
code1 |= 8; code1 |= 8;
if (code0 == code1) /* endpoints lie in same region */ if (code0 == code1) { /* endpoints lie in same region */
if (code0 == 0) /* ON to ON; trivially visible */ if (code0 == 0) /* ON to ON; trivially visible */
return -1; return -1;
else /* OFF to OFF and trivially invisible */ else /* OFF to OFF and trivially invisible */
return 0; return 0;
}
/* Endpoints are now known to lie in different regions. */ /* Endpoints are now known to lie in different regions. */
@ -1725,21 +1731,23 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
*/ */
if (rdx < 0) { if (rdx < 0) {
if (x0 <= 0 && x0 >= rdx) if (x0 <= 0 && x0 >= rdx) {
if (tPEd > 0) { if (tPEd > 0) {
if (x0 * (long)tPEd < (long)tPEn * rdx) if (x0 * (long)tPEd < (long)tPEn * rdx)
tPEn = x0, tPEd = rdx; tPEn = x0, tPEd = rdx;
} else /* tPEd < 0 */ } else /* tPEd < 0 */
if (x0 * (long)tPEd > (long)tPEn * rdx) if (x0 * (long)tPEd > (long)tPEn * rdx)
tPEn = x0, tPEd = rdx; tPEn = x0, tPEd = rdx;
}
} else /* rdx > 0 */ } else /* rdx > 0 */
if (x0 >= 0 && x0 <= rdx) if (x0 >= 0 && x0 <= rdx) {
if (tPLd > 0) { if (tPLd > 0) {
if (x0 * (long)tPLd < (long)tPLn * rdx) if (x0 * (long)tPLd < (long)tPLn * rdx)
tPLn = x0, tPLd = rdx; tPLn = x0, tPLd = rdx;
} else /* tPLd < 0 */ } else /* tPLd < 0 */
if (x0 * (long)tPLd > (long)tPLn * rdx) if (x0 * (long)tPLd > (long)tPLn * rdx)
tPLn = x0, tPLd = rdx; tPLn = x0, tPLd = rdx;
}
/* /*
* Right: tR = NR . (PR - P0) / NR . (P1 - P0) * Right: tR = NR . (PR - P0) / NR . (P1 - P0)
@ -1775,21 +1783,23 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
tn = x0 - CLIPXMAX; tn = x0 - CLIPXMAX;
if (rdx < 0) { if (rdx < 0) {
if (tn <= 0 && tn >= rdx) if (tn <= 0 && tn >= rdx) {
if (tPLd > 0) { if (tPLd > 0) {
if (tn * (long)tPLd > (long)tPLn * rdx) if (tn * (long)tPLd > (long)tPLn * rdx)
tPLn = tn, tPLd = rdx; tPLn = tn, tPLd = rdx;
} else /* tPLd < 0 */ } else /* tPLd < 0 */
if (tn * (long)tPLd < (long)tPLn * rdx) if (tn * (long)tPLd < (long)tPLn * rdx)
tPLn = tn, tPLd = rdx; tPLn = tn, tPLd = rdx;
}
} else /* rdx > 0 */ } else /* rdx > 0 */
if (tn >= 0 && tn <= rdx) if (tn >= 0 && tn <= rdx) {
if (tPEd > 0) { if (tPEd > 0) {
if (tn * (long)tPEd > (long)tPEn * rdx) if (tn * (long)tPEd > (long)tPEn * rdx)
tPEn = tn, tPEd = rdx; tPEn = tn, tPEd = rdx;
} else /* tPEd < 0 */ } else /* tPEd < 0 */
if (tn * (long)tPEd < (long)tPEn * rdx) if (tn * (long)tPEd < (long)tPEn * rdx)
tPEn = tn, tPEd = rdx; tPEn = tn, tPEd = rdx;
}
/* /*
* Bottom: tB = NB . (PB - P0) / NB . (P1 - P0) * Bottom: tB = NB . (PB - P0) / NB . (P1 - P0)
@ -1823,21 +1833,23 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
*/ */
if (rdy < 0) { if (rdy < 0) {
if (y0 <= 0 && y0 >= rdy) if (y0 <= 0 && y0 >= rdy) {
if (tPEd > 0) { if (tPEd > 0) {
if (y0 * (long)tPEd < (long)tPEn * rdy) if (y0 * (long)tPEd < (long)tPEn * rdy)
tPEn = y0, tPEd = rdy; tPEn = y0, tPEd = rdy;
} else /* tPEd < 0 */ } else /* tPEd < 0 */
if (y0 * (long)tPEd > (long)tPEn * rdy) if (y0 * (long)tPEd > (long)tPEn * rdy)
tPEn = y0, tPEd = rdy; tPEn = y0, tPEd = rdy;
}
} else /* rdy > 0 */ } else /* rdy > 0 */
if (y0 >= 0 && y0 <= rdy) if (y0 >= 0 && y0 <= rdy) {
if (tPLd > 0) { if (tPLd > 0) {
if (y0 * (long)tPLd < (long)tPLn * rdy) if (y0 * (long)tPLd < (long)tPLn * rdy)
tPLn = y0, tPLd = rdy; tPLn = y0, tPLd = rdy;
} else /* tPLd < 0 */ } else /* tPLd < 0 */
if (y0 * (long)tPLd > (long)tPLn * rdy) if (y0 * (long)tPLd > (long)tPLn * rdy)
tPLn = y0, tPLd = rdy; tPLn = y0, tPLd = rdy;
}
/* /*
* Top: tT = NT . (PT - P0) / NT . (P1 - P0) * Top: tT = NT . (PT - P0) / NT . (P1 - P0)
@ -1873,15 +1885,16 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
tn = y0 - CLIPYMAX; tn = y0 - CLIPYMAX;
if (rdy < 0) { if (rdy < 0) {
if (tn <= 0 && tn >= rdy) if (tn <= 0 && tn >= rdy) {
if (tPLd > 0) { if (tPLd > 0) {
if (tn * (long)tPLd > (long)tPLn * rdy) if (tn * (long)tPLd > (long)tPLn * rdy)
tPLn = tn, tPLd = rdy; tPLn = tn, tPLd = rdy;
} else /* tPLd < 0 */ } else /* tPLd < 0 */
if (tn * (long)tPLd < (long)tPLn * rdy) if (tn * (long)tPLd < (long)tPLn * rdy)
tPLn = tn, tPLd = rdy; tPLn = tn, tPLd = rdy;
}
} else /* rdy > 0 */ } else /* rdy > 0 */
if (tn >= 0 && tn <= rdy) if (tn >= 0 && tn <= rdy) {
if (tPEd > 0) { if (tPEd > 0) {
if (tn * (long)tPEd > (long)tPEn * rdy) if (tn * (long)tPEd > (long)tPEn * rdy)
tPEn = tn, tPEd = rdy; tPEn = tn, tPEd = rdy;
@ -1889,6 +1902,7 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
if (tn * (long)tPEd < (long)tPEn * rdy) if (tn * (long)tPEd < (long)tPEn * rdy)
tPEn = tn, tPEd = rdy; tPEn = tn, tPEd = rdy;
}
/* /*
* if ( tPL < tPE ) * if ( tPL < tPE )
* invisible * invisible
@ -1901,7 +1915,7 @@ clip3(int32 x0, int32 y0, int32 z0, int32 x1, int32 y1, int32 z1)
* invis * invis
*/ */
if (tPLd > 0 && tPEd < 0 || tPLd < 0 && tPEd > 0) { if (((tPLd > 0) && (tPEd < 0)) || ((tPLd < 0) && (tPEd > 0))) {
if (tPLn * (long)tPEd > (long)tPEn * tPLd) if (tPLn * (long)tPEd > (long)tPEn * tPLd)
return 0; /* invisible */ return 0; /* invisible */
} else } else
@ -1979,11 +1993,12 @@ vector3(int i, int32 dx, int32 dy, int32 dz) /* unscaled display-file units */
i, (long)x0,(long)y0, (long)x1,(long)y1)); i, (long)x0,(long)y0, (long)x1,(long)y1));
if (dx == 0 && dy == 0) { /* just display a point */ if (dx == 0 && dy == 0) { /* just display a point */
if (i) if (i) {
if (menu) if (menu)
illum3(x0 + MENU_OFFSET, y0, z0); illum3(x0 + MENU_OFFSET, y0, z0);
else else
illum3(x0, y0, z0); /* illum3() checks ONCRT, int0_scope */ illum3(x0, y0, z0); /* illum3() checks ONCRT, int0_scope */
}
return; return;
} }
} else { } else {
@ -2078,11 +2093,12 @@ vector3(int i, int32 dx, int32 dy, int32 dz) /* unscaled display-file units */
/* draw OK even when Maintenance Switch 3 is set */ /* draw OK even when Maintenance Switch 3 is set */
/* (but updated position registers must not be used to draw vector) */ /* (but updated position registers must not be used to draw vector) */
if (i && int0_scope && !clip_vect) /* clipped vector drawn by vt_cycle() */ if (i && int0_scope && !clip_vect) {/* clipped vector drawn by vt_cycle() */
if (menu) if (menu)
lineTwoStep(x0 + MENU_OFFSET, y0, z0, x1 + MENU_OFFSET, y1, z1); lineTwoStep(x0 + MENU_OFFSET, y0, z0, x1 + MENU_OFFSET, y1, z1);
else else
lineTwoStep(x0, y0, z0, x1, y1, z1); lineTwoStep(x0, y0, z0, x1, y1, z1);
}
/* /*
* In case of LP hit, recompute coords using "tangent register", because: * In case of LP hit, recompute coords using "tangent register", because:
@ -2244,7 +2260,7 @@ conic3(int i, int32 dcx, int32 dcy, int32 dcz, int32 dex, int32 dey, int32 dez)
one = ONSCREEN(xe, ye); one = ONSCREEN(xe, ye);
edge_indic = ons && !one; edge_indic = ons && !one;
edge_flag = edge_indic || (!ons && one); edge_flag = edge_indic || (!ons && one);
if (edge_flag) if (edge_flag) {
if (edge_intr_ena) { /* need to clip to viewport */ if (edge_intr_ena) { /* need to clip to viewport */
/* XXX edge positions aren't right; need proper clipping */ /* XXX edge positions aren't right; need proper clipping */
edge_xpos = xe; edge_xpos = xe;
@ -2254,6 +2270,7 @@ conic3(int i, int32 dcx, int32 dcy, int32 dcz, int32 dex, int32 dey, int32 dez)
goto done; goto done;
} else } else
edge_flag = 0; edge_flag = 0;
}
/* XXX for now, resort to scissoring: /* XXX for now, resort to scissoring:
illuminates only pixels that lie in the visible display area */ illuminates only pixels that lie in the visible display area */
@ -2812,15 +2829,16 @@ character(int c)
edge_indic = ONSCREEN(xbase, ybase) && !ONSCREEN(xnext, ynext); edge_indic = ONSCREEN(xbase, ybase) && !ONSCREEN(xnext, ynext);
edge_flag = edge_indic || edge_flag = edge_indic ||
!ONSCREEN(xbase, ybase) && ONSCREEN(xnext, ynext); ((!ONSCREEN(xbase, ybase)) && ONSCREEN(xnext, ynext));
/* (scaling cannot make spacing so large that it crosses the /* (scaling cannot make spacing so large that it crosses the
"working surface" while going from offscreen to offscreen) */ "working surface" while going from offscreen to offscreen) */
if (edge_flag) if (edge_flag) {
if (edge_intr_ena) { if (edge_intr_ena) {
edge_irq = 1; edge_irq = 1;
goto space; goto space;
} else } else
edge_flag = 0; edge_flag = 0;
}
if (!ONSCREEN(xbase, ybase) || !ONSCREEN(xnext, ynext)) if (!ONSCREEN(xbase, ybase) || !ONSCREEN(xnext, ynext))
goto space; goto space;
@ -3023,13 +3041,14 @@ vt11_cycle(int us, int slowdown)
(long)clip_x1, (long)clip_y1, (long)clip_z1)); (long)clip_x1, (long)clip_y1, (long)clip_z1));
if (VS60 /* XXX assuming VT11 doesn't display */ if (VS60 /* XXX assuming VT11 doesn't display */
&& (dx != 0 || dy != 0 || dz != 0) /* hardware skips null vects */ && (dx != 0 || dy != 0 || dz != 0) /* hardware skips null vects */
&& clip_i && int0_scope) /* show it */ && clip_i && int0_scope) { /* show it */
if (menu) if (menu)
lineTwoStep(clip_x0 + MENU_OFFSET, clip_y0, clip_z0, lineTwoStep(clip_x0 + MENU_OFFSET, clip_y0, clip_z0,
clip_x1 + MENU_OFFSET, clip_y1, clip_z1); clip_x1 + MENU_OFFSET, clip_y1, clip_z1);
else else
lineTwoStep(clip_x0, clip_y0, clip_z0, lineTwoStep(clip_x0, clip_y0, clip_z0,
clip_x1, clip_y1, clip_z1); clip_x1, clip_y1, clip_z1);
}
/* /*
* In case of LP hit, recompute coords using "tangent register", * In case of LP hit, recompute coords using "tangent register",
* because: * because:

View file

@ -1011,7 +1011,7 @@ ALTAIRZ80 = ${ALTAIRZ80D}/altairz80_cpu.c ${ALTAIRZ80D}/altairz80_cpu_nommu.c \
${ALTAIRZ80D}/altairz80_hdsk.c ${ALTAIRZ80D}/altairz80_net.c \ ${ALTAIRZ80D}/altairz80_hdsk.c ${ALTAIRZ80D}/altairz80_net.c \
${ALTAIRZ80D}/flashwriter2.c ${ALTAIRZ80D}/i86_decode.c \ ${ALTAIRZ80D}/flashwriter2.c ${ALTAIRZ80D}/i86_decode.c \
${ALTAIRZ80D}/i86_ops.c ${ALTAIRZ80D}/i86_prim_ops.c \ ${ALTAIRZ80D}/i86_ops.c ${ALTAIRZ80D}/i86_prim_ops.c \
${ALTAIRZ80D}/i8272.c ${ALTAIRZ80D}/insnsd.c \ ${ALTAIRZ80D}/i8272.c ${ALTAIRZ80D}/insnsd.c ${ALTAIRZ80D}/altairz80_mhdsk.c \
${ALTAIRZ80D}/mfdc.c ${ALTAIRZ80D}/n8vem.c ${ALTAIRZ80D}/vfdhd.c \ ${ALTAIRZ80D}/mfdc.c ${ALTAIRZ80D}/n8vem.c ${ALTAIRZ80D}/vfdhd.c \
${ALTAIRZ80D}/s100_disk1a.c ${ALTAIRZ80D}/s100_disk2.c ${ALTAIRZ80D}/s100_disk3.c \ ${ALTAIRZ80D}/s100_disk1a.c ${ALTAIRZ80D}/s100_disk2.c ${ALTAIRZ80D}/s100_disk3.c \
${ALTAIRZ80D}/s100_fif.c ${ALTAIRZ80D}/s100_mdriveh.c \ ${ALTAIRZ80D}/s100_fif.c ${ALTAIRZ80D}/s100_mdriveh.c \

266
scp.c
View file

@ -1717,11 +1717,8 @@ while (stat != SCPE_EXIT) { /* in case exit */
if (cmdp && (cmdp->message)) /* special message handler? */ if (cmdp && (cmdp->message)) /* special message handler? */
cmdp->message (NULL, stat); /* let it deal with display */ cmdp->message (NULL, stat); /* let it deal with display */
else else
if (stat >= SCPE_BASE) { /* error? */ if (stat >= SCPE_BASE) /* error? */
printf ("%s\n", sim_error_text (stat)); sim_printf ("%s\n", sim_error_text (stat));
if (sim_log)
fprintf (sim_log, "%s\n", sim_error_text (stat));
}
} }
if (sim_vm_post != NULL) if (sim_vm_post != NULL)
(*sim_vm_post) (TRUE); (*sim_vm_post) (TRUE);
@ -2297,6 +2294,8 @@ if ((cptr == NULL) || (strlen (cptr) == 0))
fflush(stdout); /* flush stdout */ fflush(stdout); /* flush stdout */
if (sim_log) /* flush log if enabled */ if (sim_log) /* flush log if enabled */
fflush (sim_log); fflush (sim_log);
if (sim_deb) /* flush debug if enabled */
fflush (sim_deb);
status = system (cptr); status = system (cptr);
#if defined (VMS) #if defined (VMS)
printf ("\n"); printf ("\n");
@ -3892,7 +3891,7 @@ if (dptr->flags & DEV_DEBUG) {
else { else {
fputs ("Debug=", st); fputs ("Debug=", st);
for (dep = dptr->debflags; dep->name != NULL; dep++) { for (dep = dptr->debflags; dep->name != NULL; dep++) {
if (dptr->dctrl & dep->mask) { if ((dptr->dctrl & dep->mask) == dep->mask) {
if (any) if (any)
fputc (';', st); fputc (';', st);
fputs (dep->name, st); fputs (dep->name, st);
@ -4041,7 +4040,7 @@ if ((!cptr) || (*cptr == 0))
return SCPE_2FARG; return SCPE_2FARG;
sim_trim_endspc(cptr); sim_trim_endspc(cptr);
if (chdir(cptr) != 0) { if (chdir(cptr) != 0) {
printf("Unable to change to: %s\n", cptr); sim_printf("Unable to directory change to: %s\n", cptr);
return SCPE_IOERR & SCPE_NOMESSAGE; return SCPE_IOERR & SCPE_NOMESSAGE;
} }
return SCPE_OK; return SCPE_OK;
@ -4087,57 +4086,37 @@ if ((hFind = FindFirstFileA (cptr, &File)) != INVALID_HANDLE_VALUE) {
else { else {
getcwd(DirName, PATH_MAX); getcwd(DirName, PATH_MAX);
} }
printf (" Directory of %s\n\n", DirName); sim_printf (" Directory of %s\n\n", DirName);
if (sim_log)
fprintf (sim_log, " Directory of %s\n\n", DirName);
do { do {
FileSize = (((t_int64)(File.nFileSizeHigh)) << 32) | File.nFileSizeLow; FileSize = (((t_int64)(File.nFileSizeHigh)) << 32) | File.nFileSizeLow;
sprintf (FileName, "%s%c%s", DirName, pathsep, File.cFileName); sprintf (FileName, "%s%c%s", DirName, pathsep, File.cFileName);
stat (FileName, &filestat); stat (FileName, &filestat);
local = localtime (&filestat.st_mtime); local = localtime (&filestat.st_mtime);
printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); sim_printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM");
if (sim_log)
fprintf (sim_log, "%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM");
if (filestat.st_mode & S_IFDIR) { if (filestat.st_mode & S_IFDIR) {
++DirCount; ++DirCount;
printf (" <DIR> "); sim_printf (" <DIR> ");
if (sim_log)
fprintf (sim_log, " <DIR> ");
} }
else { else {
if (filestat.st_mode & S_IFREG) { if (filestat.st_mode & S_IFREG) {
++FileCount; ++FileCount;
fprint_val (stdout, (t_value) FileSize, 10, 17, PV_RCOMMA); sim_print_val ((t_value) FileSize, 10, 17, PV_RCOMMA);
if (sim_log)
fprint_val (sim_log, (t_value) FileSize, 10, 17, PV_RCOMMA);
TotalSize += FileSize; TotalSize += FileSize;
} }
else { else {
printf ("%17s", ""); sim_printf ("%17s", "");
if (sim_log)
fprintf (sim_log, "%17s", "");
} }
} }
printf (" %s\n", File.cFileName); sim_printf (" %s\n", File.cFileName);
if (sim_log)
fprintf (sim_log, " %s\n", File.cFileName);
} while (FindNextFile (hFind, &File)); } while (FindNextFile (hFind, &File));
printf ("%16d File(s)", FileCount); sim_printf ("%16d File(s)", FileCount);
fprint_val (stdout, (t_value) TotalSize, 10, 15, PV_RCOMMA); sim_print_val ((t_value) TotalSize, 10, 15, PV_RCOMMA);
printf (" bytes\n"); sim_printf (" bytes\n");
printf ("%16d Dir(s)\n", DirCount); sim_printf ("%16d Dir(s)\n", DirCount);
if (sim_log) {
fprintf (sim_log, "%16d File(s)", FileCount);
fprint_val (sim_log, (t_value) TotalSize, 10, 15, PV_RCOMMA);
fprintf (sim_log, " bytes\n");
fprintf (sim_log, "%16d Dir(s)\n", DirCount);
}
FindClose (hFind); FindClose (hFind);
} }
else { else {
printf ("Can't list files for %s\n", cptr); sim_printf ("Can't list files for %s\n", cptr);
if (sim_log)
fprintf (sim_log, "Can't list files for %s\n", cptr);
return SCPE_ARG; return SCPE_ARG;
} }
return SCPE_OK; return SCPE_OK;
@ -4227,9 +4206,7 @@ if (dir) {
#endif #endif
MatchName = 1 + strrchr (cptr, '/'); MatchName = 1 + strrchr (cptr, '/');
printf (" Directory of %s\n\n", DirName[0] ? DirName : "/"); sim_printf (" Directory of %s\n\n", DirName[0] ? DirName : "/");
if (sim_log)
fprintf (sim_log, " Directory of %s\n\n", DirName[0] ? DirName : "/");
#if defined (HAVE_GLOB) #if defined (HAVE_GLOB)
for (i=0; i<paths.gl_pathc; i++) { for (i=0; i<paths.gl_pathc; i++) {
sprintf (FileName, "%s", paths.gl_pathv[i]); sprintf (FileName, "%s", paths.gl_pathv[i]);
@ -4243,51 +4220,33 @@ if (dir) {
#endif #endif
stat (FileName, &filestat); stat (FileName, &filestat);
local = localtime (&filestat.st_mtime); local = localtime (&filestat.st_mtime);
printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM"); sim_printf ("%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM");
if (sim_log)
fprintf (sim_log, "%02d/%02d/%04d %02d:%02d %s ", local->tm_mon+1, local->tm_mday, 1900+local->tm_year, local->tm_hour%12, local->tm_min, (local->tm_hour >= 12) ? "PM" : "AM");
if (filestat.st_mode & S_IFDIR) { if (filestat.st_mode & S_IFDIR) {
++DirCount; ++DirCount;
printf (" <DIR> "); sim_printf (" <DIR> ");
if (sim_log)
fprintf (sim_log, " <DIR> ");
} }
else { else {
if (filestat.st_mode & S_IFREG) { if (filestat.st_mode & S_IFREG) {
++FileCount; ++FileCount;
FileSize = sim_fsize_name_ex (FileName); FileSize = sim_fsize_name_ex (FileName);
fprint_val (stdout, (t_value) FileSize, 10, 17, PV_RCOMMA); sim_print_val ((t_value) FileSize, 10, 17, PV_RCOMMA);
if (sim_log)
fprint_val (sim_log, (t_value) FileSize, 10, 17, PV_RCOMMA);
TotalSize += FileSize; TotalSize += FileSize;
} }
else { else {
printf ("%17s", ""); sim_printf ("%17s", "");
if (sim_log)
fprintf (sim_log, "%17s", "");
} }
} }
c = strrchr (FileName, '/'); c = strrchr (FileName, '/');
printf (" %s\n", c ? c + 1 : FileName); sim_printf (" %s\n", c ? c + 1 : FileName);
if (sim_log)
fprintf (sim_log, " %s\n", c ? c + 1 : FileName);
} }
if (FileCount) { if (FileCount) {
printf ("%16d File(s)", FileCount); sim_printf ("%16d File(s)", FileCount);
fprint_val (stdout, (t_value) TotalSize, 10, 15, PV_RCOMMA); sim_print_val ((t_value) TotalSize, 10, 15, PV_RCOMMA);
printf (" bytes\n"); sim_printf (" bytes\n");
printf ("%16d Dir(s)\n", DirCount); sim_printf ("%16d Dir(s)\n", DirCount);
if (sim_log) {
fprintf (sim_log, "%16d File(s)", FileCount);
fprint_val (sim_log, (t_value) TotalSize, 10, 15, PV_RCOMMA);
fprintf (sim_log, " bytes\n");
fprintf (sim_log, "%16d Dir(s)\n", DirCount);
}
} }
else { else {
printf ("File Not Found\n"); sim_printf ("File Not Found\n");
if (sim_log)
fprintf (sim_log, "File Not Found\n");
} }
#if defined (HAVE_GLOB) #if defined (HAVE_GLOB)
globfree (&paths); globfree (&paths);
@ -4296,9 +4255,7 @@ if (dir) {
#endif #endif
} }
else { else {
printf ("Can't list files for %s\n", cptr); sim_printf ("Can't list files for %s\n", cptr);
if (sim_log)
fprintf (sim_log, "Can't list files for %s\n", cptr);
return SCPE_ARG; return SCPE_ARG;
} }
return SCPE_OK; return SCPE_OK;
@ -4569,9 +4526,7 @@ if (sim_switches & SWMASK ('R')) { /* read only? */
return attach_err (uptr, SCPE_OPENERR); /* yes, error */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s: unit is read only\n", sim_dname (dptr)); sim_printf ("%s: unit is read only\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "%s: unit is read only\n", sim_dname (dptr));
} }
} }
else { else {
@ -4580,9 +4535,7 @@ else {
if (uptr->fileref == NULL) /* open fail? */ if (uptr->fileref == NULL) /* open fail? */
return attach_err (uptr, SCPE_OPENERR); /* yes, error */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s: creating new file\n", sim_dname (dptr)); sim_printf ("%s: creating new file\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "%s: creating new file\n", sim_dname (dptr));
} }
} }
else { /* normal */ else { /* normal */
@ -4600,9 +4553,7 @@ else {
return attach_err (uptr, SCPE_OPENERR); /* yes, error */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s: unit is read only\n", sim_dname (dptr)); sim_printf ("%s: unit is read only\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "%s: unit is read only\n", sim_dname (dptr));
} }
} }
else { /* doesn't exist */ else { /* doesn't exist */
@ -4612,9 +4563,7 @@ else {
if (uptr->fileref == NULL) /* open fail? */ if (uptr->fileref == NULL) /* open fail? */
return attach_err (uptr, SCPE_OPENERR); /* yes, error */ return attach_err (uptr, SCPE_OPENERR); /* yes, error */
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s: creating new file\n", sim_dname (dptr)); sim_printf ("%s: creating new file\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "%s: creating new file\n", sim_dname (dptr));
} }
} }
} /* end if null */ } /* end if null */
@ -4627,9 +4576,7 @@ if (uptr->flags & UNIT_BUFABLE) { /* buffer? */
if (uptr->filebuf == NULL) /* no buffer? */ if (uptr->filebuf == NULL) /* no buffer? */
return attach_err (uptr, SCPE_MEM); /* error */ return attach_err (uptr, SCPE_MEM); /* error */
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s: buffering file in memory\n", sim_dname (dptr)); sim_printf ("%s: buffering file in memory\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "%s: buffering file in memory\n", sim_dname (dptr));
} }
uptr->hwmark = (uint32)sim_fread (uptr->filebuf, /* read file */ uptr->hwmark = (uint32)sim_fread (uptr->filebuf, /* read file */
SZ_D (dptr), cap, uptr->fileref); SZ_D (dptr), cap, uptr->fileref);
@ -4745,9 +4692,7 @@ if (uptr->flags & UNIT_BUF) {
uint32 cap = (uptr->hwmark + dptr->aincr - 1) / dptr->aincr; uint32 cap = (uptr->hwmark + dptr->aincr - 1) / dptr->aincr;
if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) { if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) {
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s: writing buffer to file\n", sim_dname (dptr)); sim_printf ("%s: writing buffer to file\n", sim_dname (dptr));
if (sim_log)
fprintf (sim_log, "%s: writing buffer to file\n", sim_dname (dptr));
} }
rewind (uptr->fileref); rewind (uptr->fileref);
sim_fwrite (uptr->filebuf, SZ_D (dptr), cap, uptr->fileref); sim_fwrite (uptr->filebuf, SZ_D (dptr), cap, uptr->fileref);
@ -5043,31 +4988,23 @@ if (strcmp (buf, save_vercur) == 0) /* version 3.5? */
else if (strcmp (buf, save_ver32) == 0) /* version 3.2? */ else if (strcmp (buf, save_ver32) == 0) /* version 3.2? */
v32 = TRUE; v32 = TRUE;
else if (strcmp (buf, save_ver30) != 0) { /* version 3.0? */ else if (strcmp (buf, save_ver30) != 0) { /* version 3.0? */
printf ("Invalid file version: %s\n", buf); sim_printf ("Invalid file version: %s\n", buf);
if (sim_log)
fprintf (sim_log, "Invalid file version: %s\n", buf);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
READ_S (buf); /* read sim name */ READ_S (buf); /* read sim name */
if (strcmp (buf, sim_name)) { /* name match? */ if (strcmp (buf, sim_name)) { /* name match? */
printf ("Wrong system type: %s\n", buf); sim_printf ("Wrong system type: %s\n", buf);
if (sim_log)
fprintf (sim_log, "Wrong system type: %s\n", buf);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
if (v35) { /* [V3.5+] options */ if (v35) { /* [V3.5+] options */
READ_S (buf); /* integer size */ READ_S (buf); /* integer size */
if (strcmp (buf, sim_si64) != 0) { if (strcmp (buf, sim_si64) != 0) {
printf ("Incompatible integer size, save file = %s\n", buf); sim_printf ("Incompatible integer size, save file = %s\n", buf);
if (sim_log)
fprintf (sim_log, "Incompatible integer size, save file = %s\n", buf);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
READ_S (buf); /* address size */ READ_S (buf); /* address size */
if (strcmp (buf, sim_sa64) != 0) { if (strcmp (buf, sim_sa64) != 0) {
printf ("Incompatible address size, save file = %s\n", buf); sim_printf ("Incompatible address size, save file = %s\n", buf);
if (sim_log)
fprintf (sim_log, "Incompatible address size, save file = %s\n", buf);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
READ_S (buf); /* Ethernet */ READ_S (buf); /* Ethernet */
@ -5084,9 +5021,7 @@ for ( ;; ) { /* device loop */
if (buf[0] == 0) /* last? */ if (buf[0] == 0) /* last? */
break; break;
if ((dptr = find_dev (buf)) == NULL) { /* locate device */ if ((dptr = find_dev (buf)) == NULL) { /* locate device */
printf ("Invalid device name: %s\n", buf); sim_printf ("Invalid device name: %s\n", buf);
if (sim_log)
fprintf (sim_log, "Invalid device name: %s\n", buf);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
READ_S (buf); /* [V3.0+] logical name */ READ_S (buf); /* [V3.0+] logical name */
@ -5106,9 +5041,7 @@ for ( ;; ) { /* device loop */
if (unitno < 0) /* end units? */ if (unitno < 0) /* end units? */
break; break;
if ((uint32) unitno >= dptr->numunits) { /* too big? */ if ((uint32) unitno >= dptr->numunits) { /* too big? */
printf ("Invalid unit number: %s%d\n", sim_dname (dptr), unitno); sim_printf ("Invalid unit number: %s%d\n", sim_dname (dptr), unitno);
if (sim_log)
fprintf (sim_log, "Invalid unit number: %s%d\n", sim_dname (dptr), unitno);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
READ_I (time); /* event time */ READ_I (time); /* event time */
@ -5157,9 +5090,7 @@ for ( ;; ) { /* device loop */
if (high > 0) { /* [V2.5+] any memory? */ if (high > 0) { /* [V2.5+] any memory? */
if (((uptr->flags & (UNIT_FIX + UNIT_ATTABLE)) != UNIT_FIX) || if (((uptr->flags & (UNIT_FIX + UNIT_ATTABLE)) != UNIT_FIX) ||
(dptr->deposit == NULL)) { (dptr->deposit == NULL)) {
printf ("Can't restore memory: %s%d\n", sim_dname (dptr), unitno); sim_printf ("Can't restore memory: %s%d\n", sim_dname (dptr), unitno);
if (sim_log)
fprintf (sim_log, "Can't restore memory: %s%d\n", sim_dname (dptr), unitno);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
if (high != old_capac) { /* size change? */ if (high != old_capac) { /* size change? */
@ -5167,10 +5098,7 @@ for ( ;; ) { /* device loop */
if ((dptr->flags & DEV_DYNM) && if ((dptr->flags & DEV_DYNM) &&
((dptr->msize == NULL) || ((dptr->msize == NULL) ||
(dptr->msize (uptr, (int32) high, NULL, NULL) != SCPE_OK))) { (dptr->msize (uptr, (int32) high, NULL, NULL) != SCPE_OK))) {
printf ("Can't change memory size: %s%d\n", sim_printf ("Can't change memory size: %s%d\n",
sim_dname (dptr), unitno);
if (sim_log)
fprintf (sim_log, "Can't change memory size: %s%d\n",
sim_dname (dptr), unitno); sim_dname (dptr), unitno);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
@ -5219,28 +5147,21 @@ for ( ;; ) { /* device loop */
break; break;
READ_I (depth); /* [V2.10+] depth */ READ_I (depth); /* [V2.10+] depth */
if ((rptr = find_reg (buf, NULL, dptr)) == NULL) { if ((rptr = find_reg (buf, NULL, dptr)) == NULL) {
printf ("Invalid register name: %s %s\n", sim_dname (dptr), buf); sim_printf ("Invalid register name: %s %s\n", sim_dname (dptr), buf);
if (sim_log)
fprintf (sim_log, "Invalid register name: %s %s\n", sim_dname (dptr), buf);
for (us = 0; us < depth; us++) { /* skip values */ for (us = 0; us < depth; us++) { /* skip values */
READ_I (val); READ_I (val);
} }
continue; continue;
} }
if (depth != rptr->depth) { /* [V2.10+] mismatch? */ if (depth != rptr->depth) { /* [V2.10+] mismatch? */
printf ("Register depth mismatch: %s %s, file = %d, sim = %d\n", sim_printf ("Register depth mismatch: %s %s, file = %d, sim = %d\n",
sim_dname (dptr), buf, depth, rptr->depth);
if (sim_log)
fprintf (sim_log, "Register depth mismatch: %s %s, file = %d, sim = %d\n",
sim_dname (dptr), buf, depth, rptr->depth); sim_dname (dptr), buf, depth, rptr->depth);
} }
mask = width_mask[rptr->width]; /* get mask */ mask = width_mask[rptr->width]; /* get mask */
for (us = 0; us < depth; us++) { /* loop thru values */ for (us = 0; us < depth; us++) { /* loop thru values */
READ_I (val); /* read value */ READ_I (val); /* read value */
if (val > mask) { /* value ok? */ if (val > mask) { /* value ok? */
printf ("Invalid register value: %s %s\n", sim_dname (dptr), buf); sim_printf ("Invalid register value: %s %s\n", sim_dname (dptr), buf);
if (sim_log)
fprintf (sim_log, "Invalid register value: %s %s\n", sim_dname (dptr), buf);
} }
else if (us < rptr->depth) /* in range? */ else if (us < rptr->depth) /* in range? */
put_rval (rptr, us, val); put_rval (rptr, us, val);
@ -5260,23 +5181,16 @@ for (j=0, r = SCPE_OK; j<attcnt; j++) {
(!stat(attnames[j], &fstat))) (!stat(attnames[j], &fstat)))
if (fstat.st_mtime > rstat.st_mtime + 30) { if (fstat.st_mtime > rstat.st_mtime + 30) {
r = SCPE_INCOMP; r = SCPE_INCOMP;
printf ("Error Attaching %s to %s - the restore state is %d seconds older than the attach file\n", sim_dname (dptr), attnames[j], (int)(fstat.st_mtime - rstat.st_mtime)); sim_printf ("Error Attaching %s to %s - the restore state is %d seconds older than the attach file\n", sim_dname (dptr), attnames[j], (int)(fstat.st_mtime - rstat.st_mtime));
printf ("restore with the -F switch to override this sanity check\n"); sim_printf ("restore with the -F switch to override this sanity check\n");
if (sim_log) {
fprintf (sim_log, "Error Attaching %s to %s - the restore state is %d seconds older than the attach file\n", sim_dname (dptr), attnames[j], (int)(fstat.st_mtime - rstat.st_mtime));
fprintf (sim_log, "restore with the -F switch to override this sanity check\n");
}
continue; continue;
} }
saved_pos = attunits[j]->pos; saved_pos = attunits[j]->pos;
sim_switches = attswitches[j]; sim_switches = attswitches[j];
r = scp_attach_unit (dptr, attunits[j], attnames[j]);/* reattach unit */ r = scp_attach_unit (dptr, attunits[j], attnames[j]);/* reattach unit */
attunits[j]->pos = saved_pos; attunits[j]->pos = saved_pos;
if (r != SCPE_OK) { if (r != SCPE_OK)
printf ("Error Attaching %s to %s\n", sim_dname (dptr), attnames[j]); sim_printf ("Error Attaching %s to %s\n", sim_dname (dptr), attnames[j]);
if (sim_log)
fprintf (sim_log, "Error Attaching %s to %s\n", sim_dname (dptr), attnames[j]);
}
} }
free (attnames[j]); free (attnames[j]);
} }
@ -5463,6 +5377,8 @@ if (unechoed_cmdline) {
fprint_stopped (stdout, r); /* print msg */ fprint_stopped (stdout, r); /* print msg */
if (sim_log) /* log if enabled */ if (sim_log) /* log if enabled */
fprint_stopped (sim_log, r); fprint_stopped (sim_log, r);
if (sim_deb) /* log if enabled */
fprint_stopped (sim_deb, r);
} }
/* Common setup for RUN or BOOT */ /* Common setup for RUN or BOOT */
@ -7074,6 +6990,25 @@ if (fputs (dbuf, stream) == EOF)
return SCPE_OK; return SCPE_OK;
} }
t_stat sim_print_val (t_value val, uint32 radix,
uint32 width, uint32 format)
{
char dbuf[MAX_WIDTH + 1];
if (width > MAX_WIDTH)
width = MAX_WIDTH;
sprint_val (dbuf, val, radix, width, format);
if (fputs (dbuf, stdout) == EOF)
return SCPE_IOERR;
if (sim_log && (sim_log != stdout))
if (fputs (dbuf, sim_log) == EOF)
return SCPE_IOERR;
if (sim_deb && (sim_deb != stdout))
if (fputs (dbuf, sim_deb) == EOF)
return SCPE_IOERR;
return SCPE_OK;
}
/* Event queue package /* Event queue package
sim_activate add entry to event queue sim_activate add entry to event queue
@ -7892,6 +7827,65 @@ if (sim_deb && (dptr->dctrl & dbits)) {
} }
} }
/* Print message to stdout, sim_log (if enabled) and sim_deb (if enabled) */
void sim_printf (const char* fmt, ...)
{
char stackbuf[STACKBUFSIZE];
int32 bufsize = sizeof(stackbuf);
char *buf = stackbuf;
int32 len;
va_list arglist;
while (1) { /* format passed string, args */
va_start (arglist, fmt);
#if defined(NO_vsnprintf)
#if defined(HAS_vsprintf_void)
/* Note, this could blow beyond the buffer, and we couldn't tell */
/* That is a limitation of the C runtime library available on this platform */
vsprintf (buf, fmt, arglist);
for (len = 0; len < bufsize-1; len++)
if (buf[len] == 0) break;
#else
len = vsprintf (buf, fmt, arglist);
#endif /* HAS_vsprintf_void */
#else /* NO_vsnprintf */
#if defined(HAS_vsnprintf_void)
vsnprintf (buf, bufsize-1, fmt, arglist);
for (len = 0; len < bufsize-1; len++)
if (buf[len] == 0) break;
#else
len = vsnprintf (buf, bufsize-1, fmt, arglist);
#endif /* HAS_vsnprintf_void */
#endif /* NO_vsnprintf */
va_end (arglist);
/* If the formatted result didn't fit into the buffer, then grow the buffer and try again */
if ((len < 0) || (len >= bufsize-1)) {
if (buf != stackbuf)
free (buf);
bufsize = bufsize * 2;
buf = (char *) malloc (bufsize);
if (buf == NULL) /* out of memory */
return;
buf[bufsize-1] = '\0';
continue;
}
break;
}
printf("%s", buf);
if (sim_log && (sim_log != stdout))
fprintf (sim_log, "%s", buf);
if (sim_deb && (sim_deb != stdout))
fprintf (sim_deb, "%s", buf);
if (buf != stackbuf)
free (buf);
}
/* Inline debugging - will print debug message if debug file is /* Inline debugging - will print debug message if debug file is
set and the bitmask matches the current device debug options. set and the bitmask matches the current device debug options.
Extra returns are added for un*x systems, since the output Extra returns are added for un*x systems, since the output

2
scp.h
View file

@ -118,6 +118,7 @@ char *get_range (DEVICE *dptr, char *cptr, t_addr *lo, t_addr *hi,
uint32 rdx, t_addr max, char term); uint32 rdx, t_addr max, char term);
t_value strtotv (const char *cptr, char **endptr, uint32 radix); t_value strtotv (const char *cptr, char **endptr, uint32 radix);
t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt); t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
t_stat sim_print_val (t_value val, uint32 radix, uint32 width, uint32 format);
char *read_line (char *cptr, int32 size, FILE *stream); char *read_line (char *cptr, int32 size, FILE *stream);
void fprint_reg_help (FILE *st, DEVICE *dptr); void fprint_reg_help (FILE *st, DEVICE *dptr);
void fprint_set_help (FILE *st, DEVICE *dptr); void fprint_set_help (FILE *st, DEVICE *dptr);
@ -142,6 +143,7 @@ t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cpt
const char *sim_error_text (t_stat stat); const char *sim_error_text (t_stat stat);
t_stat sim_string_to_stat (char *cptr, t_stat *cond); t_stat sim_string_to_stat (char *cptr, t_stat *cond);
t_stat sim_cancel_step (void); t_stat sim_cancel_step (void);
void sim_printf (const char* fmt, ...);
void sim_debug_bits (uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs, void sim_debug_bits (uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs,
uint32 before, uint32 after, int terminate); uint32 before, uint32 after, int terminate);
#if defined (__DECC) && defined (__VMS) && (defined (__VAX) || (__DECC_VER < 60590001)) #if defined (__DECC) && defined (__VMS) && (defined (__VAX) || (__DECC_VER < 60590001))

View file

@ -444,8 +444,7 @@ t_stat sim_disk_set_async (UNIT *uptr, int latency)
{ {
#if !defined(SIM_ASYNCH_IO) #if !defined(SIM_ASYNCH_IO)
char *msg = "Disk: can't operate asynchronously\r\n"; char *msg = "Disk: can't operate asynchronously\r\n";
printf ("%s", msg); sim_printf ("%s", msg);
if (sim_log) fprintf (sim_log, "%s", msg);
return SCPE_NOFNC; return SCPE_NOFNC;
#else #else
struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx;
@ -877,17 +876,13 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
return r; return r;
} }
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); sim_printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
if (sim_log)
fprintf (sim_log, "%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
} }
capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */ capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */
vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1)); vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1));
if (!vhd) { if (!vhd) {
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf); sim_printf ("%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
if (sim_log)
fprintf (sim_log, "%s%d: can't create virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
} }
return SCPE_OPENERR; return SCPE_OPENERR;
} }
@ -904,11 +899,8 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
return SCPE_MEM; return SCPE_MEM;
} }
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) { for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
if (!sim_quiet) { if (!sim_quiet)
printf ("%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); sim_printf ("%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
if (sim_log)
fprintf (sim_log, "%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
}
sects = sectors_per_buffer; sects = sectors_per_buffer;
if (lba + sects > total_sectors) if (lba + sects > total_sectors)
sects = total_sectors - lba; sects = total_sectors - lba;
@ -925,16 +917,10 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
} }
} }
if (!sim_quiet) { if (!sim_quiet) {
if (r == SCPE_OK) { if (r == SCPE_OK)
printf ("\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); sim_printf ("\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
if (sim_log) else
fprintf (sim_log, "\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); sim_printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
}
else {
printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
if (sim_log)
fprintf (sim_log, "\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
}
} }
if ((r == SCPE_OK) && (sim_switches & SWMASK ('V'))) { if ((r == SCPE_OK) && (sim_switches & SWMASK ('V'))) {
uint8 *verify_buf = (uint8*) malloc (1024*1024); uint8 *verify_buf = (uint8*) malloc (1024*1024);
@ -946,11 +932,8 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
return SCPE_MEM; return SCPE_MEM;
} }
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) { for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
if (!sim_quiet) { if (!sim_quiet)
printf ("%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors)); sim_printf ("%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
if (sim_log)
fprintf (sim_log, "%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
}
sects = sectors_per_buffer; sects = sectors_per_buffer;
if (lba + sects > total_sectors) if (lba + sects > total_sectors)
sects = total_sectors - lba; sects = total_sectors - lba;
@ -971,11 +954,8 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
} }
} }
if (!sim_quiet) { if (!sim_quiet) {
if (r == SCPE_OK) { if (r == SCPE_OK)
printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000)); sim_printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
if (sim_log)
fprintf (sim_log, "\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
}
else { else {
t_lba i; t_lba i;
uint32 save_dctrl = dptr->dctrl; uint32 save_dctrl = dptr->dctrl;
@ -984,9 +964,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
for (i = 0; i < (1024*1024/sector_size); ++i) for (i = 0; i < (1024*1024/sector_size); ++i)
if (0 != memcmp (copy_buf+i*sector_size, verify_buf+i*sector_size, sector_size)) if (0 != memcmp (copy_buf+i*sector_size, verify_buf+i*sector_size, sector_size))
break; break;
printf ("\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i); sim_printf ("\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i);
if (sim_log)
fprintf (sim_log, "\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i);
dptr->dctrl = 0xFFFFFFFF; dptr->dctrl = 0xFFFFFFFF;
sim_deb = stdout; sim_deb = stdout;
sim_disk_data_trace (uptr, copy_buf+i*sector_size, lba+i, sector_size, "Expected", TRUE, 1); sim_disk_data_trace (uptr, copy_buf+i*sector_size, lba+i, sector_size, "Expected", TRUE, 1);
@ -1076,9 +1054,7 @@ if (sim_switches & SWMASK ('R')) { /* read only? */
return _err_return (uptr, SCPE_OPENERR); /* yes, error */ return _err_return (uptr, SCPE_OPENERR); /* yes, error */
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
if (sim_log)
fprintf (sim_log, "%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
} }
} }
else { /* normal */ else { /* normal */
@ -1092,7 +1068,7 @@ else { /* normal */
return _err_return (uptr, SCPE_OPENERR);/* yes, error */ return _err_return (uptr, SCPE_OPENERR);/* yes, error */
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */ uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
if (!sim_quiet) if (!sim_quiet)
printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units)); sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
} }
else { /* doesn't exist */ else { /* doesn't exist */
if (sim_switches & SWMASK ('E')) /* must exist? */ if (sim_switches & SWMASK ('E')) /* must exist? */
@ -1104,7 +1080,7 @@ else { /* normal */
if (uptr->fileref == NULL) /* open fail? */ if (uptr->fileref == NULL) /* open fail? */
return _err_return (uptr, SCPE_OPENERR);/* yes, error */ return _err_return (uptr, SCPE_OPENERR);/* yes, error */
if (!sim_quiet) if (!sim_quiet)
printf ("%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units)); sim_printf ("%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units));
created = TRUE; created = TRUE;
} }
} /* end if null */ } /* end if null */
@ -1162,18 +1138,11 @@ if (capac && (capac != (t_offset)-1)) {
if (dontautosize) { if (dontautosize) {
if ((capac < (((t_offset)uptr->capac)*ctx->capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1))) && (DKUF_F_STD != DK_GET_FMT (uptr))) { if ((capac < (((t_offset)uptr->capac)*ctx->capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1))) && (DKUF_F_STD != DK_GET_FMT (uptr))) {
if (!sim_quiet) { if (!sim_quiet) {
printf ("%s%d: non expandable disk %s is smaller than simulated device (", sim_dname (dptr), (int)(uptr-dptr->units), cptr); sim_printf ("%s%d: non expandable disk %s is smaller than simulated device (", sim_dname (dptr), (int)(uptr-dptr->units), cptr);
fprint_val (stdout, (t_addr)(capac/ctx->capac_factor), 10, T_ADDR_W, PV_LEFT); sim_print_val ((t_addr)(capac/ctx->capac_factor), 10, T_ADDR_W, PV_LEFT);
printf ("%s < ", (ctx->capac_factor == 2) ? "W" : ""); sim_printf ("%s < ", (ctx->capac_factor == 2) ? "W" : "");
fprint_val (stdout, uptr->capac*((dptr->flags & DEV_SECTORS) ? 512 : 1), 10, T_ADDR_W, PV_LEFT); sim_print_val (uptr->capac*((dptr->flags & DEV_SECTORS) ? 512 : 1), 10, T_ADDR_W, PV_LEFT);
printf ("%s)\n", (ctx->capac_factor == 2) ? "W" : ""); sim_printf ("%s)\n", (ctx->capac_factor == 2) ? "W" : "");
if (sim_log) {
fprintf (sim_log, "%s%d: non expandable disk %s is smaller than simulated device (", sim_dname (dptr), (int)(uptr-dptr->units), cptr);
fprint_val (sim_log, (t_addr)(capac/ctx->capac_factor), 10, T_ADDR_W, PV_LEFT);
fprintf (sim_log, "%s < ", (ctx->capac_factor == 2) ? "W" : "");
fprint_val (sim_log, uptr->capac*((dptr->flags & DEV_SECTORS) ? 512 : 1), 10, T_ADDR_W, PV_LEFT);
fprintf (sim_log, "%s)\n", (ctx->capac_factor == 2) ? "W" : "");
}
} }
} }
} }
@ -1461,11 +1430,11 @@ if ((namebuf = (char *) malloc (1 + strlen (uptr->filename))) == NULL) {
} }
strcpy (namebuf, uptr->filename); strcpy (namebuf, uptr->filename);
if ((c = strrchr (namebuf, '/'))) if ((c = strrchr (namebuf, '/')))
strcpy (namebuf, c+1); memcpy (namebuf, c+1, strlen(c+1)+1);
if ((c = strrchr (namebuf, '\\'))) if ((c = strrchr (namebuf, '\\')))
strcpy (namebuf, c+1); memcpy (namebuf, c+1, strlen(c+1)+1);
if ((c = strrchr (namebuf, ']'))) if ((c = strrchr (namebuf, ']')))
strcpy (namebuf, c+1); memcpy (namebuf, c+1, strlen(c+1)+1);
packid = eth_crc32(0, namebuf, strlen (namebuf)); packid = eth_crc32(0, namebuf, strlen (namebuf));
buf[0] = (uint16)packid; buf[0] = (uint16)packid;
buf[1] = (uint16)(packid >> 16) & 0x7FFF; /* Make sure MSB is clear */ buf[1] = (uint16)(packid >> 16) & 0x7FFF; /* Make sure MSB is clear */
@ -2815,7 +2784,7 @@ if ((sDynamic) &&
} }
if (!*szParentVHDPath) { if (!*szParentVHDPath) {
Return = EINVAL; /* File Corrupt */ Return = EINVAL; /* File Corrupt */
fprintf (stderr, "Error Invalid Parent VHD for Differencing VHD\n"); sim_printf ("Error Invalid Parent VHD for Differencing VHD\n");
} }
} }
} }
@ -3024,7 +2993,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
++BlocksToMerge; ++BlocksToMerge;
} }
if (!sim_quiet) if (!sim_quiet)
printf ("Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath); sim_printf ("Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath);
for (BlockNumber=NeededBlock=0; BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries); ++BlockNumber) { for (BlockNumber=NeededBlock=0; BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries); ++BlockNumber) {
uint32 BlockSectors = SectorsPerBlock; uint32 BlockSectors = SectorsPerBlock;
@ -3048,7 +3017,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
SectorsPerBlock*BlockNumber)) SectorsPerBlock*BlockNumber))
break; break;
if (!sim_quiet) if (!sim_quiet)
printf ("Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge)); sim_printf ("Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge));
hVHD->BAT[BlockNumber] = VHD_BAT_FREE_ENTRY; hVHD->BAT[BlockNumber] = VHD_BAT_FREE_ENTRY;
} }
if (BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries)) { if (BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries)) {
@ -3057,7 +3026,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
else { else {
Status = 0; Status = 0;
if (!sim_quiet) if (!sim_quiet)
printf ("Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000)); sim_printf ("Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000));
fclose (hVHD->File); fclose (hVHD->File);
hVHD->File = NULL; hVHD->File = NULL;
remove (szVHDPath); remove (szVHDPath);
@ -3373,7 +3342,7 @@ if ((szFileSpec[0] != '/') || (strchr (szFileSpec, ':')))
else else
strncpy (szFullFileSpecBuffer, szFileSpec, BufferSize); strncpy (szFullFileSpecBuffer, szFileSpec, BufferSize);
if ((c = strstr (szFullFileSpecBuffer, "]/"))) if ((c = strstr (szFullFileSpecBuffer, "]/")))
strcpy (c+1, c+2); memcpy (c+1, c+2, strlen(c+2)+1);
memset (szFullFileSpecBuffer + strlen (szFullFileSpecBuffer), 0, BufferSize - strlen (szFullFileSpecBuffer)); memset (szFullFileSpecBuffer + strlen (szFullFileSpecBuffer), 0, BufferSize - strlen (szFullFileSpecBuffer));
#endif #endif
} }
@ -3386,6 +3355,8 @@ HostPathToVhdPath (const char *szHostPath,
char *c, *d; char *c, *d;
strncpy (szVhdPath, szHostPath, VhdPathSize-1); strncpy (szVhdPath, szHostPath, VhdPathSize-1);
if ((szVhdPath[1] == ':') && islower(szVhdPath[0]))
szVhdPath[0] = toupper(szVhdPath[0]);
szVhdPath[VhdPathSize-1] = '\0'; szVhdPath[VhdPathSize-1] = '\0';
if ((c = strrchr (szVhdPath, ']'))) { if ((c = strrchr (szVhdPath, ']'))) {
*c = '\0'; *c = '\0';
@ -3399,14 +3370,14 @@ if ((c = strrchr (szVhdPath, ']'))) {
while ((c = strchr (szVhdPath, '/'))) while ((c = strchr (szVhdPath, '/')))
*c = '\\'; *c = '\\';
for (c = strstr (szVhdPath, "\\.\\"); c; c = strstr (szVhdPath, "\\.\\")) for (c = strstr (szVhdPath, "\\.\\"); c; c = strstr (szVhdPath, "\\.\\"))
strcpy (c, c+2); memcpy (c, c+2, strlen(c+2)+1);
for (c = strstr (szVhdPath, "\\\\"); c; c = strstr (szVhdPath, "\\\\")) for (c = strstr (szVhdPath, "\\\\"); c; c = strstr (szVhdPath, "\\\\"))
strcpy (c, c+1); memcpy (c, c+1, strlen(c+1)+1);
while ((c = strstr (szVhdPath, "\\..\\"))) { while ((c = strstr (szVhdPath, "\\..\\"))) {
*c = '\0'; *c = '\0';
d = strrchr (szVhdPath, '\\'); d = strrchr (szVhdPath, '\\');
if (d) if (d)
strcpy (d, c+3); memcpy (d, c+3, strlen(c+3)+1);
else else
return d; return d;
} }
@ -3460,6 +3431,7 @@ char *FullParentVHDPath = NULL;
char *RelativeParentVHDPathUnicode = NULL; char *RelativeParentVHDPathUnicode = NULL;
char *FullParentVHDPathUnicode = NULL; char *FullParentVHDPathUnicode = NULL;
char *FullVHDPath = NULL; char *FullVHDPath = NULL;
char *TempPath = NULL;
size_t i, RelativeMatch, UpDirectories, LocatorsWritten = 0; size_t i, RelativeMatch, UpDirectories, LocatorsWritten = 0;
int64 LocatorPosition; int64 LocatorPosition;
@ -3486,14 +3458,15 @@ FullParentVHDPath = (char*) calloc (1, BytesPerSector+2);
RelativeParentVHDPathUnicode = (char*) calloc (1, BytesPerSector+2); RelativeParentVHDPathUnicode = (char*) calloc (1, BytesPerSector+2);
FullParentVHDPathUnicode = (char*) calloc (1, BytesPerSector+2); FullParentVHDPathUnicode = (char*) calloc (1, BytesPerSector+2);
FullVHDPath = (char*) calloc (1, BytesPerSector+2); FullVHDPath = (char*) calloc (1, BytesPerSector+2);
ExpandToFullPath (szParentVHDPath, FullParentVHDPath, BytesPerSector); TempPath = (char*) calloc (1, BytesPerSector+2);
HostPathToVhdPath (FullParentVHDPath, FullParentVHDPath, BytesPerSector); ExpandToFullPath (szParentVHDPath, TempPath, BytesPerSector);
HostPathToVhdPath (TempPath, FullParentVHDPath, BytesPerSector);
for (i=0; i < strlen (FullParentVHDPath); i++) for (i=0; i < strlen (FullParentVHDPath); i++)
hVHD->Dynamic.ParentUnicodeName[i*2+1] = FullParentVHDPath[i]; /* Big Endian Unicode */ hVHD->Dynamic.ParentUnicodeName[i*2+1] = FullParentVHDPath[i]; /* Big Endian Unicode */
for (i=0; i < strlen (FullParentVHDPath); i++) for (i=0; i < strlen (FullParentVHDPath); i++)
FullParentVHDPathUnicode[i*2] = FullParentVHDPath[i]; /* Little Endian Unicode */ FullParentVHDPathUnicode[i*2] = FullParentVHDPath[i]; /* Little Endian Unicode */
ExpandToFullPath (szVHDPath, FullVHDPath, BytesPerSector); ExpandToFullPath (szVHDPath, TempPath, BytesPerSector);
HostPathToVhdPath (FullVHDPath, FullVHDPath, BytesPerSector); HostPathToVhdPath (TempPath, FullVHDPath, BytesPerSector);
for (i=0, RelativeMatch=UpDirectories=0; i<strlen(FullVHDPath); i++) for (i=0, RelativeMatch=UpDirectories=0; i<strlen(FullVHDPath); i++)
if (FullVHDPath[i] == '\\') { if (FullVHDPath[i] == '\\') {
if (memcmp (FullVHDPath, FullParentVHDPath, i+1)) if (memcmp (FullVHDPath, FullParentVHDPath, i+1))
@ -3532,6 +3505,7 @@ if (RelativeMatch) {
++LocatorsWritten; ++LocatorsWritten;
} }
hVHD->Dynamic.TableOffset = NtoHll (((LocatorPosition+LocatorsWritten*BytesPerSector + VHD_DATA_BLOCK_ALIGNMENT - 1)/VHD_DATA_BLOCK_ALIGNMENT)*VHD_DATA_BLOCK_ALIGNMENT); hVHD->Dynamic.TableOffset = NtoHll (((LocatorPosition+LocatorsWritten*BytesPerSector + VHD_DATA_BLOCK_ALIGNMENT - 1)/VHD_DATA_BLOCK_ALIGNMENT)*VHD_DATA_BLOCK_ALIGNMENT);
hVHD->Dynamic.Checksum = 0;
hVHD->Dynamic.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Dynamic, sizeof(hVHD->Dynamic))); hVHD->Dynamic.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Dynamic, sizeof(hVHD->Dynamic)));
hVHD->Footer.Checksum = 0; hVHD->Footer.Checksum = 0;
hVHD->Footer.DiskType = NtoHl (VHD_DT_Differencing); hVHD->Footer.DiskType = NtoHl (VHD_DT_Differencing);
@ -3595,6 +3569,7 @@ free (FullParentVHDPath);
free (RelativeParentVHDPathUnicode); free (RelativeParentVHDPathUnicode);
free (FullParentVHDPathUnicode); free (FullParentVHDPathUnicode);
free (FullVHDPath); free (FullVHDPath);
free (TempPath);
sim_vhd_disk_close ((FILE *)hVHD); sim_vhd_disk_close ((FILE *)hVHD);
hVHD = NULL; hVHD = NULL;
if (Status) { if (Status) {

View file

@ -735,8 +735,7 @@ t_stat ethq_init(ETH_QUE* que, int max)
if (!que->item) { if (!que->item) {
/* failed to allocate memory */ /* failed to allocate memory */
char* msg = "EthQ: failed to allocate dynamic queue[%d]\r\n"; char* msg = "EthQ: failed to allocate dynamic queue[%d]\r\n";
printf(msg, max); sim_printf(msg, max);
if (sim_log) fprintf(sim_log, msg, max);
return SCPE_MEM; return SCPE_MEM;
}; };
que->max = max; que->max = max;
@ -1005,8 +1004,7 @@ static void load_function(char* function, _func* func_ptr) {
if (*func_ptr == 0) { if (*func_ptr == 0) {
char* msg = "Eth: Failed to find function '%s' in %s\r\n"; char* msg = "Eth: Failed to find function '%s' in %s\r\n";
printf (msg, function, lib_name); sim_printf (msg, function, lib_name);
if (sim_log) fprintf (sim_log, msg, function, lib_name);
lib_loaded = 3; lib_loaded = 3;
} }
} }
@ -1031,12 +1029,8 @@ int load_pcap(void) {
"Eth: You must install libpcap to use networking\r\n"; "Eth: You must install libpcap to use networking\r\n";
#endif #endif
printf (msg, lib_name); sim_printf (msg, lib_name);
printf ("%s", msg2); sim_printf ("%s", msg2);
if (sim_log) {
fprintf (sim_log, msg, lib_name);
fprintf (sim_log, "%s", msg2);
}
lib_loaded = 2; lib_loaded = 2;
break; break;
} else { } else {
@ -1071,10 +1065,7 @@ int load_pcap(void) {
if (lib_loaded == 1) { if (lib_loaded == 1) {
/* log successful load */ /* log successful load */
char* version = p_pcap_lib_version(); sim_printf("%s\n", p_pcap_lib_version());
printf("%s\n", version);
if (sim_log)
fprintf(sim_log, "%s\n", version);
} }
break; break;
default: /* loaded or failed */ default: /* loaded or failed */
@ -1693,8 +1684,7 @@ t_stat eth_set_async (ETH_DEV *dev, int latency)
{ {
#if !defined(USE_READER_THREAD) || !defined(SIM_ASYNCH_IO) #if !defined(USE_READER_THREAD) || !defined(SIM_ASYNCH_IO)
char *msg = "Eth: can't operate asynchronously, must poll\r\n"; char *msg = "Eth: can't operate asynchronously, must poll\r\n";
printf ("%s", msg); sim_printf ("%s", msg);
if (sim_log) fprintf (sim_log, "%s", msg);
return SCPE_NOFNC; return SCPE_NOFNC;
#else #else
int wakeup_needed; int wakeup_needed;
@ -1772,8 +1762,7 @@ if (0 == strncmp("tap:", savname, 4)) {
#if defined(HAVE_TAP_NETWORK) #if defined(HAVE_TAP_NETWORK)
if (!strcmp(savname, "tap:tapN")) { if (!strcmp(savname, "tap:tapN")) {
msg = "Eth: Must specify actual tap device name (i.e. tap:tap0)\r\n"; msg = "Eth: Must specify actual tap device name (i.e. tap:tap0)\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
return SCPE_OPENERR; return SCPE_OPENERR;
} }
#endif #endif
@ -1858,8 +1847,7 @@ else
memset(&voa, 0, sizeof(voa)); memset(&voa, 0, sizeof(voa));
if (!strcmp(savname, "vde:vdedevice")) { if (!strcmp(savname, "vde:vdedevice")) {
msg = "Eth: Must specify actual vde device name (i.e. vde:/tmp/switch)\r\n"; msg = "Eth: Must specify actual vde device name (i.e. vde:/tmp/switch)\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
return SCPE_OPENERR; return SCPE_OPENERR;
} }
if (!(dev->handle = (void*) vde_open(savname+4, "simh", &voa))) if (!(dev->handle = (void*) vde_open(savname+4, "simh", &voa)))
@ -1879,8 +1867,7 @@ else
if (!strcmp(savname, "udp:sourceport:remotehost:remoteport")) { if (!strcmp(savname, "udp:sourceport:remotehost:remoteport")) {
msg = "Eth: Must specify actual udp host and ports(i.e. udp:1224:somehost.com:2234)\r\n"; msg = "Eth: Must specify actual udp host and ports(i.e. udp:1224:somehost.com:2234)\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
return SCPE_OPENERR; return SCPE_OPENERR;
} }
@ -1893,8 +1880,7 @@ else
if ((SCPE_OK == sim_parse_addr (hostport, NULL, 0, NULL, NULL, 0, NULL, "localhost")) && if ((SCPE_OK == sim_parse_addr (hostport, NULL, 0, NULL, NULL, 0, NULL, "localhost")) &&
(0 == strcmp (localport, port))) { (0 == strcmp (localport, port))) {
msg = "Eth: Must specify different udp localhost ports\r\n"; msg = "Eth: Must specify different udp localhost ports\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
return SCPE_OPENERR; return SCPE_OPENERR;
} }
dev->fd_handle = sim_connect_sock_ex (localport, hostport, NULL, NULL, TRUE, FALSE); dev->fd_handle = sim_connect_sock_ex (localport, hostport, NULL, NULL, TRUE, FALSE);
@ -1908,8 +1894,7 @@ else
dev->handle = (void*) pcap_open_live(savname, bufsz, ETH_PROMISC, PCAP_READ_TIMEOUT, errbuf); dev->handle = (void*) pcap_open_live(savname, bufsz, ETH_PROMISC, PCAP_READ_TIMEOUT, errbuf);
if (!dev->handle) { /* can't open device */ if (!dev->handle) { /* can't open device */
msg = "Eth: pcap_open_live error - %s\r\n"; msg = "Eth: pcap_open_live error - %s\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
return SCPE_OPENERR; return SCPE_OPENERR;
} }
dev->eth_api = ETH_API_PCAP; dev->eth_api = ETH_API_PCAP;
@ -1920,13 +1905,11 @@ else
} }
if (errbuf[0]) { if (errbuf[0]) {
msg = "Eth: open error - %s\r\n"; msg = "Eth: open error - %s\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
return SCPE_OPENERR; return SCPE_OPENERR;
} }
msg = "Eth: opened OS device %s\r\n"; msg = "Eth: opened OS device %s\r\n";
printf (msg, savname); sim_printf (msg, savname);
if (sim_log) fprintf (sim_log, msg, savname);
/* get the NIC's hardware MAC address */ /* get the NIC's hardware MAC address */
eth_get_nic_hw_addr(dev, savname); eth_get_nic_hw_addr(dev, savname);
@ -1982,8 +1965,7 @@ if (1) {
/* set ethernet device non-blocking so pcap_dispatch() doesn't hang */ /* set ethernet device non-blocking so pcap_dispatch() doesn't hang */
if ((dev->eth_api == ETH_API_PCAP) && (pcap_setnonblock (dev->handle, 1, errbuf) == -1)) { if ((dev->eth_api == ETH_API_PCAP) && (pcap_setnonblock (dev->handle, 1, errbuf) == -1)) {
msg = "Eth: Failed to set non-blocking: %s\r\n"; msg = "Eth: Failed to set non-blocking: %s\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
} }
#endif #endif
#endif /* !defined (USE_READER_THREAD */ #endif /* !defined (USE_READER_THREAD */
@ -2065,8 +2047,7 @@ switch (dev->eth_api) {
break; break;
#endif #endif
} }
printf (msg, dev->name); sim_printf (msg, dev->name);
if (sim_log) fprintf (sim_log, msg, dev->name);
/* clean up the mess */ /* clean up the mess */
free(dev->name); free(dev->name);
@ -2183,8 +2164,7 @@ if (status != SCPE_OK) {
"which is at least 0.9 from your OS vendor or www.tcpdump.org\r\n" : "which is at least 0.9 from your OS vendor or www.tcpdump.org\r\n" :
"Eth: Error Transmitting packet: %s\r\n" "Eth: Error Transmitting packet: %s\r\n"
"You may need to run as root.\r\n"; "You may need to run as root.\r\n";
printf(msg, strerror(errno)); sim_printf(msg, strerror(errno));
if (sim_log) fprintf (sim_log, msg, strerror(errno));
return status; return status;
} }
@ -3216,22 +3196,17 @@ if (dev->eth_api == ETH_API_PCAP) {
if ((status = pcap_compile(dev->handle, &bpf, buf, 1, bpf_netmask)) < 0) { if ((status = pcap_compile(dev->handle, &bpf, buf, 1, bpf_netmask)) < 0) {
sprintf(errbuf, "%s", pcap_geterr(dev->handle)); sprintf(errbuf, "%s", pcap_geterr(dev->handle));
msg = "Eth: pcap_compile error: %s\r\n"; msg = "Eth: pcap_compile error: %s\r\n";
printf(msg, errbuf); sim_printf(msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
sim_debug(dev->dbit, dev->dptr, "Eth: pcap_compile error: %s\n", errbuf);
/* show erroneous BPF string */ /* show erroneous BPF string */
msg = "Eth: BPF string is: |%s|\r\n"; msg = "Eth: BPF string is: |%s|\r\n";
printf (msg, buf); sim_printf (msg, buf);
if (sim_log) fprintf (sim_log, msg, buf);
} }
else { else {
/* apply compiled filter string */ /* apply compiled filter string */
if ((status = pcap_setfilter(dev->handle, &bpf)) < 0) { if ((status = pcap_setfilter(dev->handle, &bpf)) < 0) {
sprintf(errbuf, "%s", pcap_geterr(dev->handle)); sprintf(errbuf, "%s", pcap_geterr(dev->handle));
msg = "Eth: pcap_setfilter error: %s\r\n"; msg = "Eth: pcap_setfilter error: %s\r\n";
printf(msg, errbuf); sim_printf(msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
sim_debug(dev->dbit, dev->dptr, "Eth: pcap_setfilter error: %s\n", errbuf);
} }
else { else {
#ifdef USE_SETNONBLOCK #ifdef USE_SETNONBLOCK
@ -3382,8 +3357,7 @@ errbuf[0] = '\0';
/* retrieve the device list */ /* retrieve the device list */
if (pcap_findalldevs(&alldevs, errbuf) == -1) { if (pcap_findalldevs(&alldevs, errbuf) == -1) {
char* msg = "Eth: error in pcap_findalldevs: %s\r\n"; char* msg = "Eth: error in pcap_findalldevs: %s\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
} }
else { else {
/* copy device list into the passed structure */ /* copy device list into the passed structure */
@ -3407,8 +3381,7 @@ i = eth_host_devices(i, max, list);
/* If no devices were found and an error message was left in the buffer, display it */ /* If no devices were found and an error message was left in the buffer, display it */
if ((i == 0) && (errbuf[0])) { if ((i == 0) && (errbuf[0])) {
char* msg = "Eth: pcap_findalldevs warning: %s\r\n"; char* msg = "Eth: pcap_findalldevs warning: %s\r\n";
printf (msg, errbuf); sim_printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
} }
/* return device count */ /* return device count */

View file

@ -215,9 +215,7 @@ for (i=0; i<serial_open_device_count; ++i)
static void sim_error_serial (char *routine, int error) static void sim_error_serial (char *routine, int error)
{ {
fprintf (stderr, "Serial: %s fails with error %d\n", routine, error); sim_printf ("Serial: %s fails with error %d\n", routine, error);
if (sim_deb)
fprintf (sim_deb, "Serial: %s fails with error %d\n", routine, error);
return; return;
} }

View file

@ -162,22 +162,14 @@ int32 i;
for (i=0; (sock_errors[i].text) && (sock_errors[i].value != err); i++) for (i=0; (sock_errors[i].text) && (sock_errors[i].value != err); i++)
; ;
if (sock_errors[i].value == err) { if (sock_errors[i].value == err)
printf ("Sockets: %s error %d - %s\n", emsg, err, sock_errors[i].text); sim_printf ("Sockets: %s error %d - %s\n", emsg, err, sock_errors[i].text);
if (sim_log) else
fprintf (sim_log, "Sockets: %s error %d - %s\n", emsg, err, sock_errors[i].text);
}
else {
#if defined(_WIN32) #if defined(_WIN32)
printf ("Sockets: %s error %d\n", emsg, err); sim_printf ("Sockets: %s error %d\n", emsg, err);
if (sim_log)
fprintf (sim_log, "Sockets: %s error %d\n", emsg, err);
#else #else
printf ("Sockets: %s error %d - %s\n", emsg, err, strerror(err)); sim_printf ("Sockets: %s error %d - %s\n", emsg, err, strerror(err));
if (sim_log)
fprintf (sim_log, "Sockets: %s error %d - %s\n", emsg, err, strerror(err));
#endif #endif
}
if (s != INVALID_SOCKET) if (s != INVALID_SOCKET)
sim_close_sock (s, flg); sim_close_sock (s, flg);
return INVALID_SOCKET; return INVALID_SOCKET;
@ -461,9 +453,7 @@ static void load_function(char* function, _func* func_ptr) {
if (*func_ptr == 0) { if (*func_ptr == 0) {
char* msg = "Sockets: Failed to find function '%s' in %s\r\n"; char* msg = "Sockets: Failed to find function '%s' in %s\r\n";
printf (msg, function, lib_name); sim_printf (msg, function, lib_name);
if (sim_log)
fprintf (sim_log, msg, function, lib_name);
lib_loaded = 3; lib_loaded = 3;
} }
} }
@ -482,9 +472,7 @@ int load_ws2(void) {
/* failed to load DLL */ /* failed to load DLL */
char* msg = "Sockets: Failed to load %s\r\n"; char* msg = "Sockets: Failed to load %s\r\n";
printf (msg, lib_name); sim_printf (msg, lib_name);
if (sim_log)
fprintf (sim_log, msg, lib_name);
lib_loaded = 2; lib_loaded = 2;
break; break;
} else { } else {
@ -732,7 +720,7 @@ wVersionRequested = MAKEWORD (2, 2);
err = WSAStartup (wVersionRequested, &wsaData); /* start Winsock */ err = WSAStartup (wVersionRequested, &wsaData); /* start Winsock */
if (err != 0) if (err != 0)
printf ("Winsock: startup error %d\n", err); sim_printf ("Winsock: startup error %d\n", err);
#if defined(AF_INET6) #if defined(AF_INET6)
load_ws2 (); load_ws2 ();
#endif /* endif AF_INET6 */ #endif /* endif AF_INET6 */

View file

@ -347,8 +347,7 @@ t_stat sim_tape_set_async (UNIT *uptr, int latency)
{ {
#if !defined(SIM_ASYNCH_IO) #if !defined(SIM_ASYNCH_IO)
char *msg = "Tape: can't operate asynchronously\r\n"; char *msg = "Tape: can't operate asynchronously\r\n";
printf ("%s", msg); sim_printf ("%s", msg);
if (sim_log) fprintf (sim_log, "%s", msg);
return SCPE_NOFNC; return SCPE_NOFNC;
#else #else
struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx; struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx;

View file

@ -118,12 +118,14 @@ UNIT sim_throt_unit = { UDATA (&sim_throt_svc, 0, 0) };
#define DBG_TRC 0x004 /* tracing */ #define DBG_TRC 0x004 /* tracing */
#define DBG_CAL 0x008 /* calibration activities */ #define DBG_CAL 0x008 /* calibration activities */
#define DBG_TIM 0x010 /* timer thread activities */ #define DBG_TIM 0x010 /* timer thread activities */
#define DBG_THR 0x020 /* throttle activities */
DEBTAB sim_timer_debug[] = { DEBTAB sim_timer_debug[] = {
{"TRACE", DBG_TRC}, {"TRACE", DBG_TRC},
{"IDLE", DBG_IDL}, {"IDLE", DBG_IDL},
{"QUEUE", DBG_QUE}, {"QUEUE", DBG_QUE},
{"CALIB", DBG_CAL}, {"CALIB", DBG_CAL},
{"TIME", DBG_TIM}, {"TIME", DBG_TIM},
{"THROT", DBG_THR},
{0} {0}
}; };
@ -907,15 +909,11 @@ t_stat r;
uint32 v; uint32 v;
if (sim_idle_rate_ms == 0) { if (sim_idle_rate_ms == 0) {
printf ("Idling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); sim_printf ("Idling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms);
if (sim_log)
fprintf (sim_log, "Idling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms);
return SCPE_NOFNC; return SCPE_NOFNC;
} }
if ((val != 0) && (sim_idle_rate_ms > (uint32) val)) { if ((val != 0) && (sim_idle_rate_ms > (uint32) val)) {
printf ("Idling is not available, Minimum OS sleep time is %dms, Requied minimum OS sleep is %dms\n", sim_os_sleep_min_ms, val); sim_printf ("Idling is not available, Minimum OS sleep time is %dms, Requied minimum OS sleep is %dms\n", sim_os_sleep_min_ms, val);
if (sim_log)
fprintf (sim_log, "Idling is not available, Minimum OS sleep time is %dms, Requied minimum OS sleep is %dms\n", sim_os_sleep_min_ms, val);
return SCPE_NOFNC; return SCPE_NOFNC;
} }
if (cptr) { if (cptr) {
@ -927,9 +925,7 @@ if (cptr) {
sim_idle_enab = TRUE; sim_idle_enab = TRUE;
if (sim_throt_type != SIM_THROT_NONE) { if (sim_throt_type != SIM_THROT_NONE) {
sim_set_throt (0, NULL); sim_set_throt (0, NULL);
printf ("Throttling disabled\n"); sim_printf ("Throttling disabled\n");
if (sim_log)
fprintf (sim_log, "Throttling disabled\n");
} }
return SCPE_OK; return SCPE_OK;
} }
@ -969,9 +965,7 @@ if (arg == 0) {
sim_throt_cancel (); sim_throt_cancel ();
} }
else if (sim_idle_rate_ms == 0) { else if (sim_idle_rate_ms == 0) {
printf ("Throttling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms); sim_printf ("Throttling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms);
if (sim_log)
fprintf (sim_log, "Throttling is not available, Minimum OS sleep time is %dms\n", sim_os_sleep_min_ms);
return SCPE_NOFNC; return SCPE_NOFNC;
} }
else { else {
@ -995,9 +989,7 @@ else {
} }
else return SCPE_ARG; else return SCPE_ARG;
if (sim_idle_enab) { if (sim_idle_enab) {
printf ("Idling disabled\n"); sim_printf ("Idling disabled\n");
if (sim_log)
fprintf (sim_log, "Idling disabled\n");
sim_clr_idle (NULL, 0, NULL, NULL); sim_clr_idle (NULL, 0, NULL, NULL);
} }
sim_throt_val = (uint32) val; sim_throt_val = (uint32) val;
@ -1121,8 +1113,8 @@ switch (sim_throt_state) {
} }
sim_throt_ms_start = sim_throt_ms_stop; sim_throt_ms_start = sim_throt_ms_stop;
sim_throt_state = 2; sim_throt_state = 2;
// fprintf (stderr, "Throttle values a_cps = %f, d_cps = %f, wait = %d\n", sim_debug (DBG_THR, &sim_timer_dev, "sim_throt_svc() Throttle values a_cps = %f, d_cps = %f, wait = %d\n",
// a_cps, d_cps, sim_throt_wait); a_cps, d_cps, sim_throt_wait);
} }
break; break;

View file

@ -826,8 +826,6 @@ if (tptr == NULL) /* no more mem? */
if (mp->port) /* copy port */ if (mp->port) /* copy port */
sprintf (growstring(&tptr, 13 + strlen (mp->port)), "%s%s", mp->port, mp->notelnet ? ";notelnet" : ""); sprintf (growstring(&tptr, 13 + strlen (mp->port)), "%s%s", mp->port, mp->notelnet ? ";notelnet" : "");
if (mp->buffered)
sprintf (growstring(&tptr, 32), ",Buffered=%d", mp->buffered);
if (mp->logfiletmpl[0]) /* logfile info */ if (mp->logfiletmpl[0]) /* logfile info */
sprintf (growstring(&tptr, 7 + strlen (mp->logfiletmpl)), ",Log=%s", mp->logfiletmpl); sprintf (growstring(&tptr, 7 + strlen (mp->logfiletmpl)), ",Log=%s", mp->logfiletmpl);
while ((*tptr == ',') || (*tptr == ' ')) while ((*tptr == ',') || (*tptr == ' '))
@ -1377,12 +1375,12 @@ if ((lp->sock) || (lp->serport) || (lp->loopback)) {
else else
if ((lp->master) || (lp->mp && lp->mp->master) || if ((lp->master) || (lp->mp && lp->mp->master) ||
(lp->port && lp->destination)) (lp->port && lp->destination))
incoming_state = TMXR_MDM_DCD | TMXR_MDM_DSR; incoming_state = TMXR_MDM_DSR;
else else
incoming_state = 0; incoming_state = 0;
lp->modembits |= incoming_state; lp->modembits |= incoming_state;
dptr = (lp->dptr ? lp->dptr : (lp->mp ? lp->mp->dptr : NULL)); dptr = (lp->dptr ? lp->dptr : (lp->mp ? lp->mp->dptr : NULL));
if (sim_deb && lp->mp && dptr) { if ((lp->modembits != before_modem_bits) && (sim_deb && lp->mp && dptr)) {
sim_debug_bits (TMXR_DBG_MDM, dptr, tmxr_modem_bits, before_modem_bits, lp->modembits, FALSE); sim_debug_bits (TMXR_DBG_MDM, dptr, tmxr_modem_bits, before_modem_bits, lp->modembits, FALSE);
sim_debug (TMXR_DBG_MDM, dptr, " - Line %d - %p\n", (int)(lp-lp->mp->ldsc), lp->txb); sim_debug (TMXR_DBG_MDM, dptr, " - Line %d - %p\n", (int)(lp-lp->mp->ldsc), lp->txb);
} }
@ -2024,19 +2022,27 @@ if (lp->serport) { /* close current serial connection *
lp->destination = NULL; lp->destination = NULL;
} }
tmxr_set_line_loopback (lp, FALSE); tmxr_set_line_loopback (lp, FALSE);
if ((lp->mp->uptr) && ((lp->uptr == NULL) || (lp->uptr == lp->mp->uptr))) {
/* Revise the unit's connect string to reflect the current attachments */
lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp);
/* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */
if (lp->mp->uptr->filename == NULL)
tmxr_detach (lp->mp, lp->mp->uptr);
}
} }
t_stat tmxr_detach_ln (TMLN *lp) t_stat tmxr_detach_ln (TMLN *lp)
{ {
tmxr_debug_trace_line (lp, "tmxr_detaach_ln()"); UNIT *uptr = NULL;
tmxr_debug_trace_line (lp, "tmxr_detach_ln()");
_mux_detach_line (lp, TRUE, TRUE); _mux_detach_line (lp, TRUE, TRUE);
if (lp->mp)
if (lp->uptr)
uptr = lp->uptr;
else
if (lp->mp->uptr)
uptr = lp->mp->uptr;
if (uptr && uptr->filename) {
/* Revise the unit's connect string to reflect the current attachments */
uptr->filename = tmxr_mux_attach_string (uptr->filename, lp->mp);
/* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */
if (uptr->filename == NULL)
tmxr_detach (lp->mp, uptr);
}
return SCPE_OK; return SCPE_OK;
} }
@ -2061,7 +2067,7 @@ char tbuf[CBUFSIZE], listen[CBUFSIZE], destination[CBUFSIZE],
SOCKET sock; SOCKET sock;
SERHANDLE serport; SERHANDLE serport;
char *tptr = cptr; char *tptr = cptr;
t_bool nolog, notelnet, listennotelnet, unbuffered, modem_control, loopback, datagram, packet; t_bool nolog, notelnet, listennotelnet, modem_control, loopback, datagram, packet;
TMLN *lp; TMLN *lp;
t_stat r = SCPE_ARG; t_stat r = SCPE_ARG;
@ -2079,9 +2085,11 @@ while (*tptr) {
memset(buffered, '\0', sizeof(buffered)); memset(buffered, '\0', sizeof(buffered));
memset(port, '\0', sizeof(port)); memset(port, '\0', sizeof(port));
memset(option, '\0', sizeof(option)); memset(option, '\0', sizeof(option));
nolog = notelnet = listennotelnet = unbuffered = loopback = FALSE; nolog = notelnet = listennotelnet = loopback = FALSE;
datagram = mp->datagram; datagram = mp->datagram;
packet = mp->packet; packet = mp->packet;
if (mp->buffered)
sprintf(buffered, "%d", mp->buffered);
if (line != -1) if (line != -1)
notelnet = listennotelnet = mp->notelnet; notelnet = listennotelnet = mp->notelnet;
modem_control = mp->modem_control; modem_control = mp->modem_control;
@ -2119,7 +2127,7 @@ while (*tptr) {
(0 == MATCH_CMD (gbuf, "UNBUFFERED"))) { (0 == MATCH_CMD (gbuf, "UNBUFFERED"))) {
if ((NULL != cptr) && ('\0' != *cptr)) if ((NULL != cptr) && ('\0' != *cptr))
return SCPE_2MARG; return SCPE_2MARG;
unbuffered = TRUE; buffered[0] = '\0';
continue; continue;
} }
if (0 == MATCH_CMD (gbuf, "BUFFERED")) { if (0 == MATCH_CMD (gbuf, "BUFFERED")) {
@ -2265,33 +2273,23 @@ while (*tptr) {
} }
} }
} }
if (unbuffered) {
if (mp->buffered) {
mp->buffered = 0;
for (i = 0; i < mp->lines; i++) { /* default line buffers */
lp = mp->ldsc + i;
lp->rxbsz = TMXR_MAXBUF;
lp->rxb = (char *)realloc(lp->rxb, lp->rxbsz);
lp->rbr = (char *)realloc(lp->rbr, lp->rxbsz);
lp->txbsz = TMXR_MAXBUF;
lp->txb = (char *)realloc(lp->txb, lp->txbsz);
lp->txbfd = lp->txbpi = lp->txbpr = 0;
}
}
}
if (buffered[0]) {
mp->buffered = atoi(buffered);
for (i = 0; i < mp->lines; i++) { /* initialize line buffers */ for (i = 0; i < mp->lines; i++) { /* initialize line buffers */
lp = mp->ldsc + i; lp = mp->ldsc + i;
lp->txbsz = mp->buffered; if (buffered[0]) {
lp->txbsz = atoi(buffered);
lp->txbfd = 1; lp->txbfd = 1;
lp->txb = (char *)realloc(lp->txb, lp->txbsz); lp->rxbsz = atoi(buffered);
}
else {
lp->txbsz = TMXR_MAXBUF;
lp->txbfd = 0;
lp->rxbsz = TMXR_MAXBUF;
}
lp->txbpi = lp->txbpr = 0; lp->txbpi = lp->txbpr = 0;
lp->rxbsz = mp->buffered; lp->txb = (char *)realloc(lp->txb, lp->txbsz);
lp->rxb = (char *)realloc(lp->rxb, lp->rxbsz); lp->rxb = (char *)realloc(lp->rxb, lp->rxbsz);
lp->rbr = (char *)realloc(lp->rbr, lp->rxbsz); lp->rbr = (char *)realloc(lp->rbr, lp->rxbsz);
} }
}
if (nolog) { if (nolog) {
mp->logfiletmpl[0] = '\0'; mp->logfiletmpl[0] = '\0';
for (i = 0; i < mp->lines; i++) { /* close line logs */ for (i = 0; i < mp->lines; i++) { /* close line logs */
@ -2316,9 +2314,7 @@ while (*tptr) {
free (mp->port); free (mp->port);
mp->port = NULL; mp->port = NULL;
} }
printf ("Listening on port %s\n", listen); sim_printf ("Listening on port %s\n", listen);
if (sim_log)
fprintf (sim_log, "Listening on port %s\n", listen);
mp->port = (char *)realloc (mp->port, 1 + strlen (listen)); mp->port = (char *)realloc (mp->port, 1 + strlen (listen));
strcpy (mp->port, listen); /* save port */ strcpy (mp->port, listen); /* save port */
mp->master = sock; /* save master socket */ mp->master = sock; /* save master socket */
@ -2343,9 +2339,7 @@ while (*tptr) {
if (loopback) { if (loopback) {
if (mp->lines > 1) if (mp->lines > 1)
return SCPE_ARG; /* ambiguous */ return SCPE_ARG; /* ambiguous */
printf ("Operating in loopback mode\n"); sim_printf ("Operating in loopback mode\n");
if (sim_log)
fprintf (sim_log, "Operating in loopback mode\n");
for (i = 0; i < mp->lines; i++) { for (i = 0; i < mp->lines; i++) {
lp = mp->ldsc + i; lp = mp->ldsc + i;
tmxr_set_line_loopback (lp, loopback); tmxr_set_line_loopback (lp, loopback);
@ -2429,23 +2423,19 @@ while (*tptr) {
return r; return r;
} }
} }
if (unbuffered) { if (buffered[0] == '\0') {
lp->txbsz = TMXR_MAXBUF; lp->rxbsz = lp->txbsz = TMXR_MAXBUF;
lp->txb = (char *)realloc (lp->txb, lp->txbsz); lp->txbfd = 0;
lp->txbfd = lp->txbpi = lp->txbpr = 0;
lp->rxbsz = lp->txbsz;
lp->rxb = (char *)realloc(lp->rxb, lp->rxbsz);
lp->rbr = (char *)realloc(lp->rbr, lp->rxbsz);
} }
if (buffered[0]) { else {
lp->txbsz = atoi(buffered); lp->rxbsz = lp->txbsz = atoi(buffered);
lp->txbfd = 1; lp->txbfd = 1;
lp->txb = (char *)realloc (lp->txb, lp->txbsz); }
lp->txbpi = lp->txbpr = 0; lp->txbpi = lp->txbpr = 0;
lp->rxbsz = lp->txbsz; lp->txb = (char *)realloc (lp->txb, lp->txbsz);
lp->rxb = (char *)realloc(lp->rxb, lp->rxbsz); lp->rxb = (char *)realloc(lp->rxb, lp->rxbsz);
lp->rbr = (char *)realloc(lp->rbr, lp->rxbsz); lp->rbr = (char *)realloc(lp->rbr, lp->rxbsz);
} lp->packet = packet;
if (nolog) { if (nolog) {
free(lp->txlogname); free(lp->txlogname);
lp->txlogname = NULL; lp->txlogname = NULL;
@ -2463,9 +2453,7 @@ while (*tptr) {
if (sock == INVALID_SOCKET) /* open error */ if (sock == INVALID_SOCKET) /* open error */
return SCPE_OPENERR; return SCPE_OPENERR;
_mux_detach_line (lp, TRUE, FALSE); _mux_detach_line (lp, TRUE, FALSE);
printf ("Line %d Listening on port %s\n", line, listen); sim_printf ("Line %d Listening on port %s\n", line, listen);
if (sim_log)
fprintf (sim_log, "Line %d Listening on port %s\n", line, listen);
lp->port = (char *)realloc (lp->port, 1 + strlen (listen)); lp->port = (char *)realloc (lp->port, 1 + strlen (listen));
strcpy (lp->port, listen); /* save port */ strcpy (lp->port, listen); /* save port */
lp->master = sock; /* save master socket */ lp->master = sock; /* save master socket */
@ -2502,7 +2490,6 @@ while (*tptr) {
else else
return SCPE_ARG; return SCPE_ARG;
} }
lp->packet = packet;
sock = sim_connect_sock_ex (datagram ? listen : NULL, destination, "localhost", NULL, datagram, packet); sock = sim_connect_sock_ex (datagram ? listen : NULL, destination, "localhost", NULL, datagram, packet);
if (sock != INVALID_SOCKET) { if (sock != INVALID_SOCKET) {
_mux_detach_line (lp, FALSE, TRUE); _mux_detach_line (lp, FALSE, TRUE);
@ -2524,9 +2511,7 @@ while (*tptr) {
} }
if (loopback) { if (loopback) {
tmxr_set_line_loopback (lp, loopback); tmxr_set_line_loopback (lp, loopback);
printf ("Line %d operating in loopback mode\n", line); sim_printf ("Line %d operating in loopback mode\n", line);
if (sim_log)
fprintf (sim_log, "Line %d operating in loopback mode\n", line);
} }
lp->modem_control = modem_control; lp->modem_control = modem_control;
r = SCPE_OK; r = SCPE_OK;
@ -2805,7 +2790,7 @@ while (sim_asynch_enabled) {
wait_count = 0; wait_count = 0;
if (select_errno == EINTR) if (select_errno == EINTR)
break; break;
fprintf (stderr, "select() returned -1, errno=%d - %s\r\n", select_errno, strerror(select_errno)); sim_printf ("select() returned -1, errno=%d - %s\r\n", select_errno, strerror(select_errno));
abort(); abort();
break; break;
default: default:
@ -2926,7 +2911,7 @@ while (sim_asynch_enabled) {
pthread_mutex_lock (&sim_tmxr_poll_lock); pthread_mutex_lock (&sim_tmxr_poll_lock);
switch (status) { switch (status) {
case WAIT_FAILED: case WAIT_FAILED:
fprintf (stderr, "WaitForMultipleObjects() Failed, LastError=%d\r\n", GetLastError()); sim_printf ("WaitForMultipleObjects() Failed, LastError=%d\r\n", GetLastError());
abort(); abort();
break; break;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
@ -3041,7 +3026,7 @@ while (sim_asynch_enabled) {
IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR | IO$M_TIMED | IO$M_TRMNOECHO, IO$_READLBLK | IO$M_NOECHO | IO$M_NOFILTR | IO$M_TIMED | IO$M_TRMNOECHO,
&iosb, 0, 0, buf, 1, 1, term, 0, 0); &iosb, 0, 0, buf, 1, 1, term, 0, 0);
if (status != SS$_NORMAL) { if (status != SS$_NORMAL) {
fprintf (stderr, "_tmxr_serial_line_poll() - QIO Failed, Status=%d\r\n", status); sim_printf ("_tmxr_serial_line_poll() - QIO Failed, Status=%d\r\n", status);
abort(); abort();
} }
wait_count = 0; wait_count = 0;
@ -3307,20 +3292,27 @@ else {
TMLN *lp; TMLN *lp;
char *attach; char *attach;
fprintf(st, "Multiplexer device: %s, ", (mp->dptr ? sim_dname (mp->dptr) : "")); fprintf(st, "Multiplexer device: %s", (mp->dptr ? sim_dname (mp->dptr) : ""));
attach = tmxr_mux_attach_string (NULL, mp);
fprintf(st, "attached to %s, ", attach);
free (attach);
if (mp->lines > 1) { if (mp->lines > 1) {
tmxr_show_lines(st, NULL, 0, mp);
fprintf(st, ", "); fprintf(st, ", ");
tmxr_show_lines(st, NULL, 0, mp);
} }
tmxr_show_summ(st, NULL, 0, mp); if (mp->packet)
fprintf(st, ", sessions=%d", mp->sessions); fprintf(st, ", Packet");
if (mp->modem_control) if (mp->datagram)
fprintf(st, ", ModemControl=enabled"); fprintf(st, ", UDP");
if (mp->notelnet) if (mp->notelnet)
fprintf(st, ", Telnet=disabled"); fprintf(st, ", Telnet=disabled");
if (mp->modem_control)
fprintf(st, ", ModemControl=enabled");
if (mp->buffered)
fprintf(st, ", Buffered=%d", mp->buffered);
attach = tmxr_mux_attach_string (NULL, mp);
if (attach)
fprintf(st, ",\n attached to %s, ", attach);
free (attach);
tmxr_show_summ(st, NULL, 0, mp);
fprintf(st, ", sessions=%d", mp->sessions);
fprintf(st, "\n"); fprintf(st, "\n");
for (j = 0; j < mp->lines; j++) { for (j = 0; j < mp->lines; j++) {
lp = mp->ldsc + j; lp = mp->ldsc + j;
@ -3395,6 +3387,7 @@ for (i = 0; i < mp->lines; i++) { /* loop thru conn */
free (lp->port); free (lp->port);
lp->port = NULL; lp->port = NULL;
} }
lp->txbfd = 0;
free (lp->txb); free (lp->txb);
lp->txb = NULL; lp->txb = NULL;
free (lp->rxb); free (lp->rxb);
@ -4165,7 +4158,7 @@ for (i = t = 0; i < mp->lines; i++)
if ((mp->ldsc[i].sock != 0) || (mp->ldsc[i].serport != 0)) if ((mp->ldsc[i].sock != 0) || (mp->ldsc[i].serport != 0))
t = t + 1; t = t + 1;
if (mp->lines > 1) if (mp->lines > 1)
fprintf (st, "%d connection%s", t, (t != 1) ? "s" : ""); fprintf (st, "%d current connection%s", t, (t != 1) ? "s" : "");
else else
fprintf (st, "%s", (t == 1) ? "connected" : "disconnected"); fprintf (st, "%s", (t == 1) ? "connected" : "disconnected");
return SCPE_OK; return SCPE_OK;

View file

@ -1521,9 +1521,7 @@ SDL_Init (SDL_INIT_VIDEO);
SDL_CreateWindowAndRenderer (vid_width, vid_height, SDL_WINDOW_SHOWN, &vid_window, &vid_renderer); SDL_CreateWindowAndRenderer (vid_width, vid_height, SDL_WINDOW_SHOWN, &vid_window, &vid_renderer);
if ((vid_window == NULL) || (vid_renderer == NULL)) { if ((vid_window == NULL) || (vid_renderer == NULL)) {
printf ("%s: Error Creating Video Window: %s\b", sim_dname(vid_dev), SDL_GetError()); sim_printf ("%s: Error Creating Video Window: %s\b", sim_dname(vid_dev), SDL_GetError());
if (sim_log)
fprintf (sim_log, "%s: Error Creating Video Window: %s\b", sim_dname(vid_dev), SDL_GetError());
SDL_Quit (); SDL_Quit ();
return 0; return 0;
} }
@ -1537,9 +1535,7 @@ vid_texture = SDL_CreateTexture (vid_renderer,
SDL_TEXTUREACCESS_STREAMING, SDL_TEXTUREACCESS_STREAMING,
vid_width, vid_height); vid_width, vid_height);
if (!vid_texture) { if (!vid_texture) {
printf ("%s: Error configuring Video environment: %s\b", sim_dname(vid_dev), SDL_GetError()); sim_printf ("%s: Error configuring Video environment: %s\b", sim_dname(vid_dev), SDL_GetError());
if (sim_log)
fprintf (sim_log, "%s: Error configuring Video environment: %s\b", sim_dname(vid_dev), SDL_GetError());
SDL_DestroyRenderer(vid_renderer); SDL_DestroyRenderer(vid_renderer);
vid_renderer = NULL; vid_renderer = NULL;
SDL_DestroyWindow(vid_window); SDL_DestroyWindow(vid_window);