--- trunk/src/include/machine.h 2007/10/08 16:18:38 12 +++ trunk/src/include/machine.h 2007/10/08 16:22:11 40 @@ -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,7 +28,7 @@ * SUCH DAMAGE. * * - * $Id: machine.h,v 1.67 2005/08/16 05:37:13 debug Exp $ + * $Id: machine.h,v 1.162 2007/04/19 15:18:16 debug Exp $ */ #include @@ -36,62 +36,69 @@ #include "symbol.h" -#include "arcbios.h" -#include "machine_x86.h" +#include "machine_arc.h" +#include "machine_pmax.h" + #define MAX_BREAKPOINTS 8 -#define BREAKPOINT_FLAG_R 1 -#define MAX_TICK_FUNCTIONS 14 +#define MAX_TICK_FUNCTIONS 16 + +#define MAX_STATISTICS_FIELDS 8 struct cpu_family; struct diskimage; struct emul; struct fb_window; struct memory; +struct of_data; +struct settings; -/* Ugly: */ -struct kn230_csr; -struct kn02_csr; -struct dec_ioasic_data; -struct ps2_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; + +/* TODO: This should probably go away... */ struct isa_pic_data { - struct pic8259_data *pic1; - struct pic8259_data *pic2; -}; + struct pic8259_data *pic1; + struct pic8259_data *pic2; + int *pending_timer_interrupts; + int last_int; +}; -#define MACHINE_NAME_MAXBUF 200 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. "emul[0].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, .. */ + /* NOTE/TODO: This isn't working yet: */ + int cycle_accurate; /* Set to non-zero for cycle + accurate (slow) emulation. */ + + /* Name set by code in src/machines/machine_*.c: */ char *machine_name; + int stable; /* startup warning for non-stable + emulation modes. */ + /* The serial number is mostly used when emulating multiple machines in a network. nr_of_nics is the current nr of network cards, which is useful when emulating multiple cards in one machine: */ int serial_nr; int nr_of_nics; + /* TODO: How about multiple cpu familys in one machine? */ struct cpu_family *cpu_family; /* @@ -112,9 +119,7 @@ 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); + double tick_hz[MAX_TICK_FUNCTIONS]; char *cpu_name; /* TODO: remove this, there could be several cpus with different names in a machine */ @@ -126,13 +131,12 @@ struct cpu **cpus; /* These are used by stuff in cpu.c, mostly: */ - int64_t ncycles; - int64_t ncycles_show; - int64_t ncycles_flush; - int64_t ncycles_since_gettimeofday; + /* TODO: Move to cpu.h! */ + int64_t ninstrs; + int64_t ninstrs_show; + int64_t ninstrs_flush; + int64_t ninstrs_since_gettimeofday; struct timeval starttime; - int a_few_cycles; - int a_few_instrs; struct diskimage *first_diskimage; @@ -145,13 +149,19 @@ int register_dump; int arch_pagesize; + int bootdev_type; + int bootdev_id; + char *bootstr; + char *bootarg; + + /* 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_! */ + /* TODO: these should be _PER CPU_! */ int cache_picache; int cache_pdcache; int cache_secondary; @@ -160,62 +170,43 @@ int cache_secondary_linesize; int dbe_on_nonexistant_memaccess; - int dyntrans_alignment_check; - 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_trace_tree; int show_symbolic_register_names; - int64_t max_instructions; 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; + /* Instruction statistics: */ + char *statistics_filename; + FILE *statistics_file; + int statistics_enabled; + char *statistics_fields; /* "vpi" etc. */ + /* Machine-dependent: (PROM stuff, etc.) */ union { struct machine_arcbios arc; - struct machine_pc pc; + struct machine_pmax pmax; + struct of_data *of_data; } md; - /* 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 isa_pic_data isa_pic_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; - } md_int; + /* Bus-specific interrupt data: */ + /* TODO: Remove! */ + struct isa_pic_data isa_pic_data; /* X11/framebuffer stuff: */ int use_x11; int x11_scaledown; + int x11_scaleup; int x11_n_display_names; char **x11_display_names; int x11_current_display_name_nr; /* updated by x11.c */ @@ -225,6 +216,10 @@ }; +/* Tick function "prototype": */ +#define DEVICE_TICK(x) void dev_ ## x ## _tick(struct cpu *cpu, void *extra) + + /* * Machine emulation types: */ @@ -234,62 +229,74 @@ #define ARCH_PPC 2 #define ARCH_SPARC 3 #define ARCH_ALPHA 4 -#define ARCH_X86 5 -#define ARCH_ARM 6 -#define ARCH_IA64 7 -#define ARCH_M68K 8 +#define ARCH_ARM 5 +#define ARCH_SH 6 +#define ARCH_AVR 7 +#define ARCH_M88K 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_SONYNEWS 1010 -#define MACHINE_EVBMIPS 1011 -#define MACHINE_PSP 1012 +#define MACHINE_NETGEAR 1008 +#define MACHINE_SONYNEWS 1009 +#define MACHINE_EVBMIPS 1010 +#define MACHINE_PSP 1011 +#define MACHINE_ALGOR 1012 +#define MACHINE_QEMU_MIPS 1013 /* 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_SANDPOINT 2003 +#define MACHINE_BEBOX 2004 +#define MACHINE_PREP 2005 +#define MACHINE_MACPPC 2006 +#define MACHINE_MVMEPPC 2007 /* SPARC: */ #define MACHINE_BARESPARC 3000 #define MACHINE_TESTSPARC 3001 -#define MACHINE_ULTRA1 3002 +#define MACHINE_SPARC 3002 /* Alpha: */ #define MACHINE_BAREALPHA 4000 #define MACHINE_TESTALPHA 4001 #define MACHINE_ALPHA 4002 -/* X86: */ -#define MACHINE_BAREX86 5000 -#define MACHINE_X86 5001 - /* ARM: */ -#define MACHINE_BAREARM 6000 -#define MACHINE_TESTARM 6001 - -/* IA64: */ -#define MACHINE_BAREIA64 7000 -#define MACHINE_TESTIA64 7001 - -/* M68K: */ -#define MACHINE_BAREM68K 8000 -#define MACHINE_TESTM68K 8001 +#define MACHINE_BAREARM 5000 +#define MACHINE_TESTARM 5001 +#define MACHINE_CATS 5002 +#define MACHINE_HPCARM 5003 +#define MACHINE_ZAURUS 5004 +#define MACHINE_NETWINDER 5005 +#define MACHINE_SHARK 5006 +#define MACHINE_IQ80321 5007 +#define MACHINE_IYONIX 5008 +#define MACHINE_QEMU_ARM 5009 + +/* SH: */ +#define MACHINE_BARESH 6000 +#define MACHINE_TESTSH 6001 +#define MACHINE_HPCSH 6002 +#define MACHINE_DREAMCAST 6003 +#define MACHINE_LANDISK 6004 + +/* AVR: */ +#define MACHINE_BAREAVR 7000 +#define MACHINE_AVR_PAL 7001 +#define MACHINE_AVR_MAHPONG 7002 + +/* M88K: */ +#define MACHINE_BAREM88K 8000 +#define MACHINE_TESTM88K 8001 /* Other "pseudo"-machines: */ #define MACHINE_NONE 0 @@ -323,10 +330,13 @@ #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 @@ -338,48 +348,87 @@ #define MACHINE_ARC_JAZZ_M700 7 #define MACHINE_ARC_NEC_R96 8 +/* Algor: */ +#define MACHINE_ALGOR_P4032 4 +#define MACHINE_ALGOR_P5064 5 + /* EVBMIPS: */ #define MACHINE_EVBMIPS_MALTA 1 #define MACHINE_EVBMIPS_MALTA_BE 2 -#define MACHINE_EVBMIPS_PB1000 3 + +/* 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 + + +/* 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 */ +}; -/* X86: */ -#define MACHINE_X86_GENERIC 1 -#define MACHINE_X86_XT 2 +struct machine_entry { + struct machine_entry *next; + /* 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; +}; -/* - * 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 +#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_tickfunction(struct machine *machine, - void (*func)(struct cpu *, void *), void *extra, int clockshift); + void (*func)(struct cpu *, void *), void *extra, + int clockshift, double hz); +void machine_statistics_init(struct machine *, char *fname); +void machine_register(char *name, MACHINE_SETUP_TYPE(setup)); 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); @@ -392,14 +441,27 @@ uint64_t data32); void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data, uint16_t data16); +uint64_t load_64bit_word(struct cpu *cpu, uint64_t addr); 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 add_environment_string(struct cpu *cpu, char *s, uint64_t *addr); +void add_environment_string_dual(struct cpu *cpu, + uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2); +void store_pointer_and_advance(struct cpu *cpu, uint64_t *addrp, + uint64_t data, int flag64); 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);