summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorBenjamin Walsh <benjamin.walsh@windriver.com>2016-10-05 17:50:54 -0400
committerBenjamin Walsh <benjamin.walsh@windriver.com>2016-10-10 21:27:39 +0000
commitc742d7e6b3a5d4829a314c6d8acbad387302b017 (patch)
treee2ed773f87ea1afdde72566a34ea345439637f9c /kernel
parentb7ef0cba5fd22c6f5f697b1cc31cbe78e251ac55 (diff)
unified: cleanup kernel initialization
- ensure dummy thread's stack is aligned - rename nano_init() to prepare_multithreading - move _Swap() to main thread into its own function Change-Id: I6c8dbe2a4e034f3db90b55d1a5e30bc73bac3d50 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/unified/init.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/kernel/unified/init.c b/kernel/unified/init.c
index 3d7eec804..49deb35a7 100644
--- a/kernel/unified/init.c
+++ b/kernel/unified/init.c
@@ -205,7 +205,7 @@ void __weak main(void)
*
* @return N/A
*/
-static void nano_init(struct tcs *dummy_thread)
+static void prepare_multithreading(struct k_thread *dummy_thread)
{
/*
* Initialize the current execution thread to permit a level of
@@ -262,6 +262,17 @@ static void nano_init(struct tcs *dummy_thread)
nanoArchInit();
}
+static void switch_to_main_thread(void)
+{
+ /*
+ * Context switch to main task (entry function is _main()): the
+ * current fake thread is not on a wait queue or ready queue, so it
+ * will never be rescheduled in.
+ */
+
+ _Swap(irq_lock());
+}
+
#ifdef CONFIG_STACK_CANARIES
/**
*
@@ -314,7 +325,7 @@ FUNC_NORETURN void _Cstart(void)
{
/* floating point operations are NOT performed during nanokernel init */
- char dummyTCS[__tTCS_NOFLOAT_SIZEOF];
+ char __stack dummy_thread[__tTCS_NOFLOAT_SIZEOF];
/*
* Initialize nanokernel data structures. This step includes
@@ -322,7 +333,7 @@ FUNC_NORETURN void _Cstart(void)
* before the hardware initialization phase.
*/
- nano_init((struct tcs *)&dummyTCS);
+ prepare_multithreading((struct k_thread *)&dummy_thread);
/* perform basic hardware initialization */
@@ -345,13 +356,7 @@ FUNC_NORETURN void _Cstart(void)
PRINT_BOOT_BANNER();
- /*
- * Context switch to main task (entry function is _main()): the
- * current fake thread is not on a wait queue or ready queue, so it
- * will never be rescheduled in.
- */
-
- _Swap(irq_lock());
+ switch_to_main_thread();
/*
* Compiler can't tell that the above routines won't return and issues