LoadFirmware() and LoadKernel() handling for test errors
Change-Id: Icecfcab8f5cc30e80da7a2d77a1b1729f5094fee
R=wfrichar@chromium.org
BUG=13107
TEST=make && make runtests
Review URL: http://codereview.chromium.org/6673048
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index ee2890c..faa9c48 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -135,6 +135,7 @@
uint64_t lowest_version = 0xFFFFFFFF;
int rec_switch, dev_switch;
BootMode boot_mode;
+ uint32_t test_err = 0;
uint32_t status;
/* TODO: differentiate between finding an invalid kernel (found_partitions>0)
@@ -156,6 +157,29 @@
goto LoadKernelExit;
}
+ /* Handle test errors */
+ VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
+ if (VBNV_TEST_ERROR_LOAD_KERNEL == test_err) {
+ /* Get error code */
+ VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err);
+ /* Clear test params so we don't repeat the error */
+ VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0);
+ VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0);
+ /* Handle error codes */
+ switch (test_err) {
+ case LOAD_KERNEL_RECOVERY:
+ recovery = VBNV_RECOVERY_RW_TEST_LK;
+ goto LoadKernelExit;
+ case LOAD_KERNEL_NOT_FOUND:
+ case LOAD_KERNEL_INVALID:
+ case LOAD_KERNEL_REBOOT:
+ retval = test_err;
+ goto LoadKernelExit;
+ default:
+ break;
+ }
+ }
+
/* Initialization */
blba = params->bytes_per_lba;
kbuf_sectors = KBUF_SIZE / blba;