mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-23 21:57:33 -04:00
[sw] remove after-main handler
This commit is contained in:
parent
37c2e1ff45
commit
2ddac9853f
3 changed files with 23 additions and 48 deletions
|
@ -137,18 +137,10 @@ int main() {
|
|||
// NOTE: exit is highly over-sized as it also includes clean-up functions (destructors), which
|
||||
// are not required for bare-metal or RTOS applications... better use the simple 'return' or even better
|
||||
// make sure main never returns. Anyway, let's check if 'exit' works.
|
||||
neorv32_uart0_printf("<exit> test...");
|
||||
neorv32_uart0_printf("terminating via <exit> ");
|
||||
exit(0);
|
||||
|
||||
return 0; // should never be reached
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* "after-main" handler that is executed after the application's
|
||||
* main function returns (called by crt0.S start-up code)
|
||||
**************************************************************************/
|
||||
void __neorv32_crt0_after_main(int32_t return_code) {
|
||||
|
||||
neorv32_uart0_printf("\n<RTE> main function returned with exit code %i </RTE>\n", return_code);
|
||||
// should never be reached
|
||||
neorv32_uart0_printf("failed!n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -245,16 +245,17 @@ int main() {
|
|||
neorv32_cpu_csr_write(CSR_MCAUSE, mcause_never_c);
|
||||
PRINT_STANDARD("[%i] PMP setup ", cnt_test);
|
||||
|
||||
// check if PMP is already locked
|
||||
tmp_a = neorv32_cpu_csr_read(CSR_PMPCFG0);
|
||||
tmp_b = ((1 << PMPCFG_L) << 0) | ((1 << PMPCFG_L) << 8) | ((1 << PMPCFG_L) << 16);
|
||||
|
||||
if (tmp_a & tmp_b) {
|
||||
PRINT_CRITICAL("\nERROR! PMP LOCKED!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pmp_num_regions >= 3) { // sufficient regions for tests
|
||||
|
||||
// check if PMP is already locked
|
||||
tmp_a = neorv32_cpu_csr_read(CSR_PMPCFG0);
|
||||
tmp_b = ((1 << PMPCFG_L) << 0) | ((1 << PMPCFG_L) << 8) | ((1 << PMPCFG_L) << 16);
|
||||
|
||||
if (tmp_a & tmp_b) {
|
||||
PRINT_CRITICAL("\nERROR! PMP LOCKED!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
cnt_test++;
|
||||
|
||||
// set execute permission for u-mode
|
||||
|
@ -2216,7 +2217,15 @@ int main() {
|
|||
PRINT_STANDARD("%c[1m[PROCESSOR TEST FAILED!]%c[0m\n", 27, 27);
|
||||
}
|
||||
|
||||
return (int)cnt_fail; // return error counter for after-main handler
|
||||
// make sure sim mode is disabled and UARTs are actually enabled
|
||||
NEORV32_UART0->CTRL |= (1 << UART_CTRL_EN);
|
||||
NEORV32_UART0->CTRL &= ~(1 << UART_CTRL_SIM_MODE);
|
||||
NEORV32_UART1->CTRL = NEORV32_UART0->CTRL;
|
||||
|
||||
// minimal result report
|
||||
PRINT_CRITICAL("%u/%u\n", (uint32_t)cnt_fail, (uint32_t)cnt_test);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2392,20 +2401,3 @@ void test_fail(void) {
|
|||
PRINT_CRITICAL("%c[1m[fail(%u)]%c[0m\n", 27, cnt_test-1, 27);
|
||||
cnt_fail++;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* "after-main" handler that is executed after the application's
|
||||
* main function returns (called by crt0.S start-up code): Output minimal
|
||||
* test report to physical UART
|
||||
**************************************************************************/
|
||||
void __neorv32_crt0_after_main(int32_t return_code) {
|
||||
|
||||
// make sure sim mode is disabled and UARTs are actually enabled
|
||||
NEORV32_UART0->CTRL |= (1 << UART_CTRL_EN);
|
||||
NEORV32_UART0->CTRL &= ~(1 << UART_CTRL_SIM_MODE);
|
||||
NEORV32_UART1->CTRL = NEORV32_UART0->CTRL;
|
||||
|
||||
// minimal result report
|
||||
PRINT_CRITICAL("%u/%u\n", (uint32_t)return_code, (uint32_t)cnt_test);
|
||||
}
|
||||
|
|
|
@ -455,15 +455,6 @@ inline void __attribute__ ((always_inline)) neorv32_cpu_csr_clr(const int csr_id
|
|||
// Misc helpers
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Prototype for "after-main handler". This function is called if main() returns.
|
||||
*
|
||||
* @param[in] return_code Return value of main() function.
|
||||
**************************************************************************/
|
||||
extern void __attribute__ ((weak)) __neorv32_crt0_after_main(int32_t return_code);
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Put CPU into sleep / power-down mode.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue