/[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 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC revision 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2006  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_cons.c,v 1.27 2005/07/12 08:49:13 debug Exp $   *  $Id: dev_cons.c,v 1.37 2006/07/23 14:37:34 debug Exp $
29   *     *  
30   *  A simple console device, useful for simple tests.   *  A simple console device, useful for simple tests.
31   *   *
# Line 47  Line 47 
47  #include "memory.h"  #include "memory.h"
48  #include "misc.h"  #include "misc.h"
49    
50    #include "testmachine/dev_cons.h"
51    
52    
53  #define CONS_TICK_SHIFT         14  #define CONS_TICK_SHIFT         14
54    
55    
56  /*  DEVICE_TICK(cons)
  *  dev_cons_tick():  
  */  
 void dev_cons_tick(struct cpu *cpu, void *extra)  
57  {  {
58          struct cpu *c = cpu->machine->cpus[0];          struct cpu *c = cpu->machine->cpus[0];
59          struct cons_data *d = extra;          struct cons_data *d = extra;
# Line 66  void dev_cons_tick(struct cpu *cpu, void Line 65  void dev_cons_tick(struct cpu *cpu, void
65  }  }
66    
67    
68  /*  DEVICE_ACCESS(cons)
  *  dev_cons_access():  
  */  
 int dev_cons_access(struct cpu *cpu, struct memory *mem,  
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
69  {  {
70          struct cons_data *d = extra;          struct cons_data *d = extra;
71          int i;          unsigned int i;
72    
73          /*  Exit the emulator:  */          /*  Exit the emulator:  */
74          if (relative_addr == DEV_CONS_HALT) {          if (relative_addr == DEV_CONS_HALT) {
75                  cpu->running = 0;                  /*  cpu->running = 0;
76                  cpu->machine->exit_without_entering_debugger = 1;                      cpu->machine->exit_without_entering_debugger = 1;
77                  return 1;                      return 1;  */
78                    /*  TODO: this doesn't work yet. for now, let's
79                        simply use exit()  */
80                    exit(1);
81          }          }
82    
83          if (writeflag == MEM_WRITE) {          if (writeflag == MEM_WRITE) {
# Line 112  int dev_cons_access(struct cpu *cpu, str Line 109  int dev_cons_access(struct cpu *cpu, str
109  }  }
110    
111    
112  /*  DEVINIT(cons)
  *  devinit_cons():  
  */  
 int devinit_cons(struct devinit *devinit)  
113  {  {
114          struct cons_data *d;          struct cons_data *d;
115          char *name3;          char *name3;
# Line 142  int devinit_cons(struct devinit *devinit Line 136  int devinit_cons(struct devinit *devinit
136                  snprintf(name3, nlen, "%s", devinit->name);                  snprintf(name3, nlen, "%s", devinit->name);
137    
138          d->irq_nr = devinit->irq_nr;          d->irq_nr = devinit->irq_nr;
139          d->console_handle = console_start_slave(devinit->machine, name3);          d->in_use = devinit->in_use;
140            d->console_handle = console_start_slave(devinit->machine, name3,
141                d->in_use);
142    
143          memory_device_register(devinit->machine->memory, name3,          memory_device_register(devinit->machine->memory, name3,
144              devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,              devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,
145              MEM_DEFAULT, NULL);              DM_DEFAULT, NULL);
146          machine_add_tickfunction(devinit->machine, dev_cons_tick,          machine_add_tickfunction(devinit->machine, dev_cons_tick,
147              d, CONS_TICK_SHIFT);              d, CONS_TICK_SHIFT, 0.0);
148    
149          devinit->return_ptr = d;          /*  NOTE: Ugly cast into pointer  */
150            devinit->return_ptr = (void *)(size_t)d->console_handle;
151          return 1;          return 1;
152  }  }
153    

Legend:
Removed from v.12  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26