/[gxemul]/trunk/src/devices/dev_lpt.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_lpt.c

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

revision 41 by dpavlin, Mon Oct 8 16:22:11 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_lpt.c,v 1.11 2007/04/20 11:17:24 debug Exp $   *  $Id: dev_lpt.c,v 1.14 2007/06/15 19:11:15 debug Exp $
29   *   *
30   *  LPT (parallel printer) controller.   *  COMMENT: LPT (parallel printer) controller
31   */   */
32    
33  #include <stdio.h>  #include <stdio.h>
# Line 37  Line 37 
37  #include "console.h"  #include "console.h"
38  #include "cpu.h"  #include "cpu.h"
39  #include "device.h"  #include "device.h"
40    #include "interrupt.h"
41  #include "machine.h"  #include "machine.h"
42  #include "memory.h"  #include "memory.h"
43  #include "misc.h"  #include "misc.h"
# Line 50  Line 51 
51  #define DEV_LPT_LENGTH          3  #define DEV_LPT_LENGTH          3
52    
53  struct lpt_data {  struct lpt_data {
54          int             irqnr;          char                    *name;
55          char            *name;          struct interrupt        irq;
56          int             console_handle;          int                     console_handle;
57    
58          unsigned char   data;          uint8_t                 data;
59          unsigned char   control;          uint8_t                 control;
60  };  };
61    
62    
# Line 111  DEVICE_ACCESS(lpt) Line 112  DEVICE_ACCESS(lpt)
112    
113  DEVINIT(lpt)  DEVINIT(lpt)
114  {  {
115          struct lpt_data *d = malloc(sizeof(struct lpt_data));          struct lpt_data *d;
116          size_t nlen;          size_t nlen;
117          char *name;          char *name;
118    
119          if (d == NULL) {          CHECK_ALLOCATION(d = malloc(sizeof(struct lpt_data)));
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
120          memset(d, 0, sizeof(struct lpt_data));          memset(d, 0, sizeof(struct lpt_data));
121          d->irqnr        = devinit->irq_nr;  
122            INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
123    
124          d->name         = devinit->name2 != NULL? devinit->name2 : "";          d->name         = devinit->name2 != NULL? devinit->name2 : "";
125          d->console_handle = console_start_slave(devinit->machine, devinit->name,          d->console_handle = console_start_slave(devinit->machine, devinit->name,
126              CONSOLE_OUTPUT_ONLY);              CONSOLE_OUTPUT_ONLY);
# Line 128  DEVINIT(lpt) Line 128  DEVINIT(lpt)
128          nlen = strlen(devinit->name) + 10;          nlen = strlen(devinit->name) + 10;
129          if (devinit->name2 != NULL)          if (devinit->name2 != NULL)
130                  nlen += strlen(devinit->name2);                  nlen += strlen(devinit->name2);
131          name = malloc(nlen);          CHECK_ALLOCATION(name = malloc(nlen));
         if (name == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
132          if (devinit->name2 != NULL && devinit->name2[0])          if (devinit->name2 != NULL && devinit->name2[0])
133                  snprintf(name, nlen, "%s [%s]", devinit->name, devinit->name2);                  snprintf(name, nlen, "%s [%s]", devinit->name, devinit->name2);
134          else          else
# Line 141  DEVINIT(lpt) Line 137  DEVINIT(lpt)
137          memory_device_register(devinit->machine->memory, name, devinit->addr,          memory_device_register(devinit->machine->memory, name, devinit->addr,
138              DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL);              DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL);
139          machine_add_tickfunction(devinit->machine, dev_lpt_tick, d,          machine_add_tickfunction(devinit->machine, dev_lpt_tick, d,
140              TICK_SHIFT, 0.0);              TICK_SHIFT);
141    
142          /*          /*
143           *  NOTE:  Ugly cast into a pointer, because this is a convenient way           *  NOTE:  Ugly cast into a pointer, because this is a convenient way

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

  ViewVC Help
Powered by ViewVC 1.1.26