mirror of
https://github.com/rcornwell/sims.git
synced 2026-01-18 09:03:11 +00:00
IBM360: Fixed some Coverity errors.
This commit is contained in:
parent
9e308e97e9
commit
4b2db13cca
@ -9,8 +9,7 @@ DOS/360: Will initialize disk.
|
||||
Assembly aborts with invalid instruction.
|
||||
|
||||
OS/360: Will initialize disk.
|
||||
Will not restore disk.
|
||||
(Restore overwrites interupt table during load).
|
||||
Will restore disk (with timer disabled)..
|
||||
Will start to IPL OS/360
|
||||
|
||||
ibm360_cpu.c:
|
||||
|
||||
@ -293,6 +293,8 @@ chan_read_byte(uint16 addr, uint8 *data) {
|
||||
int k;
|
||||
|
||||
/* Abort if we have any errors */
|
||||
if (chan < 0)
|
||||
return 1;
|
||||
if (chan_status[chan] & 0x7f)
|
||||
return 1;
|
||||
if ((ccw_cmd[chan] & 0x1) == 0) {
|
||||
@ -347,6 +349,8 @@ chan_write_byte(uint16 addr, uint8 *data) {
|
||||
uint32 mask;
|
||||
|
||||
/* Abort if we have any errors */
|
||||
if (chan < 0)
|
||||
return 1;
|
||||
if (chan_status[chan] & 0x7f)
|
||||
return 1;
|
||||
if ((ccw_cmd[chan] & 0x1) != 0) {
|
||||
@ -441,6 +445,8 @@ void
|
||||
set_devattn(uint16 addr, uint8 flags) {
|
||||
int chan = find_subchan(addr);
|
||||
|
||||
if (chan < 0)
|
||||
return;
|
||||
if (chan_dev[chan] == addr && (chan_status[chan] & STATUS_CEND) != 0 &&
|
||||
(flags & SNS_DEVEND) != 0) {
|
||||
chan_status[chan] |= ((uint16)flags) << 8;
|
||||
@ -455,6 +461,9 @@ void
|
||||
chan_end(uint16 addr, uint8 flags) {
|
||||
int chan = find_subchan(addr);
|
||||
|
||||
if (chan < 0)
|
||||
return;
|
||||
|
||||
if (chan_byte[chan] & BUFF_DIRTY) {
|
||||
int k;
|
||||
writefull(chan, ccw_addr[chan], &chan_buf[chan]);
|
||||
@ -507,10 +516,10 @@ int startio(uint16 addr) {
|
||||
UNIT *uptr;
|
||||
uint8 status;
|
||||
|
||||
sim_debug(DEBUG_CMD, &cpu_dev, "SIO %x %x %x %x\n", addr, chan,
|
||||
ccw_cmd[chan], ccw_flags[chan]);
|
||||
if (chan < 0 || dibp == 0)
|
||||
return 3;
|
||||
sim_debug(DEBUG_CMD, &cpu_dev, "SIO %x %x %x %x\n", addr, chan,
|
||||
ccw_cmd[chan], ccw_flags[chan]);
|
||||
uptr = find_chan_dev(addr);
|
||||
if (uptr == 0)
|
||||
return 3;
|
||||
@ -610,17 +619,17 @@ int haltio(uint16 addr) {
|
||||
}
|
||||
if (dibp->halt_io != NULL)
|
||||
chan_status[chan] = dibp->halt_io(uptr) << 8;
|
||||
if (chan_status[chan] & (STATUS_ATTN|STATUS_PCI|STATUS_EXPT|STATUS_CHECK|
|
||||
STATUS_PROT|STATUS_CDATA|STATUS_CCNTL|STATUS_INTER|
|
||||
STATUS_CHAIN))
|
||||
return 0;
|
||||
// if (chan_status[chan] & (STATUS_ATTN|STATUS_PCI|STATUS_EXPT|STATUS_CHECK|
|
||||
// STATUS_PROT|STATUS_CDATA|STATUS_CCNTL|STATUS_INTER|
|
||||
// STATUS_CHAIN))
|
||||
// return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int testchan(uint16 channel) {
|
||||
uint16 st = 0;
|
||||
channel >>= 8;
|
||||
if (channel = 0)
|
||||
if (channel == 0)
|
||||
return 0;
|
||||
if (channel > channels)
|
||||
return 3;
|
||||
@ -705,23 +714,24 @@ uint16 scan_chan(uint8 mask) {
|
||||
if (pend) {
|
||||
irq_pend = 1;
|
||||
i = find_subchan(pend);
|
||||
sim_debug(DEBUG_EXP, &cpu_dev, "Scan end (%x %x)\n", chan_dev[i],
|
||||
pend);
|
||||
store_csw(i);
|
||||
if (i >= 0) {
|
||||
sim_debug(DEBUG_EXP, &cpu_dev, "Scan end (%x %x)\n", chan_dev[i], pend);
|
||||
store_csw(i);
|
||||
}
|
||||
dev_status[pend] = 0;
|
||||
} else {
|
||||
for (i = 0; i < MAX_DEV; i++) {
|
||||
if (dev_status[i] != 0) {
|
||||
pend = find_subchan(i);
|
||||
if (ccw_cmd[pend] == 0 && mask & (0x80 >> (i >> 8))) {
|
||||
for (pend = 0; pend < MAX_DEV; pend++) {
|
||||
if (dev_status[pend] != 0) {
|
||||
i = find_subchan(pend);
|
||||
if (i >= 0 && ccw_cmd[i] == 0 && mask & (0x80 >> (pend >> 8))) {
|
||||
irq_pend = 1;
|
||||
M[0x44 >> 2] = (((uint32)dev_status[i]) << 24);
|
||||
M[0x44 >> 2] = (((uint32)dev_status[pend]) << 24);
|
||||
M[0x40>>2] = 0;
|
||||
sim_debug(DEBUG_EXP, &cpu_dev,
|
||||
"Set atten %03x %02x [%08x] %08x\n",
|
||||
i, dev_status[i], M[0x40 >> 2], M[0x44 >> 2]);
|
||||
dev_status[i] = 0;
|
||||
return i;
|
||||
i, dev_status[pend], M[0x40 >> 2], M[0x44 >> 2]);
|
||||
dev_status[pend] = 0;
|
||||
return pend;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -803,7 +813,7 @@ set_dev_addr(UNIT * uptr, int32 val, CONST char *cptr, void *desc)
|
||||
if ((newdev >> 8) > channels)
|
||||
return SCPE_ARG;
|
||||
|
||||
if (newdev > MAX_DEV)
|
||||
if (newdev >= MAX_DEV)
|
||||
return SCPE_ARG;
|
||||
|
||||
devaddr = GET_UADDR(uptr->u3);
|
||||
|
||||
@ -150,7 +150,7 @@ t_bool build_dev_tab (void);
|
||||
/* Interval timer option */
|
||||
t_stat rtc_srv(UNIT * uptr);
|
||||
t_stat rtc_reset(DEVICE * dptr);
|
||||
int32 rtc_tps = 120;
|
||||
int32 rtc_tps = 60;
|
||||
|
||||
|
||||
/* CPU data structures
|
||||
@ -204,7 +204,7 @@ MTAB cpu_mod[] = {
|
||||
{ FEAT_UNIV, FEAT_UNIV, NULL, "UNIV", NULL, NULL, NULL, "Universal instruction"},
|
||||
{ FEAT_STOR, 0, NULL, "NOSTORE", NULL, NULL, NULL},
|
||||
{ FEAT_STOR, FEAT_STOR, "STORE", "DECIMAL", NULL, NULL, NULL, "No storage alignment"},
|
||||
{ FEAT_TIMER, 0, "NOTIMER", NULL, NULL, NULL},
|
||||
{ FEAT_TIMER, 0, NULL, "NOTIMER", NULL, NULL},
|
||||
{ FEAT_TIMER, FEAT_TIMER, "TIMER", "TIMER", NULL, NULL, NULL, "Interval timer"},
|
||||
{ EXT_IRQ, 0, "NOEXT", NULL, NULL, NULL},
|
||||
{ EXT_IRQ, EXT_IRQ, "EXT", "EXT", NULL, NULL, NULL, "External Irq"},
|
||||
@ -417,9 +417,9 @@ int WriteByte(uint32 addr, uint32 data) {
|
||||
storepsw(OPPSW, IRC_ADDR);
|
||||
return 1;
|
||||
}
|
||||
// if ((addr & 0xfffff0) == 0xc90 && data == 0x40) {
|
||||
// fprintf(stderr, "Error byte\n\r");
|
||||
// }
|
||||
if ((addr & 0xfffff0) == 0xc90 && data == 0x40) {
|
||||
fprintf(stderr, "Error byte\n\r");
|
||||
}
|
||||
|
||||
offset = 8 * (3 - (addr & 0x3));
|
||||
addr >>= 2;
|
||||
@ -1647,7 +1647,8 @@ save_dbl:
|
||||
|
||||
case OP_ED:
|
||||
case OP_EDMK:
|
||||
ReadByte(addr1, &src1);
|
||||
if (ReadByte(addr1, &src1))
|
||||
break;
|
||||
fill = src1;
|
||||
addr1++;
|
||||
src2 = 0;
|
||||
@ -1656,10 +1657,12 @@ save_dbl:
|
||||
while(reg != 0) {
|
||||
uint8 t;
|
||||
uint32 temp;
|
||||
(void)ReadByte(addr1, &temp);
|
||||
if (ReadByte(addr1, &temp))
|
||||
break;
|
||||
t = temp;
|
||||
if (src1) {
|
||||
(void)ReadByte(addr2, &dest);
|
||||
if (ReadByte(addr2, &dest))
|
||||
break;
|
||||
addr2--;
|
||||
reg --;
|
||||
}
|
||||
@ -1682,11 +1685,13 @@ save_dbl:
|
||||
cc = 2;
|
||||
} else
|
||||
t = fill;
|
||||
WriteByte(addr1, t);
|
||||
if (WriteByte(addr1, t))
|
||||
break;
|
||||
} else if (t == 0x22) {
|
||||
src2 = 0;
|
||||
t = fill;
|
||||
WriteByte(addr1, t);
|
||||
if (WriteByte(addr1, t))
|
||||
break;
|
||||
}
|
||||
addr1--;
|
||||
reg --;
|
||||
|
||||
@ -192,8 +192,8 @@ struct dasd_t
|
||||
struct disk_t
|
||||
{
|
||||
char *name; /* Type Name */
|
||||
int cyl; /* Number of cylinders */
|
||||
int heads; /* Number of heads/cylinder */
|
||||
unsigned int cyl; /* Number of cylinders */
|
||||
unsigned int heads; /* Number of heads/cylinder */
|
||||
unsigned int bpt; /* Max bytes per track */
|
||||
uint8 dev_type; /* Device type code */
|
||||
}
|
||||
@ -362,6 +362,8 @@ uint8 dasd_startcmd(UNIT *uptr, uint16 chan, uint8 cmd) {
|
||||
case 0x3: /* Control */
|
||||
if ((cmd & 0xfc) == 0 || cmd == DK_RELEASE)
|
||||
return SNS_CHNEND|SNS_DEVEND;
|
||||
/* Fall Through */
|
||||
|
||||
case 0x1: /* Write command */
|
||||
case 0x2: /* Read command */
|
||||
uptr->u3 &= ~(DK_PARAM);
|
||||
@ -401,17 +403,17 @@ t_stat dasd_srv(UNIT * uptr)
|
||||
|
||||
/* Check if read or write command, if so grab correct cylinder */
|
||||
if (rd && data->cyl != data->ccyl) {
|
||||
int tsize = data->tsize * disk_type[type].heads;
|
||||
uint32 tsize = data->tsize * disk_type[type].heads;
|
||||
if (uptr->u3 & DK_CYL_DIRTY) {
|
||||
sim_fseek(uptr->fileref, data->cpos, SEEK_SET);
|
||||
sim_fwrite(data->cbuf, 1, tsize, uptr->fileref);
|
||||
(void)sim_fseek(uptr->fileref, data->cpos, SEEK_SET);
|
||||
(void)sim_fwrite(data->cbuf, 1, tsize, uptr->fileref);
|
||||
uptr->u3 &= ~DK_CYL_DIRTY;
|
||||
}
|
||||
data->ccyl = data->cyl;
|
||||
sim_debug(DEBUG_DETAIL, dptr, "Load unit=%d cyl=%d\n", unit, data->cyl);
|
||||
sim_debug(DEBUG_DETAIL, dptr, "Load unit=%d cyl=%d\n", unit, data->cyl);
|
||||
data->cpos = sizeof(struct dasd_header) + (data->ccyl * tsize);
|
||||
sim_fseek(uptr->fileref, data->cpos, SEEK_SET);
|
||||
sim_fread(data->cbuf, 1, tsize, uptr->fileref);
|
||||
(void)sim_fseek(uptr->fileref, data->cpos, SEEK_SET);
|
||||
(void)sim_fread(data->cbuf, 1, tsize, uptr->fileref);
|
||||
}
|
||||
sim_debug(DEBUG_POS, dptr, "state unit=%d %02x %d\n", unit, state, data->tpos);
|
||||
|
||||
@ -426,7 +428,7 @@ t_stat dasd_srv(UNIT * uptr)
|
||||
/* Read and multi-track advance to next head */
|
||||
if ((uptr->u3 & 0x83) == 0x82) {
|
||||
sim_debug(DEBUG_DETAIL, dptr, "adv head unit=%d %02x %d %d\n", unit, state,
|
||||
data->tpos, uptr->u4 && 0xff);
|
||||
data->tpos, uptr->u4 & 0xff);
|
||||
uptr->u4 ++;
|
||||
if ((uptr->u3 & 0x7) == 1 && (uptr->u3 & 0x60) != 0)
|
||||
uptr->u3 &= ~DK_INDEX;
|
||||
@ -1324,7 +1326,7 @@ dasd_format(UNIT * uptr) {
|
||||
return 1;
|
||||
}
|
||||
memset(&hdr, 0, sizeof(struct dasd_header));
|
||||
strncpy(&hdr.devid[0], "CKD_P370", 8);
|
||||
memcpy(&hdr.devid[0], "CKD_P370", 8);
|
||||
hdr.heads = disk_type[type].heads;
|
||||
hdr.tracksize = (disk_type[type].bpt | 0x1ff) + 1;
|
||||
hdr.devtype = disk_type[type].dev_type;
|
||||
@ -1370,8 +1372,6 @@ dasd_format(UNIT * uptr) {
|
||||
data->cpos = sizeof(struct dasd_header);
|
||||
data->ccyl = 0;
|
||||
data->ccyl = 0;
|
||||
// data->cyl = 2000;
|
||||
// data->state = DK_POS_SEEK;
|
||||
set_devattn(addr, SNS_DEVEND);
|
||||
sim_activate(uptr, 100);
|
||||
fputc('\n', stderr);
|
||||
@ -1434,12 +1434,10 @@ dasd_attach(UNIT * uptr, CONST char *file)
|
||||
detach_unit(uptr);
|
||||
return SCPE_ARG;
|
||||
}
|
||||
sim_fseek(uptr->fileref, sizeof(struct dasd_header), SEEK_SET);
|
||||
sim_fread(data->cbuf, 1, tsize, uptr->fileref);
|
||||
(void)sim_fseek(uptr->fileref, sizeof(struct dasd_header), SEEK_SET);
|
||||
(void)sim_fread(data->cbuf, 1, tsize, uptr->fileref);
|
||||
data->cpos = sizeof(struct dasd_header);
|
||||
data->ccyl = 0;
|
||||
// data->cyl = 2000;
|
||||
// data->state = DK_POS_SEEK;
|
||||
set_devattn(addr, SNS_DEVEND);
|
||||
sim_activate(uptr, 100);
|
||||
return SCPE_OK;
|
||||
@ -1452,8 +1450,9 @@ dasd_detach(UNIT * uptr)
|
||||
int type = GET_TYPE(uptr->flags);
|
||||
|
||||
if (uptr->u3 & DK_CYL_DIRTY) {
|
||||
sim_fseek(uptr->fileref, data->cpos, SEEK_SET);
|
||||
sim_fwrite(data->cbuf, 1, data->tsize * disk_type[type].heads, uptr->fileref);
|
||||
(void)sim_fseek(uptr->fileref, data->cpos, SEEK_SET);
|
||||
(void)sim_fwrite(data->cbuf, 1,
|
||||
data->tsize * disk_type[type].heads, uptr->fileref);
|
||||
uptr->u3 &= ~DK_CYL_DIRTY;
|
||||
}
|
||||
if (data != 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user