Files
OpenCellular/host/include/crossystem_arch.h
Randall Spangler da8d32dc8d Crossystem should return at-boot switch positions from VbSharedData
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.

Change-Id: If4156b5e14c6923c5b331c7e5feaabbffe1dad37
Reviewed-on: https://gerrit.chromium.org/gerrit/29199
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-08-06 13:15:43 -07:00

92 lines
2.9 KiB
C

/* 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.
*
* Architecture-specific APIs for crossystem
*/
#ifndef VBOOT_REFERENCE_CROSSYSTEM_ARCH_H_
#define VBOOT_REFERENCE_CROSSYSTEM_ARCH_H_
#include "vboot_nvstorage.h"
#include "vboot_struct.h"
/* Firmware types from BINF.3. Placed in the common file because both x86 and
* arm use this. The constants are defined in "Chrome OS Main Processor
* Firmware Spec"
*/
#define BINF3_RECOVERY 0
#define BINF3_NORMAL 1
#define BINF3_DEVELOPER 2
#define BINF3_NETBOOT 3
/* INTERNAL APIS FOR CROSSYSTEM AVAILABLE TO ARCH-SPECIFIC FUNCTIONS */
/* Read an integer property from VbNvStorage.
*
* Returns the parameter value, or -1 if error. */
int VbGetNvStorage(VbNvParam param);
/* Write an integer property to VbNvStorage.
*
* Returns 0 if success, -1 if error. */
int VbSetNvStorage(VbNvParam param, int value);
/* Return true if the FWID starts with the specified string. */
int FwidStartsWith(const char *start);
/* Return version of VbSharedData struct or -1 if not found. */
int VbSharedDataVersion(void);
/* Apis WITH ARCH-SPECIFIC IMPLEMENTATIONS */
/* Read the non-volatile context from NVRAM.
*
* Returns 0 if success, -1 if error. */
int VbReadNvStorage(VbNvContext* vnc);
/* Write the non-volatile context to NVRAM.
*
* Returns 0 if success, -1 if error. */
int VbWriteNvStorage(VbNvContext* vnc);
/* Read the VbSharedData buffer.
*
* Verifies the buffer contains at least enough data for the
* VbSharedDataHeader; if not, this is an error.
*
* If less data is read than expected, sets the returned structure's data_size
* to the actual amount of data read. If this is less than data_used, then
* some data was not returned; callers must handle this; this is not considered
* an error.
*
* Returns the data buffer, which must be freed by the caller using
* free(), or NULL if error. */
VbSharedDataHeader* VbSharedDataRead(void);
/* Read an architecture-specific system property integer.
*
* Returns the property value, or -1 if error. */
int VbGetArchPropertyInt(const char* name);
/* Read an architecture-specific system property string into a
* destination buffer of the specified size. Returned string will be
* null-terminated. If the buffer is too small, the returned string
* will be truncated.
*
* Returns the passed buffer, or NULL if error. */
const char* VbGetArchPropertyString(const char* name, char* dest, int size);
/* Set an architecture-specific system property integer.
*
* Returns 0 if success, -1 if error. */
int VbSetArchPropertyInt(const char* name, int value);
/* Set an architecture-specific system property string.
*
* Returns 0 if success, -1 if error. */
int VbSetArchPropertyString(const char* name, const char* value);
#endif /* VBOOT_REFERENCE__CROSSYSTEM_ARCH_H_ */