mirror of
https://github.com/rcornwell/sims.git
synced 2026-02-25 16:30:32 +00:00
Cleanup for compile without ITS or BBN options.
Cleanup of interrupt handling.
Floating point code now passes random instruction tests with
minor off by +/-1 in lower half of long add/subtract instructions.
RP10 proper handling of not ready flag.
RP10 no seek interrupts while read/write to other drive.
TM10 Clean up off by one bits in upper status.
TM10 Added MT_LASTWD flag to indicate read of last word.
TM10 Proper handling of Record length error.
TM10 Added EOR flag.
TM10 Rewind at BOT now Illegal operation.
TM10A return channel flags as 1 rather then 0.
RH10/disk Handle reset CONO flag.
RH10/disk Generate parity on register read.
RH10/disk No registers can be modified other then attention when
one drive is doing read/write operation.
RH10/disk write register 0 without GO update command.
RH10/disk command to unready drive return RMR error.
RH10/disk Search/seek to invalid CHS returns immediate error.
RH10/RP06 write to error 2 and 3 registers work.
RH10/disk no seek interrupts set when other drive read/write.
121 lines
3.8 KiB
C
121 lines
3.8 KiB
C
/* ka10_pd.c: DeCoriolis clock.
|
||
|
||
Copyright (c) 2018, Lars Brinkhoff
|
||
|
||
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
|
||
RICHARD CORNWELL 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.
|
||
|
||
This is a device which keeps track of the time and date. An access
|
||
will return the number of ticks since the beginning of the year.
|
||
There are 60 ticks per second. The device was made by Paul
|
||
DeCoriolis at MIT.
|
||
|
||
When used with a KL10, the clock was part of the KL-UDGE board
|
||
which could also provide a 60 Hz interrupt and set console lights.
|
||
This is not needed on a KA10, so it's not implemented here.
|
||
|
||
*/
|
||
|
||
#include <time.h>
|
||
#include "ka10_defs.h"
|
||
|
||
#define PD_DEVNUM 0500
|
||
#define PD_OFF (1 << DEV_V_UF)
|
||
|
||
t_stat pd_devio(uint32 dev, uint64 *data);
|
||
const char *pd_description (DEVICE *dptr);
|
||
t_stat pd_set_on(UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||
t_stat pd_set_off(UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||
t_stat pd_show_on(FILE *st, UNIT *uptr, int32 val, CONST void *desc);
|
||
|
||
UNIT pd_unit[] = {
|
||
{UDATA(NULL, UNIT_DISABLE, 0)}, /* 0 */
|
||
};
|
||
DIB pd_dib = {PD_DEVNUM, 1, &pd_devio, NULL};
|
||
|
||
MTAB pd_mod[] = {
|
||
{ MTAB_VDV, 0, "ON", "ON", pd_set_on, pd_show_on },
|
||
{ MTAB_VDV, PD_OFF, NULL, "OFF", pd_set_off },
|
||
{ 0 }
|
||
};
|
||
|
||
DEVICE pd_dev = {
|
||
"PD", pd_unit, NULL, pd_mod,
|
||
1, 8, 0, 1, 8, 36,
|
||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||
&pd_dib, DEV_DISABLE | DEV_DIS | DEV_DEBUG, 0, NULL,
|
||
NULL, NULL, NULL, NULL, NULL, &pd_description
|
||
};
|
||
|
||
static uint64 pd_ticks (void)
|
||
{
|
||
time_t t = time(NULL);
|
||
struct tm *x = localtime(&t);
|
||
uint64 seconds;
|
||
seconds = 86400ULL * x->tm_yday;
|
||
seconds += 3600ULL * x->tm_hour;
|
||
seconds += 60ULL * x->tm_min;
|
||
seconds += x->tm_sec;
|
||
// We could add individual ticks here, but there's no pressing need.
|
||
return 60ULL * seconds;
|
||
}
|
||
|
||
t_stat pd_devio(uint32 dev, uint64 *data)
|
||
{
|
||
DEVICE *dptr = &pd_dev;
|
||
|
||
switch(dev & 07) {
|
||
case DATAI:
|
||
if (dptr->flags & PD_OFF)
|
||
*data = 0;
|
||
else
|
||
*data = pd_ticks();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
return SCPE_OK;
|
||
}
|
||
|
||
const char *pd_description (DEVICE *dptr)
|
||
{
|
||
return "Paul DeCoriolis clock";
|
||
}
|
||
|
||
t_stat pd_set_on(UNIT *uptr, int32 val, CONST char *cptr, void *desc)
|
||
{
|
||
DEVICE *dptr = &pd_dev;
|
||
dptr->flags &= ~PD_OFF;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat pd_set_off(UNIT *uptr, int32 val, CONST char *cptr, void *desc)
|
||
{
|
||
DEVICE *dptr = &pd_dev;
|
||
dptr->flags |= PD_OFF;
|
||
return SCPE_OK;
|
||
}
|
||
|
||
t_stat pd_show_on(FILE *st, UNIT *uptr, int32 val, CONST void *desc)
|
||
{
|
||
DEVICE *dptr = &pd_dev;
|
||
fprintf (st, "%s", (dptr->flags & PD_OFF) ? "off" : "on");
|
||
return SCPE_OK;
|
||
}
|
||
|