summaryrefslogtreecommitdiff
path: root/common/cmd_vboot_twostop.c
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2011-07-22 13:43:20 +0800
committerSimon Glass <sjg@chromium.org>2011-08-29 10:59:06 -0700
commit0e128fd51802448ca6b2e2169e481af1f3153185 (patch)
treeacb894ae127fcc2a01019232f9ce2516fb5b042d /common/cmd_vboot_twostop.c
parent02ed9d353315871f3d7a4a1cd91fafac50dafea6 (diff)
CHROMIUM: rename and remove members of crossystem data blob
There are members of the blob that crossystem (user space utility) never uses and are members that have ambiguous names. This patch removes and renames these members, and further cleans up the code and adds static assertions to offset of members. BUG=chromium-os:17876 TEST=boot normal mode on Kaen TEST=check crossystem output Note: savedmem_{base,size} are x86-specific and crossystem is supposed to output "(error)" on ARM boards. ---------------------------------------- arch = arm # Platform architecture cros_debug = 1 # OS should allow debug features dbg_reset = 0 # Debug reset mode request (writable) dev_boot_usb = 1 # Enable developer mode boot from USB/SD (writable) devsw_boot = 0 # Developer switch position at boot devsw_cur = 1 # Developer switch current position ecfw_act = RO # Active EC firmware fmap_base = 0x000c0000 # Main firmware flashmap physical address fwb_tries = 0 # Try firmware B count (writable) fwid = 0.14.785.2011_07_22_1415 # Active firmware ID fwupdate_tries = 0 # Times to try OS firmware update (writable, inside kern_nv) hwid = ARM KAEN TEST 3084 # Hardware ID kern_nv = 0x00000000 # Non-volatile field for kernel use kernkey_vfy = sig # Type of verification done on kernel key block loc_idx = 0 # Localization index for firmware screens (writable) mainfw_act = B # Active main firmware mainfw_type = normal # Active main firmware type nvram_cleared = 1 # Have NV settings been lost? Write 0 to clear recovery_reason = 0 # Recovery mode reason for current boot recovery_request = 0 # Recovery mode request (writable) recoverysw_boot = 0 # Recovery switch position at boot recoverysw_cur = 0 # Recovery switch current position recoverysw_ec_boot = 0 # Recovery switch position at EC boot ro_fwid = 0.14.785.2011_07_22_1415 # Read-only firmware ID savedmem_base = (error) # RAM debug data area physical address savedmem_size = (error) # RAM debug data area size in bytes tpm_fwver = 0x00010001 # Firmware version stored in TPM tpm_kernver = 0x00010001 # Kernel version stored in TPM tried_fwb = 0 # Tried firmware B before A this boot vbtest_errfunc = 0 # Verified boot test error function (writable) vbtest_errno = 0 # Verified boot test error number (writable) vdat_flags = 0x0000020a # Flags from VbSharedData vdat_timers = LFS=776638,778923 LF=794303,6382322 LK=8227743,12897100 # Timer values from VbSharedData wpsw_boot = 0 # Firmware write protect hardware switch position at boot wpsw_cur = 1 # Firmware write protect hardware switch current position ---------------------------------------- Change-Id: I5041ba3dfe51901aabe97e34583fcfdec7375f9f Reviewed-on: http://gerrit.chromium.org/gerrit/4554 Tested-by: Che-Liang Chiou <clchiou@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'common/cmd_vboot_twostop.c')
-rw-r--r--common/cmd_vboot_twostop.c106
1 files changed, 44 insertions, 62 deletions
diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c
index 55491db4378..65a15d8617b 100644
--- a/common/cmd_vboot_twostop.c
+++ b/common/cmd_vboot_twostop.c
@@ -20,6 +20,7 @@
#include <chromeos/power_management.h>
#include <vboot/boot_kernel.h>
+#include <gbb_header.h> /* for GoogleBinaryBlockHeader */
#include <vboot_api.h>
#define PREFIX "vboot_twostop: "
@@ -191,11 +192,11 @@ VbError_t twostop_init_vboot_library(crossystem_data_t *cdata,
VbInitParams iparams;
iparams.flags = VB_INIT_FLAG_RO_NORMAL_SUPPORT;
- if (cdata->write_protect_sw)
+ if (cdata->boot_write_protect_switch)
iparams.flags |= VB_INIT_FLAG_WP_ENABLED;
- if (cdata->recovery_sw)
+ if (cdata->boot_recovery_switch)
iparams.flags |= VB_INIT_FLAG_REC_BUTTON_PRESSED;
- if (cdata->developer_sw)
+ if (cdata->boot_developer_switch)
iparams.flags |= VB_INIT_FLAG_DEV_SWITCH_ON;
VBDEBUG(PREFIX "iparams.flags: %08x\n", iparams.flags);
@@ -312,8 +313,8 @@ uint32_t twostop_select_and_set_main_firmware(struct fdt_twostop_fmap *fmap,
{
uint32_t selection;
uint32_t id_offset = 0, id_length = 0;
- int w, t;
- uint8_t fwid[ID_LEN];
+ int firmware_type;
+ uint8_t firmware_id[ID_LEN];
VbCommonParams cparams;
if (twostop_init_cparams(fmap, gbb, vb_shared_data, &cparams)) {
@@ -334,60 +335,45 @@ uint32_t twostop_select_and_set_main_firmware(struct fdt_twostop_fmap *fmap,
if (selection == VB_SELECT_ERROR)
return VB_SELECT_ERROR;
- w = RECOVERY_FIRMWARE;
- t = RECOVERY_TYPE;
switch(selection) {
case VB_SELECT_FIRMWARE_RECOVERY:
- w = RECOVERY_FIRMWARE;
- t = RECOVERY_TYPE;
+ case VB_SELECT_FIRMWARE_READONLY:
id_offset = fmap->readonly.firmware_id.offset;
id_length = fmap->readonly.firmware_id.length;
break;
case VB_SELECT_FIRMWARE_A:
- w = REWRITABLE_FIRMWARE_A;
- t = cdata->developer_sw ? DEVELOPER_TYPE : NORMAL_TYPE;
id_offset = fmap->readwrite_a.firmware_id.offset;
id_length = fmap->readwrite_a.firmware_id.length;
break;
case VB_SELECT_FIRMWARE_B:
- w = REWRITABLE_FIRMWARE_B;
- t = cdata->developer_sw ? DEVELOPER_TYPE : NORMAL_TYPE;
id_offset = fmap->readwrite_b.firmware_id.offset;
id_length = fmap->readwrite_b.firmware_id.length;
break;
- case VB_SELECT_FIRMWARE_READONLY:
- w = READONLY_FIRMWARE;
- t = cdata->developer_sw ? DEVELOPER_TYPE : NORMAL_TYPE;
- id_offset = fmap->readonly.firmware_id.offset;
- id_length = fmap->readonly.firmware_id.length;
- break;
default:
VBDEBUG(PREFIX "impossible selection value: %d\n", selection);
assert(0);
}
- if (id_length > sizeof(fwid)) {
- VBDEBUG(PREFIX "firmware id is too long: %u > %u\n",
- id_length, sizeof(fwid));
- return VB_SELECT_ERROR;
- }
-
- if (id_length && file->read(file, id_offset, id_length, fwid)) {
+ if (file->read(file, id_offset,
+ MIN(sizeof(firmware_id), id_length),
+ firmware_id)) {
VBDEBUG(PREFIX "failed to read active firmware id\n");
- fwid[0] = '\0';
+ firmware_id[0] = '\0';
}
- VBDEBUG(PREFIX "active main firmware : %d\n", w);
- VBDEBUG(PREFIX "active main firmware type : %d\n", t);
- VBDEBUG(PREFIX "active main firmware id : \"%s\"\n", fwid);
+ if (selection == VB_SELECT_FIRMWARE_RECOVERY)
+ firmware_type = FIRMWARE_TYPE_RECOVERY;
+ else if (cdata->boot_developer_switch)
+ firmware_type = FIRMWARE_TYPE_DEVELOPER;
+ else
+ firmware_type = FIRMWARE_TYPE_NORMAL;
- if (crossystem_data_set_active_main_firmware(cdata, w, t)) {
- VBDEBUG(PREFIX "failed to set active main firmware\n");
- return VB_SELECT_ERROR;
- }
+ VBDEBUG(PREFIX "active main firmware type : %d\n", firmware_type);
+ VBDEBUG(PREFIX "active main firmware id : \"%s\"\n", firmware_id);
- if (crossystem_data_set_fwid(cdata, fwid)) {
- VBDEBUG(PREFIX "failed to set active main firmware id\n");
+ if (crossystem_data_set_main_firmware(cdata,
+ firmware_type, firmware_id)) {
+ VBDEBUG(PREFIX "failed to set active main firmware\n");
return VB_SELECT_ERROR;
}
@@ -426,8 +412,8 @@ int twostop_init(const void const *fdt,
void *vb_shared_data)
{
cros_gpio_t wpsw, recsw, devsw;
- uint8_t frid[ID_LEN];
- uint8_t nvcxt_raw[VBNV_BLOCK_SIZE];
+ GoogleBinaryBlockHeader *gbbh = (GoogleBinaryBlockHeader *)gbb;
+ uint8_t hardware_id[ID_LEN], readonly_firmware_id[ID_LEN];
int ret = -1;
if (cros_gpio_fetch(CROS_GPIO_WPSW, fdt, &wpsw) ||
@@ -446,19 +432,6 @@ int twostop_init(const void const *fdt,
}
dump_fmap(fmap);
- /* Read NvStorage */
- if (VbExNvStorageRead(nvcxt_raw)) {
- VBDEBUG(PREFIX "failed to read NvStorage\n");
- return -1;
- }
-#ifdef VBOOT_DEBUG
- int i;
- VBDEBUG(PREFIX "nvcxt_raw: ");
- for (i = 0; i < VBNV_BLOCK_SIZE; i++)
- VBDEBUG("%02x", nvcxt_raw[i]);
- VBDEBUG("\n");
-#endif /* VBOOT_DEBUG */
-
/* We revert the decision of using firmware_storage_open_twostop() */
if (firmware_storage_open_spi(file)) {
VBDEBUG(PREFIX "failed to open firmware storage\n");
@@ -467,11 +440,13 @@ int twostop_init(const void const *fdt,
/* Read read-only firmware ID */
if (file->read(file, fmap->readonly.firmware_id.offset,
- fmap->readonly.firmware_id.length, frid)) {
+ MIN(sizeof(readonly_firmware_id),
+ fmap->readonly.firmware_id.length),
+ readonly_firmware_id)) {
VBDEBUG(PREFIX "failed to read firmware ID\n");
- goto out;
+ readonly_firmware_id[0] = '\0';
}
- VBDEBUG(PREFIX "read-only firmware id: \"%s\"\n", frid);
+ VBDEBUG(PREFIX "read-only firmware id: \"%s\"\n", readonly_firmware_id);
/* Load gbb blob */
if (file->read(file, fmap->readonly.gbb.offset,
@@ -480,15 +455,22 @@ int twostop_init(const void const *fdt,
goto out;
}
+ memcpy(hardware_id, gbb + gbbh->hwid_offset,
+ MIN(sizeof(hardware_id), gbbh->hwid_size));
+ VBDEBUG(PREFIX "hardware id: \"%s\"\n", hardware_id);
+
/* Initialize crossystem data */
+ /*
+ * TODO There is no readwrite EC firmware on our current ARM boards. But
+ * we should have a mechanism to probe (or acquire this information from
+ * the device tree) whether the active EC firmware is R/O or R/W.
+ */
if (crossystem_data_init(cdata,
- frid,
+ &wpsw, &recsw, &devsw,
fmap->readonly.fmap.offset,
- gbb,
- nvcxt_raw,
- &wpsw,
- &recsw,
- &devsw)) {
+ ACTIVE_EC_FIRMWARE_RO,
+ hardware_id,
+ readonly_firmware_id)) {
VBDEBUG(PREFIX "failed to init crossystem data\n");
goto out;
}
@@ -560,7 +542,7 @@ uint32_t twostop_boot(const void const *fdt)
firmware_storage_t file;
crossystem_data_t *cdata = (crossystem_data_t *)CROSSYSTEM_DATA_ADDRESS;
void *gbb = (void *)GBB_ADDRESS;
- void *vb_shared_data = cdata->vbshared_data;
+ void *vb_shared_data = cdata->vb_shared_data;
void *fw_blob = NULL;
uint32_t fw_size = 0;
uint32_t selection;
@@ -624,7 +606,7 @@ uint32_t twostop_readwrite_main_firmware(const void const *fdt)
struct fdt_twostop_fmap fmap;
crossystem_data_t *cdata = (crossystem_data_t *)CROSSYSTEM_DATA_ADDRESS;
void *gbb = (void *)GBB_ADDRESS;
- void *vb_shared_data = cdata->vbshared_data;
+ void *vb_shared_data = cdata->vb_shared_data;
/* Newer readwrite firmware should check version of the data blobs */