diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-08-03 12:48:24 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-08-06 16:19:00 -0700 |
commit | 8997979183316951793c24c802abea10ce9fcb91 (patch) | |
tree | d3437974604fc6eb28d1911f08fb5aa27b627330 /host/arch/x86/lib/crossystem_arch.c | |
parent | 1b0bd9ebde0fe1d51c30f1f31c481dfb4788743f (diff) | |
download | vboot-firmware-link-2695.2.B.tar.gz |
Crossystem should return at-boot switch positions from VbSharedDatafirmware-link-2695.2.B
This is more reliable than reading them through FDT/ACPI, since it reflects
the positions as shown to verified boot code.
Notes:
1. This affects ALL platforms with virtual dev switches (x86 AND arm)
2. The fix should have no effect on older platforms, but I haven't tested those.
BUG=chrome-os-partner:11805
TEST=manual
1. boot in normal mode.
devsw_boot = 0 # Developer switch position at boot
recovery_reason = 0 # Recovery mode reason for current boot
recoverysw_boot = 0 # Recovery switch position at boot
wpsw_boot = 1 # Firmware write protect hardware switch position at boot
2. boot in developer mode.
localhost ~ # crossystem
devsw_boot = 1 # Developer switch position at boot
recovery_reason = 0 # Recovery mode reason for current boot
recoverysw_boot = 0 # Recovery switch position at boot
wpsw_boot = 1 # Firmware write protect hardware switch position at boot
3. boot in developer-recovery mode using keyboard combo.
devsw_boot = 1 # Developer switch position at boot
recovery_reason = 2 # Recovery mode reason for current boot
recoverysw_boot = 1 # Recovery switch position at boot
wpsw_boot = 1 # Firmware write protect hardware switch position at boot
4. disable WP and reboot. wpsw_boot should be 0.
Original-Change-Id: If4156b5e14c6923c5b331c7e5feaabbffe1dad37
(cherry picked from commit da8d32dc8d0fb5ebcfffa305f4a3ecb2dd7c79ac)
Change-Id: I6b80c4f507ebbb9accb75ad6b21b0b5bd963921a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29320
Diffstat (limited to 'host/arch/x86/lib/crossystem_arch.c')
-rw-r--r-- | host/arch/x86/lib/crossystem_arch.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c index b0ab10fa..448a8ffa 100644 --- a/host/arch/x86/lib/crossystem_arch.c +++ b/host/arch/x86/lib/crossystem_arch.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -426,19 +426,8 @@ static const char* VbReadMainFwType(char* dest, int size) { /* Read the recovery reason. Returns the reason code or -1 if error. */ static int VbGetRecoveryReason(void) { - VbSharedDataHeader* sh; int value = -1; - /* Try reading from VbSharedData first */ - sh = VbSharedDataRead(); - if (sh) { - if (sh->struct_version >= 2) - value = sh->recovery_reason; - free(sh); - if (-1 != value) - return value; - } - /* Try reading type from BINF.4 */ value = ReadFileInt(ACPI_BINF_PATH ".4"); if (-1 != value) @@ -601,13 +590,11 @@ int VbGetArchPropertyInt(const char* name) { int value = -1; /* Values from ACPI */ - if (!strcasecmp(name,"recovery_reason")) { - value = VbGetRecoveryReason(); - } else if (!strcasecmp(name,"fmap_base")) { + if (!strcasecmp(name,"fmap_base")) value = ReadFileInt(ACPI_FMAP_PATH); - } + /* Switch positions */ - else if (!strcasecmp(name,"devsw_cur")) { + if (!strcasecmp(name,"devsw_cur")) { value = ReadGpio(GPIO_SIGNAL_TYPE_DEV); } else if (!strcasecmp(name,"recoverysw_cur")) { value = ReadGpio(GPIO_SIGNAL_TYPE_RECOVERY); @@ -615,28 +602,36 @@ int VbGetArchPropertyInt(const char* name) { value = ReadGpio(GPIO_SIGNAL_TYPE_WP); if (-1 != value && FwidStartsWith("Mario.")) value = 1 - value; /* Mario reports this backwards */ - } else if (!strcasecmp(name,"devsw_boot")) { - value = ReadFileBit(ACPI_CHSW_PATH, CHSW_DEV_BOOT); - } else if (!strcasecmp(name,"recoverysw_boot")) { - value = ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_BOOT); } else if (!strcasecmp(name,"recoverysw_ec_boot")) { value = ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_EC_BOOT); - } else if (!strcasecmp(name,"wpsw_boot")) { - value = ReadFileBit(ACPI_CHSW_PATH, CHSW_WP_BOOT); - if (-1 != value && FwidStartsWith("Mario.")) - value = 1 - value; /* Mario reports this backwards */ + } + + /* Fields for old systems which don't have VbSharedData */ + if (VbSharedDataVersion() < 2) { + if (!strcasecmp(name,"recovery_reason")) { + value = VbGetRecoveryReason(); + } else if (!strcasecmp(name,"devsw_boot")) { + value = ReadFileBit(ACPI_CHSW_PATH, CHSW_DEV_BOOT); + } else if (!strcasecmp(name,"recoverysw_boot")) { + value = ReadFileBit(ACPI_CHSW_PATH, CHSW_RECOVERY_BOOT); + } else if (!strcasecmp(name,"wpsw_boot")) { + value = ReadFileBit(ACPI_CHSW_PATH, CHSW_WP_BOOT); + if (-1 != value && FwidStartsWith("Mario.")) + value = 1 - value; /* Mario reports this backwards */ + } } /* Saved memory is at a fixed location for all H2C BIOS. If the CHSW * path exists in sysfs, it's a H2C BIOS. */ - else if (!strcasecmp(name,"savedmem_base")) { + if (!strcasecmp(name,"savedmem_base")) { return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00F00000); } else if (!strcasecmp(name,"savedmem_size")) { return (-1 == ReadFileInt(ACPI_CHSW_PATH) ? -1 : 0x00100000); } + /* NV storage values. If unable to get from NV storage, fall back to the - * CMOS reboot field used by older BIOS. */ - else if (!strcasecmp(name,"recovery_request")) { + * CMOS reboot field used by older BIOS (e.g. Mario). */ + if (!strcasecmp(name,"recovery_request")) { value = VbGetNvStorage(VBNV_RECOVERY_REQUEST); if (-1 == value) value = VbGetCmosRebootField(CMOSRF_RECOVERY); @@ -649,10 +644,11 @@ int VbGetArchPropertyInt(const char* name) { if (-1 == value) value = VbGetCmosRebootField(CMOSRF_TRY_B); } + /* Firmware update tries is now stored in the kernel field. On * older systems where it's not, it was stored in a file in the * stateful partition. */ - else if (!strcasecmp(name,"fwupdate_tries")) { + if (!strcasecmp(name,"fwupdate_tries")) { if (-1 != VbGetNvStorage(VBNV_KERNEL_FIELD)) return -1; /* NvStorage supported; fail through arch-specific * implementation to normal implementation. */ |