diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-05 14:54:24 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-05 14:54:24 +0000 |
commit | 15a54ae359d342b296b7740dcfaf0580d606b3c6 (patch) | |
tree | b385117ee6197a6f9efcdfe82ad687c801c61bed /os/nil/src | |
parent | 986a9d1db14a5d2d4621bd44ece5fd2cfb3482cf (diff) | |
download | ChibiOS-15a54ae359d342b296b7740dcfaf0580d606b3c6.tar.gz ChibiOS-15a54ae359d342b296b7740dcfaf0580d606b3c6.tar.bz2 ChibiOS-15a54ae359d342b296b7740dcfaf0580d606b3c6.zip |
Nil working on M3/M4.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6265 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/nil/src')
-rw-r--r-- | os/nil/src/nil.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/os/nil/src/nil.c b/os/nil/src/nil.c index 546854280..aefe4ccb2 100644 --- a/os/nil/src/nil.c +++ b/os/nil/src/nil.c @@ -62,6 +62,9 @@ nil_system_t nil; * @details Initializes the kernel structures, the current instructions flow
* becomes the idle thread upon return. The idle thread must not
* invoke any kernel primitive able to change state to not runnable.
+ * @note This function assumes that the @p nil global variable has been
+ * zeroed by the runtime environment. If this is not the case then
+ * make sure to clear it before calling this function.
*
* @special
*/
@@ -73,28 +76,34 @@ void chSysInit(void) { port_init();
/* Iterates through the list of defined threads.*/
- for (tp = &nil.threads[0], tcp = nil_thd_configs;
- tp < &nil.threads[NIL_CFG_NUM_THREADS];
- tp++, tcp++) {
- tp->state = NIL_STATE_READY;
- tp->timeout = 0;
-#if NIL_CFG_USE_EVENTS
- tp->epmask = 0;
+ tp = &nil.threads[0];
+ tcp = nil_thd_configs;
+ while (tp < &nil.threads[NIL_CFG_NUM_THREADS]) {
+#if NIL_CFG_ENABLE_STACK_CHECK
+ tp->stklim = (stkalign_t *)tcp->wbase;
#endif
/* Port dependent thread initialization.*/
- PORT_SETUP_CONTEXT(tp, tcp->wap, tcp->size, tcp->funcp, tcp->arg);
+ PORT_SETUP_CONTEXT(tp, tcp->wend, tcp->funcp, tcp->arg);
/* Initialization hook.*/
#if defined(NIL_CFG_THREAD_EXT_INIT_HOOK)
NIL_CFG_THREAD_EXT_INIT_HOOK(tp);
#endif
+
+ tp++, tcp++;
}
+#if NIL_CFG_ENABLE_STACK_CHECK
+ /* The idle thread is a special case because its stack is set up by the
+ runtime environment.*/
+ tp->stklim = THD_IDLE_BASE;
+#endif
+
/* Runs the highest priority thread, the current one becomes the null
thread.*/
nil.current = nil.next = nil.threads;
- port_switch(nil.threads, &nil.threads[NIL_CFG_NUM_THREADS]);
+ port_switch(nil.current, tp);
/* Interrupts enabled for the idle thread.*/
chSysEnable();
|