diff options
-rw-r--r-- | board/nvidia/chromeos/gpio.c | 1 | ||||
-rw-r--r-- | board/nvidia/chromeos/power_management.c | 7 | ||||
-rw-r--r-- | common/cmd_cros.c | 1 | ||||
-rw-r--r-- | common/cmd_cros_bootstub.c | 29 | ||||
-rw-r--r-- | common/cmd_cros_developer_firmware.c | 23 | ||||
-rw-r--r-- | common/cmd_cros_normal_firmware.c | 17 | ||||
-rw-r--r-- | common/cmd_cros_rec.c | 15 | ||||
-rw-r--r-- | config.mk | 11 | ||||
-rw-r--r-- | include/chromeos/common.h | 22 | ||||
-rw-r--r-- | lib/chromeos/firmware_storage.c | 19 | ||||
-rw-r--r-- | lib/chromeos/firmware_storage_nand.c | 1 | ||||
-rw-r--r-- | lib/chromeos/firmware_storage_ram.c | 7 | ||||
-rw-r--r-- | lib/chromeos/firmware_storage_spi.c | 37 | ||||
-rw-r--r-- | lib/chromeos/fmap.c | 1 | ||||
-rw-r--r-- | lib/chromeos/gbb_bmpblk.c | 1 | ||||
-rw-r--r-- | lib/chromeos/get_firmware_body.c | 17 | ||||
-rw-r--r-- | lib/chromeos/kernel_shared_data.c | 1 | ||||
-rw-r--r-- | lib/chromeos/load_firmware_helper.c | 21 | ||||
-rw-r--r-- | lib/chromeos/load_kernel_helper.c | 87 | ||||
-rw-r--r-- | lib/chromeos/os_storage.c | 21 | ||||
-rw-r--r-- | lib/chromeos/vboot_nvstorage_helper.c | 35 |
21 files changed, 213 insertions, 161 deletions
diff --git a/board/nvidia/chromeos/gpio.c b/board/nvidia/chromeos/gpio.c index f662b92f383..93a0b6653d2 100644 --- a/board/nvidia/chromeos/gpio.c +++ b/board/nvidia/chromeos/gpio.c @@ -39,6 +39,7 @@ #include <common.h> #include "../../common/lcd/gpinit/gpinit.h" +#include <chromeos/common.h> #include <chromeos/gpio.h> #define GPIO_ACTIVE_HIGH 0 diff --git a/board/nvidia/chromeos/power_management.c b/board/nvidia/chromeos/power_management.c index 118f5df6002..5edeaddca4f 100644 --- a/board/nvidia/chromeos/power_management.c +++ b/board/nvidia/chromeos/power_management.c @@ -13,6 +13,7 @@ #include <common.h> #include <i2c.h> +#include <chromeos/common.h> #include <chromeos/power_management.h> #define PREFIX "cold_reboot: " @@ -27,13 +28,13 @@ void cold_reboot(void) uint8_t byte; if (i2c_set_bus_num(PMIC_I2C_BUS)) { - debug(PREFIX "i2c_set_bus_num fail\n"); + VBDEBUG(PREFIX "i2c_set_bus_num fail\n"); goto FATAL; } if (i2c_read(PMIC_I2C_DEVICE_ADDRESS, TPS6586X_SUPPLYENE, 1, &byte, sizeof(byte))) { - debug(PREFIX "i2c_read fail\n"); + VBDEBUG(PREFIX "i2c_read fail\n"); goto FATAL; } @@ -42,7 +43,7 @@ void cold_reboot(void) if (i2c_write(PMIC_I2C_DEVICE_ADDRESS, TPS6586X_SUPPLYENE, 1, &byte, sizeof(byte))) { - debug(PREFIX "i2c_write fail\n"); + VBDEBUG(PREFIX "i2c_write fail\n"); goto FATAL; } diff --git a/common/cmd_cros.c b/common/cmd_cros.c index a75a771bfde..e33bce6b536 100644 --- a/common/cmd_cros.c +++ b/common/cmd_cros.c @@ -14,6 +14,7 @@ #include <common.h> #include <command.h> #include <malloc.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #include <chromeos/fmap.h> #include <chromeos/gbb_bmpblk.h> diff --git a/common/cmd_cros_bootstub.c b/common/cmd_cros_bootstub.c index 252d2e9ad10..96d7d20eaa3 100644 --- a/common/cmd_cros_bootstub.c +++ b/common/cmd_cros_bootstub.c @@ -13,6 +13,7 @@ #include <common.h> #include <command.h> #include <malloc.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #include <chromeos/gpio.h> #include <chromeos/kernel_shared_data.h> @@ -49,7 +50,7 @@ int load_recovery_firmware(firmware_storage_t *file, CONFIG_OFFSET_RECOVERY, CONFIG_LENGTH_RECOVERY, recovery_firmware_buffer); if (retval) { - debug(PREFIX "cannot load recovery firmware\n"); + VBDEBUG(PREFIX "cannot load recovery firmware\n"); } return retval; @@ -57,7 +58,7 @@ int load_recovery_firmware(firmware_storage_t *file, void jump_to_firmware(void (*firmware_entry_point)(void)) { - debug(PREFIX "jump to firmware %p\n", firmware_entry_point); + VBDEBUG(PREFIX "jump to firmware %p\n", firmware_entry_point); cleanup_before_linux(); @@ -66,7 +67,7 @@ void jump_to_firmware(void (*firmware_entry_point)(void)) /* FIXME(clchiou) Bring up a sad face as boot has failed */ enable_interrupts(); - debug(PREFIX "error: firmware returns\n"); + VBDEBUG(PREFIX "error: firmware returns\n"); while (1); } @@ -82,7 +83,7 @@ int do_cros_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (firmware_storage_init(&file)) { /* FIXME(clchiou) Bring up a sad face as boot has failed */ - debug(PREFIX "init_firmware_storage fail\n"); + VBDEBUG(PREFIX "init_firmware_storage fail\n"); while (1); } @@ -97,26 +98,26 @@ int do_cros_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (read_nvcontext(&nvcxt) || VbNvGet(&nvcxt, VBNV_RECOVERY_REQUEST, &recovery_request)) { - debug(PREFIX "fail to read nvcontext\n"); + VBDEBUG(PREFIX "fail to read nvcontext\n"); reason = VBNV_RECOVERY_US_UNSPECIFIED; goto RECOVERY; } /* clear VBNV_DEBUG_RESET_MODE after read */ if (VbNvSet(&nvcxt, VBNV_DEBUG_RESET_MODE, 0)) { - debug(PREFIX "fail to write nvcontext\n"); + VBDEBUG(PREFIX "fail to write nvcontext\n"); reason = VBNV_RECOVERY_US_UNSPECIFIED; goto RECOVERY; } if (recovery_request != VBNV_RECOVERY_NOT_REQUESTED) { - debug(PREFIX "boot recovery cookie set\n"); + VBDEBUG(PREFIX "boot recovery cookie set\n"); reason = recovery_request; goto RECOVERY; } if (is_recovery_mode_gpio_asserted()) { - debug(PREFIX "recovery button pressed\n"); + VBDEBUG(PREFIX "recovery button pressed\n"); reason = VBNV_RECOVERY_RO_MANUAL; goto RECOVERY; } @@ -128,7 +129,7 @@ int do_cros_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) boot_flags, &nvcxt, NULL, &firmware_data); if (nvcxt.raw_changed && write_nvcontext(&nvcxt)) { - debug(PREFIX "fail to write nvcontext\n"); + VBDEBUG(PREFIX "fail to write nvcontext\n"); reason = VBNV_RECOVERY_US_UNSPECIFIED; goto RECOVERY; } @@ -142,7 +143,7 @@ int do_cros_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* assert(status == LOAD_FIRMWARE_RECOVERY) */ RECOVERY: - debug(PREFIX "write to recovery cookie\n"); + VBDEBUG(PREFIX "write to recovery cookie\n"); /* * Although writing back VbNvContext cookies may fail, we boot @@ -154,20 +155,20 @@ RECOVERY: if (reason != VBNV_RECOVERY_NOT_REQUESTED && VbNvSet(&nvcxt, VBNV_RECOVERY_REQUEST, reason)) { /* FIXME: bring up a sad face? */ - debug(PREFIX "error: cannot write recovery reason\n"); + VBDEBUG(PREFIX "error: cannot write recovery reason\n"); } if (VbNvTeardown(&nvcxt)) { /* FIXME: bring up a sad face? */ - debug(PREFIX "error: cannot tear down cookie\n"); + VBDEBUG(PREFIX "error: cannot tear down cookie\n"); } if (nvcxt.raw_changed && write_nvcontext(&nvcxt)) { /* FIXME: bring up a sad face? */ - debug(PREFIX "error: cannot write recovery cookie\n"); + VBDEBUG(PREFIX "error: cannot write recovery cookie\n"); } - debug(PREFIX "jump to recovery firmware and never return\n"); + VBDEBUG(PREFIX "jump to recovery firmware and never return\n"); firmware_data = malloc(CONFIG_LENGTH_RECOVERY); WARN_ON_FAILURE(load_recovery_firmware(&file, firmware_data)); diff --git a/common/cmd_cros_developer_firmware.c b/common/cmd_cros_developer_firmware.c index 0e1754dd728..23ca1cd78f4 100644 --- a/common/cmd_cros_developer_firmware.c +++ b/common/cmd_cros_developer_firmware.c @@ -13,6 +13,7 @@ #include <common.h> #include <command.h> #include <mmc.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #include <chromeos/gbb_bmpblk.h> #include <chromeos/gpio.h> @@ -41,7 +42,7 @@ int do_cros_normal_firmware(cmd_tbl_t *cmdtp, int flag, int argc, static void beep(void) { /* TODO: implement beep */ - debug(PREFIX "beep\n"); + VBDEBUG(PREFIX "beep\n"); } static int unblocked_getc(int *c) @@ -67,12 +68,12 @@ int do_cros_developer_firmware(cmd_tbl_t *cmdtp, int flag, int argc, int c, is_after_20_seconds = 0; if (!is_developer_mode_gpio_asserted()) { - debug(PREFIX "developer switch is off; reboot to recovery!\n"); + VBDEBUG(PREFIX "developer switch is off; reboot to recovery!\n"); reboot_to_recovery_mode(VBNV_RECOVERY_RW_DEV_MISMATCH); } if (TlclStubInit() != TPM_SUCCESS) { - debug(PREFIX "fail to init tpm\n"); + VBDEBUG(PREFIX "fail to init tpm\n"); reboot_to_recovery_mode(VBNV_RECOVERY_RW_TPM_ERROR); } @@ -82,17 +83,17 @@ int do_cros_developer_firmware(cmd_tbl_t *cmdtp, int flag, int argc, * FIXME: We can't read gbb and so can't show a face on screen; * how should we do when this happen? Trap in infinite loop? */ - debug(PREFIX "cannot load gbb\n"); + VBDEBUG(PREFIX "cannot load gbb\n"); while (1); } /* we don't care whether close operation fails */ if (file.close(file.context)) { - debug(PREFIX "close firmware storage failed\n"); + VBDEBUG(PREFIX "close firmware storage failed\n"); } if (display_screen_in_bmpblk(gbb_data, SCREEN_DEVELOPER_MODE)) { - debug(PREFIX "cannot display stuff on LCD screen\n"); + VBDEBUG(PREFIX "cannot display stuff on LCD screen\n"); } start = get_timer(0); @@ -104,7 +105,7 @@ int do_cros_developer_firmware(cmd_tbl_t *cmdtp, int flag, int argc, #ifdef DEBUG /* only output when time advances at least 1 second */ if (time / CONFIG_SYS_HZ > last_time / CONFIG_SYS_HZ) - debug(PREFIX "time ~ %d sec\n", time / CONFIG_SYS_HZ); + VBDEBUG(PREFIX "time ~ %d sec\n", time / CONFIG_SYS_HZ); #endif /* Beep twice when time > 20 seconds */ @@ -121,7 +122,7 @@ int do_cros_developer_firmware(cmd_tbl_t *cmdtp, int flag, int argc, if (!unblocked_getc(&c)) continue; - debug(PREFIX "unblocked_getc() == 0x%x\n", c); + VBDEBUG(PREFIX "unblocked_getc() == 0x%x\n", c); /* Load and boot kernel from USB or SD card */ if (CTRL_U == c) { @@ -129,7 +130,7 @@ int do_cros_developer_firmware(cmd_tbl_t *cmdtp, int flag, int argc, load_and_boot_kernel(gbb_data, gbb_size, boot_flags); - debug(PREFIX "Fail to probe usb and mmc\n"); + VBDEBUG(PREFIX "Fail to probe usb and mmc\n"); beep(); } @@ -138,12 +139,12 @@ int do_cros_developer_firmware(cmd_tbl_t *cmdtp, int flag, int argc, break; if (c == ' ' || c == '\r' || c == '\n' || c == ESCAPE) { - debug(PREFIX "reboot to recovery mode\n"); + VBDEBUG(PREFIX "reboot to recovery mode\n"); reboot_to_recovery_mode(VBNV_RECOVERY_RW_DEV_SCREEN); } } - debug(PREFIX "boot from internal storage\n"); + VBDEBUG(PREFIX "boot from internal storage\n"); if (is_mmc_storage_present(MMC_EMMC_DEVNUM) && !set_bootdev("mmc", MMC_EMMC_DEVNUM, 0)) load_and_boot_kernel(gbb_data, gbb_size, boot_flags); diff --git a/common/cmd_cros_normal_firmware.c b/common/cmd_cros_normal_firmware.c index 461a863d3a5..d9e7954344a 100644 --- a/common/cmd_cros_normal_firmware.c +++ b/common/cmd_cros_normal_firmware.c @@ -15,6 +15,7 @@ #include <fat.h> #include <malloc.h> #include <mmc.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #include <chromeos/load_firmware_helper.h> #include <chromeos/load_kernel_helper.h> @@ -37,13 +38,13 @@ int initialize_drive(void) { if (initialize_mmc_device(DEVICE_NUMBER)) { - debug(PREFIX "mmc %d init fail\n", DEVICE_NUMBER); + VBDEBUG(PREFIX "mmc %d init fail\n", DEVICE_NUMBER); return -1; } - debug(PREFIX "set_bootdev %s %x:0\n", DEVICE_TYPE, DEVICE_NUMBER); + VBDEBUG(PREFIX "set_bootdev %s %x:0\n", DEVICE_TYPE, DEVICE_NUMBER); if (set_bootdev(DEVICE_TYPE, DEVICE_NUMBER, 0)) { - debug(PREFIX "set_bootdev fail\n"); + VBDEBUG(PREFIX "set_bootdev fail\n"); return -1; } @@ -60,26 +61,26 @@ int do_cros_normal_firmware(cmd_tbl_t *cmdtp, int flag, int argc, uint32_t reason = VBNV_RECOVERY_RW_UNSPECIFIED; if (TlclStubInit() != TPM_SUCCESS) { - debug(PREFIX "fail to init tpm\n"); + VBDEBUG(PREFIX "fail to init tpm\n"); reboot_to_recovery_mode(VBNV_RECOVERY_RW_TPM_ERROR); } if (initialize_drive()) { - debug(PREFIX "error: initialize fixed drive fail\n"); + VBDEBUG(PREFIX "error: initialize fixed drive fail\n"); reboot_to_recovery_mode(VBNV_RECOVERY_RW_NO_OS); } if (firmware_storage_init(&file) || load_gbb(&file, &gbb_data, &gbb_size)) { - debug(PREFIX "error: cannot read gbb\n"); + VBDEBUG(PREFIX "error: cannot read gbb\n"); reboot_to_recovery_mode(VBNV_RECOVERY_RO_SHARED_DATA); } status = load_and_boot_kernel(gbb_data, gbb_size, 0ULL); - debug(PREFIX "status == %d\n", status); + VBDEBUG(PREFIX "status == %d\n", status); if (status == LOAD_KERNEL_REBOOT) { - debug(PREFIX "internal error: reboot to current mode\n"); + VBDEBUG(PREFIX "internal error: reboot to current mode\n"); cold_reboot(); } diff --git a/common/cmd_cros_rec.c b/common/cmd_cros_rec.c index 83a06621d9a..28c71b60624 100644 --- a/common/cmd_cros_rec.c +++ b/common/cmd_cros_rec.c @@ -16,6 +16,7 @@ #include <lcd.h> #include <malloc.h> #include <usb.h> /* for wait_ms() */ +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #include <chromeos/load_firmware_helper.h> #include <chromeos/load_kernel_helper.h> @@ -37,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR; #define WARN_ON_FAILURE(action) do { \ int return_code = (action); \ if (return_code != 0) \ - debug(PREFIX "%s failed, returning %d\n", \ + VBDEBUG(PREFIX "%s failed, returning %d\n", \ #action, return_code); \ } while (0) #else @@ -87,7 +88,7 @@ static int exclude_mem_region(uint32_t start, uint32_t end) int i = g_excluded_size; if (g_excluded_size >= MAX_EXCLUDED_REGIONS) { - debug(PREFIX "the number of excluded regions reaches" + VBDEBUG(PREFIX "the number of excluded regions reaches" "the maximum: %d\n", MAX_EXCLUDED_REGIONS); return -1; } @@ -107,7 +108,7 @@ static int exclude_mem_region(uint32_t start, uint32_t end) static void zero_mem(uint32_t start, uint32_t end) { if (end > start) { - debug(PREFIX "\t[0x%08x, 0x%08x)\n", start, end); + VBDEBUG(PREFIX "\t[0x%08x, 0x%08x)\n", start, end); memset((void *)start, '\0', (size_t)(end - start)); } } @@ -120,7 +121,7 @@ static void clear_mem_regions(void) int i; uint32_t addr = g_memory_region.start; - debug(PREFIX "clear memory regions:\n"); + VBDEBUG(PREFIX "clear memory regions:\n"); for (i = 0; i < g_excluded_size; ++i) { zero_mem(addr, g_excluded_regions[i].start); if (g_excluded_regions[i].end > addr) @@ -156,7 +157,7 @@ static int test_clear_mem_regions(void) clear_mem_regions(); for (i = 0; i < 10; ++i) { if (s[i] != r[i]) { - debug(PREFIX "test_clear_mem_regions FAILED!\n"); + VBDEBUG(PREFIX "test_clear_mem_regions FAILED!\n"); return -1; } } @@ -206,12 +207,12 @@ static int init_gbb_in_ram(void) void *gbb_base = NULL; if (firmware_storage_init(&file)) { - debug(PREFIX "init firmware storage failed\n"); + VBDEBUG(PREFIX "init firmware storage failed\n"); return -1; } if (load_gbb(&file, &gbb_base, &g_gbb_size)) { - debug(PREFIX "Unable to load gbb\n"); + VBDEBUG(PREFIX "Unable to load gbb\n"); return -1; } diff --git a/config.mk b/config.mk index 7faaeab49bd..4d035177ee5 100644 --- a/config.mk +++ b/config.mk @@ -155,6 +155,17 @@ RELFLAGS= $(PLATFORM_RELFLAGS) DBGFLAGS= -g # -DDEBUG OPTFLAGS= -Os #-fomit-frame-pointer +ifdef VBOOT_DEBUG +DBGFLAGS += -DVBOOT_DEBUG +endif +ifndef LDSCRIPT +#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug +ifeq ($(CONFIG_NAND_U_BOOT),y) +LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds +else +LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds +endif +endif OBJCFLAGS += --gap-fill=0xff gccincdir := $(shell $(CC) -print-file-name=include) diff --git a/include/chromeos/common.h b/include/chromeos/common.h new file mode 100644 index 00000000000..01052ef2a5a --- /dev/null +++ b/include/chromeos/common.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2011 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. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + */ + +#ifndef CHROMEOS_COMMON_H_ +#define CHROMEOS_COMMON_H_ + +#if defined DEBUG +#define VBDEBUG debug +#elif defined VBOOT_DEBUG +#define VBDEBUG(fmt, args...) printf(fmt ,##args) +#else +#define VBDEBUG(fmt, args...) +#endif + +#endif /* CHROMEOS_COMMON_H_ */ diff --git a/lib/chromeos/firmware_storage.c b/lib/chromeos/firmware_storage.c index c84e5cdd42a..c6ad803a00d 100644 --- a/lib/chromeos/firmware_storage.c +++ b/lib/chromeos/firmware_storage.c @@ -9,6 +9,7 @@ */ #include <common.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #if defined CONFIG_CHROMEOS_DEFAULT_FIRMWARE_STORAGE_SPI && \ @@ -39,7 +40,7 @@ int (*const firmware_storage_init)(firmware_storage_t *file) = #ifndef CONFIG_CHROMEOS_FIRMWARE_STORAGE_NAND int firmware_storage_init_nand(firmware_storage_t *file) { - debug(PREFIX "NAND is not supported\n"); + VBDEBUG(PREFIX "NAND is not supported\n"); return -1; } #endif @@ -47,7 +48,7 @@ int firmware_storage_init_nand(firmware_storage_t *file) #ifndef CONFIG_CHROMEOS_FIRMWARE_STORAGE_SPI int firmware_storage_init_spi(firmware_storage_t *file) { - debug(PREFIX "SPI is not supported\n"); + VBDEBUG(PREFIX "SPI is not supported\n"); return -1; } #endif @@ -55,7 +56,7 @@ int firmware_storage_init_spi(firmware_storage_t *file) #ifndef CONFIG_CHROMEOS_FIRMWARE_STORAGE_RAM int firmware_storage_init_ram(firmware_storage_t *file, void *beg, void *end) { - debug(PREFIX "RAM is not supported\n"); + VBDEBUG(PREFIX "RAM is not supported\n"); return -1; } #endif @@ -70,7 +71,7 @@ int firmware_storage_read(firmware_storage_t *file, size_t remain; if (file->seek(file->context, offset, SEEK_SET) < 0) { - debug(PREFIX "seek to address 0x%08x fail\n", offset); + VBDEBUG(PREFIX "seek to address 0x%08x fail\n", offset); return -1; } @@ -83,12 +84,12 @@ int firmware_storage_read(firmware_storage_t *file, } if (size < 0) { - debug(PREFIX "an error occur when read firmware: %ld\n", size); + VBDEBUG(PREFIX "an error occur when read firmware: %ld\n", size); return -1; } if (remain > 0) { - debug(PREFIX "cannot read all data: %ld\n", remain); + VBDEBUG(PREFIX "cannot read all data: %ld\n", remain); return -1; } @@ -105,7 +106,7 @@ int firmware_storage_write(firmware_storage_t *file, size_t remain; if (file->seek(file->context, offset, SEEK_SET) < 0) { - debug(PREFIX "seek to address 0x%08x fail\n", offset); + VBDEBUG(PREFIX "seek to address 0x%08x fail\n", offset); return -1; } @@ -118,12 +119,12 @@ int firmware_storage_write(firmware_storage_t *file, } if (size < 0) { - debug(PREFIX "an error occur when write firmware: %ld\n", size); + VBDEBUG(PREFIX "an error occur when write firmware: %ld\n", size); return -1; } if (remain > 0) { - debug(PREFIX "cannot write all data: %ld\n", remain); + VBDEBUG(PREFIX "cannot write all data: %ld\n", remain); return -1; } diff --git a/lib/chromeos/firmware_storage_nand.c b/lib/chromeos/firmware_storage_nand.c index 7762c04c4a9..03110d2dc76 100644 --- a/lib/chromeos/firmware_storage_nand.c +++ b/lib/chromeos/firmware_storage_nand.c @@ -11,6 +11,7 @@ /* Implementation of firmware storage access interface for NAND */ #include <common.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> int firmware_storage_init_nand(firmware_storage_t *file) diff --git a/lib/chromeos/firmware_storage_ram.c b/lib/chromeos/firmware_storage_ram.c index a0bd582eefe..a95df374c4d 100644 --- a/lib/chromeos/firmware_storage_ram.c +++ b/lib/chromeos/firmware_storage_ram.c @@ -12,6 +12,7 @@ #include <common.h> #include <malloc.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> struct context_t { @@ -30,17 +31,17 @@ static off_t seek_ram(void *context, off_t offset, enum whence_t whence) else if (whence == SEEK_END) cur = cxt->end + offset; else { - debug("seek_ram: unknown whence value: %d\n", whence); + VBDEBUG("seek_ram: unknown whence value: %d\n", whence); return -1; } if (cur < cxt->beg) { - debug("seek_ram: offset underflow: %p < %p\n", cur, cxt->beg); + VBDEBUG("seek_ram: offset underflow: %p < %p\n", cur, cxt->beg); return -1; } if (cur >= cxt->end) { - debug("seek_ram: offset exceeds size: %p >= %p\n", cur, + VBDEBUG("seek_ram: offset exceeds size: %p >= %p\n", cur, cxt->end); return -1; } diff --git a/lib/chromeos/firmware_storage_spi.c b/lib/chromeos/firmware_storage_spi.c index fc71a2ad15b..250afedec9b 100644 --- a/lib/chromeos/firmware_storage_spi.c +++ b/lib/chromeos/firmware_storage_spi.c @@ -13,6 +13,7 @@ #include <common.h> #include <malloc.h> #include <spi_flash.h> +#include <chromeos/common.h> #include <chromeos/firmware_storage.h> #define PREFIX "firmware_storage_spi: " @@ -41,17 +42,17 @@ static off_t seek_spi(void *context, off_t offset, enum whence_t whence) else if (whence == SEEK_END) next_offset = cxt->flash->size + offset; else { - debug(PREFIX "unknown whence value: %d\n", whence); + VBDEBUG(PREFIX "unknown whence value: %d\n", whence); return -1; } if (next_offset < 0) { - debug(PREFIX "negative offset: %d\n", next_offset); + VBDEBUG(PREFIX "negative offset: %d\n", next_offset); return -1; } if (next_offset > cxt->flash->size) { - debug(PREFIX "offset overflow: 0x%08x > 0x%08x\n", + VBDEBUG(PREFIX "offset overflow: 0x%08x > 0x%08x\n", next_offset, cxt->flash->size); return -1; } @@ -70,7 +71,7 @@ static int border_check(struct spi_flash *flash, u32 offset, size_t *count_ptr) { if (offset >= flash->size) { - debug(PREFIX "at EOF\n"); + VBDEBUG(PREFIX "at EOF\n"); return -1; } @@ -88,7 +89,7 @@ static ssize_t read_spi(void *context, void *buf, size_t count) return -1; if (cxt->flash->read(cxt->flash, cxt->offset, count, buf)) { - debug(PREFIX "SPI read fail\n"); + VBDEBUG(PREFIX "SPI read fail\n"); return -1; } @@ -112,9 +113,9 @@ static ssize_t read_spi(void *context, void *buf, size_t count) */ static void align_to_sector(size_t *offset_ptr, size_t *length_ptr) { - debug(PREFIX "before adjustment\n"); - debug(PREFIX "offset: 0x%lx\n", *offset_ptr); - debug(PREFIX "length: 0x%lx\n", *length_ptr); + VBDEBUG(PREFIX "before adjustment\n"); + VBDEBUG(PREFIX "offset: 0x%lx\n", *offset_ptr); + VBDEBUG(PREFIX "length: 0x%lx\n", *length_ptr); /* Adjust if offset is not multiple of SECTOR_SIZE */ if (*offset_ptr & (SECTOR_SIZE - 1ul)) { @@ -127,9 +128,9 @@ static void align_to_sector(size_t *offset_ptr, size_t *length_ptr) *length_ptr += SECTOR_SIZE; } - debug(PREFIX "after adjustment\n"); - debug(PREFIX "offset: 0x%lx\n", *offset_ptr); - debug(PREFIX "length: 0x%lx\n", *length_ptr); + VBDEBUG(PREFIX "after adjustment\n"); + VBDEBUG(PREFIX "offset: 0x%lx\n", *offset_ptr); + VBDEBUG(PREFIX "length: 0x%lx\n", *length_ptr); } static ssize_t write_spi(void *context, const void *buf, size_t count) @@ -151,7 +152,7 @@ static ssize_t write_spi(void *context, const void *buf, size_t count) if (border_check(flash, offset, &tmp)) return -1; if (tmp != length) { - debug(PREFIX "cannot erase range [%08lx:%08lx]: %08lx\n", + VBDEBUG(PREFIX "cannot erase range [%08lx:%08lx]: %08lx\n", offset, offset + length, offset + tmp); return -1; } @@ -159,23 +160,23 @@ static ssize_t write_spi(void *context, const void *buf, size_t count) backup_buf = length > sizeof(static_buf) ? malloc(length) : static_buf; if ((status = flash->read(flash, offset, length, backup_buf))) { - debug(PREFIX "cannot backup data: %d\n", status); + VBDEBUG(PREFIX "cannot backup data: %d\n", status); goto EXIT; } if ((status = flash->erase(flash, offset, length))) { - debug(PREFIX "SPI erase fail: %d\n", status); + VBDEBUG(PREFIX "SPI erase fail: %d\n", status); goto EXIT; } - debug(PREFIX "cxt->offset: 0x%08lx\n", cxt->offset); - debug(PREFIX "offset: 0x%08lx\n", offset); + VBDEBUG(PREFIX "cxt->offset: 0x%08lx\n", cxt->offset); + VBDEBUG(PREFIX "offset: 0x%08lx\n", offset); /* combine data we want to write and backup data */ memcpy(backup_buf + (cxt->offset - offset), buf, count); if (flash->write(flash, offset, length, backup_buf)) { - debug(PREFIX "SPI write fail\n"); + VBDEBUG(PREFIX "SPI write fail\n"); goto EXIT; } @@ -217,7 +218,7 @@ int firmware_storage_init_spi(firmware_storage_t *file) cxt->offset = 0; cxt->flash = spi_flash_probe(bus, cs, max_hz, spi_mode); if (!cxt->flash) { - debug(PREFIX "fail to init SPI flash at %u:%u\n", bus, cs); + VBDEBUG(PREFIX "fail to init SPI flash at %u:%u\n", bus, cs); free(cxt); return -1; } diff --git a/lib/chromeos/fmap.c b/lib/chromeos/fmap.c index 1540e378912..38232a4f635 100644 --- a/lib/chromeos/fmap.c +++ b/lib/chromeos/fmap.c @@ -9,6 +9,7 @@ */ #include <common.h> +#include <chromeos/common.h> #include <chromeos/fmap.h> off_t fmap_find(const uint8_t *image, size_t image_len) diff --git a/lib/chromeos/gbb_bmpblk.c b/lib/chromeos/gbb_bmpblk.c index e7f9c12ed0e..f36a9cad5b6 100644 --- a/lib/chromeos/gbb_bmpblk.c +++ b/lib/chromeos/gbb_bmpblk.c @@ -13,6 +13,7 @@ #include <common.h> #include <lcd.h> #include <malloc.h> +#include <chromeos/common.h> #include <chromeos/gbb_bmpblk.h> #include <bmpblk_header.h> diff --git a/lib/chromeos/get_firmware_body.c b/lib/chromeos/get_firmware_body.c index 1a312790fcd..63ae5695eac 100644 --- a/lib/chromeos/get_firmware_body.c +++ b/lib/chromeos/get_firmware_body.c @@ -10,6 +10,7 @@ #include <common.h> #include <malloc.h> +#include <chromeos/common.h> #include <chromeos/get_firmware_body.h> #include <load_firmware_fw.h> @@ -56,11 +57,11 @@ int GetFirmwareBody(LoadFirmwareParams *params, uint64_t index) ssize_t n; uint8_t *firmware_body; - debug(PREFIX "firmware index: %d\n", index); + VBDEBUG(PREFIX "firmware index: %d\n", index); /* index = 0: firmware A; 1: firmware B; anything else: invalid */ if (index != 0 && index != 1) { - debug(PREFIX "incorrect index: %d\n", index); + VBDEBUG(PREFIX "incorrect index: %d\n", index); return 1; } @@ -79,16 +80,16 @@ int GetFirmwareBody(LoadFirmwareParams *params, uint64_t index) kbh = (VbKeyBlockHeader *) block; fph = (VbFirmwarePreambleHeader *) (block + kbh->key_block_size); - debug(PREFIX "key block address: %p\n", kbh); - debug(PREFIX "preamble address: %p\n", fph); - debug(PREFIX "firmware body offset: %08lx\n", data_offset); + VBDEBUG(PREFIX "key block address: %p\n", kbh); + VBDEBUG(PREFIX "preamble address: %p\n", fph); + VBDEBUG(PREFIX "firmware body offset: %08lx\n", data_offset); if (file->seek(file->context, data_offset, SEEK_SET) < 0) { - debug(PREFIX "seek to firmware data failed\n"); + VBDEBUG(PREFIX "seek to firmware data failed\n"); return 1; } - debug(PREFIX "body size: %08llx\n", fph->body_signature.data_size); + VBDEBUG(PREFIX "body size: %08llx\n", fph->body_signature.data_size); /* * This loop feeds firmware body into UpdateFirmwareBodyHash. @@ -100,7 +101,7 @@ int GetFirmwareBody(LoadFirmwareParams *params, uint64_t index) n = BLOCK_SIZE < leftover ? BLOCK_SIZE : leftover; n = file->read(file->context, firmware_body, n); if (n <= 0) { - debug(PREFIX "an error has occured " + VBDEBUG(PREFIX "an error has occured " "while reading firmware: %d\n", n); return 1; } diff --git a/lib/chromeos/kernel_shared_data.c b/lib/chromeos/kernel_shared_data.c index a6216159d99..eaeccddcdd0 100644 --- a/lib/chromeos/kernel_shared_data.c +++ b/lib/chromeos/kernel_shared_data.c @@ -9,6 +9,7 @@ */ #include <common.h> +#include <chromeos/common.h> #include <chromeos/kernel_shared_data.h> KernelSharedDataType *get_kernel_shared_data(void) diff --git a/lib/chromeos/load_firmware_helper.c b/lib/chromeos/load_firmware_helper.c index be9e6999707..b365e7716ad 100644 --- a/lib/chromeos/load_firmware_helper.c +++ b/lib/chromeos/load_firmware_helper.c @@ -10,6 +10,7 @@ #include <common.h> #include <malloc.h> +#include <chromeos/common.h> #include <chromeos/get_firmware_body.h> #include <chromeos/load_firmware_helper.h> @@ -39,12 +40,12 @@ int load_gbb(firmware_storage_t *file, void **gbb_data_ptr, gbb_data = malloc(CONFIG_LENGTH_GBB); gbb_size = CONFIG_LENGTH_GBB; if (!gbb_data) { - debug(EMSG_MALLOC, CONFIG_LENGTH_GBB); + VBDEBUG(EMSG_MALLOC, CONFIG_LENGTH_GBB); goto EXIT; } if (firmware_storage_read(file, CONFIG_OFFSET_GBB, gbb_size, gbb_data)) - debug(EMSG_READ_GBB); + VBDEBUG(EMSG_READ_GBB); else retcode = 0; @@ -83,7 +84,7 @@ static int read_verification_block(firmware_storage_t *file, /* read key block header */ if (firmware_storage_read(file, vblock_offset, sizeof(kbh), &kbh)) { - debug(PREFIX "read key block fail\n"); + VBDEBUG(PREFIX "read key block fail\n"); return -1; } key_block_size = kbh.key_block_size; @@ -91,19 +92,19 @@ static int read_verification_block(firmware_storage_t *file, /* read firmware preamble header */ if (firmware_storage_read(file, vblock_offset + key_block_size, sizeof(fph), &fph)) { - debug(PREFIX "read preamble fail\n"); + VBDEBUG(PREFIX "read preamble fail\n"); return -1; } vblock_size = key_block_size + fph.preamble_size; vblock = malloc(vblock_size); if (!vblock) { - debug(PREFIX "malloc verification block fail\n"); + VBDEBUG(PREFIX "malloc verification block fail\n"); return -1; } if (firmware_storage_read(file, vblock_offset, vblock_size, vblock)) { - debug(PREFIX "read verification block fail\n"); + VBDEBUG(PREFIX "read verification block fail\n"); free(vblock); return -1; } @@ -133,21 +134,21 @@ int load_firmware_wrapper(firmware_storage_t *file, file, CONFIG_OFFSET_FW_MAIN_A, CONFIG_OFFSET_FW_MAIN_B); if (load_gbb(file, ¶ms.gbb_data, ¶ms.gbb_size)) { - debug(PREFIX "error: read gbb fail\n"); + VBDEBUG(PREFIX "error: read gbb fail\n"); goto EXIT; } if (read_verification_block(file, CONFIG_OFFSET_VBLOCK_A, ¶ms.verification_block_0, ¶ms.verification_size_0)) { - debug(PREFIX "error: read verification block 0 fail\n"); + VBDEBUG(PREFIX "error: read verification block 0 fail\n"); goto EXIT; } if (read_verification_block(file, CONFIG_OFFSET_VBLOCK_B, ¶ms.verification_block_1, ¶ms.verification_size_1)) { - debug(PREFIX "read verification block 1 fail\n"); + VBDEBUG(PREFIX "read verification block 1 fail\n"); goto EXIT; } @@ -162,7 +163,7 @@ int load_firmware_wrapper(firmware_storage_t *file, status = LoadFirmware(¶ms); if (status == LOAD_FIRMWARE_SUCCESS) { - debug(PREFIX "will jump to rewritable firmware %lld\n", + VBDEBUG(PREFIX "will jump to rewritable firmware %lld\n", params.firmware_index); *firmware_data_ptr = gfbi.firmware_body[params.firmware_index]; diff --git a/lib/chromeos/load_kernel_helper.c b/lib/chromeos/load_kernel_helper.c index 4701625addc..a9fba7755b6 100644 --- a/lib/chromeos/load_kernel_helper.c +++ b/lib/chromeos/load_kernel_helper.c @@ -10,6 +10,7 @@ #include <common.h> #include <part.h> +#include <chromeos/common.h> #include <chromeos/gpio.h> #include <chromeos/kernel_shared_data.h> #include <chromeos/load_kernel_helper.h> @@ -62,7 +63,7 @@ int load_kernel_wrapper_core(LoadKernelParams *params, if (!bypass_load_kernel) { dev_desc = get_bootdev(); if (!dev_desc) { - debug(PREFIX "get_bootdev fail\n"); + VBDEBUG(PREFIX "get_bootdev fail\n"); goto EXIT; } } @@ -83,18 +84,18 @@ int load_kernel_wrapper_core(LoadKernelParams *params, params->nv_context = nvcxt; - debug(PREFIX "call LoadKernel() with parameters...\n"); - debug(PREFIX "shared_data_blob: 0x%p\n", + VBDEBUG(PREFIX "call LoadKernel() with parameters...\n"); + VBDEBUG(PREFIX "shared_data_blob: 0x%p\n", params->shared_data_blob); - debug(PREFIX "bytes_per_lba: %d\n", + VBDEBUG(PREFIX "bytes_per_lba: %d\n", (int) params->bytes_per_lba); - debug(PREFIX "ending_lba: 0x%08x\n", + VBDEBUG(PREFIX "ending_lba: 0x%08x\n", (int) params->ending_lba); - debug(PREFIX "kernel_buffer: 0x%p\n", + VBDEBUG(PREFIX "kernel_buffer: 0x%p\n", params->kernel_buffer); - debug(PREFIX "kernel_buffer_size: 0x%08x\n", + VBDEBUG(PREFIX "kernel_buffer_size: 0x%08x\n", (int) params->kernel_buffer_size); - debug(PREFIX "boot_flags: 0x%08x\n", + VBDEBUG(PREFIX "boot_flags: 0x%08x\n", (int) params->boot_flags); if (!bypass_load_kernel) { @@ -105,13 +106,13 @@ int load_kernel_wrapper_core(LoadKernelParams *params, } EXIT: - debug(PREFIX "LoadKernel status: %d\n", status); + VBDEBUG(PREFIX "LoadKernel status: %d\n", status); if (status == LOAD_KERNEL_SUCCESS) { - debug(PREFIX "partition_number: 0x%08x\n", + VBDEBUG(PREFIX "partition_number: 0x%08x\n", (int) params->partition_number); - debug(PREFIX "bootloader_address: 0x%08x\n", + VBDEBUG(PREFIX "bootloader_address: 0x%08x\n", (int) params->bootloader_address); - debug(PREFIX "bootloader_size: 0x%08x\n", + VBDEBUG(PREFIX "bootloader_size: 0x%08x\n", (int) params->bootloader_size); if (params->partition_number == 2) { @@ -121,7 +122,7 @@ EXIT: setenv("kernelpart", "4"); setenv("rootpart", "5"); } else { - debug(PREFIX "unknown kernel partition: %d\n", + VBDEBUG(PREFIX "unknown kernel partition: %d\n", (int) params->partition_number); status = LOAD_KERNEL_NOT_FOUND; } @@ -141,7 +142,7 @@ EXIT: (GoogleBinaryBlockHeader*) gbb_data; int i; - debug(PREFIX "kernel shared data at %p\n", sd); + VBDEBUG(PREFIX "kernel shared data at %p\n", sd); strcpy((char*) sd->signature, "CHROMEOS"); sd->version = SHARED_MEM_VERSION; @@ -209,24 +210,24 @@ EXIT: memcpy(sd->nvcxt_cache, params->nv_context->raw, VBNV_BLOCK_SIZE); - debug(PREFIX "version %08x\n", sd->version); - debug(PREFIX "chsw %08x\n", sd->chsw); + VBDEBUG(PREFIX "version %08x\n", sd->version); + VBDEBUG(PREFIX "chsw %08x\n", sd->chsw); for (i = 0; i < 5; i++) - debug(PREFIX "binf[%2d] %08x\n", i, sd->binf[i]); - debug(PREFIX "vbnv[ 0] %08x\n", sd->vbnv[0]); - debug(PREFIX "vbnv[ 1] %08x\n", sd->vbnv[1]); - debug(PREFIX "nvcxt %08llx\n", sd->nvcxt_lba); - debug(PREFIX "nvcxt_c "); + VBDEBUG(PREFIX "binf[%2d] %08x\n", i, sd->binf[i]); + VBDEBUG(PREFIX "vbnv[ 0] %08x\n", sd->vbnv[0]); + VBDEBUG(PREFIX "vbnv[ 1] %08x\n", sd->vbnv[1]); + VBDEBUG(PREFIX "nvcxt %08llx\n", sd->nvcxt_lba); + VBDEBUG(PREFIX "nvcxt_c "); for (i = 0; i < VBNV_BLOCK_SIZE; i++) - debug("%02x", sd->nvcxt_cache[i]); + VBDEBUG("%02x", sd->nvcxt_cache[i]); putc('\n'); - debug(PREFIX "write_protect_sw %d\n", sd->write_protect_sw); - debug(PREFIX "recovery_sw %d\n", sd->recovery_sw); - debug(PREFIX "developer_sw %d\n", sd->developer_sw); - debug(PREFIX "hwid \"%s\"\n", sd->hwid); - debug(PREFIX "fwid \"%s\"\n", sd->fwid); - debug(PREFIX "frid \"%s\"\n", sd->frid); - debug(PREFIX "fmap %08x\n", sd->fmap_base); + VBDEBUG(PREFIX "write_protect_sw %d\n", sd->write_protect_sw); + VBDEBUG(PREFIX "recovery_sw %d\n", sd->recovery_sw); + VBDEBUG(PREFIX "developer_sw %d\n", sd->developer_sw); + VBDEBUG(PREFIX "hwid \"%s\"\n", sd->hwid); + VBDEBUG(PREFIX "fwid \"%s\"\n", sd->fwid); + VBDEBUG(PREFIX "frid \"%s\"\n", sd->frid); + VBDEBUG(PREFIX "fmap %08x\n", sd->fmap_base); } return status; @@ -264,7 +265,7 @@ static int load_kernel_config(uint64_t bootloader_address) * http://crosbug.com/14022 */ if (run_command(buf, 0)) { - debug(PREFIX "run_command(%s) fail\n", buf); + VBDEBUG(PREFIX "run_command(%s) fail\n", buf); return 1; } return 0; @@ -331,7 +332,7 @@ static void update_cmdline(char *src, int devnum, int partnum, uint8_t *guid, // sanity check on inputs if (devnum < 0 || devnum > 25 || partnum < 1 || partnum > 99) { - debug(PREFIX "insane input: %d, %d\n", devnum, partnum); + VBDEBUG(PREFIX "insane input: %d, %d\n", devnum, partnum); devnum = 0; partnum = 3; } @@ -381,28 +382,28 @@ static int boot_kernel(LoadKernelParams *params) char load_address[32]; char *argv[2] = { "bootm", load_address }; - debug(PREFIX "boot_kernel\n"); - debug(PREFIX "kernel_buffer: 0x%p\n", + VBDEBUG(PREFIX "boot_kernel\n"); + VBDEBUG(PREFIX "kernel_buffer: 0x%p\n", params->kernel_buffer); - debug(PREFIX "bootloader_address: 0x%08x\n", + VBDEBUG(PREFIX "bootloader_address: 0x%08x\n", (int) params->bootloader_address); if (load_kernel_config(params->bootloader_address)) { - debug(PREFIX "error: load kernel config failed\n"); + VBDEBUG(PREFIX "error: load kernel config failed\n"); return; } if ((cmdline = getenv("bootargs"))) { - debug(PREFIX "cmdline before update: %s\n", cmdline); + VBDEBUG(PREFIX "cmdline before update: %s\n", cmdline); update_cmdline(cmdline, get_device_number(), params->partition_number + 1, params->partition_guid, cmdline_buf); setenv("bootargs", cmdline_buf); - debug(PREFIX "cmdline after update: %s\n", getenv("bootargs")); + VBDEBUG(PREFIX "cmdline after update: %s\n", getenv("bootargs")); } else { - debug(PREFIX "bootargs == NULL\n"); + VBDEBUG(PREFIX "bootargs == NULL\n"); } /* @@ -412,11 +413,11 @@ static int boot_kernel(LoadKernelParams *params) * by calling do_bootm. */ sprintf(load_address, "0x%p", params->kernel_buffer); - debug(PREFIX "run command: %s %s\n", argv[0], argv[1]); + VBDEBUG(PREFIX "run command: %s %s\n", argv[0], argv[1]); do_bootm(NULL, 0, sizeof(argv)/sizeof(*argv), argv); /* should never reach here! */ - debug(PREFIX "error: do_bootm() returned\n"); + VBDEBUG(PREFIX "error: do_bootm() returned\n"); return LOAD_KERNEL_INVALID; } @@ -440,7 +441,7 @@ int load_and_boot_kernel(void *gbb_data, uint64_t gbb_size, * Even if we can't read nvcxt, we continue anyway because this * is developer firmware */ - debug(PREFIX "fail to read nvcontext\n"); + VBDEBUG(PREFIX "fail to read nvcontext\n"); } prepare_bootargs(); @@ -448,7 +449,7 @@ int load_and_boot_kernel(void *gbb_data, uint64_t gbb_size, status = load_kernel_wrapper(¶ms, gbb_data, gbb_size, boot_flags, &nvcxt, NULL); - debug(PREFIX "load_kernel_wrapper returns %d\n", status); + VBDEBUG(PREFIX "load_kernel_wrapper returns %d\n", status); if (VbNvTeardown(&nvcxt) || (nvcxt.raw_changed && write_nvcontext(&nvcxt))) { @@ -456,7 +457,7 @@ int load_and_boot_kernel(void *gbb_data, uint64_t gbb_size, * Even if we can't read nvcxt, we continue anyway because this * is developer firmware */ - debug(PREFIX "fail to write nvcontext\n"); + VBDEBUG(PREFIX "fail to write nvcontext\n"); } if (status == LOAD_KERNEL_SUCCESS) diff --git a/lib/chromeos/os_storage.c b/lib/chromeos/os_storage.c index 64ee57ab4f4..a47ab71615b 100644 --- a/lib/chromeos/os_storage.c +++ b/lib/chromeos/os_storage.c @@ -17,6 +17,7 @@ #ifdef CONFIG_USB_STORAGE #include <usb.h> #endif +#include <chromeos/common.h> #include <chromeos/os_storage.h> #include <linux/string.h> /* for strcmp */ @@ -64,7 +65,7 @@ ulong get_limit(void) uint64_t get_bytes_per_lba(void) { if (!bootdev_config.dev_desc) { - debug(PREFIX "get_bytes_per_lba: not dev_desc set\n"); + VBDEBUG(PREFIX "get_bytes_per_lba: not dev_desc set\n"); return ~0ULL; } @@ -79,7 +80,7 @@ uint64_t get_ending_lba(void) bytes_per_lba = get_bytes_per_lba(); if (bytes_per_lba == ~0ULL) { - debug(PREFIX "get_ending_lba: get bytes_per_lba fail\n"); + VBDEBUG(PREFIX "get_ending_lba: get bytes_per_lba fail\n"); goto EXIT; } @@ -89,7 +90,7 @@ uint64_t get_ending_lba(void) buf = static_buf; if (BootDeviceReadLBA(1, 1, buf)) { - debug(PREFIX "get_ending_lba: read primary GPT header fail\n"); + VBDEBUG(PREFIX "get_ending_lba: read primary GPT header fail\n"); goto EXIT; } @@ -125,7 +126,7 @@ int set_bootdev(char *ifname, int dev, int part) disk_partition_t part_info; if ((bootdev_config.dev_desc = get_dev(ifname, dev)) == NULL) { - debug(PREFIX "block device not supported\n"); + VBDEBUG(PREFIX "block device not supported\n"); goto cleanup; } @@ -137,7 +138,7 @@ int set_bootdev(char *ifname, int dev, int part) } if (get_partition_info(bootdev_config.dev_desc, part, &part_info)) { - debug(PREFIX "cannot find partition\n"); + VBDEBUG(PREFIX "cannot find partition\n"); goto cleanup; } @@ -195,7 +196,7 @@ int BootDeviceWriteLBA(uint64_t lba_start, uint64_t lba_count, int is_mmc_storage_present(int mmc_device_number) { if (mmc_device_number >= MMC_DEV_INSTANCES) { - debug(PREFIX "%d >= MMC_DEV_INSTANCES\n", mmc_device_number); + VBDEBUG(PREFIX "%d >= MMC_DEV_INSTANCES\n", mmc_device_number); return 0; } @@ -214,7 +215,7 @@ int is_mmc_storage_present(int mmc_device_number) int is_usb_storage_present(int usb_controller_number) { if (usb_controller_number >= CONFIG_USB_CONTROLLER_INSTANCES) { - debug(PREFIX "%d >= CONFIG_USB_CONTROLLER_INSTANCES\n", + VBDEBUG(PREFIX "%d >= CONFIG_USB_CONTROLLER_INSTANCES\n", usb_controller_number); return 0; } @@ -226,7 +227,7 @@ int is_usb_storage_present(int usb_controller_number) extern int USB_EHCI_TEGRA_BASE_ADDR; extern int USB_base_addr[]; if (!USB_base_addr[usb_controller_number]) { - debug(PREFIX "unknown USB controller: %d\n", + VBDEBUG(PREFIX "unknown USB controller: %d\n", usb_controller_number); return 0; } @@ -259,7 +260,7 @@ int is_any_storage_device_plugged(int boot_probed_device) return 1; } #else - debug(PREFIX "MMC storage is not enabled\n"); + VBDEBUG(PREFIX "MMC storage is not enabled\n"); #endif #ifdef CONFIG_USB_STORAGE @@ -270,7 +271,7 @@ int is_any_storage_device_plugged(int boot_probed_device) return 1; } #else - debug(PREFIX "USB storage is not enabled\n"); + VBDEBUG(PREFIX "USB storage is not enabled\n"); #endif return 0; diff --git a/lib/chromeos/vboot_nvstorage_helper.c b/lib/chromeos/vboot_nvstorage_helper.c index 7e326968ce9..9d2b0a6957c 100644 --- a/lib/chromeos/vboot_nvstorage_helper.c +++ b/lib/chromeos/vboot_nvstorage_helper.c @@ -35,6 +35,7 @@ */ #include <common.h> +#include <chromeos/common.h> #include <chromeos/power_management.h> #include <chromeos/vboot_nvstorage_helper.h> @@ -76,12 +77,12 @@ static int prepare_access_nvcontext(block_dev_desc_t **dev_desc_ptr, dev_desc = get_dev("mmc", 0); if (dev_desc == NULL) { - debug(PREFIX "get_dev(0) fail\n"); + VBDEBUG(PREFIX "get_dev(0) fail\n"); return -1; } if (dev_desc->block_read(dev_desc->dev, 1, 1, buf) < 0) { - debug(PREFIX "read primary GPT table fail\n"); + VBDEBUG(PREFIX "read primary GPT table fail\n"); return -1; } @@ -99,19 +100,19 @@ static int access_nvcontext(VbNvContext *nvcxt, int is_read) uint8_t buf[512]; if (set_mmc_device(0, &last_dev)) { - debug(PREFIX "set_mmc_device(0) fail\n"); + VBDEBUG(PREFIX "set_mmc_device(0) fail\n"); return -1; } - debug(PREFIX "last_dev: %d\n", last_dev); + VBDEBUG(PREFIX "last_dev: %d\n", last_dev); if (prepare_access_nvcontext(&dev_desc, &nvcxt_lba)) { - debug(PREFIX "prepare_access_nvcontext fail\n"); + VBDEBUG(PREFIX "prepare_access_nvcontext fail\n"); goto EXIT; } if (dev_desc->block_read(dev_desc->dev, nvcxt_lba, 1, buf) < 0) { - debug(PREFIX "block_read fail\n"); + VBDEBUG(PREFIX "block_read fail\n"); goto EXIT; } @@ -121,7 +122,7 @@ static int access_nvcontext(VbNvContext *nvcxt, int is_read) memcpy(buf, nvcxt->raw, VBNV_BLOCK_SIZE); if (dev_desc->block_write(dev_desc->dev, nvcxt_lba, 1, buf) < 0) { - debug(PREFIX "block_write fail\n"); + VBDEBUG(PREFIX "block_write fail\n"); goto EXIT; } } @@ -142,12 +143,12 @@ uint64_t get_nvcxt_lba(void) uint64_t nvcxt_lba = ~0ULL; if (set_mmc_device(0, &last_dev)) { - debug(PREFIX "set_mmc_device(0) fail\n"); + VBDEBUG(PREFIX "set_mmc_device(0) fail\n"); return ~0ULL; } if (prepare_access_nvcontext(&dev_desc, &nvcxt_lba)) - debug(PREFIX "prepare_access_nvcontext fail\n"); + VBDEBUG(PREFIX "prepare_access_nvcontext fail\n"); /* restore previous device */ if (last_dev != -1 && last_dev != 0) @@ -171,19 +172,19 @@ int clear_recovery_request(void) VbNvContext nvcxt; if (read_nvcontext(&nvcxt) || VbNvSetup(&nvcxt)) { - debug(PREFIX "cannot read nvcxt\n"); + VBDEBUG(PREFIX "cannot read nvcxt\n"); return 1; } if (VbNvSet(&nvcxt, VBNV_RECOVERY_REQUEST, VBNV_RECOVERY_NOT_REQUESTED)) { - debug(PREFIX "cannot clear VBNV_RECOVERY_REQUEST\n"); + VBDEBUG(PREFIX "cannot clear VBNV_RECOVERY_REQUEST\n"); return 1; } if (VbNvTeardown(&nvcxt) || (nvcxt.raw_changed && write_nvcontext(&nvcxt))) { - debug(PREFIX "cannot write nvcxt\n"); + VBDEBUG(PREFIX "cannot write nvcxt\n"); return 1; } @@ -196,22 +197,22 @@ void reboot_to_recovery_mode(uint32_t reason) nvcxt = &nvcontext; if (read_nvcontext(nvcxt) || VbNvSetup(nvcxt)) { - debug(PREFIX "cannot read nvcxt\n"); + VBDEBUG(PREFIX "cannot read nvcxt\n"); goto FAIL; } - debug(PREFIX "store recovery cookie in recovery field\n"); + VBDEBUG(PREFIX "store recovery cookie in recovery field\n"); if (VbNvSet(nvcxt, VBNV_RECOVERY_REQUEST, reason) || VbNvTeardown(nvcxt) || (nvcxt->raw_changed && write_nvcontext(nvcxt))) { - debug(PREFIX "cannot write back nvcxt"); + VBDEBUG(PREFIX "cannot write back nvcxt"); goto FAIL; } - debug(PREFIX "reboot to recovery mode\n"); + VBDEBUG(PREFIX "reboot to recovery mode\n"); cold_reboot(); - debug(PREFIX "error: cold_reboot() returned\n"); + VBDEBUG(PREFIX "error: cold_reboot() returned\n"); FAIL: /* FIXME: bring up a sad face? */ printf("Please reset and press recovery button when reboot.\n"); |