diff options
author | Palmer Dabbelt <palmer@dabbelt.com> | 2018-10-10 17:17:50 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmer@dabbelt.com> | 2018-10-10 17:17:50 -0700 |
commit | cd3065133f9b4f4ddda6dffa4d8b0a15a925f4fb (patch) | |
tree | 969604f12a9d4000b0b86d646b51140e0f59a5f4 /machine | |
parent | 7bee30c1ff56975041ffc67cd0170d7477aba865 (diff) | |
download | riscv-pk-maxmem.zip riscv-pk-maxmem.tar.gz riscv-pk-maxmem.tar.bz2 |
Add "--with-max-memory-bytes", to limit the used memorymaxmem
I have no idea if this works, but it does at least compile.
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Diffstat (limited to 'machine')
-rw-r--r-- | machine/fdt.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/machine/fdt.c b/machine/fdt.c index e8a504f..ba94b8d 100644 --- a/machine/fdt.c +++ b/machine/fdt.c @@ -126,6 +126,15 @@ const uint32_t *fdt_get_size(const struct fdt_scan_node *node, const uint32_t *v return value; } +const uint32_t *fdt_set_size(const struct fdt_scan_node *node, uint32_t *value, uint64_t new_value) +{ + for (int cells = node->size_cells; cells > 0; --cells) { + *value++ = new_value; + new_value >>= 32; + } + return value; +} + int fdt_string_list_index(const struct fdt_scan_prop *prop, const char *str) { const char *list = (const char *)prop->value; @@ -176,9 +185,14 @@ static void mem_done(const struct fdt_scan_node *node, void *extra) while (end - value > 0) { uint64_t base, size; - value = fdt_get_address(node->parent, value, &base); + const uint32_t *size_ptr; + size_ptr = value = fdt_get_address(node->parent, value, &base); value = fdt_get_size (node->parent, value, &size); if (base <= self && self <= base + size) { mem_size = size; } +#ifdef MAX_MEMORY_BYTES + if (size > (uintptr_t)(MAX_MEMORY_BYTES)) + fdt_set_size(node->parent, (uint32_t *)size_ptr, (uintptr_t)(MAX_MEMORY_BYTES)); +#endif } assert (end == value); } |