1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-05-07 08:06:58 +00:00

SCP: Updated to current. Including AWS support.

This commit is contained in:
Richard Cornwell
2019-03-28 20:59:05 -04:00
parent 6a2ad87c90
commit b4e85eea18
10 changed files with 739 additions and 111 deletions

View File

@@ -37,10 +37,16 @@
static void *ng_dptr;
static int ng_dbit;
#if defined(__cplusplus)
extern "C" {
#endif
#define DEVICE void
extern void _sim_debug_device (unsigned int dbits, DEVICE* dptr, const char* fmt, ...);
#define DEBUGF(...) _sim_debug_device (ng_dbit, ng_dptr, ## __VA_ARGS__)
#if defined(__cplusplus)
}
#endif
int ng_type = 0;
int ng_scale = PIX_SCALE;

47
scp.c
View File

@@ -2240,7 +2240,7 @@ static const char simh_help[] =
" Specifies a true (false {NOT}) condition if the file exists.\n"
"5File Comparison Expressions\n"
" Files can have their contents compared with:\n\n"
"++-D {NOT} \"<filespec1>\" == \"<filespec2>\" \n\n"
"++-F {NOT} \"<filespec1>\" == \"<filespec2>\" \n\n"
" Specifies a true (false {NOT}) condition if the indicated files\n"
" have the same contents.\n\n"
/***************** 80 character line width template *************************/
@@ -2637,7 +2637,7 @@ else if (*argv[0]) { /* sim name arg? */
if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR) /* didn't exist/can't open? */
stat = SCPE_OK;
if (sim_switches & SWMASK ('T')) /* Command Line -T switch */
if (sim_switches & SWMASK ('T')) /* Command Line -T switch */
stat = sim_library_unit_tests (); /* run library unit tests */
if (SCPE_BARE_STATUS(stat) != SCPE_EXIT)
@@ -4260,7 +4260,6 @@ for (i=1; i<arg_count-1; ++i)
return SCPE_OK;
}
static
int sim_cmp_string (const char *s1, const char *s2)
{
long int v1, v2;
@@ -6680,8 +6679,10 @@ for (i = 0; i < start; i++) {
return SCPE_IERR;
}
for (i = start; (dptr = sim_devices[i]) != NULL; i++) {
if (sim_switches & SWMASK('P'))
if (sim_switches & SWMASK('P')) {
tmxr_add_debug (dptr); /* Add TMXR debug to MUX devices */
sim_tape_add_debug (dptr); /* Add TAPE debug to TAPE devices */
}
if (dptr->reset != NULL) {
reason = dptr->reset (dptr);
if (reason != SCPE_OK)
@@ -6879,6 +6880,7 @@ return attach_unit (uptr, (CONST char *)cptr); /* no, std routine */
t_stat attach_unit (UNIT *uptr, CONST char *cptr)
{
DEVICE *dptr;
t_bool open_rw = FALSE;
if (!(uptr->flags & UNIT_ATTABLE)) /* not attachable? */
return SCPE_NOATT;
@@ -6932,6 +6934,8 @@ else {
sim_messagef (SCPE_OK, "%s: creating new file\n", sim_dname (dptr));
}
} /* end if null */
else
open_rw = TRUE;
} /* end else */
}
if (uptr->flags & UNIT_BUFABLE) { /* buffer? */
@@ -6947,6 +6951,12 @@ if (uptr->flags & UNIT_BUFABLE) { /* buffer? */
}
uptr->flags = uptr->flags | UNIT_ATT;
uptr->pos = 0;
if (open_rw && /* open for write in append mode? */
(sim_switches & SWMASK ('A')) &&
(uptr->flags & UNIT_SEQ) &&
(!(uptr->flags & UNIT_MUSTBUF)) &&
(0 == sim_fseek (uptr->fileref, 0, SEEK_END)))
uptr->pos = (t_addr)sim_ftell (uptr->fileref); /* Position at end of file */
return SCPE_OK;
}
@@ -12894,6 +12904,11 @@ if (sim_deb && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & reason)) {
ebcdicbuf[eidx++] = '.';
}
}
for (; sidx<16; ++sidx) {
strbuf[soff+sidx] = ' ';
if (eidx)
ebcdicbuf[eidx++] = ' ';
}
outbuf[oidx] = '\0';
strbuf[soff+sidx] = '\0';
ebcdicbuf[eidx] = '\0';
@@ -14515,6 +14530,23 @@ delete_Stack (postfix);
return cptr;
}
/*
* To avoid Coverity complaints about the use of rand() we define the function locally
*/
static uint32 sim_rand_seed;
void sim_srand (unsigned int seed)
{
sim_rand_seed = (uint32)seed;
}
int sim_rand ()
{
sim_rand_seed = sim_rand_seed * 214013 + 2531011;
return (sim_rand_seed >> 16) & RAND_MAX;
}
/*
* Compiled in unit tests for the various device oriented library
* modules: sim_card, sim_disk, sim_tape, sim_ether, sim_tmxr, etc.
@@ -14524,11 +14556,18 @@ static t_stat sim_library_unit_tests (void)
{
int i;
DEVICE *dptr;
int32 saved_switches = sim_switches & ~SWMASK ('T');
t_stat stat = SCPE_OK;
if (sim_switches & SWMASK ('D')) {
sim_switches &= ~(SWMASK ('D') | SWMASK ('R') | SWMASK ('F') | SWMASK ('T'));
sim_set_debon (0, "STDOUT");
sim_switches = saved_switches;
}
for (i = 0; (dptr = sim_devices[i]) != NULL; i++) {
t_stat tstat = SCPE_OK;
sim_switches = saved_switches;
switch (DEV_TYPE(dptr)) {
#if defined(USE_SIM_CARD)
case DEV_CARD:

7
scp.h
View File

@@ -231,6 +231,12 @@ size_t sim_strlcpy (char *dst, const char *src, size_t size);
#ifndef strcasecmp
#define strcasecmp(str1, str2) sim_strcasecmp ((str1), (str2))
#endif
void sim_srand (unsigned int seed);
int sim_rand (void);
#ifdef RAND_MAX
#undef RAND_MAX
#endif
#define RAND_MAX 32767
CONST char *get_sim_opt (int32 opt, CONST char *cptr, t_stat *st);
CONST char *get_sim_sw (CONST char *cptr);
const char *put_switches (char *buf, size_t bufsize, uint32 sw);
@@ -297,6 +303,7 @@ t_stat sim_exp_show (FILE *st, CONST EXPECT *exp, const char *match);
t_stat sim_exp_showall (FILE *st, const EXPECT *exp);
t_stat sim_exp_check (EXPECT *exp, uint8 data);
CONST char *match_ext (CONST char *fnam, const char *ext);
int sim_cmp_string (const char *s1, const char *s2);
t_stat show_version (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);

View File

@@ -2242,6 +2242,21 @@ else
return SCPE_OK;
}
/* Set debug switches */
int32 sim_set_deb_switches (int32 switches)
{
int32 old_deb_switches = sim_deb_switches;
sim_deb_switches = switches &
(SWMASK ('R') | SWMASK ('P') |
SWMASK ('T') | SWMASK ('A') |
SWMASK ('F') | SWMASK ('N') |
SWMASK ('B') | SWMASK ('E') |
SWMASK ('D') ); /* save debug switches */
return old_deb_switches;
}
/* Set debug routine */
t_stat sim_set_debon (int32 flag, CONST char *cptr)
@@ -2267,11 +2282,8 @@ r = sim_open_logfile (gbuf, FALSE, &sim_deb, &sim_deb_ref);
if (r != SCPE_OK)
return r;
sim_deb_switches = sim_switches &
(SWMASK ('R') | SWMASK ('P') |
SWMASK ('T') | SWMASK ('A') |
SWMASK ('F') | SWMASK ('N') |
SWMASK ('B')); /* save debug switches */
sim_set_deb_switches (sim_switches);
if (sim_deb_switches & SWMASK ('R')) {
struct tm loc_tm, gmt_tm;
time_t time_t_now;

View File

@@ -81,6 +81,7 @@ t_stat sim_set_serial (int32 flag, CONST char *cptr);
t_stat sim_set_noserial (int32 flag, CONST char *cptr);
t_stat sim_set_logon (int32 flag, CONST char *cptr);
t_stat sim_set_logoff (int32 flag, CONST char *cptr);
int32 sim_set_deb_switches (int32 switches);
t_stat sim_set_debon (int32 flag, CONST char *cptr);
t_stat sim_set_cons_debug (int32 flg, CONST char *cptr);
t_stat sim_set_cons_buff (int32 flg, CONST char *cptr);

View File

@@ -650,7 +650,8 @@ struct UNIT {
#define UNIT_NO_FIO 0000004 /* fileref is NOT a FILE * */
#define UNIT_DISK_CHK 0000010 /* disk data debug checking (sim_disk) */
#define UNIT_TMR_UNIT 0000020 /* Unit registered as a calibrated timer */
#define UNIT_V_DF_TAPE 6 /* Bit offset for Tape Density reservation */
#define UNIT_TAPE_MRK 0000040 /* Tape Unit AWS Tapemark */
#define UNIT_V_DF_TAPE 7 /* Bit offset for Tape Density reservation */
#define UNIT_S_DF_TAPE 3 /* Bits Reserved for Tape Density */
struct BITFIELD {

View File

@@ -41,7 +41,7 @@
sim_finit - initialize package
sim_fopen - open file
sim_fread - endian independent read (formerly fxread)
sim_write - endian independent write (formerly fxwrite)
sim_fwrite - endian independent write (formerly fxwrite)
sim_fseek - conditionally extended (>32b) seek (
sim_fseeko - extended seek (>32b if available)
sim_fsize - get file size
@@ -205,9 +205,11 @@ t_offset pos, sz;
if (fp == NULL)
return 0;
pos = sim_ftell (fp);
sim_fseeko (fp, 0, SEEK_END);
if (sim_fseeko (fp, 0, SEEK_END))
return 0;
sz = sim_ftell (fp);
sim_fseeko (fp, pos, SEEK_SET);
if (sim_fseeko (fp, pos, SEEK_SET))
return 0;
return sz;
}

File diff suppressed because it is too large Load Diff

View File

@@ -63,6 +63,10 @@ typedef uint32 t_mtrlnt; /* magtape rec lnt */
typedef uint16 t_tpclnt; /* magtape rec lnt */
#define TPC_TMK 0x0000 /* tape mark */
#define TPC_EOM 0xFFFF /* end of medium */
/* P7B tape format */
#define P7B_SOR 0x80 /* start of record */
@@ -71,7 +75,15 @@ typedef uint16 t_tpclnt; /* magtape rec lnt */
#define P7B_DPAR (P7B_PAR|P7B_DATA) /* data and parity */
#define P7B_EOF 0x0F /* eof character */
#define TPC_TMK 0x0000 /* tape mark */
/* AWS tape format */
typedef uint16 t_awslnt; /* magtape rec lnt */
typedef struct {
t_awslnt nxtlen;
t_awslnt prelen;
t_awslnt rectyp;
#define AWS_TMK 0x0040
#define AWS_REC 0x00A0
} t_awshdr;
/* Unit flags */
@@ -85,7 +97,7 @@ typedef uint16 t_tpclnt; /* magtape rec lnt */
#define MTUF_F_E11 1 /* E11 format */
#define MTUF_F_TPC 2 /* TPC format */
#define MTUF_F_P7B 3 /* P7B format */
#define MUTF_F_TDF 4 /* TDF format */
#define MTUF_F_AWS 4 /* AWS format */
#define MTUF_V_UF (MTUF_V_FMT + MTUF_W_FMT)
#define MTUF_PNU (1u << MTUF_V_PNU)
#define MTUF_WLK (1u << MTUF_V_WLK)
@@ -96,11 +108,14 @@ typedef uint16 t_tpclnt; /* magtape rec lnt */
#define MT_F_E11 (MTUF_F_E11 << MTUF_V_FMT)
#define MT_F_TPC (MTUF_F_TPC << MTUF_V_FMT)
#define MT_F_P7B (MTUF_F_P7B << MTUF_V_FMT)
#define MT_F_TDF (MTUF_F_TDF << MTUF_V_FMT)
#define MT_F_AWS (MTUF_F_AWS << MTUF_V_FMT)
#define MT_SET_PNU(u) (u)->flags = (u)->flags | MTUF_PNU
#define MT_CLR_PNU(u) (u)->flags = (u)->flags & ~MTUF_PNU
#define MT_TST_PNU(u) ((u)->flags & MTUF_PNU)
#define MT_SET_INMRK(u) (u)->dynflags = (u)->dynflags | UNIT_TAPE_MRK
#define MT_CLR_INMRK(u) (u)->dynflags = (u)->dynflags & ~UNIT_TAPE_MRK
#define MT_TST_INMRK(u) ((u)->dynflags & UNIT_TAPE_MRK)
#define MT_GET_FMT(u) (((u)->flags >> MTUF_V_FMT) & MTUF_M_FMT)
/* sim_tape_position Position Flags */
@@ -146,11 +161,13 @@ typedef uint16 t_tpclnt; /* magtape rec lnt */
#define MTSE_WRP 9 /* write protected */
#define MTSE_LEOT 10 /* Logical End Of Tape */
#define MTSE_RUNAWAY 11 /* tape runaway */
#define MTSE_MAX_ERR 11
typedef void (*TAPE_PCALLBACK)(UNIT *unit, t_stat status);
/* Tape Internal Debug flags */
#define MTSE_DBG_API 0x10000000 /* API Trace */
#define MTSE_DBG_DAT 0x20000000 /* Debug Data */
#define MTSE_DBG_POS 0x40000000 /* Debug Positioning activities */
#define MTSE_DBG_STR 0x80000000 /* Debug Tape Structure */
@@ -210,6 +227,7 @@ t_stat sim_tape_show_dens (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
t_stat sim_tape_set_asynch (UNIT *uptr, int latency);
t_stat sim_tape_clr_asynch (UNIT *uptr);
t_stat sim_tape_test (DEVICE *dptr);
t_stat sim_tape_add_debug (DEVICE *dptr);
#ifdef __cplusplus
}

View File

@@ -3913,7 +3913,7 @@ static DEBTAB tmxr_debug[] = {
t_stat tmxr_add_debug (DEVICE *dptr)
{
if (!(dptr->flags & DEV_MUX))
if (DEV_TYPE(dptr) != DEV_MUX)
return SCPE_OK;
return sim_add_debug_flags (dptr, tmxr_debug);
}