/[gxemul]/trunk/src/devices/dev_ns16550.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_ns16550.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_ns16550.c,v 1.58 2006/12/30 13:30:58 debug Exp $   *  $Id: dev_ns16550.c,v 1.62 2007/06/15 19:57:33 debug Exp $
29   *     *  
30   *  NS16550 serial controller.   *  COMMENT: NS16550 serial controller
  *  
31   *   *
32   *  TODO: Implement the FIFO.   *  TODO: Implement the FIFO.
33   */   */
# Line 322  DEVICE_ACCESS(ns16550) Line 321  DEVICE_ACCESS(ns16550)
321    
322  DEVINIT(ns16550)  DEVINIT(ns16550)
323  {  {
324          struct ns_data *d = malloc(sizeof(struct ns_data));          struct ns_data *d;
325          size_t nlen;          size_t nlen;
326          char *name;          char *name;
327    
328          if (d == NULL) {          CHECK_ALLOCATION(d = malloc(sizeof(struct ns_data)));
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
329          memset(d, 0, sizeof(struct ns_data));          memset(d, 0, sizeof(struct ns_data));
330    
331          d->addrmult     = devinit->addr_mult;          d->addrmult     = devinit->addr_mult;
# Line 350  DEVINIT(ns16550) Line 346  DEVINIT(ns16550)
346          nlen = strlen(devinit->name) + 10;          nlen = strlen(devinit->name) + 10;
347          if (devinit->name2 != NULL)          if (devinit->name2 != NULL)
348                  nlen += strlen(devinit->name2);                  nlen += strlen(devinit->name2);
349          name = malloc(nlen);          CHECK_ALLOCATION(name = malloc(nlen));
         if (name == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
350          if (devinit->name2 != NULL && devinit->name2[0])          if (devinit->name2 != NULL && devinit->name2[0])
351                  snprintf(name, nlen, "%s [%s]", devinit->name, devinit->name2);                  snprintf(name, nlen, "%s [%s]", devinit->name, devinit->name2);
352          else          else
# Line 364  DEVINIT(ns16550) Line 356  DEVINIT(ns16550)
356              DEV_NS16550_LENGTH * d->addrmult, dev_ns16550_access, d,              DEV_NS16550_LENGTH * d->addrmult, dev_ns16550_access, d,
357              DM_DEFAULT, NULL);              DM_DEFAULT, NULL);
358          machine_add_tickfunction(devinit->machine,          machine_add_tickfunction(devinit->machine,
359              dev_ns16550_tick, d, TICK_SHIFT, 0.0);              dev_ns16550_tick, d, TICK_SHIFT);
360    
361          /*          /*
362           *  NOTE:  Ugly cast into a pointer, because this is a convenient way           *  NOTE:  Ugly cast into a pointer, because this is a convenient way
363           *         to return the console handle to code in src/machine.c.           *         to return the console handle to code in src/machines/.
364           */           */
365          devinit->return_ptr = (void *)(size_t)d->console_handle;          devinit->return_ptr = (void *)(size_t)d->console_handle;
366    

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

  ViewVC Help
Powered by ViewVC 1.1.26