diff --git a/hal/armv7a/exceptions.c b/hal/armv7a/exceptions.c index 6bd9725e..65013f44 100644 --- a/hal/armv7a/exceptions.c +++ b/hal/armv7a/exceptions.c @@ -133,6 +133,10 @@ void exceptions_dispatch(unsigned int n, exc_context_t *ctx) hal_exceptionsDumpContext(buff, ctx, n); hal_consolePrint(buff); +#ifdef NDEBUG + hal_cpuReboot(); +#endif + for (;;) hal_cpuHalt(); } diff --git a/hal/armv7a/imx6ull/hal.c b/hal/armv7a/imx6ull/hal.c index 634d28a3..76d92cd7 100644 --- a/hal/armv7a/imx6ull/hal.c +++ b/hal/armv7a/imx6ull/hal.c @@ -247,3 +247,11 @@ int hal_memoryGetNextEntry(addr_t start, addr_t end, mapent_t *entry) return -1; } + + +void hal_cpuReboot(void) +{ + _imx6ull_softRst(); + + __builtin_unreachable(); +} diff --git a/hal/armv7a/imx6ull/imx6ull.c b/hal/armv7a/imx6ull/imx6ull.c index ff3d1125..7f32bac4 100644 --- a/hal/armv7a/imx6ull/imx6ull.c +++ b/hal/armv7a/imx6ull/imx6ull.c @@ -122,6 +122,10 @@ enum { }; +/* WDOG registers */ +enum { wdog_wcr = 0, wdog_wsr, wdog_wrsr, wdog_wicr, wdog_wmcr }; + + /* Reserved slots */ static const char ccm_reserved[] = { clk_asrc + 1, clk_ipsync_ip2apb_tzasc1_ipg + 1, clk_pxp + 1, clk_mmdc_core_aclk_fast_core_p0 + 1, clk_iomux_snvs_gpr + 1, clk_usdhc2 + 1 }; @@ -137,9 +141,21 @@ struct { volatile u32 *iomux_snvs; volatile u32 *mmdc; + + volatile u16 *wdog; } imx6ull_common; +void _imx6ull_softRst(void) +{ + /* assert SRS signal by writing 0 to bit 4 and 1 to bit 2 (WDOG enable) */ + *(imx6ull_common.wdog + wdog_wcr) = (1 << 2); + hal_cpuDataMemoryBarrier(); + for (;;) { + } +} + + static int imx6ull_isValidDev(int dev) { int i; @@ -373,6 +389,8 @@ void imx6ull_init(void) imx6ull_common.iomux_gpr = (void *)0x020e4000; imx6ull_common.iomux_snvs = (void *)0x02290000; + imx6ull_common.wdog = (void *)0x020bc000; + imx6ull_pllInit(); /* Set ARM clock to 792 MHz; set ARM clock divider to 1 */ diff --git a/hal/armv7a/imx6ull/imx6ull.h b/hal/armv7a/imx6ull/imx6ull.h index 76b3308b..e4c7acc3 100644 --- a/hal/armv7a/imx6ull/imx6ull.h +++ b/hal/armv7a/imx6ull/imx6ull.h @@ -169,6 +169,9 @@ enum { #define CLK_SEL_QSPI1_PLL3_PFD2 5 +extern void _imx6ull_softRst(void); + + extern int imx6ull_setDevClock(int dev, unsigned int state); diff --git a/hal/armv7m/cpu.c b/hal/armv7m/cpu.c index 1457966c..fe0444b1 100644 --- a/hal/armv7m/cpu.c +++ b/hal/armv7m/cpu.c @@ -298,7 +298,7 @@ unsigned int hal_cpuID(void) } -void hal_cpuReset(void) +void hal_cpuReboot(void) { hal_cpuDataSyncBarrier(); *(cpu_common.scb + scb_aircr) = ((0x5fa << 16) | (*(cpu_common.scb + scb_aircr) & (0x700)) | (1 << 0x02)); diff --git a/hal/armv7m/cpu.h b/hal/armv7m/cpu.h index cda2ca0c..dff06d69 100644 --- a/hal/armv7m/cpu.h +++ b/hal/armv7m/cpu.h @@ -87,7 +87,7 @@ extern void hal_invalDCacheAll(void); extern unsigned int hal_cpuID(void); -extern void hal_cpuReset(void); +extern void hal_cpuReboot(void); extern void hal_cpuInit(void); diff --git a/hal/armv7m/exceptions.c b/hal/armv7m/exceptions.c index 042652bb..380d96b7 100644 --- a/hal/armv7m/exceptions.c +++ b/hal/armv7m/exceptions.c @@ -131,7 +131,7 @@ __attribute__((section(".noxip"))) void hal_exceptionsDispatch(unsigned int n, s hal_consolePrint(buff); #ifdef NDEBUG - hal_cpuReset(); + hal_cpuReboot(); #endif for (;;) { diff --git a/hal/armv7m/imxrt/hal.c b/hal/armv7m/imxrt/hal.c index e19f34a1..24678b24 100644 --- a/hal/armv7m/imxrt/hal.c +++ b/hal/armv7m/imxrt/hal.c @@ -166,13 +166,6 @@ int hal_memoryGetNextEntry(addr_t start, addr_t end, mapent_t *entry) } -void hal_cpuReboot(void) -{ - hal_cpuReset(); - __builtin_unreachable(); -} - - int hal_cpuJump(void) { if (hal_common.entry == (addr_t)-1) diff --git a/hal/armv7m/stm32/hal.c b/hal/armv7m/stm32/hal.c index f276fd17..acdf2d38 100644 --- a/hal/armv7m/stm32/hal.c +++ b/hal/armv7m/stm32/hal.c @@ -171,13 +171,6 @@ int hal_memoryGetNextEntry(addr_t start, addr_t end, mapent_t *entry) } -void hal_cpuReboot(void) -{ - hal_cpuReset(); - __builtin_unreachable(); -} - - int hal_cpuJump(void) { if (hal_common.entry == (addr_t)-1) diff --git a/hal/armv8m/cpu.c b/hal/armv8m/cpu.c index 1f606cae..23e368ab 100644 --- a/hal/armv8m/cpu.c +++ b/hal/armv8m/cpu.c @@ -254,7 +254,7 @@ unsigned int hal_cpuID(void) } -void hal_cpuReset(void) +void hal_cpuReboot(void) { hal_cpuDataSyncBarrier(); *(cpu_common.scb + scb_aircr) = ((0x5fau << 16) | (*(cpu_common.scb + scb_aircr) & (0x700u)) | (1 << 0x02)); diff --git a/hal/armv8m/cpu.h b/hal/armv8m/cpu.h index 91ff24bf..b199088c 100644 --- a/hal/armv8m/cpu.h +++ b/hal/armv8m/cpu.h @@ -83,7 +83,7 @@ extern void hal_invalDCacheAll(void); extern unsigned int hal_cpuID(void); -extern void hal_cpuReset(void); +extern void hal_cpuReboot(void); extern void hal_cpuInit(void); diff --git a/hal/armv8m/nrf/hal.c b/hal/armv8m/nrf/hal.c index e351c3ff..f4d51b12 100644 --- a/hal/armv8m/nrf/hal.c +++ b/hal/armv8m/nrf/hal.c @@ -176,13 +176,6 @@ int hal_memoryGetNextEntry(addr_t start, addr_t end, mapent_t *entry) } -void hal_cpuReboot(void) -{ - hal_cpuReset(); - __builtin_unreachable(); -} - - int hal_cpuJump(void) { if (hal_common.entry == (addr_t)-1) { diff --git a/hal/ia32/exceptions.c b/hal/ia32/exceptions.c index e915995b..f3ad9bb1 100644 --- a/hal/ia32/exceptions.c +++ b/hal/ia32/exceptions.c @@ -158,7 +158,14 @@ static void exceptions_defaultHandler(unsigned int n, exc_context_t *ctx) hal_consolePrint(buff); hal_consolePrint("\033[0m"); hal_interruptsDisableAll(); - hal_cpuHalt(); + +#ifdef NDEBUG + hal_cpuReboot(); +#endif + + for (;;) { + hal_cpuHalt(); + } } diff --git a/hal/sparcv8leon3/cpu.c b/hal/sparcv8leon3/cpu.c index 4b2335ce..6c8a3690 100644 --- a/hal/sparcv8leon3/cpu.c +++ b/hal/sparcv8leon3/cpu.c @@ -18,5 +18,6 @@ void hal_cpuReboot(void) { /* TODO */ + /* *(u32 *)(INT_CTRL_BASE + 128) = 0x00000001; */ /* __builtin_unreachable(); */ } diff --git a/hal/sparcv8leon3/cpu.h b/hal/sparcv8leon3/cpu.h index 3d6d98a0..ea5ef3ed 100644 --- a/hal/sparcv8leon3/cpu.h +++ b/hal/sparcv8leon3/cpu.h @@ -54,13 +54,6 @@ static inline void hal_cpuDataStoreBarrier(void) } -static inline void hal_cpuReset(void) -{ - /* TODO */ - *(u32 *)(INT_CTRL_BASE + 128) = 0x00000001; -} - - #endif /* __ASSEMBLY__ */ diff --git a/hal/sparcv8leon3/exceptions.c b/hal/sparcv8leon3/exceptions.c index 000cfe5e..5dc2688a 100644 --- a/hal/sparcv8leon3/exceptions.c +++ b/hal/sparcv8leon3/exceptions.c @@ -174,6 +174,10 @@ void exceptions_dispatch(unsigned int n, exc_context_t *ctx) hal_exceptionsDumpContext(buff, ctx, n); hal_consolePrint(buff); +#ifdef NDEBUG + hal_cpuReboot(); +#endif + for (;;) { hal_cpuHalt(); }