Last CooCox version

Some handlers were defined twice in vectors_sam3s.c, perhaps some others need to be checked ... later!
This commit is contained in:
bsongis
2012-06-11 18:32:11 +00:00
parent 38d5ca9236
commit 8dee4218f7
37 changed files with 556 additions and 504 deletions
-11
View File
@@ -1,11 +0,0 @@
CooCox CoOS's source code package includes the following files:
kernel: CooCox CoOS's source code, you can use it without any modification.
portable: CooCox CoOS's port for Cortex M3. It includes the source code for Cortex M3 architecture with three edition : MDK, IAR, GCC. You can choose a suitable one for your application.
config: Configuration files for CooCox CoOS. You can tailor CooCox CoOS for your application with it.
CooCox CoOS's TERMS AND CONDITIONS.pdf: The terms you should obey when using CooCox CoOS's source code.
To develop application based on CooCox CoOS, you should include all the source code files in the kernel folder, and choose an edition in portable folder for the compiler that you are using. You also should amend config.h for tailoring CooCox CoOS, otherwise CooCox CoOS may be too big for your needs.
+11 -11
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file ccrtos.h * @file CoOS.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief API header file of CooCox CoOS. * @brief API header file of CooCox CoOS.
* @details This file including all API functions's declare of CooCox CoOS. * @details This file including all API functions's declare of CooCox CoOS.
******************************************************************************* *******************************************************************************
@@ -42,16 +42,16 @@ typedef void (*vFUNCPtr)(void);
/*---------------------------- Constant Define -------------------------------*/ /*---------------------------- Constant Define -------------------------------*/
#ifndef NULL #ifndef Co_NULL
#define NULL ((void *)0) #define Co_NULL ((void *)0)
#endif #endif
#ifndef FALSE #ifndef Co_FALSE
#define FALSE (0) #define Co_FALSE (0)
#endif #endif
#ifndef TRUE #ifndef Co_TRUE
#define TRUE (1) #define Co_TRUE (1)
#endif #endif
@@ -120,11 +120,11 @@ extern OS_VER CoGetOSVersion(void); /*!< Get OS version value */
/* Implement in file "task.c" */ /* Implement in file "task.c" */
#define CoCreateTask(task,argv,prio,stk,stkSz) \ #define CoCreateTask(task,argv,prio,stk,stkSz) \
CreateTask(task,argv,(prio)|((stkSz)<<8),stk) CreateTask(task,argv,(prio)|(((stkSz)<<8) &0x000FFF00 ),stk)
#define CoCreateTaskEx(task,argv,prio,stk,stkSz,timeSlice,isWaitting) \ #define CoCreateTaskEx(task,argv,prio,stk,stkSz,timeSlice,isWaitting) \
CreateTask(task,argv,(prio)|((stkSz)<<8)|((timeSlice)<<20)|(isWaitting<<31),stk) CreateTask(task,argv,(prio)|(((stkSz)<<8)&0x000FFF00)|(((timeSlice)<<20)&0x7FF00000)|((isWaitting<<31)&0x80000000),stk)
extern void CoExitTask(void); extern void CoExitTask(void);
extern OS_TID CoGetCurTaskID(void); extern OS_TID CoGetCurTaskID(void);
+11 -11
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file config.h * @file OsConfig.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief This file use by user to configuration CooCox CoOS. * @brief This file use by user to configuration CooCox CoOS.
* @note Ensure you have knew every item before modify this file. * @note Ensure you have knew every item before modify this file.
******************************************************************************* *******************************************************************************
@@ -52,7 +52,7 @@ systick frequency (Hz).
/*!< /*!<
max systerm api call num in ISR. max systerm api call num in ISR.
*/ */
#define CFG_MAX_SERVICE_REQUEST (3) #define CFG_MAX_SERVICE_REQUEST (5)
/*!< /*!<
Enable(1) or disable(0) order list schedule. Enable(1) or disable(0) order list schedule.
@@ -198,22 +198,22 @@ Event sort type.(1)FIFO (2)PRI (3)FIFO+PRI
Max number of event.(must be less than 255) Max number of event.(must be less than 255)
Event = semaphore + mailbox + queue; Event = semaphore + mailbox + queue;
*/ */
#define CFG_MAX_EVENT (10) #define CFG_MAX_EVENT (20)
/*!< /*!<
Enable(1) or disable(0) semaphore management. Enable(1) or disable(0) semaphore management.
*/ */
#define CFG_SEM_EN (1) #define CFG_SEM_EN (0)
/*!< /*!<
Enable(1) or disable(0) mailbox management. Enable(1) or disable(0) mailbox management.
*/ */
#define CFG_MAILBOX_EN (1) #define CFG_MAILBOX_EN (0)
/*!< /*!<
Enable(1) or disable(0) queue management. Enable(1) or disable(0) queue management.
*/ */
#define CFG_QUEUE_EN (1) #define CFG_QUEUE_EN (0)
/*!< /*!<
Max number of queue.(less than CFG_MAX_EVENT). Max number of queue.(less than CFG_MAX_EVENT).
@@ -232,7 +232,7 @@ Enable(1) or disable(0) flag management.
Max number of flag is 32. Max number of flag is 32.
*/ */
#if CFG_TASK_WAITTING_EN > 0 #if CFG_TASK_WAITTING_EN > 0
#define CFG_FLAG_EN (1) #define CFG_FLAG_EN (0)
#endif #endif
@@ -242,7 +242,7 @@ Enable(1) or disable(0) mutex management.
*/ */
#if CFG_TASK_WAITTING_EN > 0 #if CFG_TASK_WAITTING_EN > 0
#if CFG_TASK_SCHEDULE_EN > 0 #if CFG_TASK_SCHEDULE_EN > 0
#define CFG_MUTEX_EN (1) #define CFG_MUTEX_EN (0)
#endif #endif
#endif #endif
@@ -258,7 +258,7 @@ Max number of mutex.(must be less than 255).
/*!< /*!<
Enable(1) or disable(0) utility management. Enable(1) or disable(0) utility management.
*/ */
#define CFG_UTILITY_EN (1) #define CFG_UTILITY_EN (0)
#if CFG_UTILITY_EN >0 #if CFG_UTILITY_EN >0
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file core.h * @file OsCore.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Header file related to kernel * @brief Header file related to kernel
******************************************************************************* *******************************************************************************
* @copy * @copy
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file error.h * @file OsError.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief rror dispose header file * @brief rror dispose header file
* @details This file use to dispose error which from error configure for OS. * @details This file use to dispose error which from error configure for OS.
******************************************************************************* *******************************************************************************
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file event.h * @file OsEvent.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Event management header file * @brief Event management header file
* @details This file including some defines and declares related to event * @details This file including some defines and declares related to event
* (semaphore,mailbox,queque) management. * (semaphore,mailbox,queque) management.
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file flag.h * @file OsFlag.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Evnet flag management header file * @brief Evnet flag management header file
* @details This file including some defines and declares about flag management. * @details This file including some defines and declares about flag management.
******************************************************************************* *******************************************************************************
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file kernelHeap.h * @file OsKernelHeap.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Header file related to memory management * @brief Header file related to memory management
* @details This file including some defines and function declare related to * @details This file including some defines and function declare related to
* kernel heap management. * kernel heap management.
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file mm.h * @file OsMm.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Header file related to memory management * @brief Header file related to memory management
* @details This file including some defines and function declare related to * @details This file including some defines and function declare related to
* memory management. * memory management.
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file mutex.h * @file OsMutex.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Mutex management header file * @brief Mutex management header file
* @details This file including some defines and declare related to mutex * @details This file including some defines and declare related to mutex
* management. * management.
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file queue.h * @file OsQueue.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Queue management header file * @brief Queue management header file
* @details This file including some defines and declares about queue management. * @details This file including some defines and declares about queue management.
******************************************************************************* *******************************************************************************
+5 -3
View File
@@ -1,9 +1,9 @@
/** /**
******************************************************************************* *******************************************************************************
* @file serviceReq.h * @file OsServiceReq.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Header file related to service request * @brief Header file related to service request
* @details This file including some defines and function declare related to * @details This file including some defines and function declare related to
* service request. * service request.
@@ -26,6 +26,7 @@
#define FLAG_REQ (U8)0x3 #define FLAG_REQ (U8)0x3
#define QUEUE_REQ (U8)0x4 #define QUEUE_REQ (U8)0x4
typedef struct ServiceReqCell typedef struct ServiceReqCell
{ {
U8 type; U8 type;
@@ -36,6 +37,7 @@ typedef struct ServiceReqCell
typedef struct ServiceReqQueue typedef struct ServiceReqQueue
{ {
U8 cnt; U8 cnt;
U8 head;
SQC cell[CFG_MAX_SERVICE_REQUEST]; SQC cell[CFG_MAX_SERVICE_REQUEST];
}SRQ,*P_SRQ; }SRQ,*P_SRQ;
+6 -6
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file task.h * @file OsTask.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Header file related to task. * @brief Header file related to task.
* @details This file including some defines and function declare related to task. * @details This file including some defines and function declare related to task.
******************************************************************************* *******************************************************************************
@@ -93,9 +93,9 @@ extern P_OSTCB TCBNext; /*!< A pointer to TCB next be scheduled. */
extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */ extern P_OSTCB TCBRunning; /*!< A pointer to TCB that is running. */
extern U64 OSCheckTime; extern U64 OSCheckTime;
extern U8 OSIntNesting; /*!< Use to indicate interrupt nesting level. */ extern volatile U8 OSIntNesting; /*!< Use to indicate interrupt nesting level.*/
extern U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK). */ extern volatile U8 OSSchedLock; /*!< Schedule is lock(LOCK) or unlock(UN_LOCK).*/
extern BOOL TaskSchedReq; extern volatile BOOL TaskSchedReq;
extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE]; extern OS_STK idle_stk[CFG_IDLE_STACK_SIZE];
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file task.c * @file OsTime.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Header file related to time management * @brief Header file related to time management
* @details Thie file including some data declare related to time managment. * @details Thie file including some data declare related to time managment.
******************************************************************************* *******************************************************************************
+3 -3
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file timer.h * @file OsTimer.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Timer manage header file * @brief Timer manage header file
* @details This file including some declares and defines related to timer * @details This file including some declares and defines related to timer
* management. * management.
+4 -4
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file coocox.h * @file coocox.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Gather for all header file of CooCox CoOS. * @brief Gather for all header file of CooCox CoOS.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -17,8 +17,8 @@
#ifndef _COOCOX_H #ifndef _COOCOX_H
#define _COOCOX_H #define _COOCOX_H
#define OS_VERSION (U16)0x0112 /*!< OS version.(format: Vx.xx), #define OS_VERSION (U16)0x0113 /*!< OS version.(format: Vx.xx),
e.g. value 0x0111 is version V1.12*/ e.g. value 0x0113 is version V1.13*/
/*---------------------------- Include ---------------------------------------*/ /*---------------------------- Include ---------------------------------------*/
#include "CoOS.h" #include "CoOS.h"
#include "OsArch.h" #include "OsArch.h"
+10 -10
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file core.c * @file core.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Core implementation code of CooCox CoOS kernel. * @brief Core implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -17,9 +17,9 @@
#include <coocox.h> #include <coocox.h>
/*---------------------------- Variable Define -------------------------------*/ /*---------------------------- Variable Define -------------------------------*/
U8 OSIntNesting = 0; /*!< Use to indicate interrupt nesting level*/ volatile U8 OSIntNesting = 0; /*!< Use to indicate interrupt nesting level*/
U8 OSSchedLock = 0; /*!< Task Switch lock. */ volatile U8 OSSchedLock = 0; /*!< Task Switch lock. */
BOOL TaskSchedReq = FALSE; volatile BOOL TaskSchedReq = Co_FALSE;
/** /**
@@ -61,7 +61,7 @@ void CoExitISR(void)
Dec8(&OSIntNesting); /* OSIntNesting decrease */ Dec8(&OSIntNesting); /* OSIntNesting decrease */
if( OSIntNesting == 0) /* Is OSIntNesting == 0? */ if( OSIntNesting == 0) /* Is OSIntNesting == 0? */
{ {
if(TaskSchedReq == TRUE) if(TaskSchedReq == Co_TRUE)
{ {
OSSchedLock++; OSSchedLock++;
Schedule(); /* Call task schedule */ Schedule(); /* Call task schedule */
@@ -90,13 +90,13 @@ void OsSchedUnlock(void)
if(OSSchedLock == 1) /* Is OSSchedLock == 0? */ if(OSSchedLock == 1) /* Is OSSchedLock == 0? */
{ {
#if CFG_TASK_WAITTING_EN > 0 #if CFG_TASK_WAITTING_EN > 0
if(IsrReq == TRUE) if(IsrReq == Co_TRUE)
{ {
RespondSRQ(); /* Respond service request */ RespondSRQ(); /* Respond service request */
} }
#endif #endif
/* Judge task state change or higher PRI task coming in */ /* Judge task state change or higher PRI task coming in */
if(TaskSchedReq == TRUE) if(TaskSchedReq == Co_TRUE)
{ {
Schedule(); /* Call task schedule */ Schedule(); /* Call task schedule */
} }
@@ -184,7 +184,7 @@ void CoInitOS(void)
OsSchedLock(); /* Lock Schedule */ OsSchedLock(); /* Lock Schedule */
/* Create first task -- IDLE task. */ /* Create first task -- IDLE task. */
CoCreateTask( CoIdleTask, CoCreateTask( CoIdleTask,
NULL, Co_NULL,
CFG_LOWEST_PRIO, CFG_LOWEST_PRIO,
&idle_stk[CFG_IDLE_STACK_SIZE-1], &idle_stk[CFG_IDLE_STACK_SIZE-1],
CFG_IDLE_STACK_SIZE CFG_IDLE_STACK_SIZE
+35 -35
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file event.c * @file event.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief event management implementation code of CooCox CoOS kernel. * @brief event management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -22,7 +22,7 @@
#if CFG_EVENT_EN > 0 #if CFG_EVENT_EN > 0
ECB EventTbl[CFG_MAX_EVENT]= {{0}};/*!< Table which save event control block.*/ ECB EventTbl[CFG_MAX_EVENT]= {{0}};/*!< Table which save event control block.*/
P_ECB FreeEventList = NULL; /*!< Pointer to free event control block. */ P_ECB FreeEventList = Co_NULL; /*!< Pointer to free event control block. */
/** /**
@@ -47,7 +47,7 @@ void CreateEventList(void)
i=0; i=0;
pecb1 = &EventTbl[0]; /* Get first item */ pecb1 = &EventTbl[0]; /* Get first item */
#if CFG_MAX_EVENT == 1 /* Build event list for only one item */ #if CFG_MAX_EVENT == 1 /* Build event list for only one item */
pecb1->eventPtr = NULL; pecb1->eventPtr = Co_NULL;
pecb1->id = i; /* Assign ID. */ pecb1->id = i; /* Assign ID. */
pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */
#endif #endif
@@ -63,7 +63,7 @@ void CreateEventList(void)
pecb2++; pecb2++;
} }
pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */ pecb1->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */
pecb1->eventPtr = NULL; /* Set link for last item */ pecb1->eventPtr = Co_NULL; /* Set link for last item */
pecb1->id = i; pecb1->id = i;
#endif #endif
@@ -101,10 +101,10 @@ static void ReleaseECB(P_ECB pecb)
* @param[in] eventType The type of event which being created. * @param[in] eventType The type of event which being created.
* @param[in] eventSortType Event sort type. * @param[in] eventSortType Event sort type.
* @param[in] eventCounter Event counter,ONLY for EVENT_TYPE_SEM. * @param[in] eventCounter Event counter,ONLY for EVENT_TYPE_SEM.
* @param[in] eventPtr Event struct pointer,ONLY for Queue.NULL for other * @param[in] eventPtr Event struct pointer,ONLY for Queue.Co_NULL for other
* event type. * event type.
* @param[out] None * @param[out] None
* @retval NULL Invalid pointer,create event fail. * @retval Co_NULL Invalid pointer,create event fail.
* @retval others Pointer to event control block which had assigned right now. * @retval others Pointer to event control block which had assigned right now.
* *
* @par Description * @par Description
@@ -119,10 +119,10 @@ P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr)
P_ECB pecb; P_ECB pecb;
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
if(FreeEventList == NULL) /* Is there no free evnet item */ if(FreeEventList == Co_NULL) /* Is there no free evnet item */
{ {
OsSchedUnlock(); /* Yes,unlock schedule */ OsSchedUnlock(); /* Yes,unlock schedule */
return NULL; /* Return error */ return Co_NULL; /* Return error */
} }
pecb = FreeEventList;/* Assign the free event item to this event */ pecb = FreeEventList;/* Assign the free event item to this event */
FreeEventList = FreeEventList->eventPtr; /* Reset free event item */ FreeEventList = FreeEventList->eventPtr; /* Reset free event item */
@@ -131,7 +131,7 @@ P_ECB CreatEvent(U8 eventType,U8 eventSortType,void* eventPtr)
pecb->eventType = eventType; /* Initialize event item as user set */ pecb->eventType = eventType; /* Initialize event item as user set */
pecb->eventSortType = eventSortType; pecb->eventSortType = eventSortType;
pecb->eventPtr = eventPtr; pecb->eventPtr = eventPtr;
pecb->eventTCBList = NULL; pecb->eventTCBList = Co_NULL;
return pecb; /* Return event item pointer */ return pecb; /* Return event item pointer */
} }
@@ -160,7 +160,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
P_OSTCB ptcb; P_OSTCB ptcb;
if(opt == OPT_DEL_NO_PEND) /* Do delete event when no task pend? */ if(opt == OPT_DEL_NO_PEND) /* Do delete event when no task pend? */
{ {
if(pecb->eventTCBList != NULL) /* Yes,is there task pend this event? */ if(pecb->eventTCBList != Co_NULL) /* Yes,is there task pend this event? */
{ {
return E_TASK_WAITING; /* Yes,error return */ return E_TASK_WAITING; /* Yes,error return */
} }
@@ -172,7 +172,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
else if(opt == OPT_DEL_ANYWAY) /* Do delete event anyway? */ else if(opt == OPT_DEL_ANYWAY) /* Do delete event anyway? */
{ {
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
while(pecb->eventTCBList != NULL) /* Is there task pend this event? */ while(pecb->eventTCBList != Co_NULL) /* Is there task pend this event? */
{ /* Yes,remove it */ { /* Yes,remove it */
ptcb = pecb->eventTCBList;/* Get first task in event waiting list */ ptcb = pecb->eventTCBList;/* Get first task in event waiting list */
if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */ if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */
@@ -182,7 +182,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
/* Set next item as event waiting list head */ /* Set next item as event waiting list head */
pecb->eventTCBList = ptcb->waitNext; pecb->eventTCBList = ptcb->waitNext;
ptcb->waitNext = NULL; /* Clear link for event waiting list */ ptcb->waitNext = Co_NULL; /* Clear link for event waiting list */
ptcb->eventID = INVALID_ID; /* Sign that not to use. */ ptcb->eventID = INVALID_ID; /* Sign that not to use. */
InsertToTCBRdyList(ptcb); /* Insert task into ready list */ InsertToTCBRdyList(ptcb); /* Insert task into ready list */
@@ -207,7 +207,7 @@ StatusType DeleteEvent(P_ECB pecb,U8 opt)
* opt == EVENT_SORT_TYPE_FIFO By FIFO. * opt == EVENT_SORT_TYPE_FIFO By FIFO.
* opt == EVENT_SORT_TYPE_PRIO By priority order,hghest priority * opt == EVENT_SORT_TYPE_PRIO By priority order,hghest priority
* as head,lowest priority as end. * as head,lowest priority as end.
* (Highest-->...-->Lowest-->NULL) * (Highest-->...-->Lowest-->Co_NULL)
******************************************************************************* *******************************************************************************
*/ */
void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb) void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
@@ -228,13 +228,13 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
#if (CFG_EVENT_SORT == 1) || (CFG_EVENT_SORT == 3) #if (CFG_EVENT_SORT == 1) || (CFG_EVENT_SORT == 3)
{ {
if(ptcb1 == NULL) /* Is no item in event waiting list?*/ if(ptcb1 == Co_NULL) /* Is no item in event waiting list?*/
{ {
pecb->eventTCBList = ptcb; /* Yes,set task as first item */ pecb->eventTCBList = ptcb; /* Yes,set task as first item */
} }
else else
{ {
while(ptcb1->waitNext != NULL)/* No,insert task in last */ while(ptcb1->waitNext != Co_NULL)/* No,insert task in last */
{ {
ptcb1 = ptcb1->waitNext; ptcb1 = ptcb1->waitNext;
} }
@@ -249,7 +249,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
#endif #endif
#if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3) #if (CFG_EVENT_SORT == 2) || (CFG_EVENT_SORT == 3)
{ {
if(ptcb1 == NULL) /* Is no item in event waiting list? */ if(ptcb1 == Co_NULL) /* Is no item in event waiting list? */
{ {
pecb->eventTCBList = ptcb; /* Yes,set task as first item */ pecb->eventTCBList = ptcb; /* Yes,set task as first item */
} }
@@ -263,7 +263,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
else /* No,find correct place to insert */ else /* No,find correct place to insert */
{ {
ptcb2 = ptcb1->waitNext; ptcb2 = ptcb1->waitNext;
while(ptcb2 != NULL) /* Is last item? */ while(ptcb2 != Co_NULL) /* Is last item? */
{ {
if(ptcb2->prio > ptcb->prio) /* No,is correct place? */ if(ptcb2->prio > ptcb->prio) /* No,is correct place? */
{ {
@@ -275,7 +275,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
ptcb1->waitNext = ptcb; /* Set link for list */ ptcb1->waitNext = ptcb; /* Set link for list */
ptcb->waitPrev = ptcb1; ptcb->waitPrev = ptcb1;
ptcb->waitNext = ptcb2; ptcb->waitNext = ptcb2;
if(ptcb2 != NULL) if(ptcb2 != Co_NULL)
{ {
ptcb2->waitPrev = ptcb; ptcb2->waitPrev = ptcb;
} }
@@ -283,7 +283,7 @@ void EventTaskToWait(P_ECB pecb,P_OSTCB ptcb)
} }
#endif #endif
ptcb->state = TASK_WAITING; /* Set task status to TASK_WAITING state */ ptcb->state = TASK_WAITING; /* Set task status to TASK_WAITING state */
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
OsSchedUnlock(); /* Unlock schedule,and call task schedule */ OsSchedUnlock(); /* Unlock schedule,and call task schedule */
} }
@@ -307,16 +307,16 @@ void EventTaskToRdy(P_ECB pecb)
P_QCB pqcb; P_QCB pqcb;
#endif #endif
ptcb = pecb->eventTCBList; ptcb = pecb->eventTCBList;
if(ptcb == NULL) if(ptcb == Co_NULL)
return; return;
pecb->eventTCBList = ptcb->waitNext;/* Get first task in event waiting list*/ pecb->eventTCBList = ptcb->waitNext;/* Get first task in event waiting list*/
if(pecb->eventTCBList != NULL) /* Is no item in event waiting list? */ if(pecb->eventTCBList != Co_NULL) /* Is no item in event waiting list? */
{ {
pecb->eventTCBList->waitPrev = NULL; /* No,clear link for first item */ pecb->eventTCBList->waitPrev = Co_NULL; /* No,clear link for first item */
} }
ptcb->waitNext = NULL; /* Clear event waiting link for task*/ ptcb->waitNext = Co_NULL; /* Clear event waiting link for task*/
ptcb->eventID = INVALID_ID; /* Sign that not to use. */ ptcb->eventID = INVALID_ID; /* Sign that not to use. */
if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */ if(ptcb->delayTick != INVALID_VALUE) /* Is task in delay list? */
@@ -326,7 +326,7 @@ void EventTaskToRdy(P_ECB pecb)
if(pecb->eventType == EVENT_TYPE_MBOX)/* Is it a mailbox event? */ if(pecb->eventType == EVENT_TYPE_MBOX)/* Is it a mailbox event? */
{ {
ptcb->pmail = pecb->eventPtr; /* Yes,send mail to task */ ptcb->pmail = pecb->eventPtr; /* Yes,send mail to task */
pecb->eventPtr = NULL; /* Clear event sign */ pecb->eventPtr = Co_NULL; /* Clear event sign */
pecb->eventCounter--; pecb->eventCounter--;
} }
#if CFG_QUEUE_EN >0 #if CFG_QUEUE_EN >0
@@ -380,28 +380,28 @@ void RemoveEventWaittingList(P_OSTCB ptcb)
pecb = &EventTbl[ptcb->eventID]; /* Get event control block */ pecb = &EventTbl[ptcb->eventID]; /* Get event control block */
/* Is there only one item in event waiting list? */ /* Is there only one item in event waiting list? */
if((ptcb->waitNext == NULL) && (ptcb->waitPrev == NULL)) if((ptcb->waitNext == Co_NULL) && (ptcb->waitPrev == Co_NULL))
{ {
pecb->eventTCBList = NULL; /* Yes,set event waiting list as NULL */ pecb->eventTCBList = Co_NULL; /* Yes,set event waiting list as Co_NULL */
} }
else if(ptcb->waitPrev == NULL)/* Is the first item in event waiting list?*/ else if(ptcb->waitPrev == Co_NULL)/* Is the first item in event waiting list?*/
{ {
/* Yes,remove task from list,and reset event waiting list */ /* Yes,remove task from list,and reset event waiting list */
ptcb->waitNext->waitPrev = NULL; ptcb->waitNext->waitPrev = Co_NULL;
pecb->eventTCBList = ptcb->waitNext; pecb->eventTCBList = ptcb->waitNext;
ptcb->waitNext = NULL; ptcb->waitNext = Co_NULL;
} }
else if(ptcb->waitNext == NULL)/* Is the last item in event waiting list? */ else if(ptcb->waitNext == Co_NULL)/* Is the last item in event waiting list? */
{ {
ptcb->waitPrev->waitNext = NULL; /* Yes,remove task form list */ ptcb->waitPrev->waitNext = Co_NULL; /* Yes,remove task form list */
ptcb->waitPrev = NULL; ptcb->waitPrev = Co_NULL;
} }
else /* No, remove task from list */ else /* No, remove task from list */
{ {
ptcb->waitPrev->waitNext = ptcb->waitNext; ptcb->waitPrev->waitNext = ptcb->waitNext;
ptcb->waitNext->waitPrev = ptcb->waitPrev; ptcb->waitNext->waitPrev = ptcb->waitPrev;
ptcb->waitPrev = NULL; ptcb->waitPrev = Co_NULL;
ptcb->waitNext = NULL; ptcb->waitNext = Co_NULL;
} }
ptcb->eventID = INVALID_ID; /* Sign that not to use. */ ptcb->eventID = INVALID_ID; /* Sign that not to use. */
} }
+26 -26
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file flag.c * @file flag.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Flag management implementation code of coocox CoOS kernel. * @brief Flag management implementation code of coocox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -31,7 +31,7 @@ static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode);
/** /**
******************************************************************************* *******************************************************************************
* @brief Create a flag * @brief Create a flag
* @param[in] bAutoReset Reset mode,TRUE(Auto Reset) FLASE(Manual Reset). * @param[in] bAutoReset Reset mode,Co_TRUE(Auto Reset) FLASE(Manual Reset).
* @param[in] bInitialState Initial state. * @param[in] bInitialState Initial state.
* @param[out] None * @param[out] None
* @retval E_CREATE_FAIL Create flag fail. * @retval E_CREATE_FAIL Create flag fail.
@@ -99,7 +99,7 @@ StatusType CoDelFlag(OS_FlagID id,U8 opt)
OsSchedLock(); OsSchedLock();
pnode = pfcb->headNode; pnode = pfcb->headNode;
while(pnode != NULL) /* Ready all tasks waiting for flags */ while(pnode != Co_NULL) /* Ready all tasks waiting for flags */
{ {
if((pnode->waitFlags&(1<<id)) != 0) /* If no task is waiting on flags */ if((pnode->waitFlags&(1<<id)) != 0) /* If no task is waiting on flags */
{ {
@@ -305,11 +305,11 @@ StatusType CoWaitForSingleFlag(OS_FlagID id,U32 timeout)
/* Block task until the required flag is set */ /* Block task until the required flag is set */
FlagBlock (&flagNode,(1<<id),OPT_WAIT_ONE); FlagBlock (&flagNode,(1<<id),OPT_WAIT_ONE);
curTCB->state = TASK_WAITING; curTCB->state = TASK_WAITING;
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
OsSchedUnlock(); OsSchedUnlock();
/* The required flag is set and the task is in running state */ /* The required flag is set and the task is in running state */
curTCB->pnode = NULL; curTCB->pnode = Co_NULL;
OsSchedLock(); OsSchedLock();
/* Clear the required flag or not */ /* Clear the required flag or not */
@@ -323,13 +323,13 @@ StatusType CoWaitForSingleFlag(OS_FlagID id,U32 timeout)
InsertDelayList(curTCB,timeout); InsertDelayList(curTCB,timeout);
OsSchedUnlock(); OsSchedUnlock();
if(curTCB->pnode == NULL) /* If time-out occurred */ if(curTCB->pnode == Co_NULL) /* If time-out occurred */
{ {
return E_TIMEOUT; return E_TIMEOUT;
} }
else /* If flag is set */ else /* If flag is set */
{ {
curTCB->pnode = NULL; curTCB->pnode = Co_NULL;
OsSchedLock(); OsSchedLock();
/* Clear the required flag or not */ /* Clear the required flag or not */
@@ -410,10 +410,10 @@ U32 CoWaitForMultipleFlags(U32 flags,U8 waitType,U32 timeout,StatusType *perr)
/* Block task until the required flag are set */ /* Block task until the required flag are set */
FlagBlock(&flagNode,flags,waitType); FlagBlock(&flagNode,flags,waitType);
curTCB->state = TASK_WAITING; curTCB->state = TASK_WAITING;
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
OsSchedUnlock(); OsSchedUnlock();
curTCB->pnode = NULL; curTCB->pnode = Co_NULL;
OsSchedLock(); OsSchedLock();
springFlag = flags & pfcb->flagRdy; springFlag = flags & pfcb->flagRdy;
pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt);/* Clear the flags */ pfcb->flagRdy &= ~(springFlag & pfcb->resetOpt);/* Clear the flags */
@@ -428,14 +428,14 @@ U32 CoWaitForMultipleFlags(U32 flags,U8 waitType,U32 timeout,StatusType *perr)
InsertDelayList(curTCB,timeout); InsertDelayList(curTCB,timeout);
OsSchedUnlock(); OsSchedUnlock();
if(curTCB->pnode == NULL) /* If time-out occurred */ if(curTCB->pnode == Co_NULL) /* If time-out occurred */
{ {
*perr = E_TIMEOUT; *perr = E_TIMEOUT;
return 0; return 0;
} }
else /* If the required flags are set */ else /* If the required flags are set */
{ {
curTCB->pnode = NULL; curTCB->pnode = Co_NULL;
OsSchedLock(); OsSchedLock();
springFlag = flags & FlagCrl.flagRdy; springFlag = flags & FlagCrl.flagRdy;
@@ -522,7 +522,7 @@ StatusType CoSetFlag(OS_FlagID id)
OsSchedLock(); OsSchedLock();
pnode = pfcb->headNode; pnode = pfcb->headNode;
while(pnode != NULL) while(pnode != Co_NULL)
{ {
if(pnode->waitType == OPT_WAIT_ALL) /* Extract all the bits we want */ if(pnode->waitType == OPT_WAIT_ALL) /* Extract all the bits we want */
{ {
@@ -577,7 +577,7 @@ StatusType isr_SetFlag(OS_FlagID id)
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
{ {
/* Insert the request into service request queue */ /* Insert the request into service request queue */
if(InsertInSRQ(FLAG_REQ,id,NULL) == FALSE) if(InsertInSRQ(FLAG_REQ,id,Co_NULL) == Co_FALSE)
{ {
return E_SEV_REQ_FULL; /* The service requst queue is full */ return E_SEV_REQ_FULL; /* The service requst queue is full */
} }
@@ -617,17 +617,17 @@ static void FlagBlock(P_FLAG_NODE pnode,U32 flags,U8 waitType)
pnode->waitFlags = flags; /* Save the flags that we need to wait for*/ pnode->waitFlags = flags; /* Save the flags that we need to wait for*/
pnode->waitType = waitType; /* Save the type of wait */ pnode->waitType = waitType; /* Save the type of wait */
if(pfcb->tailNode == NULL) /* If this is the first NODE to insert? */ if(pfcb->tailNode == Co_NULL) /* If this is the first NODE to insert? */
{ {
pnode->nextNode = NULL; pnode->nextNode = Co_NULL;
pnode->prevNode = NULL; pnode->prevNode = Co_NULL;
pfcb->headNode = pnode; /* Insert the NODE to the head */ pfcb->headNode = pnode; /* Insert the NODE to the head */
} }
else /* If it is not the first NODE to insert? */ else /* If it is not the first NODE to insert? */
{ {
pfcb->tailNode->nextNode = pnode; /* Insert the NODE to the tail */ pfcb->tailNode->nextNode = pnode; /* Insert the NODE to the tail */
pnode->prevNode = pfcb->tailNode; pnode->prevNode = pfcb->tailNode;
pnode->nextNode = NULL; pnode->nextNode = Co_NULL;
} }
pfcb->tailNode = pnode; pfcb->tailNode = pnode;
} }
@@ -686,27 +686,27 @@ static P_FLAG_NODE RemoveFromLink(P_FLAG_NODE pnode)
void RemoveLinkNode(P_FLAG_NODE pnode) void RemoveLinkNode(P_FLAG_NODE pnode)
{ {
/* If only one NODE in the list*/ /* If only one NODE in the list*/
if((pnode->nextNode == NULL) && (pnode->prevNode == NULL)) if((pnode->nextNode == Co_NULL) && (pnode->prevNode == Co_NULL))
{ {
FlagCrl.headNode = NULL; FlagCrl.headNode = Co_NULL;
FlagCrl.tailNode = NULL; FlagCrl.tailNode = Co_NULL;
} }
else if(pnode->nextNode == NULL) /* If the NODE is tail */ else if(pnode->nextNode == Co_NULL) /* If the NODE is tail */
{ {
FlagCrl.tailNode = pnode->prevNode; FlagCrl.tailNode = pnode->prevNode;
pnode->prevNode->nextNode = NULL; pnode->prevNode->nextNode = Co_NULL;
} }
else if(pnode->prevNode == NULL) /* If the NODE is head */ else if(pnode->prevNode == Co_NULL) /* If the NODE is head */
{ {
FlagCrl.headNode = pnode->nextNode; FlagCrl.headNode = pnode->nextNode;
pnode->nextNode->prevNode = NULL; pnode->nextNode->prevNode = Co_NULL;
} }
else /* The NODE is in the middle */ else /* The NODE is in the middle */
{ {
pnode->nextNode->prevNode = pnode->prevNode; pnode->nextNode->prevNode = pnode->prevNode;
pnode->prevNode->nextNode = pnode->nextNode; pnode->prevNode->nextNode = pnode->nextNode;
} }
pnode->waitTask->pnode = NULL; pnode->waitTask->pnode = Co_NULL;
} }
#endif #endif
+2 -2
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file hook.c * @file hook.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief hook management implementation code of CooCox CoOS kernel. * @brief hook management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
+41 -41
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file kernelHeap.c * @file kernelHeap.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief kernel heap management implementation code of CooCox CoOS kernel. * @brief kernel heap management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -21,7 +21,7 @@
#if CFG_KHEAP_EN >0 #if CFG_KHEAP_EN >0
/*---------------------------- Variable Define -------------------------------*/ /*---------------------------- Variable Define -------------------------------*/
U32 KernelHeap[KHEAP_SIZE] = {0}; /*!< Kernel heap */ U32 KernelHeap[KHEAP_SIZE] = {0}; /*!< Kernel heap */
P_FMB FMBlist = NULL; /*!< Free memory block list */ P_FMB FMBlist = Co_NULL; /*!< Free memory block list */
KHeap Kheap = {0}; /*!< Kernel heap control */ KHeap Kheap = {0}; /*!< Kernel heap control */
@@ -43,9 +43,9 @@ void CoCreateKheap(void)
Kheap.startAddr = (U32)(KernelHeap); /* Initialize kernel heap control */ Kheap.startAddr = (U32)(KernelHeap); /* Initialize kernel heap control */
Kheap.endAddr = (U32)(KernelHeap) + KHEAP_SIZE*4; Kheap.endAddr = (U32)(KernelHeap) + KHEAP_SIZE*4;
FMBlist = (P_FMB)KernelHeap; /* Initialize free memory block list*/ FMBlist = (P_FMB)KernelHeap; /* Initialize free memory block list*/
FMBlist->nextFMB = NULL; FMBlist->nextFMB = Co_NULL;
FMBlist->nextUMB = NULL; FMBlist->nextUMB = Co_NULL;
FMBlist->preUMB = NULL; FMBlist->preUMB = Co_NULL;
} }
@@ -54,7 +54,7 @@ void CoCreateKheap(void)
* @brief Allocation size bytes of memory block from kernel heap. * @brief Allocation size bytes of memory block from kernel heap.
* @param[in] size Length of menory block. * @param[in] size Length of menory block.
* @param[out] None * @param[out] None
* @retval NULL Allocate fail. * @retval Co_NULL Allocate fail.
* @retval others Pointer to memory block. * @retval others Pointer to memory block.
* *
* @par Description * @par Description
@@ -72,7 +72,7 @@ void* CoKmalloc(U32 size)
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ #if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if( size == 0 ) if( size == 0 )
{ {
return NULL; return Co_NULL;
} }
#endif #endif
@@ -81,10 +81,10 @@ void* CoKmalloc(U32 size)
kheapAddr = Kheap.endAddr; /* Get the end address of kernel heap */ kheapAddr = Kheap.endAddr; /* Get the end address of kernel heap */
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
freeMB = FMBlist; /* Get first item of free memory list */ freeMB = FMBlist; /* Get first item of free memory list */
preFMB = NULL; preFMB = Co_NULL;
while(freeMB != NULL ) /* Is out of free memory list? */ while(freeMB != Co_NULL ) /* Is out of free memory list? */
{ /* No */ { /* No */
if(freeMB->nextUMB == NULL) /* Is last item of free memory list? */ if(freeMB->nextUMB == Co_NULL) /* Is last item of free memory list? */
{ /* Yes,get size for this free item */ { /* Yes,get size for this free item */
freeSize = kheapAddr - (U32)(freeMB); freeSize = kheapAddr - (U32)(freeMB);
} }
@@ -104,7 +104,7 @@ void* CoKmalloc(U32 size)
{ {
/* Yes,malloc together(12 is the size of the header information /* Yes,malloc together(12 is the size of the header information
of free memory block ). */ of free memory block ). */
if(preFMB != NULL)/* Is first item of free memory block list? */ if(preFMB != Co_NULL)/* Is first item of free memory block list? */
{ /* No,set the link for list */ { /* No,set the link for list */
preFMB->nextFMB = freeMB->nextFMB; preFMB->nextFMB = freeMB->nextFMB;
} }
@@ -113,7 +113,7 @@ void* CoKmalloc(U32 size)
FMBlist = freeMB->nextFMB; FMBlist = freeMB->nextFMB;
} }
if(freeMB->nextUMB != NULL) /* Is last item? */ if(freeMB->nextUMB != Co_NULL) /* Is last item? */
{ /* No,set the link for list */ { /* No,set the link for list */
tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1); tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1);
tmpUMB->preMB = (void*)((U32)usedMB|0x1); tmpUMB->preMB = (void*)((U32)usedMB|0x1);
@@ -127,7 +127,7 @@ void* CoKmalloc(U32 size)
/* Get new free memory block address */ /* Get new free memory block address */
newFMB = (P_FMB)((U32)(freeMB) + size); newFMB = (P_FMB)((U32)(freeMB) + size);
if(preFMB != NULL)/* Is first item of free memory block list? */ if(preFMB != Co_NULL)/* Is first item of free memory block list? */
{ {
preFMB->nextFMB = newFMB; /* No,set the link for list */ preFMB->nextFMB = newFMB; /* No,set the link for list */
} }
@@ -141,7 +141,7 @@ void* CoKmalloc(U32 size)
newFMB->nextUMB = freeMB->nextUMB; newFMB->nextUMB = freeMB->nextUMB;
newFMB->nextFMB = freeMB->nextFMB; newFMB->nextFMB = freeMB->nextFMB;
if(freeMB->nextUMB != NULL) /* Is last item? */ if(freeMB->nextUMB != Co_NULL) /* Is last item? */
{ /* No,set the link for list */ { /* No,set the link for list */
tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1); tmpUMB = (P_UMB)((U32)(freeMB->nextUMB)-1);
tmpUMB->preMB = newFMB; tmpUMB->preMB = newFMB;
@@ -151,7 +151,7 @@ void* CoKmalloc(U32 size)
usedMB->preMB = freeMB->preUMB; usedMB->preMB = freeMB->preUMB;
} }
if(freeMB->preUMB != NULL) /* Is first item? */ if(freeMB->preUMB != Co_NULL) /* Is first item? */
{ /* No,set the link for list */ { /* No,set the link for list */
tmpUMB = (P_UMB)((U32)(freeMB->preUMB)-1); tmpUMB = (P_UMB)((U32)(freeMB->preUMB)-1);
tmpUMB->nextMB = (void*)((U32)usedMB|0x1); tmpUMB->nextMB = (void*)((U32)usedMB|0x1);
@@ -164,7 +164,7 @@ void* CoKmalloc(U32 size)
freeMB = freeMB->nextFMB; /* Get the next item as current item*/ freeMB = freeMB->nextFMB; /* Get the next item as current item*/
} }
OsSchedUnlock(); /* Unlock schedule */ OsSchedUnlock(); /* Unlock schedule */
return NULL; /* Error return */ return Co_NULL; /* Error return */
} }
@@ -185,7 +185,7 @@ void CoKfree(void* memBuf)
P_UMB usedMB,nextUMB,preUMB; P_UMB usedMB,nextUMB,preUMB;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ #if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(memBuf == NULL) if(memBuf == Co_NULL)
{ {
return; return;
} }
@@ -213,7 +213,7 @@ void CoKfree(void* memBuf)
preUMB = (P_UMB)((U32)(FMBlist->preUMB)-1); preUMB = (P_UMB)((U32)(FMBlist->preUMB)-1);
while(preUMB != usedMB) while(preUMB != usedMB)
{ {
if(preUMB == NULL) if(preUMB == Co_NULL)
{ {
OsSchedUnlock(); OsSchedUnlock();
return; return;
@@ -223,25 +223,25 @@ void CoKfree(void* memBuf)
} }
else else
{ {
if(FMBlist == NULL) if(FMBlist == Co_NULL)
{ {
nextUMB = (P_UMB)(Kheap.startAddr); nextUMB = (P_UMB)(Kheap.startAddr);
} }
else else
{ {
if(FMBlist->nextUMB != NULL) if(FMBlist->nextUMB != Co_NULL)
{ {
nextUMB = (P_UMB)((U32)(FMBlist->nextUMB)-1); nextUMB = (P_UMB)((U32)(FMBlist->nextUMB)-1);
} }
else else
{ {
nextUMB = NULL; nextUMB = Co_NULL;
} }
} }
while(nextUMB != usedMB) while(nextUMB != usedMB)
{ {
if(nextUMB == NULL) if(nextUMB == Co_NULL)
{ {
OsSchedUnlock(); OsSchedUnlock();
return; return;
@@ -263,15 +263,15 @@ void CoKfree(void* memBuf)
/* Is between two free memory block? */ /* Is between two free memory block? */
if( (((U32)(usedMB->nextMB)&0x1) == 0) && (((U32)(usedMB->preMB)&0x1)==0) ) if( (((U32)(usedMB->nextMB)&0x1) == 0) && (((U32)(usedMB->preMB)&0x1)==0) )
{ /* Yes,is the only one item in kernel heap? */ { /* Yes,is the only one item in kernel heap? */
if((usedMB->nextMB == NULL) && (usedMB->preMB == NULL)) if((usedMB->nextMB == Co_NULL) && (usedMB->preMB == Co_NULL))
{ {
curFMB = (P_FMB)usedMB; /* Yes,release this item */ curFMB = (P_FMB)usedMB; /* Yes,release this item */
curFMB->nextFMB = NULL; curFMB->nextFMB = Co_NULL;
curFMB->nextUMB = NULL; curFMB->nextUMB = Co_NULL;
curFMB->preUMB = NULL; curFMB->preUMB = Co_NULL;
FMBlist = curFMB; FMBlist = curFMB;
} }
else if(usedMB->preMB == NULL) /* Is the first item in kernel heap */ else if(usedMB->preMB == Co_NULL) /* Is the first item in kernel heap */
{ {
/* Yes,release this item,and set link for list */ /* Yes,release this item,and set link for list */
curFMB = (P_FMB)usedMB; curFMB = (P_FMB)usedMB;
@@ -279,14 +279,14 @@ void CoKfree(void* memBuf)
curFMB->nextFMB = nextFMB->nextFMB; curFMB->nextFMB = nextFMB->nextFMB;
curFMB->nextUMB = nextFMB->nextUMB; curFMB->nextUMB = nextFMB->nextUMB;
curFMB->preUMB = NULL; curFMB->preUMB = Co_NULL;
FMBlist = curFMB; FMBlist = curFMB;
} }
else if(usedMB->nextMB == NULL) /* Is the last item in kernel heap */ else if(usedMB->nextMB == Co_NULL) /* Is the last item in kernel heap */
{ /* Yes,release this item,and set link for list */ { /* Yes,release this item,and set link for list */
curFMB = (P_FMB)(usedMB->preMB); curFMB = (P_FMB)(usedMB->preMB);
curFMB->nextFMB = NULL; curFMB->nextFMB = Co_NULL;
curFMB->nextUMB = NULL; curFMB->nextUMB = Co_NULL;
} }
else /* All no,show this item between two normal FMB */ else /* All no,show this item between two normal FMB */
{ {
@@ -300,13 +300,13 @@ void CoKfree(void* memBuf)
} }
else if(((U32)(usedMB->preMB)&0x1) == 0) /* Is between FMB and UMB? */ else if(((U32)(usedMB->preMB)&0x1) == 0) /* Is between FMB and UMB? */
{ {
if(usedMB->preMB == NULL) /* Yes,is the first item in kernel heap? */ if(usedMB->preMB == Co_NULL) /* Yes,is the first item in kernel heap? */
{ {
/* Yes,release this item,and set link for list */ /* Yes,release this item,and set link for list */
curFMB = (P_FMB)usedMB; curFMB = (P_FMB)usedMB;
nextUMB = (P_UMB)usedMB->nextMB; nextUMB = (P_UMB)usedMB->nextMB;
curFMB->nextUMB = nextUMB; curFMB->nextUMB = nextUMB;
curFMB->preUMB = NULL; curFMB->preUMB = Co_NULL;
curFMB->nextFMB = FMBlist; curFMB->nextFMB = FMBlist;
FMBlist = curFMB; FMBlist = curFMB;
} }
@@ -323,7 +323,7 @@ void CoKfree(void* memBuf)
preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */ preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */
curFMB = (P_FMB)(usedMB); /* new FMB */ curFMB = (P_FMB)(usedMB); /* new FMB */
preFMB = GetPreFMB(usedMB); /* Get previous FMB */ preFMB = GetPreFMB(usedMB); /* Get previous FMB */
if(preFMB == NULL) /* Is previous FMB==NULL? */ if(preFMB == Co_NULL) /* Is previous FMB==Co_NULL? */
{ {
nextFMB = FMBlist; /* Yes,get next FMB */ nextFMB = FMBlist; /* Yes,get next FMB */
FMBlist = curFMB; /* Reset new FMB as the first item of FMB list*/ FMBlist = curFMB; /* Reset new FMB as the first item of FMB list*/
@@ -334,11 +334,11 @@ void CoKfree(void* memBuf)
preFMB->nextFMB = curFMB; /* Set link for FMB list */ preFMB->nextFMB = curFMB; /* Set link for FMB list */
} }
if(nextFMB == NULL) /* Is new FMB as last item of FMB list? */ if(nextFMB == Co_NULL) /* Is new FMB as last item of FMB list? */
{ {
curFMB->preUMB = preUMB; /* Yes,set link for list */ curFMB->preUMB = preUMB; /* Yes,set link for list */
curFMB->nextUMB = NULL; curFMB->nextUMB = Co_NULL;
curFMB->nextFMB = NULL; curFMB->nextFMB = Co_NULL;
} }
else else
{ {
@@ -354,7 +354,7 @@ void CoKfree(void* memBuf)
preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */ preUMB = (P_UMB)(usedMB->preMB); /* Get previous UMB */
nextUMB = (P_UMB)(usedMB->nextMB); /* Get next UMB */ nextUMB = (P_UMB)(usedMB->nextMB); /* Get next UMB */
if(preFMB == NULL ) /* Is previous FMB==NULL? */ if(preFMB == Co_NULL ) /* Is previous FMB==Co_NULL? */
{ {
nextFMB = FMBlist; /* Yes,get next FMB */ nextFMB = FMBlist; /* Yes,get next FMB */
FMBlist = curFMB; /* Reset new FMB as the first item of FMB list */ FMBlist = curFMB; /* Reset new FMB as the first item of FMB list */
@@ -370,12 +370,12 @@ void CoKfree(void* memBuf)
curFMB->nextFMB = nextFMB; curFMB->nextFMB = nextFMB;
} }
if(curFMB->preUMB != NULL)/* Is current FMB as first item in kernel heap? */ if(curFMB->preUMB != Co_NULL)/* Is current FMB as first item in kernel heap? */
{ /* No,set link for list */ { /* No,set link for list */
preUMB = (P_UMB)((U32)(curFMB->preUMB)-1); preUMB = (P_UMB)((U32)(curFMB->preUMB)-1);
preUMB->nextMB = (void*)curFMB; preUMB->nextMB = (void*)curFMB;
} }
if(curFMB->nextUMB != NULL)/* Is current FMB as last item in kernel heap? */ if(curFMB->nextUMB != Co_NULL)/* Is current FMB as last item in kernel heap? */
{ /* No,set link for list */ { /* No,set link for list */
nextUMB = (P_UMB)((U32)(curFMB->nextUMB)-1); nextUMB = (P_UMB)((U32)(curFMB->nextUMB)-1);
nextUMB->preMB = (void*)curFMB; nextUMB->preMB = (void*)curFMB;
+26 -23
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file mbox.c * @file mbox.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Mailbox management implementation code of CooCox CoOS kernel. * @brief Mailbox management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -38,8 +38,8 @@ OS_EventID CoCreateMbox(U8 sortType)
P_ECB pecb; P_ECB pecb;
/* Create a mailbox type event control block */ /* Create a mailbox type event control block */
pecb = CreatEvent(EVENT_TYPE_MBOX,sortType,NULL); pecb = CreatEvent(EVENT_TYPE_MBOX,sortType,Co_NULL);
if(pecb == NULL) /* If failed to create event block */ if(pecb == Co_NULL) /* If failed to create event block */
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -92,7 +92,7 @@ StatusType CoDelMbox(OS_EventID id,U8 opt)
* @brief Accept a mailbox * @brief Accept a mailbox
* @param[in] id Event ID. * @param[in] id Event ID.
* @param[out] perr A pointer to error code. * @param[out] perr A pointer to error code.
* @retval NULL * @retval Co_NULL
* @retval A pointer to mailbox accepted. * @retval A pointer to mailbox accepted.
* *
* @par Description * @par Description
@@ -108,7 +108,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
if(id >= CFG_MAX_EVENT) if(id >= CFG_MAX_EVENT)
{ {
*perr = E_INVALID_ID; /* Invalid 'id' */ *perr = E_INVALID_ID; /* Invalid 'id' */
return NULL; return Co_NULL;
} }
#endif #endif
pecb = &EventTbl[id]; pecb = &EventTbl[id];
@@ -117,7 +117,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
if(pecb->eventType != EVENT_TYPE_MBOX)/* Invalid event control block type */ if(pecb->eventType != EVENT_TYPE_MBOX)/* Invalid event control block type */
{ {
*perr = E_INVALID_ID; *perr = E_INVALID_ID;
return NULL; return Co_NULL;
} }
#endif #endif
OsSchedLock(); OsSchedLock();
@@ -125,7 +125,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
{ {
*perr = E_OK; *perr = E_OK;
pmail = pecb->eventPtr; /* Get the message */ pmail = pecb->eventPtr; /* Get the message */
pecb->eventPtr = NULL; /* Clear the mailbox */ pecb->eventPtr = Co_NULL; /* Clear the mailbox */
pecb->eventCounter = 0; pecb->eventCounter = 0;
OsSchedUnlock(); OsSchedUnlock();
return pmail; /* Return the message received */ return pmail; /* Return the message received */
@@ -133,8 +133,8 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
else /* If the mailbox is empty */ else /* If the mailbox is empty */
{ {
OsSchedUnlock(); OsSchedUnlock();
*perr = E_MBOX_EMPTY; /* Mailbox is empty,return NULL */ *perr = E_MBOX_EMPTY; /* Mailbox is empty,return Co_NULL */
return NULL; return Co_NULL;
} }
} }
@@ -146,7 +146,7 @@ void* CoAcceptMail(OS_EventID id,StatusType* perr)
* @param[in] id Event ID. * @param[in] id Event ID.
* @param[in] timeout The longest time for writting mail. * @param[in] timeout The longest time for writting mail.
* @param[out] perr A pointer to error code. * @param[out] perr A pointer to error code.
* @retval NULL * @retval Co_NULL
* @retval A pointer to mailbox accept. * @retval A pointer to mailbox accept.
* *
* @par Description * @par Description
@@ -163,14 +163,14 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
if(OSIntNesting > 0) /* If the caller is ISR */ if(OSIntNesting > 0) /* If the caller is ISR */
{ {
*perr = E_CALL; *perr = E_CALL;
return NULL; return Co_NULL;
} }
#if CFG_PAR_CHECKOUT_EN >0 #if CFG_PAR_CHECKOUT_EN >0
if(id >= CFG_MAX_EVENT) if(id >= CFG_MAX_EVENT)
{ {
*perr = E_INVALID_ID; /* Invalid 'id',retrun error */ *perr = E_INVALID_ID; /* Invalid 'id',retrun error */
return NULL; return Co_NULL;
} }
#endif #endif
@@ -179,25 +179,28 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
if(pecb->eventType != EVENT_TYPE_MBOX) if(pecb->eventType != EVENT_TYPE_MBOX)
{ {
*perr = E_INVALID_ID; /* Invalid event type,not EVENT_TYPE_MBOX */ *perr = E_INVALID_ID; /* Invalid event type,not EVENT_TYPE_MBOX */
return NULL; return Co_NULL;
} }
#endif #endif
if(OSSchedLock != 0) /* Judge schedule is locked or not? */ if(OSSchedLock != 0) /* Judge schedule is locked or not? */
{ {
*perr = E_OS_IN_LOCK; /* Schedule is locked */ *perr = E_OS_IN_LOCK; /* Schedule is locked */
return NULL; /* return NULL */ return Co_NULL; /* return Co_NULL */
} }
OsSchedLock();
if( pecb->eventCounter == 1) /* If there is already a message */ if( pecb->eventCounter == 1) /* If there is already a message */
{ {
*perr = E_OK; *perr = E_OK;
pmail = pecb->eventPtr; /* Get the message */ pmail = pecb->eventPtr; /* Get the message */
pecb->eventPtr = NULL; /* Clear the mailbox */ pecb->eventPtr = Co_NULL; /* Clear the mailbox */
pecb->eventCounter = 0; pecb->eventCounter = 0;
OsSchedUnlock();
return pmail; /* Return the message received */ return pmail; /* Return the message received */
} }
else /* If message is not available, task will pend */ else /* If message is not available, task will pend */
{ {
OsSchedUnlock();
curTCB = TCBRunning; curTCB = TCBRunning;
if(timeout == 0) /* If time-out is not configured */ if(timeout == 0) /* If time-out is not configured */
{ {
@@ -206,8 +209,8 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
/* Have recived a message or the mailbox have been deleted */ /* Have recived a message or the mailbox have been deleted */
pmail = curTCB->pmail; pmail = curTCB->pmail;
curTCB->pmail = NULL; curTCB->pmail = Co_NULL;
return pmail; /* Return received message or NULL */ return pmail; /* Return received message or Co_NULL */
} }
else /* If time-out is configured */ else /* If time-out is configured */
{ {
@@ -217,17 +220,17 @@ void* CoPendMail(OS_EventID id,U32 timeout,StatusType* perr)
EventTaskToWait(pecb,curTCB); EventTaskToWait(pecb,curTCB);
InsertDelayList(curTCB,timeout); InsertDelayList(curTCB,timeout);
OsSchedUnlock(); OsSchedUnlock();
if( curTCB->pmail == NULL) /* Time-out occurred */ if( curTCB->pmail == Co_NULL) /* Time-out occurred */
{ {
*perr = E_TIMEOUT; *perr = E_TIMEOUT;
return NULL; return Co_NULL;
} }
else /* Have recived a message or the mailbox have been deleted*/ else /* Have recived a message or the mailbox have been deleted*/
{ {
*perr = E_OK; *perr = E_OK;
pmail = curTCB->pmail; pmail = curTCB->pmail;
curTCB->pmail = NULL; curTCB->pmail = Co_NULL;
return pmail; /* Return received message or NULL */ return pmail; /* Return received message or Co_NULL */
} }
} }
} }
@@ -301,7 +304,7 @@ StatusType isr_PostMail(OS_EventID id,void* pmail)
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
{ {
/* Insert the request into service request queue */ /* Insert the request into service request queue */
if(InsertInSRQ(MBOX_REQ,id,pmail) == FALSE) if(InsertInSRQ(MBOX_REQ,id,pmail) == Co_FALSE)
{ {
return E_SEV_REQ_FULL; /* If service request queue is full */ return E_SEV_REQ_FULL; /* If service request queue is full */
} }
+13 -13
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file mm.c * @file mm.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief memory management implementation code of CooCox CoOS kernel. * @brief memory management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -45,7 +45,7 @@ OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum)
memory = memBuf; memory = memBuf;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ #if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(memBuf == NULL) if(memBuf == Co_NULL)
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -81,7 +81,7 @@ OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum)
memBlk->nextBlock = (P_MemBlk)memory; memBlk->nextBlock = (P_MemBlk)memory;
memBlk = memBlk->nextBlock; memBlk = memBlk->nextBlock;
} }
memBlk->nextBlock = NULL; memBlk->nextBlock = Co_NULL;
return i; /* Return memory block ID */ return i; /* Return memory block ID */
} }
} }
@@ -120,8 +120,8 @@ StatusType CoDelMemoryPartition(OS_MMID mmID)
MemoryIDVessel &= ~(1<<mmID); MemoryIDVessel &= ~(1<<mmID);
OsSchedUnlock(); /* Unlock schedule */ OsSchedUnlock(); /* Unlock schedule */
memCtl->memAddr = NULL; memCtl->memAddr = Co_NULL;
memCtl->freeBlock = NULL; memCtl->freeBlock = Co_NULL;
memCtl->blockSize = 0; memCtl->blockSize = 0;
memCtl->blockNum = 0; memCtl->blockNum = 0;
return E_OK; /* Return OK */ return E_OK; /* Return OK */
@@ -163,7 +163,7 @@ U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr)
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
memBlk = (P_MemBlk)(memCtl->freeBlock);/* Get the free item in memory list*/ memBlk = (P_MemBlk)(memCtl->freeBlock);/* Get the free item in memory list*/
fbNum = 0; fbNum = 0;
while(memBlk != NULL) /* Get counter of free item */ while(memBlk != Co_NULL) /* Get counter of free item */
{ {
fbNum++; fbNum++;
memBlk = memBlk->nextBlock; /* Get next free iterm */ memBlk = memBlk->nextBlock; /* Get next free iterm */
@@ -179,7 +179,7 @@ U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr)
* @brief Get a memory buffer from memory partition * @brief Get a memory buffer from memory partition
* @param[in] mmID Specify memory partition that want to assign buffer. * @param[in] mmID Specify memory partition that want to assign buffer.
* @param[out] None * @param[out] None
* @retval NULL Assign buffer fail. * @retval Co_NULL Assign buffer fail.
* @retval others Assign buffer successful,and return the buffer pointer. * @retval others Assign buffer successful,and return the buffer pointer.
* *
* @par Description * @par Description
@@ -193,19 +193,19 @@ void* CoGetMemoryBuffer(OS_MMID mmID)
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ #if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(mmID >= CFG_MAX_MM) if(mmID >= CFG_MAX_MM)
{ {
return NULL; return Co_NULL;
} }
if( ((1<<mmID)&MemoryIDVessel) == 0) if( ((1<<mmID)&MemoryIDVessel) == 0)
{ {
return NULL; return Co_NULL;
} }
#endif #endif
memCtl = &MemoryTbl[mmID]; memCtl = &MemoryTbl[mmID];
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
if(memCtl->freeBlock == NULL ) /* Is there no free item in memory list */ if(memCtl->freeBlock == Co_NULL ) /* Is there no free item in memory list */
{ {
OsSchedUnlock(); /* Unlock schedule */ OsSchedUnlock(); /* Unlock schedule */
return NULL; /* Yes,error return */ return Co_NULL; /* Yes,error return */
} }
memBlk = (P_MemBlk)memCtl->freeBlock; /* Get free memory block */ memBlk = (P_MemBlk)memCtl->freeBlock; /* Get free memory block */
memCtl->freeBlock = (U8*)memBlk->nextBlock; /* Reset the first free item */ memCtl->freeBlock = (U8*)memBlk->nextBlock; /* Reset the first free item */
@@ -242,7 +242,7 @@ StatusType CoFreeMemoryBuffer(OS_MMID mmID,void* buf)
{ {
return E_INVALID_ID; return E_INVALID_ID;
} }
if(buf == NULL) if(buf == Co_NULL)
{ {
return E_INVALID_PARAMETER; return E_INVALID_PARAMETER;
} }
+24 -24
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file mutex.c * @file mutex.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Mutex management implementation code of CooCox CoOS kernel. * @brief Mutex management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -56,7 +56,7 @@ OS_MutexID CoCreateMutex(void)
pMutex->originalPrio = 0xff; pMutex->originalPrio = 0xff;
pMutex->mutexFlag = MUTEX_FREE; /* Mutex is free,not was occupied */ pMutex->mutexFlag = MUTEX_FREE; /* Mutex is free,not was occupied */
pMutex->taskID = INVALID_ID; pMutex->taskID = INVALID_ID;
pMutex->waittingList = NULL; pMutex->waittingList = Co_NULL;
return id; /* Return mutex ID */ return id; /* Return mutex ID */
} }
@@ -156,24 +156,24 @@ StatusType CoEnterMutexSection(OS_MutexID mutexID)
} }
pCurTcb->state = TASK_WAITING; /* Block current task */ pCurTcb->state = TASK_WAITING; /* Block current task */
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
pCurTcb->TCBnext = NULL; pCurTcb->TCBnext = Co_NULL;
pCurTcb->TCBprev = NULL; pCurTcb->TCBprev = Co_NULL;
ptcb = pMutex->waittingList; ptcb = pMutex->waittingList;
if(ptcb == NULL) /* If the event waiting list is empty */ if(ptcb == Co_NULL) /* If the event waiting list is empty */
{ {
pMutex->waittingList = pCurTcb; /* Insert the task to head */ pMutex->waittingList = pCurTcb; /* Insert the task to head */
} }
else /* If the event waiting list is not empty */ else /* If the event waiting list is not empty */
{ {
while(ptcb->TCBnext != NULL) /* Insert the task to tail */ while(ptcb->TCBnext != Co_NULL) /* Insert the task to tail */
{ {
ptcb = ptcb->TCBnext; ptcb = ptcb->TCBnext;
} }
ptcb->TCBnext = pCurTcb; ptcb->TCBnext = pCurTcb;
pCurTcb->TCBprev = ptcb; pCurTcb->TCBprev = ptcb;
pCurTcb->TCBnext = NULL; pCurTcb->TCBnext = Co_NULL;
} }
} }
OsSchedUnlock(); OsSchedUnlock();
@@ -217,7 +217,7 @@ StatusType CoLeaveMutexSection(OS_MutexID mutexID)
pMutex = &MutexTbl[mutexID]; /* Obtain point of mutex control block*/ pMutex = &MutexTbl[mutexID]; /* Obtain point of mutex control block*/
ptcb = &TCBTbl[pMutex->taskID]; ptcb = &TCBTbl[pMutex->taskID];
ptcb->mutexID = INVALID_ID; ptcb->mutexID = INVALID_ID;
if(pMutex->waittingList == NULL) /* If the mutex waiting list is empty */ if(pMutex->waittingList == Co_NULL) /* If the mutex waiting list is empty */
{ {
pMutex->mutexFlag = MUTEX_FREE; /* The mutex resource is available */ pMutex->mutexFlag = MUTEX_FREE; /* The mutex resource is available */
pMutex->taskID = INVALID_ID; pMutex->taskID = INVALID_ID;
@@ -232,7 +232,7 @@ StatusType CoLeaveMutexSection(OS_MutexID mutexID)
{ {
ptcb = pMutex->waittingList;/* Point to mutex first waiting task */ ptcb = pMutex->waittingList;/* Point to mutex first waiting task */
prio = ptcb->prio; prio = ptcb->prio;
while(ptcb != NULL) /* Find the highest priority task */ while(ptcb != Co_NULL) /* Find the highest priority task */
{ {
if(ptcb->prio < prio) if(ptcb->prio < prio)
{ {
@@ -268,8 +268,8 @@ StatusType CoLeaveMutexSection(OS_MutexID mutexID)
ptcb->prio = prio; /* Raise the task's priority */ ptcb->prio = prio; /* Raise the task's priority */
/* Insert the task which acquire the mutex into ready list. */ /* Insert the task which acquire the mutex into ready list. */
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
InsertToTCBRdyList(ptcb); /* Insert the task into the READY list */ InsertToTCBRdyList(ptcb); /* Insert the task into the READY list */
OsSchedUnlock(); OsSchedUnlock();
@@ -297,29 +297,29 @@ void RemoveMutexList(P_OSTCB ptcb)
pMutex = &MutexTbl[ptcb->mutexID]; pMutex = &MutexTbl[ptcb->mutexID];
/* If only one task waiting on mutex */ /* If only one task waiting on mutex */
if((ptcb->TCBnext ==NULL) && (ptcb->TCBprev == NULL)) if((ptcb->TCBnext ==Co_NULL) && (ptcb->TCBprev == Co_NULL))
{ {
pMutex->waittingList = NULL; /* Waiting list is empty */ pMutex->waittingList = Co_NULL; /* Waiting list is empty */
} }
else if(ptcb->TCBnext == NULL) /* If the task is the last of waiting list*/ else if(ptcb->TCBnext == Co_NULL) /* If the task is the last of waiting list*/
{ {
/* Remove task from mutex waiting list */ /* Remove task from mutex waiting list */
ptcb->TCBprev->TCBnext = NULL; ptcb->TCBprev->TCBnext = Co_NULL;
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
} }
else if(ptcb->TCBprev == NULL)/* If the task is the first of waiting list*/ else if(ptcb->TCBprev == Co_NULL)/* If the task is the first of waiting list*/
{ {
/* Remove task from waiting list */ /* Remove task from waiting list */
ptcb->TCBnext->TCBprev = NULL; ptcb->TCBnext->TCBprev = Co_NULL;
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
} }
else /* If the task is in the middle of waiting list */ else /* If the task is in the middle of waiting list */
{ {
/* Remove task from wait list */ /* Remove task from wait list */
ptcb->TCBnext->TCBprev = ptcb->TCBprev; ptcb->TCBnext->TCBprev = ptcb->TCBprev;
ptcb->TCBprev->TCBnext = ptcb->TCBnext; ptcb->TCBprev->TCBnext = ptcb->TCBnext;
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
} }
ptcb->mutexID = INVALID_ID; ptcb->mutexID = INVALID_ID;
@@ -330,7 +330,7 @@ void RemoveMutexList(P_OSTCB ptcb)
ptcb = pMutex->waittingList; ptcb = pMutex->waittingList;
prio = pMutex->originalPrio; prio = pMutex->originalPrio;
pMutex->hipriTaskID = pMutex->taskID; pMutex->hipriTaskID = pMutex->taskID;
while(ptcb != NULL) /* Find task ID of highest priority task*/ while(ptcb != Co_NULL) /* Find task ID of highest priority task*/
{ {
if(ptcb->prio < prio) if(ptcb->prio < prio)
{ {
+24 -22
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file queue.c * @file queue.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Queue management implementation code of CooCox CoOS kernel. * @brief Queue management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -45,7 +45,7 @@ OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType)
P_ECB pecb; P_ECB pecb;
#if CFG_PAR_CHECKOUT_EN >0 #if CFG_PAR_CHECKOUT_EN >0
if((qStart == NULL) || (size == 0)) if((qStart == Co_NULL) || (size == 0))
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -70,7 +70,7 @@ OS_EventID CoCreateQueue(void **qStart, U16 size ,U8 sortType)
/* Get a event control block and initial the event content */ /* Get a event control block and initial the event content */
pecb = CreatEvent(EVENT_TYPE_QUEUE,sortType,&QueueTbl[i]); pecb = CreatEvent(EVENT_TYPE_QUEUE,sortType,&QueueTbl[i]);
if(pecb == NULL ) /* If there is no free EVENT control block*/ if(pecb == Co_NULL ) /* If there is no free EVENT control block*/
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -123,7 +123,7 @@ StatusType CoDelQueue(OS_EventID id,U8 opt)
if(err == E_OK) /* If the event block have been deleted */ if(err == E_OK) /* If the event block have been deleted */
{ {
QueueIDVessel &= ~((U32)(1<<(pqcb->id))); /* Update free queue list */ QueueIDVessel &= ~((U32)(1<<(pqcb->id))); /* Update free queue list */
pqcb->qStart = NULL; pqcb->qStart = Co_NULL;
pqcb->id = 0; pqcb->id = 0;
pqcb->head = 0; pqcb->head = 0;
pqcb->tail = 0; pqcb->tail = 0;
@@ -140,7 +140,7 @@ StatusType CoDelQueue(OS_EventID id,U8 opt)
* @brief Accept a mail from queue * @brief Accept a mail from queue
* @param[in] id Event ID. * @param[in] id Event ID.
* @param[out] perr A pointer to error code. * @param[out] perr A pointer to error code.
* @retval NULL * @retval Co_NULL
* @retval A pointer to mail accepted. * @retval A pointer to mail accepted.
* *
* @par Description * @par Description
@@ -157,7 +157,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
if(id >= CFG_MAX_EVENT) if(id >= CFG_MAX_EVENT)
{ {
*perr = E_INVALID_ID; /* Invalid id,return error */ *perr = E_INVALID_ID; /* Invalid id,return error */
return NULL; return Co_NULL;
} }
#endif #endif
@@ -166,7 +166,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
if(pecb->eventType != EVENT_TYPE_QUEUE)/* Invalid event control block type*/ if(pecb->eventType != EVENT_TYPE_QUEUE)/* Invalid event control block type*/
{ {
*perr = E_INVALID_ID; *perr = E_INVALID_ID;
return NULL; return Co_NULL;
} }
#endif #endif
pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */
@@ -189,7 +189,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
{ {
OsSchedUnlock(); OsSchedUnlock();
*perr = E_QUEUE_EMPTY; *perr = E_QUEUE_EMPTY;
return NULL; /* Return NULL */ return Co_NULL; /* Return Co_NULL */
} }
} }
@@ -201,7 +201,7 @@ void* CoAcceptQueueMail(OS_EventID id,StatusType* perr)
* @param[in] id Event ID. * @param[in] id Event ID.
* @param[in] timeout The longest time for writting mail. * @param[in] timeout The longest time for writting mail.
* @param[out] perr A pointer to error code. * @param[out] perr A pointer to error code.
* @retval NULL * @retval Co_NULL
* @retval A pointer to mail accept. * @retval A pointer to mail accept.
* *
* @par Description * @par Description
@@ -218,13 +218,13 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
if(OSIntNesting > 0) /* If the caller is ISR */ if(OSIntNesting > 0) /* If the caller is ISR */
{ {
*perr = E_CALL; *perr = E_CALL;
return NULL; return Co_NULL;
} }
#if CFG_PAR_CHECKOUT_EN >0 #if CFG_PAR_CHECKOUT_EN >0
if(id >= CFG_MAX_EVENT) if(id >= CFG_MAX_EVENT)
{ {
*perr = E_INVALID_ID; /* Invalid event id,return error */ *perr = E_INVALID_ID; /* Invalid event id,return error */
return NULL; return Co_NULL;
} }
#endif #endif
@@ -233,16 +233,16 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
if(pecb->eventType != EVENT_TYPE_QUEUE) /* The event type is not queue */ if(pecb->eventType != EVENT_TYPE_QUEUE) /* The event type is not queue */
{ {
*perr = E_INVALID_ID; *perr = E_INVALID_ID;
return NULL; return Co_NULL;
} }
#endif #endif
if(OSSchedLock != 0) /* Judge schedule is locked or not? */ if(OSSchedLock != 0) /* Judge schedule is locked or not? */
{ {
*perr = E_OS_IN_LOCK; /* Schedule is locked,return error */ *perr = E_OS_IN_LOCK; /* Schedule is locked,return error */
return NULL; return Co_NULL;
} }
pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */ pqcb = (P_QCB)pecb->eventPtr; /* Point at queue control block */
OsSchedLock();
if(pqcb->qSize != 0) /* If there are any messages in the queue */ if(pqcb->qSize != 0) /* If there are any messages in the queue */
{ {
/* Extract oldest message from the queue */ /* Extract oldest message from the queue */
@@ -253,11 +253,13 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
{ {
pqcb->head = 0; pqcb->head = 0;
} }
OsSchedUnlock();
*perr = E_OK; *perr = E_OK;
return pmail; /* Return message received */ return pmail; /* Return message received */
} }
else /* If there is no message in the queue*/ else /* If there is no message in the queue*/
{ {
OsSchedUnlock();
curTCB = TCBRunning; curTCB = TCBRunning;
if(timeout == 0) /* If time-out is not configured */ if(timeout == 0) /* If time-out is not configured */
{ {
@@ -266,9 +268,9 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
/* Have recived message or the queue have been deleted */ /* Have recived message or the queue have been deleted */
pmail = curTCB->pmail; pmail = curTCB->pmail;
curTCB->pmail = NULL; curTCB->pmail = Co_NULL;
*perr = E_OK; *perr = E_OK;
return pmail; /* Return message received or NULL */ return pmail; /* Return message received or Co_NULL */
} }
else /* If time-out is configured */ else /* If time-out is configured */
{ {
@@ -278,17 +280,17 @@ void* CoPendQueueMail(OS_EventID id,U32 timeout,StatusType* perr)
EventTaskToWait(pecb,curTCB); EventTaskToWait(pecb,curTCB);
InsertDelayList(curTCB,timeout); InsertDelayList(curTCB,timeout);
OsSchedUnlock(); OsSchedUnlock();
if(curTCB->pmail == NULL) /* If time-out occurred */ if(curTCB->pmail == Co_NULL) /* If time-out occurred */
{ {
*perr = E_TIMEOUT; *perr = E_TIMEOUT;
return NULL; return Co_NULL;
} }
else /* If event occured */ else /* If event occured */
{ {
pmail = curTCB->pmail; pmail = curTCB->pmail;
curTCB->pmail = NULL; curTCB->pmail = Co_NULL;
*perr = E_OK; *perr = E_OK;
return pmail; /* Return message received or NULL */ return pmail; /* Return message received or Co_NULL */
} }
} }
} }
@@ -372,7 +374,7 @@ StatusType isr_PostQueueMail(OS_EventID id,void* pmail)
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
{ {
/* Insert the request into service request queue */ /* Insert the request into service request queue */
if(InsertInSRQ(QUEUE_REQ,id,pmail) == FALSE) if(InsertInSRQ(QUEUE_REQ,id,pmail) == Co_FALSE)
{ {
return E_SEV_REQ_FULL; /* If service request queue is full */ return E_SEV_REQ_FULL; /* If service request queue is full */
} }
+11 -8
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file sem.c * @file sem.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Semaphore management implementation code of CooCox CoOS kernel. * @brief Semaphore management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -49,8 +49,8 @@ OS_EventID CoCreateSem(U16 initCnt,U16 maxCnt,U8 sortType)
#endif #endif
/* Create a semaphore type event control block */ /* Create a semaphore type event control block */
pecb = CreatEvent(EVENT_TYPE_SEM,sortType,NULL); pecb = CreatEvent(EVENT_TYPE_SEM,sortType,Co_NULL);
if(pecb == NULL) /* If failed to create event block */ if(pecb == Co_NULL) /* If failed to create event block */
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -194,18 +194,21 @@ StatusType CoPendSem(OS_EventID id,U32 timeout)
{ {
return E_OS_IN_LOCK; /* Yes,error return */ return E_OS_IN_LOCK; /* Yes,error return */
} }
OsSchedLock();
if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */ if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */
{ {
pecb->eventCounter--; /* Decrement semaphore only if positive */ pecb->eventCounter--; /* Decrement semaphore only if positive */
OsSchedUnlock();
return E_OK; return E_OK;
} }
else /* Resource is not available */ else /* Resource is not available */
{ {
OsSchedUnlock();
curTCB = TCBRunning; curTCB = TCBRunning;
if(timeout == 0) /* If time-out is not configured */ if(timeout == 0) /* If time-out is not configured */
{ {
EventTaskToWait(pecb,curTCB); /* Block task until event occurs */ EventTaskToWait(pecb,curTCB); /* Block task until event occurs */
curTCB->pmail = NULL; curTCB->pmail = Co_NULL;
return E_OK; return E_OK;
} }
else /* If time-out is configured */ else /* If time-out is configured */
@@ -217,13 +220,13 @@ StatusType CoPendSem(OS_EventID id,U32 timeout)
InsertDelayList(curTCB,timeout); InsertDelayList(curTCB,timeout);
OsSchedUnlock(); OsSchedUnlock();
if (curTCB->pmail == NULL) /* If pmail is NULL, time-out occurred*/ if (curTCB->pmail == Co_NULL) /* If pmail is Co_NULL, time-out occurred*/
{ {
return E_TIMEOUT; return E_TIMEOUT;
} }
else /* Event occurred or event have been deleted*/ else /* Event occurred or event have been deleted*/
{ {
curTCB->pmail = NULL; curTCB->pmail = Co_NULL;
return E_OK; return E_OK;
} }
} }
@@ -300,7 +303,7 @@ StatusType isr_PostSem(OS_EventID id)
if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */ if(OSSchedLock > 0) /* If scheduler is locked,(the caller is ISR) */
{ {
/* Initiate a post service handling request */ /* Initiate a post service handling request */
if(InsertInSRQ(SEM_REQ,id,NULL) == FALSE) if(InsertInSRQ(SEM_REQ,id,Co_NULL) == Co_FALSE)
{ {
return E_SEV_REQ_FULL; /* If service request queue is full */ return E_SEV_REQ_FULL; /* If service request queue is full */
} }
+68 -50
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file serviceReq.c * @file serviceReq.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief servive request management implementation code of CooCox CoOS kernel. * @brief servive request management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -22,15 +22,15 @@
#if CFG_MAX_SERVICE_REQUEST > 0 #if CFG_MAX_SERVICE_REQUEST > 0
/*---------------------------- Variable Define -------------------------------*/ /*---------------------------- Variable Define -------------------------------*/
SRQ ServiceReq = {0}; /*!< ISR server request queue */ SRQ ServiceReq = {0,0}; /*!< ISR server request queue */
#endif #endif
BOOL IsrReq = FALSE; BOOL IsrReq = Co_FALSE;
#if (CFG_TASK_WAITTING_EN > 0) #if (CFG_TASK_WAITTING_EN > 0)
BOOL TimeReq = FALSE; /*!< Time delay dispose request */ BOOL TimeReq = Co_FALSE; /*!< Time delay dispose request */
#endif #endif
#if CFG_TMR_EN > 0 #if CFG_TMR_EN > 0
BOOL TimerReq = FALSE; /*!< Timer dispose request */ BOOL TimerReq = Co_FALSE; /*!< Timer dispose request */
#endif #endif
/** /**
@@ -41,8 +41,8 @@ BOOL TimerReq = FALSE; /*!< Timer dispose request */
* @param[in] arg Service request argument. * @param[in] arg Service request argument.
* @param[out] None * @param[out] None
* *
* @retval FALSE Successfully insert into service request queue. * @retval Co_FALSE Successfully insert into service request queue.
* @retval TRUE Failure to insert into service request queue. * @retval Co_TRUE Failure to insert into service request queue.
* *
* @par Description * @par Description
* @details This function be called to insert a requst into service request * @details This function be called to insert a requst into service request
@@ -50,26 +50,34 @@ BOOL TimerReq = FALSE; /*!< Timer dispose request */
* @note * @note
******************************************************************************* *******************************************************************************
*/ */
#if CFG_MAX_SERVICE_REQUEST > 0 #if (CFG_MAX_SERVICE_REQUEST > 0)
BOOL InsertInSRQ(U8 type,U8 id,void* arg) BOOL InsertInSRQ(U8 type,U8 id,void* arg)
{ {
U16 cnt; P_SQC pcell;
P_SQC pcell; U8 cnt;
cnt = Inc8(&ServiceReq.cnt); /* Service request counter decrease */ U8 heed;
if(cnt >= CFG_MAX_SERVICE_REQUEST) /* If counter exceed max */ IRQ_DISABLE_SAVE();
if (ServiceReq.cnt >= CFG_MAX_SERVICE_REQUEST)
{ {
return FALSE; /* Error return */ IRQ_ENABLE_RESTORE ();
return Co_FALSE; /* Error return */
} }
IsrReq = TRUE; cnt = Inc8(&ServiceReq.cnt);
pcell = &ServiceReq.cell[cnt]; /* Save service request type and parameter */ heed = ServiceReq.head;
pcell->type = type; IsrReq = Co_TRUE;
pcell->id = id; pcell = &ServiceReq.cell[((cnt+heed)%CFG_MAX_SERVICE_REQUEST)];/*the tail */
pcell->arg = arg; pcell->type = type; /* Save service request type, */
return TRUE; /* Return OK */ pcell->id = id; /* event id */
pcell->arg = arg; /* and parameter */
IRQ_ENABLE_RESTORE ();
return Co_TRUE; /* Return OK */
} }
#endif #endif
/** /**
******************************************************************************* *******************************************************************************
* @brief Respond the request in the service request queue. * @brief Respond the request in the service request queue.
@@ -85,62 +93,72 @@ BOOL InsertInSRQ(U8 type,U8 id,void* arg)
*/ */
void RespondSRQ(void) void RespondSRQ(void)
{ {
#if CFG_MAX_SERVICE_REQUEST > 0 #if CFG_MAX_SERVICE_REQUEST > 0
U16 i; SQC cell;
P_SQC pcell;
#endif #endif
#if (CFG_TASK_WAITTING_EN > 0) #if (CFG_TASK_WAITTING_EN > 0)
if(TimeReq == TRUE) /* Time delay request? */ if(TimeReq == Co_TRUE) /* Time delay request? */
{ {
TimeDispose(); /* Yes,call handler */ TimeDispose(); /* Yes,call handler */
TimeReq = FALSE; /* Reset time delay request false */ TimeReq = Co_FALSE; /* Reset time delay request Co_FALSE */
} }
#endif #endif
#if CFG_TMR_EN > 0 #if CFG_TMR_EN > 0
if(TimerReq == TRUE) /* Timer request? */ if(TimerReq == Co_TRUE) /* Timer request? */
{ {
TmrDispose(); /* Yes,call handler */ TmrDispose(); /* Yes,call handler */
TimerReq = FALSE; /* Reset timer request false */ TimerReq = Co_FALSE; /* Reset timer request Co_FALSE */
} }
#endif #endif
#if CFG_MAX_SERVICE_REQUEST > 0 #if CFG_MAX_SERVICE_REQUEST > 0
pcell = &ServiceReq.cell[0]; /* Get the head item of service request list*/
for(i=0;i<ServiceReq.cnt;i++,pcell++) while (ServiceReq.cnt != 0)
{ {
switch(pcell->type) /* Judge service request type */ IRQ_DISABLE_SAVE (); /* need to protect the following */
cell = ServiceReq.cell[ServiceReq.head]; /* extract one cell */
ServiceReq.head = (ServiceReq.head + 1) % /* move head (pop) */
CFG_MAX_SERVICE_REQUEST;
ServiceReq.cnt--;
IRQ_ENABLE_RESTORE (); /* now use the cell copy */
switch(cell.type) /* Judge service request type */
{ {
#if CFG_SEM_EN > 0 #if CFG_SEM_EN > 0
case SEM_REQ: /* Semaphore post request,call handler*/ case SEM_REQ: /* Semaphore post request,call handler*/
CoPostSem(pcell->id); CoPostSem(cell.id);
break; break;
#endif #endif
#if CFG_MAILBOX_EN > 0 #if CFG_MAILBOX_EN > 0
case MBOX_REQ: /* Mailbox post request,call handler */ case MBOX_REQ: /* Mailbox post request,call handler */
CoPostMail(pcell->id,pcell->arg); CoPostMail(cell.id, cell.arg);
break; break;
#endif #endif
#if CFG_FLAG_EN > 0 #if CFG_FLAG_EN > 0
case FLAG_REQ: /* Flag set request,call handler */ case FLAG_REQ: /* Flag set request,call handler */
CoSetFlag(pcell->id); CoSetFlag(cell.id);
break; break;
#endif #endif
#if CFG_QUEUE_EN > 0 #if CFG_QUEUE_EN > 0
case QUEUE_REQ: /* Queue post request,call handler */ case QUEUE_REQ: /* Queue post request,call handler */
CoPostQueueMail(pcell->id,pcell->arg); CoPostQueueMail(cell.id, cell.arg);
break; break;
#endif #endif
default: /* Others,break */ default: /* Others,break */
break; break;
} }
pcell->type = 0; /* Initialize the service request cell*/ }
pcell->id = 0;
pcell->arg = 0;
}
ServiceReq.cnt = 0; /* Initialize the service request queue */
#endif #endif
IsrReq = FALSE; IRQ_DISABLE_SAVE (); /* need to protect the following */
if (ServiceReq.cnt == 0) /* another item in the queue already? */
{
IsrReq = Co_FALSE; /* queue still empty here */
}
IRQ_ENABLE_RESTORE (); /* now it is done and return */
} }
#endif #endif
+65 -65
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file task.c * @file task.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief task management implementation code of CooCox CoOS kernel. * @brief task management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -25,10 +25,10 @@ OSTCB TCBTbl[CFG_MAX_USER_TASKS+SYS_TASK_NUM] = {{0}};
/*!< The stack of IDLE task. */ /*!< The stack of IDLE task. */
OS_STK idle_stk[CFG_IDLE_STACK_SIZE] = {0}; OS_STK idle_stk[CFG_IDLE_STACK_SIZE] = {0};
P_OSTCB FreeTCB = NULL; /*!< pointer to free TCB */ P_OSTCB FreeTCB = Co_NULL; /*!< pointer to free TCB */
P_OSTCB TCBRdy = NULL; /*!< Pointer to the READY list. */ P_OSTCB TCBRdy = Co_NULL; /*!< Pointer to the READY list. */
P_OSTCB TCBNext = NULL; /*!< Poniter to task that next scheduled by OS */ P_OSTCB TCBNext = Co_NULL; /*!< Poniter to task that next scheduled by OS */
P_OSTCB TCBRunning = NULL; /*!< Pointer to TCB that current running task. */ P_OSTCB TCBRunning = Co_NULL; /*!< Pointer to TCB that current running task. */
U64 OSCheckTime = 0; /*!< The counter of system tick. */ U64 OSCheckTime = 0; /*!< The counter of system tick. */
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
@@ -80,7 +80,7 @@ void CreateTCBList(void)
#endif #endif
ptcb1->taskID = i; ptcb1->taskID = i;
ptcb1->TCBnext = NULL; ptcb1->TCBnext = Co_NULL;
FreeTCB = &TCBTbl[0]; /* Initialize FreeTCB as head item of list */ FreeTCB = &TCBTbl[0]; /* Initialize FreeTCB as head item of list */
} }
@@ -93,8 +93,8 @@ void CreateTCBList(void)
* @brief Get sequence number for Assign priority * @brief Get sequence number for Assign priority
* @param[in] pri Assign priority * @param[in] pri Assign priority
* @param[out] SequenceNum priority number * @param[out] SequenceNum priority number
* @retval TRUE Assign priority in priority queue. * @retval Co_TRUE Assign priority in priority queue.
* FALSE Assign priority not in priority queue. * Co_FALSE Assign priority not in priority queue.
* *
* @par Description * @par Description
* @details This function is called in Binary-Scheduling Algorithm * @details This function is called in Binary-Scheduling Algorithm
@@ -114,7 +114,7 @@ static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum)
if(pri == ActivePri[num]) if(pri == ActivePri[num])
{ {
*SequenceNum = num; *SequenceNum = num;
return TRUE; return Co_TRUE;
} }
else if (pri < ActivePri[num]) else if (pri < ActivePri[num])
{ {
@@ -127,7 +127,7 @@ static BOOL GetPriSeqNum(U8 pri,OS_TID* SequenceNum)
} }
} }
*SequenceNum = num; *SequenceNum = num;
return FALSE; return Co_FALSE;
} }
@@ -238,8 +238,8 @@ static void PrioRemap(OS_TID seqNum)
* @brief Get the ready status for assign sequence number * @brief Get the ready status for assign sequence number
* @param[in] seqNum Assign sequence number * @param[in] seqNum Assign sequence number
* @param[out] None * @param[out] None
* @retval TRUE This priority has ready task * @retval Co_TRUE This priority has ready task
* FALSE This priority doesn't have ready task * Co_FALSE This priority doesn't have ready task
* *
* @par Description * @par Description
* @details This function is called in Binary-Scheduling Algorithm * @details This function is called in Binary-Scheduling Algorithm
@@ -250,9 +250,9 @@ static BOOL GetPrioSeqNumStatus(U8 seqNum)
{ {
if( (RdyTaskPriInfo[seqNum/32] & (1<<(seqNum%32))) == 0) if( (RdyTaskPriInfo[seqNum/32] & (1<<(seqNum%32))) == 0)
{ {
return FALSE; return Co_FALSE;
} }
return TRUE; return Co_TRUE;
} }
@@ -293,10 +293,10 @@ static void SetPrioSeqNumStatus(U8 seqNum, BOOL isRdy)
* increate the task num for this priority. * increate the task num for this priority.
******************************************************************************* *******************************************************************************
*/ */
static void ActiveTaskPri(U8 pri) void ActiveTaskPri(U8 pri)
{ {
OS_TID seqNum,num; OS_TID seqNum,num;
if(GetPriSeqNum(pri,&seqNum) == FALSE) if(GetPriSeqNum(pri,&seqNum) == Co_FALSE)
{ {
for(num=PriNum;num>seqNum;num--) for(num=PriNum;num>seqNum;num--)
{ {
@@ -332,7 +332,7 @@ static void ActiveTaskPri(U8 pri)
* remove the priority for queue. * remove the priority for queue.
******************************************************************************* *******************************************************************************
*/ */
static void DeleteTaskPri(U8 pri) void DeleteTaskPri(U8 pri)
{ {
OS_TID seqNum,num; OS_TID seqNum,num;
@@ -384,7 +384,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
{ {
if(ptcb != tcbInsert) /* Yes,is inserted task equal to running task? */ if(ptcb != tcbInsert) /* Yes,is inserted task equal to running task? */
{ {
if(ptcb != NULL) /* No,TCBRunning == NULL? */ if(ptcb != Co_NULL) /* No,TCBRunning == Co_NULL? */
{ /* N0,OSCheckTime < OSTickCnt? */ { /* N0,OSCheckTime < OSTickCnt? */
if(OSCheckTime < OSTickCnt) if(OSCheckTime < OSTickCnt)
{ /* Yes,set OSCheckTime for task robin */ { /* Yes,set OSCheckTime for task robin */
@@ -398,7 +398,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
GetPriSeqNum(prio,&seqNum); GetPriSeqNum(prio,&seqNum);
if(GetPrioSeqNumStatus(seqNum) == TRUE) if(GetPrioSeqNumStatus(seqNum) == Co_TRUE)
{ {
ptcb = &TCBTbl[RdyTaskPri[seqNum]]; ptcb = &TCBTbl[RdyTaskPri[seqNum]];
RdyTaskPri[seqNum] = tcbInsert->taskID; RdyTaskPri[seqNum] = tcbInsert->taskID;
@@ -411,8 +411,8 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
if(RdyTaskSeqNum == INVALID_ID) if(RdyTaskSeqNum == INVALID_ID)
{ {
ptcb = TCBRdy; ptcb = TCBRdy;
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
if(ptcb == NULL) if(ptcb == Co_NULL)
{ {
TCBRdy = tcbInsert; TCBRdy = tcbInsert;
} }
@@ -434,7 +434,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
tcbInsert->TCBnext = ptcbNext; /* Set link for list */ tcbInsert->TCBnext = ptcbNext; /* Set link for list */
ptcb->TCBnext = tcbInsert; ptcb->TCBnext = tcbInsert;
tcbInsert->TCBprev = ptcb; tcbInsert->TCBprev = ptcb;
if(ptcbNext != NULL) if(ptcbNext != Co_NULL)
{ {
ptcbNext->TCBprev = tcbInsert; ptcbNext->TCBprev = tcbInsert;
} }
@@ -442,14 +442,14 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
#else #else
ptcb = TCBRdy; ptcb = TCBRdy;
if (ptcb == NULL) /* Is ready list NULL? */ if (ptcb == Co_NULL) /* Is ready list Co_NULL? */
{ {
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
TCBRdy = tcbInsert; /* Yse,set tcbInsert as head item of list */ TCBRdy = tcbInsert; /* Yse,set tcbInsert as head item of list */
} }
else if (prio < ptcb->prio)/* Is PRI of inserted task higher than TCBRdy? */ else if (prio < ptcb->prio)/* Is PRI of inserted task higher than TCBRdy? */
{ {
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */ tcbInsert->TCBnext = ptcb; /* Yes,set tcbInsert as head item of list */
ptcb->TCBprev = tcbInsert; ptcb->TCBprev = tcbInsert;
TCBRdy = tcbInsert; TCBRdy = tcbInsert;
@@ -457,7 +457,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
else /* No,find correct place */ else /* No,find correct place */
{ {
ptcbNext = ptcb->TCBnext; /* Get next item */ ptcbNext = ptcb->TCBnext; /* Get next item */
while(ptcbNext != NULL) /* Is last item in ready list? */ while(ptcbNext != Co_NULL) /* Is last item in ready list? */
{ /* No,find correct place */ { /* No,find correct place */
if(prio < ptcbNext->prio) /* Is correct place? */ if(prio < ptcbNext->prio) /* Is correct place? */
break; /* Yes,break circulation */ break; /* Yes,break circulation */
@@ -467,7 +467,7 @@ void InsertToTCBRdyList(P_OSTCB tcbInsert)
tcbInsert->TCBnext = ptcbNext; /* Set link for list */ tcbInsert->TCBnext = ptcbNext; /* Set link for list */
ptcb->TCBnext = tcbInsert; ptcb->TCBnext = tcbInsert;
tcbInsert->TCBprev = ptcb; tcbInsert->TCBprev = ptcb;
if(ptcbNext != NULL) if(ptcbNext != Co_NULL)
{ {
ptcbNext->TCBprev = tcbInsert; ptcbNext->TCBprev = tcbInsert;
} }
@@ -495,57 +495,57 @@ void RemoveFromTCBRdyList(P_OSTCB ptcb)
U8 prio; U8 prio;
U8 seqNum; U8 seqNum;
BOOL isChange; BOOL isChange;
isChange = FALSE; isChange = Co_FALSE;
prio = ptcb->prio; prio = ptcb->prio;
GetPriSeqNum(prio,&seqNum); GetPriSeqNum(prio,&seqNum);
#endif #endif
/* Is there only one item in READY list? */ /* Is there only one item in READY list? */
if((ptcb->TCBnext == NULL) && (ptcb->TCBprev == NULL) ) if((ptcb->TCBnext == Co_NULL) && (ptcb->TCBprev == Co_NULL) )
{ {
TCBRdy = NULL; /* Yes,set READY list as NULL */ TCBRdy = Co_NULL; /* Yes,set READY list as Co_NULL */
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
isChange = TRUE; isChange = Co_TRUE;
#endif #endif
} }
else if(ptcb->TCBprev == NULL) /* Is the first item in READY list? */ else if(ptcb->TCBprev == Co_NULL) /* Is the first item in READY list? */
{ {
/* Yes,remove task from the list,and reset the head of READY list */ /* Yes,remove task from the list,and reset the head of READY list */
TCBRdy = ptcb->TCBnext; TCBRdy = ptcb->TCBnext;
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
TCBRdy->TCBprev = NULL; TCBRdy->TCBprev = Co_NULL;
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
if(TCBRdy->prio != prio) if(TCBRdy->prio != prio)
isChange = TRUE; isChange = Co_TRUE;
#endif #endif
} }
else if( ptcb->TCBnext == NULL) /* Is the last item in READY list? */ else if( ptcb->TCBnext == Co_NULL) /* Is the last item in READY list? */
{ /* Yes,remove task from list */ { /* Yes,remove task from list */
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
if(ptcb->TCBprev->prio != prio) if(ptcb->TCBprev->prio != prio)
isChange = TRUE; isChange = Co_TRUE;
else else
RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; RdyTaskPri[seqNum] = ptcb->TCBprev->taskID;
#endif #endif
ptcb->TCBprev->TCBnext = NULL; ptcb->TCBprev->TCBnext = Co_NULL;
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
} }
else /* No, remove task from list */ else /* No, remove task from list */
{ {
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
if((ptcb->TCBprev->prio != prio) && (ptcb->TCBnext->prio != prio)) if((ptcb->TCBprev->prio != prio) && (ptcb->TCBnext->prio != prio))
isChange = TRUE; isChange = Co_TRUE;
else if((ptcb->TCBprev->prio == prio) && (ptcb->TCBnext->prio != prio)) else if((ptcb->TCBprev->prio == prio) && (ptcb->TCBnext->prio != prio))
RdyTaskPri[seqNum] = ptcb->TCBprev->taskID; RdyTaskPri[seqNum] = ptcb->TCBprev->taskID;
#endif #endif
ptcb->TCBprev->TCBnext = ptcb->TCBnext; ptcb->TCBprev->TCBnext = ptcb->TCBnext;
ptcb->TCBnext->TCBprev = ptcb->TCBprev; ptcb->TCBnext->TCBprev = ptcb->TCBprev;
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
} }
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
if(isChange == TRUE) if(isChange == Co_TRUE)
{ {
RdyTaskPri[seqNum] = INVALID_ID; RdyTaskPri[seqNum] = INVALID_ID;
SetPrioSeqNumStatus(seqNum, 0); SetPrioSeqNumStatus(seqNum, 0);
@@ -642,7 +642,7 @@ StatusType CoSetPriority(OS_TID taskID,U8 priority)
if(ptcb->prio > TCBRdy->prio) /* Yes,Is PRI higher than TCBRdy? */ if(ptcb->prio > TCBRdy->prio) /* Yes,Is PRI higher than TCBRdy? */
{ {
OsSchedLock(); /* Yes,reorder task in READY list */ OsSchedLock(); /* Yes,reorder task in READY list */
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
OsSchedUnlock(); OsSchedUnlock();
} }
} }
@@ -657,7 +657,7 @@ StatusType CoSetPriority(OS_TID taskID,U8 priority)
ptcb = pMutex->waittingList; ptcb = pMutex->waittingList;
prio = pMutex->originalPrio; prio = pMutex->originalPrio;
pMutex->hipriTaskID = pMutex->taskID; pMutex->hipriTaskID = pMutex->taskID;
while(ptcb != NULL) while(ptcb != Co_NULL)
{ {
if(ptcb->prio < prio) if(ptcb->prio < prio)
{ {
@@ -716,12 +716,12 @@ void Schedule(void)
pCurTcb = TCBRunning; pCurTcb = TCBRunning;
pRdyTcb = TCBRdy; pRdyTcb = TCBRdy;
if((pRdyTcb==NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0)) if((pRdyTcb==Co_NULL) || (pCurTcb != TCBNext) || (OSSchedLock >1) || (OSIntNesting >0))
{ {
return; return;
} }
TaskSchedReq = FALSE; TaskSchedReq = Co_FALSE;
RunPrio = pCurTcb->prio; RunPrio = pCurTcb->prio;
RdyPrio = pRdyTcb->prio; RdyPrio = pRdyTcb->prio;
@@ -790,10 +790,10 @@ static P_OSTCB AssignTCB(void)
P_OSTCB ptcb; P_OSTCB ptcb;
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
if(FreeTCB == NULL) /* Is there no free TCB */ if(FreeTCB == Co_NULL) /* Is there no free TCB */
{ {
OsSchedUnlock(); /* Yes,unlock schedule */ OsSchedUnlock(); /* Yes,unlock schedule */
return NULL; /* Error return */ return Co_NULL; /* Error return */
} }
ptcb = FreeTCB; /* Yes,assgin free TCB for this task */ ptcb = FreeTCB; /* Yes,assgin free TCB for this task */
/* Set next item as the head of free TCB list */ /* Set next item as the head of free TCB list */
@@ -835,11 +835,11 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
prio = parameter&0xff; prio = parameter&0xff;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */ #if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(task == NULL) if(task == Co_NULL)
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
if(stk == NULL) if(stk == Co_NULL)
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -856,7 +856,7 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
#endif // CFG_PAR_CHECKOUT_EN #endif // CFG_PAR_CHECKOUT_EN
#if CFG_TASK_SCHEDULE_EN == 0 #if CFG_TASK_SCHEDULE_EN == 0
if(TCBRunning != NULL) if(TCBRunning != Co_NULL)
return E_CREATE_FAIL; return E_CREATE_FAIL;
#endif #endif
@@ -864,7 +864,7 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
ptcb = AssignTCB(); /* Get free TCB to use */ ptcb = AssignTCB(); /* Get free TCB to use */
if(ptcb == NULL) /* Is free TCB equal to NULL? */ if(ptcb == Co_NULL) /* Is free TCB equal to Co_NULL? */
{ {
return E_CREATE_FAIL; /* Yes,error return */ return E_CREATE_FAIL; /* Yes,error return */
} }
@@ -884,8 +884,8 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
ptcb->taskFuc = task; ptcb->taskFuc = task;
ptcb->taskStk = stk; ptcb->taskStk = stk;
#endif #endif
ptcb->TCBnext = NULL; /* Initialize TCB link in READY list */ ptcb->TCBnext = Co_NULL; /* Initialize TCB link in READY list */
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
#if CFG_ROBIN_EN >0 /* Set task time slice for task robin */ #if CFG_ROBIN_EN >0 /* Set task time slice for task robin */
timeSlice = (parameter&0x7fff0000)>>20; timeSlice = (parameter&0x7fff0000)>>20;
@@ -897,14 +897,14 @@ OS_TID CreateTask(FUNCPtr task,void *argv,U32 parameter,OS_STK *stk)
#endif #endif
#if CFG_FLAG_EN > 0 #if CFG_FLAG_EN > 0
ptcb->pnode = NULL; /* Initialize task as no flag waiting */ ptcb->pnode = Co_NULL; /* Initialize task as no flag waiting */
#endif #endif
#if CFG_EVENT_EN > 0 #if CFG_EVENT_EN > 0
ptcb->eventID = INVALID_ID; /* Initialize task as no event waiting*/ ptcb->eventID = INVALID_ID; /* Initialize task as no event waiting*/
ptcb->pmail = NULL; ptcb->pmail = Co_NULL;
ptcb->waitNext = NULL; ptcb->waitNext = Co_NULL;
ptcb->waitPrev = NULL; ptcb->waitPrev = Co_NULL;
#endif #endif
#if CFG_MUTEX_EN > 0 #if CFG_MUTEX_EN > 0
@@ -1009,7 +1009,7 @@ StatusType CoDelTask(OS_TID taskID)
#endif #endif
#if CFG_FLAG_EN > 0 #if CFG_FLAG_EN > 0
if(ptcb->pnode != NULL) /* Is task in flag waiting list? */ if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list? */
{ {
/* Yes,remove task from flag waiting list */ /* Yes,remove task from flag waiting list */
RemoveLinkNode(ptcb->pnode); RemoveLinkNode(ptcb->pnode);
@@ -1025,7 +1025,7 @@ StatusType CoDelTask(OS_TID taskID)
} }
#endif #endif
ptcb->state = TASK_DORMANT; /* Release TCB */ ptcb->state = TASK_DORMANT; /* Release TCB */
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
#if CFG_ORDER_LIST_SCHEDULE_EN ==0 #if CFG_ORDER_LIST_SCHEDULE_EN ==0
DeleteTaskPri(ptcb->prio); DeleteTaskPri(ptcb->prio);
@@ -1083,7 +1083,7 @@ StatusType CoActivateTask(OS_TID taskID,void *argv)
#endif #endif
ptcb = &TCBTbl[taskID]; ptcb = &TCBTbl[taskID];
#if CFG_PAR_CHECKOUT_EN >0 #if CFG_PAR_CHECKOUT_EN >0
if(ptcb->stkPtr == NULL) if(ptcb->stkPtr == Co_NULL)
return E_INVALID_ID; return E_INVALID_ID;
#endif #endif
if(ptcb->state != TASK_DORMANT) if(ptcb->state != TASK_DORMANT)
@@ -1171,7 +1171,7 @@ StatusType CoSuspendTask(OS_TID taskID)
} }
else else
{ {
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
} }
ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */
@@ -1229,7 +1229,7 @@ StatusType CoAwakeTask(OS_TID taskID)
} }
#if CFG_FLAG_EN > 0 #if CFG_FLAG_EN > 0
if(ptcb->pnode != NULL) /* Is task in flag waiting list */ if(ptcb->pnode != Co_NULL) /* Is task in flag waiting list */
{ {
return E_TASK_WAIT_OTHER; /* Yes,error return */ return E_TASK_WAIT_OTHER; /* Yes,error return */
} }
+26 -26
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file time.c * @file time.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief time management implementation code of CooCox CoOS kernel. * @brief time management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -21,7 +21,7 @@
#if CFG_TASK_WAITTING_EN > 0 #if CFG_TASK_WAITTING_EN > 0
/*---------------------------- Variable Define -------------------------------*/ /*---------------------------- Variable Define -------------------------------*/
P_OSTCB DlyList = NULL; /*!< Header pointer to the DELAY list.*/ P_OSTCB DlyList = Co_NULL; /*!< Header pointer to the DELAY list.*/
/** /**
@@ -44,7 +44,7 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
if(ticks == 0) /* Is delay tick == 0? */ if(ticks == 0) /* Is delay tick == 0? */
return; /* Yes,do nothing,return */ return; /* Yes,do nothing,return */
if(DlyList == NULL) /* Is no item in DELAY list? */ if(DlyList == Co_NULL) /* Is no item in DELAY list? */
{ {
ptcb->delayTick = ticks; /* Yes,set this as first item */ ptcb->delayTick = ticks; /* Yes,set this as first item */
DlyList = ptcb; DlyList = ptcb;
@@ -56,14 +56,14 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
deltaTicks = ticks; /* Get task delay ticks */ deltaTicks = ticks; /* Get task delay ticks */
/* Find correct place */ /* Find correct place */
while(dlyNext != NULL) while(dlyNext != Co_NULL)
{ {
/* Get delta ticks with previous item */ /* Get delta ticks with previous item */
deltaTicks -= dlyNext->delayTick; deltaTicks -= dlyNext->delayTick;
if(deltaTicks < 0) /* Is delta ticks<0? */ if(deltaTicks < 0) /* Is delta ticks<0? */
{ {
/* Yes,get correct place */ /* Yes,get correct place */
if(dlyNext->TCBprev != NULL) /* Is head item of DELAY list? */ if(dlyNext->TCBprev != Co_NULL) /* Is head item of DELAY list? */
{ {
dlyNext->TCBprev->TCBnext = ptcb; /* No,insert into */ dlyNext->TCBprev->TCBnext = ptcb; /* No,insert into */
ptcb->TCBprev = dlyNext->TCBprev; ptcb->TCBprev = dlyNext->TCBprev;
@@ -81,7 +81,7 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
break; break;
} }
/* Is last item in DELAY list? */ /* Is last item in DELAY list? */
else if((deltaTicks >= 0) && (dlyNext->TCBnext == NULL) ) else if((deltaTicks >= 0) && (dlyNext->TCBnext == Co_NULL) )
{ {
ptcb->TCBprev = dlyNext; /* Yes,insert into */ ptcb->TCBprev = dlyNext; /* Yes,insert into */
dlyNext->TCBnext = ptcb; dlyNext->TCBnext = ptcb;
@@ -93,7 +93,7 @@ void InsertDelayList(P_OSTCB ptcb,U32 ticks)
} }
ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */ ptcb->state = TASK_WAITING; /* Set task status as TASK_WAITING */
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
} }
@@ -112,31 +112,31 @@ void RemoveDelayList(P_OSTCB ptcb)
{ {
/* Is there only one item in the DELAY list? */ /* Is there only one item in the DELAY list? */
if((ptcb->TCBprev == NULL) && ( ptcb->TCBnext == NULL)) if((ptcb->TCBprev == Co_NULL) && ( ptcb->TCBnext == Co_NULL))
{ {
DlyList = NULL; /* Yes,set DELAY list as NULL */ DlyList = Co_NULL; /* Yes,set DELAY list as Co_NULL */
} }
else if(ptcb->TCBprev == NULL) /* Is the first item in DELAY list? */ else if(ptcb->TCBprev == Co_NULL) /* Is the first item in DELAY list? */
{ {
/* Yes,remove task from the DELAY list,and reset the list */ /* Yes,remove task from the DELAY list,and reset the list */
DlyList = ptcb->TCBnext; DlyList = ptcb->TCBnext;
ptcb->TCBnext->delayTick += ptcb->delayTick; ptcb->TCBnext->delayTick += ptcb->delayTick;
ptcb->TCBnext->TCBprev = NULL; ptcb->TCBnext->TCBprev = Co_NULL;
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
} }
else if(ptcb->TCBnext == NULL) /* Is the last item in DELAY list? */ else if(ptcb->TCBnext == Co_NULL) /* Is the last item in DELAY list? */
{ {
ptcb->TCBprev->TCBnext = NULL; /* Yes,remove task form DELAY list */ ptcb->TCBprev->TCBnext = Co_NULL; /* Yes,remove task form DELAY list */
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
} }
else /* No, remove task from DELAY list */ else /* No, remove task from DELAY list */
{ {
ptcb->TCBprev->TCBnext = ptcb->TCBnext; ptcb->TCBprev->TCBnext = ptcb->TCBnext;
ptcb->TCBnext->TCBprev = ptcb->TCBprev; ptcb->TCBnext->TCBprev = ptcb->TCBprev;
ptcb->TCBnext->delayTick += ptcb->delayTick; ptcb->TCBnext->delayTick += ptcb->delayTick;
ptcb->TCBnext = NULL; ptcb->TCBnext = Co_NULL;
ptcb->TCBprev = NULL; ptcb->TCBprev = Co_NULL;
} }
ptcb->delayTick = INVALID_VALUE; /* Set task delay tick value as invalid */ ptcb->delayTick = INVALID_VALUE; /* Set task delay tick value as invalid */
} }
@@ -227,7 +227,7 @@ StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks)
ptcb = &TCBTbl[taskID]; ptcb = &TCBTbl[taskID];
#if CFG_PAR_CHECKOUT_EN >0 #if CFG_PAR_CHECKOUT_EN >0
if(ptcb->stkPtr == NULL) if(ptcb->stkPtr == Co_NULL)
{ {
return E_INVALID_ID; return E_INVALID_ID;
} }
@@ -316,7 +316,7 @@ void TimeDispose(void)
P_OSTCB dlyList; P_OSTCB dlyList;
dlyList = DlyList; /* Get first item of DELAY list */ dlyList = DlyList; /* Get first item of DELAY list */
while((dlyList != NULL) && (dlyList->delayTick == 0) ) while((dlyList != Co_NULL) && (dlyList->delayTick == 0) )
{ {
#if CFG_EVENT_EN > 0 #if CFG_EVENT_EN > 0
@@ -327,21 +327,21 @@ void TimeDispose(void)
#endif #endif
#if CFG_FLAG_EN > 0 #if CFG_FLAG_EN > 0
if(dlyList->pnode != NULL) /* Is task in flag waiting list? */ if(dlyList->pnode != Co_NULL) /* Is task in flag waiting list? */
{ {
RemoveLinkNode(dlyList->pnode); /* Yes,remove task from list */ RemoveLinkNode(dlyList->pnode); /* Yes,remove task from list */
} }
#endif #endif
dlyList->delayTick = INVALID_VALUE; /* Set delay tick value as invalid*/ dlyList->delayTick = INVALID_VALUE; /* Set delay tick value as invalid*/
DlyList = dlyList->TCBnext; /* Get next item as the head of DELAY list*/ DlyList = dlyList->TCBnext; /* Get next item as the head of DELAY list*/
dlyList->TCBnext = NULL; dlyList->TCBnext = Co_NULL;
InsertToTCBRdyList(dlyList); /* Insert task into READY list */ InsertToTCBRdyList(dlyList); /* Insert task into READY list */
dlyList = DlyList; /* Get the first item of DELAY list */ dlyList = DlyList; /* Get the first item of DELAY list */
if(dlyList != NULL) /* Is DELAY list as NULL? */ if(dlyList != Co_NULL) /* Is DELAY list as Co_NULL? */
{ {
dlyList->TCBprev = NULL; /* No,initialize the first item */ dlyList->TCBprev = Co_NULL; /* No,initialize the first item */
} }
} }
} }
@@ -363,8 +363,8 @@ void isr_TimeDispose(void)
{ {
if(OSSchedLock > 1) /* Is schedule lock? */ if(OSSchedLock > 1) /* Is schedule lock? */
{ {
IsrReq = TRUE; IsrReq = Co_TRUE;
TimeReq = TRUE; /* Yes,set time request true */ TimeReq = Co_TRUE; /* Yes,set time request Co_TRUE */
} }
else else
{ {
+23 -23
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file timer.c * @file timer.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief timer management implementation code of CooCox CoOS kernel. * @brief timer management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -22,7 +22,7 @@
#if CFG_TMR_EN > 0 #if CFG_TMR_EN > 0
TmrCtrl TmrTbl[CFG_MAX_TMR]= {{0}};/*!< Table which save timer control block.*/ TmrCtrl TmrTbl[CFG_MAX_TMR]= {{0}};/*!< Table which save timer control block.*/
P_TmrCtrl TmrList = NULL; /*!< The header of the TmrCtrl list. */ P_TmrCtrl TmrList = Co_NULL; /*!< The header of the TmrCtrl list. */
U32 TmrIDVessel = 0; /*!< Timer ID container. */ U32 TmrIDVessel = 0; /*!< Timer ID container. */
@@ -51,7 +51,7 @@ static void InsertTmrList(OS_TCID tmrID)
} }
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
if(TmrList == NULL) /* Is no item in timer list? */ if(TmrList == Co_NULL) /* Is no item in timer list? */
{ {
TmrList = &TmrTbl[tmrID]; /* Yes,set this as first item */ TmrList = &TmrTbl[tmrID]; /* Yes,set this as first item */
} }
@@ -61,13 +61,13 @@ static void InsertTmrList(OS_TCID tmrID)
deltaTicks = tmrCnt; /* Get timer tick */ deltaTicks = tmrCnt; /* Get timer tick */
/* find correct place */ /* find correct place */
while(pTmr != NULL) while(pTmr != Co_NULL)
{ {
deltaTicks -= pTmr->tmrCnt; /* Get ticks with previous item */ deltaTicks -= pTmr->tmrCnt; /* Get ticks with previous item */
if(deltaTicks < 0) /* Is delta ticks<0? */ if(deltaTicks < 0) /* Is delta ticks<0? */
{ {
/* Yes,get correct place */ /* Yes,get correct place */
if(pTmr->tmrPrev!= NULL)/* Is head item of timer list? */ if(pTmr->tmrPrev!= Co_NULL)/* Is head item of timer list? */
{ {
/* No,insert into */ /* No,insert into */
pTmr->tmrPrev->tmrNext = &TmrTbl[tmrID]; pTmr->tmrPrev->tmrNext = &TmrTbl[tmrID];
@@ -86,7 +86,7 @@ static void InsertTmrList(OS_TCID tmrID)
break; break;
} }
/* Is last item in list? */ /* Is last item in list? */
else if((deltaTicks >= 0) && (pTmr->tmrNext == NULL)) else if((deltaTicks >= 0) && (pTmr->tmrNext == Co_NULL))
{ {
/* Yes,insert into */ /* Yes,insert into */
TmrTbl[tmrID].tmrPrev = pTmr; TmrTbl[tmrID].tmrPrev = pTmr;
@@ -121,30 +121,30 @@ static void RemoveTmrList(OS_TCID tmrID)
OsSchedLock(); /* Lock schedule */ OsSchedLock(); /* Lock schedule */
/* Is there only one item in timer list? */ /* Is there only one item in timer list? */
if((pTmr->tmrPrev == NULL) && (pTmr->tmrNext == NULL)) if((pTmr->tmrPrev == Co_NULL) && (pTmr->tmrNext == Co_NULL))
{ {
TmrList = NULL; /* Yes,set timer list as NULL */ TmrList = Co_NULL; /* Yes,set timer list as Co_NULL */
} }
else if(pTmr->tmrPrev == NULL) /* Is the first item in timer list? */ else if(pTmr->tmrPrev == Co_NULL) /* Is the first item in timer list? */
{ /* Yes,remove timer from list,and reset timer list */ { /* Yes,remove timer from list,and reset timer list */
TmrList = pTmr->tmrNext; TmrList = pTmr->tmrNext;
TmrList->tmrPrev = NULL; TmrList->tmrPrev = Co_NULL;
pTmr->tmrNext->tmrCnt += pTmr->tmrCnt; pTmr->tmrNext->tmrCnt += pTmr->tmrCnt;
pTmr->tmrNext = NULL; pTmr->tmrNext = Co_NULL;
} }
else if(pTmr->tmrNext == NULL) /* Is the last item in timer list? */ else if(pTmr->tmrNext == Co_NULL) /* Is the last item in timer list? */
{ {
/* Yes,remove timer form list */ /* Yes,remove timer form list */
pTmr->tmrPrev->tmrNext = NULL; pTmr->tmrPrev->tmrNext = Co_NULL;
pTmr->tmrPrev = NULL; pTmr->tmrPrev = Co_NULL;
} }
else /* No, remove timer from list */ else /* No, remove timer from list */
{ {
pTmr->tmrPrev->tmrNext = pTmr->tmrNext; pTmr->tmrPrev->tmrNext = pTmr->tmrNext;
pTmr->tmrNext->tmrPrev = pTmr->tmrPrev; pTmr->tmrNext->tmrPrev = pTmr->tmrPrev;
pTmr->tmrNext->tmrCnt += pTmr->tmrCnt; pTmr->tmrNext->tmrCnt += pTmr->tmrCnt;
pTmr->tmrNext = NULL; pTmr->tmrNext = Co_NULL;
pTmr->tmrPrev = NULL; pTmr->tmrPrev = Co_NULL;
} }
OsSchedUnlock(); /* Unlock schedule */ OsSchedUnlock(); /* Unlock schedule */
} }
@@ -173,7 +173,7 @@ OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func)
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
if(func == NULL) if(func == Co_NULL)
{ {
return E_CREATE_FAIL; return E_CREATE_FAIL;
} }
@@ -191,8 +191,8 @@ OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func)
TmrTbl[i].tmrCnt = tmrCnt; TmrTbl[i].tmrCnt = tmrCnt;
TmrTbl[i].tmrReload = tmrReload; TmrTbl[i].tmrReload = tmrReload;
TmrTbl[i].tmrCallBack = func; TmrTbl[i].tmrCallBack = func;
TmrTbl[i].tmrPrev = NULL; TmrTbl[i].tmrPrev = Co_NULL;
TmrTbl[i].tmrNext = NULL; TmrTbl[i].tmrNext = Co_NULL;
return i; /* Return timer ID */ return i; /* Return timer ID */
} }
} }
@@ -396,7 +396,7 @@ void TmrDispose(void)
P_TmrCtrl pTmr; P_TmrCtrl pTmr;
pTmr = TmrList; /* Get first item of timer list */ pTmr = TmrList; /* Get first item of timer list */
while((pTmr != NULL) && (pTmr->tmrCnt == 0) ) while((pTmr != Co_NULL) && (pTmr->tmrCnt == 0) )
{ {
if(pTmr->tmrType == TMR_TYPE_ONE_SHOT) /* Is a One-shot timer? */ if(pTmr->tmrType == TMR_TYPE_ONE_SHOT) /* Is a One-shot timer? */
{ {
@@ -435,8 +435,8 @@ void isr_TmrDispose(void)
{ {
if(OSSchedLock > 1) /* Is schedule lock? */ if(OSSchedLock > 1) /* Is schedule lock? */
{ {
IsrReq = TRUE; IsrReq = Co_TRUE;
TimerReq = TRUE; /* Yes,set timer request true */ TimerReq = Co_TRUE; /* Yes,set timer request true */
} }
else else
{ {
+2 -2
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file utility.c * @file utility.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Utility management implementation code of CooCox CoOS kernel. * @brief Utility management implementation code of CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
+2 -2
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file utility.h * @file utility.h
* @version V1.00 Initial version * @version V1.1.4
* @date 2009.06.26 * @date 2011.04.20
* @brief Utility function header file * @brief Utility function header file
* @details This file including some defines and declares related to utility * @details This file including some defines and declares related to utility
* function. * function.
+52 -8
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file prot.c * @file prot.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Compiler adapter for CooCox CoOS kernel. * @brief Compiler adapter for CooCox CoOS kernel.
******************************************************************************* *******************************************************************************
* @copy * @copy
@@ -27,8 +27,10 @@ U32 INT_EXIT = 0xFFFFFFFC;
//****************************************************************************** //******************************************************************************
// PUBLIC FUNCTIONS // PUBLIC FUNCTIONS
//****************************************************************************** //******************************************************************************
extern U8 Inc8(U8 *data) ; extern U8 Inc8(volatile U8 *data) ;
extern U8 Dec8(U8 *data) ; extern U8 Dec8(volatile U8 *data) ;
extern void IRQ_ENABLE_RESTORE(void);
extern void IRQ_DISABLE_SAVE(void);
extern void SetEnvironment(OS_STK *pstk) __attribute__ ((naked)); extern void SetEnvironment(OS_STK *pstk) __attribute__ ((naked));
extern void SwitchContext(void) __attribute__ ((naked)); extern void SwitchContext(void) __attribute__ ((naked));
extern void PendSV_Handler(void) __attribute__ ((naked)); extern void PendSV_Handler(void) __attribute__ ((naked));
@@ -46,7 +48,7 @@ extern void PendSV_Handler(void) __attribute__ ((naked));
* and Saved into memory cell. * and Saved into memory cell.
****************************************************************************** ******************************************************************************
*/ */
U8 Inc8 (U8 *data) U8 Inc8 (volatile U8 *data)
{ {
register U8 result = 0; register U8 result = 0;
@@ -81,7 +83,7 @@ U8 Inc8 (U8 *data)
* and Saved into memory cell. * and Saved into memory cell.
****************************************************************************** ******************************************************************************
*/ */
U8 Dec8 (U8 *data) U8 Dec8 (volatile U8 *data)
{ {
register U8 result = 0; register U8 result = 0;
__asm volatile __asm volatile
@@ -100,6 +102,46 @@ U8 Dec8 (U8 *data)
return (result); return (result);
} }
/**
******************************************************************************
* @brief ENABLE Interrupt
* @param[in] None
* @param[out] None
* @retval None
*
* @par Description
* @details This function is called to ENABLE Interrupt.
******************************************************************************
*/
void IRQ_ENABLE_RESTORE(void)
{
__asm volatile
(
" CPSIE I \n"
);
return;
}
/**
******************************************************************************
* @brief Close Interrupt
* @param[in] None
* @param[out] None
* @retval None
*
* @par Description
* @details This function is called to close Interrupt.
******************************************************************************
*/
void IRQ_DISABLE_SAVE(void)
{
__asm volatile
(
" CPSID I \n"
);
return;
}
/** /**
****************************************************************************** ******************************************************************************
@@ -119,8 +161,9 @@ void SetEnvironment (OS_STK *pstk)
( (
" SUB R0,#28 \n" " SUB R0,#28 \n"
" MSR PSP,R0 \n" " MSR PSP,R0 \n"
" BX LR \n" " BX LR \n"
); );
} }
@@ -145,8 +188,9 @@ void SwitchContext(void)
" LDR R2,=NVIC_PENDSVSET \n" " LDR R2,=NVIC_PENDSVSET \n"
" LDR R1,[R2] \n" " LDR R1,[R2] \n"
" STR R1, [R3] \n" " STR R1, [R3] \n"
" BX LR \n" " BX LR \n"
); );
} }
+7 -5
View File
@@ -1,8 +1,8 @@
/** /**
******************************************************************************* *******************************************************************************
* @file cpu.h * @file OsArch.h
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief Implement function declare related to Cortex-M3(ARM-v7) * @brief Implement function declare related to Cortex-M3(ARM-v7)
* @details This header file including functions or defines related to * @details This header file including functions or defines related to
* Cortex-M3(ARM-v7). * Cortex-M3(ARM-v7).
@@ -43,6 +43,8 @@ extern U64 OSTickCnt; /*!< Counter for current system ticks. */
extern OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk); extern OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk);
extern void SwitchContext(void); /*!< Switch context */ extern void SwitchContext(void); /*!< Switch context */
extern void SetEnvironment(OS_STK *pstk);/*!< Set environment for run */ extern void SetEnvironment(OS_STK *pstk);/*!< Set environment for run */
extern U8 Inc8 (U8 *data); extern U8 Inc8 (volatile U8 *data);
extern U8 Dec8 (U8 *data); extern U8 Dec8 (volatile U8 *data);
extern void IRQ_ENABLE_RESTORE(void);
extern void IRQ_DISABLE_SAVE(void);
#endif #endif
+7 -7
View File
@@ -1,9 +1,9 @@
/** /**
******************************************************************************* *******************************************************************************
* @file cpu.c * @file arch.c
* @version V1.12 * @version V1.1.4
* @date 2010.03.01 * @date 2011.04.20
* @brief This file provides InitTaskContext() and SysTick_Handler(). * @brief This file provides InitTaskContext() and SysTick_Handler().
******************************************************************************* *******************************************************************************
* @copy * @copy
* WRITE COPY INFORMATION USE CAPITAL LETTER * WRITE COPY INFORMATION USE CAPITAL LETTER
@@ -63,7 +63,7 @@ void SysTick_Handler(void)
OSSchedLock++; /* Lock scheduler. */ OSSchedLock++; /* Lock scheduler. */
OSTickCnt++; /* Increment systerm time. */ OSTickCnt++; /* Increment systerm time. */
#if CFG_TASK_WAITTING_EN >0 #if CFG_TASK_WAITTING_EN >0
if(DlyList != NULL) /* Have task in delay list? */ if(DlyList != Co_NULL) /* Have task in delay list? */
{ {
if(DlyList->delayTick > 1) /* Delay time > 1? */ if(DlyList->delayTick > 1) /* Delay time > 1? */
{ {
@@ -78,7 +78,7 @@ void SysTick_Handler(void)
#endif #endif
#if CFG_TMR_EN > 0 #if CFG_TMR_EN > 0
if(TmrList != NULL) /* Have timer in working? */ if(TmrList != Co_NULL) /* Have timer in working? */
{ {
if(TmrList->tmrCnt > 1) /* Timer time > 1? */ if(TmrList->tmrCnt > 1) /* Timer time > 1? */
{ {
@@ -91,6 +91,6 @@ void SysTick_Handler(void)
} }
} }
#endif #endif
TaskSchedReq = TRUE; TaskSchedReq = Co_TRUE;
OsSchedUnlock(); OsSchedUnlock();
} }
+7 -18
View File
@@ -322,7 +322,7 @@ ifeq ($(PCB), ARM)
# V4 ARM, so ... # V4 ARM, so ...
OPT = 2 OPT = 2
CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM
EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable # FreeRTOSV7.1.1/Source/include FreeRTOSV7.1.1/Source/portable/GCC/ARM_CM3 EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable
BOARDSRC = board_ersky9x.cpp BOARDSRC = board_ersky9x.cpp
EXTRABOARDSRC = ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c EXTRABOARDSRC = ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c
CPPSRC += ersky9x/ff.cpp ersky9x/diskio.cpp ersky9x/gtime.cpp CPPSRC += ersky9x/ff.cpp ersky9x/diskio.cpp ersky9x/gtime.cpp
@@ -677,24 +677,14 @@ ifeq ($(PCB), ARM)
%.elf: allsrc.cpp %.elf: allsrc.cpp
@echo @echo
@echo $(MSG_COMPILING) $@ @echo $(MSG_COMPILING) $@
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/list.c -o list.o
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/queue.c -o queue.o
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/tasks.c -o tasks.o
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/timers.c -o timers.o
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/portable/GCC/ARM_CM3/port.c -o port.o
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/portable/IAR/ARM_CM3/port.c -o port.o
#$(AS) FreeRTOSV7.1.1/Source/portable/IAR/ARM_CM3/portasm.s -o portasm.o
#$(CC) $(ALL_CPPFLAGS) FreeRTOSV7.1.1/Source/portable/MemMang/heap_2.c -o heap.o
#$(CC) $(ALL_CPPFLAGS) syscalls.c -o syscalls.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/core.c -o core.o $(CC) $(ALL_CPPFLAGS) CoOS/kernel/core.c -o core.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/hook.c -o hook.o $(CC) $(ALL_CPPFLAGS) CoOS/kernel/hook.c -o hook.o
#$(CC) $(ALL_CPPFLAGS) CoOS/kernel/kernelHeap.c -o kernelHeap.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/task.c -o task.o $(CC) $(ALL_CPPFLAGS) CoOS/kernel/task.c -o task.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/mutex.c -o mutex.o #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/mutex.c -o mutex.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/sem.c -o sem.o #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/sem.c -o sem.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/queue.c -o queue.o #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/queue.c -o queue.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/mbox.c -o mbox.o #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/mbox.c -o mbox.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/flag.c -o flag.o #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/flag.c -o flag.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/event.c -o event.o $(CC) $(ALL_CPPFLAGS) CoOS/kernel/event.c -o event.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/time.c -o time.o $(CC) $(ALL_CPPFLAGS) CoOS/kernel/time.c -o time.o
$(CC) $(ALL_CPPFLAGS) CoOS/kernel/timer.c -o timer.o $(CC) $(ALL_CPPFLAGS) CoOS/kernel/timer.c -o timer.o
@@ -702,8 +692,7 @@ ifeq ($(PCB), ARM)
$(CC) $(ALL_CPPFLAGS) CoOS/portable/GCC/port.c -o port.o $(CC) $(ALL_CPPFLAGS) CoOS/portable/GCC/port.c -o port.o
$(CC) $(ALL_CPPFLAGS) CoOS/portable/arch.c -o arch.o $(CC) $(ALL_CPPFLAGS) CoOS/portable/arch.c -o arch.o
$(CC) $(ALL_CPPFLAGS) $< -o allsrc.o $(CC) $(ALL_CPPFLAGS) $< -o allsrc.o
#$(CC) allsrc.o list.o queue.o tasks.o timers.o port.o heap.o syscalls.o -mcpu=cortex-m3 -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@ $(CC) allsrc.o core.o hook.o task.o event.o time.o timer.o serviceReq.o port.o arch.o -mcpu=cortex-m3 -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@
$(CC) allsrc.o core.o hook.o task.o mutex.o sem.o queue.o mbox.o flag.o event.o time.o timer.o serviceReq.o port.o arch.o -mcpu=cortex-m3 -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@
else else
%.elf: allsrc.cpp %.elf: allsrc.cpp
@echo @echo
+4 -4
View File
@@ -51,8 +51,8 @@ void BusFault_Handler (void) __attribute__((weak));
void UsageFault_Handler (void) __attribute__((weak)); void UsageFault_Handler (void) __attribute__((weak));
void SVC_Handler (void) __attribute__((weak)); void SVC_Handler (void) __attribute__((weak));
void DebugMon_Handler (void) __attribute__((weak)); void DebugMon_Handler (void) __attribute__((weak));
void PendSV_Handler (void) __attribute__((weak)); extern void PendSV_Handler (void) __attribute__((weak));
void SysTick_Handler (void) __attribute__((weak)); extern void SysTick_Handler (void) __attribute__((weak));
void SUPC_IRQHandler (void) __attribute__((weak)); void SUPC_IRQHandler (void) __attribute__((weak));
void RSTC_IRQHandler (void) __attribute__((weak)); void RSTC_IRQHandler (void) __attribute__((weak));
@@ -158,8 +158,8 @@ void BusFault_Handler (void) { while(1); }
void UsageFault_Handler (void) { while(1); } void UsageFault_Handler (void) { while(1); }
void SVC_Handler (void) { while(1); } void SVC_Handler (void) { while(1); }
void DebugMon_Handler (void) { while(1); } void DebugMon_Handler (void) { while(1); }
void PendSV_Handler (void) { while(1); } // void PendSV_Handler (void) { while(1); }
void SysTick_Handler (void) { while(1); } // void SysTick_Handler (void) { while(1); }
void SUPC_IRQHandler (void) { while(1); } void SUPC_IRQHandler (void) { while(1); }
void RSTC_IRQHandler (void) { while(1); } void RSTC_IRQHandler (void) { while(1); }