Skip to content

Commit 037c835

Browse files
rmn30nwf-msr
authored andcommitted
riscv_sim: Add command line arguments to enable or disable use of boot ROM.
This adds command line arguments --boot-rom and --no-boot-rom to enable or disable the use of the boot ROM at the reset vector. The current behaviour (--boot-rom) initialises a small bit of memory at the reset vector to set up argument registers and then jump to the address specified by entry point of the ELF file. With --no-boot-rom the simulator just sets the initial PC to the entry point. For backwards compatibility the default is to use the boot-rom unless NO_BOOT_ROM is defined during compilation.
1 parent 036655d commit 037c835

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

c_emulator/riscv_sim.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ bool config_print_reg = true;
8585
bool config_print_mem_access = true;
8686
bool config_print_platform = true;
8787
bool config_print_rvfi = false;
88+
int config_use_boot_rom =
89+
#ifdef NO_BOOT_ROM
90+
false
91+
#else
92+
true
93+
#endif
94+
;
8895

8996
void set_config_print(char *var, bool val)
9097
{
@@ -145,6 +152,8 @@ static struct option options[] = {
145152
{"inst-limit", required_argument, 0, 'l' },
146153
{"enable-zfinx", no_argument, 0, 'x' },
147154
{"enable-writable-fiom", no_argument, 0, OPT_ENABLE_WRITABLE_FIOM},
155+
{"boot-rom", no_argument, &config_use_boot_rom, true},
156+
{"no-boot-rom", no_argument, &config_use_boot_rom, false},
148157
#ifdef SAILCOV
149158
{"sailcov-file", required_argument, 0, 'c' },
150159
#endif
@@ -159,10 +168,10 @@ static void print_usage(const char *argv0, int ec)
159168
#endif
160169
struct option *opt = options;
161170
while (opt->name) {
162-
if (isprint(opt->val))
171+
if (opt->flag == NULL)
163172
fprintf(stdout, "\t -%c\t --%s\n", (char)opt->val, opt->name);
164173
else
165-
fprintf(stdout, "\t \t --%s\n", opt->name);
174+
fprintf(stdout, "\t\t --%s\n", opt->name);
166175
opt++;
167176
}
168177
exit(ec);
@@ -620,7 +629,11 @@ void init_sail(uint64_t elf_entry)
620629
zPC = elf_entry;
621630
} else
622631
#endif
632+
if (config_use_boot_rom) {
623633
init_sail_reset_vector(elf_entry);
634+
} else {
635+
zPC = elf_entry;
636+
}
624637

625638
// this is probably unnecessary now; remove
626639
if (!rv_enable_rvc)

0 commit comments

Comments
 (0)