|
|
|
@ -84,12 +84,17 @@ htif_t::~htif_t() |
|
|
|
|
|
|
|
void htif_t::start() |
|
|
|
{ |
|
|
|
if (!targs.empty() && targs[0] != "none") { |
|
|
|
try { |
|
|
|
load_program(); |
|
|
|
} catch (const incompat_xlen & err) { |
|
|
|
fprintf(stderr, "Error: cannot execute %d-bit program on RV%d hart\n", err.actual_xlen, err.expected_xlen); |
|
|
|
exit(1); |
|
|
|
if (!targs.empty()) { |
|
|
|
if (targs[0] != "none") { |
|
|
|
try { |
|
|
|
load_program(); |
|
|
|
} catch (const incompat_xlen & err) { |
|
|
|
fprintf(stderr, "Error: cannot execute %d-bit program on RV%d hart\n", err.actual_xlen, err.expected_xlen); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} else { |
|
|
|
auto empty_symbols = std::map<std::string, uint64_t>(); |
|
|
|
load_symbols(empty_symbols); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -150,21 +155,8 @@ std::map<std::string, uint64_t> htif_t::load_payload(const std::string& payload, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void htif_t::load_program() |
|
|
|
void htif_t::load_symbols(std::map<std::string, uint64_t>& symbols) |
|
|
|
{ |
|
|
|
std::map<std::string, uint64_t> symbols = load_payload(targs[0], &entry, load_offset); |
|
|
|
|
|
|
|
// detect torture tests so we can print the memory signature at the end
|
|
|
|
if (symbols.count("begin_signature") && symbols.count("end_signature")) { |
|
|
|
sig_addr = symbols["begin_signature"]; |
|
|
|
sig_len = symbols["end_signature"] - sig_addr; |
|
|
|
} |
|
|
|
|
|
|
|
for (auto payload : payloads) { |
|
|
|
reg_t dummy_entry; |
|
|
|
load_payload(payload, &dummy_entry, 0); |
|
|
|
} |
|
|
|
|
|
|
|
class nop_memif_t : public memif_t { |
|
|
|
public: |
|
|
|
nop_memif_t(htif_t* htif) : memif_t(htif), htif(htif) {} |
|
|
|
@ -181,6 +173,12 @@ void htif_t::load_program() |
|
|
|
symbols.merge(other_symbols); |
|
|
|
} |
|
|
|
|
|
|
|
// detect torture tests so we can print the memory signature at the end
|
|
|
|
if (symbols.count("begin_signature") && symbols.count("end_signature")) { |
|
|
|
sig_addr = symbols["begin_signature"]; |
|
|
|
sig_len = symbols["end_signature"] - sig_addr; |
|
|
|
} |
|
|
|
|
|
|
|
if (symbols.count("tohost") && symbols.count("fromhost")) { |
|
|
|
tohost_addr = symbols["tohost"]; |
|
|
|
fromhost_addr = symbols["fromhost"]; |
|
|
|
@ -193,6 +191,18 @@ void htif_t::load_program() |
|
|
|
if ( it == addr2symbol.end()) |
|
|
|
addr2symbol[i.second] = i.first; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void htif_t::load_program() |
|
|
|
{ |
|
|
|
std::map<std::string, uint64_t> symbols = load_payload(targs[0], &entry, load_offset); |
|
|
|
|
|
|
|
load_symbols(symbols); |
|
|
|
|
|
|
|
for (auto payload : payloads) { |
|
|
|
reg_t dummy_entry; |
|
|
|
load_payload(payload, &dummy_entry, 0); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|