summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-01-03 13:49:18 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-12 15:56:27 -0800
commit21015898b39aa8742057ed6e6423c308c8d0a15d (patch)
tree8221b6a48e13d8cdf15820cc92247167f8ac5fe0
parentdf4eb2bb7be9d61bfe9bdf6c33f836f358b18cf6 (diff)
downloadvboot-21015898b39aa8742057ed6e6423c308c8d0a15d.tar.gz
firmware: replace VBDEBUG(()) macro with VB2_DEBUG()
The original VBDEBUG macro used doubly-nested parens to work with MSVC, which didn't support varargs in macros. We now only use more modern compilers, so replace it with the VB2_DEBUG macro and get rid of the ugly and fragile double parens. BUG=chromium:611535 BRANCH=none TEST=make runtests; build_packages --board=reef chromeos-firmware Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425133 Reviewed-by: Shelley Chen <shchen@chromium.org>
-rw-r--r--firmware/lib/cgptlib/cgptlib.c32
-rw-r--r--firmware/lib/gpt_misc.c48
-rw-r--r--firmware/lib/include/utility.h7
-rw-r--r--firmware/lib/region-kernel.c12
-rw-r--r--firmware/lib/rollback_index.c52
-rw-r--r--firmware/lib/tpm2_lite/marshaling.c96
-rw-r--r--firmware/lib/tpm2_lite/tlcl.c24
-rw-r--r--firmware/lib/tpm_lite/tlcl.c78
-rw-r--r--firmware/lib/vboot_api_kernel.c60
-rw-r--r--firmware/lib/vboot_audio.c48
-rw-r--r--firmware/lib/vboot_common.c10
-rw-r--r--firmware/lib/vboot_common_init.c12
-rw-r--r--firmware/lib/vboot_display.c36
-rw-r--r--firmware/lib/vboot_ui.c126
-rw-r--r--firmware/stub/tpm_lite_stub.c17
-rw-r--r--host/lib/crossystem.c11
-rw-r--r--host/lib/file_keys.c2
-rw-r--r--host/lib/host_misc.c8
-rw-r--r--host/lib/signature_digest.c20
-rw-r--r--tests/vboot_api_devmode_tests.c36
-rw-r--r--tests/vboot_api_kernel_tests.c36
-rw-r--r--tests/vboot_audio_tests.c1
22 files changed, 394 insertions, 378 deletions
diff --git a/firmware/lib/cgptlib/cgptlib.c b/firmware/lib/cgptlib/cgptlib.c
index 954ca5fa..449ed2f0 100644
--- a/firmware/lib/cgptlib/cgptlib.c
+++ b/firmware/lib/cgptlib/cgptlib.c
@@ -3,8 +3,10 @@
* found in the LICENSE file.
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "sysincludes.h"
#include "cgptlib.h"
#include "cgptlib_internal.h"
#include "crc32.h"
@@ -22,7 +24,7 @@ int GptInit(GptData *gpt)
retval = GptSanityCheck(gpt);
if (GPT_SUCCESS != retval) {
- VBDEBUG(("GptInit() failed sanity check\n"));
+ VB2_DEBUG("GptInit() failed sanity check\n");
return retval;
}
@@ -50,18 +52,18 @@ int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size)
e = entries + i;
if (!IsKernelEntry(e))
continue;
- VBDEBUG(("GptNextKernelEntry looking at same prio "
- "partition %d\n", i+1));
- VBDEBUG(("GptNextKernelEntry s%d t%d p%d\n",
- GetEntrySuccessful(e), GetEntryTries(e),
- GetEntryPriority(e)));
+ VB2_DEBUG("GptNextKernelEntry looking at same prio "
+ "partition %d\n", i+1);
+ VB2_DEBUG("GptNextKernelEntry s%d t%d p%d\n",
+ GetEntrySuccessful(e), GetEntryTries(e),
+ GetEntryPriority(e));
if (!(GetEntrySuccessful(e) || GetEntryTries(e)))
continue;
if (GetEntryPriority(e) == gpt->current_priority) {
gpt->current_kernel = i;
*start_sector = e->starting_lba;
*size = e->ending_lba - e->starting_lba + 1;
- VBDEBUG(("GptNextKernelEntry likes it\n"));
+ VB2_DEBUG("GptNextKernelEntry likes it\n");
return GPT_SUCCESS;
}
}
@@ -75,11 +77,11 @@ int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size)
int current_prio = GetEntryPriority(e);
if (!IsKernelEntry(e))
continue;
- VBDEBUG(("GptNextKernelEntry looking at new prio "
- "partition %d\n", i+1));
- VBDEBUG(("GptNextKernelEntry s%d t%d p%d\n",
- GetEntrySuccessful(e), GetEntryTries(e),
- GetEntryPriority(e)));
+ VB2_DEBUG("GptNextKernelEntry looking at new prio "
+ "partition %d\n", i+1);
+ VB2_DEBUG("GptNextKernelEntry s%d t%d p%d\n",
+ GetEntrySuccessful(e), GetEntryTries(e),
+ GetEntryPriority(e));
if (!(GetEntrySuccessful(e) || GetEntryTries(e)))
continue;
if (current_prio >= gpt->current_priority) {
@@ -101,11 +103,11 @@ int GptNextKernelEntry(GptData *gpt, uint64_t *start_sector, uint64_t *size)
gpt->current_priority = new_prio;
if (CGPT_KERNEL_ENTRY_NOT_FOUND == new_kernel) {
- VBDEBUG(("GptNextKernelEntry no more kernels\n"));
+ VB2_DEBUG("GptNextKernelEntry no more kernels\n");
return GPT_ERROR_NO_VALID_KERNEL;
}
- VBDEBUG(("GptNextKernelEntry likes partition %d\n", new_kernel + 1));
+ VB2_DEBUG("GptNextKernelEntry likes partition %d\n", new_kernel + 1);
e = entries + new_kernel;
*start_sector = e->starting_lba;
*size = e->ending_lba - e->starting_lba + 1;
diff --git a/firmware/lib/gpt_misc.c b/firmware/lib/gpt_misc.c
index 3b079444..ca16f220 100644
--- a/firmware/lib/gpt_misc.c
+++ b/firmware/lib/gpt_misc.c
@@ -3,8 +3,10 @@
* found in the LICENSE file.
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "sysincludes.h"
#include "cgptlib.h"
#include "cgptlib_internal.h"
#include "crc32.h"
@@ -46,7 +48,7 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
/* Read primary header from the drive, skipping the protective MBR */
if (0 != VbExDiskRead(disk_handle, 1, 1, gptdata->primary_header)) {
- VBDEBUG(("Read error in primary GPT header\n"));
+ VB2_DEBUG("Read error in primary GPT header\n");
memset(gptdata->primary_header, 0, gptdata->sector_bytes);
}
@@ -66,21 +68,21 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
primary_header->entries_lba,
entries_sectors,
gptdata->primary_entries)) {
- VBDEBUG(("Read error in primary GPT entries\n"));
+ VB2_DEBUG("Read error in primary GPT entries\n");
primary_valid = 0;
}
} else {
- VBDEBUG(("Primary GPT header is %s\n",
- memcmp(primary_header->signature,
- GPT_HEADER_SIGNATURE_IGNORED,
- GPT_HEADER_SIGNATURE_SIZE)
- ? "invalid" : "being ignored"));
+ VB2_DEBUG("Primary GPT header is %s\n",
+ memcmp(primary_header->signature,
+ GPT_HEADER_SIGNATURE_IGNORED,
+ GPT_HEADER_SIGNATURE_SIZE)
+ ? "invalid" : "being ignored");
}
/* Read secondary header from the end of the drive */
if (0 != VbExDiskRead(disk_handle, gptdata->gpt_drive_sectors - 1, 1,
gptdata->secondary_header)) {
- VBDEBUG(("Read error in secondary GPT header\n"));
+ VB2_DEBUG("Read error in secondary GPT header\n");
memset(gptdata->secondary_header, 0, gptdata->sector_bytes);
}
@@ -100,15 +102,15 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
secondary_header->entries_lba,
entries_sectors,
gptdata->secondary_entries)) {
- VBDEBUG(("Read error in secondary GPT entries\n"));
+ VB2_DEBUG("Read error in secondary GPT entries\n");
secondary_valid = 0;
}
} else {
- VBDEBUG(("Secondary GPT header is %s\n",
- memcmp(secondary_header->signature,
- GPT_HEADER_SIGNATURE_IGNORED,
- GPT_HEADER_SIGNATURE_SIZE)
- ? "invalid" : "being ignored"));
+ VB2_DEBUG("Secondary GPT header is %s\n",
+ memcmp(secondary_header->signature,
+ GPT_HEADER_SIGNATURE_IGNORED,
+ GPT_HEADER_SIGNATURE_SIZE)
+ ? "invalid" : "being ignored");
}
/* Return 0 if least one GPT header was valid */
@@ -147,17 +149,17 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
entries_lba = h->entries_lba;
if (gptdata->ignored & MASK_PRIMARY) {
- VBDEBUG(("Not updating primary GPT: "
- "marked to be ignored.\n"));
+ VB2_DEBUG("Not updating primary GPT: "
+ "marked to be ignored.\n");
skip_primary = 1;
} else if (gptdata->modified & GPT_MODIFIED_HEADER1) {
if (!memcmp(h->signature, GPT_HEADER_SIGNATURE2,
GPT_HEADER_SIGNATURE_SIZE)) {
- VBDEBUG(("Not updating primary GPT: "
- "legacy mode is enabled.\n"));
+ VB2_DEBUG("Not updating primary GPT: "
+ "legacy mode is enabled.\n");
skip_primary = 1;
} else {
- VBDEBUG(("Updating GPT header 1\n"));
+ VB2_DEBUG("Updating GPT header 1\n");
if (0 != VbExDiskWrite(disk_handle, 1, 1,
gptdata->primary_header))
goto fail;
@@ -167,7 +169,7 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
if (gptdata->primary_entries && !skip_primary) {
if (gptdata->modified & GPT_MODIFIED_ENTRIES1) {
- VBDEBUG(("Updating GPT entries 1\n"));
+ VB2_DEBUG("Updating GPT entries 1\n");
if (0 != VbExDiskWrite(disk_handle, entries_lba,
entries_sectors,
gptdata->primary_entries))
@@ -181,7 +183,7 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
GptHeader *h = (GptHeader *)(gptdata->secondary_header);
entries_lba = h->entries_lba;
if (gptdata->modified & GPT_MODIFIED_HEADER2) {
- VBDEBUG(("Updating GPT header 2\n"));
+ VB2_DEBUG("Updating GPT header 2\n");
if (0 != VbExDiskWrite(disk_handle,
gptdata->gpt_drive_sectors - 1, 1,
gptdata->secondary_header))
@@ -191,7 +193,7 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata)
if (gptdata->secondary_entries && !(gptdata->ignored & MASK_SECONDARY)){
if (gptdata->modified & GPT_MODIFIED_ENTRIES2) {
- VBDEBUG(("Updating GPT entries 2\n"));
+ VB2_DEBUG("Updating GPT entries 2\n");
if (0 != VbExDiskWrite(disk_handle,
entries_lba, entries_sectors,
gptdata->secondary_entries))
diff --git a/firmware/lib/include/utility.h b/firmware/lib/include/utility.h
index 589685b1..590c60af 100644
--- a/firmware/lib/include/utility.h
+++ b/firmware/lib/include/utility.h
@@ -14,13 +14,6 @@
#include "sysincludes.h"
#include "vboot_api.h"
-/* Debug and error output */
-#ifdef VBOOT_DEBUG
-#define VBDEBUG(params) VbExDebug params
-#else
-#define VBDEBUG(params)
-#endif
-
#ifdef VBOOT_DEBUG
#define VbAssert(expr) do { if (!(expr)) { \
VbExError("assert fail: %s at %s:%d\n", \
diff --git a/firmware/lib/region-kernel.c b/firmware/lib/region-kernel.c
index 96d9cb6f..7041b4f6 100644
--- a/firmware/lib/region-kernel.c
+++ b/firmware/lib/region-kernel.c
@@ -6,8 +6,10 @@
* (Firmware portion)
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "sysincludes.h"
#include "bmpblk_header.h"
#include "region.h"
#include "gbb_access.h"
@@ -50,8 +52,8 @@ VbError_t VbGbbReadBmpHeader(VbCommonParams *cparams, BmpBlockHeader *hdr_ret)
(hdr->major_version > BMPBLOCK_MAJOR_VERSION) ||
((hdr->major_version == BMPBLOCK_MAJOR_VERSION) &&
(hdr->minor_version > BMPBLOCK_MINOR_VERSION))) {
- VBDEBUG(("VbGbbReadBmpHeader(): "
- "invalid/too new bitmap header\n"));
+ VB2_DEBUG("VbGbbReadBmpHeader(): "
+ "invalid/too new bitmap header\n");
free(hdr);
return VBERROR_INVALID_BMPFV;
}
@@ -78,12 +80,12 @@ VbError_t VbRegionReadHWID(VbCommonParams *cparams, char *hwid,
gbb = cparams->gbb;
if (0 == gbb->hwid_size) {
- VBDEBUG(("VbHWID(): invalid hwid size\n"));
+ VB2_DEBUG("VbHWID(): invalid hwid size\n");
return VBERROR_SUCCESS; /* oddly enough! */
}
if (gbb->hwid_size > max_size) {
- VBDEBUG(("VbDisplayDebugInfo(): invalid hwid offset/size\n"));
+ VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n");
return VBERROR_INVALID_PARAMETER;
}
ret = VbRegionReadGbb(cparams, gbb->hwid_offset, gbb->hwid_size, hwid);
diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c
index 84eee008..43c6772f 100644
--- a/firmware/lib/rollback_index.c
+++ b/firmware/lib/rollback_index.c
@@ -6,9 +6,11 @@
* stored in the TPM NVRAM.
*/
-#include "sysincludes.h"
-
+#include "2sysincludes.h"
+#include "2common.h"
#include "2crc8.h"
+
+#include "sysincludes.h"
#include "rollback_index.h"
#include "tlcl.h"
#include "tss_constants.h"
@@ -41,8 +43,8 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk);
#define RETURN_ON_FAILURE(tpm_command) do { \
uint32_t result_; \
if ((result_ = (tpm_command)) != TPM_SUCCESS) { \
- VBDEBUG(("Rollback: %08x returned by " #tpm_command \
- "\n", (int)result_)); \
+ VB2_DEBUG("Rollback: %08x returned by " #tpm_command \
+ "\n", (int)result_); \
return result_; \
} \
} while (0)
@@ -50,7 +52,7 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk);
uint32_t TPMClearAndReenable(void)
{
- VBDEBUG(("TPM: Clear and re-enable\n"));
+ VB2_DEBUG("TPM: Clear and re-enable\n");
RETURN_ON_FAILURE(TlclForceClear());
RETURN_ON_FAILURE(TlclSetEnable());
RETURN_ON_FAILURE(TlclSetDeactivated(0));
@@ -103,10 +105,10 @@ uint32_t ReadSpaceFirmware(RollbackSpaceFirmware *rsf)
offsetof(RollbackSpaceFirmware, crc8)))
return TPM_SUCCESS;
- VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
+ VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
}
- VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
+ VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
return TPM_E_CORRUPTED_STATE;
}
@@ -133,11 +135,11 @@ uint32_t WriteSpaceFirmware(RollbackSpaceFirmware *rsf)
if (r == TPM_SUCCESS)
return r;
- VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
+ VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
/* Try writing it again. Maybe it was garbled on the way out. */
}
- VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
+ VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
return TPM_E_CORRUPTED_STATE;
}
@@ -145,11 +147,11 @@ uint32_t SetVirtualDevMode(int val)
{
RollbackSpaceFirmware rsf;
- VBDEBUG(("TPM: Entering %s()\n", __func__));
+ VB2_DEBUG("TPM: Entering %s()\n", __func__);
if (TPM_SUCCESS != ReadSpaceFirmware(&rsf))
return VBERROR_TPM_FIRMWARE_SETUP;
- VBDEBUG(("TPM: flags were 0x%02x\n", rsf.flags));
+ VB2_DEBUG("TPM: flags were 0x%02x\n", rsf.flags);
if (val)
rsf.flags |= FLAG_VIRTUAL_DEV_MODE_ON;
else
@@ -158,12 +160,12 @@ uint32_t SetVirtualDevMode(int val)
* NOTE: This doesn't update the FLAG_LAST_BOOT_DEVELOPER bit. That
* will be done on the next boot.
*/
- VBDEBUG(("TPM: flags are now 0x%02x\n", rsf.flags));
+ VB2_DEBUG("TPM: flags are now 0x%02x\n", rsf.flags);
if (TPM_SUCCESS != WriteSpaceFirmware(&rsf))
return VBERROR_TPM_SET_BOOT_MODE_STATE;
- VBDEBUG(("TPM: Leaving %s()\n", __func__));
+ VB2_DEBUG("TPM: Leaving %s()\n", __func__);
return VBERROR_SUCCESS;
}
@@ -199,10 +201,10 @@ uint32_t ReadSpaceKernel(RollbackSpaceKernel *rsk)
vb2_crc8(rsk, offsetof(RollbackSpaceKernel, crc8)))
return TPM_SUCCESS;
- VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
+ VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
}
- VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
+ VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
return TPM_E_CORRUPTED_STATE;
}
@@ -229,11 +231,11 @@ uint32_t WriteSpaceKernel(RollbackSpaceKernel *rsk)
if (r == TPM_SUCCESS)
return r;
- VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
+ VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
/* Try writing it again. Maybe it was garbled on the way out. */
}
- VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
+ VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
return TPM_E_CORRUPTED_STATE;
}
@@ -293,7 +295,7 @@ uint32_t RollbackKernelRead(uint32_t* version)
}
#endif
memcpy(version, &rsk.kernel_versions, sizeof(*version));
- VBDEBUG(("TPM: RollbackKernelRead %x\n", (int)*version));
+ VB2_DEBUG("TPM: RollbackKernelRead %x\n", (int)*version);
return TPM_SUCCESS;
}
@@ -303,8 +305,8 @@ uint32_t RollbackKernelWrite(uint32_t version)
uint32_t old_version;
RETURN_ON_FAILURE(ReadSpaceKernel(&rsk));
memcpy(&old_version, &rsk.kernel_versions, sizeof(old_version));
- VBDEBUG(("TPM: RollbackKernelWrite %x --> %x\n",
- (int)old_version, (int)version));
+ VB2_DEBUG("TPM: RollbackKernelWrite %x --> %x\n",
+ (int)old_version, (int)version);
memcpy(&rsk.kernel_versions, &version, sizeof(version));
return WriteSpaceKernel(&rsk);
}
@@ -345,11 +347,11 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp)
r = TlclRead(FWMP_NV_INDEX, u.buf, sizeof(u.bf));
if (r == TPM_E_BADINDEX) {
/* Missing space is not an error; use defaults */
- VBDEBUG(("TPM: %s() - no FWMP space\n", __func__));
+ VB2_DEBUG("TPM: %s() - no FWMP space\n", __func__);
return TPM_SUCCESS;
} else if (r != TPM_SUCCESS) {
- VBDEBUG(("TPM: %s() - read returned 0x%x\n",
- __func__, r));
+ VB2_DEBUG("TPM: %s() - read returned 0x%x\n",
+ __func__, r);
return r;
}
@@ -373,7 +375,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp)
/* Verify CRC */
if (u.bf.crc != vb2_crc8(u.buf + 2, u.bf.struct_size - 2)) {
- VBDEBUG(("TPM: %s() - bad CRC\n", __func__));
+ VB2_DEBUG("TPM: %s() - bad CRC\n", __func__);
continue;
}
@@ -395,7 +397,7 @@ uint32_t RollbackFwmpRead(struct RollbackSpaceFwmp *fwmp)
return TPM_SUCCESS;
}
- VBDEBUG(("TPM: %s() - too many bad CRCs, giving up\n", __func__));
+ VB2_DEBUG("TPM: %s() - too many bad CRCs, giving up\n", __func__);
return TPM_E_CORRUPTED_STATE;
}
diff --git a/firmware/lib/tpm2_lite/marshaling.c b/firmware/lib/tpm2_lite/marshaling.c
index 97b20fe1..f51e4764 100644
--- a/firmware/lib/tpm2_lite/marshaling.c
+++ b/firmware/lib/tpm2_lite/marshaling.c
@@ -4,6 +4,9 @@
* found in the LICENSE file.
*/
+#include "2sysincludes.h"
+#include "2common.h"
+
#include "tpm2_marshaling.h"
#include "utility.h"
@@ -110,9 +113,9 @@ static void unmarshal_TPM2B_MAX_NV_BUFFER(void **buffer,
{
nv_buffer->t.size = unmarshal_u16(buffer, size);
if (nv_buffer->t.size > *size) {
- VBDEBUG(("%s:%d - "
- "size mismatch: expected %d, remaining %d\n",
- __func__, __LINE__, nv_buffer->t.size, *size));
+ VB2_DEBUG("%s:%d - "
+ "size mismatch: expected %d, remaining %d\n",
+ __func__, __LINE__, nv_buffer->t.size, *size);
return;
}
@@ -130,9 +133,9 @@ static void unmarshal_authorization_section(void **buffer, int *size,
* just confirm that this is the case and report any discrepancy.
*/
if (*size != 5)
- VBDEBUG(("%s:%d - unexpected authorisation section size %d "
- "for %s\n",
- __func__, __LINE__, *size, cmd_name));
+ VB2_DEBUG("%s:%d - unexpected authorisation section size %d "
+ "for %s\n",
+ __func__, __LINE__, *size, cmd_name);
*buffer = ((uint8_t *)(*buffer)) + *size;
*size = 0;
@@ -147,9 +150,9 @@ static void unmarshal_nv_read(void **buffer, int *size,
if (nvr->params_size !=
(nvr->buffer.t.size + sizeof(nvr->buffer.t.size))) {
- VBDEBUG(("%s:%d - parameter/buffer %d/%d size mismatch",
- __func__, __LINE__, nvr->params_size,
- nvr->buffer.t.size));
+ VB2_DEBUG("%s:%d - parameter/buffer %d/%d size mismatch",
+ __func__, __LINE__, nvr->params_size,
+ nvr->buffer.t.size);
return;
}
@@ -165,9 +168,9 @@ static void unmarshal_TPM2B(void **buffer,
{
tpm2b->size = unmarshal_u16(buffer, size);
if (tpm2b->size > *size) {
- VBDEBUG(("%s:%d - "
- "size mismatch: expected %d, remaining %d\n",
- __func__, __LINE__, tpm2b->size, *size));
+ VB2_DEBUG("%s:%d - "
+ "size mismatch: expected %d, remaining %d\n",
+ __func__, __LINE__, tpm2b->size, *size);
*size = -1;
return;
}
@@ -184,9 +187,9 @@ static void unmarshal_TPMS_NV_PUBLIC(void **buffer,
{
int tpm2b_size = unmarshal_u16(buffer, size);
if (tpm2b_size > *size) {
- VBDEBUG(("%s:%d - "
- "size mismatch: expected %d, remaining %d\n",
- __func__, __LINE__, tpm2b_size, *size));
+ VB2_DEBUG("%s:%d - "
+ "size mismatch: expected %d, remaining %d\n",
+ __func__, __LINE__, tpm2b_size, *size);
*size = -1;
return;
}
@@ -199,9 +202,9 @@ static void unmarshal_TPMS_NV_PUBLIC(void **buffer,
pub->dataSize = unmarshal_u16(buffer, &tpm2b_size);
if (tpm2b_size != 0) {
- VBDEBUG(("%s:%d - "
- "TPMS_NV_PUBLIC size doesn't match the size field\n",
- __func__, __LINE__));
+ VB2_DEBUG("%s:%d - "
+ "TPMS_NV_PUBLIC size doesn't match the size field\n",
+ __func__, __LINE__);
*size = -1;
return;
}
@@ -214,9 +217,9 @@ static void unmarshal_nv_read_public(void **buffer, int *size,
unmarshal_TPM2B(buffer, size, &nv_pub->nvName);
if (*size > 0) {
- VBDEBUG(("%s:%d - "
- "extra %d bytes after nvName\n",
- __func__, __LINE__, *size));
+ VB2_DEBUG("%s:%d - "
+ "extra %d bytes after nvName\n",
+ __func__, __LINE__, *size);
*size = -1;
return;
}
@@ -229,9 +232,9 @@ static void unmarshal_TPML_TAGGED_TPM_PROPERTY(void **buffer, int *size,
if (prop->count != 1) {
*size = -1;
- VBDEBUG(("%s:%d:Request to unmarshal unsupported "
- "number of properties: %u\n",
- __FILE__, __LINE__, prop->count));
+ VB2_DEBUG("%s:%d:Request to unmarshal unsupported "
+ "number of properties: %u\n",
+ __FILE__, __LINE__, prop->count);
return;
}
@@ -254,9 +257,9 @@ static void unmarshal_TPMS_CAPABILITY_DATA(void **buffer, int *size,
default:
*size = -1;
- VBDEBUG(("%s:%d:Request to unmarshal unsupported "
- "capability %#x\n",
- __FILE__, __LINE__, cap_data->capability));
+ VB2_DEBUG("%s:%d:Request to unmarshal unsupported "
+ "capability %#x\n",
+ __FILE__, __LINE__, cap_data->capability);
}
}
@@ -351,8 +354,8 @@ static void marshal_reserve_size_field(void **buffer,
int *buffer_space)
{
if (field_size != sizeof(uint32_t) && field_size != sizeof(uint16_t)) {
- VBDEBUG(("%s:%d:Unsupported size field size: %d\n",
- __FILE__, __LINE__, field_size));
+ VB2_DEBUG("%s:%d:Unsupported size field size: %d\n",
+ __FILE__, __LINE__, field_size);
*buffer_space = -1;
return;
}
@@ -706,8 +709,8 @@ int tpm_marshal_command(TPM_CC command, void *tpm_command_body,
default:
body_size = -1;
- VBDEBUG(("%s:%d:Request to marshal unsupported command %#x\n",
- __FILE__, __LINE__, command));
+ VB2_DEBUG("%s:%d:Request to marshal unsupported command %#x\n",
+ __FILE__, __LINE__, command);
}
if (body_size > 0) {
@@ -740,8 +743,9 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
if (!cr_size) {
if (tpm2_resp.hdr.tpm_size != sizeof(tpm2_resp.hdr))
- VBDEBUG(("%s: size mismatch in response to command %#x\n",
- __func__, command));
+ VB2_DEBUG("%s: "
+ "size mismatch in response to command %#x\n",
+ __func__, command);
return &tpm2_resp;
}
@@ -778,28 +782,28 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
{
int i;
- VBDEBUG(("%s:%d:"
- "Request to unmarshal unexpected command %#x,"
- " code %#x",
- __func__, __LINE__, command,
- tpm2_resp.hdr.tpm_code));
+ VB2_DEBUG("%s:%d:"
+ "Request to unmarshal unexpected command %#x,"
+ " code %#x",
+ __func__, __LINE__, command,
+ tpm2_resp.hdr.tpm_code);
for (i = 0; i < cr_size; i++) {
if (!(i % 16))
- VBDEBUG(("\n"));
- VBDEBUG(("%2.2x ",
- ((uint8_t *)response_body)[i]));
+ VB2_DEBUG("\n");
+ VB2_DEBUG("%2.2x ",
+ ((uint8_t *)response_body)[i]);
}
}
- VBDEBUG(("\n"));
+ VB2_DEBUG("\n");
return NULL;
}
if (cr_size) {
- VBDEBUG(("%s:%d got %d bytes back in response to %#x,"
- " failed to parse (%d)\n",
- __func__, __LINE__, tpm2_resp.hdr.tpm_size,
- command, cr_size));
+ VB2_DEBUG("%s:%d got %d bytes back in response to %#x,"
+ " failed to parse (%d)\n",
+ __func__, __LINE__, tpm2_resp.hdr.tpm_size,
+ command, cr_size);
return NULL;
}
diff --git a/firmware/lib/tpm2_lite/tlcl.c b/firmware/lib/tpm2_lite/tlcl.c
index bb726f10..7a9f68e0 100644
--- a/firmware/lib/tpm2_lite/tlcl.c
+++ b/firmware/lib/tpm2_lite/tlcl.c
@@ -7,6 +7,9 @@
* in the firmware
*/
+#include "2sysincludes.h"
+#include "2common.h"
+
#include "rollback_index.h"
#include "tpm2_marshaling.h"
#include "utility.h"
@@ -23,22 +26,21 @@ static struct tpm2_response *tpm_process_command(TPM_CC command,
out_size = tpm_marshal_command(command, command_body,
cr_buffer, sizeof(cr_buffer));
if (out_size < 0) {
- VBDEBUG(("command %#x, cr size %d\n",
- command, out_size));
+ VB2_DEBUG("command %#x, cr size %d\n", command, out_size);
return NULL;
}
in_size = sizeof(cr_buffer);
if (VbExTpmSendReceive(cr_buffer, out_size,
cr_buffer, &in_size) != TPM_SUCCESS) {
- VBDEBUG(("tpm transaction failed for %#x\n", command));
+ VB2_DEBUG("tpm transaction failed for %#x\n", command);
return NULL;
}
response = tpm_unmarshal_response(command, cr_buffer, in_size);
- VBDEBUG(("%s: command %#x, return code %#x\n", __func__, command,
- response ? response->hdr.tpm_code : -1));
+ VB2_DEBUG("%s: command %#x, return code %#x\n", __func__, command,
+ response ? response->hdr.tpm_code : -1);
return response;
}
@@ -208,13 +210,13 @@ uint32_t TlclForceClear(void)
uint32_t TlclSetDeactivated(uint8_t flag)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
+ VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
return TPM_SUCCESS;
}
uint32_t TlclSetEnable(void)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
+ VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
return TPM_SUCCESS;
}
@@ -234,13 +236,13 @@ uint32_t TlclGetFlags(uint8_t* disable,
int TlclIsOwned(void)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
+ VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
return 0;
}
uint32_t TlclExtend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
+ VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
return TPM_SUCCESS;
}
@@ -474,7 +476,7 @@ uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length)
uint32_t TlclPCRRead(uint32_t index, void *data, uint32_t length)
{
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
+ VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
return TPM_SUCCESS;
}
@@ -517,6 +519,6 @@ uint32_t TlclReadLock(uint32_t index)
uint32_t TlclGetRandom(uint8_t *data, uint32_t length, uint32_t *size)
{
*size = 0;
- VBDEBUG(("%s called, NOT YET IMPLEMENTED\n", __func__));
+ VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__);
return TPM_E_IOERROR;
}
diff --git a/firmware/lib/tpm_lite/tlcl.c b/firmware/lib/tpm_lite/tlcl.c
index 70fce2b9..5a99fdc7 100644
--- a/firmware/lib/tpm_lite/tlcl.c
+++ b/firmware/lib/tpm_lite/tlcl.c
@@ -14,8 +14,10 @@
* time.
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "sysincludes.h"
#include "tlcl.h"
#include "tlcl_internal.h"
#include "tlcl_structures.h"
@@ -73,18 +75,18 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request,
uint32_t result;
#ifdef EXTRA_LOGGING
- VBDEBUG(("TPM: command: %x%x %x%x%x%x %x%x%x%x\n",
- request[0], request[1],
- request[2], request[3], request[4], request[5],
- request[6], request[7], request[8], request[9]));
+ VB2_DEBUG("TPM: command: %x%x %x%x%x%x %x%x%x%x\n",
+ request[0], request[1],
+ request[2], request[3], request[4], request[5],
+ request[6], request[7], request[8], request[9]);
#endif
result = VbExTpmSendReceive(request, TpmCommandSize(request),
response, &response_length);
if (0 != result) {
/* Communication with TPM failed, so response is garbage */
- VBDEBUG(("TPM: command 0x%x send/receive failed: 0x%x\n",
- TpmCommandCode(request), result));
+ VB2_DEBUG("TPM: command 0x%x send/receive failed: 0x%x\n",
+ TpmCommandCode(request), result);
return result;
}
/* Otherwise, use the result code from the response */
@@ -95,14 +97,14 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request,
* crosbug.com/17017 */
#ifdef EXTRA_LOGGING
- VBDEBUG(("TPM: response: %x%x %x%x%x%x %x%x%x%x\n",
- response[0], response[1],
- response[2], response[3], response[4], response[5],
- response[6], response[7], response[8], response[9]));
+ VB2_DEBUG("TPM: response: %x%x %x%x%x%x %x%x%x%x\n",
+ response[0], response[1],
+ response[2], response[3], response[4], response[5],
+ response[6], response[7], response[8], response[9]);
#endif
- VBDEBUG(("TPM: command 0x%x returned 0x%x\n",
- TpmCommandCode(request), result));
+ VB2_DEBUG("TPM: command 0x%x returned 0x%x\n",
+ TpmCommandCode(request), result);
return result;
}
@@ -165,32 +167,32 @@ uint32_t TlclLibClose(void)
uint32_t TlclStartup(void)
{
- VBDEBUG(("TPM: Startup\n"));
+ VB2_DEBUG("TPM: Startup\n");
return Send(tpm_startup_cmd.buffer);
}
uint32_t TlclSaveState(void)
{
- VBDEBUG(("TPM: SaveState\n"));
+ VB2_DEBUG("TPM: SaveState\n");
return Send(tpm_savestate_cmd.buffer);
}
uint32_t TlclResume(void)
{
- VBDEBUG(("TPM: Resume\n"));
+ VB2_DEBUG("TPM: Resume\n");
return Send(tpm_resume_cmd.buffer);
}
uint32_t TlclSelfTestFull(void)
{
- VBDEBUG(("TPM: Self test full\n"));
+ VB2_DEBUG("TPM: Self test full\n");
return Send(tpm_selftestfull_cmd.buffer);
}
uint32_t TlclContinueSelfTest(void)
{
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
- VBDEBUG(("TPM: Continue self test\n"));
+ VB2_DEBUG("TPM: Continue self test\n");
/* Call the No Retry version of SendReceive to avoid recursion. */
return TlclSendReceiveNoRetry(tpm_continueselftest_cmd.buffer,
response, sizeof(response));
@@ -199,7 +201,7 @@ uint32_t TlclContinueSelfTest(void)
uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size)
{
struct s_tpm_nv_definespace_cmd cmd;
- VBDEBUG(("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size));
+ VB2_DEBUG("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size);
memcpy(&cmd, &tpm_nv_definespace_cmd, sizeof(cmd));
ToTpmUint32(cmd.buffer + tpm_nv_definespace_cmd.index, index);
ToTpmUint32(cmd.buffer + tpm_nv_definespace_cmd.perm, perm);
@@ -214,7 +216,7 @@ uint32_t TlclWrite(uint32_t index, const void* data, uint32_t length)
const int total_length =
kTpmRequestHeaderLength + kWriteInfoLength + length;
- VBDEBUG(("TPM: TlclWrite(0x%x, %d)\n", index, length));
+ VB2_DEBUG("TPM: TlclWrite(0x%x, %d)\n", index, length);
memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd));
VbAssert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE);
SetTpmCommandSize(cmd.buffer, total_length);
@@ -233,7 +235,7 @@ uint32_t TlclRead(uint32_t index, void* data, uint32_t length)
uint32_t result_length;
uint32_t result;
- VBDEBUG(("TPM: TlclRead(0x%x, %d)\n", index, length));
+ VB2_DEBUG("TPM: TlclRead(0x%x, %d)\n", index, length);
memcpy(&cmd, &tpm_nv_read_cmd, sizeof(cmd));
ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.index, index);
ToTpmUint32(cmd.buffer + tpm_nv_read_cmd.length, length);
@@ -257,7 +259,7 @@ uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length)
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
uint32_t result;
- VBDEBUG(("TPM: TlclPCRRead(0x%x, %d)\n", index, length));
+ VB2_DEBUG("TPM: TlclPCRRead(0x%x, %d)\n", index, length);
if (length < kPcrDigestLength) {
return TPM_E_IOERROR;
}
@@ -275,31 +277,31 @@ uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length)
uint32_t TlclWriteLock(uint32_t index)
{
- VBDEBUG(("TPM: Write lock 0x%x\n", index));
+ VB2_DEBUG("TPM: Write lock 0x%x\n", index);
return TlclWrite(index, NULL, 0);
}
uint32_t TlclReadLock(uint32_t index)
{
- VBDEBUG(("TPM: Read lock 0x%x\n", index));
+ VB2_DEBUG("TPM: Read lock 0x%x\n", index);
return TlclRead(index, NULL, 0);
}
uint32_t TlclAssertPhysicalPresence(void)
{
- VBDEBUG(("TPM: Asserting physical presence\n"));
+ VB2_DEBUG("TPM: Asserting physical presence\n");
return Send(tpm_ppassert_cmd.buffer);
}
uint32_t TlclPhysicalPresenceCMDEnable(void)
{
- VBDEBUG(("TPM: Enable the physical presence command\n"));
+ VB2_DEBUG("TPM: Enable the physical presence command\n");
return Send(tpm_ppenable_cmd.buffer);
}
uint32_t TlclFinalizePhysicalPresence(void)
{
- VBDEBUG(("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n"));
+ VB2_DEBUG("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n");
return Send(tpm_finalizepp_cmd.buffer);
}
@@ -312,13 +314,13 @@ uint32_t TlclAssertPhysicalPresenceResult(void)
uint32_t TlclLockPhysicalPresence(void)
{
- VBDEBUG(("TPM: Lock physical presence\n"));
+ VB2_DEBUG("TPM: Lock physical presence\n");
return Send(tpm_pplock_cmd.buffer);
}
uint32_t TlclSetNvLocked(void)
{
- VBDEBUG(("TPM: Set NV locked\n"));
+ VB2_DEBUG("TPM: Set NV locked\n");
return TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0);
}
@@ -333,26 +335,26 @@ int TlclIsOwned(void)
uint32_t TlclForceClear(void)
{
- VBDEBUG(("TPM: Force clear\n"));
+ VB2_DEBUG("TPM: Force clear\n");
return Send(tpm_forceclear_cmd.buffer);
}
uint32_t TlclSetEnable(void)
{
- VBDEBUG(("TPM: Enabling TPM\n"));
+ VB2_DEBUG("TPM: Enabling TPM\n");
return Send(tpm_physicalenable_cmd.buffer);
}
uint32_t TlclClearEnable(void)
{
- VBDEBUG(("TPM: Disabling TPM\n"));
+ VB2_DEBUG("TPM: Disabling TPM\n");
return Send(tpm_physicaldisable_cmd.buffer);
}
uint32_t TlclSetDeactivated(uint8_t flag)
{
struct s_tpm_physicalsetdeactivated_cmd cmd;
- VBDEBUG(("TPM: SetDeactivated(%d)\n", flag));
+ VB2_DEBUG("TPM: SetDeactivated(%d)\n", flag);
memcpy(&cmd, &tpm_physicalsetdeactivated_cmd, sizeof(cmd));
*(cmd.buffer + cmd.deactivated) = flag;
return Send(cmd.buffer);
@@ -408,9 +410,9 @@ uint32_t TlclGetFlags(uint8_t* disable,
*deactivated = pflags.deactivated;
if (nvlocked)
*nvlocked = pflags.nvLocked;
- VBDEBUG(("TPM: Got flags disable=%d, deactivated=%d, "
- "nvlocked=%d\n",
- pflags.disable, pflags.deactivated, pflags.nvLocked));
+ VB2_DEBUG("TPM: Got flags disable=%d, deactivated=%d, "
+ "nvlocked=%d\n",
+ pflags.disable, pflags.deactivated, pflags.nvLocked);
}
return result;
}
@@ -418,7 +420,7 @@ uint32_t TlclGetFlags(uint8_t* disable,
uint32_t TlclSetGlobalLock(void)
{
uint32_t x;
- VBDEBUG(("TPM: Set global lock\n"));
+ VB2_DEBUG("TPM: Set global lock\n");
return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0);
}
@@ -485,7 +487,7 @@ uint32_t TlclGetRandom(uint8_t* data, uint32_t length, uint32_t *size)
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
uint32_t result;
- VBDEBUG(("TPM: TlclGetRandom(%d)\n", length));
+ VB2_DEBUG("TPM: TlclGetRandom(%d)\n", length);
memcpy(&cmd, &tpm_get_random_cmd, sizeof(cmd));
ToTpmUint32(cmd.buffer + tpm_get_random_cmd.bytesRequested, length);
/* There must be room in the response buffer for the bytes. */
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 1e49c46c..f2f39661 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -53,7 +53,7 @@ struct LoadKernelParams *VbApiKernelGetParams(void)
static void VbSetRecoveryRequest(struct vb2_context *ctx,
uint32_t recovery_request)
{
- VBDEBUG(("VbSetRecoveryRequest(%d)\n", (int)recovery_request));
+ VB2_DEBUG("VbSetRecoveryRequest(%d)\n", (int)recovery_request);
vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST, recovery_request);
}
@@ -108,8 +108,8 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
uint32_t disk_count = 0;
uint32_t i;
- VBDEBUG(("VbTryLoadKernel() start, get_info_flags=0x%x\n",
- (unsigned)get_info_flags));
+ VB2_DEBUG("VbTryLoadKernel() start, get_info_flags=0x%x\n",
+ (unsigned)get_info_flags);
lkp.fwmp = &fwmp;
lkp.nv_context = &vnc;
@@ -120,7 +120,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
get_info_flags))
disk_count = 0;
- VBDEBUG(("VbTryLoadKernel() found %d disks\n", (int)disk_count));
+ VB2_DEBUG("VbTryLoadKernel() found %d disks\n", (int)disk_count);
if (0 == disk_count) {
VbSetRecoveryRequest(ctx, VBNV_RECOVERY_RW_NO_DISK);
return VBERROR_NO_DISK_FOUND;
@@ -128,7 +128,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
/* Loop over disks */
for (i = 0; i < disk_count; i++) {
- VBDEBUG(("VbTryLoadKernel() trying disk %d\n", (int)i));
+ VB2_DEBUG("VbTryLoadKernel() trying disk %d\n", (int)i);
/*
* Sanity-check what we can. FWIW, VbTryLoadKernel() is always
* called with only a single bit set in get_info_flags.
@@ -141,11 +141,11 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
16 > disk_info[i].lba_count ||
get_info_flags != (disk_info[i].flags &
~VB_DISK_FLAG_EXTERNAL_GPT)) {
- VBDEBUG((" skipping: bytes_per_lba=%" PRIu64
- " lba_count=%" PRIu64 " flags=0x%x\n",
- disk_info[i].bytes_per_lba,
- disk_info[i].lba_count,
- disk_info[i].flags));
+ VB2_DEBUG(" skipping: bytes_per_lba=%" PRIu64
+ " lba_count=%" PRIu64 " flags=0x%x\n",
+ disk_info[i].bytes_per_lba,
+ disk_info[i].lba_count,
+ disk_info[i].flags);
continue;
}
lkp.disk_handle = disk_info[i].handle;
@@ -156,7 +156,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
lkp.boot_flags |= disk_info[i].flags & VB_DISK_FLAG_EXTERNAL_GPT
? BOOT_FLAG_EXTERNAL_GPT : 0;
retval = LoadKernel(ctx, &lkp, cparams);
- VBDEBUG(("VbTryLoadKernel() LoadKernel() = %d\n", retval));
+ VB2_DEBUG("VbTryLoadKernel() LoadKernel() = %d\n", retval);
/*
* Stop now if we found a kernel.
@@ -488,7 +488,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
cparams->gbb = malloc(sizeof(*cparams->gbb));
retval = VbGbbReadHeader_static(cparams, cparams->gbb);
if (VBERROR_SUCCESS != retval) {
- VBDEBUG(("Gbb read header failed.\n"));
+ VB2_DEBUG("Gbb read header failed.\n");
return retval;
}
@@ -512,13 +512,13 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
}
if (dev_switch && allow_fastboot_full_cap) {
- VBDEBUG(("Only performing integrity-check.\n"));
+ VB2_DEBUG("Only performing integrity-check.\n");
hash_only = 1;
} else {
/* Get recovery key. */
retval = VbGbbReadRecoveryKey(cparams, &kernel_subkey);
if (VBERROR_SUCCESS != retval) {
- VBDEBUG(("Gbb Read Recovery key failed.\n"));
+ VB2_DEBUG("Gbb Read Recovery key failed.\n");
return retval;
}
}
@@ -544,7 +544,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
if (VB2_SUCCESS !=
vb2_unpack_key(&kernel_subkey2,
(struct vb2_packed_key *)kernel_subkey)) {
- VBDEBUG(("Unable to unpack kernel subkey\n"));
+ VB2_DEBUG("Unable to unpack kernel subkey\n");
goto fail;
}
rv = vb2_verify_keyblock(keyblock2, image_size,
@@ -552,7 +552,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
}
if (VB2_SUCCESS != rv) {
- VBDEBUG(("Verifying key block signature/hash failed.\n"));
+ VB2_DEBUG("Verifying key block signature/hash failed.\n");
goto fail;
}
@@ -560,13 +560,13 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
if (!(key_block->key_block_flags &
(dev_switch ? KEY_BLOCK_FLAG_DEVELOPER_1 :
KEY_BLOCK_FLAG_DEVELOPER_0))) {
- VBDEBUG(("Key block developer flag mismatch.\n"));
+ VB2_DEBUG("Key block developer flag mismatch.\n");
if (hash_only == 0)
goto fail;
}
if (!(key_block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_1)) {
- VBDEBUG(("Key block recovery flag mismatch.\n"));
+ VB2_DEBUG("Key block recovery flag mismatch.\n");
if (hash_only == 0)
goto fail;
}
@@ -574,7 +574,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
/* Get key for preamble/data verification from the key block. */
struct vb2_public_key data_key2;
if (VB2_SUCCESS != vb2_unpack_key(&data_key2, &keyblock2->data_key)) {
- VBDEBUG(("Unable to unpack kernel data key\n"));
+ VB2_DEBUG("Unable to unpack kernel data key\n");
goto fail;
}
@@ -589,11 +589,11 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
image_size - key_block->key_block_size,
&data_key2,
&wb)) {
- VBDEBUG(("Preamble verification failed.\n"));
+ VB2_DEBUG("Preamble verification failed.\n");
goto fail;
}
- VBDEBUG(("Kernel preamble is good.\n"));
+ VB2_DEBUG("Kernel preamble is good.\n");
/* Verify kernel data */
body_offset = key_block->key_block_size + preamble->preamble_size;
@@ -602,11 +602,11 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
image_size - body_offset,
(struct vb2_signature *)&preamble->body_signature,
&data_key2, &wb)) {
- VBDEBUG(("Kernel data verification failed.\n"));
+ VB2_DEBUG("Kernel data verification failed.\n");
goto fail;
}
- VBDEBUG(("Kernel is good.\n"));
+ VB2_DEBUG("Kernel is good.\n");
/* Fill in output parameters. */
kparams->kernel_buffer = kbuf + body_offset;
@@ -629,12 +629,12 @@ fail:
VbError_t VbUnlockDevice(void)
{
- VBDEBUG(("%s() Enabling dev-mode...\n", __func__));
+ VB2_DEBUG("%s() Enabling dev-mode...\n", __func__);
if (TPM_SUCCESS != SetVirtualDevMode(1))
return VBERROR_TPM_SET_BOOT_MODE_STATE;
- VBDEBUG(("%s() Mode change will take effect on next reboot.\n",
- __func__));
+ VB2_DEBUG("%s() Mode change will take effect on next reboot.\n",
+ __func__);
return VBERROR_SUCCESS;
}
@@ -642,14 +642,14 @@ VbError_t VbLockDevice(void)
{
VbNvLoad();
- VBDEBUG(("%s() - Storing request to leave dev-mode.\n",
- __func__));
+ VB2_DEBUG("%s() - Storing request to leave dev-mode.\n",
+ __func__);
VbNvSet(&vnc, VBNV_DISABLE_DEV_REQUEST, 1);
VbNvCommit();
- VBDEBUG(("%s() Mode change will take effect on next reboot.\n",
- __func__));
+ VB2_DEBUG("%s() Mode change will take effect on next reboot.\n",
+ __func__);
return VBERROR_SUCCESS;
}
diff --git a/firmware/lib/vboot_audio.c b/firmware/lib/vboot_audio.c
index 8f311710..b1b2b8c6 100644
--- a/firmware/lib/vboot_audio.c
+++ b/firmware/lib/vboot_audio.c
@@ -5,8 +5,10 @@
* Delay/beep functions used in dev-mode kernel selection.
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "sysincludes.h"
#include "crc32.h"
#include "gbb_header.h"
#include "utility.h"
@@ -69,8 +71,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
uint32_t this_msecs, on_msecs, total_msecs;
uint32_t count;
- VBDEBUG(("VbGetDevMusicNotes: use_short is %d, hdr is %p, "
- "maxsize is %d\n", use_short, hdr, maxsize));
+ VB2_DEBUG("VbGetDevMusicNotes: use_short is %d, hdr is %p, "
+ "maxsize is %d\n", use_short, hdr, maxsize);
if (use_short) {
builtin = short_notes_;
@@ -89,7 +91,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
goto nope;
if (0 != memcmp(hdr->sig, "$SND", sizeof(hdr->sig))) {
- VBDEBUG(("VbGetDevMusicNotes: bad sig\n"));
+ VB2_DEBUG("VbGetDevMusicNotes: bad sig\n");
goto nope;
}
@@ -99,8 +101,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
*/
maxnotes = 1 + (maxsize - sizeof(VbDevMusic)) / sizeof(VbDevMusicNote);
if (hdr->count == 0 || hdr->count > maxnotes) {
- VBDEBUG(("VbGetDevMusicNotes: count=%d maxnotes=%d\n",
- hdr->count, maxnotes));
+ VB2_DEBUG("VbGetDevMusicNotes: count=%d maxnotes=%d\n",
+ hdr->count, maxnotes);
goto nope;
}
@@ -112,8 +114,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
if ((sizeof(VbDevMusicNote) > UINT_MAX / hdr->count) ||
(sizeof(hdr->count) >
UINT_MAX - hdr->count * sizeof(VbDevMusicNote))) {
- VBDEBUG(("VbGetDevMusicNotes: count=%d, just isn't right\n",
- hdr->count));
+ VB2_DEBUG("VbGetDevMusicNotes: count=%d, just isn't right\n",
+ hdr->count);
goto nope;
}
@@ -123,12 +125,12 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
mysum = Crc32(&(hdr->count), mylen);
if (mysum != hdr->checksum) {
- VBDEBUG(("VbGetDevMusicNotes: mysum=%08x, want=%08x\n",
- mysum, hdr->checksum));
+ VB2_DEBUG("VbGetDevMusicNotes: mysum=%08x, want=%08x\n",
+ mysum, hdr->checksum);
goto nope;
}
- VBDEBUG(("VbGetDevMusicNotes: custom notes struct at %p\n", hdr));
+ VB2_DEBUG("VbGetDevMusicNotes: custom notes struct at %p\n", hdr);
/*
* Measure the audible sound up to the first 22 seconds, being careful
@@ -149,8 +151,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
}
/* We require at least one second of noise in the first 22 seconds */
- VBDEBUG(("VbGetDevMusicNotes: with %d msecs of sound to begin\n",
- on_msecs));
+ VB2_DEBUG("VbGetDevMusicNotes: with %d msecs of sound to begin\n",
+ on_msecs);
if (on_msecs < REQUIRED_NOISE_TIME)
goto nope;
@@ -158,14 +160,14 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
* We'll also require that the total time be less than 5 minutes. No
* real reason, it just gives us less to worry about.
*/
- VBDEBUG(("VbGetDevMusicNotes: lasting %d msecs\n", total_msecs));
+ VB2_DEBUG("VbGetDevMusicNotes: lasting %d msecs\n", total_msecs);
if (total_msecs > MAX_CUSTOM_DELAY) {
goto nope;
}
/* One more check, just to be paranoid. */
if (hdr->count > (UINT_MAX / sizeof(VbDevMusicNote) - 1)) {
- VBDEBUG(("VbGetDevMusicNotes: they're all out to get me!\n"));
+ VB2_DEBUG("VbGetDevMusicNotes: they're all out to get me!\n");
goto nope;
}
@@ -184,8 +186,8 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
notebuf[hdr->count].msec = this_msecs;
notebuf[hdr->count].frequency = 0;
count++;
- VBDEBUG(("VbGetDevMusicNotes: adding %d msecs of silence\n",
- this_msecs));
+ VB2_DEBUG("VbGetDevMusicNotes: adding %d msecs of silence\n",
+ this_msecs);
}
/* Done */
@@ -196,7 +198,7 @@ static void VbGetDevMusicNotes(VbAudioContext *audio, int use_short)
nope:
/* No custom notes, use the default. The count is already set. */
- VBDEBUG(("VbGetDevMusicNotes: using %d default notes\n", count));
+ VB2_DEBUG("VbGetDevMusicNotes: using %d default notes\n", count);
audio->music_notes = builtin;
audio->note_count = count;
audio->free_notes_when_done = 0;
@@ -220,8 +222,8 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
VbExSleepMs(10);
b = VbExGetTimer();
ticks_per_msec = (b - a) / 10ULL ;
- VBDEBUG(("VbAudioOpen() - ticks_per_msec is %" PRIu64 "\n",
- ticks_per_msec));
+ VB2_DEBUG("VbAudioOpen() - ticks_per_msec is %" PRIu64 "\n",
+ ticks_per_msec);
/* Initialize */
memset(audio, 0, sizeof(*audio));
@@ -230,7 +232,7 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
/* See if we have full background sound capability or not. */
if (VBERROR_SUCCESS != VbExBeep(0,0)) {
- VBDEBUG(("VbAudioOpen() - VbExBeep() is limited\n"));
+ VB2_DEBUG("VbAudioOpen() - VbExBeep() is limited\n");
audio->background_beep = 0;
}
@@ -240,12 +242,12 @@ VbAudioContext *VbAudioOpen(VbCommonParams *cparams)
*/
if (gbb->major_version == GBB_MAJOR_VER && gbb->minor_version >= 1
&& (gbb->flags & GBB_FLAG_DEV_SCREEN_SHORT_DELAY)) {
- VBDEBUG(("VbAudioOpen() - using short dev screen delay\n"));
+ VB2_DEBUG("VbAudioOpen() - using short dev screen delay\n");
use_short = 1;
}
VbGetDevMusicNotes(audio, use_short);
- VBDEBUG(("VbAudioOpen() - note count %d\n", audio->note_count));
+ VB2_DEBUG("VbAudioOpen() - note count %d\n", audio->note_count);
return audio;
}
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index 452677ef..fd6ef79b 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -168,12 +168,12 @@ int VerifyVmlinuzInsideKBlob(uint64_t kblob, uint64_t kblob_size,
uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size)
{
if (!header || size > header->data_size - header->data_used) {
- VBDEBUG(("VbSharedData buffer out of space.\n"));
+ VB2_DEBUG("VbSharedData buffer out of space.\n");
return 0; /* Not initialized, or not enough space left. */
}
uint64_t offs = header->data_used;
- VBDEBUG(("VbSharedDataReserve %d bytes at %d\n", (int)size, (int)offs));
+ VB2_DEBUG("VbSharedDataReserve %d bytes at %d\n", (int)size, (int)offs);
header->data_used += size;
return offs;
@@ -190,9 +190,9 @@ int VbSharedDataSetKernelKey(VbSharedDataHeader *header, const VbPublicKey *src)
kdest = &header->kernel_subkey;
- VBDEBUG(("Saving kernel subkey to shared data: size %d, algo %d\n",
- vb2_rsa_sig_size(vb2_crypto_to_signature(src->algorithm)),
- (int)src->algorithm));
+ VB2_DEBUG("Saving kernel subkey to shared data: size %d, algo %d\n",
+ vb2_rsa_sig_size(vb2_crypto_to_signature(src->algorithm)),
+ (int)src->algorithm);
/* Attempt to allocate space for key, if it hasn't been allocated yet */
if (!header->kernel_subkey_data_offset) {
diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c
index 90edae68..b85c3cc3 100644
--- a/firmware/lib/vboot_common_init.c
+++ b/firmware/lib/vboot_common_init.c
@@ -6,23 +6,25 @@
* (Firmware portion)
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "sysincludes.h"
#include "vboot_api.h"
#include "vboot_common.h"
#include "utility.h"
int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
{
- VBDEBUG(("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
- (int)sizeof(VbSharedDataHeader)));
+ VB2_DEBUG("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
+ (int)sizeof(VbSharedDataHeader));
if (size < sizeof(VbSharedDataHeader)) {
- VBDEBUG(("Not enough data for header.\n"));
+ VB2_DEBUG("Not enough data for header.\n");
return VBOOT_SHARED_DATA_INVALID;
}
if (size < VB_SHARED_DATA_MIN_SIZE) {
- VBDEBUG(("Shared data buffer too small.\n"));
+ VB2_DEBUG("Shared data buffer too small.\n");
return VBOOT_SHARED_DATA_INVALID;
}
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index 39bd2fa7..18aaf783 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -116,7 +116,7 @@ void VbRenderTextAtPos(const char *text, int right_to_left,
uint32_t cur_x = x, cur_y = y;
if (!text || !font) {
- VBDEBUG((" VbRenderTextAtPos: invalid args\n"));
+ VB2_DEBUG(" VbRenderTextAtPos: invalid args\n");
return;
}
@@ -140,8 +140,8 @@ void VbRenderTextAtPos(const char *text, int right_to_left,
if (VBERROR_SUCCESS != VbExDisplayImage(cur_x, cur_y, buffer,
buffersize)) {
- VBDEBUG((" VbRenderTextAtPos: "
- "can't display ascii 0x%x\n", text[i]));
+ VB2_DEBUG(" VbRenderTextAtPos: "
+ "can't display ascii 0x%x\n", text[i]);
}
if (!right_to_left)
@@ -207,16 +207,16 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
case VB_SCREEN_DEVELOPER_EGG:
default:
/* Screens which aren't in the GBB */
- VBDEBUG(("VbDisplayScreenFromGBB(): screen %d not in the GBB\n",
- (int)screen));
+ VB2_DEBUG("VbDisplayScreenFromGBB(): screen %d not in GBB\n",
+ (int)screen);
retval = VBERROR_INVALID_SCREEN_INDEX;
goto VbDisplayScreenFromGBB_exit;
}
if (screen_index >= hdr.number_of_screenlayouts) {
- VBDEBUG(("VbDisplayScreenFromGBB(): "
- "screen %d index %d not in the GBB\n",
- (int)screen, (int)screen_index));
+ VB2_DEBUG("VbDisplayScreenFromGBB(): "
+ "screen %d index %d not in the GBB\n",
+ (int)screen, (int)screen_index);
retval = VBERROR_INVALID_SCREEN_INDEX;
goto VbDisplayScreenFromGBB_exit;
}
@@ -255,10 +255,10 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
image_info.width,
image_info.height);
if (ret) {
- VBDEBUG(("VbExDisplaySetDimension"
- "(%d,%d): failed (%#x).\n",
- image_info.width,
- image_info.height, ret));
+ VB2_DEBUG("VbExDisplaySetDimension"
+ "(%d,%d): failed (%#x).\n",
+ image_info.width,
+ image_info.height, ret);
}
}
@@ -294,9 +294,9 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
break;
default:
- VBDEBUG(("VbDisplayScreenFromGBB(): "
- "unsupported ImageFormat %d\n",
- image_info.format));
+ VB2_DEBUG("VbDisplayScreenFromGBB(): "
+ "unsupported ImageFormat %d\n",
+ image_info.format);
retval = VBERROR_INVALID_GBB;
}
@@ -312,7 +312,7 @@ VbError_t VbDisplayScreenFromGBB(struct vb2_context *ctx,
VbRegionCheckVersion(cparams);
VbDisplayScreenFromGBB_exit:
- VBDEBUG(("leaving VbDisplayScreenFromGBB() with %d\n",retval));
+ VB2_DEBUG("leaving VbDisplayScreenFromGBB() with %d\n",retval);
return retval;
}
@@ -716,8 +716,8 @@ VbError_t VbCheckDisplayKey(struct vb2_context *ctx, VbCommonParams *cparams,
loc = (loc < count - 1 ? loc + 1 : 0);
else
loc = (loc > 0 ? loc - 1 : count - 1);
- VBDEBUG(("VbCheckDisplayKey() - change localization to %d\n",
- (int)loc));
+ VB2_DEBUG("VbCheckDisplayKey() - change localization to %d\n",
+ (int)loc);
vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, loc);
vb2_nv_set(ctx, VB2_NV_BACKUP_NVRAM_REQUEST, 1);
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 8f9ada49..3dbb5680 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -29,7 +29,7 @@
static void VbAllowUsbBoot(struct vb2_context *ctx)
{
- VBDEBUG(("%s\n", __func__));
+ VB2_DEBUG("%s\n", __func__);
vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
}
@@ -53,9 +53,9 @@ static int VbWantShutdown(uint32_t gbb_flags)
static void VbTryLegacy(int allowed)
{
if (!allowed)
- VBDEBUG(("VbBootDeveloper() - Legacy boot is disabled\n"));
+ VB2_DEBUG("VbBootDeveloper() - Legacy boot is disabled\n");
else if (0 != RollbackKernelLock(0))
- VBDEBUG(("Error locking kernel versions on legacy boot.\n"));
+ VB2_DEBUG("Error locking kernel versions on legacy boot.\n");
else
VbExLegacy(); /* will not return if successful */
@@ -69,9 +69,9 @@ uint32_t VbTryUsb(struct vb2_context *ctx, VbCommonParams *cparams)
{
uint32_t retval = VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_REMOVABLE);
if (VBERROR_SUCCESS == retval) {
- VBDEBUG(("VbBootDeveloper() - booting USB\n"));
+ VB2_DEBUG("VbBootDeveloper() - booting USB\n");
} else {
- VBDEBUG(("VbBootDeveloper() - no kernel found on USB\n"));
+ VB2_DEBUG("VbBootDeveloper() - no kernel found on USB\n");
VbExBeep(250, 200);
VbExSleepMs(120);
/*
@@ -98,7 +98,7 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
uint32_t button;
int rec_button_was_pressed = 0;
- VBDEBUG(("Entering %s(0x%x)\n", __func__, confirm_flags));
+ VB2_DEBUG("Entering %s(0x%x)\n", __func__, confirm_flags);
/* Await further instructions */
while (1) {
@@ -118,17 +118,17 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
break;
}
- VBDEBUG(("%s() - Yes (1)\n", __func__));
+ VB2_DEBUG("%s() - Yes (1)\n", __func__);
return 1;
break;
case ' ':
- VBDEBUG(("%s() - Space (%d)\n", __func__,
- confirm_flags & VB_CONFIRM_SPACE_MEANS_NO));
+ VB2_DEBUG("%s() - Space (%d)\n", __func__,
+ confirm_flags & VB_CONFIRM_SPACE_MEANS_NO);
if (confirm_flags & VB_CONFIRM_SPACE_MEANS_NO)
return 0;
break;
case 0x1b:
- VBDEBUG(("%s() - No (0)\n", __func__));
+ VB2_DEBUG("%s() - No (0)\n", __func__);
return 0;
break;
default:
@@ -137,12 +137,12 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
*/
if (!(shared->flags & VBSD_BOOT_REC_SWITCH_VIRTUAL)) {
if (button) {
- VBDEBUG(("%s() - Rec button pressed\n",
- __func__));
+ VB2_DEBUG("%s() - Rec button pressed\n",
+ __func__);
rec_button_was_pressed = 1;
} else if (rec_button_was_pressed) {
- VBDEBUG(("%s() - Rec button (1)\n",
- __func__));
+ VB2_DEBUG("%s() - Rec button (1)\n",
+ __func__);
return 1;
}
}
@@ -173,7 +173,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
VbAudioContext *audio = 0;
- VBDEBUG(("Entering %s()\n", __func__));
+ VB2_DEBUG("Entering %s()\n", __func__);
/* Check if USB booting is allowed */
uint32_t allow_usb = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_USB);
@@ -205,9 +205,9 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
allow_legacy = 1;
if (fwmp_flags & FWMP_DEV_DISABLE_BOOT) {
if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
- VBDEBUG(("%s() - FWMP_DEV_DISABLE_BOOT rejected by "
- "FORCE_DEV_SWITCH_ON\n",
- __func__));
+ VB2_DEBUG("%s() - FWMP_DEV_DISABLE_BOOT rejected by "
+ "FORCE_DEV_SWITCH_ON\n",
+ __func__);
} else {
disable_dev_boot = 1;
}
@@ -215,14 +215,14 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
/* If dev mode is disabled, only allow TONORM */
while (disable_dev_boot) {
- VBDEBUG(("%s() - dev_disable_boot is set.\n", __func__));
+ VB2_DEBUG("%s() - dev_disable_boot is set.\n", __func__);
VbDisplayScreen(ctx, cparams, VB_SCREEN_DEVELOPER_TO_NORM, 0);
VbExDisplayDebugInfo(dev_disable_msg);
/* Ignore space in VbUserConfirms()... */
switch (VbUserConfirms(ctx, cparams, 0)) {
case 1:
- VBDEBUG(("%s() - leaving dev-mode.\n", __func__));
+ VB2_DEBUG("%s() - leaving dev-mode.\n", __func__);
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST, 1);
VbDisplayScreen(ctx, cparams,
VB_SCREEN_TO_NORM_CONFIRMED,
@@ -230,11 +230,11 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
VbExSleepMs(5000);
return VBERROR_REBOOT_REQUIRED;
case -1:
- VBDEBUG(("%s() - shutdown requested\n", __func__));
+ VB2_DEBUG("%s() - shutdown requested\n", __func__);
return VBERROR_SHUTDOWN_REQUESTED;
default:
/* Ignore user attempt to cancel */
- VBDEBUG(("%s() - ignore cancel TONORM\n", __func__));
+ VB2_DEBUG("%s() - ignore cancel TONORM\n", __func__);
}
}
@@ -249,7 +249,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
uint32_t key;
if (VbWantShutdown(gbb->flags)) {
- VBDEBUG(("VbBootDeveloper() - shutdown requested!\n"));
+ VB2_DEBUG("VbBootDeveloper() - shutdown requested!\n");
VbAudioClose(audio);
return VBERROR_SHUTDOWN_REQUESTED;
}
@@ -265,8 +265,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
break;
case ' ':
/* See if we should disable virtual dev-mode switch. */
- VBDEBUG(("%s shared->flags=0x%x\n",
- __func__, shared->flags));
+ VB2_DEBUG("%s shared->flags=0x%x\n",
+ __func__, shared->flags);
if (shared->flags & VBSD_HONOR_VIRT_DEV_SWITCH &&
shared->flags & VBSD_BOOT_DEV_SWITCH_ON) {
/* Stop the countdown while we go ask... */
@@ -276,9 +276,9 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
* TONORM won't work (only for
* non-shipping devices).
*/
- VBDEBUG(("%s() - TONORM rejected by "
- "FORCE_DEV_SWITCH_ON\n",
- __func__));
+ VB2_DEBUG("%s() - TONORM rejected by "
+ "FORCE_DEV_SWITCH_ON\n",
+ __func__);
VbExDisplayDebugInfo(
"WARNING: TONORM prohibited by "
"GBB FORCE_DEV_SWITCH_ON.\n\n");
@@ -291,8 +291,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
/* Ignore space in VbUserConfirms()... */
switch (VbUserConfirms(ctx, cparams, 0)) {
case 1:
- VBDEBUG(("%s() - leaving dev-mode.\n",
- __func__));
+ VB2_DEBUG("%s() - leaving dev-mode.\n",
+ __func__);
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST,
1);
VbDisplayScreen(ctx,
@@ -302,13 +302,13 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
VbExSleepMs(5000);
return VBERROR_REBOOT_REQUIRED;
case -1:
- VBDEBUG(("%s() - shutdown requested\n",
- __func__));
+ VB2_DEBUG("%s() - shutdown requested\n",
+ __func__);
return VBERROR_SHUTDOWN_REQUESTED;
default:
/* Stay in dev-mode */
- VBDEBUG(("%s() - stay in dev-mode\n",
- __func__));
+ VB2_DEBUG("%s() - stay in dev-mode\n",
+ __func__);
VbDisplayScreen(ctx,
cparams,
VB_SCREEN_DEVELOPER_WARNING,
@@ -321,8 +321,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
* No virtual dev-mode switch, so go directly
* to recovery mode.
*/
- VBDEBUG(("%s() - going to recovery\n",
- __func__));
+ VB2_DEBUG("%s() - going to recovery\n",
+ __func__);
vb2_nv_set(ctx, VB2_NV_RECOVERY_REQUEST,
VBNV_RECOVERY_RW_DEV_SCREEN);
VbAudioClose(audio);
@@ -331,14 +331,14 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
break;
case 0x04:
/* Ctrl+D = dismiss warning; advance to timeout */
- VBDEBUG(("VbBootDeveloper() - "
- "user pressed Ctrl+D; skip delay\n"));
+ VB2_DEBUG("VbBootDeveloper() - "
+ "user pressed Ctrl+D; skip delay\n");
ctrl_d_pressed = 1;
goto fallout;
break;
case 0x0c:
- VBDEBUG(("VbBootDeveloper() - "
- "user pressed Ctrl+L; Try legacy boot\n"));
+ VB2_DEBUG("VbBootDeveloper() - "
+ "user pressed Ctrl+L; Try legacy boot\n");
VbTryLegacy(allow_legacy);
break;
@@ -349,11 +349,11 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
*/
case 0x15:
/* Ctrl+U = try USB boot, or beep if failure */
- VBDEBUG(("VbBootDeveloper() - "
- "user pressed Ctrl+U; try USB\n"));
+ VB2_DEBUG("VbBootDeveloper() - "
+ "user pressed Ctrl+U; try USB\n");
if (!allow_usb) {
- VBDEBUG(("VbBootDeveloper() - "
- "USB booting is disabled\n"));
+ VB2_DEBUG("VbBootDeveloper() - "
+ "USB booting is disabled\n");
VbExDisplayDebugInfo(
"WARNING: Booting from external media "
"(USB/SD) has not been enabled. Refer "
@@ -383,7 +383,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
}
break;
default:
- VBDEBUG(("VbBootDeveloper() - pressed key %d\n", key));
+ VB2_DEBUG("VbBootDeveloper() - pressed key %d\n", key);
VbCheckDisplayKey(ctx, cparams, key);
break;
}
@@ -393,7 +393,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
/* If defaulting to legacy boot, try that unless Ctrl+D was pressed */
if (use_legacy && !ctrl_d_pressed) {
- VBDEBUG(("VbBootDeveloper() - defaulting to legacy\n"));
+ VB2_DEBUG("VbBootDeveloper() - defaulting to legacy\n");
VbTryLegacy(allow_legacy);
}
@@ -405,7 +405,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
}
/* Timeout or Ctrl+D; attempt loading from fixed disk */
- VBDEBUG(("VbBootDeveloper() - trying fixed disk\n"));
+ VB2_DEBUG("VbBootDeveloper() - trying fixed disk\n");
VbAudioClose(audio);
return VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_FIXED);
}
@@ -430,7 +430,7 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
uint32_t key;
int i;
- VBDEBUG(("VbBootRecovery() start\n"));
+ VB2_DEBUG("VbBootRecovery() start\n");
/*
* If the dev-mode switch is off and the user didn't press the recovery
@@ -448,8 +448,8 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
* back here, thus, we won't be able to give a user a chance to
* reboot to workaround boot hicups.
*/
- VBDEBUG(("VbBootRecovery() saving recovery reason (%#x)\n",
- shared->recovery_reason));
+ VB2_DEBUG("VbBootRecovery() saving recovery reason (%#x)\n",
+ shared->recovery_reason);
vb2_nv_set(ctx, VB2_NV_RECOVERY_SUBCODE,
shared->recovery_reason);
/*
@@ -459,7 +459,7 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
vb2_nv_commit(ctx);
VbDisplayScreen(ctx, cparams, VB_SCREEN_OS_BROKEN, 0);
- VBDEBUG(("VbBootRecovery() waiting for manual recovery\n"));
+ VB2_DEBUG("VbBootRecovery() waiting for manual recovery\n");
while (1) {
VbCheckDisplayKey(ctx, cparams, VbExKeyboardRead());
if (VbWantShutdown(cparams->gbb->flags))
@@ -469,9 +469,9 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
}
/* Loop and wait for a recovery image */
- VBDEBUG(("VbBootRecovery() waiting for a recovery image\n"));
+ VB2_DEBUG("VbBootRecovery() waiting for a recovery image\n");
while (1) {
- VBDEBUG(("VbBootRecovery() attempting to load kernel2\n"));
+ VB2_DEBUG("VbBootRecovery() attempting to load kernel2\n");
retval = VbTryLoadKernel(ctx, cparams, VB_DISK_FLAG_REMOVABLE);
/*
@@ -520,8 +520,8 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
* any case we don't like this. Beep
* and ignore.
*/
- VBDEBUG(("%s() - ^D but rec switch "
- "is pressed\n", __func__));
+ VB2_DEBUG("%s() - ^D but rec switch "
+ "is pressed\n", __func__);
VbExBeep(120, 400);
continue;
}
@@ -537,23 +537,23 @@ VbError_t vb2_recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
switch (VbUserConfirms(ctx, cparams,
vbc_flags)) {
case 1:
- VBDEBUG(("%s() Enabling dev-mode...\n",
- __func__));
+ VB2_DEBUG("%s() Enabling dev-mode...\n",
+ __func__);
if (TPM_SUCCESS != SetVirtualDevMode(1))
return VBERROR_TPM_SET_BOOT_MODE_STATE;
- VBDEBUG(("%s() Reboot so it will take "
- "effect\n", __func__));
+ VB2_DEBUG("%s() Reboot so it will take "
+ "effect\n", __func__);
if (VbExGetSwitches
(VB_INIT_FLAG_ALLOW_USB_BOOT))
VbAllowUsbBoot(ctx);
return VBERROR_REBOOT_REQUIRED;
case -1:
- VBDEBUG(("%s() - Shutdown requested\n",
- __func__));
+ VB2_DEBUG("%s() - Shutdown requested\n",
+ __func__);
return VBERROR_SHUTDOWN_REQUESTED;
default: /* zero, actually */
- VBDEBUG(("%s() - Not enabling "
- "dev-mode\n", __func__));
+ VB2_DEBUG("%s() - Not enabling "
+ "dev-mode\n", __func__);
/*
* Jump out of the outer loop to
* refresh the display quickly.
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c
index 71bf73cd..97eebd0f 100644
--- a/firmware/stub/tpm_lite_stub.c
+++ b/firmware/stub/tpm_lite_stub.c
@@ -8,6 +8,9 @@
#include <stdint.h>
+#include "2sysincludes.h"
+#include "2common.h"
+
#include "tlcl.h"
#include "tlcl_internal.h"
#include "utility.h"
@@ -176,8 +179,8 @@ VbError_t VbExTpmOpen(void)
if (saved_errno != EBUSY)
break;
- VBDEBUG(("TPM: retrying %s: %s\n",
- device_path, strerror(errno)));
+ VB2_DEBUG("TPM: retrying %s: %s\n",
+ device_path, strerror(errno));
/* Stall until TPM comes back. */
delay.tv_sec = 0;
@@ -216,7 +219,7 @@ VbError_t VbExTpmSendReceive(const uint8_t* request, uint32_t request_length,
#ifdef VBOOT_DEBUG
struct timeval before, after;
- VBDEBUG(("request (%d bytes):\n", request_length));
+ VB2_DEBUG("request (%d bytes):\n", request_length);
DbgPrintBytes(request, request_length);
gettimeofday(&before, NULL);
#endif
@@ -227,11 +230,11 @@ VbError_t VbExTpmSendReceive(const uint8_t* request, uint32_t request_length,
#ifdef VBOOT_DEBUG
gettimeofday(&after, NULL);
- VBDEBUG(("response (%d bytes):\n", *response_length));
+ VB2_DEBUG("response (%d bytes):\n", *response_length);
DbgPrintBytes(response, *response_length);
- VBDEBUG(("execution time: %dms\n",
- (int) ((after.tv_sec - before.tv_sec) * 1000 +
- (after.tv_usec - before.tv_usec) / 1000)));
+ VB2_DEBUG("execution time: %dms\n",
+ (int) ((after.tv_sec - before.tv_sec) * 1000 +
+ (after.tv_usec - before.tv_usec) / 1000));
#endif
#ifndef NDEBUG
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 05126214..f1221834 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -791,12 +791,12 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
ssize_t n;
if (pipe(mosys_to_crossystem) < 0) {
- VBDEBUG(("pipe() error\n"));
+ fprintf(stderr, "pipe() error\n");
return -1;
}
if ((pid = fork()) < 0) {
- VBDEBUG(("fork() error\n"));
+ fprintf(stderr, "fork() error\n");
close(mosys_to_crossystem[0]);
close(mosys_to_crossystem[1]);
return -1;
@@ -806,7 +806,7 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
if (STDOUT_FILENO != mosys_to_crossystem[1]) {
if (dup2(mosys_to_crossystem[1], STDOUT_FILENO)
!= STDOUT_FILENO) {
- VBDEBUG(("stdout dup2() failed (mosys)\n"));
+ fprintf(stderr, "stdout dup2() failed (mosys)\n");
close(mosys_to_crossystem[1]);
exit(1);
}
@@ -814,7 +814,7 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
/* Execute mosys */
execv(InAndroid() ? MOSYS_ANDROID_PATH : MOSYS_CROS_PATH, argv);
/* We shouldn't be here; exit now! */
- VBDEBUG(("execv() of mosys failed\n"));
+ fprintf(stderr, "execv() of mosys failed\n");
close(mosys_to_crossystem[1]);
exit(1);
} else { /* Parent */
@@ -832,9 +832,8 @@ static int ExecuteMosys(char * const argv[], char *buf, size_t bufsize)
}
close(mosys_to_crossystem[0]);
if (n < 0)
- VBDEBUG(("read() error reading output from mosys\n"));
+ fprintf(stderr, "read() error on output from mosys\n");
if (waitpid(pid, &status, 0) < 0 || status) {
- VBDEBUG(("waitpid() or mosys error\n"));
fprintf(stderr, "waitpid() or mosys error\n");
return -1;
}
diff --git a/host/lib/file_keys.c b/host/lib/file_keys.c
index 0aba6b86..7df7ceb2 100644
--- a/host/lib/file_keys.c
+++ b/host/lib/file_keys.c
@@ -29,7 +29,7 @@ int DigestFile(char *input_file, enum vb2_hash_algorithm alg,
struct vb2_digest_context ctx;
if( (input_fd = open(input_file, O_RDONLY)) == -1 ) {
- VBDEBUG(("Couldn't open %s\n", input_file));
+ fprintf(stderr, "Couldn't open %s\n", input_file);
return VB2_ERROR_UNKNOWN;
}
vb2_digest_init(&ctx, alg);
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c
index 611253b9..250ca99d 100644
--- a/host/lib/host_misc.c
+++ b/host/lib/host_misc.c
@@ -30,7 +30,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr)
f = fopen(filename, "rb");
if (!f) {
- VBDEBUG(("Unable to open file %s\n", filename));
+ fprintf(stderr, "Unable to open file %s\n", filename);
return NULL;
}
@@ -49,7 +49,7 @@ uint8_t* ReadFile(const char* filename, uint64_t* sizeptr)
}
if(1 != fread(buf, size, 1, f)) {
- VBDEBUG(("Unable to read from file %s\n", filename));
+ fprintf(stderr, "Unable to read from file %s\n", filename);
fclose(f);
free(buf);
return NULL;
@@ -103,12 +103,12 @@ int WriteFile(const char* filename, const void *data, uint64_t size)
{
FILE *f = fopen(filename, "wb");
if (!f) {
- VBDEBUG(("Unable to open file %s\n", filename));
+ fprintf(stderr, "Unable to open file %s\n", filename);
return 1;
}
if (1 != fwrite(data, size, 1, f)) {
- VBDEBUG(("Unable to write to file %s\n", filename));
+ fprintf(stderr, "Unable to write to file %s\n", filename);
fclose(f);
unlink(filename); /* Delete any partial file */
return 1;
diff --git a/host/lib/signature_digest.c b/host/lib/signature_digest.c
index d56b05be..025a9ffe 100644
--- a/host/lib/signature_digest.c
+++ b/host/lib/signature_digest.c
@@ -42,7 +42,8 @@ uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
uint8_t digest[VB2_SHA512_DIGEST_SIZE]; /* Longest digest */
if (algorithm >= VB2_ALG_COUNT) {
- VBDEBUG(("SignatureDigest() called with invalid algorithm!\n"));
+ fprintf(stderr, "SignatureDigest(): "
+ "Called with invalid algorithm!\n");
} else if (VB2_SUCCESS ==
vb2_digest_buffer(buf, len, vb2_crypto_to_hash(algorithm),
digest, sizeof(digest))) {
@@ -60,7 +61,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
uint8_t* signature = NULL;
uint8_t* signature_digest = SignatureDigest(buf, len, algorithm);
if (!signature_digest) {
- VBDEBUG(("SignatureBuf(): Couldn't get signature digest\n"));
+ fprintf(stderr, "SignatureBuf(): "
+ "Couldn't get signature digest\n");
return NULL;
}
@@ -70,7 +72,7 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
const uint8_t* digestinfo = NULL;
if (VB2_SUCCESS != vb2_digest_info(hash_alg, &digestinfo,
&digestinfo_size)) {
- VBDEBUG(("SignatureBuf(): Couldn't get digest info\n"));
+ fprintf(stderr, "SignatureBuf(): Couldn't get digest info\n");
free(signature_digest);
return NULL;
}
@@ -79,8 +81,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
key_fp = fopen(key_file, "r");
if (!key_fp) {
- VBDEBUG(("SignatureBuf(): Couldn't open key file: %s\n",
- key_file));
+ fprintf(stderr, "SignatureBuf(): Couldn't open key file: %s\n",
+ key_file);
free(signature_digest);
return NULL;
}
@@ -88,8 +90,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
signature = (uint8_t *)malloc(
vb2_rsa_sig_size(vb2_crypto_to_signature(algorithm)));
else
- VBDEBUG(("SignatureBuf(): Couldn't read private key from: %s\n",
- key_file));
+ fprintf(stderr, "SignatureBuf(): "
+ "Couldn't read private key from: %s\n", key_file);
if (signature) {
if (-1 == RSA_private_encrypt(
signature_digest_len, /* Input length. */
@@ -97,8 +99,8 @@ uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
signature, /* Output signature. */
key, /* Key to use. */
RSA_PKCS1_PADDING)) /* Padding to use. */
- VBDEBUG(("SignatureBuf(): "
- "RSA_private_encrypt() failed.\n"));
+ fprintf(stderr, "SignatureBuf(): "
+ "RSA_private_encrypt() failed.\n");
}
fclose(key_fp);
if (key)
diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
index 271f3428..cc24cee9 100644
--- a/tests/vboot_api_devmode_tests.c
+++ b/tests/vboot_api_devmode_tests.c
@@ -231,21 +231,21 @@ uint32_t VbExKeyboardRead(void) {
now = current_time;
if (kbd_fire_key && now >= kbd_fire_at) {
- VBDEBUG((" VbExKeyboardRead() - returning %d at %d msec\n",
- kbd_fire_key, now));
+ VB2_DEBUG(" VbExKeyboardRead() - returning %d at %d msec\n",
+ kbd_fire_key, now);
tmp = kbd_fire_key;
kbd_fire_key = 0;
return tmp;
}
- VBDEBUG((" VbExKeyboardRead() - returning %d at %d msec\n",
- 0, now));
+ VB2_DEBUG(" VbExKeyboardRead() - returning %d at %d msec\n",
+ 0, now);
return 0;
}
void VbExSleepMs(uint32_t msec) {
current_ticks += (uint64_t)msec * TICKS_PER_MSEC;
current_time = current_ticks / TICKS_PER_MSEC;
- VBDEBUG(("VbExSleepMs(%d) -> %d\n", msec, current_time));
+ VB2_DEBUG("VbExSleepMs(%d) -> %d\n", msec, current_time);
}
uint64_t VbExGetTimer(void) {
@@ -253,7 +253,7 @@ uint64_t VbExGetTimer(void) {
}
VbError_t VbExBeep(uint32_t msec, uint32_t frequency) {
- VBDEBUG(("VbExBeep(%d, %d) at %d msec\n", msec, frequency, current_time));
+ VB2_DEBUG("VbExBeep(%d, %d) at %d msec\n", msec, frequency, current_time);
if (current_event < max_events &&
msec == expected_event[current_event].msec &&
@@ -271,31 +271,31 @@ VbError_t VbExBeep(uint32_t msec, uint32_t frequency) {
VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale) {
switch(screen_type) {
case VB_SCREEN_BLANK:
- VBDEBUG(("VbExDisplayScreen(BLANK)\n"));
+ VB2_DEBUG("VbExDisplayScreen(BLANK)\n");
break;
case VB_SCREEN_DEVELOPER_WARNING:
- VBDEBUG(("VbExDisplayScreen(DEV)\n"));
+ VB2_DEBUG("VbExDisplayScreen(DEV)\n");
break;
case VB_SCREEN_DEVELOPER_EGG:
- VBDEBUG(("VbExDisplayScreen(EGG)\n"));
+ VB2_DEBUG("VbExDisplayScreen(EGG)\n");
break;
case VB_SCREEN_RECOVERY_REMOVE:
- VBDEBUG(("VbExDisplayScreen(REMOVE)\n"));
+ VB2_DEBUG("VbExDisplayScreen(REMOVE)\n");
break;
case VB_SCREEN_RECOVERY_INSERT:
- VBDEBUG(("VbExDisplayScreen(INSERT)\n"));
+ VB2_DEBUG("VbExDisplayScreen(INSERT)\n");
break;
case VB_SCREEN_RECOVERY_NO_GOOD:
- VBDEBUG(("VbExDisplayScreen(NO_GOOD)\n"));
+ VB2_DEBUG("VbExDisplayScreen(NO_GOOD)\n");
break;
case VB_SCREEN_OS_BROKEN:
- VBDEBUG(("VbExDisplayScreen(BROKEN)\n"));
+ VB2_DEBUG("VbExDisplayScreen(BROKEN)\n");
break;
default:
- VBDEBUG(("VbExDisplayScreen(%d)\n", screen_type));
+ VB2_DEBUG("VbExDisplayScreen(%d)\n", screen_type);
}
- VBDEBUG((" current_time is %d msec\n", current_time));
+ VB2_DEBUG(" current_time is %d msec\n", current_time);
return VBERROR_SUCCESS;
}
@@ -307,7 +307,7 @@ static void VbBootDeveloperSoundTest(void) {
int num_tests = sizeof(test) / sizeof(test_case_t);
for (i=0; i<num_tests; i++) {
- VBDEBUG(("STARTING %s ...\n", test[i].name));
+ VB2_DEBUG("STARTING %s ...\n", test[i].name);
ResetMocks();
gbb.flags = test[i].gbb_flags;
beep_return = test[i].beep_return;
@@ -316,8 +316,8 @@ static void VbBootDeveloperSoundTest(void) {
max_events = test[i].num_events;
expected_event = test[i].notes;
(void) VbBootDeveloper(&ctx, &cparams);
- VBDEBUG(("INFO: matched %d total %d expected %d\n",
- matched_events, current_event, test[i].num_events));
+ VB2_DEBUG("INFO: matched %d total %d expected %d\n",
+ matched_events, current_event, test[i].num_events);
TEST_TRUE(matched_events == test[i].num_events &&
current_event == test[i].num_events, test[i].name);
}
diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c
index 1d80dc4b..3214d442 100644
--- a/tests/vboot_api_kernel_tests.c
+++ b/tests/vboot_api_kernel_tests.c
@@ -232,7 +232,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
int i;
int num_disks = 0;
- VBDEBUG(("My %s\n", __FUNCTION__));
+ VB2_DEBUG("My %s\n", __FUNCTION__);
*infos_ptr = mock_disks;
@@ -248,14 +248,14 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
t->disks_to_provide[i].flags;
mock_disks[num_disks].handle = (VbExDiskHandle_t)
t->disks_to_provide[i].diskname;
- VBDEBUG((" mock_disk[%d] %" PRIu64 " %" PRIu64
- " 0x%x %s\n", i,
- mock_disks[num_disks].bytes_per_lba,
- mock_disks[num_disks].lba_count,
- mock_disks[num_disks].flags,
- (mock_disks[num_disks].handle
- ? (char *)mock_disks[num_disks].handle
- : "0")));
+ VB2_DEBUG(" mock_disk[%d] %" PRIu64 " %" PRIu64
+ " 0x%x %s\n", i,
+ mock_disks[num_disks].bytes_per_lba,
+ mock_disks[num_disks].lba_count,
+ mock_disks[num_disks].flags,
+ (mock_disks[num_disks].handle
+ ? (char *)mock_disks[num_disks].handle
+ : "0"));
num_disks++;
} else {
mock_disks[num_disks].handle =
@@ -268,8 +268,8 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
else
*count = num_disks;
- VBDEBUG((" *count=%" PRIu32 "\n", *count));
- VBDEBUG((" return 0x%x\n", t->diskgetinfo_return_val));
+ VB2_DEBUG(" *count=%" PRIu32 "\n", *count);
+ VB2_DEBUG(" return 0x%x\n", t->diskgetinfo_return_val);
return t->diskgetinfo_return_val;
}
@@ -278,8 +278,8 @@ VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
VbExDiskHandle_t preserve_handle)
{
got_load_disk = (const char *)preserve_handle;
- VBDEBUG(("%s(): got_load_disk = %s\n", __FUNCTION__,
- got_load_disk ? got_load_disk : "0"));
+ VB2_DEBUG("%s(): got_load_disk = %s\n", __FUNCTION__,
+ got_load_disk ? got_load_disk : "0");
return VBERROR_SUCCESS;
}
@@ -287,9 +287,9 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params,
VbCommonParams *cparams)
{
got_find_disk = (const char *)params->disk_handle;
- VBDEBUG(("%s(%d): got_find_disk = %s\n", __FUNCTION__,
- load_kernel_calls,
- got_find_disk ? got_find_disk : "0"));
+ VB2_DEBUG("%s(%d): got_find_disk = %s\n", __FUNCTION__,
+ load_kernel_calls,
+ got_find_disk ? got_find_disk : "0");
if (t->external_expected[load_kernel_calls] !=
!!(params->boot_flags & BOOT_FLAG_EXTERNAL_GPT))
got_external_mismatch++;
@@ -300,8 +300,8 @@ void vb2_nv_set(struct vb2_context *ctx,
enum vb2_nv_param param,
uint32_t value)
{
- VBDEBUG(("%s(): got_recovery_request_val = %d (0x%x)\n", __FUNCTION__,
- value, value));
+ VB2_DEBUG("%s(): got_recovery_request_val = %d (0x%x)\n", __FUNCTION__,
+ value, value);
got_recovery_request_val = value;
}
diff --git a/tests/vboot_audio_tests.c b/tests/vboot_audio_tests.c
index c392c0d9..07ca438e 100644
--- a/tests/vboot_audio_tests.c
+++ b/tests/vboot_audio_tests.c
@@ -59,7 +59,6 @@ void FixChecksum(VbDevMusic *hdr) {
/* Reset mock data (for use before each test) */
static void ResetMocks(void) {
- VBDEBUG(("ResetMocks()\n"));
memset(&cparams, 0, sizeof(cparams));
cparams.gbb_data = &gbb;
cparams.gbb = &gbb;