aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-10-24 11:07:52 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-10-24 11:16:10 -0400
commitfaeaa54925e0a6fa197c48faf6317a86824f64d7 (patch)
treee8679d9af4998068d5fc721c0fc9d2f1e55145f4 /src
parent632ff9e55adced3f055b0926a32cff0b53a7bd0e (diff)
downloadkutter-faeaa54925e0a6fa197c48faf6317a86824f64d7.tar.gz
kutter-faeaa54925e0a6fa197c48faf6317a86824f64d7.tar.xz
kutter-faeaa54925e0a6fa197c48faf6317a86824f64d7.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/atsam/main.c9
-rw-r--r--src/atsamd/main.c10
-rw-r--r--src/generic/armcm_boot.c12
-rw-r--r--src/generic/armcm_boot.h2
-rw-r--r--src/lpc176x/main.c9
-rw-r--r--src/stm32/main.c10
6 files changed, 27 insertions, 25 deletions
diff --git a/src/atsam/main.c b/src/atsam/main.c
index 580ad770..843b5034 100644
--- a/src/atsam/main.c
+++ b/src/atsam/main.c
@@ -4,6 +4,7 @@
//
// 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/usb_cdc.h" // usb_request_bootloader
#include "command.h" // DECL_COMMAND_FLAGS
@@ -110,11 +111,11 @@ matrix_init(void)
| MATRIX_SCFG_DEFMSTR_TYPE(1));
}
-// Main entry point
-int
-main(void)
+// Main entry point - called from armcm_boot.c:ResetHandler()
+void
+armcm_main(void)
{
+ SystemInit();
matrix_init();
sched_main();
- return 0;
}
diff --git a/src/atsamd/main.c b/src/atsamd/main.c
index a5b7196b..d3943e6a 100644
--- a/src/atsamd/main.c
+++ b/src/atsamd/main.c
@@ -4,12 +4,14 @@
//
// 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
-// Main entry point
-int
-main(void)
+// Main entry point - called from armcm_boot.c:ResetHandler()
+void
+armcm_main(void)
{
+ SystemInit();
sched_main();
- return 0;
}
diff --git a/src/generic/armcm_boot.c b/src/generic/armcm_boot.c
index ad7461ca..261fb912 100644
--- a/src/generic/armcm_boot.c
+++ b/src/generic/armcm_boot.c
@@ -6,8 +6,8 @@
#include "armcm_boot.h" // DECL_ARMCM_IRQ
#include "autoconf.h" // CONFIG_MCU
-#include "board/internal.h" // SystemInit
#include "command.h" // DECL_CONSTANT_STR
+#include "misc.h" // dynmem_start
// Export MCU type
DECL_CONSTANT_STR("MCU", CONFIG_MCU);
@@ -37,14 +37,10 @@ ResetHandler(void)
// Initializing the C library isn't needed...
//__libc_init_array();
- // Initialize the machine
- SystemInit();
+ // Run the main board specific code
+ armcm_main();
- // Run the main code
- extern int main(void);
- main();
-
- // The main() call should not return
+ // The armcm_main() call should not return
for (;;)
;
}
diff --git a/src/generic/armcm_boot.h b/src/generic/armcm_boot.h
index a0bfd3f4..7bd982ce 100644
--- a/src/generic/armcm_boot.h
+++ b/src/generic/armcm_boot.h
@@ -3,6 +3,8 @@
#include "ctr.h" // DECL_CTR_INT
+void armcm_main(void);
+
// Declare an IRQ handler
#define DECL_ARMCM_IRQ(FUNC, NUM) \
DECL_CTR_INT("DECL_ARMCM_IRQ " __stringify(FUNC), 1, CTR_INT(NUM))
diff --git a/src/lpc176x/main.c b/src/lpc176x/main.c
index 79001e72..7f19f8c0 100644
--- a/src/lpc176x/main.c
+++ b/src/lpc176x/main.c
@@ -4,6 +4,7 @@
//
// 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 "sched.h" // sched_main
@@ -56,10 +57,10 @@ enable_pclock(uint32_t pclk)
}
}
-// Main entry point
-int
-main(void)
+// Main entry point - called from armcm_boot.c:ResetHandler()
+void
+armcm_main(void)
{
+ SystemInit();
sched_main();
- return 0;
}
diff --git a/src/stm32/main.c b/src/stm32/main.c
index 7c46d4b5..5cf7dfd1 100644
--- a/src/stm32/main.c
+++ b/src/stm32/main.c
@@ -4,15 +4,15 @@
//
// 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 "sched.h" // sched_main
-// Main entry point
-int
-main(void)
+// Main entry point - called from armcm_boot.c:ResetHandler()
+void
+armcm_main(void)
{
+ SystemInit();
clock_setup();
-
sched_main();
- return 0;
}