Skip to content

Commit

Permalink
ram: overwrite gcpt
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokamikami committed Mar 22, 2024
1 parent f8df21a commit d496ffc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/test/csrc/common/ram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ void LinearizedFootprintsMemory::save_linear_memory(const char *filename) {
out_file.close();
}

void overwrite_ram(char *gcpt_restore, uint64_t overwrite_nbytes) {
InputReader *reader = new FileReader(gcpt_restore);
int overwrite_size = reader->read_all(simMemory->as_ptr(), overwrite_nbytes);
Info("Overwrite %d bytes from file %s.\n", overwrite_size,gcpt_restore);
delete reader;
}

#ifdef WITH_DRAMSIM3
void dramsim3_init() {
#if !defined(DRAMSIM3_CONFIG) || !defined(DRAMSIM3_OUTDIR)
Expand Down
1 change: 1 addition & 0 deletions src/test/csrc/common/ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class LinearizedFootprintsMemory : public FootprintsMemory {
extern SimMemory *simMemory;
// This is to initialize the common mmap RAM
void init_ram(const char *image, uint64_t n_bytes);
void overwrite_ram(char *gcpt_restore, uint64_t overwrite_nbytes);

#ifdef WITH_DRAMSIM3

Expand Down
10 changes: 10 additions & 0 deletions src/test/csrc/vcs/vcs_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
static bool has_reset = false;
static char bin_file[256] = "/dev/zero";
static char *flash_bin_file = NULL;
static char *gcpt_bin_file = NULL;
static bool enable_difftest = true;
static uint64_t max_instrs = 0;
static char *workload_list = NULL;
static uint64_t overwrite_nbytes = 0xe00;

enum {
SIMV_RUN,
Expand All @@ -53,6 +55,11 @@ extern "C" void set_flash_bin(char *s) {
strcpy(flash_bin_file, s);
}

extern "C" void set_gcpt_bin_file(char *s) {
gcpt_bin_file = (char *)malloc(256);
strcpy(gcpt_bin_file, s);
}

extern "C" void set_max_instrs(uint64_t mc) {
printf("set max instrs: %lu\n", mc);
max_instrs = mc;
Expand Down Expand Up @@ -117,6 +124,9 @@ extern "C" uint8_t simv_init() {
init_goldenmem();
init_nemuproxy(DEFAULT_EMU_RAM_SIZE);
}
if (gcpt_bin_file != NULL) {
overwrite_ram(gcpt_bin_file, overwrite_nbytes);
}
return 0;
}

Expand Down
5 changes: 1 addition & 4 deletions src/test/csrc/verilator/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,7 @@ Emulator::Emulator(int argc, const char *argv[])
}

if (args.gcpt_restore) {
InputReader *reader = new FileReader(args.gcpt_restore);
int overwrite_size = reader->read_all(simMemory->as_ptr(), args.overwrite_nbytes);
Info("Overwrite %d bytes from file %s.\n", overwrite_size, args.gcpt_restore);
delete reader;
overwrite_ram(args.gcpt_restore, args.overwrite_nbytes);
}

#ifdef ENABLE_CHISEL_DB
Expand Down

0 comments on commit d496ffc

Please sign in to comment.