diff options
-rw-r--r-- | chip/it83xx/system.c | 15 | ||||
-rw-r--r-- | core/nds32/cpu.h | 1 | ||||
-rw-r--r-- | core/nds32/init.S | 9 | ||||
-rw-r--r-- | core/nds32/task.c | 3 |
4 files changed, 28 insertions, 0 deletions
diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c index 3ff3921d1b..23e832b902 100644 --- a/chip/it83xx/system.c +++ b/chip/it83xx/system.c @@ -9,6 +9,7 @@ #include "cpu.h" #include "ec2i_chip.h" #include "flash.h" +#include "hooks.h" #include "host_command.h" #include "intc.h" #include "registers.h" @@ -80,6 +81,20 @@ static void check_reset_cause(void) system_set_reset_flags(flags); } +static void system_reset_cause_is_unknown(void) +{ + /* No reset cause and not sysjump. */ + if (!system_get_reset_flags() && !system_jumped_to_this_image()) + /* + * We decrease 4 or 2 for "ec_reset_lp" here, that depend on + * which jump and link instruction has executed. + * (jral5: LP=PC+2, jal: LP=PC+4) + */ + ccprintf("===Unknown reset! jump from %x or %x===\n", + ec_reset_lp - 4, ec_reset_lp - 2); +} +DECLARE_HOOK(HOOK_INIT, system_reset_cause_is_unknown, HOOK_PRIO_FIRST); + int system_is_reboot_warm(void) { uint32_t reset_flags; diff --git a/core/nds32/cpu.h b/core/nds32/cpu.h index dcf668bd24..f5e4353cc3 100644 --- a/core/nds32/cpu.h +++ b/core/nds32/cpu.h @@ -55,5 +55,6 @@ static inline uint32_t get_itype(void) void cpu_init(void); extern uint32_t ilp; +extern uint32_t ec_reset_lp; #endif /* __CROS_EC_CPU_H */ diff --git a/core/nds32/init.S b/core/nds32/init.S index 4db057dd91..1df5ae79ae 100644 --- a/core/nds32/init.S +++ b/core/nds32/init.S @@ -119,6 +119,12 @@ reset: /* Set system stack pointer. */ la $sp, stack_end + /* + * move content of lp into r5 and then store the content + * into variable "ec_reset_lp" later after memory initialization. + */ + mov55 $r5, $lp + /* map/enable the 16kB of DLM at 0x00080000 */ li $r0, 0x00080005 mtsr $r0, $mr7 @@ -163,6 +169,9 @@ data_loop: swi.bi $r3, [$r1], 4 bne $r1, $r2, data_loop + /* store the content of r5 (lp after reset) into "ec_reset_lp" */ + swi.gp $r5, [ + ec_reset_lp] + /* we switch to our own exception vectors */ /* go back to it level 0 with HW interrupts globally disabled */ li $r4, 0x70008 diff --git a/core/nds32/task.c b/core/nds32/task.c index 9a77114651..f713c52442 100644 --- a/core/nds32/task.c +++ b/core/nds32/task.c @@ -180,6 +180,9 @@ int cpu_int_entry_number; */ uint32_t ilp; +/* This variable is used to save link pointer register at EC reset. */ +uint32_t ec_reset_lp; + static inline task_ *__task_id_to_ptr(task_id_t id) { return tasks + id; |