Aaron Durbin (adurbin@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10215
-gerrit
commit c2b56ea4d52926e81ab565c6615f706f7e9e94f3 Author: Aaron Durbin adurbin@chromium.org Date: Fri May 15 13:23:49 2015 -0500
regions: add more helpers
Fill out functions to get the offset and size for both regions and region_devices. Additionally add a helper for memory mapping an entire region_device.
Change-Id: I8896eaf5b29e4a67470f4adc6f5b541566cb93b5 Signed-off-by: Aaron Durbin adurbin@chromium.org --- src/include/region.h | 21 +++++++++++++++++++++ src/lib/region.c | 5 ----- 2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/include/region.h b/src/include/region.h index 99ea488..82db854 100644 --- a/src/include/region.h +++ b/src/include/region.h @@ -93,11 +93,32 @@ struct region_device { }, \ }
+static inline size_t region_offset(const struct region *r) +{ + return r->offset; +} + static inline size_t region_sz(const struct region *r) { return r->size; }
+static inline size_t region_device_sz(const struct region_device *rdev) +{ + return region_sz(&rdev->region); +} + +static inline size_t region_device_offset(const struct region_device *rdev) +{ + return region_offset(&rdev->region); +} + +/* Memory map entire region device. Same semantics as rdev_mmap() above. */ +static inline void *rdev_mmap_full(const struct region_device *rd) +{ + return rdev_mmap(rd, 0, region_device_sz(rd)); +} + struct mem_region_device { char *base; struct region_device rdev; diff --git a/src/lib/region.c b/src/lib/region.c index b56b3d7..d5d3762 100644 --- a/src/lib/region.c +++ b/src/lib/region.c @@ -20,11 +20,6 @@ #include <region.h> #include <string.h>
-static inline size_t region_offset(const struct region *r) -{ - return r->offset; -} - static inline size_t region_end(const struct region *r) { return region_sz(r) + region_offset(r);