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>
This commit is contained in:
@ -48,6 +48,18 @@ static const struct region_device *rdev_root(const struct region_device *rdev)
|
||||
return rdev->root;
|
||||
}
|
||||
|
||||
ssize_t rdev_relative_offset(const struct region_device *p,
|
||||
const struct region_device *c)
|
||||
{
|
||||
if (rdev_root(p) != rdev_root(c))
|
||||
return -1;
|
||||
|
||||
if (!is_subregion(&p->region, &c->region))
|
||||
return -1;
|
||||
|
||||
return region_device_offset(c) - region_device_offset(p);
|
||||
}
|
||||
|
||||
void *rdev_mmap(const struct region_device *rd, size_t offset, size_t size)
|
||||
{
|
||||
const struct region_device *rdev;
|
||||
|
Reference in New Issue
Block a user