/[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 41 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_rtc.c,v 1.5 2006/12/30 13:30:59 debug Exp $   *  $Id: dev_rtc.c,v 1.7 2007/06/15 19:57:34 debug Exp $
29   *   *
30   *  An experimental Real-Time Clock device. It can be used to retrieve the   *  COMMENT: A generic Real-Time Clock device, for the test machines
31   *  current system time, and to cause periodic interrupts.   *
32     *  It can be used to retrieve the current system time, and to cause periodic
33     *  interrupts.
34   */   */
35    
36  #include <stdio.h>  #include <stdio.h>
# Line 74  static void timer_tick(struct timer *t, Line 76  static void timer_tick(struct timer *t,
76    
77  DEVICE_TICK(rtc)  DEVICE_TICK(rtc)
78  {    {  
79          struct rtc_data *d = (struct rtc_data *) extra;          struct rtc_data *d = extra;
80    
81          if (d->pending_interrupts > 0)          if (d->pending_interrupts > 0)
82                  INTERRUPT_ASSERT(d->irq);                  INTERRUPT_ASSERT(d->irq);
# Line 85  DEVICE_TICK(rtc) Line 87  DEVICE_TICK(rtc)
87    
88  DEVICE_ACCESS(rtc)  DEVICE_ACCESS(rtc)
89  {  {
90          struct rtc_data *d = (struct rtc_data *) extra;          struct rtc_data *d = extra;
91          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
92    
93          if (writeflag == MEM_WRITE)          if (writeflag == MEM_WRITE)
# Line 159  DEVICE_ACCESS(rtc) Line 161  DEVICE_ACCESS(rtc)
161    
162  DEVINIT(rtc)  DEVINIT(rtc)
163  {  {
164          struct rtc_data *d = malloc(sizeof(struct rtc_data));          struct rtc_data *d;
165    
166          if (d == NULL) {          CHECK_ALLOCATION(d = malloc(sizeof(struct rtc_data)));
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
167          memset(d, 0, sizeof(struct rtc_data));          memset(d, 0, sizeof(struct rtc_data));
168    
169          INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);          INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
# Line 174  DEVINIT(rtc) Line 173  DEVINIT(rtc)
173              DM_DEFAULT, NULL);              DM_DEFAULT, NULL);
174    
175          machine_add_tickfunction(devinit->machine,          machine_add_tickfunction(devinit->machine,
176              dev_rtc_tick, d, DEV_RTC_TICK_SHIFT, 0.0);              dev_rtc_tick, d, DEV_RTC_TICK_SHIFT);
177    
178          return 1;          return 1;
179  }  }

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26