Remove old scratchpad-based reboot-to-image interface

Now that we can jump directly to other images, we don't need this.

We jump to image A by default, unless the recovery button or signal is asserted.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8562
TEST=manual

Reboot -> runs image A
Reboot with reload (F3) held down -> runs RO
Reboot with 'dut-control goog_rec_mode:on' -> runs RO

Change-Id: I8259fe0d738ce0ca897d2f4427d8cf61858b8901
This commit is contained in:
Randall Spangler
2012-03-20 09:40:00 -07:00
parent 61748b4f04
commit 41e3b58258
3 changed files with 39 additions and 69 deletions

View File

@@ -466,3 +466,9 @@ void keyboard_put_char(uint8_t chr, int send_irq)
{
/* TODO: needs to be implemented */
}
int keyboard_scan_recovery_pressed(void)
{
/* TODO: (crosbug.com/p/8573) needs to be implemented */
return 0;
}

View File

@@ -277,6 +277,15 @@ static int command_sysjump(int argc, char **argv)
DECLARE_CONSOLE_COMMAND(sysjump, command_sysjump);
static int command_reboot(int argc, char **argv)
{
uart_puts("Rebooting!\n\n\n");
uart_flush_output();
system_reset(1);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(reboot, command_reboot);
/*****************************************************************************/
/* Host commands */

View File

@@ -1,95 +1,50 @@
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2012 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.
*/
/* Verified boot module for Chrome EC */
#include "common.h" /* for CONFIG_REBOOT_EC */
#include "console.h"
#include "host_command.h" /* for CONFIG_REBOOT_EC */
#include "lpc_commands.h" /* for CONFIG_REBOOT_EC */
#include "gpio.h"
#include "keyboard_scan.h"
#include "system.h"
#include "uart.h"
#include "util.h"
#include "vboot.h"
#define SCRATCHPAD_EMPTY 0
#define SCRATCHPAD_REQUEST_A 0xb00daaaa
#define SCRATCHPAD_REQUEST_B 0xb00dbbbb
#define SCRATCHPAD_SELECTED_A 0x0000d1da
#define SCRATCHPAD_SELECTED_B 0x0000d1db
#define SCRATCHPAD_SELECTED_RO 0x0000d1d0
#define SCRATCHPAD_FAILED_A 0x0000eeea
#define SCRATCHPAD_FAILED_B 0x0000eeeb
/* Jumps to one of the RW images if necessary. */
static void jump_to_other_image(void)
{
int s;
/* Only jump to another image if we're currently in RO */
if (system_get_image_copy() != SYSTEM_IMAGE_RO)
return; /* Not in RO firmware, so ignore scratchpad */
return;
if (system_get_reset_cause() != SYSTEM_RESET_SOFT_COLD) {
/* In RO firmware, but not because of a warm boot.
* Stay in RO regardless of scratchpad, and clear it
* so we don't use it on the next boot. */
system_set_scratchpad(SCRATCHPAD_EMPTY);
/* Don't jump if recovery requested */
if (keyboard_scan_recovery_pressed()) {
uart_puts("Vboot staying in RO because key pressed.\n");
return;
}
/* TODO: check recovery button; if it's pressed, stay in RO */
/* Check for a scratchpad value we recognize. Clear the
* scratchpad before jumping, so we only do this once. */
s = system_get_scratchpad();
if (s == SCRATCHPAD_REQUEST_A) {
system_set_scratchpad(SCRATCHPAD_SELECTED_A);
system_run_image_copy(SYSTEM_IMAGE_RW_A);
/* Shouldn't normally return; if we did, flag error */
system_set_scratchpad(SCRATCHPAD_FAILED_A);
} else if (s == SCRATCHPAD_REQUEST_B) {
system_set_scratchpad(SCRATCHPAD_SELECTED_B);
system_run_image_copy(SYSTEM_IMAGE_RW_B);
/* Shouldn't normally return; if we did, flag error */
system_set_scratchpad(SCRATCHPAD_FAILED_B);
} else {
system_set_scratchpad(SCRATCHPAD_EMPTY);
#if !defined(BOARD_daisy) && !defined(BOARD_discovery)
/* TODO: (crosbug.com/p/8572) Daisy and discovery don't define a GPIO
* for the recovery signal from servo, so can't check it. */
if (gpio_get_level(GPIO_RECOVERYn) == 0) {
uart_puts("Vboot staying in RO due to recovery signal.\n");
return;
}
#endif
#ifdef BOARD_link
/* TODO: (crosbug.com/p/8561) once daisy can warm-boot to another
* image, enable this there too. */
/* TODO: real verified boot (including recovery reason); for now, just
* jump to image A. */
system_run_image_copy(SYSTEM_IMAGE_RW_A);
#endif
}
/*****************************************************************************/
/* Console commands */
static int command_reboot(int argc, char **argv)
{
/* Handle request to boot to a specific image */
if (argc >= 2) {
if (!strcasecmp(argv[1], "a")) {
uart_puts("Rebooting to image A!\n\n\n");
system_set_scratchpad(SCRATCHPAD_REQUEST_A);
} else if (!strcasecmp(argv[1], "b")) {
uart_puts("Rebooting to image B!\n\n\n");
system_set_scratchpad(SCRATCHPAD_REQUEST_B);
} else {
uart_puts("Usage: reboot [ A | B ]\n");
return EC_ERROR_UNKNOWN;
}
} else {
uart_puts("Rebooting to RO!\n\n\n");
}
uart_flush_output();
/* TODO - param to specify warm/cold */
system_reset(1);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(reboot, command_reboot);
/*****************************************************************************/
/* Initialization */