/[gxemul]/trunk/src/devices/dev_cons.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_cons.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_cons.c,v 1.40 2007/02/03 20:14:23 debug Exp $   *  $Id: dev_cons.c,v 1.42 2007/06/15 18:44:19 debug Exp $
29   *     *  
30   *  A simple console device, useful for simple tests.   *  COMMENT: A simple console device, for the test machines
31   *   *
32   *  This device provides memory mapped I/O for a simple console supporting   *  This device provides memory mapped I/O for a simple console supporting
33   *  putchar (writing to memory) and getchar (reading from memory), and   *  putchar (writing to memory) and getchar (reading from memory), and
# Line 61  DEVICE_TICK(cons) Line 61  DEVICE_TICK(cons)
61  {  {
62          struct cons_data *d = extra;          struct cons_data *d = extra;
63    
         INTERRUPT_DEASSERT(d->irq);  
   
64          if (console_charavail(d->console_handle))          if (console_charavail(d->console_handle))
65                  INTERRUPT_ASSERT(d->irq);                  INTERRUPT_ASSERT(d->irq);
66            else
67                    INTERRUPT_DEASSERT(d->irq);
68  }  }
69    
70    
# Line 118  DEVINIT(cons) Line 118  DEVINIT(cons)
118          char *name3;          char *name3;
119          size_t nlen;          size_t nlen;
120    
121          d = malloc(sizeof(struct cons_data));          CHECK_ALLOCATION(d = malloc(sizeof(struct cons_data)));
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
122          memset(d, 0, sizeof(struct cons_data));          memset(d, 0, sizeof(struct cons_data));
123    
124          nlen = strlen(devinit->name) + 10;          nlen = strlen(devinit->name) + 10;
125          if (devinit->name2 != NULL)          if (devinit->name2 != NULL)
126                  nlen += strlen(devinit->name2) + 10;                  nlen += strlen(devinit->name2) + 10;
127          name3 = malloc(nlen);          CHECK_ALLOCATION(name3 = malloc(nlen));
         if (name3 == NULL) {  
                 fprintf(stderr, "out of memory in dev_cons_init()\n");  
                 exit(1);  
         }  
128          if (devinit->name2 != NULL && devinit->name2[0])          if (devinit->name2 != NULL && devinit->name2[0])
129                  snprintf(name3, nlen, "%s [%s]", devinit->name, devinit->name2);                  snprintf(name3, nlen, "%s [%s]", devinit->name, devinit->name2);
130          else          else
# Line 148  DEVINIT(cons) Line 140  DEVINIT(cons)
140              devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,              devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,
141              DM_DEFAULT, NULL);              DM_DEFAULT, NULL);
142          machine_add_tickfunction(devinit->machine, dev_cons_tick,          machine_add_tickfunction(devinit->machine, dev_cons_tick,
143              d, CONS_TICK_SHIFT, 0.0);              d, CONS_TICK_SHIFT);
144    
145          /*  NOTE: Ugly cast into pointer  */          /*  NOTE: Ugly cast into pointer  */
146          devinit->return_ptr = (void *)(size_t)d->console_handle;          devinit->return_ptr = (void *)(size_t)d->console_handle;

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

  ViewVC Help
Powered by ViewVC 1.1.26