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

This commit is contained in:
Mark Emmer 2014-03-17 16:37:24 -06:00
commit e15b09fcb7
8 changed files with 77 additions and 91 deletions

View file

@ -1013,6 +1013,8 @@ t_stat cr_wr ( int32 data,
int32 PA,
int32 access )
{
int curr_crs = crs; /* Save current crs to recover status */
switch ((PA >> 1) & 03) {
case 0:
if (CR11_CTL(&cr_unit)) {
@ -1024,7 +1026,6 @@ t_stat cr_wr ( int32 data,
data = (crs & ~0377) | (data & 0377);
if (!(data & CSR_IE))
CLR_INT (CR);
int curr_crs = crs; /* Save current crs to recover status */
crs = (crs & ~CRCSR_RW) | (data & CRCSR_RW);
/* Clear status bits after CSR load */
crs &= ~(CSR_ERR | CRCSR_ONLINE | CRCSR_CRDDONE | CRCSR_TIMERR);

View file

@ -3574,7 +3574,9 @@ uint32 i, j;
sim_debug(DBG_TRC, dptr, "dmc_reset(%s)\n", dptr->name);
dmc_desc.packet = TRUE;
dmc_desc.buffered = 16384;
dmp_desc.packet = TRUE;
dmp_desc.buffered = 16384;
/* Connect structures together */
for (i=0; i < DMC_NUMDEVICE; i++) {
dmc_csrs[i].sel0 = &dmc_sel0[i];
@ -3738,7 +3740,7 @@ if (!peer[0]) {
fprintf (sim_log, "Peer must be specified before attach\n");
return SCPE_ARG;
}
sprintf (attach_string, "Line=%d,Buffered=16384,Connect=%s,%s", dmc, peer, cptr);
sprintf (attach_string, "Line=%d,Connect=%s,%s", dmc, peer, cptr);
ans = tmxr_open_master (mp, attach_string); /* open master socket */
if (ans != SCPE_OK)
return ans;

8
scp.c
View file

@ -484,7 +484,6 @@ FILEREF *sim_log_ref = NULL; /* log file file referen
FILE *sim_deb = NULL; /* debug file */
FILEREF *sim_deb_ref = NULL; /* debug file file reference */
int32 sim_deb_switches = 0; /* debug switches */
REG *sim_deb_PC = NULL; /* debug PC register pointer */
struct timespec sim_deb_basetime; /* debug timestamp relative base time */
char *sim_prompt = NULL; /* prompt string */
static FILE *sim_gotofile; /* the currently open do file */
@ -568,6 +567,7 @@ const struct scp_error {
{"STALL", "Console Telnet output stall"},
{"AFAIL", "Assertion failed"},
{"INVREM", "Invalid remote console command"},
{"NOTATT", "Not attached"},
};
const size_t size_map[] = { sizeof (int8),
@ -7826,9 +7826,9 @@ if (sim_deb_switches & SWMASK ('P')) {
if (sim_vm_pc_value)
val = (*sim_vm_pc_value)();
else
val = get_rval (sim_deb_PC, 0);
sprintf(pc_s, "-%s:", sim_deb_PC->name);
sprint_val (&pc_s[strlen(pc_s)], val, sim_deb_PC->radix, sim_deb_PC->width, sim_deb_PC->flags & REG_FMT);
val = get_rval (sim_PC, 0);
sprintf(pc_s, "-%s:", sim_PC->name);
sprint_val (&pc_s[strlen(pc_s)], val, sim_PC->radix, sim_PC->width, sim_PC->flags & REG_FMT);
}
sprintf(debug_line_prefix, "DBG(%s%s%.0f%s)%s> %s %s: ", tim_t, tim_a, sim_gtime(), pc_s, AIO_MAIN_THREAD ? "" : "+", dptr->name, debug_type);
return debug_line_prefix;

1
scp.h
View file

@ -180,7 +180,6 @@ extern FILE *sim_deb; /* debug file */
extern FILEREF *sim_deb_ref; /* debug file file reference */
extern int32 sim_deb_switches; /* debug display flags */
extern struct timespec sim_deb_basetime; /* debug base time for relative time output */
extern REG *sim_deb_PC; /* debug PC register */
extern UNIT *sim_clock_queue;
extern int32 sim_is_running;
extern char *sim_prompt; /* prompt string */

View file

@ -1063,8 +1063,6 @@ if (sim_deb_switches & SWMASK ('R')) {
if (!(sim_deb_switches & (SWMASK ('A') | SWMASK ('T'))))
sim_deb_switches |= SWMASK ('T');
}
if (sim_deb_switches & SWMASK ('P'))
sim_deb_PC = find_reg ("PC", NULL, sim_dflt_dev);
if (!sim_quiet) {
printf ("Debug output to \"%s\"\n",
sim_logfile_name (sim_deb, sim_deb_ref));
@ -1126,7 +1124,6 @@ if (sim_deb == NULL) /* no debug? */
sim_close_logfile (&sim_deb_ref);
sim_deb = NULL;
sim_deb_switches = 0;
sim_deb_PC = NULL;
if (!sim_quiet) {
printf ("Debug output disabled\n");
if (sim_log)

View file

@ -304,8 +304,9 @@ typedef uint32 t_addr;
#define SCPE_STALL (SCPE_BASE + 41) /* Telnet conn stall */
#define SCPE_AFAIL (SCPE_BASE + 42) /* assert failed */
#define SCPE_INVREM (SCPE_BASE + 43) /* invalid remote console command */
#define SCPE_NOTATT (SCPE_BASE + 44) /* not attached */
#define SCPE_MAX_ERR (SCPE_BASE + 44) /* Maximum SCPE Error Value */
#define SCPE_MAX_ERR (SCPE_BASE + 45) /* Maximum SCPE Error Value */
#define SCPE_KFLAG 0x1000 /* tti data flag */
#define SCPE_BREAK 0x2000 /* tti break flag */
#define SCPE_NOMESSAGE 0x10000000 /* message display supression flag */
@ -747,9 +748,10 @@ typedef struct sim_bitfield BITFIELD;
/* This replaces any references to "assert()" which should never be invoked */
/* with an expression which causes side effects (i.e. must be executed for */
/* the program to work correctly) */
#define ASSURE(_Expression) if (_Expression) {fprintf(stderr, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
if (sim_log) fprintf(sim_log, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
if (sim_deb) fprintf(sim_deb, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
#define ASSURE(_Expression) if (!(_Expression)) {char *_exp = #_Expression; char *_file = __FILE__; \
fprintf(stderr, "%s failed at %s line %d\n", _exp, _file, __LINE__); \
if (sim_log) fprintf(sim_log, "%s failed at %s line %d\n", _exp, _file, __LINE__); \
if (sim_deb) fprintf(sim_deb, "%s failed at %s line %d\n", _exp, _file, __LINE__); \
abort();} else (void)0
/* Asynch/Threaded I/O support */

View file

@ -1198,7 +1198,7 @@ FILE *fileref;
t_bool auto_format;
if ((uptr == NULL) || !(uptr->flags & UNIT_ATT))
return SCPE_IERR;
return SCPE_NOTATT;
ctx = (struct disk_context *)uptr->disk_ctx;
fileref = uptr->fileref;
@ -1322,7 +1322,7 @@ fprintf (st, " Volume Serial Number is F8DE-510C\n\n");
fprintf (st, " Directory of H:\\Data\n\n");
fprintf (st, " 04/14/2011 12:57 PM 5,120 RA92.vhd\n");
fprintf (st, " 1 File(s) 5,120 bytes\n");
fprintf (st, " sim> atta rq3 -c RA92-1.vhd RA92.vhd\n");
fprintf (st, " sim> atta rq3 -d RA92-1-Diff.vhd RA92.vhd\n");
fprintf (st, " sim> atta rq3 -c RA92-1.vhd RA92.vhd\n");
fprintf (st, " RQ3: creating new virtual disk 'RA92-1.vhd'\n");
fprintf (st, " RQ3: Copied 1505MB. 99%% complete.\n");
@ -2670,7 +2670,7 @@ if (!File) {
goto Return_Cleanup;
}
if (ModifiedTimeStamp) {
if (stat (szVHDPath, &statb)) {
if (fstat (fileno (File), &statb)) {
Return = errno;
goto Return_Cleanup;
}
@ -3516,31 +3516,22 @@ for (i=0; i < strlen(RelativeParentVHDPath); i++)
RelativeParentVHDPathUnicode[i*2] = RelativeParentVHDPath[i];
hVHD->Dynamic.ParentTimeStamp = ParentTimeStamp;
memcpy (hVHD->Dynamic.ParentUniqueID, ParentFooter.UniqueID, sizeof (hVHD->Dynamic.ParentUniqueID));
hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataSpace = NtoHl (BytesPerSector);
hVHD->Dynamic.ParentLocatorEntries[7].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
++LocatorsWritten;
memcpy (hVHD->Dynamic.ParentLocatorEntries[6].PlatformCode, "Wi2k", 4);
hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataSpace = NtoHl (BytesPerSector);
hVHD->Dynamic.ParentLocatorEntries[6].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
/* There are two potential parent locators on current vhds */
memcpy (hVHD->Dynamic.ParentLocatorEntries[0].PlatformCode, "W2ku", 4);
hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataSpace = NtoHl (BytesPerSector);
hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataLength = NtoHl ((uint32)(2*strlen(FullParentVHDPath)));
hVHD->Dynamic.ParentLocatorEntries[0].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
++LocatorsWritten;
if (RelativeMatch) {
memcpy (hVHD->Dynamic.ParentLocatorEntries[7].PlatformCode, "Wi2r", 4);
hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataLength = NtoHl ((uint32)(strlen(RelativeParentVHDPath)));
memcpy (hVHD->Dynamic.ParentLocatorEntries[5].PlatformCode, "W2ru", 4);
hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataSpace = NtoHl (BytesPerSector);
hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataLength = NtoHl ((uint32)(2*strlen(RelativeParentVHDPath)));
hVHD->Dynamic.ParentLocatorEntries[5].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
memcpy (hVHD->Dynamic.ParentLocatorEntries[1].PlatformCode, "W2ru", 4);
hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataSpace = NtoHl (BytesPerSector);
hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataLength = NtoHl ((uint32)(2*strlen(RelativeParentVHDPath)));
hVHD->Dynamic.ParentLocatorEntries[1].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
++LocatorsWritten;
}
memcpy (hVHD->Dynamic.ParentLocatorEntries[4].PlatformCode, "W2ku", 4);
hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataSpace = NtoHl (BytesPerSector);
hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength = NtoHl ((uint32)(2*strlen(FullParentVHDPath)));
hVHD->Dynamic.ParentLocatorEntries[4].Reserved = 0;
hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector);
++LocatorsWritten;
hVHD->Dynamic.TableOffset = NtoHll (((LocatorPosition+LocatorsWritten*BytesPerSector + VHD_DATA_BLOCK_ALIGNMENT - 1)/VHD_DATA_BLOCK_ALIGNMENT)*VHD_DATA_BLOCK_ALIGNMENT);
hVHD->Dynamic.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Dynamic, sizeof(hVHD->Dynamic)));
hVHD->Footer.Checksum = 0;
hVHD->Footer.DiskType = NtoHl (VHD_DT_Differencing);
@ -3563,6 +3554,14 @@ if (WriteFilePosition (hVHD->File,
Status = errno;
goto Cleanup_Return;
}
if (WriteFilePosition (hVHD->File,
hVHD->BAT,
BytesPerSector*((NtoHl (hVHD->Dynamic.MaxTableEntries)*sizeof(*hVHD->BAT)+BytesPerSector-1)/BytesPerSector),
NULL,
NtoHll (hVHD->Dynamic.TableOffset))) {
Status = errno;
goto Cleanup_Return;
}
if (WriteFilePosition (hVHD->File,
&hVHD->Footer,
sizeof (hVHD->Footer),
@ -3571,35 +3570,21 @@ if (WriteFilePosition (hVHD->File,
Status = errno;
goto Cleanup_Return;
}
if (WriteFilePosition (hVHD->File,
RelativeParentVHDPath,
BytesPerSector,
NULL,
NtoHll (hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataOffset))) {
Status = errno;
goto Cleanup_Return;
}
if (WriteFilePosition (hVHD->File,
FullParentVHDPath,
BytesPerSector,
NULL,
NtoHll (hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset))) {
Status = errno;
goto Cleanup_Return;
}
if (WriteFilePosition (hVHD->File,
RelativeParentVHDPathUnicode,
BytesPerSector,
NULL,
NtoHll (hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset))) {
Status = errno;
goto Cleanup_Return;
}
if (WriteFilePosition (hVHD->File,
if (hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataLength)
if (WriteFilePosition (hVHD->File,
FullParentVHDPathUnicode,
BytesPerSector,
NULL,
NtoHll (hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset))) {
NtoHll (hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataOffset))) {
Status = errno;
goto Cleanup_Return;
}
if (hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataLength)
if (WriteFilePosition (hVHD->File,
RelativeParentVHDPathUnicode,
BytesPerSector,
NULL,
NtoHll (hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataOffset))) {
Status = errno;
goto Cleanup_Return;
}
@ -3613,7 +3598,7 @@ free (FullVHDPath);
sim_vhd_disk_close ((FILE *)hVHD);
hVHD = NULL;
if (Status) {
if (EEXIST != Status)
if ((EEXIST != Status) && (ENOENT != Status))
remove (szVHDPath);
}
else {

View file

@ -831,7 +831,7 @@ if (mp->buffered)
if (mp->logfiletmpl[0]) /* logfile info */
sprintf (growstring(&tptr, 7 + strlen (mp->logfiletmpl)), ",Log=%s", mp->logfiletmpl);
while ((*tptr == ',') || (*tptr == ' '))
strcpy(tptr, tptr+1);
memcpy (tptr, tptr+1, strlen(tptr+1)+1);
for (i=0; i<mp->lines; ++i) {
char *lptr;
lp = mp->ldsc + i;
@ -844,7 +844,7 @@ for (i=0; i<mp->lines; ++i) {
}
if (mp->lines == 1)
while ((*tptr == ',') || (*tptr == ' '))
strcpy(tptr, tptr+1);
memcpy (tptr, tptr+1, strlen(tptr+1)+1);
if (*tptr == '\0') {
free (tptr);
tptr = NULL;
@ -1238,13 +1238,6 @@ if ((lp->destination) && (!lp->serport)) {
}
}
tmxr_init_line (lp); /* initialize line state */
if (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);
}
return SCPE_OK;
}
@ -2031,6 +2024,13 @@ if (lp->serport) { /* close current serial connection *
lp->destination = NULL;
}
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)
@ -2124,7 +2124,7 @@ while (*tptr) {
}
if (0 == MATCH_CMD (gbuf, "BUFFERED")) {
if ((NULL == cptr) || ('\0' == *cptr))
strcpy(buffered, "32768");
strcpy (buffered, "32768");
else {
i = (int32) get_uint (cptr, 10, 1024*1024, &r);
if ((r != SCPE_OK) || (i == 0))
@ -2203,7 +2203,7 @@ while (*tptr) {
return SCPE_ARG;
cptr = hostport;
}
strcpy(destination, cptr);
strcpy (destination, cptr);
continue;
}
cptr = get_glyph (gbuf, port, ';');
@ -2229,7 +2229,7 @@ while (*tptr) {
return SCPE_OPENERR;
sim_close_sock (sock, 1);
sim_os_ms_sleep (2); /* let the close finish (required on some platforms) */
strcpy(listen, port);
strcpy (listen, port);
cptr = get_glyph (cptr, option, ';');
if (option[0]) {
if (0 == MATCH_CMD (option, "NOTELNET"))
@ -2254,10 +2254,10 @@ while (*tptr) {
if (mp->lines > 1)
sprintf(lp->txlogname, "%s_%d", mp->logfiletmpl, i);
else
strcpy(lp->txlogname, mp->logfiletmpl);
strcpy (lp->txlogname, mp->logfiletmpl);
r = sim_open_logfile (lp->txlogname, TRUE, &lp->txlog, &lp->txlogref);
if (r == SCPE_OK)
setvbuf(lp->txlog, NULL, _IOFBF, 65536);
setvbuf (lp->txlog, NULL, _IOFBF, 65536);
else {
free (lp->txlogname);
lp->txlogname = NULL;
@ -2384,7 +2384,7 @@ while (*tptr) {
if (datagram) {
if (listen[0]) {
lp->port = (char *)realloc (lp->port, 1 + strlen (listen));
strcpy(lp->port, listen); /* save port */
strcpy (lp->port, listen); /* save port */
}
else
return SCPE_ARG;
@ -2419,7 +2419,7 @@ while (*tptr) {
sim_close_logfile (&lp->txlogref);
lp->txlog = NULL;
lp->txlogname = (char *)realloc (lp->txlogname, 1 + strlen (logfiletmpl));
strcpy(lp->txlogname, mp->logfiletmpl);
strcpy (lp->txlogname, mp->logfiletmpl);
r = sim_open_logfile (lp->txlogname, TRUE, &lp->txlog, &lp->txlogref);
if (r == SCPE_OK)
setvbuf(lp->txlog, NULL, _IOFBF, 65536);
@ -2467,7 +2467,7 @@ while (*tptr) {
if (sim_log)
fprintf (sim_log, "Line %d Listening on port %s\n", line, 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 */
if (listennotelnet != mp->notelnet)
lp->notelnet = listennotelnet;
@ -2497,7 +2497,7 @@ while (*tptr) {
if (datagram) {
if (listen[0]) {
lp->port = (char *)realloc (lp->port, 1 + strlen (listen));
strcpy(lp->port, listen); /* save port */
strcpy (lp->port, listen); /* save port */
}
else
return SCPE_ARG;