emul.cc Source File
Back to the index.
Go to the documentation of this file.
79 static void add_breakpoints(
struct machine *m)
99 "ERROR! Breakpoint '%s' could not be"
115 if ((dp >> 32) == 0 && ((dp >> 31) & 1))
116 dp |= 0xffffffff00000000ULL;
121 debug(
"breakpoint %i: 0x%" PRIx64, i, dp);
132 static void fix_console(
void)
148 memset(e, 0,
sizeof(
struct emul));
225 snprintf(tmpstr,
sizeof(tmpstr),
"machine[%i]", i);
239 static void add_arc_components(
struct machine *m)
242 uint64_t start =
cpu->
pc & 0x1fffffff;
243 uint64_t len = 0xc00000 - start;
245 uint64_t scsicontroller, scsidevice, scsidisk;
247 if ((
cpu->
pc >> 60) != 0xf) {
248 start =
cpu->
pc & 0xffffffffffULL;
249 len = 0xc00000 - start;
269 if (scsicontroller == 0)
278 char component_string[100];
279 const char *name =
"DEC RZ58 (C) DEC2000";
294 name =
"NEC CD-ROM CDR-210P 1.0 ";
299 a, flags, 1, 2, d->
id, 0xffffffff,
300 name, scsicontroller, NULL, 0);
304 b, flags, 1, 2, 0, 0xffffffff, NULL,
305 scsidevice, NULL, 0);
313 snprintf(component_string,
314 sizeof(component_string),
315 "scsi(0)cdrom(%i)", d->
id);
317 component_string, scsidevice);
319 snprintf(component_string,
320 sizeof(component_string),
321 "scsi(0)cdrom(%i)fdisk(0)", d->
id);
323 component_string, scsidisk);
325 snprintf(component_string,
326 sizeof(component_string),
327 "scsi(0)disk(%i)", d->
id);
329 component_string, scsidevice);
331 snprintf(component_string,
332 sizeof(component_string),
333 "scsi(0)disk(%i)rdisk(0)", d->
id);
335 component_string, scsidisk);
355 int n_devices,
char **device_names)
359 uint64_t memory_amount, entrypoint = 0, gp = 0, toc = 0;
370 fatal(
"No machine type specified?\n");
411 for (i=0; i<m->
ncpus; i++) {
413 if (m->
cpus[i] == NULL) {
414 fprintf(stderr,
"Unable to create CPU object. "
434 unsigned char data[256];
436 for (j=0; j<
sizeof(
data); j++)
437 data[j] = random() & 255;
443 for (i=0; i<n_devices; i++)
455 fprintf(stderr,
"\nNo executable files were"
456 " specified, and booting directly from disk"
461 fprintf(stderr,
"No executable file(s) loaded, and "
462 "we are not booting directly from a disk image."
470 char *name_to_load = *load_names;
471 int remove_after_load = 0;
474 if (name_to_load[0] == 8) {
476 remove_after_load = 1;
483 tmp_f = fopen(name_to_load,
"r");
485 unsigned char buf[2];
488 memset(buf, 0,
sizeof(buf));
489 res = fread(buf, 1,
sizeof(buf), tmp_f);
491 if (res ==
sizeof(buf) &&
492 buf[0] == 0x1f && buf[1] == 0x8b) {
493 size_t zzlen =
strlen(name_to_load)*2 + 100;
497 debug(
"gunziping %s\n", name_to_load);
505 if (remove_after_load) {
506 snprintf(zz, zzlen,
"mv %s %s.gz",
507 name_to_load, name_to_load);
510 snprintf(zz, zzlen,
"gunzip %s.gz",
518 const char *tmpdir = getenv(
"TMPDIR");
524 (
char*) malloc(300));
525 snprintf(new_temp_name, 300,
526 "%s/gxemul.XXXXXXXXXXXX", tmpdir);
528 tmpfile_handle = mkstemp(new_temp_name);
529 close(tmpfile_handle);
530 snprintf(zz, zzlen,
"gunzip -c '%s' > "
531 "%s", name_to_load, new_temp_name);
534 name_to_load = new_temp_name;
535 remove_after_load = 1;
550 if (remove_after_load) {
551 debug(
"removing %s\n", name_to_load);
552 unlink(name_to_load);
558 cpu->
pc = entrypoint;
569 fatal(
"ARM: misaligned pc: TODO\n");
582 fatal(
"M88K: lowest bits of pc set: TODO\n");
585 cpu->
pc &= 0xfffffffc;
589 if ((
cpu->
pc >> 32) == 0 && (
cpu->
pc & 0x80000000ULL))
590 cpu->
pc |= 0xffffffff00000000ULL;
597 0xffffffff00000000ULL;
606 cpu->
pc &= 0xffffffffULL;
611 cpu->
pc &= 0xffffffffULL;
616 fatal(
"emul_machine_setup(): Internal error: "
617 "Unimplemented arch %i\n", m->
arch);
629 for (i=0; i<m->
ncpus; i++)
640 for (i=0; i<m->
ncpus; i++)
651 0x9fff0000, 0x10000,
"r2k3k_cache", 0, 0);
658 add_arc_components(m);
666 debug(
"0x%08" PRIx32, (uint32_t)
669 debug(
" (gp=0x%08" PRIx32
")", (uint32_t)
673 debug(
"0x%016" PRIx64, (uint64_t)
676 debug(
" (gp=0x%016" PRIx64
")", (uint64_t)
734 fprintf(stderr,
"emul_simple_init(): n_machines != 1\n");
740 debug(
"Simple setup...\n");
766 debug(
"Creating emulation from configfile \"%s\":\n", fname);
787 int i = 0, j, go = 1, n, anything;
792 fatal(
"No emulation defined. Aborting.\n");
797 fatal(
"No machine(s) defined. Aborting.\n");
922 printf(
"Press enter to quit.\n");
void file_load(struct machine *machine, struct memory *mem, char *filename, uint64_t *entrypointp, int arch, uint64_t *gpp, int *byte_orderp, uint64_t *tocp)
struct cpu_family * cpu_family_ptr_by_number(int arch)
struct mips_cpu_type_def cpu_type
#define COMPONENT_CLASS_PeripheralClass
int force_debugger_at_exit
void emul_destroy(struct emul *emul)
void x11_init(struct machine *machine)
struct cpu_family * cpu_family
void debugger_reset(void)
void cpu_run_deinit(struct machine *machine)
struct settings * settings
struct symbol_context symbol_context
struct breakpoints breakpoints
struct cpu * cpu_new(struct memory *mem, struct machine *machine, int cpu_id, char *name)
void arcbios_add_memory_descriptor(struct cpu *cpu, uint64_t base, uint64_t len, int arctype)
void settings_remove(struct settings *settings, const char *name)
#define COMPONENT_FLAG_ReadOnly
#define SETTINGS_FORMAT_STRING
#define SETTINGS_FORMAT_DECIMAL
void settings_add(struct settings *settings, const char *name, int writable, int type, int format, void *ptr)
void machine_destroy(struct machine *machine)
uint64_t arcbios_get_scsicontroller(struct machine *machine)
#define SETTINGS_TYPE_STRING
#define COMPONENT_FLAG_Removable
void machine_default_cputype(struct machine *)
addr & if(addr >=0x24 &&page !=NULL)
int use_random_bootstrap_cpu
void machine_memsize_fix(struct machine *)
void x11_check_event(struct emul *emul)
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f)
void debugger_execute_cmd(char *cmd, int cmd_len)
uint64_t arcbios_addchild_manual(struct cpu *cpu, uint64_t cclass, uint64_t type, uint64_t flags, uint64_t version, uint64_t revision, uint64_t key, uint64_t affinitymask, const char *identifier, uint64_t parent, void *config_data, size_t config_len)
int machine_run(struct machine *machine)
int console_charavail(int handle)
void cpu_show_cycles(struct machine *machine, int forced)
int64_t ninstrs_since_gettimeofday
void console_init_main(struct emul *emul)
struct diskimage * first_diskimage
void machine_setup(struct machine *)
int load_bootblock(struct machine *m, struct cpu *cpu, int *n_loadp, char ***load_namesp)
#define COMPONENT_TYPE_DiskController
#define NET_DEFAULT_IPV4_MASK
void emul_dumpinfo(struct emul *e)
void net_dumpinfo(struct net *net)
void emul_run(struct emul *emul)
#define NO_BYTE_ORDER_OVERRIDE
#define ENTER_SINGLE_STEPPING
void machine_dumpinfo(struct machine *)
void COMBINE() strlen(struct cpu *cpu, struct arm_instr_call *ic, int low_addr)
void fatal(const char *fmt,...)
void debugger_activate(int x)
void settings_remove_all(struct settings *settings)
void console_sigcont(int x)
void * device_add(struct machine *machine, const char *name_and_params)
int console_readchar(int handle)
int old_instruction_trace
struct settings * settings
#define ARCBIOS_MEM_FreeMemory
#define COMPONENT_CLASS_ControllerClass
struct emul * emul_new(char *name)
void emul_machine_setup(struct machine *m, int n_load, char **load_names, int n_devices, char **device_names)
#define NET_INIT_FLAG_GATEWAY
void debugger_init(struct emul *emul)
struct machine * machine_new(char *name, struct emul *emul, int id)
void arcbios_add_string_to_component(struct machine *machine, char *string, uint64_t component)
#define SETTINGS_TYPE_SUBSETTINGS
void emul_parse_config(struct emul *e, char *fname)
int get_symbol_addr(struct symbol_context *, const char *symbol, uint64_t *addr)
struct sh_cpu_type_def cpu_type
void settings_destroy(struct settings *settings)
void console_debug_dump(struct machine *machine)
#define COMPONENT_TYPE_DiskPeripheral
uint64_t gpr[N_MIPS_GPRS]
#define COMPONENT_FLAG_Input
void emul_simple_init(struct emul *emul)
#define COMPONENT_FLAG_Output
struct machine * emul_add_machine(struct emul *e, char *name)
#define DEBUG_INDENTATION
void add_symbol_name(struct symbol_context *, uint64_t addr, uint64_t len, const char *name, int type, int n_args)
#define COMPONENT_TYPE_FloppyDiskPeripheral
#define ARCBIOS_MEM_LoadedProgram
#define COMPONENT_TYPE_CDROMController
struct machine ** machines
#define NET_DEFAULT_IPV4_LEN
struct settings * settings_new(void)
void print_separator_line(void)
struct emul * emul_create_from_configfile(char *fname)
void console_deinit_main(void)
void symbol_recalc_sizes(struct symbol_context *)
struct memory * memory_new(uint64_t physical_max, int arch)
int(* memory_rw)(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int cache_flags)
struct net * net_init(struct emul *emul, int init_flags, const char *ipv4addr, int netipv4len, char **remote, int n_remote, int local_port, const char *settings_prefix)
void cpu_run_init(struct machine *machine)
void diskimage_dump_info(struct machine *machine)
void debug_indentation(int diff)
#define SETTINGS_TYPE_INT
#define CHECK_ALLOCATION(ptr)
Generated on Tue Mar 24 2020 14:04:48 for GXemul by
1.8.17