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

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

revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-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: machine.c,v 1.689 2006/10/04 11:56:40 debug Exp $   *  $Id: machine.c,v 1.693 2007/01/28 14:15:29 debug Exp $
29   */   */
30    
31  #include <stdio.h>  #include <stdio.h>
# Line 45  Line 45 
45  #include "diskimage.h"  #include "diskimage.h"
46  #include "emul.h"  #include "emul.h"
47  #include "machine.h"  #include "machine.h"
 #include "machine_interrupts.h"  
48  #include "memory.h"  #include "memory.h"
49  #include "misc.h"  #include "misc.h"
50  #include "net.h"  #include "net.h"
# Line 67  struct machine_entry *first_machine_entr Line 66  struct machine_entry *first_machine_entr
66   *   *
67   *  Returns a reasonably initialized struct machine.   *  Returns a reasonably initialized struct machine.
68   */   */
69  struct machine *machine_new(char *name, struct emul *emul)  struct machine *machine_new(char *name, struct emul *emul, int id)
70  {  {
71          struct machine *m;          struct machine *m;
72          m = malloc(sizeof(struct machine));          m = malloc(sizeof(struct machine));
# Line 83  struct machine *machine_new(char *name, Line 82  struct machine *machine_new(char *name,
82    
83          m->name = strdup(name);          m->name = strdup(name);
84    
85            /*  Full path, e.g. "emul[0].machine[0]":  */
86            m->path = malloc(strlen(emul->path) + 20);
87            if (m->path == NULL) {
88                    fprintf(stderr, "out of memory\n");
89                    exit(1);
90            }
91            snprintf(m->path, strlen(emul->path) + 20, "%s.machine[%i]",
92                emul->path, id);
93    
94          /*  Sane default values:  */          /*  Sane default values:  */
95          m->serial_nr = 1;          m->serial_nr = 1;
96          m->machine_type = MACHINE_NONE;          m->machine_type = MACHINE_NONE;
# Line 147  void machine_destroy(struct machine *mac Line 155  void machine_destroy(struct machine *mac
155          if (machine->name != NULL)          if (machine->name != NULL)
156                  free(machine->name);                  free(machine->name);
157    
158            if (machine->path != NULL)
159                    free(machine->path);
160    
161          /*  Remove any remaining level-1 settings:  */          /*  Remove any remaining level-1 settings:  */
162          settings_remove_all(machine->settings);          settings_remove_all(machine->settings);
163          settings_destroy(machine->settings);          settings_destroy(machine->settings);
# Line 375  void machine_statistics_init(struct mach Line 386  void machine_statistics_init(struct mach
386    
387    
388  /*  /*
  *  machine_bus_register():  
  *  
  *  Registers a bus in a machine.  
  */  
 void machine_bus_register(struct machine *machine, char *busname,  
         void (*debug_dump)(void *), void *extra)  
 {  
         struct machine_bus *tmp, *last = NULL, *new;  
   
         new = zeroed_alloc(sizeof(struct machine_bus));  
         new->name = strdup(busname);  
         new->debug_dump = debug_dump;  
         new->extra = extra;  
   
         /*  Register last in the bus list:  */  
         tmp = machine->first_bus;  
         while (tmp != NULL) {  
                 last = tmp;  
                 tmp = tmp->next;  
         }  
   
         if (last == NULL)  
                 machine->first_bus = new;  
         else  
                 last->next = new;  
   
         machine->n_busses ++;  
 }  
   
   
 /*  
  *  machine_dump_bus_info():  
  *  
  *  Dumps info about registered busses.  
  */  
 void machine_dump_bus_info(struct machine *m)  
 {  
         struct machine_bus *bus = m->first_bus;  
         int iadd = DEBUG_INDENTATION;  
   
         if (m->n_busses > 0)  
                 debug("busses:\n");  
         debug_indentation(iadd);  
         while (bus != NULL) {  
                 bus->debug_dump(bus->extra);  
                 bus = bus->next;  
         }  
         debug_indentation(-iadd);  
 }  
   
   
 /*  
389   *  machine_dumpinfo():   *  machine_dumpinfo():
390   *   *
391   *  Dumps info about a machine in some kind of readable format. (Used by   *  Dumps info about a machine in some kind of readable format. (Used by
# Line 478  void machine_dumpinfo(struct machine *m) Line 437  void machine_dumpinfo(struct machine *m)
437                  debug("\n");                  debug("\n");
438          }          }
439    
         machine_dump_bus_info(m);  
   
440          diskimage_dump_info(m);          diskimage_dump_info(m);
441    
442          if (m->force_netboot)          if (m->force_netboot)
# Line 939  void machine_setup(struct machine *machi Line 896  void machine_setup(struct machine *machi
896                  debug("\n");                  debug("\n");
897          }          }
898    
         if (verbose >= 2)  
                 machine_dump_bus_info(machine);  
   
899          if (!machine->stable)          if (!machine->stable)
900                  fatal("!\n!  NOTE: This machine type is not implemented well"                  fatal("!\n!  NOTE: This machine type is not implemented well"
901                      " enough yet to run\n!  any real-world code!"                      " enough yet to run\n!  any real-world code!"

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

  ViewVC Help
Powered by ViewVC 1.1.26