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

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

revision 26 by dpavlin, Mon Oct 8 16:20:10 2007 UTC revision 40 by dpavlin, Mon Oct 8 16:22:11 2007 UTC
# Line 2  Line 2 
2  #define MACHINE_H  #define MACHINE_H
3    
4  /*  /*
5   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2007  Anders Gavare.  All rights reserved.
6   *   *
7   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
8   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 28  Line 28 
28   *  SUCH DAMAGE.   *  SUCH DAMAGE.
29   *   *
30   *   *
31   *  $Id: machine.h,v 1.120 2006/06/24 19:52:28 debug Exp $   *  $Id: machine.h,v 1.162 2007/04/19 15:18:16 debug Exp $
32   */   */
33    
34  #include <sys/types.h>  #include <sys/types.h>
35  #include <sys/time.h>  #include <sys/time.h>
36    
 #include "debugger_gdb.h"  
37  #include "symbol.h"  #include "symbol.h"
38    
39  #include "machine_arc.h"  #include "machine_arc.h"
40  #include "machine_pmax.h"  #include "machine_pmax.h"
 #include "machine_x86.h"  
41    
42    
43  #define MAX_BREAKPOINTS         8  #define MAX_BREAKPOINTS         8
 #define BREAKPOINT_FLAG_R       1  
44    
45  #define MAX_TICK_FUNCTIONS      16  #define MAX_TICK_FUNCTIONS      16
46    
47    #define MAX_STATISTICS_FIELDS   8
48    
49  struct cpu_family;  struct cpu_family;
50  struct diskimage;  struct diskimage;
51  struct emul;  struct emul;
52  struct fb_window;  struct fb_window;
53  struct memory;  struct memory;
54  struct of_data;  struct of_data;
55    struct settings;
56    
57    
58  /*  Ugly:  */  /*  TODO: This should probably go away...  */
 struct kn230_csr;  
 struct kn02_csr;  
 struct dec_ioasic_data;  
 struct ps2_data;  
 struct footbridge_data;  
 struct dec5800_data;  
 struct au1x00_ic_data;  
 struct malta_data;  
 struct vr41xx_data;  
 struct jazz_data;  
 struct crime_data;  
 struct mace_data;  
 struct sgi_ip20_data;  
 struct sgi_ip22_data;  
 struct sgi_ip30_data;  
59  struct isa_pic_data {  struct isa_pic_data {
60          struct pic8259_data     *pic1;          struct pic8259_data     *pic1;
61          struct pic8259_data     *pic2;          struct pic8259_data     *pic2;
         int                     last_int;  
         int                     native_irq;  
 };  
62    
63            int                     *pending_timer_interrupts;
64  struct machine_bus {          int                     last_int;
         struct machine_bus *next;  
   
         char            *name;  
   
         void            (*debug_dump)(void *);  
         void            *extra;  
65  };  };
66    
67    
 #define MACHINE_NAME_MAXBUF             150  
   
68  struct machine {  struct machine {
69          /*  Pointer back to the emul struct we are in:  */          /*  Pointer back to the emul struct we are in:  */
70          struct emul *emul;          struct emul *emul;
71    
72            /*  Settings:  */
73            struct settings *settings;
74    
75          /*  Name as choosen by the user:  */          /*  Name as choosen by the user:  */
76          char    *name;          char    *name;
77    
78            /*  Full "path" to the machine, e.g. "emul[0].machine[0]":  */
79            char    *path;
80    
81          int     arch;                   /*  ARCH_MIPS, ARCH_PPC, ..  */          int     arch;                   /*  ARCH_MIPS, ARCH_PPC, ..  */
82          int     machine_type;           /*  MACHINE_PMAX, ..  */          int     machine_type;           /*  MACHINE_PMAX, ..  */
83          int     machine_subtype;        /*  MACHINE_DEC_3MAX_5000, ..  */          int     machine_subtype;        /*  MACHINE_DEC_3MAX_5000, ..  */
84    
85            /*  NOTE/TODO: This isn't working yet:  */
86          int     cycle_accurate;         /*  Set to non-zero for cycle          int     cycle_accurate;         /*  Set to non-zero for cycle
87                                              accurate (slow) emulation.  */                                              accurate (slow) emulation.  */
88    
# Line 116  struct machine { Line 98  struct machine {
98          int     serial_nr;          int     serial_nr;
99          int     nr_of_nics;          int     nr_of_nics;
100    
101            /*  TODO: How about multiple cpu familys in one machine?  */
102          struct cpu_family *cpu_family;          struct cpu_family *cpu_family;
103    
104          /*          /*
# Line 138  struct machine { Line 121  struct machine {
121          void    *tick_extra[MAX_TICK_FUNCTIONS];          void    *tick_extra[MAX_TICK_FUNCTIONS];
122          double  tick_hz[MAX_TICK_FUNCTIONS];          double  tick_hz[MAX_TICK_FUNCTIONS];
123    
         void    (*md_interrupt)(struct machine *m, struct cpu *cpu,  
                     int irq_nr, int assert);  
   
124          char    *cpu_name;  /*  TODO: remove this, there could be several          char    *cpu_name;  /*  TODO: remove this, there could be several
125                                  cpus with different names in a machine  */                                  cpus with different names in a machine  */
126          int     byte_order_override;          int     byte_order_override;
# Line 150  struct machine { Line 130  struct machine {
130          int     ncpus;          int     ncpus;
131          struct cpu **cpus;          struct cpu **cpus;
132    
         /*  Registered busses:  */  
         struct machine_bus *first_bus;  
         int     n_busses;  
   
133          /*  These are used by stuff in cpu.c, mostly:  */          /*  These are used by stuff in cpu.c, mostly:  */
134          int64_t ncycles;          /*  TODO: Move to cpu.h!  */
135          int64_t ncycles_show;          int64_t ninstrs;
136          int64_t ncycles_flush;          int64_t ninstrs_show;
137          int64_t ncycles_since_gettimeofday;          int64_t ninstrs_flush;
138            int64_t ninstrs_since_gettimeofday;
139          struct timeval starttime;          struct timeval starttime;
         int     a_few_cycles;  
         int     a_few_instrs;  
140    
141          struct diskimage *first_diskimage;          struct diskimage *first_diskimage;
142    
# Line 179  struct machine { Line 154  struct machine {
154          char    *bootstr;          char    *bootstr;
155          char    *bootarg;          char    *bootarg;
156    
157          struct debugger_gdb gdb;          /*  Breakpoints:  */
   
158          int     n_breakpoints;          int     n_breakpoints;
159          char    *breakpoint_string[MAX_BREAKPOINTS];          char    *breakpoint_string[MAX_BREAKPOINTS];
160          uint64_t breakpoint_addr[MAX_BREAKPOINTS];          uint64_t breakpoint_addr[MAX_BREAKPOINTS];
161          int     breakpoint_flags[MAX_BREAKPOINTS];          int     breakpoint_flags[MAX_BREAKPOINTS];
162    
163          /*  Cache sizes: (1 << x) x=0 for default values  */          /*  Cache sizes: (1 << x) x=0 for default values  */
164          /*  TODO: these are _PER CPU_!  */          /*  TODO: these should be _PER CPU_!  */
165          int     cache_picache;          int     cache_picache;
166          int     cache_pdcache;          int     cache_pdcache;
167          int     cache_secondary;          int     cache_secondary;
# Line 196  struct machine { Line 170  struct machine {
170          int     cache_secondary_linesize;          int     cache_secondary_linesize;
171    
172          int     dbe_on_nonexistant_memaccess;          int     dbe_on_nonexistant_memaccess;
173          int     dyntrans_alignment_check;          int     halt_on_nonexistant_memaccess;
174          int     instruction_trace;          int     instruction_trace;
175          int     show_nr_of_instructions;          int     show_nr_of_instructions;
176            int     show_trace_tree;
177          int     show_symbolic_register_names;          int     show_symbolic_register_names;
178          int     emulated_hz;          int     emulated_hz;
179          int     speed_tricks;          int     allow_instruction_combinations;
180          char    *userland_emul;         /*  NULL for no userland emulation  */          char    *userland_emul;         /*  NULL for no userland emulation  */
181          int     force_netboot;          int     force_netboot;
182          int     slow_serial_interrupts_hack_for_linux;          int     slow_serial_interrupts_hack_for_linux;
183          uint64_t file_loaded_end_addr;          uint64_t file_loaded_end_addr;
184          char    *boot_kernel_filename;          char    *boot_kernel_filename;
185          char    *boot_string_argument;          char    *boot_string_argument;
   
         int     automatic_clock_adjustment;  
186          int     exit_without_entering_debugger;          int     exit_without_entering_debugger;
         int     show_trace_tree;  
   
187          int     n_gfx_cards;          int     n_gfx_cards;
188    
189            /*  Instruction statistics:  */
190            char    *statistics_filename;
191            FILE    *statistics_file;
192            int     statistics_enabled;
193            char    *statistics_fields;     /*  "vpi" etc.  */
194    
195          /*  Machine-dependent: (PROM stuff, etc.)  */          /*  Machine-dependent: (PROM stuff, etc.)  */
196          union {          union {
197                  struct machine_arcbios  arc;                  struct machine_arcbios  arc;
198                  struct machine_pmax     pmax;                  struct machine_pmax     pmax;
199                  struct machine_pc       pc;                  struct of_data          *of_data;
200          } md;          } md;
201    
         /*  OpenFirmware:  */  
         struct of_data *of_data;  
   
202          /*  Bus-specific interrupt data:  */          /*  Bus-specific interrupt data:  */
203            /*  TODO: Remove!  */
204          struct isa_pic_data isa_pic_data;          struct isa_pic_data isa_pic_data;
205    
         /*  Machine-dependent interrupt specific structs:  */  
         union {  
                 struct kn230_csr *kn230_csr;  
                 struct kn02_csr *kn02_csr;  
                 struct dec_ioasic_data *dec_ioasic_data;  
                 struct ps2_data *ps2_data;  
                 struct dec5800_data *dec5800_csr;  
                 struct au1x00_ic_data *au1x00_ic_data;  
                 struct vr41xx_data *vr41xx_data;        
                 struct jazz_data *jazz_data;  
                 struct malta_data *malta_data;  
                 struct sgi_ip20_data *sgi_ip20_data;  
                 struct sgi_ip22_data *sgi_ip22_data;  
                 struct sgi_ip30_data *sgi_ip30_data;  
                 struct {  
                         struct crime_data *crime_data;  
                         struct mace_data *mace_data;  
                 } ip32;  
                 struct footbridge_data *footbridge_data;  
                 struct bebox_data *bebox_data;  
                 struct prep_data *prep_data;  
                 struct cpc700_data *cpc700_data;  
                 struct gc_data *gc_data;  
                 struct v3_data *v3_data;  
         } md_int;  
   
206          /*  X11/framebuffer stuff:  */          /*  X11/framebuffer stuff:  */
207          int     use_x11;          int     use_x11;
208          int     x11_scaledown;          int     x11_scaledown;
# Line 267  struct machine { Line 216  struct machine {
216  };  };
217    
218    
219    /*  Tick function "prototype":  */
220    #define DEVICE_TICK(x)  void dev_ ## x ## _tick(struct cpu *cpu, void *extra)
221    
222    
223  /*  /*
224   *  Machine emulation types:   *  Machine emulation types:
225   */   */
# Line 276  struct machine { Line 229  struct machine {
229  #define ARCH_PPC                2  #define ARCH_PPC                2
230  #define ARCH_SPARC              3  #define ARCH_SPARC              3
231  #define ARCH_ALPHA              4  #define ARCH_ALPHA              4
232  #define ARCH_X86                5  #define ARCH_ARM                5
233  #define ARCH_ARM                6  #define ARCH_SH                 6
234  #define ARCH_IA64               7  #define ARCH_AVR                7
235  #define ARCH_M68K               8  #define ARCH_M88K               8
 #define ARCH_SH                 9  
 #define ARCH_HPPA               10  
 #define ARCH_I960               11  
 #define ARCH_AVR                12  
236    
237  /*  MIPS:  */  /*  MIPS:  */
238  #define MACHINE_BAREMIPS        1000  #define MACHINE_BAREMIPS        1000
# Line 299  struct machine { Line 248  struct machine {
248  #define MACHINE_EVBMIPS         1010  #define MACHINE_EVBMIPS         1010
249  #define MACHINE_PSP             1011  #define MACHINE_PSP             1011
250  #define MACHINE_ALGOR           1012  #define MACHINE_ALGOR           1012
251    #define MACHINE_QEMU_MIPS       1013
252    
253  /*  PPC:  */  /*  PPC:  */
254  #define MACHINE_BAREPPC         2000  #define MACHINE_BAREPPC         2000
255  #define MACHINE_TESTPPC         2001  #define MACHINE_TESTPPC         2001
256  #define MACHINE_WALNUT          2002  #define MACHINE_PMPPC           2002
257  #define MACHINE_PMPPC           2003  #define MACHINE_SANDPOINT       2003
258  #define MACHINE_SANDPOINT       2004  #define MACHINE_BEBOX           2004
259  #define MACHINE_BEBOX           2005  #define MACHINE_PREP            2005
260  #define MACHINE_PREP            2006  #define MACHINE_MACPPC          2006
261  #define MACHINE_MACPPC          2007  #define MACHINE_MVMEPPC         2007
 #define MACHINE_DB64360         2008  
 #define MACHINE_MVMEPPC         2009  
262    
263  /*  SPARC:  */  /*  SPARC:  */
264  #define MACHINE_BARESPARC       3000  #define MACHINE_BARESPARC       3000
# Line 322  struct machine { Line 270  struct machine {
270  #define MACHINE_TESTALPHA       4001  #define MACHINE_TESTALPHA       4001
271  #define MACHINE_ALPHA           4002  #define MACHINE_ALPHA           4002
272    
 /*  X86:  */  
 #define MACHINE_BAREX86         5000  
 #define MACHINE_X86             5001  
   
273  /*  ARM:  */  /*  ARM:  */
274  #define MACHINE_BAREARM         6000  #define MACHINE_BAREARM         5000
275  #define MACHINE_TESTARM         6001  #define MACHINE_TESTARM         5001
276  #define MACHINE_CATS            6002  #define MACHINE_CATS            5002
277  #define MACHINE_HPCARM          6003  #define MACHINE_HPCARM          5003
278  #define MACHINE_ZAURUS          6004  #define MACHINE_ZAURUS          5004
279  #define MACHINE_NETWINDER       6005  #define MACHINE_NETWINDER       5005
280  #define MACHINE_SHARK           6006  #define MACHINE_SHARK           5006
281  #define MACHINE_IQ80321         6007  #define MACHINE_IQ80321         5007
282  #define MACHINE_IYONIX          6008  #define MACHINE_IYONIX          5008
283  #define MACHINE_TS7200          6009  #define MACHINE_QEMU_ARM        5009
   
 /*  IA64:  */  
 #define MACHINE_BAREIA64        7000  
 #define MACHINE_TESTIA64        7001  
   
 /*  M68K:  */  
 #define MACHINE_BAREM68K        8000  
 #define MACHINE_TESTM68K        8001  
284    
285  /*  SH:  */  /*  SH:  */
286  #define MACHINE_BARESH          9000  #define MACHINE_BARESH          6000
287  #define MACHINE_TESTSH          9001  #define MACHINE_TESTSH          6001
288  #define MACHINE_HPCSH           9002  #define MACHINE_HPCSH           6002
289    #define MACHINE_DREAMCAST       6003
290  /*  HPPA:  */  #define MACHINE_LANDISK         6004
 #define MACHINE_BAREHPPA        10000  
 #define MACHINE_TESTHPPA        10001  
   
 /*  I960:  */  
 #define MACHINE_BAREI960        11000  
 #define MACHINE_TESTI960        11001  
291    
292  /*  AVR:  */  /*  AVR:  */
293  #define MACHINE_BAREAVR         12000  #define MACHINE_BAREAVR         7000
294  #define MACHINE_AVR_PAL         12001  #define MACHINE_AVR_PAL         7001
295  #define MACHINE_AVR_MAHPONG     12002  #define MACHINE_AVR_MAHPONG     7002
296    
297    /*  M88K:  */
298    #define MACHINE_BAREM88K        8000
299    #define MACHINE_TESTM88K        8001
300    
301  /*  Other "pseudo"-machines:  */  /*  Other "pseudo"-machines:  */
302  #define MACHINE_NONE            0  #define MACHINE_NONE            0
# Line 404  struct machine { Line 338  struct machine {
338  #define MACHINE_HPCSH_JORNADA680                1  #define MACHINE_HPCSH_JORNADA680                1
339  #define MACHINE_HPCSH_JORNADA690                2  #define MACHINE_HPCSH_JORNADA690                2
340    
 /*  Playstation 2:  */  
 #define PLAYSTATION2_BDA        0xffffffffa0001000ULL  
 #define PLAYSTATION2_OPTARGS    0xffffffff81fff100ULL  
 #define PLAYSTATION2_SIFBIOS    0xffffffffbfc10000ULL  
   
341  /*  SGI and ARC:  */  /*  SGI and ARC:  */
342  #define MACHINE_ARC_NEC_RD94            1  #define MACHINE_ARC_NEC_RD94            1
343  #define MACHINE_ARC_JAZZ_PICA           2  #define MACHINE_ARC_JAZZ_PICA           2
# Line 426  struct machine { Line 355  struct machine {
355  /*  EVBMIPS:  */  /*  EVBMIPS:  */
356  #define MACHINE_EVBMIPS_MALTA           1  #define MACHINE_EVBMIPS_MALTA           1
357  #define MACHINE_EVBMIPS_MALTA_BE        2  #define MACHINE_EVBMIPS_MALTA_BE        2
 #define MACHINE_EVBMIPS_MESHCUBE        3  
 #define MACHINE_EVBMIPS_PB1000          4  
358    
359  /*  PReP:  */  /*  PReP:  */
360  #define MACHINE_PREP_IBM6050            1  #define MACHINE_PREP_IBM6050            1
# Line 438  struct machine { Line 365  struct machine {
365  #define MACHINE_SPARC_SS20              2  #define MACHINE_SPARC_SS20              2
366  #define MACHINE_SPARC_ULTRA1            3  #define MACHINE_SPARC_ULTRA1            3
367  #define MACHINE_SPARC_ULTRA60           4  #define MACHINE_SPARC_ULTRA60           4
368    #define MACHINE_SPARC_SUN4V             5
369    
370  /*  MacPPC:  TODO: Real model names  */  /*  MacPPC:  TODO: Real model names  */
371  #define MACHINE_MACPPC_G3               1  #define MACHINE_MACPPC_G3               1
# Line 449  struct machine { Line 377  struct machine {
377  #define MACHINE_MVMEPPC_2100            2  #define MACHINE_MVMEPPC_2100            2
378  #define MACHINE_MVMEPPC_5500            3  #define MACHINE_MVMEPPC_5500            3
379    
 /*  X86:  */  
 #define MACHINE_X86_GENERIC             1  
 #define MACHINE_X86_XT                  2  
   
   
 /*  
  *  Problem: kernels seem to be loaded at low addresses in RAM, so  
  *  storing environment strings and memory descriptors there is a bad  
  *  idea. They are stored at 0xbfc..... instead.  The ARC SPB must  
  *  be at physical address 0x1000 though.  
  */  
 #define SGI_SPB_ADDR            0xffffffff80001000ULL  
 /*  0xbfc10000 is firmware callback vector stuff  */  
 #define ARC_FIRMWARE_VECTORS    0xffffffffbfc80000ULL  
 #define ARC_FIRMWARE_ENTRIES    0xffffffffbfc88000ULL  
 #define ARC_ARGV_START          0xffffffffbfc90000ULL  
 #define ARC_ENV_STRINGS         0xffffffffbfc98000ULL  
 #define ARC_ENV_POINTERS        0xffffffffbfc9d000ULL  
 #define SGI_SYSID_ADDR          0xffffffffbfca1800ULL  
 #define ARC_DSPSTAT_ADDR        0xffffffffbfca1c00ULL  
 #define ARC_MEMDESC_ADDR        0xffffffffbfca1c80ULL  
 #define ARC_CONFIG_DATA_ADDR    0xffffffffbfca2000ULL  
 #define FIRST_ARC_COMPONENT     0xffffffffbfca8000ULL  
 #define ARC_PRIVATE_VECTORS     0xffffffffbfcb0000ULL  
 #define ARC_PRIVATE_ENTRIES     0xffffffffbfcb8000ULL  
   
380    
381  /*  For the automachine system:  */  /*  For the automachine system:  */
382  struct machine_entry_subtype {  struct machine_entry_subtype {
# Line 518  void automachine_init(void); Line 420  void automachine_init(void);
420    
421    
422  /*  machine.c:  */  /*  machine.c:  */
423  struct machine *machine_new(char *name, struct emul *emul);  struct machine *machine_new(char *name, struct emul *emul, int id);
424    void machine_destroy(struct machine *machine);
425  int machine_name_to_type(char *stype, char *ssubtype,  int machine_name_to_type(char *stype, char *ssubtype,
426          int *type, int *subtype, int *arch);          int *type, int *subtype, int *arch);
427  void machine_add_tickfunction(struct machine *machine,  void machine_add_tickfunction(struct machine *machine,
428          void (*func)(struct cpu *, void *), void *extra,          void (*func)(struct cpu *, void *), void *extra,
429          int clockshift, double hz);          int clockshift, double hz);
430    void machine_statistics_init(struct machine *, char *fname);
431  void machine_register(char *name, MACHINE_SETUP_TYPE(setup));  void machine_register(char *name, MACHINE_SETUP_TYPE(setup));
432  void dump_mem_string(struct cpu *cpu, uint64_t addr);  void dump_mem_string(struct cpu *cpu, uint64_t addr);
433  void store_string(struct cpu *cpu, uint64_t addr, char *s);  void store_string(struct cpu *cpu, uint64_t addr, char *s);
# Line 537  void store_32bit_word_in_host(struct cpu Line 441  void store_32bit_word_in_host(struct cpu
441          uint64_t data32);          uint64_t data32);
442  void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data,  void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data,
443          uint16_t data16);          uint16_t data16);
444    uint64_t load_64bit_word(struct cpu *cpu, uint64_t addr);
445  uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr);  uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr);
446  uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr);  uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr);
447  void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len);  void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len);
# Line 549  void machine_setup(struct machine *); Line 454  void machine_setup(struct machine *);
454  void machine_memsize_fix(struct machine *);  void machine_memsize_fix(struct machine *);
455  void machine_default_cputype(struct machine *);  void machine_default_cputype(struct machine *);
456  void machine_dumpinfo(struct machine *);  void machine_dumpinfo(struct machine *);
 void machine_bus_register(struct machine *, char *busname,  
         void (*debug_dump)(void *), void *extra);  
457  int machine_run(struct machine *machine);  int machine_run(struct machine *machine);
458  void machine_list_available_types_and_cpus(void);  void machine_list_available_types_and_cpus(void);
459  struct machine_entry *machine_entry_new(const char *name,  struct machine_entry *machine_entry_new(const char *name,

Legend:
Removed from v.26  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26