PCem

changeset 158:153d673e767a

Implemented RTC update interrupt, fixes hang on startup on RedHat Seawolf (and probably some other Linux distros)
author TomW
date Wed Sep 17 21:50:57 2014 +0100
parents cf4453f069ba
children 7dbd14c4adac
files src/nvr.c
diffstat 1 files changed, 23 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/nvr.c	Mon Sep 15 15:07:48 2014 +0100
     1.2 +++ b/src/nvr.c	Wed Sep 17 21:50:57 2014 +0100
     1.3 @@ -12,6 +12,8 @@
     1.4  
     1.5  int nvr_dosave = 0;
     1.6  
     1.7 +static int nvr_onesec_time = 0, nvr_onesec_cnt = 0;
     1.8 +
     1.9  void getnvrtime()
    1.10  {
    1.11  	time_get(nvrram);
    1.12 @@ -26,7 +28,7 @@
    1.13          if (rtctime>newrtctime) rtctime=newrtctime;
    1.14  }
    1.15  
    1.16 -void nvr_rtc()
    1.17 +void nvr_rtc(void *p)
    1.18  {
    1.19          int c;
    1.20          if (!(nvrram[0xA]&0xF))
    1.21 @@ -37,7 +39,7 @@
    1.22          c=1<<((nvrram[0xA]&0xF)-1);
    1.23          rtctime += (int)(RTCCONST * c * (1 << TIMER_SHIFT));
    1.24  //        pclog("RTCtime now %f\n",rtctime);
    1.25 -        nvrram[0xC]=0x40;
    1.26 +        nvrram[0xC] |= 0x40;
    1.27          if (nvrram[0xB]&0x40)
    1.28          {
    1.29                  nvrram[0xC]|=0x80;
    1.30 @@ -47,6 +49,24 @@
    1.31          }
    1.32  }
    1.33  
    1.34 +void nvr_onesec(void *p)
    1.35 +{
    1.36 +        nvr_onesec_cnt++;
    1.37 +        if (nvr_onesec_cnt >= 100)
    1.38 +        {
    1.39 +                nvr_onesec_cnt = 0;
    1.40 +                nvrram[0xC] |= 0x10;
    1.41 +                if (nvrram[0xB] & 0x10)
    1.42 +                {
    1.43 +                        nvrram[0xC] |= 0x80;
    1.44 +                        if (AMSTRAD) picint(2);
    1.45 +                        else         picint(0x100);
    1.46 +                }
    1.47 +//                pclog("RTC onesec\n");
    1.48 +        }
    1.49 +        nvr_onesec_time += (int)(10000 * TIMER_USEC);
    1.50 +}
    1.51 +
    1.52  void writenvr(uint16_t addr, uint8_t val, void *priv)
    1.53  {
    1.54          int c;
    1.55 @@ -175,4 +195,5 @@
    1.56  {
    1.57          io_sethandler(0x0070, 0x0002, readnvr, NULL, NULL, writenvr, NULL, NULL,  NULL);
    1.58          timer_add(nvr_rtc, &rtctime, TIMER_ALWAYS_ENABLED, NULL);
    1.59 +        timer_add(nvr_onesec, &nvr_onesec_time, TIMER_ALWAYS_ENABLED, NULL);
    1.60  }