summaryrefslogtreecommitdiffstats
path: root/writeprotect.h
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2020-09-21 17:10:21 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2020-09-28 06:32:22 +0000
commitd3b6acffe40351d84cfd6aaa0238f9a653d69aa1 (patch)
tree651cac93d8fb2446d0cac5a2d4b60f9f8f23e7da /writeprotect.h
parentb1f858f65b2abd276542650d8cb9e382da258967 (diff)
downloadflashrom-d3b6acffe40351d84cfd6aaa0238f9a653d69aa1.tar.gz
flashrom-d3b6acffe40351d84cfd6aaa0238f9a653d69aa1.tar.bz2
flashrom-d3b6acffe40351d84cfd6aaa0238f9a653d69aa1.zip
Add writeprotect support infrastructure
The following just lays out the structure for write protect manipulation of SPI flash chips in Flashrom. We later follow up with adding support for each manufacturer group. BUG=b:153800563 BRANCH=none TEST=builds Change-Id: Id93b5a1cb2da476fa8a7dde41d7b963024117474 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/40325 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'writeprotect.h')
-rw-r--r--writeprotect.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/writeprotect.h b/writeprotect.h
new file mode 100644
index 000000000..bded4c854
--- /dev/null
+++ b/writeprotect.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2010 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __WRITEPROTECT_H__
+#define __WRITEPROTECT_H__ 1
+
+enum wp_mode {
+ WP_MODE_UNKNOWN = -1,
+ WP_MODE_HARDWARE, /* hardware WP pin determines status */
+ WP_MODE_POWER_CYCLE, /* WP active until power off/on cycle */
+ WP_MODE_PERMANENT, /* status register permanently locked,
+ WP permanently enabled */
+};
+
+struct wp {
+ int (*list_ranges)(const struct flashctx *flash);
+ int (*set_range)(const struct flashctx *flash,
+ unsigned int start, unsigned int len);
+ int (*enable)(const struct flashctx *flash, enum wp_mode mode);
+ int (*disable)(const struct flashctx *flash);
+ int (*wp_status)(const struct flashctx *flash);
+};
+
+extern struct wp wp_generic;
+
+enum wp_mode get_wp_mode(const char *mode_str);
+
+/*
+ * Generic write-protect stuff
+ */
+
+struct modifier_bits {
+ int sec; /* if 1, bp bits describe sectors */
+ int tb; /* value of top/bottom select bit */
+};
+
+#endif /* !__WRITEPROTECT_H__ */