summaryrefslogtreecommitdiff
path: root/src/commonlib/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-10-28 16:09:42 -0500
committerAaron Durbin <adurbin@chromium.org>2015-10-29 18:58:07 +0100
commit5907eb8f5a32b0514bb63a6ed847ead1712bc454 (patch)
treea9b5cb6fddcfc26d38a54a0f476e4b10d476a323 /src/commonlib/include
parente11f6c3be168b1efde7fa1b5fd8754b9b8057dc9 (diff)
commonlib/region: add xlate_region_device
There are cases where one region_device needs to be accessed using offset/sizes from one address space that need the offset translated into a different address space for operations to take place. The xlate_region_device provides an offset that is subtracted from the incoming transaction before deferring to the backing access region. Change-Id: I41d43924bb6fbc7b4d3681877543209e1085e15c Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/12227 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'src/commonlib/include')
-rw-r--r--src/commonlib/include/commonlib/region.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h
index d3e7ebdfff..fbc1790033 100644
--- a/src/commonlib/include/commonlib/region.h
+++ b/src/commonlib/include/commonlib/region.h
@@ -154,4 +154,27 @@ void mmap_helper_device_init(struct mmap_helper_region_device *mdev,
void *mmap_helper_rdev_mmap(const struct region_device *, size_t, size_t);
int mmap_helper_rdev_munmap(const struct region_device *, void *);
+/* A translated region device provides the ability to publish a region device
+ * in one address space and use an access mechansim within another address
+ * space. The sub region is the window within the 1st address space and
+ * the request is modified prior to accessing the second address space
+ * provided by access_dev. */
+struct xlate_region_device {
+ const struct region_device *access_dev;
+ struct region sub_region;
+ struct region_device rdev;
+};
+
+extern const struct region_device_ops xlate_rdev_ops;
+
+#define XLATE_REGION_INIT(access_dev_, sub_offset_, sub_size_, parent_sz_) \
+ { \
+ .access_dev = access_dev_, \
+ .sub_region = { \
+ .offset = (sub_offset_), \
+ .size = (sub_size_), \
+ }, \
+ .rdev = REGION_DEV_INIT(&xlate_rdev_ops, 0, (parent_sz_)),\
+ }
+
#endif /* _REGION_H_ */