/[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 18 by dpavlin, Mon Oct 8 16:19:11 2007 UTC revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: dev_lpt.c,v 1.2 2005/10/26 14:37:04 debug Exp $   *  $Id: dev_lpt.c,v 1.5 2005/11/13 00:14:09 debug Exp $
29   *   *
30   *  LPT (parallel printer) controller.   *  LPT (parallel printer) controller.
  *  
  *  TODO: This is just a dummy.  
31   */   */
32    
33  #include <stdio.h>  #include <stdio.h>
# Line 43  Line 41 
41  #include "memory.h"  #include "memory.h"
42  #include "misc.h"  #include "misc.h"
43    
44    #include "lptreg.h"
45    
46    
47  #define debug fatal  /*  #define debug fatal  */
48    
49  #define TICK_SHIFT              15  #define TICK_SHIFT              18
50  #define DEV_LPT_LENGTH          3  #define DEV_LPT_LENGTH          3
51    
52  struct lpt_data {  struct lpt_data {
# Line 56  struct lpt_data { Line 56  struct lpt_data {
56          int             console_handle;          int             console_handle;
57    
58          unsigned char   data;          unsigned char   data;
59            unsigned char   control;
60  };  };
61    
62    
# Line 85  int dev_lpt_access(struct cpu *cpu, stru Line 86  int dev_lpt_access(struct cpu *cpu, stru
86    
87          switch (relative_addr) {          switch (relative_addr) {
88    
89          case 0: if (writeflag == MEM_READ)          case LPT_DATA:
90                    if (writeflag == MEM_READ)
91                          odata = d->data;                          odata = d->data;
92                  else                  else
93                          d->data = idata;                          d->data = idata;
94                  break;                  break;
95    
96          default:          case LPT_STATUS:
97                  if (writeflag == MEM_READ) {                  odata = LPS_NBSY | LPS_NACK | LPS_SELECT | LPS_NERR;
98                          debug("[ lpt (%s): read from %i: UNIMPLEMENTED ]\n",                  break;
99                              d->name, (int)relative_addr);  
100                  } else {          case LPT_CONTROL:
101                          debug("[ lpt (%s): write to %i, data = 0x%llx: "                  if (writeflag == MEM_WRITE) {
102                              "UNIMPLEMENTED ]\n", d->name, (int)relative_addr,                          if (idata != d->control) {
103                              (long long)idata);                                  if (idata & LPC_STROBE) {
104                                            /*  data strobe  */
105                                            console_putchar(d->console_handle,
106                                                d->data);
107                                    }
108                            }
109                            d->control = idata;
110                  }                  }
111                    break;
112          }          }
113    
114          if (writeflag == MEM_READ)          if (writeflag == MEM_READ)
# Line 143  int devinit_lpt(struct devinit *devinit) Line 152  int devinit_lpt(struct devinit *devinit)
152                  snprintf(name, nlen, "%s", devinit->name);                  snprintf(name, nlen, "%s", devinit->name);
153    
154          memory_device_register(devinit->machine->memory, name, devinit->addr,          memory_device_register(devinit->machine->memory, name, devinit->addr,
155              DEV_LPT_LENGTH, dev_lpt_access, d, MEM_DEFAULT, NULL);              DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL);
156          machine_add_tickfunction(devinit->machine, dev_lpt_tick, d, TICK_SHIFT);          machine_add_tickfunction(devinit->machine, dev_lpt_tick, d, TICK_SHIFT);
157    
158          /*          /*

Legend:
Removed from v.18  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26