aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-10-02 16:52:18 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-10-02 16:52:18 +0000
commit1b269aa139ba66288cc2c3f1b463c73821343262 (patch)
treed69e3b0f8016def9da728232fc82f6297f4f70ed
parente4e90fae74549139baaf135034b3be2abcf284a6 (diff)
downloadChibiOS-1b269aa139ba66288cc2c3f1b463c73821343262.tar.gz
ChibiOS-1b269aa139ba66288cc2c3f1b463c73821343262.tar.bz2
ChibiOS-1b269aa139ba66288cc2c3f1b463c73821343262.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@29 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/LPC214x-GCC/chcore.h8
-rw-r--r--demos/Win32-MSVS/ch.vcproj6
-rw-r--r--demos/Win32-MSVS/chcore.h2
-rw-r--r--ports/ARM7-LPC214x/GCC/lpc214x.h8
-rw-r--r--readme.txt3
-rw-r--r--src/chevents.c5
-rw-r--r--src/chlists.c6
-rw-r--r--src/chschd.c18
-rw-r--r--src/include/events.h5
-rw-r--r--src/include/scheduler.h10
-rw-r--r--src/include/threads.h8
11 files changed, 40 insertions, 39 deletions
diff --git a/demos/LPC214x-GCC/chcore.h b/demos/LPC214x-GCC/chcore.h
index bc49994ce..b2091b686 100644
--- a/demos/LPC214x-GCC/chcore.h
+++ b/demos/LPC214x-GCC/chcore.h
@@ -20,6 +20,14 @@
#ifndef _CHCORE_H_
#define _CHCORE_H_
+/*
+ * The following values are implementation dependent. You may change them in
+ * order to match your HW.
+ */
+#define FOSC 12000000
+#define CCLK 48000000
+#define PCLK 12000000
+
typedef void *regarm;
/*
diff --git a/demos/Win32-MSVS/ch.vcproj b/demos/Win32-MSVS/ch.vcproj
index b1619033c..185e65dc1 100644
--- a/demos/Win32-MSVS/ch.vcproj
+++ b/demos/Win32-MSVS/ch.vcproj
@@ -151,6 +151,9 @@
RelativePath="..\..\src\chinit.c">
</File>
<File
+ RelativePath="..\..\src\chlists.c">
+ </File>
+ <File
RelativePath="..\..\src\chmsg.c">
</File>
<File
@@ -206,6 +209,9 @@
RelativePath="..\..\src\include\events.h">
</File>
<File
+ RelativePath="..\..\src\include\lists.h">
+ </File>
+ <File
RelativePath="..\..\src\include\messages.h">
</File>
<File
diff --git a/demos/Win32-MSVS/chcore.h b/demos/Win32-MSVS/chcore.h
index 487dd175a..26e0b66bf 100644
--- a/demos/Win32-MSVS/chcore.h
+++ b/demos/Win32-MSVS/chcore.h
@@ -63,7 +63,7 @@ typedef struct {
#define INT_REQUIRED_STACK 0x0
-#define UserStackSize(n) (sizeof(Thread) + sizeof(PTR_EQ) + sizeof(PTR_EQ) + \
+#define UserStackSize(n) (sizeof(Thread) + sizeof(void *)*2 + \
sizeof(struct stackregs) + (n) + (INT_REQUIRED_STACK))
void __fastcall chSysHalt(void);
diff --git a/ports/ARM7-LPC214x/GCC/lpc214x.h b/ports/ARM7-LPC214x/GCC/lpc214x.h
index 63be5c36c..cb1aa76f4 100644
--- a/ports/ARM7-LPC214x/GCC/lpc214x.h
+++ b/ports/ARM7-LPC214x/GCC/lpc214x.h
@@ -24,14 +24,6 @@ typedef volatile unsigned char IOREG8;
typedef volatile unsigned int IOREG32;
/*
- * The following values are implementation dependent. You may change them in
- * order to match your HW.
- */
-#define FOSC 12000000
-#define CCLK 48000000
-#define PCLK 12000000
-
-/*
* System.
*/
#define MEMMAP (*((IOREG32 *)0xE01FC040))
diff --git a/readme.txt b/readme.txt
index 526126ee7..6261bb2da 100644
--- a/readme.txt
+++ b/readme.txt
@@ -33,7 +33,8 @@ LPC214x-GCC - ChibiOS/RT port for ARM7 LPC2148, the demo targets the
*****************************************************************************
*** 0.3.1 ***
-- Lists code moved into chlists.c from various other places and reorganized.
+- Lists code moved into chlists.c from various other places optimized and
+ reorganized.
- The list of the threads waiting in chThdWait() is now a single link list,
this saves some space.
- Cleaned the template files code, the files contained some obsolete
diff --git a/src/chevents.c b/src/chevents.c
index 4dcf37a22..9094f45cd 100644
--- a/src/chevents.c
+++ b/src/chevents.c
@@ -140,11 +140,12 @@ void chEvtSendI(EventSource *esp) {
* @return the event identifier
* @note Only a single event is served in the function, the one with the
* lowest event id. The function is meant to be invoked into a loop so
- * that all events are received and served.<br>
+ * that all events are received and served.<br>
* This means that Event Listeners with a lower event identifier have
* an higher priority.
*/
-t_eventid chEvtWait(t_eventmask ewmask, t_evhandler handlers[]) {
+t_eventid chEvtWait(t_eventmask ewmask,
+ t_evhandler handlers[]) {
t_eventid i;
t_eventmask m;
diff --git a/src/chlists.c b/src/chlists.c
index d01c8c37c..7994f8ac6 100644
--- a/src/chlists.c
+++ b/src/chlists.c
@@ -31,10 +31,8 @@
*/
void fifo_insert(Thread *tp, ThreadsQueue *tqp) {
- tp->p_next = (Thread *)tqp;
- tp->p_prev = tqp->p_prev;
- tqp->p_prev->p_next = tp;
- tqp->p_prev = tp;
+ tp->p_prev = (tp->p_next = (Thread *)tqp)->p_prev;
+ tp->p_prev->p_next = tqp->p_prev = tp;
}
/*
diff --git a/src/chschd.c b/src/chschd.c
index 81031f8c4..254f87937 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -27,12 +27,12 @@
/** @cond never*/
static ReadyList rlist;
+static t_cnt preempt;
#ifndef CH_CURRP_REGISTER_CACHE
Thread *currp;
#endif
-static t_cnt preempt;
#ifdef CH_USE_SYSTEMTIME
t_time stime;
#endif
@@ -45,8 +45,8 @@ t_time stime;
*/
void chSchInit(void) {
- rlist.p_next = rlist.p_prev = (Thread *)&rlist;
- rlist.p_prio = ABSPRIO;
+ fifo_init(&rlist.r_queue);
+ rlist.r_prio = ABSPRIO;
preempt = CH_TIME_QUANTUM;
#ifdef CH_USE_SYSTEMTIME
stime = 0;
@@ -68,7 +68,7 @@ Thread *chSchReadyI(Thread *tp) {
tp->p_state = PRREADY;
tp->p_rdymsg = RDY_OK;
- cp = rlist.p_prev;
+ cp = rlist.r_queue.p_prev;
while (cp->p_prio < prio)
cp = cp->p_prev;
// Insertion on p_next
@@ -84,7 +84,7 @@ Thread *chSchReadyI(Thread *tp) {
static void nextready(void) {
Thread *otp = currp;
- (currp = fifo_remove((ThreadsQueue *)&rlist))->p_state = PRCURR;
+ (currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR;
preempt = CH_TIME_QUANTUM;
chSysSwitchI(&otp->p_ctx, &currp->p_ctx);
}
@@ -136,7 +136,7 @@ void chSchWakeupI(Thread *tp, t_msg msg) {
*/
void chSchRescheduleI(void) {
- if (isempty(&rlist) || firstprio(&rlist) <= currp->p_prio)
+ if (isempty(&rlist.r_queue) || firstprio(&rlist.r_queue) <= currp->p_prio)
return;
chSchDoRescheduleI();
@@ -159,15 +159,15 @@ void chSchDoRescheduleI(void) {
*/
BOOL chSchRescRequiredI(void) {
- if (isempty(&rlist))
+ if (isempty(&rlist.r_queue))
return FALSE;
if (preempt) {
- if (firstprio(&rlist) <= currp->p_prio)
+ if (firstprio(&rlist.r_queue) <= currp->p_prio)
return FALSE;
}
else { /* Time quantum elapsed. */
- if (firstprio(&rlist) < currp->p_prio)
+ if (firstprio(&rlist.r_queue) < currp->p_prio)
return FALSE;
}
return TRUE;
diff --git a/src/include/events.h b/src/include/events.h
index c5dfe7438..322f7ec7d 100644
--- a/src/include/events.h
+++ b/src/include/events.h
@@ -70,7 +70,7 @@ typedef struct EventSource {
* @note Can be called with interrupts disabled or enabled.
*/
#define chEvtIsListening(esp) \
- ((esp) != (EventSource *)(esp)->es_next)
+ ((esp) != (EventSource *)(esp)->es_next)
/** Event Handler callback function.*/
@@ -81,7 +81,8 @@ void chEvtUnregister(EventSource *esp, EventListener *elp);
void chEvtClear(t_eventmask mask);
void chEvtSend(EventSource *esp);
void chEvtSendI(EventSource *esp);
-t_eventid chEvtWait(t_eventmask ewmask, t_evhandler handlers[]);
+t_eventid chEvtWait(t_eventmask ewmask,
+ t_evhandler handlers[]);
#ifdef CH_USE_EVENTS_TIMEOUT
t_eventid chEvtWaitTimeout(t_eventmask ewmask,
t_evhandler handlers[],
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index 2efabbcd2..6a3f7f8f8 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -32,18 +32,14 @@
/** Returned if the thread was made ready because a reset.*/
#define RDY_RESET -2
-#define firstprio(qp) ((qp)->p_next->p_prio)
+#define firstprio(rlp) ((rlp)->p_next->p_prio)
/**
* Ready list header.
*/
typedef struct {
- /** Highest priority \p Thread in the list.*/
- Thread *p_next;
- /** Lowest priority \p Thread in the list.*/
- Thread *p_prev;
- /** Alwas set to \p MAXPRIO.*/
- t_prio p_prio;
+ ThreadsQueue r_queue;
+ t_prio r_prio;
} ReadyList;
/*
diff --git a/src/include/threads.h b/src/include/threads.h
index beb41aae7..12737de2e 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -78,7 +78,7 @@ struct Thread {
* systems, be caruful in doing so.
*/
#ifdef CH_USE_WAITEXIT
- /** The queue of the threads waiting for this thread termination.*/
+ /** The list of the threads waiting for this thread termination.*/
ThreadsList p_waiting;
#endif
#ifdef CH_USE_EXIT_EVENT
@@ -151,10 +151,8 @@ typedef t_msg (*t_tfunc)(void *);
#ifdef CH_OPTIMIZE_SPEED
static INLINE void fifo_insert(Thread *tp, ThreadsQueue *tqp) {
- tp->p_next = (Thread *)tqp;
- tp->p_prev = tqp->p_prev;
- tqp->p_prev->p_next = tp;
- tqp->p_prev = tp;
+ tp->p_prev = (tp->p_next = (Thread *)tqp)->p_prev;
+ tp->p_prev->p_next = tqp->p_prev = tp;
}
static INLINE Thread *fifo_remove(ThreadsQueue *tqp) {