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

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

revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 70 by dpavlin, Sun Oct 14 16:53:24 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: interrupt.c,v 1.7 2007/02/03 16:41:42 debug Exp $   *  $Id: interrupt.c,v 1.13 2007/08/29 20:36:49 debug Exp $
29   *   *
30   *  The interrupt subsystem.   *  The interrupt subsystem.
31   *   *
32   *  Interrupts have a "path", e.g. "emul[0].machine[0].cpu.5". A device which   *  Interrupts have a "path", e.g. "machine[0].cpu.5". A device which
33   *  wishes to cause this interrupt needs to connect to it.   *  wishes to cause this interrupt needs to connect to it.
34   *   *
35   *  The possible interrupt paths are registered by CPUs, interrupt controllers,   *  The possible interrupt paths are registered by CPUs, interrupt controllers,
# Line 49  Line 49 
49  #include "misc.h"  #include "misc.h"
50    
51    
52    /*  #define INTERRUPT_DEBUG  */
53    #define INTERRUPT_DEBUG  1
54    
55    
56  struct interrupt_handler {  struct interrupt_handler {
57          struct interrupt        template;          struct interrupt        template;
58          int                     nr_of_exclusive_users;          int                     nr_of_exclusive_users;
# Line 73  static void no_interrupt_deassert(struct Line 77  static void no_interrupt_deassert(struct
77   *  Add an interrupt handler to the interrupt subsystem. The 'template'   *  Add an interrupt handler to the interrupt subsystem. The 'template'
78   *  needs to have all members set.   *  needs to have all members set.
79   *   *
80   *  Name is of the form "emul[0].machine[0].cpu[0].irq[3].isa[14]" etc.   *  Name is of the form "machine[0].cpu[0].irq[3].isa[14]" etc.
81   *   *
82   *  If there already is a handler with this name, the emulator aborts.   *  If there already is a handler with this name, the emulator aborts.
83   */   */
# Line 81  void interrupt_handler_register(struct i Line 85  void interrupt_handler_register(struct i
85  {  {
86          int i;          int i;
87    
88  #ifdef UNSTABLE_DEVEL  #ifdef INTERRUPT_DEBUG
89          printf("interrupt_handler_register(\"%s\")\n", template->name);          printf("interrupt_handler_register(\"%s\")\n", template->name);
90  #endif  #endif
91    
# Line 98  void interrupt_handler_register(struct i Line 102  void interrupt_handler_register(struct i
102          }          }
103    
104          nr_of_interrupt_handlers ++;          nr_of_interrupt_handlers ++;
105          interrupt_handlers = realloc(interrupt_handlers,          CHECK_ALLOCATION(interrupt_handlers = realloc(interrupt_handlers,
106              nr_of_interrupt_handlers * sizeof(struct interrupt_handler));              nr_of_interrupt_handlers * sizeof(struct interrupt_handler)));
         if (interrupt_handlers == NULL) {  
                 fprintf(stderr, "out of memory in "  
                     "ninterrupt_handler_register().\n");  
                 exit(1);  
         }  
107    
108          interrupt_handlers[nr_of_interrupt_handlers-1].template = *template;          interrupt_handlers[nr_of_interrupt_handlers-1].template = *template;
109          interrupt_handlers[nr_of_interrupt_handlers-1].template.name =          CHECK_ALLOCATION(interrupt_handlers[nr_of_interrupt_handlers-1].
110              strdup(template->name);              template.name = strdup(template->name));
111  }  }
112    
113    
# Line 123  void interrupt_handler_remove(char *name Line 122  void interrupt_handler_remove(char *name
122  {  {
123          int i;          int i;
124    
125  #ifdef UNSTABLE_DEVEL  #ifdef INTERRUPT_DEBUG
126          printf("interrupt_handler_remove(\"%s\")\n", name);          printf("interrupt_handler_remove(\"%s\")\n", name);
127  #endif  #endif
128    
# Line 170  int interrupt_handler_lookup(char *name, Line 169  int interrupt_handler_lookup(char *name,
169  {  {
170          int i;          int i;
171    
172  #ifdef UNSTABLE_DEVEL  #ifdef INTERRUPT_DEBUG
173          printf("interrupt_handler_lookup(\"%s\")\n", name);          printf("interrupt_handler_lookup(\"%s\")\n", name);
174  #endif  #endif
175    
# Line 189  int interrupt_handler_lookup(char *name, Line 188  int interrupt_handler_lookup(char *name,
188                  return 1;                  return 1;
189          }          }
190    
191          printf("interrupt_handler_lookup(\"%s\") failed. Aborting.\n", name);          /*  The 'if' is an ugly hack to prevent a Compaq CC warning.  */
192          abort();          if (i >= nr_of_interrupt_handlers) {
193                    printf("interrupt_handler_lookup(\"%s\") failed. "
194                        "Aborting.\n", name);
195                    abort();
196            }
197    
198          return 0;          return 0;
199  }  }
# Line 205  void interrupt_connect(struct interrupt Line 208  void interrupt_connect(struct interrupt
208  {  {
209          int i;          int i;
210    
211  #ifdef UNSTABLE_DEVEL  #ifdef INTERRUPT_DEBUG
212          printf("interrupt_connect(\"%s\")\n", in->name);          printf("interrupt_connect(\"%s\")\n", in->name);
213  #endif  #endif
214    

Legend:
Removed from v.34  
changed lines
  Added in v.70

  ViewVC Help
Powered by ViewVC 1.1.26