aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-22 15:11:04 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-22 15:11:04 +0000
commitd51331c78ad8c4c5ad4769d6271cb0e06c11beb1 (patch)
tree5daa533b98381972de75076bd89c13007aef261e /os/kernel/src
parent4bdf358424068f452a4d5a450e6001a03ca4f819 (diff)
downloadChibiOS-d51331c78ad8c4c5ad4769d6271cb0e06c11beb1.tar.gz
ChibiOS-d51331c78ad8c4c5ad4769d6271cb0e06c11beb1.tar.bz2
ChibiOS-d51331c78ad8c4c5ad4769d6271cb0e06c11beb1.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4614 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src')
-rw-r--r--os/kernel/src/chregistry.c57
-rw-r--r--os/kernel/src/chsys.c12
2 files changed, 35 insertions, 34 deletions
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c
index 5036a52bc..4a383a379 100644
--- a/os/kernel/src/chregistry.c
+++ b/os/kernel/src/chregistry.c
@@ -50,34 +50,11 @@
#if CH_USE_REGISTRY || defined(__DOXYGEN__)
-/* Converting configuration options in bit masks in order to be encoded in
- the global variable ch_root.*/
-#if CH_DBG_ENABLE_STACK_CHECK
-#define MSK_DBG_ENABLE_STACK_CHECK 1
-#else
-#define MSK_DBG_ENABLE_STACK_CHECK 0
-#endif
-
-#if CH_USE_DYNAMIC
-#define MSK_USE_DYNAMIC 2
-#else
-#define MSK_USE_DYNAMIC 0
-#endif
-
-#if CH_TIME_QUANTUM > 0
-#define MSK_TIME_QUANTUM 4
-#else
-#define MSK_TIME_QUANTUM 0
-#endif
-
-#if CH_DBG_THREADS_PROFILING
-#define MSK_DBG_THREADS_PROFILING 8
-#else
-#define MSK_DBG_THREADS_PROFILING 0
-#endif
+#define THD_OFFSET(field) (uint8_t)((size_t)&_mainthread.field - \
+ (size_t)&_mainthread)
-/**
- * @brief OS signature in ROM plus debug-related information.
+/*
+ * OS signature in ROM plus debug-related information.
*/
ROMCONST chroot_t ch_root = {
"CHRT",
@@ -87,12 +64,30 @@ ROMCONST chroot_t ch_root = {
(CH_KERNEL_MINOR << 6) |
(CH_KERNEL_PATCH) << 0),
(uint8_t)sizeof (void *),
- (uint8_t)(MSK_DBG_THREADS_PROFILING | MSK_TIME_QUANTUM |
- MSK_USE_DYNAMIC | MSK_DBG_ENABLE_STACK_CHECK),
+ (uint8_t)sizeof (systime_t),
+ THD_OFFSET(p_prio),
+ THD_OFFSET(p_ctx),
+ THD_OFFSET(p_newer),
+ THD_OFFSET(p_older),
+ THD_OFFSET(p_name),
+#if CH_DBG_ENABLE_STACK_CHECK
+ THD_OFFSET(p_stklimit),
+#else
(uint8_t)0,
+#endif
+ THD_OFFSET(p_state),
+ THD_OFFSET(p_flags),
+#if CH_USE_DYNAMIC
+ THD_OFFSET(p_refs),
+#else
+ (uint8_t)0,
+#endif
+#if CH_TIME_QUANTUM > 0
+ THD_OFFSET(p_preempt),
+#else
(uint8_t)0,
- &rlist,
- &vtlist
+#endif
+ THD_OFFSET(p_time)
};
/**
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index e433a8e42..5bc86807b 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -36,10 +36,17 @@
#include "ch.h"
#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
-/* Idle thread working area.*/
+/**
+ * @brief Idle thread working area.
+ */
WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
/**
+ * @brief Main thread structure.
+ */
+Thread _mainthread;
+
+/**
* @brief This function implements the idle thread infinite loop.
* @details The function puts the processor in the lowest power mode capable
* to serve interrupts.<br>
@@ -73,7 +80,6 @@ void _idle_thread(void *p) {
* @special
*/
void chSysInit(void) {
- static Thread mainthread;
#if CH_DBG_ENABLE_STACK_CHECK
extern stkalign_t __main_thread_stack_base__;
#endif
@@ -92,7 +98,7 @@ void chSysInit(void) {
#endif
/* Now this instructions flow becomes the main thread.*/
- setcurrp(_thread_init(&mainthread, NORMALPRIO));
+ setcurrp(_thread_init(&_mainthread, NORMALPRIO));
currp->p_state = THD_STATE_CURRENT;
#if CH_DBG_ENABLE_STACK_CHECK
/* This is a special case because the main thread Thread structure is not