mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
VbNvStorage: Add flags for misc settings
1. Change offset 8 to hold all misc settings (fastboot, boot_on_ac detect) instead of only fastboot settings. 2. Add flag to hold state of boot_on_ac_detect (If set to 1, AP should start booting as soon as AC is connected in off-state). BUG=chrome-os-partner:41680 BRANCH=None TEST=Compiles successfully. make runtests successful. Change-Id: I64b3fc69bd52cbcaf5899c953ccafa2e81b5b8a5 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/289900 Trybot-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
14f122601f
commit
8804be8cbe
@@ -158,8 +158,10 @@ uint32_t vb2_nv_get(struct vb2_context *ctx, enum vb2_nv_param param)
|
||||
return GETBIT(VB2_NV_OFFS_HEADER , VB2_NV_HEADER_WIPEOUT);
|
||||
|
||||
case VB2_NV_FASTBOOT_UNLOCK_IN_FW:
|
||||
return GETBIT(VB2_NV_OFFS_FASTBOOT,
|
||||
VB2_NV_FASTBOOT_FLAG_UNLOCK_IN_FW);
|
||||
return GETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_UNLOCK_FASTBOOT);
|
||||
|
||||
case VB2_NV_BOOT_ON_AC_DETECT:
|
||||
return GETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_BOOT_ON_AC_DETECT);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -312,7 +314,11 @@ void vb2_nv_set(struct vb2_context *ctx,
|
||||
break;
|
||||
|
||||
case VB2_NV_FASTBOOT_UNLOCK_IN_FW:
|
||||
SETBIT(VB2_NV_OFFS_FASTBOOT, VB2_NV_FASTBOOT_FLAG_UNLOCK_IN_FW);
|
||||
SETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_UNLOCK_FASTBOOT);
|
||||
break;
|
||||
|
||||
case VB2_NV_BOOT_ON_AC_DETECT:
|
||||
SETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_BOOT_ON_AC_DETECT);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ enum vb2_nv_param {
|
||||
|
||||
/* Fastboot: Unlock in firmware, 0=disabled, 1=enabled. */
|
||||
VB2_NV_FASTBOOT_UNLOCK_IN_FW,
|
||||
/* Boot system when AC detected (0=no, 1=yes). */
|
||||
VB2_NV_BOOT_ON_AC_DETECT,
|
||||
};
|
||||
|
||||
/* Firmware result codes for VB2_NV_FW_RESULT and VB2_NV_FW_PREV_RESULT */
|
||||
|
||||
@@ -28,12 +28,12 @@ enum vb2_nv_offset {
|
||||
VB2_NV_OFFS_TPM = 5,
|
||||
VB2_NV_OFFS_RECOVERY_SUBCODE = 6,
|
||||
VB2_NV_OFFS_BOOT2 = 7,
|
||||
VB2_NV_OFFS_FASTBOOT = 8,
|
||||
VB2_NV_OFFS_MISC = 8,
|
||||
/* Offsets 9-10 are currently unused */
|
||||
VB2_NV_OFFS_KERNEL = 11, /* 11-14; field is 32 bits */
|
||||
/* CRC must be last field */
|
||||
VB2_NV_OFFS_CRC = 15
|
||||
};
|
||||
};
|
||||
|
||||
/* Fields in VB2_NV_OFFS_HEADER (unused = 0x07) */
|
||||
#define VB2_NV_HEADER_WIPEOUT 0x08
|
||||
@@ -67,7 +67,8 @@ enum vb2_nv_offset {
|
||||
#define VB2_NV_TPM_CLEAR_OWNER_REQUEST 0x01
|
||||
#define VB2_NV_TPM_CLEAR_OWNER_DONE 0x02
|
||||
|
||||
/* Fields in VB2_NV_OFFS_FASTBOOT (unused = 0xfe) */
|
||||
#define VB2_NV_FASTBOOT_FLAG_UNLOCK_IN_FW 0x01
|
||||
/* Fields in VB2_NV_OFFS_MISC (unused = 0xfc) */
|
||||
#define VB2_NV_MISC_UNLOCK_FASTBOOT 0x01
|
||||
#define VB2_NV_MISC_BOOT_ON_AC_DETECT 0x02
|
||||
|
||||
#endif /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ */
|
||||
|
||||
@@ -112,6 +112,8 @@ typedef enum VbNvParam {
|
||||
|
||||
/* Fastboot: Unlock in firmware, 0=disabled, 1=enabled. */
|
||||
VBNV_FASTBOOT_UNLOCK_IN_FW,
|
||||
/* Boot system when AC detected (0=no, 1=yes). */
|
||||
VBNV_BOOT_ON_AC_DETECT,
|
||||
|
||||
} VbNvParam;
|
||||
|
||||
|
||||
@@ -57,8 +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 MISC_OFFSET 8
|
||||
#define MISC_UNLOCK_FASTBOOT 0x01
|
||||
#define MISC_BOOT_ON_AC_DETECT 0x02
|
||||
|
||||
#define KERNEL_FIELD_OFFSET 11
|
||||
#define CRC_OFFSET 15
|
||||
@@ -206,7 +207,11 @@ int VbNvGet(VbNvContext *context, VbNvParam param, uint32_t *dest)
|
||||
return 0;
|
||||
|
||||
case VBNV_FASTBOOT_UNLOCK_IN_FW:
|
||||
*dest = (raw[FASTBOOT_OFFSET] & FASTBOOT_UNLOCK_IN_FW) ? 1 : 0;
|
||||
*dest = (raw[MISC_OFFSET] & MISC_UNLOCK_FASTBOOT) ? 1 : 0;
|
||||
return 0;
|
||||
|
||||
case VBNV_BOOT_ON_AC_DETECT:
|
||||
*dest = (raw[MISC_OFFSET] & MISC_BOOT_ON_AC_DETECT) ? 1 : 0;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
@@ -397,9 +402,16 @@ int VbNvSet(VbNvContext *context, VbNvParam param, uint32_t value)
|
||||
|
||||
case VBNV_FASTBOOT_UNLOCK_IN_FW:
|
||||
if (value)
|
||||
raw[FASTBOOT_OFFSET] |= FASTBOOT_UNLOCK_IN_FW;
|
||||
raw[MISC_OFFSET] |= MISC_UNLOCK_FASTBOOT;
|
||||
else
|
||||
raw[FASTBOOT_OFFSET] &= ~FASTBOOT_UNLOCK_IN_FW;
|
||||
raw[MISC_OFFSET] &= ~MISC_UNLOCK_FASTBOOT;
|
||||
break;
|
||||
|
||||
case VBNV_BOOT_ON_AC_DETECT:
|
||||
if (value)
|
||||
raw[MISC_OFFSET] |= MISC_BOOT_ON_AC_DETECT;
|
||||
else
|
||||
raw[MISC_OFFSET] &= ~MISC_BOOT_ON_AC_DETECT;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -533,10 +533,10 @@ int VbGetSystemPropertyInt(const char* name) {
|
||||
value = GetVdatInt(VDAT_INT_TRIED_FIRMWARE_B);
|
||||
} else if (!strcasecmp(name,"recovery_reason")) {
|
||||
value = GetVdatInt(VDAT_INT_RECOVERY_REASON);
|
||||
}
|
||||
/* Fastboot-related parameters */
|
||||
else if (!strcasecmp(name, "fastboot_unlock_in_fw")) {
|
||||
} else if (!strcasecmp(name, "fastboot_unlock_in_fw")) {
|
||||
value = VbGetNvStorage(VBNV_FASTBOOT_UNLOCK_IN_FW);
|
||||
} else if (!strcasecmp(name, "boot_on_ac_detect")) {
|
||||
value = VbGetNvStorage(VBNV_BOOT_ON_AC_DETECT);
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -663,6 +663,8 @@ int VbSetSystemPropertyInt(const char* name, int value) {
|
||||
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);
|
||||
} else if (!strcasecmp(name, "boot_on_ac_detect")) {
|
||||
return VbSetNvStorage_WithBackup(VBNV_BOOT_ON_AC_DETECT, value);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -50,6 +50,7 @@ static struct nv_field nvfields[] = {
|
||||
{VB2_NV_OPROM_NEEDED, 0, 1, 0, "oprom needed"},
|
||||
{VB2_NV_BACKUP_NVRAM_REQUEST, 0, 1, 0, "backup nvram request"},
|
||||
{VB2_NV_FASTBOOT_UNLOCK_IN_FW, 0, 1, 0, "fastboot unlock in fw"},
|
||||
{VB2_NV_BOOT_ON_AC_DETECT, 0, 1, 0, "boot on ac detect"},
|
||||
{0, 0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ static VbNvField nvfields[] = {
|
||||
{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"},
|
||||
{VBNV_BOOT_ON_AC_DETECT, 0, 1, 0, "boot on ac detect"},
|
||||
{0, 0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user