summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/2nvstorage.c12
-rw-r--r--firmware/2lib/include/2nvstorage.h2
-rw-r--r--firmware/2lib/include/2nvstorage_fields.h9
-rw-r--r--firmware/include/vboot_nvstorage.h2
-rw-r--r--firmware/lib/vboot_nvstorage.c22
-rw-r--r--host/lib/crossystem.c8
-rw-r--r--tests/vb2_nvstorage_tests.c1
-rw-r--r--tests/vboot_nvstorage_test.c1
8 files changed, 42 insertions, 15 deletions
diff --git a/firmware/2lib/2nvstorage.c b/firmware/2lib/2nvstorage.c
index 35cf6fcc..66a2202f 100644
--- a/firmware/2lib/2nvstorage.c
+++ b/firmware/2lib/2nvstorage.c
@@ -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;
}
diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h
index 9ade3e78..0a533e3e 100644
--- a/firmware/2lib/include/2nvstorage.h
+++ b/firmware/2lib/include/2nvstorage.h
@@ -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 */
diff --git a/firmware/2lib/include/2nvstorage_fields.h b/firmware/2lib/include/2nvstorage_fields.h
index 0a6c5385..45d9a7c5 100644
--- a/firmware/2lib/include/2nvstorage_fields.h
+++ b/firmware/2lib/include/2nvstorage_fields.h
@@ -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_ */
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h
index 8a8da1c7..4447ef7f 100644
--- a/firmware/include/vboot_nvstorage.h
+++ b/firmware/include/vboot_nvstorage.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;
diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c
index 54ac5ec9..3b2a725b 100644
--- a/firmware/lib/vboot_nvstorage.c
+++ b/firmware/lib/vboot_nvstorage.c
@@ -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[MISC_OFFSET] &= ~MISC_UNLOCK_FASTBOOT;
+ break;
+
+ case VBNV_BOOT_ON_AC_DETECT:
+ if (value)
+ raw[MISC_OFFSET] |= MISC_BOOT_ON_AC_DETECT;
else
- raw[FASTBOOT_OFFSET] &= ~FASTBOOT_UNLOCK_IN_FW;
+ raw[MISC_OFFSET] &= ~MISC_BOOT_ON_AC_DETECT;
break;
default:
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 8ac37cc7..268ecdf1 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -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;
diff --git a/tests/vb2_nvstorage_tests.c b/tests/vb2_nvstorage_tests.c
index 8b1aa2d6..02c8acc8 100644
--- a/tests/vb2_nvstorage_tests.c
+++ b/tests/vb2_nvstorage_tests.c
@@ -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}
};
diff --git a/tests/vboot_nvstorage_test.c b/tests/vboot_nvstorage_test.c
index 7df0cffd..bbded635 100644
--- a/tests/vboot_nvstorage_test.c
+++ b/tests/vboot_nvstorage_test.c
@@ -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}
};