1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-01-11 23:52:48 +00:00

SCP: Updated to current.

This commit is contained in:
Richard Cornwell 2020-10-12 23:27:08 -04:00
parent ea38a90c29
commit bb03b35bab
6 changed files with 44 additions and 29 deletions

36
scp.c
View File

@ -654,6 +654,7 @@ static t_bool sim_if_cmd_last[MAX_DO_NEST_LVL+1];
static t_bool sim_if_result[MAX_DO_NEST_LVL+1];
static t_bool sim_if_result_last[MAX_DO_NEST_LVL+1];
static t_bool sim_cptr_is_action[MAX_DO_NEST_LVL+1];
static DEVICE *sim_failed_reset_dptr = NULL;
t_stat sim_last_cmd_stat; /* Command Status */
struct timespec cmd_time; /* */
@ -2688,7 +2689,7 @@ for (i = 1; i < argc; i++) { /* loop thru args */
if (get_switches (argv[i], &sw, NULL) == SW_ERROR) {
fprintf (stderr, "Invalid switch %s\n", argv[i]);
free (targv);
return 0;
return EXIT_FAILURE;
}
sim_switches = sim_switches | sw;
}
@ -2696,7 +2697,7 @@ for (i = 1; i < argc; i++) { /* loop thru args */
if ((strlen (argv[i]) + strlen (cbuf) + 3) >= sizeof(cbuf)) {
fprintf (stderr, "Argument string too long\n");
free (targv);
return 0;
return EXIT_FAILURE;
}
if (*cbuf) /* concat args */
strlcat (cbuf, " ", sizeof (cbuf));
@ -2740,6 +2741,7 @@ if (sim_timer_init ()) {
fprintf (stderr, "Fatal timer initialization error\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
sim_register_internal_device (&sim_scp_dev);
@ -2753,21 +2755,24 @@ if ((stat = sim_ttinit ()) != SCPE_OK) {
sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
if ((sim_eval = (t_value *) calloc (sim_emax, sizeof (t_value))) == NULL) {
fprintf (stderr, "Unable to allocate examine buffer\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
};
if (sim_dflt_dev == NULL) /* if no default */
sim_dflt_dev = sim_devices[0];
if ((stat = reset_all_p (0)) != SCPE_OK) {
fprintf (stderr, "Fatal simulator initialization error\n%s\n",
sim_error_text (stat));
fprintf (stderr, "Fatal simulator initialization error\nDevice %s initial reset call returned: %s\n",
sim_failed_reset_dptr->name, sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
if (register_check) {
@ -2778,17 +2783,21 @@ if (register_check) {
sim_printf ("Simulator device register sanity check error\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
sim_printf ("*** Good Registers in %s simulator.\n", sim_name);
if (argc < 2) /* No remaining command arguments? */
if (argc < 2) { /* No remaining command arguments? */
free (targv);
return EXIT_SUCCESS; /* then we're done */
}
}
if ((stat = sim_brk_init ()) != SCPE_OK) {
fprintf (stderr, "Fatal breakpoint table initialization error\n%s\n",
sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
/* always check for register definition problems */
@ -2866,7 +2875,7 @@ return sim_exit_status;
t_stat process_stdin_commands (t_stat stat, char *argv[], t_bool do_called)
{
char cbuf[4*CBUFSIZE], gbuf[CBUFSIZE];
CONST char *cptr;
CONST char *cptr = NULL;
t_stat stat_nomessage;
CTAB *cmdp = NULL;
@ -4638,12 +4647,12 @@ t_stat assert_cmd (int32 flag, CONST char *cptr)
char gbuf[CBUFSIZE], gbuf2[CBUFSIZE];
CONST char *tptr, *gptr;
REG *rptr;
uint32 idx;
uint32 idx = 0;
t_stat r;
t_bool Not = FALSE;
t_bool Exist = FALSE;
t_bool result;
t_addr addr;
t_addr addr = 0;
t_stat reason;
cptr = (CONST char *)get_sim_opt (CMD_OPT_SW|CMD_OPT_DFT, (CONST char *)cptr, &r);
@ -4770,7 +4779,8 @@ else {
return SCPE_ARG;
gptr = tptr; /* update */
}
else idx = 0; /* not array */
else
idx = 0; /* not array */
if (idx >= rptr->depth) /* validate subscript */
return SCPE_SUB;
}
@ -7303,8 +7313,10 @@ for (i = start; (dptr = sim_devices[i]) != NULL; i++) {
}
if (dptr->reset != NULL) {
reason = dptr->reset (dptr);
if (reason != SCPE_OK)
if (reason != SCPE_OK) {
sim_failed_reset_dptr = dptr;
return reason;
}
}
}
for (i = 0; sim_internal_device_count && (dptr = sim_internal_devices[i]); ++i) {
@ -10794,7 +10806,7 @@ SCHTAB *get_asearch (CONST char *cptr, int32 radix, SCHTAB *schptr)
{
int32 c, logop, cmpop;
t_value *logval, *cmpval;
t_stat reason;
t_stat reason = SCPE_OK;
CONST char *ocptr = cptr;
const char *sptr;
char gbuf[CBUFSIZE];
@ -12653,7 +12665,7 @@ return SCPE_OK;
t_stat sim_exp_check (EXPECT *exp, uint8 data)
{
int32 i;
EXPTAB *ep;
EXPTAB *ep = NULL;
int regex_checks = 0;
char *tstr = NULL;

4
scp.h
View File

@ -339,8 +339,8 @@ void sim_debug_unit (uint32 dbits, UNIT* uptr, const char *fmt, ...) GCC_FMT_ATT
#else
void _sim_debug_unit (uint32 dbits, UNIT *uptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4);
void _sim_debug_device (uint32 dbits, DEVICE* dptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4);
#define sim_debug(dbits, dptr, ...) do { if (sim_deb && dptr && ((dptr)->dctrl & (dbits))) _sim_debug_device (dbits, dptr, __VA_ARGS__);} while (0)
#define sim_debug_unit(dbits, uptr, ...) do { if (sim_deb && uptr && (((uptr)->dctrl | (uptr)->dptr->dctrl) & (dbits))) _sim_debug_unit (dbits, uptr, __VA_ARGS__);} while (0)
#define sim_debug(dbits, dptr, ...) do { if ((sim_deb != NULL) && ((dptr) != NULL) && ((dptr)->dctrl & (dbits))) _sim_debug_device (dbits, dptr, __VA_ARGS__);} while (0)
#define sim_debug_unit(dbits, uptr, ...) do { if ((sim_deb != NULL) && ((uptr) != NULL) && (((uptr)->dctrl | (uptr)->dptr->dctrl) & (dbits))) _sim_debug_unit (dbits, uptr, __VA_ARGS__);} while (0)
#endif
void sim_flush_buffered_files (void);

View File

@ -2049,7 +2049,7 @@ else
return sim_messagef (SCPE_INVREM, "Can't enable Remote Console Master mode with Remote Console disabled\n");
if (sim_rem_master_mode) {
t_stat stat_nomessage;
t_stat stat_nomessage = 0;
sim_messagef (SCPE_OK, "Command input starting on Master Remote Console Session\n");
stat = sim_run_boot_prep (0);
@ -2291,7 +2291,7 @@ t_stat sim_set_debon (int32 flag, CONST char *cptr)
char gbuf[CBUFSIZE];
t_stat r;
time_t now;
size_t buffer_size;
size_t buffer_size = 0;
if ((cptr == NULL) || (*cptr == 0)) /* need arg */
return SCPE_2FARG;

View File

@ -1671,7 +1671,6 @@ return SCPE_IOERR;
static t_stat rstsLoadAndScanSATT(rstsContext *context, uint16 uaa, uint16 uar, t_offset *result)
{
t_offset blocks = 0;
uint8 bitmap[8192];
int i, j;
RSTS_ACNT acnt;
@ -2080,7 +2079,8 @@ switch (DK_GET_FMT (uptr)) { /* case on format */
/* Construct a pseudo simh disk footer*/
memcpy (f->Signature, "simh", 4);
strncpy ((char *)f->DriveType, sim_vhd_disk_get_dtype (uptr->fileref, &f->SectorSize, &f->TransferElementSize, (char *)f->CreatingSimulator, &creation_time), sizeof (f->DriveType) - 1);
memset (f->DriveType, 0, sizeof (f->DriveType));
strlcpy ((char *)f->DriveType, sim_vhd_disk_get_dtype (uptr->fileref, &f->SectorSize, &f->TransferElementSize, (char *)f->CreatingSimulator, &creation_time), sizeof (f->DriveType));
f->SectorSize = NtoHl (f->SectorSize);
f->TransferElementSize = NtoHl (f->TransferElementSize);
if ((f->SectorSize == 0) || (NtoHl (f->SectorSize) == 0x00020000)) { /* Old or mangled format VHD footer */
@ -2089,7 +2089,8 @@ switch (DK_GET_FMT (uptr)) { /* case on format */
f->SectorSize = NtoHl (f->SectorSize);
f->TransferElementSize = NtoHl (f->TransferElementSize);
}
strncpy ((char*)f->CreationTime, ctime (&creation_time), sizeof (f->CreationTime) - 1);
memset (f->CreationTime, 0, sizeof (f->CreationTime));
strlcpy ((char*)f->CreationTime, ctime (&creation_time), sizeof (f->CreationTime));
container_size = sim_vhd_disk_size (uptr->fileref);
f->SectorCount = NtoHl ((uint32)(container_size / NtoHl (f->SectorSize)));
container_size += sizeof (*f); /* Adjust since it is removed below */
@ -2146,12 +2147,15 @@ f = (struct simh_disk_footer *)calloc (1, sizeof (*f));
f->AccessFormat = DK_GET_FMT (uptr);
total_sectors = (((t_offset)uptr->capac) * ctx->capac_factor * ((dptr->flags & DEV_SECTORS) ? 512 : 1)) / ctx->sector_size;
memcpy (f->Signature, "simh", 4);
strncpy ((char *)f->CreatingSimulator, sim_name, sizeof (f->CreatingSimulator) - 1);
strncpy ((char *)f->DriveType, dtype, sizeof (f->DriveType) - 1);
memset (f->CreatingSimulator, 0, sizeof (f->CreatingSimulator));
strlcpy ((char *)f->CreatingSimulator, sim_name, sizeof (f->CreatingSimulator));
memset (f->DriveType, 0, sizeof (f->DriveType));
strlcpy ((char *)f->DriveType, dtype, sizeof (f->DriveType));
f->SectorSize = NtoHl (ctx->sector_size);
f->SectorCount = NtoHl ((uint32)total_sectors);
f->TransferElementSize = NtoHl (ctx->xfer_element_size);
strncpy ((char*)f->CreationTime, ctime (&now), sizeof (f->CreationTime) - 1);
memset (f->CreationTime, 0, sizeof (f->CreationTime));
strlcpy ((char*)f->CreationTime, ctime (&now), sizeof (f->CreationTime));
f->Checksum = NtoHl (eth_crc32 (0, f, sizeof (*f) - sizeof (f->Checksum)));
free (ctx->footer);
ctx->footer = f;
@ -2528,7 +2532,7 @@ if ((DK_GET_FMT (uptr) == DKUF_F_VHD) || (ctx->footer)) {
if (ctx->footer) {
sector_size = NtoHl (ctx->footer->SectorSize);
xfer_element_size = NtoHl (ctx->footer->TransferElementSize);
strncpy (created_name, (char *)ctx->footer->CreatingSimulator, sizeof (created_name));
strlcpy (created_name, (char *)ctx->footer->CreatingSimulator, sizeof (created_name));
}
if ((DK_GET_FMT (uptr) == DKUF_F_VHD) && created && dtype) {
sim_vhd_disk_set_dtype (uptr->fileref, dtype, ctx->sector_size, ctx->xfer_element_size);
@ -4736,7 +4740,9 @@ memset (hVHD->Footer.DriveType, '\0', sizeof hVHD->Footer.DriveType);
memcpy (hVHD->Footer.DriveType, dtype, ((1+strlen (dtype)) < sizeof (hVHD->Footer.DriveType)) ? (1+strlen (dtype)) : sizeof (hVHD->Footer.DriveType));
hVHD->Footer.DriveSectorSize = NtoHl (SectorSize);
hVHD->Footer.DriveTransferElementSize = NtoHl (xfer_element_size);
strncpy ((char *)hVHD->Footer.CreatingSimulator, sim_name, sizeof (hVHD->Footer.CreatingSimulator) - 1);
hVHD->Footer.CreatingSimulator[sizeof (hVHD->Footer.CreatingSimulator) - 1] = '\0'; /* Force NUL termination */
memset (hVHD->Footer.CreatingSimulator, 0, sizeof (hVHD->Footer.CreatingSimulator));
strlcpy ((char *)hVHD->Footer.CreatingSimulator, sim_name, sizeof (hVHD->Footer.CreatingSimulator));
hVHD->Footer.Checksum = 0;
hVHD->Footer.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Footer, sizeof(hVHD->Footer)));

View File

@ -1908,7 +1908,7 @@ static void *
_eth_writer(void *arg)
{
ETH_DEV* volatile dev = (ETH_DEV*)arg;
ETH_WRITE_REQUEST *request;
ETH_WRITE_REQUEST *request = NULL;
/* Boost Priority for this I/O thread vs the CPU instruction execution
thread which in general won't be readily yielding the processor when
@ -4272,7 +4272,6 @@ ETH_MAC filter_address[3] = {
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
};
int addr_count;
ETH_MAC physical_addr = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
ETH_MAC host_nic_phy_hw_addr = {0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
ETH_MAC *host_phy_addr_list[2] = {&host_nic_phy_hw_addr, NULL};
int host_phy_addr_listindex;

View File

@ -992,9 +992,7 @@ if (dir) {
#endif
t_offset FileSize;
char *FileName;
const char *MatchName = 1 + strrchr (cptr, '/');
char *p_name;
struct tm *local;
char *p_name;
#if defined (HAVE_GLOB)
size_t i;
#endif