Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sim_t: Add sim_t::add_device() #1389

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions riscv/sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
abstract_device_t* device = factory->parse_from_fdt(fdt, this, &device_base);
if (device) {
assert(device_base);
bus.add_device(device_base, device);
std::shared_ptr<abstract_device_t> dev_ptr(device);
devices.push_back(dev_ptr);
add_device(device_base, dev_ptr);

if (i == 0) // clint_factory
clint = std::static_pointer_cast<clint_t>(dev_ptr);
Expand Down Expand Up @@ -277,6 +276,11 @@ void sim_t::step(size_t n)
}
}

void sim_t::add_device(reg_t addr, std::shared_ptr<abstract_device_t> dev) {
bus.add_device(addr, dev.get());
devices.push_back(dev);
}

void sim_t::set_debug(bool value)
{
debug = value;
Expand Down Expand Up @@ -369,8 +373,7 @@ void sim_t::set_rom()
rom.resize((rom.size() + align - 1) / align * align);

std::shared_ptr<rom_device_t> boot_rom(new rom_device_t(rom));
bus.add_device(DEFAULT_RSTVEC, boot_rom.get());
devices.push_back(boot_rom);
add_device(DEFAULT_RSTVEC, boot_rom);
}

char* sim_t::addr_to_mem(reg_t paddr) {
Expand Down
1 change: 1 addition & 0 deletions riscv/sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class sim_t : public htif_t, public simif_t
int run();
void set_debug(bool value);
void set_histogram(bool value);
void add_device(reg_t addr, std::shared_ptr<abstract_device_t> dev);

// Configure logging
//
Expand Down