Nikolai Artemiev has uploaded this change for review.

View Change

[RFC] writeprotect: implement wp_print_status()

BUG=b:195381327,b:153800563
TEST=flashrom --wp-status
BRANCH=none

Change-Id: I499f521781ee8999921996517802c0c0c641d869
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
---
M cli_classic.c
M writeprotect.c
M writeprotect.h
3 files changed, 41 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/38/58738/1
diff --git a/cli_classic.c b/cli_classic.c
index a9eb43b..f078fb3 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -805,6 +805,9 @@
ret |= wp_print_ranges(fill_flash);
}

+ if (wp_status) {
+ ret |= wp_print_status(fill_flash);
+ }

flashrom_flag_set(fill_flash, FLASHROM_FLAG_FORCE, !!force);
#if CONFIG_INTERNAL == 1
diff --git a/writeprotect.c b/writeprotect.c
index 3a52d99..011f5d0 100644
--- a/writeprotect.c
+++ b/writeprotect.c
@@ -441,3 +441,39 @@

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)
+{
+ 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;
+}
diff --git a/writeprotect.h b/writeprotect.h
index 5d23d2e..0cfb2da 100644
--- a/writeprotect.h
+++ b/writeprotect.h
@@ -64,4 +64,6 @@

int wp_print_ranges(struct flashctx *flash);

+int wp_print_status(struct flashctx *flash);
+
#endif

To view, visit change 58738. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I499f521781ee8999921996517802c0c0c641d869
Gerrit-Change-Number: 58738
Gerrit-PatchSet: 1
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-MessageType: newchange