diff options
Diffstat (limited to 'common/memory.c')
-rw-r--r-- | common/memory.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/memory.c b/common/memory.c index 7e24ecb2bd..583843cc34 100644 --- a/common/memory.c +++ b/common/memory.c @@ -15,6 +15,7 @@ #include <asm/sections.h> #include <malloc.h> #include <of.h> +#include <mmu.h> /* * Begin and End of memory area for malloc(), and current "brk" @@ -149,6 +150,7 @@ int barebox_add_memory_bank(const char *name, resource_size_t start, struct resource newres = { .start = start, .end = start + size - 1, + .flags = IORESOURCE_MEM, }; for_each_memory_bank(bank) { @@ -210,6 +212,31 @@ struct resource *__request_sdram_region(const char *name, unsigned flags, return NULL; } +/* use for secure firmware to inhibit speculation */ +struct resource *reserve_sdram_region(const char *name, resource_size_t start, + resource_size_t size) +{ + struct resource *res; + + if (!IS_ALIGNED(start, PAGE_SIZE)) { + pr_err("%s: %s start is not page aligned\n", __func__, name); + start = ALIGN_DOWN(start, PAGE_SIZE); + } + + if (!IS_ALIGNED(size, PAGE_SIZE)) { + pr_err("%s: %s size is not page aligned\n", __func__, name); + size = ALIGN(size, PAGE_SIZE); + } + + res = __request_sdram_region(name, IORESOURCE_BUSY, start, size); + if (!res) + return NULL; + + remap_range((void *)start, size, MAP_UNCACHED); + + return res; +} + int release_sdram_region(struct resource *res) { return release_region(res); |