[coreboot-gerrit] New patch to review for coreboot: commonlib/region: Add helpers for dynamic initialization of region dev
Furquan Shaikh (furquan@google.com)
gerrit at coreboot.org
Mon Jun 20 19:34:45 CEST 2016
Furquan Shaikh (furquan at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15267
-gerrit
commit cf378d4ad1a51f695b2a2472853aa1fb7ce7662e
Author: Furquan Shaikh <furquan at google.com>
Date: Sun Jun 19 23:16:45 2016 -0700
commonlib/region: Add helpers for dynamic initialization of region dev
This allows initialization of runtime region devices and xlate region
devices where all parameters cannot be statically determined.
BUG=chrome-os-partner:54563
Change-Id: Ia6e1b695fed3bbfa08598d1593e650fc1465d41f
Signed-off-by: Furquan Shaikh <furquan at google.com>
---
src/commonlib/include/commonlib/region.h | 13 ++++++++++++-
src/commonlib/region.c | 23 +++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h
index a13c66c..da821fc 100644
--- a/src/commonlib/include/commonlib/region.h
+++ b/src/commonlib/include/commonlib/region.h
@@ -90,6 +90,11 @@ struct region_device {
}, \
}
+/* Helper to dynamically initialize region device. */
+void region_device_init(struct region_device *rdev,
+ const struct region_device_ops *ops, size_t offset,
+ size_t size);
+
static inline size_t region_offset(const struct region *r)
{
return r->offset;
@@ -177,7 +182,7 @@ struct xlate_region_device {
extern const struct region_device_ops xlate_rdev_ops;
-#define XLATE_REGION_INIT(access_dev_, sub_offset_, sub_size_, parent_sz_) \
+#define XLATE_REGION_DEV_INIT(access_dev_, sub_offset_, sub_size_, parent_sz_) \
{ \
.access_dev = access_dev_, \
.sub_region = { \
@@ -187,4 +192,10 @@ extern const struct region_device_ops xlate_rdev_ops;
.rdev = REGION_DEV_INIT(&xlate_rdev_ops, 0, (parent_sz_)),\
}
+/* Helper to dynamically initialize xlate region device. */
+void xlate_region_device_init(struct xlate_region_device *xdev,
+ struct region_device *access_dev,
+ size_t sub_offset, size_t sub_size,
+ size_t parent_size);
+
#endif /* _REGION_H_ */
diff --git a/src/commonlib/region.c b/src/commonlib/region.c
index bfc5fc8..4f654cf 100644
--- a/src/commonlib/region.c
+++ b/src/commonlib/region.c
@@ -133,6 +133,29 @@ void mem_region_device_init(struct mem_region_device *mdev, void *base,
mdev->rdev.region.size = size;
}
+void region_device_init(struct region_device *rdev,
+ const struct region_device_ops *ops, size_t offset,
+ size_t size)
+{
+ memset(rdev, 0, sizeof(*rdev));
+ rdev->root = NULL;
+ rdev->ops = ops;
+ rdev->region.offset = offset;
+ rdev->region.size = size;
+}
+
+void xlate_region_device_init(struct xlate_region_device *xdev,
+ struct region_device *access_dev,
+ size_t sub_offset, size_t sub_size,
+ size_t parent_size)
+{
+ memset(xdev, 0, sizeof(*xdev));
+ xdev->access_dev = access_dev;
+ xdev->sub_region.offset = sub_offset;
+ xdev->sub_region.size = sub_size;
+ region_device_init(&xdev->rdev, &xlate_rdev_ops, 0, parent_size);
+}
+
static void *mdev_mmap(const struct region_device *rd, size_t offset,
size_t size __unused)
{
More information about the coreboot-gerrit
mailing list