Browse Source

Add --debug-no-abstract-csr (#267)

This is used to make sure that OpenOCD can work on targets that don't
support abstract access to CSR registers. It replaces a simpler hack,
which caused #266.
pull/297/head
Tim Newsome 7 years ago
committed by GitHub
parent
commit
69a8b5d2cf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      riscv/debug_module.cc
  2. 4
      riscv/debug_module.h
  3. 6
      riscv/sim.cc
  4. 2
      riscv/sim.h
  5. 6
      spike_main/spike.cc

11
riscv/debug_module.cc

@ -32,13 +32,15 @@ static unsigned field_width(unsigned n)
///////////////////////// debug_module_t
debug_module_t::debug_module_t(sim_t *sim, unsigned progbufsize, unsigned max_bus_master_bits,
bool require_authentication, unsigned abstract_rti, bool support_hasel) :
bool require_authentication, unsigned abstract_rti, bool support_hasel,
bool support_abstract_csr_access) :
nprocs(sim->nprocs()),
progbufsize(progbufsize),
program_buffer_bytes(4 + 4*progbufsize),
max_bus_master_bits(max_bus_master_bits),
require_authentication(require_authentication),
abstract_rti(abstract_rti),
support_abstract_csr_access(support_abstract_csr_access),
debug_progbuf_start(debug_data_start - program_buffer_bytes),
debug_abstract_start(debug_progbuf_start - debug_abstract_size*4),
custom_base(0),
@ -585,9 +587,7 @@ bool debug_module_t::perform_abstract_command()
unsigned i = 0;
if (get_field(command, AC_ACCESS_REGISTER_TRANSFER)) {
if (regno < 0x1000 && progbufsize < 2) {
// Make the debugger use the program buffer if it's available, so it
// can test both use cases.
if (regno < 0x1000 && support_abstract_csr_access) {
write32(debug_abstract, i++, csrw(S0, CSR_DSCRATCH));
if (write) {
@ -642,9 +642,6 @@ bool debug_module_t::perform_abstract_command()
}
} else if (regno >= 0x1020 && regno < 0x1040) {
// Don't force the debugger to use progbuf if it exists, so the
// debugger has to make the decision not to use abstract commands to
// access 64-bit FPRs on 32-bit targets.
unsigned fprnum = regno - 0x1020;
if (write) {

4
riscv/debug_module.h

@ -95,7 +95,8 @@ class debug_module_t : public abstract_device_t
*/
debug_module_t(sim_t *sim, unsigned progbufsize,
unsigned max_bus_master_bits, bool require_authentication,
unsigned abstract_rti, bool support_hasel);
unsigned abstract_rti, bool support_hasel,
bool support_abstract_csr_access);
~debug_module_t();
void add_device(bus_t *bus);
@ -127,6 +128,7 @@ class debug_module_t : public abstract_device_t
unsigned max_bus_master_bits;
bool require_authentication;
unsigned abstract_rti;
bool support_abstract_csr_access;
static const unsigned debug_data_start = 0x380;
unsigned debug_progbuf_start;

6
riscv/sim.cc

@ -29,12 +29,14 @@ sim_t::sim_t(const char* isa, size_t nprocs, bool halted, reg_t start_pc,
const std::vector<std::string>& args,
std::vector<int> const hartids, unsigned progsize,
unsigned max_bus_master_bits, bool require_authentication,
suseconds_t abstract_delay_usec, bool support_hasel)
suseconds_t abstract_delay_usec, bool support_hasel,
bool support_abstract_csr_access)
: htif_t(args), mems(mems), procs(std::max(nprocs, size_t(1))),
start_pc(start_pc), current_step(0), current_proc(0), debug(false),
histogram_enabled(false), dtb_enabled(true), remote_bitbang(NULL),
debug_module(this, progsize, max_bus_master_bits, require_authentication,
abstract_delay_usec, support_hasel)
abstract_delay_usec, support_hasel,
support_abstract_csr_access)
{
signal(SIGINT, &handle_signal);

2
riscv/sim.h

@ -26,7 +26,7 @@ public:
const std::vector<std::string>& args, const std::vector<int> hartids,
unsigned progsize, unsigned max_bus_master_bits,
bool require_authentication, suseconds_t abstract_delay_usec,
bool support_hasel);
bool support_hasel, bool support_abstract_csr_access);
~sim_t();
// run the simulation to completion

6
spike_main/spike.cc

@ -49,6 +49,7 @@ static void help(int exit_code = 1)
fprintf(stderr, " --abstract-rti=<n> Number of Run-Test/Idle cycles "
"required for an abstract command to execute [default 0]\n");
fprintf(stderr, " --without-hasel Debug module supports hasel\n");
fprintf(stderr, " --debug-no-abstract-csr Debug module won't support abstract to authenticate\n");
exit(exit_code);
}
@ -115,6 +116,7 @@ int main(int argc, char** argv)
unsigned dmi_rti = 0;
unsigned abstract_rti = 0;
bool support_hasel = true;
bool support_abstract_csr_access = true;
std::vector<int> hartids;
auto const hartids_parser = [&](const char *s) {
@ -168,6 +170,8 @@ int main(int argc, char** argv)
[&](const char* s){abstract_rti = atoi(s);});
parser.option(0, "without-hasel", 0,
[&](const char* s){support_hasel = false;});
parser.option(0, "debug-no-abstract-csr", 0,
[&](const char* s){support_abstract_csr_access = false;});
auto argv1 = parser.parse(argv);
std::vector<std::string> htif_args(argv1, (const char*const*)argv + argc);
@ -179,7 +183,7 @@ int main(int argc, char** argv)
sim_t s(isa, nprocs, halted, start_pc, mems, htif_args, std::move(hartids),
progsize, max_bus_master_bits, require_authentication,
abstract_rti, support_hasel);
abstract_rti, support_hasel, support_abstract_csr_access);
std::unique_ptr<remote_bitbang_t> remote_bitbang((remote_bitbang_t *) NULL);
std::unique_ptr<jtag_dtm_t> jtag_dtm(
new jtag_dtm_t(&s.debug_module, dmi_rti));

Loading…
Cancel
Save