armcm_boot: Use armcm_main() instead of main() to start board code

The main() function has a special meaning to gcc and using it can
result in different code generation.  Use armcm_main() to avoid that.

Also, invoke SystemInit() from the board specific armcm_main() code.
This gives the board code more control over board initialization.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-10-24 11:07:52 -04:00
parent 632ff9e55a
commit faeaa54925
6 changed files with 27 additions and 25 deletions

View File

@ -4,6 +4,7 @@
// //
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "board/armcm_boot.h" // armcm_main
#include "board/irq.h" // irq_disable #include "board/irq.h" // irq_disable
#include "board/usb_cdc.h" // usb_request_bootloader #include "board/usb_cdc.h" // usb_request_bootloader
#include "command.h" // DECL_COMMAND_FLAGS #include "command.h" // DECL_COMMAND_FLAGS
@ -110,11 +111,11 @@ matrix_init(void)
| MATRIX_SCFG_DEFMSTR_TYPE(1)); | MATRIX_SCFG_DEFMSTR_TYPE(1));
} }
// Main entry point // Main entry point - called from armcm_boot.c:ResetHandler()
int void
main(void) armcm_main(void)
{ {
SystemInit();
matrix_init(); matrix_init();
sched_main(); sched_main();
return 0;
} }

View File

@ -4,12 +4,14 @@
// //
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "board/armcm_boot.h" // armcm_main
#include "internal.h" // SystemInit
#include "sched.h" // sched_main #include "sched.h" // sched_main
// Main entry point // Main entry point - called from armcm_boot.c:ResetHandler()
int void
main(void) armcm_main(void)
{ {
SystemInit();
sched_main(); sched_main();
return 0;
} }

View File

@ -6,8 +6,8 @@
#include "armcm_boot.h" // DECL_ARMCM_IRQ #include "armcm_boot.h" // DECL_ARMCM_IRQ
#include "autoconf.h" // CONFIG_MCU #include "autoconf.h" // CONFIG_MCU
#include "board/internal.h" // SystemInit
#include "command.h" // DECL_CONSTANT_STR #include "command.h" // DECL_CONSTANT_STR
#include "misc.h" // dynmem_start
// Export MCU type // Export MCU type
DECL_CONSTANT_STR("MCU", CONFIG_MCU); DECL_CONSTANT_STR("MCU", CONFIG_MCU);
@ -37,14 +37,10 @@ ResetHandler(void)
// Initializing the C library isn't needed... // Initializing the C library isn't needed...
//__libc_init_array(); //__libc_init_array();
// Initialize the machine // Run the main board specific code
SystemInit(); armcm_main();
// Run the main code // The armcm_main() call should not return
extern int main(void);
main();
// The main() call should not return
for (;;) for (;;)
; ;
} }

View File

@ -3,6 +3,8 @@
#include "ctr.h" // DECL_CTR_INT #include "ctr.h" // DECL_CTR_INT
void armcm_main(void);
// Declare an IRQ handler // Declare an IRQ handler
#define DECL_ARMCM_IRQ(FUNC, NUM) \ #define DECL_ARMCM_IRQ(FUNC, NUM) \
DECL_CTR_INT("DECL_ARMCM_IRQ " __stringify(FUNC), 1, CTR_INT(NUM)) DECL_CTR_INT("DECL_ARMCM_IRQ " __stringify(FUNC), 1, CTR_INT(NUM))

View File

@ -4,6 +4,7 @@
// //
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "board/armcm_boot.h" // armcm_main
#include "internal.h" // enable_pclock #include "internal.h" // enable_pclock
#include "sched.h" // sched_main #include "sched.h" // sched_main
@ -56,10 +57,10 @@ enable_pclock(uint32_t pclk)
} }
} }
// Main entry point // Main entry point - called from armcm_boot.c:ResetHandler()
int void
main(void) armcm_main(void)
{ {
SystemInit();
sched_main(); sched_main();
return 0;
} }

View File

@ -4,15 +4,15 @@
// //
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "board/armcm_boot.h" // armcm_main
#include "internal.h" // clock_setup #include "internal.h" // clock_setup
#include "sched.h" // sched_main #include "sched.h" // sched_main
// Main entry point // Main entry point - called from armcm_boot.c:ResetHandler()
int void
main(void) armcm_main(void)
{ {
SystemInit();
clock_setup(); clock_setup();
sched_main(); sched_main();
return 0;
} }