Skip to content

Commit

Permalink
Add more ISAs to MARS (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkryukov authored Mar 18, 2020
1 parent b09a401 commit 081acc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion simulator/kernel/mars/mars_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <fstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

class MARSKernel : public BaseKernel {
Expand Down Expand Up @@ -247,12 +248,19 @@ void MARSKernel::connect_mars_handler()
elf_loader.load_to( mem.get(), 0x8'0000'0180 - elf_loader.get_text_section_addr());
}

static bool is_mips_le( std::string_view isa)
{
static std::unordered_set<std::string_view> isas =
{ "mars", "mars64", "mips32le", "mips32", "mips64", "mips64le" };
return isas.count( isa) > 0;
}

void MARSKernel::connect_exception_handler()
{
auto isa = sim->get_isa();
if ( isa == "riscv32" || isa == "riscv64")
connect_riscv_handler();
else if ( isa == "mars" || isa == "mars64" || isa == "mips32le" || isa == "mips32")
else if ( is_mips_le( isa))
connect_mars_handler();
else
throw UnsupportedISA( isa);
Expand Down
2 changes: 1 addition & 1 deletion simulator/kernel/mars/t/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ TEST_CASE( "MARS: unsupported syscall")

TEST_CASE( "MARS: unsupported isa")
{
auto sim = Simulator::create_simulator( "mips64", true);
auto sim = Simulator::create_simulator( "mips64be", true);
auto mars_kernel = create_mars_kernel( std::cin, std::cout, std::cerr);
mars_kernel->set_simulator( sim);
CHECK_THROWS_AS( mars_kernel->connect_exception_handler(), UnsupportedISA);
Expand Down

0 comments on commit 081acc6

Please sign in to comment.