提交 9738abcc 编写于 作者: Z Zihao Yu

Merge branch 'fix-difftest' into 'rv64'

Fix difftest

See merge request projectn/nemu!5
#include "common.h"
#include "device/map.h"
#define ARGSROM_MMIO 0xa2000000
static uint8_t *argsrom_base;
char* get_mainargs(void);
void init_argsrom() {
argsrom_base = new_space(4096);
strcpy((char *)argsrom_base, get_mainargs());
add_mmio_map("argsrom", ARGSROM_MMIO, argsrom_base, 4096, NULL);
}
#include "common.h"
void init_argsrom();
#ifdef HAS_IOE
#include <sys/time.h>
......@@ -65,7 +63,6 @@ void sdl_clear_event_queue() {
}
void init_device() {
init_argsrom();
init_serial();
init_timer();
init_vga();
......@@ -85,7 +82,6 @@ void init_device() {
#else
void init_device() {
init_argsrom();
}
#endif /* HAS_IOE */
......@@ -17,6 +17,14 @@ static bool is_detach = false;
void difftest_skip_ref() {
if (is_detach) return;
is_skip_ref = true;
// If such an instruction is one of the instruction packing in QEMU
// (see below), we end the process of catching up with QEMU's pc to
// keep the consistent behavior in our best.
// Note that this is still not perfect: if the packed instructions
// already write some memory, and the incoming instruction in NEMU
// will load that memory, we will encounter false negative. But such
// situation is infrequent.
skip_dut_nr_instr = 0;
}
// this is used to deal with instruction packing in QEMU.
......@@ -70,6 +78,8 @@ void init_difftest(char *ref_so_file, long img_size) {
ref_difftest_init();
ref_difftest_memcpy_from_dut(PC_START, guest_to_host(IMAGE_START), img_size);
char *mainargs = guest_to_host(0);
ref_difftest_memcpy_from_dut(PC_START - IMAGE_START, mainargs, strlen(mainargs) + 1);
ref_difftest_setregs(&cpu);
}
......
......@@ -55,6 +55,9 @@ static inline long load_img() {
assert(ret == 1);
fclose(fp);
// mainargs
strcpy(guest_to_host(0), mainargs);
}
return size;
}
......@@ -77,10 +80,6 @@ static inline void parse_args(int argc, char *argv[]) {
}
}
char* get_mainargs(void) {
return mainargs;
}
int init_monitor(int argc, char *argv[]) {
/* Perform some global initialization. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册