Browse Source
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.pull/946/head
5 changed files with 61 additions and 18 deletions
@ -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 |
|||
Loading…
Reference in new issue