summaryrefslogtreecommitdiff
path: root/chip/ish/system.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2019-05-29 15:51:48 -0600
committerJack Rosenthal <jrosenth@chromium.org>2019-06-06 19:55:40 +0000
commitc723e723392aabc35747a6678b4b7931d7aeddb7 (patch)
tree2ebdd22275c369d0580641ddb23b8e782ff0b91a /chip/ish/system.c
parente12b71b1fe82af7bc804004147f33da5e29cced1 (diff)
downloadchrome-ec-c723e723392aabc35747a6678b4b7931d7aeddb7.tar.gz
ish: use magic number to verify persistent data
Move persistent data definitions to a structure and have linker script define the address of the symbol into the AON ROM (persistent data storage). Use the magic number "ISHd" to verify persistent data storage and copy to static memory when valid. Commit changes from the local copy during reset. BUG=b:133779707,b:133647823,b:132059981 BRANCH=none TEST=power-on is only reset flag under cold reset, panic data persists, watchdog reset produces correct reset flags, UART always printing system info on boot Change-Id: I65a458cc2656f8fe26361ef2117ceb5439edff6c Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1636293 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Diffstat (limited to 'chip/ish/system.c')
-rw-r--r--chip/ish/system.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/chip/ish/system.c b/chip/ish/system.c
index 1af3499f62..0d778eaa5e 100644
--- a/chip/ish/system.c
+++ b/chip/ish/system.c
@@ -3,30 +3,23 @@
* found in the LICENSE file.
*/
-/* System module ISH (Not implemented) */
-
#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
#include "gpio.h"
+#include "hooks.h"
#include "host_command.h"
#include "ish_fwst.h"
+#include "ish_persistent_data.h"
+#include "power_mgt.h"
#include "registers.h"
#include "shared_mem.h"
+#include "spi.h"
#include "system.h"
-#include "hooks.h"
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "spi.h"
-#include "power_mgt.h"
-
-/* Indices for hibernate data registers (RAM backed by VBAT) */
-enum hibdata_index {
- HIBDATA_INDEX_SCRATCHPAD = 0, /* General-purpose scratchpad */
- HIBDATA_INDEX_SAVED_RESET_FLAGS /* Saved reset flags */
-};
int system_is_reboot_warm(void)
{
@@ -37,35 +30,34 @@ int system_is_reboot_warm(void)
void system_pre_init(void)
{
ish_fwst_set_fw_status(FWSTS_FW_IS_RUNNING);
-
task_enable_irq(ISH_FABRIC_IRQ);
-
- if (IS_ENABLED(CONFIG_LOW_POWER_IDLE))
- ish_pm_init();
-
- system_set_reset_flags(chip_read_reset_flags());
+ ish_pm_init();
+ ish_persistent_data_init();
}
void chip_save_reset_flags(uint32_t flags)
{
- ISH_RESET_FLAGS = flags;
+ ish_persistent_data.reset_flags = flags;
}
uint32_t chip_read_reset_flags(void)
{
- uint32_t flags = ISH_RESET_FLAGS;
-
- if (flags)
- return flags;
-
- /* Flags are zero? Assume we came up from a cold reset */
- return RESET_FLAG_POWER_ON;
+ return ish_persistent_data.reset_flags;
}
void system_reset(int flags)
{
uint32_t save_flags;
+ /*
+ * We can't save any data when we do an ish_mia_reset(). Take
+ * the quick path out.
+ */
+ if (!IS_ENABLED(CONFIG_ISH_PM_AONTASK) || flags & SYSTEM_RESET_HARD) {
+ ish_mia_reset();
+ __builtin_unreachable();
+ }
+
system_encode_save_flags(flags, &save_flags);
if (flags & SYSTEM_RESET_AP_WATCHDOG)
@@ -73,15 +65,8 @@ void system_reset(int flags)
chip_save_reset_flags(save_flags);
- /*
- * ish_pm_reset() does more (poweroff main SRAM, etc) than
- * ish_mia_reset() which just resets the ISH minute-ia cpu core
- */
- if (!IS_ENABLED(CONFIG_LOW_POWER_IDLE) || flags & SYSTEM_RESET_HARD)
- ish_mia_reset();
- else
- ish_pm_reset();
-
+ ish_persistent_data_commit();
+ ish_pm_reset();
__builtin_unreachable();
}