Beispiel #1
0
static void rtc_alarm_check (void)
{
  static u_char last_sec = 0xff; /* any invalid value to begin with */
  u_char h0,m0,s0,h,m,s;

  s0=GET_CMOS(CMOS_SEC);
  m0=GET_CMOS(CMOS_MIN);
  h0=GET_CMOS(CMOS_HOUR);

  /* this is a test for equality - we can't just call a lib time
   * function because a second could be skipped */
  h = GET_CMOS(CMOS_HOURALRM);
  if (h>=0xc0 || h0==h) {      /* Eric: all c0-ff are don't care */
    m = GET_CMOS(CMOS_MINALRM);
    if (m>=0xc0 || m0==m) {
      s = GET_CMOS(CMOS_SECALRM);
      if (s>=0xc0 || (s0==s && s0!=last_sec)) {
        last_sec = s0;
        h_printf("RTC: got alarm at %02d:%02d:%02d\n",h,m,s);
        SET_CMOS(CMOS_STATUSC, GET_CMOS(CMOS_STATUSC) | 0x20);
        if ((GET_CMOS(CMOS_STATUSB) & 0x20) && !(GET_CMOS(CMOS_STATUSC) & 0x80)) {
	  SET_CMOS(CMOS_STATUSC, GET_CMOS(CMOS_STATUSC) | 0x80);
          h_printf("RTC: alarm IRQ\n");
	  pic_request(PIC_IRQ8);
        }
      }
    }
  }
}
Beispiel #2
0
void rtc_run(void)
{
  static hitimer_t last_time = -1;
  int rate;
  hitimer_t ticks_m, cur_time = GETusTIME(0);
  if (last_time == -1 || last_time > cur_time) {
    last_time = cur_time;
    return;
  }
  rate = rtc_get_rate(GET_CMOS(CMOS_STATUSA) & 0x0f);
  ticks_m = (cur_time - last_time) * rate;
  q_ticks_m += ticks_m;
  last_time = cur_time;
  if (debug_level('h') > 8)
    h_printf("RTC: A=%hhx B=%hhx C=%hhx rate=%i queued=%lli added=%lli\n",
	GET_CMOS(CMOS_STATUSA), GET_CMOS(CMOS_STATUSB), GET_CMOS(CMOS_STATUSC),
	rate, (long long)q_ticks_m, (long long)ticks_m);
  if (q_ticks_m >= 1000000) {
    Bit8u old_c = GET_CMOS(CMOS_STATUSC);
    SET_CMOS(CMOS_STATUSC, old_c | 0x40);
    if ((GET_CMOS(CMOS_STATUSB) & 0x40) && !(GET_CMOS(CMOS_STATUSC) & 0x80)) {
      SET_CMOS(CMOS_STATUSC, GET_CMOS(CMOS_STATUSC) | 0x80);
      if (debug_level('h') > 7)
        h_printf("RTC: periodic IRQ, queued=%lli, added=%lli\n",
	    (long long)q_ticks_m, (long long)ticks_m);
      pic_request(PIC_IRQ8);
    }
    if (!(old_c & 0x40))
      q_ticks_m -= 1000000;
  }
}
Beispiel #3
0
void AESTimerTick(void)
{
  ipx_socket_t *mysock;
  AESECB_t *ECB;

  /* run through the socket list, and process any pending AES events */
  mysock = ipx_socket_list;
  while (mysock) {
    /* see if this socket has any AES events pending */
    ECB = FARt_PTR(mysock->AESList);
    while (ECB) {
      if (ECB->TimeLeft > 0) {
	ECB->TimeLeft--;
	n_printf("IPX: AES timer decremented to %d on ECB at %p\n",
		 ECB->TimeLeft, ECB);
	if (ECB->TimeLeft == 0) {
	  /* now setup to call the ESR for this event */
	  pic_request(PIC_IPX_AES);
	  return;
	}
      }
      ECB = FARt_PTR(ECB->Link);
    }
    mysock = mysock->next;
  }
}
Beispiel #4
0
/* DANG_BEGIN_FUNCTION pic_activate
 *
 * pic_activate requests any interrupts whose scheduled time has arrived.
 * anything after pic_dos_time and before pic_sys_time is activated.
 * pic_dos_time is advanced to the earliest time scheduled.
 * DANG_END_FUNCTION
 */
static void pic_activate(void)
{
  hitimer_t earliest;
  int timer, count;
  unsigned pic_newirr = pic_pirr & ~(pic_irr | pic_isr);
  pic_irr |= pic_newirr;
  pic_pirr &= ~pic_newirr;

/*if(pic_irr&~pic_imr) return;*/
   earliest = pic_sys_time;
   count = 0;
   for (timer=0; timer<32; ++timer) {
      if ((pic_itime[timer] != NEVER) && (pic_itime[timer] < pic_sys_time)) {
         if (pic_itime[timer] != pic_ltime[timer]) {
               if ((earliest == NEVER) || (pic_itime[timer] < earliest))
                    earliest = pic_itime[timer];
               pic_request(timer);
               ++count;
         }
      }
   }
   if(count) pic_print(2,"Activated ",count, " interrupts.");
   pic_print2(2,"Activate ++ dos time to ",earliest, " ");
   pic_print2(2,"pic_sys_time is ",pic_sys_time," ");
   /*if(!pic_icount)*/ pic_dos_time = pic_itime[32] = earliest;
}
Beispiel #5
0
/* write byte to the 8042's output buffer */
void output_byte_8042(Bit8u value) {
   port60_buffer=value;
   port60_ready=1;
   if (keyb_ctrl_command & 0x01) {    /* if interrupt enabled */
      k_printf("8042: scheduling IRQ1\n");
      pic_request(PIC_IRQ1);
   }
   else
      k_printf("8042: interrupt flag OFF!\n");
}
Beispiel #6
0
static inline int process_interrupt(SillyG_t *sg)
{
  int irq, ret=0;

  if ((irq = sg->irq) != 0) {
    h_printf("INTERRUPT: 0x%02x\n", irq);
    ret=(pic_request(pic_irq_list[irq])!=PIC_REQ_LOST);
  }
  return ret;
}
Beispiel #7
0
void rtc_update (void)	/* called every 1s from SIGALRM */
{
  u_char h0,m0,s0,D0,M0,Y0,C0,days;
  static const u_char dpm[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  if (GET_CMOS(CMOS_STATUSA) & 0x80)
    error("RTC: A/UIP set on update\n");

  if (GET_CMOS(CMOS_STATUSB) & 0x80) {
    h_printf("RTC updates inhibited\n");
    return;
  }

  SET_CMOS(CMOS_STATUSA, GET_CMOS(CMOS_STATUSA)|0x80);
  s0=GET_CMOS(CMOS_SEC);
  m0=GET_CMOS(CMOS_MIN);
  h0=GET_CMOS(CMOS_HOUR);
  D0=GET_CMOS(CMOS_DOM);
  M0=GET_CMOS(CMOS_MONTH);
  Y0=GET_CMOS(CMOS_YEAR);
  C0=GET_CMOS(CMOS_CENTURY);

  if ((++s0)>59) {
    s0=0;
    if ((++m0)>59) {
      m0=0;
      if ((++h0)>23) {
       h0=0;

       /* Compute days in current month. */
       if (M0>12 || M0<1) M0=1;    /* Error! */
       days = dpm[M0];
       if ((Y0&3) == 0 && M0 == 2) days++; /* Leap year & Feb */

       if (++D0>days) {
        D0=1;
        if (++M0>12) {
         M0=1;
         if (++Y0>99) {
          Y0=0;
          ++C0;   /* Only 19->20 transition realistic. */
          SET_CMOS(CMOS_CENTURY, C0);
         }
         SET_CMOS(CMOS_YEAR, Y0);
        }
        SET_CMOS(CMOS_MONTH, M0);
       }
       SET_CMOS(CMOS_DOM, D0);

       /* As well as day-of-month, do day-of-week */
       days=GET_CMOS(CMOS_DOW);
       days++;
       if(days > 7 || days < 1) days=1;
       SET_CMOS(CMOS_DOW, days);
      }
      SET_CMOS(CMOS_HOUR, h0);
    }
    SET_CMOS(CMOS_MIN, m0);
  }
  SET_CMOS(CMOS_SEC, s0);

  h_printf("RTC: cmos update %02d:%02d:%02d, B=%#x\n",h0,m0,s0,GET_CMOS(CMOS_STATUSB));

  rtc_alarm_check();

  /* per-second IRQ */
  SET_CMOS(CMOS_STATUSC, GET_CMOS(CMOS_STATUSC) | 0x10);
  if ((GET_CMOS(CMOS_STATUSB) & 0x10) && !(GET_CMOS(CMOS_STATUSC) & 0x80)) {
    SET_CMOS(CMOS_STATUSC, GET_CMOS(CMOS_STATUSC) | 0x80);
    h_printf("RTC: update IRQ\n");
    pic_request(PIC_IRQ8);
  }

  SET_CMOS(CMOS_STATUSA, GET_CMOS(CMOS_STATUSA)&~0x80);
}
Beispiel #8
0
static void ipx_async_callback(void *arg)
{
  n_printf("IPX: requesting receiver IRQ\n");
  pic_request(PIC_IPX);
}