summaryrefslogtreecommitdiff
path: root/src/commonlib/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-12-15 13:29:41 -0600
committerAaron Durbin <adurbin@chromium.org>2016-01-06 01:11:15 +0100
commit990ab7efe5d0eddb96542042bf5106811365e34a (patch)
tree9b251fbeb52a6f70f703a988ff553c80ff55b6dd /src/commonlib/include
parentaf91b8b086b6fd087a99a4e88ad76e46defacf9b (diff)
downloadcoreboot-990ab7efe5d0eddb96542042bf5106811365e34a.tar.xz
commonlib: Add function to compute relative offsets from two region_devices.
Provide a helper function which returns the relative offset between 2 region_devices that have a parent-child child relationship. BUG=chrome-os-partner:48412 BUG=chromium:445938 BRANCH=None TEST=Utilized and booted on glados. Change-Id: Ie0041b33e73a6601748f1289e98b6f1f8756eb11 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/12782 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src/commonlib/include')
-rw-r--r--src/commonlib/include/commonlib/region.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h
index cc4ee289d2..35d48ade85 100644
--- a/src/commonlib/include/commonlib/region.h
+++ b/src/commonlib/include/commonlib/region.h
@@ -121,6 +121,13 @@ static inline void *rdev_mmap_full(const struct region_device *rd)
return rdev_mmap(rd, 0, region_device_sz(rd));
}
+/*
+ * Compute relative offset of the child (c) w.r.t. the parent (p). Returns < 0
+ * when child is not within the parent's region.
+ */
+ssize_t rdev_relative_offset(const struct region_device *p,
+ const struct region_device *c);
+
struct mem_region_device {
char *base;
struct region_device rdev;