git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@29 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
e4e90fae74
commit
1b269aa139
|
@ -20,6 +20,14 @@
|
||||||
#ifndef _CHCORE_H_
|
#ifndef _CHCORE_H_
|
||||||
#define _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;
|
typedef void *regarm;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -150,6 +150,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\chinit.c">
|
RelativePath="..\..\src\chinit.c">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\chlists.c">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\chmsg.c">
|
RelativePath="..\..\src\chmsg.c">
|
||||||
</File>
|
</File>
|
||||||
|
@ -205,6 +208,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\include\events.h">
|
RelativePath="..\..\src\include\events.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\include\lists.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\include\messages.h">
|
RelativePath="..\..\src\include\messages.h">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct {
|
||||||
|
|
||||||
#define INT_REQUIRED_STACK 0x0
|
#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))
|
sizeof(struct stackregs) + (n) + (INT_REQUIRED_STACK))
|
||||||
|
|
||||||
void __fastcall chSysHalt(void);
|
void __fastcall chSysHalt(void);
|
||||||
|
|
|
@ -23,14 +23,6 @@
|
||||||
typedef volatile unsigned char IOREG8;
|
typedef volatile unsigned char IOREG8;
|
||||||
typedef volatile unsigned int IOREG32;
|
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.
|
* System.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,7 +33,8 @@ LPC214x-GCC - ChibiOS/RT port for ARM7 LPC2148, the demo targets the
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** 0.3.1 ***
|
*** 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,
|
- The list of the threads waiting in chThdWait() is now a single link list,
|
||||||
this saves some space.
|
this saves some space.
|
||||||
- Cleaned the template files code, the files contained some obsolete
|
- Cleaned the template files code, the files contained some obsolete
|
||||||
|
|
|
@ -144,7 +144,8 @@ void chEvtSendI(EventSource *esp) {
|
||||||
* This means that Event Listeners with a lower event identifier have
|
* This means that Event Listeners with a lower event identifier have
|
||||||
* an higher priority.
|
* 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_eventid i;
|
||||||
t_eventmask m;
|
t_eventmask m;
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,8 @@
|
||||||
*/
|
*/
|
||||||
void fifo_insert(Thread *tp, ThreadsQueue *tqp) {
|
void fifo_insert(Thread *tp, ThreadsQueue *tqp) {
|
||||||
|
|
||||||
tp->p_next = (Thread *)tqp;
|
tp->p_prev = (tp->p_next = (Thread *)tqp)->p_prev;
|
||||||
tp->p_prev = tqp->p_prev;
|
tp->p_prev->p_next = tqp->p_prev = tp;
|
||||||
tqp->p_prev->p_next = tp;
|
|
||||||
tqp->p_prev = tp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
18
src/chschd.c
18
src/chschd.c
|
@ -27,12 +27,12 @@
|
||||||
/** @cond never*/
|
/** @cond never*/
|
||||||
|
|
||||||
static ReadyList rlist;
|
static ReadyList rlist;
|
||||||
|
static t_cnt preempt;
|
||||||
|
|
||||||
#ifndef CH_CURRP_REGISTER_CACHE
|
#ifndef CH_CURRP_REGISTER_CACHE
|
||||||
Thread *currp;
|
Thread *currp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static t_cnt preempt;
|
|
||||||
#ifdef CH_USE_SYSTEMTIME
|
#ifdef CH_USE_SYSTEMTIME
|
||||||
t_time stime;
|
t_time stime;
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,8 +45,8 @@ t_time stime;
|
||||||
*/
|
*/
|
||||||
void chSchInit(void) {
|
void chSchInit(void) {
|
||||||
|
|
||||||
rlist.p_next = rlist.p_prev = (Thread *)&rlist;
|
fifo_init(&rlist.r_queue);
|
||||||
rlist.p_prio = ABSPRIO;
|
rlist.r_prio = ABSPRIO;
|
||||||
preempt = CH_TIME_QUANTUM;
|
preempt = CH_TIME_QUANTUM;
|
||||||
#ifdef CH_USE_SYSTEMTIME
|
#ifdef CH_USE_SYSTEMTIME
|
||||||
stime = 0;
|
stime = 0;
|
||||||
|
@ -68,7 +68,7 @@ Thread *chSchReadyI(Thread *tp) {
|
||||||
|
|
||||||
tp->p_state = PRREADY;
|
tp->p_state = PRREADY;
|
||||||
tp->p_rdymsg = RDY_OK;
|
tp->p_rdymsg = RDY_OK;
|
||||||
cp = rlist.p_prev;
|
cp = rlist.r_queue.p_prev;
|
||||||
while (cp->p_prio < prio)
|
while (cp->p_prio < prio)
|
||||||
cp = cp->p_prev;
|
cp = cp->p_prev;
|
||||||
// Insertion on p_next
|
// Insertion on p_next
|
||||||
|
@ -84,7 +84,7 @@ Thread *chSchReadyI(Thread *tp) {
|
||||||
static void nextready(void) {
|
static void nextready(void) {
|
||||||
Thread *otp = currp;
|
Thread *otp = currp;
|
||||||
|
|
||||||
(currp = fifo_remove((ThreadsQueue *)&rlist))->p_state = PRCURR;
|
(currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR;
|
||||||
preempt = CH_TIME_QUANTUM;
|
preempt = CH_TIME_QUANTUM;
|
||||||
chSysSwitchI(&otp->p_ctx, &currp->p_ctx);
|
chSysSwitchI(&otp->p_ctx, &currp->p_ctx);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ void chSchWakeupI(Thread *tp, t_msg msg) {
|
||||||
*/
|
*/
|
||||||
void chSchRescheduleI(void) {
|
void chSchRescheduleI(void) {
|
||||||
|
|
||||||
if (isempty(&rlist) || firstprio(&rlist) <= currp->p_prio)
|
if (isempty(&rlist.r_queue) || firstprio(&rlist.r_queue) <= currp->p_prio)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chSchDoRescheduleI();
|
chSchDoRescheduleI();
|
||||||
|
@ -159,15 +159,15 @@ void chSchDoRescheduleI(void) {
|
||||||
*/
|
*/
|
||||||
BOOL chSchRescRequiredI(void) {
|
BOOL chSchRescRequiredI(void) {
|
||||||
|
|
||||||
if (isempty(&rlist))
|
if (isempty(&rlist.r_queue))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (preempt) {
|
if (preempt) {
|
||||||
if (firstprio(&rlist) <= currp->p_prio)
|
if (firstprio(&rlist.r_queue) <= currp->p_prio)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else { /* Time quantum elapsed. */
|
else { /* Time quantum elapsed. */
|
||||||
if (firstprio(&rlist) < currp->p_prio)
|
if (firstprio(&rlist.r_queue) < currp->p_prio)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -81,7 +81,8 @@ void chEvtUnregister(EventSource *esp, EventListener *elp);
|
||||||
void chEvtClear(t_eventmask mask);
|
void chEvtClear(t_eventmask mask);
|
||||||
void chEvtSend(EventSource *esp);
|
void chEvtSend(EventSource *esp);
|
||||||
void chEvtSendI(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
|
#ifdef CH_USE_EVENTS_TIMEOUT
|
||||||
t_eventid chEvtWaitTimeout(t_eventmask ewmask,
|
t_eventid chEvtWaitTimeout(t_eventmask ewmask,
|
||||||
t_evhandler handlers[],
|
t_evhandler handlers[],
|
||||||
|
|
|
@ -32,18 +32,14 @@
|
||||||
/** Returned if the thread was made ready because a reset.*/
|
/** Returned if the thread was made ready because a reset.*/
|
||||||
#define RDY_RESET -2
|
#define RDY_RESET -2
|
||||||
|
|
||||||
#define firstprio(qp) ((qp)->p_next->p_prio)
|
#define firstprio(rlp) ((rlp)->p_next->p_prio)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ready list header.
|
* Ready list header.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** Highest priority \p Thread in the list.*/
|
ThreadsQueue r_queue;
|
||||||
Thread *p_next;
|
t_prio r_prio;
|
||||||
/** Lowest priority \p Thread in the list.*/
|
|
||||||
Thread *p_prev;
|
|
||||||
/** Alwas set to \p MAXPRIO.*/
|
|
||||||
t_prio p_prio;
|
|
||||||
} ReadyList;
|
} ReadyList;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -78,7 +78,7 @@ struct Thread {
|
||||||
* systems, be caruful in doing so.
|
* systems, be caruful in doing so.
|
||||||
*/
|
*/
|
||||||
#ifdef CH_USE_WAITEXIT
|
#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;
|
ThreadsList p_waiting;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CH_USE_EXIT_EVENT
|
#ifdef CH_USE_EXIT_EVENT
|
||||||
|
@ -151,10 +151,8 @@ typedef t_msg (*t_tfunc)(void *);
|
||||||
#ifdef CH_OPTIMIZE_SPEED
|
#ifdef CH_OPTIMIZE_SPEED
|
||||||
static INLINE void fifo_insert(Thread *tp, ThreadsQueue *tqp) {
|
static INLINE void fifo_insert(Thread *tp, ThreadsQueue *tqp) {
|
||||||
|
|
||||||
tp->p_next = (Thread *)tqp;
|
tp->p_prev = (tp->p_next = (Thread *)tqp)->p_prev;
|
||||||
tp->p_prev = tqp->p_prev;
|
tp->p_prev->p_next = tqp->p_prev = tp;
|
||||||
tqp->p_prev->p_next = tp;
|
|
||||||
tqp->p_prev = tp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE Thread *fifo_remove(ThreadsQueue *tqp) {
|
static INLINE Thread *fifo_remove(ThreadsQueue *tqp) {
|
||||||
|
|
Loading…
Reference in New Issue