/[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 9 by dpavlin, Mon Oct 8 16:18:19 2007 UTC revision 10 by dpavlin, Mon Oct 8 16:18:27 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_cons.c,v 1.25 2005/06/11 21:04:31 debug Exp $   *  $Id: dev_cons.c,v 1.26 2005/06/26 11:43:48 debug Exp $
29   *     *  
30   *  A console device.  (Fake, only useful for simple tests.)   *  A console device.  (Fake, only useful for simple tests.)
31   *  It is hardwared to the lowest available MIPS hardware IRQ, and only   *  It is hardwared to the lowest available MIPS hardware IRQ, and only
# Line 126  int dev_cons_init(struct machine *machin Line 126  int dev_cons_init(struct machine *machin
126  {  {
127          struct cons_data *d;          struct cons_data *d;
128          char *name2;          char *name2;
129            size_t nlen;
130    
131          d = malloc(sizeof(struct cons_data));          d = malloc(sizeof(struct cons_data));
132          if (d == NULL) {          if (d == NULL) {
# Line 136  int dev_cons_init(struct machine *machin Line 137  int dev_cons_init(struct machine *machin
137          d->irq_nr = irq_nr;          d->irq_nr = irq_nr;
138          d->console_handle = console_start_slave(machine, name);          d->console_handle = console_start_slave(machine, name);
139    
140          name2 = malloc(strlen(name) + 20);          nlen = strlen(name) + 20;
141            name2 = malloc(nlen);
142          if (name2 == NULL) {          if (name2 == NULL) {
143                  fprintf(stderr, "out of memory in dev_cons_init()\n");                  fprintf(stderr, "out of memory in dev_cons_init()\n");
144                  exit(1);                  exit(1);
145          }          }
146          if (name != NULL && name[0])          if (name != NULL && name[0])
147                  sprintf(name2, "cons [%s]", name);                  snprintf(name2, nlen, "cons [%s]", name);
148          else          else
149                  sprintf(name2, "cons");                  snprintf(name2, nlen, "cons");
150    
151          memory_device_register(mem, name2, baseaddr, DEV_CONS_LENGTH,          memory_device_register(mem, name2, baseaddr, DEV_CONS_LENGTH,
152              dev_cons_access, d, MEM_DEFAULT, NULL);              dev_cons_access, d, MEM_DEFAULT, NULL);

Legend:
Removed from v.9  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26