/[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 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 40 by dpavlin, Mon Oct 8 16:22:11 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: dev_lpt.c,v 1.5 2005/11/13 00:14:09 debug Exp $   *  $Id: dev_lpt.c,v 1.11 2007/04/20 11:17:24 debug Exp $
29   *   *
30   *  LPT (parallel printer) controller.   *  LPT (parallel printer) controller.
31   */   */
# Line 50  Line 50 
50  #define DEV_LPT_LENGTH          3  #define DEV_LPT_LENGTH          3
51    
52  struct lpt_data {  struct lpt_data {
         int             in_use;  
53          int             irqnr;          int             irqnr;
54          char            *name;          char            *name;
55          int             console_handle;          int             console_handle;
# Line 60  struct lpt_data { Line 59  struct lpt_data {
59  };  };
60    
61    
62  /*  DEVICE_TICK(lpt)
  *  dev_lpt_tick():  
  */  
 void dev_lpt_tick(struct cpu *cpu, void *extra)  
63  {  {
64          /*  struct lpt_data *d = extra;  */          /*  struct lpt_data *d = extra;  */
65    
# Line 71  void dev_lpt_tick(struct cpu *cpu, void Line 67  void dev_lpt_tick(struct cpu *cpu, void
67  }  }
68    
69    
70  /*  DEVICE_ACCESS(lpt)
  *  dev_lpt_access():  
  */  
 int dev_lpt_access(struct cpu *cpu, struct memory *mem,  
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
71  {  {
72          uint64_t idata = 0, odata=0;          uint64_t idata = 0, odata=0;
73          struct lpt_data *d = extra;          struct lpt_data *d = extra;
# Line 118  int dev_lpt_access(struct cpu *cpu, stru Line 109  int dev_lpt_access(struct cpu *cpu, stru
109  }  }
110    
111    
112  /*  DEVINIT(lpt)
  *  devinit_lpt():  
  */  
 int devinit_lpt(struct devinit *devinit)  
113  {  {
114          struct lpt_data *d = malloc(sizeof(struct lpt_data));          struct lpt_data *d = malloc(sizeof(struct lpt_data));
115          size_t nlen;          size_t nlen;
# Line 133  int devinit_lpt(struct devinit *devinit) Line 121  int devinit_lpt(struct devinit *devinit)
121          }          }
122          memset(d, 0, sizeof(struct lpt_data));          memset(d, 0, sizeof(struct lpt_data));
123          d->irqnr        = devinit->irq_nr;          d->irqnr        = devinit->irq_nr;
         d->in_use       = devinit->in_use;  
124          d->name         = devinit->name2 != NULL? devinit->name2 : "";          d->name         = devinit->name2 != NULL? devinit->name2 : "";
125          d->console_handle =          d->console_handle = console_start_slave(devinit->machine, devinit->name,
126              console_start_slave(devinit->machine, devinit->name);              CONSOLE_OUTPUT_ONLY);
127    
128          nlen = strlen(devinit->name) + 10;          nlen = strlen(devinit->name) + 10;
129          if (devinit->name2 != NULL)          if (devinit->name2 != NULL)
# Line 153  int devinit_lpt(struct devinit *devinit) Line 140  int devinit_lpt(struct devinit *devinit)
140    
141          memory_device_register(devinit->machine->memory, name, devinit->addr,          memory_device_register(devinit->machine->memory, name, devinit->addr,
142              DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL);              DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL);
143          machine_add_tickfunction(devinit->machine, dev_lpt_tick, d, TICK_SHIFT);          machine_add_tickfunction(devinit->machine, dev_lpt_tick, d,
144                TICK_SHIFT, 0.0);
145    
146          /*          /*
147           *  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.20  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26