Skip to content

Commit

Permalink
hal: Add reboot on exception when NDEBUG to ia32, armv7a and sparcv9
Browse files Browse the repository at this point in the history
JIRA: RTOS-489
  • Loading branch information
agkaminski committed Jul 13, 2023
1 parent db609b9 commit e9ae55a
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 34 deletions.
4 changes: 4 additions & 0 deletions hal/armv7a/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
8 changes: 8 additions & 0 deletions hal/armv7a/imx6ull/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
18 changes: 18 additions & 0 deletions hal/armv7a/imx6ull/imx6ull.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 3 additions & 0 deletions hal/armv7a/imx6ull/imx6ull.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 (;;) {
Expand Down
7 changes: 0 additions & 7 deletions hal/armv7m/imxrt/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions hal/armv7m/stm32/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hal/armv8m/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion hal/armv8m/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions hal/armv8m/nrf/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion hal/ia32/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}


Expand Down
1 change: 1 addition & 0 deletions hal/sparcv8leon3/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
void hal_cpuReboot(void)
{
/* TODO */
/* *(u32 *)(INT_CTRL_BASE + 128) = 0x00000001; */
/* __builtin_unreachable(); */
}
7 changes: 0 additions & 7 deletions hal/sparcv8leon3/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */


Expand Down
4 changes: 4 additions & 0 deletions hal/sparcv8leon3/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit e9ae55a

Please sign in to comment.