/[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 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC
# Line 2  Line 2 
2  #define MACHINE_H  #define MACHINE_H
3    
4  /*  /*
5   *  Copyright (C) 2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2006  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.86 2005/11/22 02:07:40 debug Exp $   *  $Id: machine.h,v 1.128 2006/08/14 17:45:47 debug Exp $
32   */   */
33    
34  #include <sys/types.h>  #include <sys/types.h>
35  #include <sys/time.h>  #include <sys/time.h>
36    
37    #include "debugger_gdb.h"
38  #include "symbol.h"  #include "symbol.h"
39    
40  #include "machine_arc.h"  #include "machine_arc.h"
41    #include "machine_pmax.h"
42  #include "machine_x86.h"  #include "machine_x86.h"
43    
44    
45  #define MAX_BREAKPOINTS         8  #define MAX_BREAKPOINTS         8
46  #define BREAKPOINT_FLAG_R       1  #define BREAKPOINT_FLAG_R       1
47    
48  #define MAX_TICK_FUNCTIONS      14  #define MAX_TICK_FUNCTIONS      16
49    
50    #define MAX_STATISTICS_FIELDS   8
51    
52  struct cpu_family;  struct cpu_family;
53  struct diskimage;  struct diskimage;
54  struct emul;  struct emul;
55  struct fb_window;  struct fb_window;
56  struct memory;  struct memory;
57    struct of_data;
58    
59  /*  Ugly:  */  /*  Ugly:  */
60  struct kn230_csr;  struct kn230_csr;
# Line 70  struct sgi_ip30_data; Line 75  struct sgi_ip30_data;
75  struct isa_pic_data {  struct isa_pic_data {
76          struct pic8259_data     *pic1;          struct pic8259_data     *pic1;
77          struct pic8259_data     *pic2;          struct pic8259_data     *pic2;
78    
79          int                     last_int;          int                     last_int;
80          int                     native_irq;          int                     native_irq;
81            int                     native_secondary_irq;
82            uint8_t                 secondary_mask1;
83  };  };
84    
85    
86  #define MACHINE_NAME_MAXBUF             150  struct machine_bus {
87            struct machine_bus *next;
88    
89            char            *name;
90    
91            void            (*debug_dump)(void *);
92            void            *extra;
93    };
94    
95    
96  struct machine {  struct machine {
97          /*  Pointer back to the emul struct we are in:  */          /*  Pointer back to the emul struct we are in:  */
# Line 85  struct machine { Line 101  struct machine {
101          char    *name;          char    *name;
102    
103          int     arch;                   /*  ARCH_MIPS, ARCH_PPC, ..  */          int     arch;                   /*  ARCH_MIPS, ARCH_PPC, ..  */
104          int     machine_type;           /*  MACHINE_DEC, ..  */          int     machine_type;           /*  MACHINE_PMAX, ..  */
105          int     machine_subtype;        /*  MACHINE_DEC_3MAX_5000, ..  */          int     machine_subtype;        /*  MACHINE_DEC_3MAX_5000, ..  */
106    
107            int     cycle_accurate;         /*  Set to non-zero for cycle
108                                                accurate (slow) emulation.  */
109    
110            /*  Name set by code in src/machines/machine_*.c:  */
111          char    *machine_name;          char    *machine_name;
112    
113            int     stable;                 /*  startup warning for non-stable
114                                                emulation modes.  */
115    
116          /*  The serial number is mostly used when emulating multiple machines          /*  The serial number is mostly used when emulating multiple machines
117              in a network. nr_of_nics is the current nr of network cards, which              in a network. nr_of_nics is the current nr of network cards, which
118              is useful when emulating multiple cards in one machine:  */              is useful when emulating multiple cards in one machine:  */
119          int     serial_nr;          int     serial_nr;
120          int     nr_of_nics;          int     nr_of_nics;
121    
122            /*  TODO: How about multiple cpu familys in one machine?  */
123          struct cpu_family *cpu_family;          struct cpu_family *cpu_family;
124    
125          /*          /*
# Line 116  struct machine { Line 140  struct machine {
140          int     ticks_reset_value[MAX_TICK_FUNCTIONS];          int     ticks_reset_value[MAX_TICK_FUNCTIONS];
141          void    (*tick_func[MAX_TICK_FUNCTIONS])(struct cpu *, void *);          void    (*tick_func[MAX_TICK_FUNCTIONS])(struct cpu *, void *);
142          void    *tick_extra[MAX_TICK_FUNCTIONS];          void    *tick_extra[MAX_TICK_FUNCTIONS];
143            double  tick_hz[MAX_TICK_FUNCTIONS];
144    
145          void    (*md_interrupt)(struct machine *m, struct cpu *cpu,          void    (*md_interrupt)(struct machine *m, struct cpu *cpu,
146                      int irq_nr, int assert);                      int irq_nr, int assert);
# Line 129  struct machine { Line 154  struct machine {
154          int     ncpus;          int     ncpus;
155          struct cpu **cpus;          struct cpu **cpus;
156    
157            /*  Registered busses:  */
158            struct machine_bus *first_bus;
159            int     n_busses;
160    
161          /*  These are used by stuff in cpu.c, mostly:  */          /*  These are used by stuff in cpu.c, mostly:  */
162          int64_t ncycles;          int64_t ninstrs;
163          int64_t ncycles_show;          int64_t ninstrs_show;
164          int64_t ncycles_flush;          int64_t ninstrs_flush;
165          int64_t ncycles_since_gettimeofday;          int64_t ninstrs_since_gettimeofday;
166          struct timeval starttime;          struct timeval starttime;
         int     a_few_cycles;  
         int     a_few_instrs;  
167    
168          struct diskimage *first_diskimage;          struct diskimage *first_diskimage;
169    
# Line 149  struct machine { Line 176  struct machine {
176          int     register_dump;          int     register_dump;
177          int     arch_pagesize;          int     arch_pagesize;
178    
179            int     bootdev_type;
180            int     bootdev_id;
181            char    *bootstr;
182            char    *bootarg;
183    
184            struct debugger_gdb gdb;
185    
186            /*  Breakpoints:  */
187          int     n_breakpoints;          int     n_breakpoints;
188          char    *breakpoint_string[MAX_BREAKPOINTS];          char    *breakpoint_string[MAX_BREAKPOINTS];
189          uint64_t breakpoint_addr[MAX_BREAKPOINTS];          uint64_t breakpoint_addr[MAX_BREAKPOINTS];
# Line 164  struct machine { Line 199  struct machine {
199          int     cache_secondary_linesize;          int     cache_secondary_linesize;
200    
201          int     dbe_on_nonexistant_memaccess;          int     dbe_on_nonexistant_memaccess;
         int     dyntrans_alignment_check;  
         int     bintrans_enable;  
         int     old_bintrans_enable;  
         int     bintrans_enabled_from_start;  
         int     bintrans_size;  
202          int     instruction_trace;          int     instruction_trace;
         int     single_step_on_bad_addr;  
203          int     show_nr_of_instructions;          int     show_nr_of_instructions;
204            int     show_trace_tree;
205          int     show_symbolic_register_names;          int     show_symbolic_register_names;
         int64_t max_instructions;  
206          int     emulated_hz;          int     emulated_hz;
207          int     max_random_cycles_per_chunk;          int     allow_instruction_combinations;
         int     speed_tricks;  
208          char    *userland_emul;         /*  NULL for no userland emulation  */          char    *userland_emul;         /*  NULL for no userland emulation  */
209          int     force_netboot;          int     force_netboot;
210          int     slow_serial_interrupts_hack_for_linux;          int     slow_serial_interrupts_hack_for_linux;
211          uint64_t file_loaded_end_addr;          uint64_t file_loaded_end_addr;
212          char    *boot_kernel_filename;          char    *boot_kernel_filename;
213          char    *boot_string_argument;          char    *boot_string_argument;
   
214          int     automatic_clock_adjustment;          int     automatic_clock_adjustment;
215          int     exit_without_entering_debugger;          int     exit_without_entering_debugger;
         int     show_trace_tree;  
   
216          int     n_gfx_cards;          int     n_gfx_cards;
217    
218            /*  Instruction statistics:  */
219            char    *statistics_filename;
220            FILE    *statistics_file;
221            int     statistics_enabled;
222            char    *statistics_fields;     /*  "vpi" etc.  */
223    
224          /*  Machine-dependent: (PROM stuff, etc.)  */          /*  Machine-dependent: (PROM stuff, etc.)  */
225          union {          union {
226                  struct machine_arcbios  arc;                  struct machine_arcbios  arc;
227                    struct machine_pmax     pmax;
228                  struct machine_pc       pc;                  struct machine_pc       pc;
229          } md;          } md;
230    
231            /*  OpenFirmware:  */
232            struct of_data *of_data;
233    
234          /*  Bus-specific interrupt data:  */          /*  Bus-specific interrupt data:  */
235          struct isa_pic_data isa_pic_data;          struct isa_pic_data isa_pic_data;
236    
# Line 221  struct machine { Line 256  struct machine {
256                  struct bebox_data *bebox_data;                  struct bebox_data *bebox_data;
257                  struct prep_data *prep_data;                  struct prep_data *prep_data;
258                  struct cpc700_data *cpc700_data;                  struct cpc700_data *cpc700_data;
259                    struct gc_data *gc_data;
260                    struct v3_data *v3_data;
261          } md_int;          } md_int;
262    
263          /*  X11/framebuffer stuff:  */          /*  X11/framebuffer stuff:  */
# Line 236  struct machine { Line 273  struct machine {
273  };  };
274    
275    
276    /*  Tick function "prototype":  */
277    #define DEVICE_TICK(x)  void dev_ ## x ## _tick(struct cpu *cpu, void *extra)
278    
279    
280  /*  /*
281   *  Machine emulation types:   *  Machine emulation types:
282   */   */
# Line 253  struct machine { Line 294  struct machine {
294  #define ARCH_HPPA               10  #define ARCH_HPPA               10
295  #define ARCH_I960               11  #define ARCH_I960               11
296  #define ARCH_AVR                12  #define ARCH_AVR                12
297  #define ARCH_NEWMIPS            13  #define ARCH_TRANSPUTER         13
298    
299  /*  MIPS:  */  /*  MIPS:  */
300  #define MACHINE_BAREMIPS        1000  #define MACHINE_BAREMIPS        1000
301  #define MACHINE_TESTMIPS        1001  #define MACHINE_TESTMIPS        1001
302  #define MACHINE_DEC             1002  #define MACHINE_PMAX            1002
303  #define MACHINE_COBALT          1003  #define MACHINE_COBALT          1003
304  #define MACHINE_HPCMIPS         1004  #define MACHINE_HPCMIPS         1004
305  #define MACHINE_PS2             1005  #define MACHINE_PS2             1005
306  #define MACHINE_SGI             1006  #define MACHINE_SGI             1006
307  #define MACHINE_ARC             1007  #define MACHINE_ARC             1007
308  #define MACHINE_MESHCUBE        1008  #define MACHINE_NETGEAR         1008
309  #define MACHINE_NETGEAR         1009  #define MACHINE_SONYNEWS        1009
310  #define MACHINE_SONYNEWS        1010  #define MACHINE_EVBMIPS         1010
311  #define MACHINE_EVBMIPS         1011  #define MACHINE_PSP             1011
312  #define MACHINE_PSP             1012  #define MACHINE_ALGOR           1012
313  #define MACHINE_ALGOR           1013  #define MACHINE_QEMU_MIPS       1013
314    
315  /*  PPC:  */  /*  PPC:  */
316  #define MACHINE_BAREPPC         2000  #define MACHINE_BAREPPC         2000
# Line 281  struct machine { Line 322  struct machine {
322  #define MACHINE_PREP            2006  #define MACHINE_PREP            2006
323  #define MACHINE_MACPPC          2007  #define MACHINE_MACPPC          2007
324  #define MACHINE_DB64360         2008  #define MACHINE_DB64360         2008
325    #define MACHINE_MVMEPPC         2009
326    
327  /*  SPARC:  */  /*  SPARC:  */
328  #define MACHINE_BARESPARC       3000  #define MACHINE_BARESPARC       3000
329  #define MACHINE_TESTSPARC       3001  #define MACHINE_TESTSPARC       3001
330  #define MACHINE_ULTRA1          3002  #define MACHINE_SPARC           3002
331    
332  /*  Alpha:  */  /*  Alpha:  */
333  #define MACHINE_BAREALPHA       4000  #define MACHINE_BAREALPHA       4000
# Line 306  struct machine { Line 348  struct machine {
348  #define MACHINE_SHARK           6006  #define MACHINE_SHARK           6006
349  #define MACHINE_IQ80321         6007  #define MACHINE_IQ80321         6007
350  #define MACHINE_IYONIX          6008  #define MACHINE_IYONIX          6008
351    #define MACHINE_TS7200          6009
352    
353  /*  IA64:  */  /*  IA64:  */
354  #define MACHINE_BAREIA64        7000  #define MACHINE_BAREIA64        7000
# Line 319  struct machine { Line 362  struct machine {
362  #define MACHINE_BARESH          9000  #define MACHINE_BARESH          9000
363  #define MACHINE_TESTSH          9001  #define MACHINE_TESTSH          9001
364  #define MACHINE_HPCSH           9002  #define MACHINE_HPCSH           9002
365    #define MACHINE_DREAMCAST       9003
366    
367  /*  HPPA:  */  /*  HPPA:  */
368  #define MACHINE_BAREHPPA        10000  #define MACHINE_BAREHPPA        10000
# Line 330  struct machine { Line 374  struct machine {
374    
375  /*  AVR:  */  /*  AVR:  */
376  #define MACHINE_BAREAVR         12000  #define MACHINE_BAREAVR         12000
377    #define MACHINE_AVR_PAL         12001
378    #define MACHINE_AVR_MAHPONG     12002
379    
380  /*  NEWMIPS:  */  /*  TRANSPUTER:  */
381  #define MACHINE_BARENEWMIPS     13000  #define MACHINE_BARETRANSPUTER  13000
 #define MACHINE_TESTNEWMIPS     13001  
382    
383  /*  Other "pseudo"-machines:  */  /*  Other "pseudo"-machines:  */
384  #define MACHINE_NONE            0  #define MACHINE_NONE            0
# Line 375  struct machine { Line 420  struct machine {
420  #define MACHINE_HPCSH_JORNADA680                1  #define MACHINE_HPCSH_JORNADA680                1
421  #define MACHINE_HPCSH_JORNADA690                2  #define MACHINE_HPCSH_JORNADA690                2
422    
 /*  Playstation 2:  */  
 #define PLAYSTATION2_BDA        0xffffffffa0001000ULL  
 #define PLAYSTATION2_OPTARGS    0xffffffff81fff100ULL  
 #define PLAYSTATION2_SIFBIOS    0xffffffffbfc10000ULL  
   
423  /*  SGI and ARC:  */  /*  SGI and ARC:  */
424  #define MACHINE_ARC_NEC_RD94            1  #define MACHINE_ARC_NEC_RD94            1
425  #define MACHINE_ARC_JAZZ_PICA           2  #define MACHINE_ARC_JAZZ_PICA           2
# Line 397  struct machine { Line 437  struct machine {
437  /*  EVBMIPS:  */  /*  EVBMIPS:  */
438  #define MACHINE_EVBMIPS_MALTA           1  #define MACHINE_EVBMIPS_MALTA           1
439  #define MACHINE_EVBMIPS_MALTA_BE        2  #define MACHINE_EVBMIPS_MALTA_BE        2
440  #define MACHINE_EVBMIPS_PB1000          3  #define MACHINE_EVBMIPS_MESHCUBE        3
441    #define MACHINE_EVBMIPS_PB1000          4
442    
443    /*  PReP:  */
444    #define MACHINE_PREP_IBM6050            1
445    #define MACHINE_PREP_MVME2400           2
446    
447    /*  Sun SPARC:  */
448    #define MACHINE_SPARC_SS5               1
449    #define MACHINE_SPARC_SS20              2
450    #define MACHINE_SPARC_ULTRA1            3
451    #define MACHINE_SPARC_ULTRA60           4
452    
453  /*  MacPPC:  TODO: Real model names  */  /*  MacPPC:  TODO: Real model names  */
454  #define MACHINE_MACPPC_G4               1  #define MACHINE_MACPPC_G3               1
455  #define MACHINE_MACPPC_G5               2  #define MACHINE_MACPPC_G4               2
456    #define MACHINE_MACPPC_G5               3
457    
458    /*  MVMEPPC  */
459    #define MACHINE_MVMEPPC_1600            1
460    #define MACHINE_MVMEPPC_2100            2
461    #define MACHINE_MVMEPPC_5500            3
462    
463  /*  X86:  */  /*  X86:  */
464  #define MACHINE_X86_GENERIC             1  #define MACHINE_X86_GENERIC             1
465  #define MACHINE_X86_XT                  2  #define MACHINE_X86_XT                  2
466    
467    
468  /*  /*  For the automachine system:  */
469   *  Problem: kernels seem to be loaded at low addresses in RAM, so  struct machine_entry_subtype {
470   *  storing environment strings and memory descriptors there is a bad          int                     machine_subtype;/*  Old-style subtype  */
471   *  idea. They are stored at 0xbfc..... instead.  The ARC SPB must          const char              *name;          /*  Official name  */
472   *  be at physical address 0x1000 though.          int                     n_aliases;
473   */          char                    **aliases;      /*  Aliases  */
474  #define SGI_SPB_ADDR            0xffffffff80001000ULL  };
475  /*  0xbfc10000 is firmware callback vector stuff  */  
476  #define ARC_FIRMWARE_VECTORS    0xffffffffbfc80000ULL  struct machine_entry {
477  #define ARC_FIRMWARE_ENTRIES    0xffffffffbfc88000ULL          struct machine_entry    *next;
478  #define ARC_ARGV_START          0xffffffffbfc90000ULL  
479  #define ARC_ENV_STRINGS         0xffffffffbfc98000ULL          /*  Machine type:  */
480  #define ARC_ENV_POINTERS        0xffffffffbfc9d000ULL          int                     arch;
481  #define SGI_SYSID_ADDR          0xffffffffbfca1800ULL          int                     machine_type;   /*  Old-style type  */
482  #define ARC_DSPSTAT_ADDR        0xffffffffbfca1c00ULL          const char              *name;          /*  Official name  */
483  #define ARC_MEMDESC_ADDR        0xffffffffbfca1c80ULL          int                     n_aliases;
484  #define ARC_CONFIG_DATA_ADDR    0xffffffffbfca2000ULL          char                    **aliases;      /*  Aliases  */
485  #define FIRST_ARC_COMPONENT     0xffffffffbfca8000ULL  
486  #define ARC_PRIVATE_VECTORS     0xffffffffbfcb0000ULL          void                    (*setup)(struct machine *, struct cpu *);
487  #define ARC_PRIVATE_ENTRIES     0xffffffffbfcb8000ULL          void                    (*set_default_cpu)(struct machine *);
488            void                    (*set_default_ram)(struct machine *);
489    
490            /*  Machine subtypes:  */
491            int                     n_subtypes;
492            struct machine_entry_subtype **subtype;
493    };
494    
495    #define MACHINE_SETUP_TYPE(n)   void (*n)(struct machine *, struct cpu *)
496    #define MACHINE_SETUP(x)        void machine_setup_ ## x(struct machine *machine, \
497                                        struct cpu *cpu)
498    #define MACHINE_DEFAULT_CPU(x)  void machine_default_cpu_ ## x(struct machine *machine)
499    #define MACHINE_DEFAULT_RAM(x)  void machine_default_ram_ ## x(struct machine *machine)
500    #define MACHINE_REGISTER(x)     void machine_register_ ## x(void)
501    #define MR_DEFAULT(x,name,arch,type) struct machine_entry               \
502                *me = machine_entry_new(name,arch,type);                    \
503            me->setup = machine_setup_ ## x;                                \
504            me->set_default_cpu = machine_default_cpu_ ## x;                \
505            machine_entry_register(me, arch);
506    void automachine_init(void);
507    
508    
509  /*  machine.c:  */  /*  machine.c:  */
# Line 435  struct machine *machine_new(char *name, Line 511  struct machine *machine_new(char *name,
511  int machine_name_to_type(char *stype, char *ssubtype,  int machine_name_to_type(char *stype, char *ssubtype,
512          int *type, int *subtype, int *arch);          int *type, int *subtype, int *arch);
513  void machine_add_tickfunction(struct machine *machine,  void machine_add_tickfunction(struct machine *machine,
514          void (*func)(struct cpu *, void *), void *extra, int clockshift);          void (*func)(struct cpu *, void *), void *extra,
515            int clockshift, double hz);
516    void machine_statistics_init(struct machine *, char *fname);
517    void machine_register(char *name, MACHINE_SETUP_TYPE(setup));
518  void dump_mem_string(struct cpu *cpu, uint64_t addr);  void dump_mem_string(struct cpu *cpu, uint64_t addr);
519  void store_string(struct cpu *cpu, uint64_t addr, char *s);  void store_string(struct cpu *cpu, uint64_t addr, char *s);
520  int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64);  int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64);
# Line 451  void store_16bit_word_in_host(struct cpu Line 530  void store_16bit_word_in_host(struct cpu
530  uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr);  uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr);
531  uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr);  uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr);
532  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);
533    void add_environment_string(struct cpu *cpu, char *s, uint64_t *addr);
534    void add_environment_string_dual(struct cpu *cpu,
535            uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2);
536    void store_pointer_and_advance(struct cpu *cpu, uint64_t *addrp,
537            uint64_t data, int flag64);
538  void machine_setup(struct machine *);  void machine_setup(struct machine *);
539  void machine_memsize_fix(struct machine *);  void machine_memsize_fix(struct machine *);
540  void machine_default_cputype(struct machine *);  void machine_default_cputype(struct machine *);
541  void machine_dumpinfo(struct machine *);  void machine_dumpinfo(struct machine *);
542    void machine_bus_register(struct machine *, char *busname,
543            void (*debug_dump)(void *), void *extra);
544    int machine_run(struct machine *machine);
545  void machine_list_available_types_and_cpus(void);  void machine_list_available_types_and_cpus(void);
546    struct machine_entry *machine_entry_new(const char *name,
547            int arch, int oldstyle_type);
548    void machine_entry_add_alias(struct machine_entry *me, const char *name);
549    void machine_entry_add_subtype(struct machine_entry *me, const char *name,
550            int oldstyle_subtype, ...);
551    void machine_entry_register(struct machine_entry *me, int arch);
552  void machine_init(void);  void machine_init(void);
553    
554    

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

  ViewVC Help
Powered by ViewVC 1.1.26