git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@29 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2007-10-02 16:52:18 +00:00
parent e4e90fae74
commit 1b269aa139
11 changed files with 40 additions and 39 deletions

View File

@ -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;
/*

View File

@ -150,6 +150,9 @@
<File
RelativePath="..\..\src\chinit.c">
</File>
<File
RelativePath="..\..\src\chlists.c">
</File>
<File
RelativePath="..\..\src\chmsg.c">
</File>
@ -205,6 +208,9 @@
<File
RelativePath="..\..\src\include\events.h">
</File>
<File
RelativePath="..\..\src\include\lists.h">
</File>
<File
RelativePath="..\..\src\include\messages.h">
</File>

View File

@ -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);

View File

@ -23,14 +23,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.
*/

View File

@ -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

View File

@ -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;

View File

@ -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;
}
/*

View File

@ -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;

View File

@ -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[],

View File

@ -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;
/*

View File

@ -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) {