mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-23 17:55:01 +00:00
fastboot: Add fastboot related flags to nvstorage
Use unused offset 8 for fastboot related flags. BUG=chrome-os-partner:40196 BRANCH=None TEST=Compiles successfully. Change-Id: I6df0985924ba80cdcb68bb6b7658bf962f01287f Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/273180 Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org> Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
ebf886b5fd
commit
c180460feb
@@ -110,6 +110,9 @@ typedef enum VbNvParam {
|
||||
/* Wipeout request from firmware present. */
|
||||
VBNV_FW_REQ_WIPEOUT,
|
||||
|
||||
/* Fastboot: Unlock in firmware, 0=disabled, 1=enabled. */
|
||||
VBNV_FASTBOOT_UNLOCK_IN_FW,
|
||||
|
||||
} VbNvParam;
|
||||
|
||||
/* Result of trying the firmware in VBNV_FW_TRIED */
|
||||
|
||||
@@ -323,6 +323,7 @@ VbError_t VbInit(VbCommonParams *cparams, VbInitParams *iparams)
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_LEGACY, 0);
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_SIGNED_ONLY, 0);
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, 0);
|
||||
VbNvSet(&vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, 0);
|
||||
/*
|
||||
* Back up any changes now, so these values can't be forgotten
|
||||
* by draining the battery. We really only care about these
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
#define BOOT2_PREV_RESULT_SHIFT 4 /* Number of bits to shift result */
|
||||
#define BOOT2_PREV_TRIED 0x40
|
||||
|
||||
#define FASTBOOT_OFFSET 8
|
||||
#define FASTBOOT_UNLOCK_IN_FW 0x01
|
||||
|
||||
#define KERNEL_FIELD_OFFSET 11
|
||||
#define CRC_OFFSET 15
|
||||
|
||||
@@ -202,6 +205,10 @@ int VbNvGet(VbNvContext *context, VbNvParam param, uint32_t *dest)
|
||||
*dest = (raw[HEADER_OFFSET] & HEADER_WIPEOUT) ? 1 : 0;
|
||||
return 0;
|
||||
|
||||
case VBNV_FASTBOOT_UNLOCK_IN_FW:
|
||||
*dest = (raw[FASTBOOT_OFFSET] & FASTBOOT_UNLOCK_IN_FW) ? 1 : 0;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
@@ -388,6 +395,13 @@ int VbNvSet(VbNvContext *context, VbNvParam param, uint32_t value)
|
||||
raw[HEADER_OFFSET] &= ~HEADER_WIPEOUT;
|
||||
break;
|
||||
|
||||
case VBNV_FASTBOOT_UNLOCK_IN_FW:
|
||||
if (value)
|
||||
raw[FASTBOOT_OFFSET] |= FASTBOOT_UNLOCK_IN_FW;
|
||||
else
|
||||
raw[FASTBOOT_OFFSET] &= ~FASTBOOT_UNLOCK_IN_FW;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ static const VbNvParam backup_params[] = {
|
||||
VBNV_DEV_BOOT_LEGACY,
|
||||
VBNV_DEV_BOOT_SIGNED_ONLY,
|
||||
VBNV_DEV_BOOT_FASTBOOT_FULL_CAP,
|
||||
VBNV_FASTBOOT_UNLOCK_IN_FW,
|
||||
};
|
||||
|
||||
/* We can't back things up if there isn't enough storage. */
|
||||
|
||||
@@ -534,6 +534,10 @@ int VbGetSystemPropertyInt(const char* name) {
|
||||
} else if (!strcasecmp(name,"recovery_reason")) {
|
||||
value = GetVdatInt(VDAT_INT_RECOVERY_REASON);
|
||||
}
|
||||
/* Fastboot-related parameters */
|
||||
else if (!strcasecmp(name, "fastboot_unlock_in_fw")) {
|
||||
value = VbGetNvStorage(VBNV_FASTBOOT_UNLOCK_IN_FW);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -657,6 +661,8 @@ int VbSetSystemPropertyInt(const char* name, int value) {
|
||||
return VbSetNvStorage_WithBackup(VBNV_DEV_BOOT_SIGNED_ONLY, value);
|
||||
} else if (!strcasecmp(name,"dev_boot_fastboot_full_cap")) {
|
||||
return VbSetNvStorage_WithBackup(VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, value);
|
||||
} else if (!strcasecmp(name, "fastboot_unlock_in_fw")) {
|
||||
return VbSetNvStorage_WithBackup(VBNV_FASTBOOT_UNLOCK_IN_FW, value);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -556,6 +556,7 @@ static void VbInitTestBackup(void)
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_LEGACY, 1);
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_SIGNED_ONLY, 1);
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, 1);
|
||||
VbNvSet(&vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, 1);
|
||||
/* and some that don't */
|
||||
VbNvSet(&vnc, VBNV_OPROM_NEEDED, 1);
|
||||
VbNvSet(&vnc, VBNV_TRY_B_COUNT, 3);
|
||||
@@ -585,6 +586,8 @@ static void VbInitTestBackup(void)
|
||||
TEST_EQ(u, 0, " NV dev_boot_signed_only");
|
||||
VbNvGet(&vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, &u);
|
||||
TEST_EQ(u, 0, " NV dev_boot_fastboot_full_cap");
|
||||
VbNvGet(&vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, &u);
|
||||
TEST_EQ(u, 0, " NV_fastboot_unlock_in_fw ");
|
||||
/* So we should have written the backup */
|
||||
TEST_EQ(backup_write_called, 1, " Backup written once");
|
||||
/* And the backup should reflect the persisent flags. */
|
||||
@@ -602,6 +605,8 @@ static void VbInitTestBackup(void)
|
||||
TEST_EQ(u, 0, " BU dev_boot_signed_only");
|
||||
VbNvGet(&tmp_vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, &u);
|
||||
TEST_EQ(u, 0, " BU dev_boot_fastboot_full_cap");
|
||||
VbNvGet(&tmp_vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, &u);
|
||||
TEST_EQ(u, 0, " BU fastboot_unlock_in_fw");
|
||||
/* but not the others */
|
||||
VbNvGet(&tmp_vnc, VBNV_OPROM_NEEDED, &u);
|
||||
TEST_EQ(u, 0, " BU oprom_needed");
|
||||
@@ -642,6 +647,7 @@ static void VbInitTestBackup(void)
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_LEGACY, 1);
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_SIGNED_ONLY, 1);
|
||||
VbNvSet(&vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, 1);
|
||||
VbNvSet(&vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, 1);
|
||||
/* and some that don't */
|
||||
VbNvSet(&vnc, VBNV_OPROM_NEEDED, 1);
|
||||
VbNvSet(&vnc, VBNV_TRY_B_COUNT, 4);
|
||||
@@ -691,6 +697,8 @@ static void VbInitTestBackup(void)
|
||||
TEST_EQ(u, 1, " BU dev_boot_signed_only");
|
||||
VbNvGet(&tmp_vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, &u);
|
||||
TEST_EQ(u, 1, " BU dev_boot_fastboot_full_cap");
|
||||
VbNvGet(&tmp_vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, &u);
|
||||
TEST_EQ(u, 1, " BU fastboot_unlock_in_fw");
|
||||
/* but not the others */
|
||||
VbNvGet(&tmp_vnc, VBNV_OPROM_NEEDED, &u);
|
||||
TEST_EQ(u, 0, " BU oprom_needed");
|
||||
@@ -730,6 +738,8 @@ static void VbInitTestBackup(void)
|
||||
TEST_EQ(u, 1, " BU dev_boot_signed_only");
|
||||
VbNvGet(&vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, &u);
|
||||
TEST_EQ(u, 1, " BU dev_boot_fastboot_full_cap");
|
||||
VbNvGet(&vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, &u);
|
||||
TEST_EQ(u, 1, " BU fastboot_unlock_in_fw");
|
||||
|
||||
/*
|
||||
* But if we lose the NV storage and go back to normal mode at the same
|
||||
@@ -766,6 +776,8 @@ static void VbInitTestBackup(void)
|
||||
TEST_EQ(u, 0, " BU dev_boot_signed_only");
|
||||
VbNvGet(&vnc, VBNV_DEV_BOOT_FASTBOOT_FULL_CAP, &u);
|
||||
TEST_EQ(u, 0, " BU dev_boot_fastboot_full_cap");
|
||||
VbNvGet(&vnc, VBNV_FASTBOOT_UNLOCK_IN_FW, &u);
|
||||
TEST_EQ(u, 0, " BU fastboot_unlock_in_fw");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ static VbNvField nvfields[] = {
|
||||
{VBNV_FW_RESULT, VBNV_FW_RESULT_UNKNOWN, 1, 2, "firmware result"},
|
||||
{VBNV_FW_PREV_TRIED, 0, 1, 0, "firmware prev tried"},
|
||||
{VBNV_FW_PREV_RESULT, VBNV_FW_RESULT_UNKNOWN, 1, 3, "firmware prev result"},
|
||||
{VBNV_FASTBOOT_UNLOCK_IN_FW, 0, 1, 0, "fastboot unlock in firmware"},
|
||||
{0, 0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user