diff options
author | Julius Werner <jwerner@chromium.org> | 2021-04-16 16:48:32 -0700 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2021-04-21 02:06:26 +0000 |
commit | c893197352acc9b53c1beef5082cbc0271f63688 (patch) | |
tree | b975712387bd54bd0101a736adbb2a6fe5b824bb /src/lib/fmap.c | |
parent | b03e497ef16e9e38ba9220d31131a6bfdef35390 (diff) | |
download | coreboot-c893197352acc9b53c1beef5082cbc0271f63688.tar.gz coreboot-c893197352acc9b53c1beef5082cbc0271f63688.tar.bz2 coreboot-c893197352acc9b53c1beef5082cbc0271f63688.zip |
commonlib/region: Turn addrspace_32bit into a more official API
We had the addrspace_32bit rdev in prog_loaders.c for a while to help
represent memory ranges as an rdev, and we've found it useful for a
couple of things that have nothing to do with program loading. This
patch moves the concept straight into commonlib/region.c so it is no
longer anchored in such a weird place, and easier to use in unit tests.
Also expand the concept to the whole address space (there's no real need
to restrict it to 32 bits in 64-bit environments) and introduce an
rdev_chain_mem() helper function to make it a bit easier to use. Replace
some direct uses of struct mem_region_device with this new API where it
seems to make sense.
Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Ie4c763b77f77d227768556a9528681d771a08dca
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52533
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib/fmap.c')
-rw-r--r-- | src/lib/fmap.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/fmap.c b/src/lib/fmap.c index 418e715b3ecc..254d7877f6bf 100644 --- a/src/lib/fmap.c +++ b/src/lib/fmap.c @@ -16,7 +16,7 @@ */ static int fmap_print_once; -static struct mem_region_device fmap_cache; +static struct region_device fmap_cache; #define print_once(...) do { \ if (!fmap_print_once) \ @@ -53,7 +53,7 @@ static void report(const struct fmap *fmap) fmap_print_once = 1; } -static void setup_preram_cache(struct mem_region_device *cache_mrdev) +static void setup_preram_cache(struct region_device *cache_rdev) { if (CONFIG(NO_FMAP_CACHE)) return; @@ -99,7 +99,7 @@ static void setup_preram_cache(struct mem_region_device *cache_mrdev) report(fmap); register_cache: - mem_region_device_ro_init(cache_mrdev, fmap, FMAP_SIZE); + rdev_chain_mem(cache_rdev, fmap, FMAP_SIZE); } static int find_fmap_directory(struct region_device *fmrd) @@ -109,10 +109,10 @@ static int find_fmap_directory(struct region_device *fmrd) size_t offset = FMAP_OFFSET; /* Try FMAP cache first */ - if (!region_device_sz(&fmap_cache.rdev)) + if (!region_device_sz(&fmap_cache)) setup_preram_cache(&fmap_cache); - if (region_device_sz(&fmap_cache.rdev)) - return rdev_chain_full(fmrd, &fmap_cache.rdev); + if (region_device_sz(&fmap_cache)) + return rdev_chain_full(fmrd, &fmap_cache); boot_device_init(); boot = boot_device_ro(); @@ -281,7 +281,7 @@ static void fmap_register_cbmem_cache(int unused) if (!e) return; - mem_region_device_ro_init(&fmap_cache, cbmem_entry_start(e), cbmem_entry_size(e)); + rdev_chain_mem(&fmap_cache, cbmem_entry_start(e), cbmem_entry_size(e)); } /* |