summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2015-01-12 16:25:13 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-14 03:16:49 +0000
commit32138f9d4c143bc0858d32e3a7a7b30ff5655212 (patch)
treef0dffc8993b456ad0e55d468e8da21518cfe060a
parentf10e9099286202f83ce4c1dc5ef1e85fcb5ccde7 (diff)
downloadvboot-32138f9d4c143bc0858d32e3a7a7b30ff5655212.tar.gz
vboot2: Split NV storage field defintions into their own header
And include it in vb2_api.h if VB20 internals are needed. This allows coreboot to get at the fields more cleanly for now, rather than duplicating the field definitions. In the long run, we should have APIs for this rather than having coreboot peek at the bits directly. BUG=none BRANCH=none TEST=emerge-veyron_pinky coreboot && make -j runtests Change-Id: Ic308c3470773b91191bf682ff1b3cfce8864d26a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/240285 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--firmware/2lib/2nvstorage.c57
-rw-r--r--firmware/2lib/include/2nvstorage_fields.h67
-rw-r--r--firmware/include/vb2_api.h1
3 files changed, 69 insertions, 56 deletions
diff --git a/firmware/2lib/2nvstorage.c b/firmware/2lib/2nvstorage.c
index 5c7b9800..68a4dad0 100644
--- a/firmware/2lib/2nvstorage.c
+++ b/firmware/2lib/2nvstorage.c
@@ -10,62 +10,7 @@
#include "2crc8.h"
#include "2misc.h"
#include "2nvstorage.h"
-
-/*
- * Constants for NV storage. We use this rather than structs and bitfields so
- * the data format is consistent across platforms and compilers. Total NV
- * storage size is VB2_NVDATA_SIZE = 16 bytes.
- *
- * These constants must match the equivalent constants in
- * lib/vboot_nvstorage.c. (We currently don't share a common header file
- * because we're tring to keep the two libs independent, and we hope to
- * deprecate that one.)
- */
-
-enum vb2_nv_offset {
- VB2_NV_OFFS_HEADER = 0,
- VB2_NV_OFFS_BOOT = 1,
- VB2_NV_OFFS_RECOVERY = 2,
- VB2_NV_OFFS_LOCALIZATION = 3,
- VB2_NV_OFFS_DEV = 4,
- VB2_NV_OFFS_TPM = 5,
- VB2_NV_OFFS_RECOVERY_SUBCODE = 6,
- VB2_NV_OFFS_BOOT2 = 7,
- /* Offsets 8-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 = 0x0f) */
-#define VB2_NV_HEADER_KERNEL_SETTINGS_RESET 0x10
-#define VB2_NV_HEADER_FW_SETTINGS_RESET 0x20
-#define VB2_NV_HEADER_SIGNATURE 0x40
-#define VB2_NV_HEADER_MASK 0xc0
-
-/* Fields in VB2_NV_OFFS_BOOT */
-#define VB2_NV_BOOT_TRY_COUNT_MASK 0x0f
-#define VB2_NV_BOOT_BACKUP_NVRAM 0x10
-#define VB2_NV_BOOT_OPROM_NEEDED 0x20
-#define VB2_NV_BOOT_DISABLE_DEV 0x40
-#define VB2_NV_BOOT_DEBUG_RESET 0x80
-
-/* Fields in VB2_NV_OFFS_BOOT2 (unused = 0x80) */
-#define VB2_NV_BOOT2_RESULT_MASK 0x03
-#define VB2_NV_BOOT2_TRIED 0x04
-#define VB2_NV_BOOT2_TRY_NEXT 0x08
-#define VB2_NV_BOOT2_PREV_RESULT_MASK 0x30
-#define VB2_NV_BOOT2_PREV_RESULT_SHIFT 4 /* Number of bits to shift result */
-#define VB2_NV_BOOT2_PREV_TRIED 0x40
-
-/* Fields in VB2_NV_OFFS_DEV (unused = 0xf8) */
-#define VB2_NV_DEV_FLAG_USB 0x01
-#define VB2_NV_DEV_FLAG_SIGNED_ONLY 0x02
-#define VB2_NV_DEV_FLAG_LEGACY 0x04
-
-/* Fields in VB2_NV_OFFS_TPM (unused = 0xfc) */
-#define VB2_NV_TPM_CLEAR_OWNER_REQUEST 0x01
-#define VB2_NV_TPM_CLEAR_OWNER_DONE 0x02
+#include "2nvstorage_fields.h"
static void vb2_nv_regen_crc(struct vb2_context *ctx)
{
diff --git a/firmware/2lib/include/2nvstorage_fields.h b/firmware/2lib/include/2nvstorage_fields.h
new file mode 100644
index 00000000..a794f383
--- /dev/null
+++ b/firmware/2lib/include/2nvstorage_fields.h
@@ -0,0 +1,67 @@
+/* Copyright 2015 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.
+ *
+ * Non-volatile storage bitfields
+ */
+
+#ifndef VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_
+#define VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_
+
+/*
+ * Constants for NV storage. We use this rather than structs and bitfields so
+ * the data format is consistent across platforms and compilers. Total NV
+ * storage size is VB2_NVDATA_SIZE = 16 bytes.
+ *
+ * These constants must match the equivalent constants in
+ * lib/vboot_nvstorage.c. (We currently don't share a common header file
+ * because we're tring to keep the two libs independent, and we hope to
+ * deprecate that one.)
+ */
+
+enum vb2_nv_offset {
+ VB2_NV_OFFS_HEADER = 0,
+ VB2_NV_OFFS_BOOT = 1,
+ VB2_NV_OFFS_RECOVERY = 2,
+ VB2_NV_OFFS_LOCALIZATION = 3,
+ VB2_NV_OFFS_DEV = 4,
+ VB2_NV_OFFS_TPM = 5,
+ VB2_NV_OFFS_RECOVERY_SUBCODE = 6,
+ VB2_NV_OFFS_BOOT2 = 7,
+ /* Offsets 8-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 = 0x0f) */
+#define VB2_NV_HEADER_KERNEL_SETTINGS_RESET 0x10
+#define VB2_NV_HEADER_FW_SETTINGS_RESET 0x20
+#define VB2_NV_HEADER_SIGNATURE 0x40
+#define VB2_NV_HEADER_MASK 0xc0
+
+/* Fields in VB2_NV_OFFS_BOOT */
+#define VB2_NV_BOOT_TRY_COUNT_MASK 0x0f
+#define VB2_NV_BOOT_BACKUP_NVRAM 0x10
+#define VB2_NV_BOOT_OPROM_NEEDED 0x20
+#define VB2_NV_BOOT_DISABLE_DEV 0x40
+#define VB2_NV_BOOT_DEBUG_RESET 0x80
+
+/* Fields in VB2_NV_OFFS_BOOT2 (unused = 0x80) */
+#define VB2_NV_BOOT2_RESULT_MASK 0x03
+#define VB2_NV_BOOT2_TRIED 0x04
+#define VB2_NV_BOOT2_TRY_NEXT 0x08
+#define VB2_NV_BOOT2_PREV_RESULT_MASK 0x30
+#define VB2_NV_BOOT2_PREV_RESULT_SHIFT 4 /* Number of bits to shift result */
+#define VB2_NV_BOOT2_PREV_TRIED 0x40
+
+/* Fields in VB2_NV_OFFS_DEV (unused = 0xf8) */
+#define VB2_NV_DEV_FLAG_USB 0x01
+#define VB2_NV_DEV_FLAG_SIGNED_ONLY 0x02
+#define VB2_NV_DEV_FLAG_LEGACY 0x04
+
+/* Fields in VB2_NV_OFFS_TPM (unused = 0xfc) */
+#define VB2_NV_TPM_CLEAR_OWNER_REQUEST 0x01
+#define VB2_NV_TPM_CLEAR_OWNER_DONE 0x02
+
+#endif /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ */
diff --git a/firmware/include/vb2_api.h b/firmware/include/vb2_api.h
index 0b32a782..d8746d01 100644
--- a/firmware/include/vb2_api.h
+++ b/firmware/include/vb2_api.h
@@ -24,6 +24,7 @@
* TODO: Make cleaner APIs to this stuff.
*/
#ifdef NEED_VB20_INTERNALS
+#include "../2lib/include/2nvstorage_fields.h"
#include "../2lib/include/2struct.h"
#include "../lib20/include/vb2_struct.h"
#endif