diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2018-06-08 20:19:21 +0300 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-06-12 07:43:37 +0000 |
commit | d022718001a7651d9d357a1a3359d07c13a0ad9d (patch) | |
tree | cc5447213109929e02f29f08f177b5957c7e5bd6 /src/lib | |
parent | 43fc1aee4d8c4b9198a9b41cc5bc2a8a2663ef29 (diff) |
bootmem: Clarify usage with bounce-buffer
Add bootmem_targets_usable_with_bounce() to handle
cases of payload loading via bounce-buffer.
Change-Id: I9ebbc621f8810c0317d7c97c6b4cdd41527ddcbb
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/26985
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/bootmem.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c index 90f4970d52..66d459207d 100644 --- a/src/lib/bootmem.c +++ b/src/lib/bootmem.c @@ -201,12 +201,12 @@ bool bootmem_walk(range_action_t action, void *arg) return false; } -int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size) +static int bootmem_region_targets_ram(uint64_t start, uint64_t end, + struct memranges *bm) { const struct range_entry *r; - uint64_t end = start + size; - memranges_each_entry(r, &bootmem) { + memranges_each_entry(r, bm) { /* All further bootmem entries are beyond this range. */ if (end <= range_entry_base(r)) break; @@ -219,6 +219,24 @@ int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size) return 0; } +/* Common testcase for loading any segments to bootmem. + * Returns 1 if the requested memory range is all tagged as type BM_MEM_RAM. + * Otherwise returns 0. + */ +int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size) +{ + return bootmem_region_targets_ram(start, start + size, &bootmem); +} + +/* Special testcase to use when loading payload segments when bounce-buffer is + * supported. Memory ranges tagged with >BM_MEM_OS_CUTOFF may be overwritten at + * the time we jump to payload. + */ +int bootmem_region_usable_with_bounce(uint64_t start, uint64_t size) +{ + return bootmem_region_targets_ram(start, start + size, &bootmem_os); +} + void *bootmem_allocate_buffer(size_t size) { const struct range_entry *r; |