aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-08-10 08:07:43 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-08-10 08:07:43 +0000
commitc3dc5598c315f4650bfcd1e595104a2ace7aa87c (patch)
tree890774f4ca76e9729624adfc0254544791e9cecb /os/kernel/src
parent16712a78831d021d9ee40ade082aefafc9aea196 (diff)
downloadChibiOS-c3dc5598c315f4650bfcd1e595104a2ace7aa87c.tar.gz
ChibiOS-c3dc5598c315f4650bfcd1e595104a2ace7aa87c.tar.bz2
ChibiOS-c3dc5598c315f4650bfcd1e595104a2ace7aa87c.zip
Global variables consolidation.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6116 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src')
-rw-r--r--os/kernel/src/chregistry.c10
-rw-r--r--os/kernel/src/chschd.c29
-rw-r--r--os/kernel/src/chsys.c5
-rw-r--r--os/kernel/src/chvt.c34
4 files changed, 37 insertions, 41 deletions
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c
index b43341edd..b0d241fee 100644
--- a/os/kernel/src/chregistry.c
+++ b/os/kernel/src/chregistry.c
@@ -42,8 +42,8 @@
* terminating threads can pulse an event source and an event handler
* can perform a scansion of the registry in order to recover the
* memory.
- * @pre In order to use the threads registry the @p CH_CFG_USE_REGISTRY option
- * must be enabled in @p chconf.h.
+ * @pre In order to use the threads registry the @p CH_CFG_USE_REGISTRY
+ * option must be enabled in @p chconf.h.
* @{
*/
#include "ch.h"
@@ -66,7 +66,7 @@
/* Module local functions. */
/*===========================================================================*/
-#define _offsetof(st, m) \
+#define _offsetof(st, m) \
((size_t)((char *)&((st *)0)->m - (char *)0))
/*===========================================================================*/
@@ -131,7 +131,7 @@ thread_t *chRegFirstThread(void) {
thread_t *tp;
chSysLock();
- tp = rlist.r_newer;
+ tp = ch.rlist.r_newer;
#if CH_CFG_USE_DYNAMIC
tp->p_refs++;
#endif
@@ -155,7 +155,7 @@ thread_t *chRegNextThread(thread_t *tp) {
chSysLock();
ntp = tp->p_newer;
- if (ntp == (thread_t *)&rlist)
+ if (ntp == (thread_t *)&ch.rlist)
ntp = NULL;
#if CH_CFG_USE_DYNAMIC
else {
diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c
index db0097108..53a14dac7 100644
--- a/os/kernel/src/chschd.c
+++ b/os/kernel/src/chschd.c
@@ -37,11 +37,6 @@
/* Module exported variables. */
/*===========================================================================*/
-/**
- * @brief Ready list header.
- */
-ready_list_t rlist;
-
/*===========================================================================*/
/* Module local types. */
/*===========================================================================*/
@@ -65,10 +60,10 @@ ready_list_t rlist;
*/
void _scheduler_init(void) {
- queue_init(&rlist.r_queue);
- rlist.r_prio = NOPRIO;
+ queue_init(&ch.rlist.r_queue);
+ ch.rlist.r_prio = NOPRIO;
#if CH_CFG_USE_REGISTRY
- rlist.r_newer = rlist.r_older = (thread_t *)&rlist;
+ ch.rlist.r_newer = ch.rlist.r_older = (thread_t *)&ch.rlist;
#endif
}
@@ -100,7 +95,7 @@ thread_t *chSchReadyI(thread_t *tp) {
"invalid state");
tp->p_state = CH_STATE_READY;
- cp = (thread_t *)&rlist.r_queue;
+ cp = (thread_t *)&ch.rlist.r_queue;
do {
cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio);
@@ -131,7 +126,7 @@ void chSchGoSleepS(tstate_t newstate) {
time quantum when it will wakeup.*/
otp->p_preempt = CH_CFG_TIME_QUANTUM;
#endif
- setcurrp(queue_fifo_remove(&rlist.r_queue));
+ setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
currp->p_state = CH_STATE_CURRENT;
chSysSwitch(currp, otp);
}
@@ -149,7 +144,7 @@ static void wakeup(void *p) {
another thread with higher priority.*/
chSysUnlockFromISR();
return;
-#if CH_CFG_USE_SEMAPHORES || CH_CFG_USE_QUEUES || \
+#if CH_CFG_USE_SEMAPHORES || CH_CFG_USE_QUEUES || \
(CH_CFG_USE_CONDVARS && CH_CFG_USE_CONDVARS_TIMEOUT)
#if CH_CFG_USE_SEMAPHORES
case CH_STATE_WTSEM:
@@ -274,7 +269,7 @@ void chSchRescheduleS(void) {
* @special
*/
bool chSchIsPreemptionRequired(void) {
- tprio_t p1 = firstprio(&rlist.r_queue);
+ tprio_t p1 = firstprio(&ch.rlist.r_queue);
tprio_t p2 = currp->p_prio;
#if CH_CFG_TIME_QUANTUM > 0
/* If the running thread has not reached its time quantum, reschedule only
@@ -304,7 +299,7 @@ void chSchDoRescheduleBehind(void) {
otp = currp;
/* Picks the first thread from the ready queue and makes it current.*/
- setcurrp(queue_fifo_remove(&rlist.r_queue));
+ setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
currp->p_state = CH_STATE_CURRENT;
#if CH_CFG_TIME_QUANTUM > 0
otp->p_preempt = CH_CFG_TIME_QUANTUM;
@@ -327,11 +322,11 @@ void chSchDoRescheduleAhead(void) {
otp = currp;
/* Picks the first thread from the ready queue and makes it current.*/
- setcurrp(queue_fifo_remove(&rlist.r_queue));
+ setcurrp(queue_fifo_remove(&ch.rlist.r_queue));
currp->p_state = CH_STATE_CURRENT;
otp->p_state = CH_STATE_READY;
- cp = (thread_t *)&rlist.r_queue;
+ cp = (thread_t *)&ch.rlist.r_queue;
do {
cp = cp->p_next;
} while (cp->p_prio > otp->p_prio);
@@ -356,8 +351,8 @@ void chSchDoRescheduleAhead(void) {
void chSchDoReschedule(void) {
#if CH_CFG_TIME_QUANTUM > 0
- /* If CH_CFG_TIME_QUANTUM is enabled then there are two different scenarios to
- handle on preemption: time quantum elapsed or not.*/
+ /* If CH_CFG_TIME_QUANTUM is enabled then there are two different scenarios
+ to handle on preemption: time quantum elapsed or not.*/
if (currp->p_preempt == 0) {
/* The thread consumed its time quantum so it is enqueued behind threads
with same priority level, however, it acquires a new time quantum.*/
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index 2494706d7..9212cbf5f 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -48,6 +48,11 @@
/* Module local variables. */
/*===========================================================================*/
+/**
+ * @brief System data structures.
+ */
+ch_system_t ch;
+
#if !CH_CFG_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
* @brief Idle thread working area.
diff --git a/os/kernel/src/chvt.c b/os/kernel/src/chvt.c
index 3e6028f9c..6fa4dd582 100644
--- a/os/kernel/src/chvt.c
+++ b/os/kernel/src/chvt.c
@@ -37,11 +37,6 @@
/* Module exported variables. */
/*===========================================================================*/
-/**
- * @brief Virtual timers delta list header.
- */
-virtual_timers_list_t vtlist;
-
/*===========================================================================*/
/* Module local types. */
/*===========================================================================*/
@@ -66,12 +61,12 @@ virtual_timers_list_t vtlist;
*/
void _vt_init(void) {
- vtlist.vt_next = vtlist.vt_prev = (void *)&vtlist;
- vtlist.vt_delta = (systime_t)-1;
+ ch.vtlist.vt_next = ch.vtlist.vt_prev = (void *)&ch.vtlist;
+ ch.vtlist.vt_delta = (systime_t)-1;
#if CH_CFG_TIMEDELTA == 0
- vtlist.vt_systime = 0;
+ ch.vtlist.vt_systime = 0;
#else /* CH_CFG_TIMEDELTA > 0 */
- vtlist.vt_lasttime = 0;
+ ch.vtlist.vt_lasttime = 0;
#endif /* CH_CFG_TIMEDELTA > 0 */
}
@@ -128,7 +123,7 @@ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
vtp->vt_par = par;
vtp->vt_func = vtfunc;
- p = vtlist.vt_next;
+ p = ch.vtlist.vt_next;
#if CH_CFG_TIMEDELTA > 0 || defined(__DOXYGEN__)
{
@@ -139,21 +134,21 @@ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
if (delay < CH_CFG_TIMEDELTA)
delay = CH_CFG_TIMEDELTA;
- if (&vtlist == (virtual_timers_list_t *)p) {
+ if (&ch.vtlist == (virtual_timers_list_t *)p) {
/* The delta list is empty, the current time becomes the new
delta list base time.*/
- vtlist.vt_lasttime = now;
- port_timer_start_alarm(vtlist.vt_lasttime + delay);
+ ch.vtlist.vt_lasttime = now;
+ port_timer_start_alarm(ch.vtlist.vt_lasttime + delay);
}
else {
/* Now the delay is calculated as delta from the last tick interrupt
time.*/
- delay += now - vtlist.vt_lasttime;
+ delay += now - ch.vtlist.vt_lasttime;
/* If the specified delay is closer in time than the first element
in the delta list then it becomes the next alarm event in time.*/
if (delay < p->vt_delta)
- port_timer_set_alarm(vtlist.vt_lasttime + delay);
+ port_timer_set_alarm(ch.vtlist.vt_lasttime + delay);
}
}
#endif /* CH_CFG_TIMEDELTA > 0 */
@@ -172,7 +167,7 @@ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
/* Special case when the timer is in last position in the list, the
value in the header must be restored.*/;
p->vt_delta -= delay;
- vtlist.vt_delta = (systime_t)-1;
+ ch.vtlist.vt_delta = (systime_t)-1;
}
/**
@@ -199,17 +194,18 @@ void chVTDoResetI(virtual_timer_t *vtp) {
/* The above code changes the value in the header when the removed element
is the last of the list, restoring it.*/
- vtlist.vt_delta = (systime_t)-1;
+ ch.vtlist.vt_delta = (systime_t)-1;
#if CH_CFG_TIMEDELTA > 0 || defined(__DOXYGEN__)
{
- if (&vtlist == (virtual_timers_list_t *)vtlist.vt_next) {
+ if (&ch.vtlist == (virtual_timers_list_t *)ch.vtlist.vt_next) {
/* Just removed the last element in the list, alarm timer stopped.*/
port_timer_stop_alarm();
}
else {
/* The alarm is set to the next element in the delta list.*/
- port_timer_set_alarm(vtlist.vt_lasttime + vtlist.vt_next->vt_delta);
+ port_timer_set_alarm(ch.vtlist.vt_lasttime +
+ ch.vtlist.vt_next->vt_delta);
}
}
#endif /* CH_CFG_TIMEDELTA > 0 */