1 /******************************************************************************
2 ** File Name: oscfg.h *
3 ** Author: Benjamin.Wang *
5 ** Copyright: 2006 Spreadtrum, Incorporated. All Rights Reserved. *
6 ** Description: This file is used to do some definition about task *
7 ** creation. If static task is created or thread entry is *
8 ** defined, you should include this file. *
9 ******************************************************************************
11 ******************************************************************************
13 ** ------------------------------------------------------------------------- *
14 ** DATE NAME DESCRIPTION *
15 ** 11/08/2006 Benjamin.Wang Create. *
16 ******************************************************************************/
21 /**---------------------------------------------------------------------------*
23 **---------------------------------------------------------------------------*/
31 /**---------------------------------------------------------------------------*
32 ** MACRO Definations *
33 **---------------------------------------------------------------------------*/
34 /* For dynamic malloc task stack mode*/
35 #define DEF_TASK(__name, __prio, __stack_size, __queue_num) \
37 void* __name##_STACK_ADDR = (void*)SCI_ALLOC_CONST(((__stack_size >> 2) << 2) + 3); \
38 char* __name##_QUEUE_ADDR = (char*)SCI_ALLOC_CONST(__queue_num * SCI_QUEUE_ITEM_SIZE * 4 + 3); \
39 extern void thread_entry_##__name(uint32, void*); \
40 SCI_ASSERT((__name##_STACK_ADDR != SCI_NULL) && (__name##_QUEUE_ADDR != SCI_NULL)); \
41 __name##_STACK_ADDR = (void*)((((uint32)__name##_STACK_ADDR + 3) >> 2) << 2); \
42 __name##_QUEUE_ADDR = (char*)((((uint32)__name##_QUEUE_ADDR + 3) >> 2) << 2); \
43 SCI_CreateStaticThread(__name, "T_"#__name, thread_entry_##__name, 0, 0, \
44 __name##_STACK_ADDR, __stack_size, __prio, SCI_PREEMPT, "Q_"#__name, \
45 __name##_QUEUE_ADDR, __queue_num, SCI_AUTO_START); \
48 /* For static task stack mode*/
50 #define DEF_TASK(__name, __prio, __stack_size, __queue_num) \
52 static uint32 __name##_STACK_ADDR[__stack_size >> 2]; \
53 static uint32 __name##_QUEUE_ADDR[__queue_num * SCI_QUEUE_ITEM_SIZE]; \
54 extern void thread_entry_##__name(uint32, void*); \
55 SCI_CreateStaticThread(__name, "T_"#__name, thread_entry_##__name, 0, 0, \
56 __name##_STACK_ADDR, __stack_size, __prio, SCI_PREEMPT, "Q_"#__name, \
57 __name##_QUEUE_ADDR, __queue_num, SCI_AUTO_START); \
61 #define STATIC_TASK_DEF_BEGIN(__type) PUBLIC void SCI_CreateTasks##__type(void){
63 #define STATIC_TASK_DEF_END }
65 #define STATIC_TASK_CREATE(__type) \
67 extern void SCI_CreateTasks##__type(void); \
68 SCI_CreateTasks##__type(); \
71 #define THREAD_ENTRY(__name) void thread_entry_##__name(uint32 argc, void* argv)
72 /* Thread entry Example:
73 * THREAD_ENTRY(CM) //Entry name(__name) should be the same one as task define.
75 * // Attention: Notice module's initialization order. Avoid system's block.
78 * //wait event or get signal
83 /**---------------------------------------------------------------------------*
85 **---------------------------------------------------------------------------*/
87 /**---------------------------------------------------------------------------*
89 **---------------------------------------------------------------------------*/
91 /**---------------------------------------------------------------------------*
93 **---------------------------------------------------------------------------*/
95 /**---------------------------------------------------------------------------*
96 ** Constant Variables *
97 **---------------------------------------------------------------------------*/
99 /**---------------------------------------------------------------------------*
100 ** Function Prototypes *
101 **---------------------------------------------------------------------------*/
103 /**---------------------------------------------------------------------------*
105 **---------------------------------------------------------------------------*/