From 60c0c86c288d14c81177e6f56aa5c6b77e40fbec Mon Sep 17 00:00:00 2001 From: Parshintsev Anatoly Date: Mon, 10 Oct 2022 15:01:32 +0300 Subject: Report error if an unsupported memory configuration is detected --- riscv/cfg.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'riscv/cfg.h') diff --git a/riscv/cfg.h b/riscv/cfg.h index 6369bd8..13dcf3a 100644 --- a/riscv/cfg.h +++ b/riscv/cfg.h @@ -32,18 +32,22 @@ private: class mem_cfg_t { public: - mem_cfg_t(reg_t base, reg_t size) - : base(base), size(size) - { - // The truth of these assertions should be ensured by whatever is creating + static bool check_if_supported(reg_t base, reg_t size) { + // The truth of these conditions should be ensured by whatever is creating // the regions in the first place, but we have them here to make sure that // we can't end up describing memory regions that don't make sense. They // ask that the page size is a multiple of the minimum page size, that the // page is aligned to the minimum page size, that the page is non-empty and // that the top address is still representable in a reg_t. - assert((size % PGSIZE == 0) && + return (size % PGSIZE == 0) && (base % PGSIZE == 0) && - (base + size > base)); + (base + size > base); + } + + mem_cfg_t(reg_t base, reg_t size) + : base(base), size(size) + { + assert(mem_cfg_t::check_if_supported(base, size)); } reg_t base; -- cgit v1.1 From 7e8d1e6f29a0e6b9f8b1b65a88b5dc87c25a4f9a Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Fri, 14 Oct 2022 11:31:21 -0700 Subject: Support command-line configuration of number of pmpregions --- riscv/cfg.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'riscv/cfg.h') diff --git a/riscv/cfg.h b/riscv/cfg.h index 13dcf3a..dbdb58b 100644 --- a/riscv/cfg.h +++ b/riscv/cfg.h @@ -61,6 +61,7 @@ public: const char *default_bootargs, const char *default_isa, const char *default_priv, const char *default_varch, + const reg_t default_pmpregions, const std::vector &default_mem_layout, const std::vector default_hartids, bool default_real_time_clint) @@ -69,6 +70,7 @@ public: isa(default_isa), priv(default_priv), varch(default_varch), + pmpregions(default_pmpregions), mem_layout(default_mem_layout), hartids(default_hartids), explicit_hartids(false), @@ -80,6 +82,7 @@ public: cfg_arg_t isa; cfg_arg_t priv; cfg_arg_t varch; + reg_t pmpregions; cfg_arg_t> mem_layout; std::optional start_pc; cfg_arg_t> hartids; -- cgit v1.1