aboutsummaryrefslogtreecommitdiff
path: root/riscv/cfg.h
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2022-02-19 00:02:11 +0000
committerRupert Swarbrick <rswarbrick@gmail.com>2022-03-18 15:30:41 +0000
commitb742ddc66fd4ccb6cec98cbd8ebb705fe93ca735 (patch)
treea5c2f32b7c7996732f72b8142971610eb68f2a67 /riscv/cfg.h
parent1fea2afbf46d2641d77f2db3d6108e0897431a84 (diff)
downloadspike-b742ddc66fd4ccb6cec98cbd8ebb705fe93ca735.zip
spike-b742ddc66fd4ccb6cec98cbd8ebb705fe93ca735.tar.gz
spike-b742ddc66fd4ccb6cec98cbd8ebb705fe93ca735.tar.bz2
Initial step towards factoring out command line configuration
This commit defines a "cfg_t" structure, which currently just holds the initrd address range. It will be augmented in future commits to hold other configuration arguments as well. To represent a configuration argument, we define an arg_t base class. This holds a current value, together with a flag that tells us whether the value has been updated from the default. The idea is that in future we're going to use that flag when reading a DTB file: if an argument has actually been specified on the command line, we need to take it into account; if not, we can ignore the default and use the DTB file's supplied value.
Diffstat (limited to 'riscv/cfg.h')
-rw-r--r--riscv/cfg.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/riscv/cfg.h b/riscv/cfg.h
new file mode 100644
index 0000000..bee5051
--- /dev/null
+++ b/riscv/cfg.h
@@ -0,0 +1,38 @@
+// See LICENSE for license details.
+#ifndef _RISCV_CFG_H
+#define _RISCV_CFG_H
+
+#include "decode.h"
+
+template <typename T>
+class cfg_arg_t {
+public:
+ cfg_arg_t(T default_val)
+ : value(default_val), was_set(false) {}
+
+ bool overridden() const { return was_set; }
+
+ T operator()() const { return value; }
+
+ T operator=(const T v) {
+ value = v;
+ was_set = true;
+ return value;
+ }
+
+private:
+ T value;
+ bool was_set;
+};
+
+class cfg_t
+{
+public:
+ cfg_t(std::pair<reg_t, reg_t> default_initrd_bounds)
+ : initrd_bounds(default_initrd_bounds)
+ {}
+
+ cfg_arg_t<std::pair<reg_t, reg_t>> initrd_bounds;
+};
+
+#endif