--- trunk/src/include/machine.h 2007/10/08 16:18:00 4 +++ trunk/src/include/machine.h 2007/10/10 23:31:09 49 @@ -2,7 +2,7 @@ #define MACHINE_H /* - * Copyright (C) 2005 Anders Gavare. All rights reserved. + * Copyright (C) 2005-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,52 +28,93 @@ * SUCH DAMAGE. * * - * $Id: machine.h,v 1.46 2005/04/16 02:02:28 debug Exp $ + * $Id: machine.h,v 1.182 2007/08/29 20:36:49 debug Exp $ */ #include -#include #include "symbol.h" - -#define MAX_BREAKPOINTS 8 -#define BREAKPOINT_FLAG_R 1 - -#define MAX_TICK_FUNCTIONS 14 - struct cpu_family; struct diskimage; struct emul; struct fb_window; +struct machine_arcbios; +struct machine_pmax; struct memory; +struct of_data; +struct settings; + + +/* TODO: This should probably go away... */ +struct isa_pic_data { + struct pic8259_data *pic1; + struct pic8259_data *pic2; + + int *pending_timer_interrupts; + int last_int; +}; + +struct breakpoints { + int n; + + /* Arrays, with one element for each entry: */ + char **string; + uint64_t *addr; +}; + +struct statistics { + char *filename; + FILE *file; + int enabled; + char *fields; /* "vpi" etc. */ +}; -/* Ugly: */ -struct kn230_csr; -struct kn02_csr; -struct dec_ioasic_data; -struct ps2_data; -struct dec5800_data; -struct au1x00_ic_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; +struct tick_functions { + int n_entries; + /* Arrays, with one element for each entry: */ + int *ticks_till_next; + int *ticks_reset_value; + void (*(*f))(struct cpu *, void *); + void **extra; +}; + +struct x11_md { + /* X11/framebuffer stuff: */ + int in_use; + int scaledown; + int scaleup; + int n_display_names; + char **display_names; + int current_display_name_nr; /* updated by x11.c */ + + int n_fb_windows; + struct fb_window **fb_windows; +}; + + +/* + * The machine struct: + */ struct machine { /* Pointer back to the emul struct we are in: */ struct emul *emul; + /* Settings: */ + struct settings *settings; + /* Name as choosen by the user: */ char *name; + /* Full "path" to the machine, e.g. "machine[0]": */ + char *path; + int arch; /* ARCH_MIPS, ARCH_PPC, .. */ - int machine_type; /* MACHINE_DEC, .. */ + int machine_type; /* MACHINE_PMAX, .. */ int machine_subtype; /* MACHINE_DEC_3MAX_5000, .. */ + /* Name set by code in src/machines/machine_*.c: */ char *machine_name; /* The serial number is mostly used when emulating multiple machines @@ -82,29 +123,15 @@ int serial_nr; int nr_of_nics; + /* TODO: How about multiple cpu familys in one machine? */ struct cpu_family *cpu_family; - /* - * The "mainbus": - * - * o) memory - * o) devices - * o) CPUs - */ - struct memory *memory; int main_console_handle; - /* Hardware devices, run every x clock cycles. */ - int n_tick_entries; - int ticks_till_next[MAX_TICK_FUNCTIONS]; - int ticks_reset_value[MAX_TICK_FUNCTIONS]; - void (*tick_func[MAX_TICK_FUNCTIONS])(struct cpu *, void *); - void *tick_extra[MAX_TICK_FUNCTIONS]; - - void (*md_interrupt)(struct machine *m, struct cpu *cpu, - int irq_nr, int assert); + /* Tick functions (e.g. hardware devices): */ + struct tick_functions tick_functions; char *cpu_name; /* TODO: remove this, there could be several cpus with different names in a machine */ @@ -115,14 +142,6 @@ int ncpus; struct cpu **cpus; - /* These are used by stuff in cpu.c, mostly: */ - struct timeval starttime; - int64_t ncycles; - int64_t ncycles_show; - int64_t ncycles_flush; - int a_few_cycles; - int a_few_instrs; - struct diskimage *first_diskimage; struct symbol_context symbol_context; @@ -132,74 +151,54 @@ int memory_offset_in_mb; int prom_emulation; int register_dump; + int arch_pagesize; + + int bootdev_type; + int bootdev_id; + char *bootstr; + char *bootarg; + + /* Breakpoints: */ + struct breakpoints breakpoints; - int n_breakpoints; - char *breakpoint_string[MAX_BREAKPOINTS]; - uint64_t breakpoint_addr[MAX_BREAKPOINTS]; - int breakpoint_flags[MAX_BREAKPOINTS]; - - /* Cache sizes: (1 << x) x=0 for default values */ - /* TODO: these are _PER CPU_! */ - int cache_picache; - int cache_pdcache; - int cache_secondary; - int cache_picache_linesize; - int cache_pdcache_linesize; - int cache_secondary_linesize; - - int dbe_on_nonexistant_memaccess; - int bintrans_enable; - int old_bintrans_enable; - int bintrans_enabled_from_start; - int bintrans_size; + int halt_on_nonexistant_memaccess; int instruction_trace; - int single_step_on_bad_addr; int show_nr_of_instructions; - int show_symbolic_register_names; - int64_t max_instructions; + int show_trace_tree; int emulated_hz; - int max_random_cycles_per_chunk; - int speed_tricks; + int allow_instruction_combinations; char *userland_emul; /* NULL for no userland emulation */ int force_netboot; int slow_serial_interrupts_hack_for_linux; uint64_t file_loaded_end_addr; char *boot_kernel_filename; char *boot_string_argument; - - int automatic_clock_adjustment; int exit_without_entering_debugger; - int show_trace_tree; - int n_gfx_cards; - /* Yuck, this is ugly: */ - 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 crime_data *crime_data; - struct mace_data *mace_data; - struct sgi_ip20_data *sgi_ip20_data; - struct sgi_ip22_data *sgi_ip22_data; - struct sgi_ip30_data *sgi_ip30_data; + /* Instruction statistics: */ + struct statistics statistics; - /* X11/framebuffer stuff: */ - int use_x11; - int x11_scaledown; - int x11_n_display_names; - char **x11_display_names; - int x11_current_display_name_nr; /* updated by x11.c */ + /* X11/framebuffer stuff (per machine): */ + struct x11_md x11_md; - int n_fb_windows; - struct fb_window **fb_windows; + /* Machine-dependent: (PROM stuff, etc.) */ + union { + struct machine_arcbios *arc; + struct machine_pmax *pmax; + struct of_data *of_data; + } md; + + /* Bus-specific interrupt data: */ + /* TODO: Remove! */ + struct isa_pic_data isa_pic_data; }; +/* Tick function "prototype": */ +#define DEVICE_TICK(x) void dev_ ## x ## _tick(struct cpu *cpu, void *extra) + + /* * Machine emulation types: */ @@ -208,55 +207,69 @@ #define ARCH_MIPS 1 #define ARCH_PPC 2 #define ARCH_SPARC 3 -#define ARCH_URISC 4 -#define ARCH_HPPA 5 -#define ARCH_ALPHA 6 -#define ARCH_X86 7 +#define ARCH_ALPHA 4 +#define ARCH_ARM 5 +#define ARCH_SH 6 +#define ARCH_M88K 7 +#define ARCH_M32R 8 /* MIPS: */ #define MACHINE_BAREMIPS 1000 #define MACHINE_TESTMIPS 1001 -#define MACHINE_DEC 1002 +#define MACHINE_PMAX 1002 #define MACHINE_COBALT 1003 #define MACHINE_HPCMIPS 1004 #define MACHINE_PS2 1005 #define MACHINE_SGI 1006 #define MACHINE_ARC 1007 -#define MACHINE_MESHCUBE 1008 -#define MACHINE_NETGEAR 1009 -#define MACHINE_WRT54G 1010 -#define MACHINE_SONYNEWS 1011 +#define MACHINE_EVBMIPS 1008 +#define MACHINE_ALGOR 1009 +#define MACHINE_QEMU_MIPS 1010 /* PPC: */ #define MACHINE_BAREPPC 2000 #define MACHINE_TESTPPC 2001 -#define MACHINE_WALNUT 2002 -#define MACHINE_PMPPC 2003 -#define MACHINE_SANDPOINT 2004 -#define MACHINE_BEBOX 2005 -#define MACHINE_PREP 2006 -#define MACHINE_MACPPC 2007 -#define MACHINE_DB64360 2008 +#define MACHINE_PMPPC 2002 +#define MACHINE_BEBOX 2003 +#define MACHINE_PREP 2004 +#define MACHINE_MACPPC 2005 +#define MACHINE_MVMEPPC 2006 +#define MACHINE_SANDPOINT 2007 /* SPARC: */ #define MACHINE_BARESPARC 3000 -#define MACHINE_ULTRA1 3001 - -/* URISC: */ -#define MACHINE_BAREURISC 4000 -#define MACHINE_TESTURISC 4001 - -/* HPPA: */ -#define MACHINE_BAREHPPA 5000 -#define MACHINE_TESTHPPA 5001 +#define MACHINE_TESTSPARC 3001 +#define MACHINE_SPARC 3002 /* Alpha: */ -#define MACHINE_BAREALPHA 6000 -#define MACHINE_TESTALPHA 6001 - -/* X86: */ -#define MACHINE_BAREX86 7000 -#define MACHINE_X86 7001 +#define MACHINE_BAREALPHA 4000 +#define MACHINE_TESTALPHA 4001 +#define MACHINE_ALPHA 4002 + +/* ARM: */ +#define MACHINE_BAREARM 5000 +#define MACHINE_TESTARM 5001 +#define MACHINE_CATS 5002 +#define MACHINE_HPCARM 5003 +#define MACHINE_NETWINDER 5004 +#define MACHINE_IQ80321 5005 +#define MACHINE_QEMU_ARM 5006 + +/* SH: */ +#define MACHINE_BARESH 6000 +#define MACHINE_TESTSH 6001 +#define MACHINE_HPCSH 6002 +#define MACHINE_DREAMCAST 6003 +#define MACHINE_LANDISK 6004 + +/* M88K: */ +#define MACHINE_BAREM88K 7000 +#define MACHINE_TESTM88K 7001 +#define MACHINE_MVME88K 7002 + +/* M32R: */ +#define MACHINE_BAREM32R 8000 +#define MACHINE_TESTM32R 8001 /* Other "pseudo"-machines: */ #define MACHINE_NONE 0 @@ -280,9 +293,7 @@ #define DEC_PROM_TCINFO 0xffffffffbfc2c000ULL #define DEC_MEMMAP_ADDR 0xffffffffbfc30000ULL - /* HPCmips: */ -/* Machine types: */ #define MACHINE_HPCMIPS_CASIO_BE300 1 #define MACHINE_HPCMIPS_CASIO_E105 2 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_770 3 @@ -292,73 +303,116 @@ #define MACHINE_HPCMIPS_AGENDA_VR3 7 #define MACHINE_HPCMIPS_IBM_WORKPAD_Z50 8 -/* Playstation 2: */ -#define PLAYSTATION2_BDA 0xffffffffa0001000ULL -#define PLAYSTATION2_OPTARGS 0xffffffff81fff100ULL -#define PLAYSTATION2_SIFBIOS 0xffffffffbfc10000ULL +/* HPCarm: */ +#define MACHINE_HPCARM_IPAQ 1 +#define MACHINE_HPCARM_JORNADA720 2 + +/* HPCsh: */ +#define MACHINE_HPCSH_JORNADA680 1 +#define MACHINE_HPCSH_JORNADA690 2 /* SGI and ARC: */ -#define MACHINE_ARC_NEC_RD94 1 -#define MACHINE_ARC_JAZZ_PICA 2 -#define MACHINE_ARC_NEC_R94 3 -#define MACHINE_ARC_DESKTECH_TYNE 4 -#define MACHINE_ARC_JAZZ_MAGNUM 5 -#define MACHINE_ARC_NEC_R98 6 -#define MACHINE_ARC_JAZZ_M700 7 -#define MACHINE_ARC_NEC_R96 8 +#define MACHINE_ARC_JAZZ_PICA 1 +#define MACHINE_ARC_JAZZ_MAGNUM 2 + +/* Algor: */ +#define MACHINE_ALGOR_P4032 1 +#define MACHINE_ALGOR_P5064 2 + +/* EVBMIPS: */ +#define MACHINE_EVBMIPS_MALTA 1 +#define MACHINE_EVBMIPS_MALTA_BE 2 + +/* PReP: */ +#define MACHINE_PREP_IBM6050 1 +#define MACHINE_PREP_MVME2400 2 + +/* Sun SPARC: */ +#define MACHINE_SPARC_SS5 1 +#define MACHINE_SPARC_SS20 2 +#define MACHINE_SPARC_ULTRA1 3 +#define MACHINE_SPARC_ULTRA60 4 +#define MACHINE_SPARC_SUN4V 5 /* MacPPC: TODO: Real model names */ -#define MACHINE_MACPPC_G4 1 -#define MACHINE_MACPPC_G5 2 +#define MACHINE_MACPPC_G3 1 +#define MACHINE_MACPPC_G4 2 +#define MACHINE_MACPPC_G5 3 + +/* MVMEPPC */ +#define MACHINE_MVMEPPC_1600 1 +#define MACHINE_MVMEPPC_2100 2 +#define MACHINE_MVMEPPC_5500 3 + +/* MVME88K */ +#define MACHINE_MVME88K_187 1 +#define MACHINE_MVME88K_188 2 +#define MACHINE_MVME88K_197 3 + + +/* For the automachine system: */ +struct machine_entry_subtype { + int machine_subtype;/* Old-style subtype */ + const char *name; /* Official name */ + int n_aliases; + char **aliases; /* Aliases */ +}; +struct machine_entry { + struct machine_entry *next; -/* - * 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 + /* Machine type: */ + int arch; + int machine_type; /* Old-style type */ + const char *name; /* Official name */ + int n_aliases; + char **aliases; /* Aliases */ + + void (*setup)(struct machine *, struct cpu *); + void (*set_default_cpu)(struct machine *); + void (*set_default_ram)(struct machine *); + + /* Machine subtypes: */ + int n_subtypes; + struct machine_entry_subtype **subtype; +}; + +#define MACHINE_SETUP_TYPE(n) void (*n)(struct machine *, struct cpu *) +#define MACHINE_SETUP(x) void machine_setup_ ## x(struct machine *machine, \ + struct cpu *cpu) +#define MACHINE_DEFAULT_CPU(x) void machine_default_cpu_ ## x(struct machine *machine) +#define MACHINE_DEFAULT_RAM(x) void machine_default_ram_ ## x(struct machine *machine) +#define MACHINE_REGISTER(x) void machine_register_ ## x(void) +#define MR_DEFAULT(x,name,arch,type) struct machine_entry \ + *me = machine_entry_new(name,arch,type); \ + me->setup = machine_setup_ ## x; \ + me->set_default_cpu = machine_default_cpu_ ## x; \ + machine_entry_register(me, arch); +void automachine_init(void); /* machine.c: */ -struct machine *machine_new(char *name, struct emul *emul); +struct machine *machine_new(char *name, struct emul *emul, int id); +void machine_destroy(struct machine *machine); int machine_name_to_type(char *stype, char *ssubtype, int *type, int *subtype, int *arch); +void machine_add_breakpoint_string(struct machine *machine, char *str); void machine_add_tickfunction(struct machine *machine, void (*func)(struct cpu *, void *), void *extra, int clockshift); -void dump_mem_string(struct cpu *cpu, uint64_t addr); -void store_string(struct cpu *cpu, uint64_t addr, char *s); -int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64); -int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32); -int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16); -void store_64bit_word_in_host(struct cpu *cpu, unsigned char *data, - uint64_t data32); -void store_32bit_word_in_host(struct cpu *cpu, unsigned char *data, - uint64_t data32); -void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data, - uint16_t data16); -uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr); -uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr); -void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len); +void machine_statistics_init(struct machine *, char *fname); +void machine_register(char *name, MACHINE_SETUP_TYPE(setup)); void machine_setup(struct machine *); void machine_memsize_fix(struct machine *); void machine_default_cputype(struct machine *); void machine_dumpinfo(struct machine *); +int machine_run(struct machine *machine); void machine_list_available_types_and_cpus(void); +struct machine_entry *machine_entry_new(const char *name, + int arch, int oldstyle_type); +void machine_entry_add_alias(struct machine_entry *me, const char *name); +void machine_entry_add_subtype(struct machine_entry *me, const char *name, + int oldstyle_subtype, ...); +void machine_entry_register(struct machine_entry *me, int arch); void machine_init(void);