[coreboot-gerrit] Change in coreboot[master]: commonlib/region: [WIP] Add region protect API
Rizwan Qureshi (Code Review)
gerrit at coreboot.org
Mon Sep 24 15:13:11 CEST 2018
Rizwan Qureshi has uploaded this change for review. ( https://review.coreboot.org/28724
Change subject: commonlib/region: [WIP] Add region protect API
......................................................................
commonlib/region: [WIP] Add region protect API
Add "protect" operation to the region_device_ops.
This can be used for write protecting the region that is
represented by the device.
Also add an API redev_protect() which will expose the protect
operation to the library user.
Change-Id: I4c9376e2c2c7a4852f13c65824c6cd64a1c6ac0a
Signed-off-by: Rizwan Qureshi <rizwan.qureshi at intel.com>
---
M src/commonlib/include/commonlib/region.h
M src/commonlib/region.c
2 files changed, 22 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/28724/1
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h
index 45484dd..901fd35 100644
--- a/src/commonlib/include/commonlib/region.h
+++ b/src/commonlib/include/commonlib/region.h
@@ -63,6 +63,11 @@
ssize_t rdev_eraseat(const struct region_device *rd, size_t offset,
size_t size);
+/*
+ * Returns < 0 on error otherwise returns 0 on success, < 0 0n error.
+ */
+int rdev_protect(const struct region_device *rd);
+
/****************************************
* Implementation of a region device *
****************************************/
@@ -75,6 +80,10 @@
int rdev_chain(struct region_device *child, const struct region_device *parent,
size_t offset, size_t size);
+struct region {
+ size_t offset;
+ size_t size;
+};
/* A region_device operations. */
struct region_device_ops {
@@ -84,12 +93,9 @@
ssize_t (*writeat)(const struct region_device *, const void *, size_t,
size_t);
ssize_t (*eraseat)(const struct region_device *, size_t, size_t);
+ int (*protect)(const struct region *);
};
-struct region {
- size_t offset;
- size_t size;
-};
struct region_device {
const struct region_device *root;
diff --git a/src/commonlib/region.c b/src/commonlib/region.c
index 541a125..58b5fa4 100644
--- a/src/commonlib/region.c
+++ b/src/commonlib/region.c
@@ -151,6 +151,18 @@
return rdev->ops->eraseat(rdev, req.offset, req.size);
}
+int rdev_protect(const struct region_device *rd)
+{
+ const struct region_device *rdev;
+
+ rdev = rdev_root(rd);
+
+ if (rdev->ops->protect == NULL)
+ return -1;
+
+ return rdev->ops->protect(region_device_region(rdev));
+}
+
int rdev_chain(struct region_device *child, const struct region_device *parent,
size_t offset, size_t size)
{
--
To view, visit https://review.coreboot.org/28724
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c9376e2c2c7a4852f13c65824c6cd64a1c6ac0a
Gerrit-Change-Number: 28724
Gerrit-PatchSet: 1
Gerrit-Owner: Rizwan Qureshi <rizwan.qureshi at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180924/49d5338e/attachment.html>
More information about the coreboot-gerrit
mailing list