summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2011-02-17 11:06:47 -0800
committerRandall Spangler <rspangler@chromium.org>2011-02-17 11:06:47 -0800
commitc80fe65f9e42aba26077fc93ce43ae6c02b9eb67 (patch)
tree46dfd4451380a9f8d6f829a1ca045becb0f3156d
parentf82f941b803b0c28240913eb57b34ab4c6c6b96a (diff)
downloadvboot-c80fe65f9e42aba26077fc93ce43ae6c02b9eb67.tar.gz
Fix WP polarity on Mario
Note that both the current and boot settings are incorrect as reported by the BIOS. This fixes both. Change-Id: Iebd2b4ac91232444e538f6e2763a22cb227f2e4f BUG=chrome-os-partner:2078 TEST=manual Run crossystem on Mario and Alex with WP enabled, disabled and check Verify true hardware WP status by doing: flashrom --wp-enable flashrom --wp-status flashrom --wp-disable flashrom --wp-status On a system with hardware WP enabled, the disable step should fail and write protect will still report enabled. Review URL: http://codereview.chromium.org/6531035
-rw-r--r--host/lib/crossystem.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index c3bee752..277749b9 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -83,6 +83,16 @@ int ReadFileBit(const char* filename, int bitmask) {
}
+/* Return true if the FWID starts with the specified string. */
+static int FwidStartsWith(const char *start) {
+ char fwid[128];
+ if (!VbGetSystemPropertyString("fwid", fwid, sizeof(fwid)))
+ return 0;
+
+ return 0 == strncmp(fwid, start, strlen(start));
+}
+
+
/* Read a GPIO of the specified signal type (see ACPI GPIO SignalType).
*
* Returns 1 if the signal is asserted, 0 if not asserted, or -1 if error. */
@@ -155,25 +165,31 @@ int ReadGpio(int signal_type) {
*
* Returns the property value, or -1 if error. */
int VbGetSystemPropertyInt(const char* name) {
+ int value = -1;
if (!strcasecmp(name,"devsw_cur")) {
- return ReadGpio(GPIO_SIGNAL_TYPE_DEV);
+ value = ReadGpio(GPIO_SIGNAL_TYPE_DEV);
} else if (!strcasecmp(name,"devsw_boot")) {
- return ReadFileBit(ACPI_CHSW_PATH, CHSW_DEV_BOOT);
+ value = ReadFileBit(ACPI_CHSW_PATH, CHSW_DEV_BOOT);
} else if (!strcasecmp(name,"recoverysw_cur")) {
- return ReadGpio(GPIO_SIGNAL_TYPE_RECOVERY);
+ value = ReadGpio(GPIO_SIGNAL_TYPE_RECOVERY);
} else if (!strcasecmp(name,"recoverysw_boot")) {
- return ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_BOOT);
+ value = ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_BOOT);
} else if (!strcasecmp(name,"recoverysw_ec_boot")) {
- return ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_EC_BOOT);
+ value = ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_EC_BOOT);
} else if (!strcasecmp(name,"wpsw_cur")) {
- return ReadGpio(GPIO_SIGNAL_TYPE_WP);
+ value = ReadGpio(GPIO_SIGNAL_TYPE_WP);
+ if (-1 != value && FwidStartsWith("Mario."))
+ value = 1 - value; /* Mario reports this backwards */
} else if (!strcasecmp(name,"wpsw_boot")) {
- return ReadFileBit(ACPI_CHSW_PATH, CHSW_WP_BOOT);
- } else
- return -1;
+ value = ReadFileBit(ACPI_CHSW_PATH, CHSW_WP_BOOT);
+ if (-1 != value && FwidStartsWith("Mario."))
+ value = 1 - value; /* Mario reports this backwards */
+ }
/* TODO: remaining properties from spec */
+
+ return value;
}