/[gxemul]/trunk/src/devices/dev_rtc.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/devices/dev_rtc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 33 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2006-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_rtc.c,v 1.3 2006/10/14 23:46:17 debug Exp $   *  $Id: dev_rtc.c,v 1.5 2006/12/30 13:30:59 debug Exp $
29   *   *
30   *  An experimental Real-Time Clock device. It can be used to retrieve the   *  An experimental Real-Time Clock device. It can be used to retrieve the
31   *  current system time, and to cause periodic interrupts.   *  current system time, and to cause periodic interrupts.
# Line 50  Line 50 
50  #define DEV_RTC_TICK_SHIFT      14  #define DEV_RTC_TICK_SHIFT      14
51    
52  struct rtc_data {  struct rtc_data {
53          int             hz;          struct interrupt        irq;
54          int             irq_nr;          int                     pending_interrupts;
         int             pending_interrupts;  
         struct timer    *timer;  
55    
56          struct timeval  cur_time;                int                     hz;
57            struct timer            *timer;
58    
59            struct timeval          cur_time;      
60  };  };
61    
62    
# Line 76  DEVICE_TICK(rtc) Line 77  DEVICE_TICK(rtc)
77          struct rtc_data *d = (struct rtc_data *) extra;          struct rtc_data *d = (struct rtc_data *) extra;
78    
79          if (d->pending_interrupts > 0)          if (d->pending_interrupts > 0)
80                  cpu_interrupt(cpu, d->irq_nr);                  INTERRUPT_ASSERT(d->irq);
81          else          else
82                  cpu_interrupt_ack(cpu, d->irq_nr);                  INTERRUPT_DEASSERT(d->irq);
83  }  }
84    
85    
# Line 132  DEVICE_ACCESS(rtc) Line 133  DEVICE_ACCESS(rtc)
133                  if (d->pending_interrupts > 0)                  if (d->pending_interrupts > 0)
134                          d->pending_interrupts --;                          d->pending_interrupts --;
135    
136                  cpu_interrupt_ack(cpu, d->irq_nr);                  INTERRUPT_DEASSERT(d->irq);
137    
138                  /*  TODO: Reassert the interrupt here, if                  /*  TODO: Reassert the interrupt here, if
139                      d->pending_interrupts is still above zero?  */                      d->pending_interrupts is still above zero?  */
# Line 165  DEVINIT(rtc) Line 166  DEVINIT(rtc)
166                  exit(1);                  exit(1);
167          }          }
168          memset(d, 0, sizeof(struct rtc_data));          memset(d, 0, sizeof(struct rtc_data));
169          d->irq_nr = devinit->irq_nr;  
170            INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
171    
172          memory_device_register(devinit->machine->memory, devinit->name,          memory_device_register(devinit->machine->memory, devinit->name,
173              devinit->addr, DEV_RTC_LENGTH, dev_rtc_access, (void *)d,              devinit->addr, DEV_RTC_LENGTH, dev_rtc_access, (void *)d,

Legend:
Removed from v.33  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26