/[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 24 by dpavlin, Mon Oct 8 16:19:56 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.36 2006/05/06 08:42:49 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    
# Line 69  void dev_cons_tick(struct cpu *cpu, void Line 71  void dev_cons_tick(struct cpu *cpu, void
71  /*  /*
72   *  dev_cons_access():   *  dev_cons_access():
73   */   */
74  int dev_cons_access(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(cons)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
75  {  {
76          struct cons_data *d = extra;          struct cons_data *d = extra;
77          int i;          unsigned int i;
78    
79          /*  Exit the emulator:  */          /*  Exit the emulator:  */
80          if (relative_addr == DEV_CONS_HALT) {          if (relative_addr == DEV_CONS_HALT) {
81                  cpu->running = 0;                  /*  cpu->running = 0;
82                  cpu->machine->exit_without_entering_debugger = 1;                      cpu->machine->exit_without_entering_debugger = 1;
83                  return 1;                      return 1;  */
84                    /*  TODO: this doesn't work yet. for now, let's
85                        simply use exit()  */
86                    exit(1);
87          }          }
88    
89          if (writeflag == MEM_WRITE) {          if (writeflag == MEM_WRITE) {
# Line 112  int dev_cons_access(struct cpu *cpu, str Line 115  int dev_cons_access(struct cpu *cpu, str
115  }  }
116    
117    
118  /*  DEVINIT(cons)
  *  devinit_cons():  
  */  
 int devinit_cons(struct devinit *devinit)  
119  {  {
120          struct cons_data *d;          struct cons_data *d;
121          char *name3;          char *name3;
# Line 142  int devinit_cons(struct devinit *devinit Line 142  int devinit_cons(struct devinit *devinit
142                  snprintf(name3, nlen, "%s", devinit->name);                  snprintf(name3, nlen, "%s", devinit->name);
143    
144          d->irq_nr = devinit->irq_nr;          d->irq_nr = devinit->irq_nr;
145          d->console_handle = console_start_slave(devinit->machine, name3);          d->in_use = devinit->in_use;
146            d->console_handle = console_start_slave(devinit->machine, name3,
147                d->in_use);
148    
149          memory_device_register(devinit->machine->memory, name3,          memory_device_register(devinit->machine->memory, name3,
150              devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,              devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d,
151              MEM_DEFAULT, NULL);              DM_DEFAULT, NULL);
152          machine_add_tickfunction(devinit->machine, dev_cons_tick,          machine_add_tickfunction(devinit->machine, dev_cons_tick,
153              d, CONS_TICK_SHIFT);              d, CONS_TICK_SHIFT, 0.0);
154    
155          devinit->return_ptr = d;          /*  NOTE: Ugly cast into pointer  */
156            devinit->return_ptr = (void *)(size_t)d->console_handle;
157          return 1;          return 1;
158  }  }
159    

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

  ViewVC Help
Powered by ViewVC 1.1.26