Nikolai Artemiev has uploaded this change for review.
[RFC] writeprotect: implement wp_print_status()
Change-Id: I82441c60c239a5b947b5a2a87b61e7bdf60bee89
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
---
M writeprotect.c
1 file changed, 34 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/84/58484/1
diff --git a/writeprotect.c b/writeprotect.c
index e6e8df2..526e525 100644
--- a/writeprotect.c
+++ b/writeprotect.c
@@ -441,8 +441,40 @@
return 0;
}
+
+static void print_wp_mode(enum wp_mode mode)
+{
+ if (mode == WP_MODE_DISABLED) msg_ginfo("disabled");
+ if (mode == WP_MODE_HARDWARE) msg_ginfo("hardware");
+ if (mode == WP_MODE_POWER_CYCLE) msg_ginfo("powercycle");
+ if (mode == WP_MODE_PERMANENT) msg_ginfo("permanent");
+}
+
+
int wp_print_status(struct flashctx *flash)
{
- /* TODO */
- return 1;
+ struct wp_chip_state wpst;
+ struct wp_range range;
+ enum wp_mode mode;
+
+ if (read_wp_chip_state(flash, &wpst))
+ return 1;
+
+ if (decode_wp_mode(&wpst, &mode))
+ return 1;
+
+ range.chip_len = flash->chip->total_size * 1024;
+ flash->chip->decode_range(&wpst, &range);
+
+ msg_ginfo("\nWrite protect chip state: ");
+ print_wp_chip_state(&wpst);
+
+ msg_ginfo("\n\nProtection range: ");
+ print_range(&range);
+
+ msg_ginfo("\n\nProtection mode: ");
+ print_wp_mode(mode);
+ msg_ginfo("\n");
+
+ return 0;
}
To view, visit change 58484. To unsubscribe, or for help writing mail filters, visit settings.