summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2014-07-29 14:14:45 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-30 08:39:56 +0000
commit61d0caf338bddf3842809c9b833f26a0eab769fa (patch)
tree6a31d7e554afa92889ebd36c933bb858be923890
parent5871a19f5cf7687afdc66134be2ce61694461090 (diff)
downloadchrome-ec-61d0caf338bddf3842809c9b833f26a0eab769fa.tar.gz
ryu: Use get_base to access flash location
Previous assumption assumed that the flash was remapped to address 0. This is not the case anymore since cl/210063 BUG=chrome-os-partner:30997 TEST=Check we can boot the EC now. BRANCH=None Change-Id: I46e1dc0ad840b21661aa5d87817369b29a659c9b Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/210407
-rw-r--r--common/system.c71
1 files changed, 32 insertions, 39 deletions
diff --git a/common/system.c b/common/system.c
index dc761eb490..2bbf572f8e 100644
--- a/common/system.c
+++ b/common/system.c
@@ -90,6 +90,36 @@ static enum ec_reboot_cmd reboot_at_shutdown;
/* On-going actions preventing going into deep-sleep mode */
uint32_t sleep_mask;
+/**
+ * Return the base pointer for the image copy, or 0xffffffff if error.
+ */
+static uintptr_t get_base(enum system_image_copy_t copy)
+{
+ switch (copy) {
+ case SYSTEM_IMAGE_RO:
+ return CONFIG_FLASH_BASE + CONFIG_FW_RO_OFF;
+ case SYSTEM_IMAGE_RW:
+ return CONFIG_FLASH_BASE + CONFIG_FW_RW_OFF;
+ default:
+ return 0xffffffff;
+ }
+}
+
+/**
+ * Return the size of the image copy, or 0 if error.
+ */
+static uint32_t get_size(enum system_image_copy_t copy)
+{
+ switch (copy) {
+ case SYSTEM_IMAGE_RO:
+ return CONFIG_FW_RO_SIZE;
+ case SYSTEM_IMAGE_RW:
+ return CONFIG_FW_RW_SIZE;
+ default:
+ return 0;
+ }
+}
+
int system_is_locked(void)
{
if (force_locked)
@@ -297,13 +327,8 @@ int system_get_image_used(enum system_image_copy_t copy)
const uint8_t *image;
int size = 0;
- if (copy == SYSTEM_IMAGE_RO) {
- image = (const uint8_t *)CONFIG_FW_RO_OFF;
- size = CONFIG_FW_RO_SIZE;
- } else if (copy == SYSTEM_IMAGE_RW) {
- image = (const uint8_t *)CONFIG_FW_RW_OFF;
- size = CONFIG_FW_RW_SIZE;
- }
+ image = (const uint8_t *)(get_base(copy));
+ size = get_size(copy);
if (size <= 0)
return 0;
@@ -396,38 +421,6 @@ static void jump_to_image(uintptr_t init_addr)
resetvec();
}
-/**
- * Return the base pointer for the image copy, or 0xffffffff if error.
- */
-static uint32_t get_base(enum system_image_copy_t copy)
-{
- switch (copy) {
- case SYSTEM_IMAGE_RO:
- return CONFIG_FLASH_BASE + CONFIG_FW_RO_OFF;
- case SYSTEM_IMAGE_RW:
- return CONFIG_FLASH_BASE + CONFIG_FW_RW_OFF;
- default:
- return 0xffffffff;
- }
-}
-
-/**
- * Return the size of the image copy, or 0 if error.
- */
-#ifndef EMU_BUILD
-static uint32_t get_size(enum system_image_copy_t copy)
-{
- switch (copy) {
- case SYSTEM_IMAGE_RO:
- return CONFIG_FW_RO_SIZE;
- case SYSTEM_IMAGE_RW:
- return CONFIG_FW_RW_SIZE;
- default:
- return 0;
- }
-}
-#endif
-
int system_run_image_copy(enum system_image_copy_t copy)
{
uintptr_t base;