1
0
mirror of https://github.com/simh/simh.git synced 2026-01-25 11:46:37 +00:00

VAX & VAX780 Generalized setting TODR for all OSes.

Unbound the TODR value from the 100hz clock tick interrupt.  TODR now behaves like the original battery backed-up clock and runs with the wall clock, not the simulated instruction clock (except when running ROM diagnostics).

Two operational modes are available:
    - Default VMS mode, which is similar to the previous
      behavior in that without initializing the TODR it
      would default to the value VMS would set it to if
      VMS knew the correct time.  This would be correct
      almost all the time unless a VMS disk hadn't been
      booted from for more than a year.  This mode
      produces strange time results for non VMS OSes on
      each system boot.
    - OS Agnostic mode.  This mode behaves precisely like
      the VAX780 TODR and works correctly for all OSes.
      This mode is enabled by attaching the TODR to a
      battery backup state file for the TOY clock
      (i.e. sim> attach TODR TOY_CLOCK).  When operating
      in OS Agnostic mode, the TODR will initially start
      counting from 0 and be adjusted differently when an
      OS specifically writes to the TODR.  VMS will prompt
      to set the time on the initial boot unless the SYSGEN
      parameter TIMEPROMPTWAIT is set to 0.
This commit is contained in:
Mark Pizzolato
2011-09-28 15:05:07 -07:00
parent 3ae8a42dae
commit 5687f9227b
4 changed files with 314 additions and 66 deletions

View File

@@ -152,8 +152,7 @@ return sim_os_msec () - stime;
}
#if defined(SIM_ASYNCH_IO)
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 1
#ifdef NEED_CLOCK_REALTIME
int clock_gettime(int clk_id, struct timespec *tp)
{
uint32 secs, ns, tod[2], unixbase[2] = {0xd53e8000, 0x019db1de};
@@ -225,12 +224,13 @@ Sleep (msec);
return sim_os_msec () - stime;
}
#if !defined(CLOCK_REALTIME) && defined (SIM_ASYNCH_IO)
#define CLOCK_REALTIME 1
#if defined(NEED_CLOCK_REALTIME)
int clock_gettime(int clk_id, struct timespec *tp)
{
t_uint64 now, unixbase;
if (clk_id != CLOCK_REALTIME)
return -1;
unixbase = 116444736;
unixbase *= 1000000000;
GetSystemTimeAsFileTime((FILETIME*)&now);
@@ -315,8 +315,7 @@ treq.tv_nsec = (milliseconds % MILLIS_PER_SEC) * NANOS_PER_MILLI;
return sim_os_msec () - stime;
}
#if !defined(CLOCK_REALTIME) && defined (SIM_ASYNCH_IO)
#define CLOCK_REALTIME 1
#if defined(NEED_CLOCK_REALTIME)
int clock_gettime(int clk_id, struct timespec *tp)
{
struct timeval cur;
@@ -377,8 +376,7 @@ if (tim > SIM_IDLE_MAX)
return tim;
}
#if !defined(_POSIX_SOURCE) && defined(SIM_ASYNCH_IO)
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 1
#ifdef NEED_CLOCK_REALTIME
typedef int clockid_t;
int clock_gettime(clockid_t clk_id, struct timespec *tp)
{
@@ -408,6 +406,21 @@ return sim_os_msec () - stime;
#endif
/* diff = min - sub */
void
sim_timespec_diff (struct timespec *diff, struct timespec *min, struct timespec *sub)
{
/* move the minuend value to the difference and operate there. */
*diff = *min;
/* Borrow as needed for the nsec value */
if (sub->tv_nsec > min->tv_nsec) {
--diff->tv_sec;
diff->tv_nsec += 1000000000;
}
diff->tv_nsec -= sub->tv_nsec;
diff->tv_sec -= sub->tv_sec;
}
#if defined(SIM_ASYNCH_IO)
uint32 sim_idle_ms_sleep (unsigned int msec)
{