4 /**---------------------------------------------------------------------------*
6 **---------------------------------------------------------------------------*/
7 // c standard head file.
8 #include <linux/string.h>
12 #include "sci_types.h"
15 /**---------------------------------------------------------------------------*
17 **---------------------------------------------------------------------------*/
23 /**---------------------------------------------------------------------------*
24 ** Constant Variables *
25 **---------------------------------------------------------------------------*/
26 // Invalid state value.
27 #define SCI_INVALID_STATE ~0
29 //---------------------------------------------
31 //---------------------------------------------
33 #define SCI_SUCCESS 0x00
35 #define SCI_DELETED 0x01
36 //Invalid pool pointer.
37 #define SCI_POOL_ERROR 0x02
39 #define SCI_PTR_ERROR 0x03
40 //A wait option other than TX_NO_WAIT was specified on call from a non-thread.
41 #define SCI_WAIT_ERROR 0x04
43 #define SCI_SIZE_ERROR 0x05
44 //Invalid event group pointer.
45 #define SCI_GROUP_ERROR 0x06
46 //Service was unable to get the specified events.
47 #define SCI_NO_EVENTS 0x07
48 //Invalid option was specified.
49 #define SCI_OPTION_ERROR 0x08
50 //Invalid queue pointer.
51 #define SCI_QUEUE_ERROR 0x09
52 //Service was unable to retrieve a message because the queue was empty.
53 #define SCI_QUEUE_EMPTY 0x0A
54 //Service was unable to send message because the queue was full.
55 #define SCI_QUEUE_FULL 0x0B
56 //Invalid counting semaphore pointer.
57 #define SCI_SEMAPHORE_ERROR 0x0C
58 //Service was unable to retrieve an instance of the counting semaphore (semaphore count is zero).
59 #define SCI_NO_INSTANCE 0x0D
60 //Invalid thread control pointer.
61 #define SCI_THREAD_ERROR 0x0E
62 //Invalid thread priority, which is a value outside the range of 0-31.
63 #define SCI_PRIORITY_ERROR 0x0F
64 //Service was unable to allocate memory.
65 #define SCI_NO_MEMORY 0x10
66 //Specified thread is not in a terminated or completed state.
67 #define SCI_DELETE_ERROR 0x11
68 //Specified thread is not suspended.
69 #define SCI_RESUME_ERROR 0x12
70 //Invalid caller of this service.
71 #define SCI_CALLER_ERROR 0x13
72 //Specified thread is in a terminated or completed state.
73 #define SCI_SUSPEND_ERROR 0x14
74 //Invalid application timer pointer.
75 #define SCI_TIMER_ERROR 0x15
76 //Invalid value (a zero) supplied for initial ticks.
77 #define SCI_TICK_ERROR 0x16
78 //Timer was already active./Invalid activation selected.
79 #define SCI_ACTIVATE_ERROR 0x17
80 //Invalid preemption threshold specified.
81 //This value must be a valid priority less than or equal to the initial priority of the thread.
82 #define SCI_THRESH_ERROR 0x18
83 //Previously set delayed suspension was lifted.
84 #define SCI_SUSPEND_LIFTED 0x19
85 //Suspension was aborted by another thread, timer, or ISR.
86 #define SCI_WAIT_ABORTED 0x1A
87 //Specified thread is not in a waiting state.
88 #define SCI_WAIT_ABORT_ERROR 0x1B
89 //Invalid mutex pointer.
90 #define SCI_MUTEX_ERROR 0x1C
91 //Service was unable to get ownership of the mutex.
92 #define SCI_NOT_AVAILABLE 0x1D
93 //Mutex is not owned by caller.
94 #define SCI_NOT_OWNED 0x1E
95 //Invalid priority inherit parameter.
96 #define SCI_INHERIT_ERROR 0x1F
97 //Invalid auto-start selection.
98 #define SCI_START_ERROR 0x20
99 //Parameter is invalid.
100 #define SCI_PARAM_ERROR 0x21
102 #define SCI_ERROR 0xFF
104 //---------------------------------------------
105 // API input parameters.
106 //---------------------------------------------
108 #define SCI_TRUE TRUE // Boolean true value
109 #define SCI_FALSE FALSE // Boolean false value
112 #define SCI_NO_WAIT 0x0
113 #define SCI_WAIT_FOREVER 0xFFFFFFFF
115 // Option used to set/get event.
117 #define SCI_OR_CLEAR 1
119 #define SCI_AND_CLEAR 3
121 // Auto start option on thread
122 #define SCI_DONT_START 0
123 #define SCI_AUTO_START 1
125 // Indicates if the thread is preemptable.
126 #define SCI_NO_PREEMPT 0
127 #define SCI_PREEMPT 1
129 // Auto start option on timer.
130 #define SCI_NO_ACTIVATE 0
131 #define SCI_AUTO_ACTIVATE 1
133 //@Zhemin.Lin, add, 09/12/2003, CR:MS00004678
134 //priority inherit mode for mutex
135 #define SCI_NO_INHERIT 0
136 #define SCI_INHERIT 1
138 // Thread priority definetion
139 #define SCI_PRIORITY_KERNEL 0
140 #define SCI_PRIORITY_TIME_CRITICAL 5
141 #define SCI_PRIORITY_HIGHEST 10
142 #define SCI_PRIORITY_ABOVE_NORMAL 15
143 #define SCI_PRIORITY_NORMAL 20
144 #define SCI_PRIORITY_BELOW_NORMAL 24
145 #define SCI_PRIORITY_LOWEST 28
146 #define SCI_PRIORITY_IDLE 31
148 //---------------------------------------------
149 // General constants.
150 //---------------------------------------------
151 // Max ID of static thread MUST be less than this value.
152 #define SCI_MAX_STATIC_THREAD_ID 100
153 // Number of all static threads should less than this value.
154 #define SCI_MAX_STATIC_THREAD_NUM 100
157 #define SCI_INVALID_BLOCK_ID 0xFFFFFFFF
159 // Size of Queue item. Number of unsigned long int.
160 #define SCI_QUEUE_ITEM_SIZE 1
162 // Name size of thread, timer, queue, etc...
163 #define SCI_MAX_NAME_SIZE 32
165 // RTOS system state.
166 #define SCI_RTOS_INITIALIZE_IN_PROGRESS 0
167 #define SCI_RTOS_INITIALIZE_COMPLETED 1
171 #define CONST_HEAP_MEMORY 0x22222222UL
172 #define DYNAMIC_HEAP_BASE_MEMORY 0x33333333UL
173 #define DYNAMIC_HEAP_APP_MEMORY 0x44444444UL
176 #define SCI_TRACE_NULL SCI_TraceNull
178 extern void SCI_Trace(const char *, ...);
179 #define SCI_TRACE_ERROR SCI_Trace
180 #define SCI_TRACE_HIGH SCI_Trace
181 #define SCI_TRACE_MID SCI_Trace
182 #define SCI_TRACE_LOW SCI_Trace
183 #define SCI_TRACE_BUF SCI_TraceBuf
184 #define SCI_TRACE_DATA SCI_TraceCapData
186 #define SCI_TRACE_ERROR SCI_TraceError
187 #define SCI_TRACE_HIGH SCI_TraceHigh
188 #define SCI_TRACE_DATA SCI_TraceCapData
190 #ifdef TRACE_INFO_SUPPORT
191 #define SCI_TRACE_BUF SCI_TraceBuf
192 #define SCI_TRACE_MID SCI_TraceMid
193 #define SCI_TRACE_LOW SCI_TraceLow
195 #define SCI_TRACE_BUF(...)
196 #define SCI_TRACE_MID(...)
197 #define SCI_TRACE_LOW(...)
201 //---------------------------------------------
203 //---------------------------------------------
204 typedef void *SCI_EVENT_GROUP_PTR;
205 typedef void *SCI_THREAD_PTR;
206 typedef void *SCI_TIMER_PTR;
208 //Zhemin.Lin, add, 09/12/2003, CR:MS00004678,
209 typedef void *SCI_MUTEX_PTR;
210 typedef void *SCI_SEMAPHORE_PTR;
214 /**---------------------------------------------------------------------------*
216 **---------------------------------------------------------------------------*/
218 #define SCI_ASSERT(_EXP)
219 #define SCI_PASSERT(_EXP,PRINT_STR)
222 #define SCI_MEMCPY(_DEST_PTR, _SRC_PTR, _SIZE) \
225 SCI_ASSERT(PNULL != (_DEST_PTR)); \
226 if ((_SIZE)>0) { memcpy((_DEST_PTR), (_SRC_PTR), (_SIZE));} \
229 #define SCI_MEMSET(_DEST_PTR, _VALUE, _SIZE) \
232 SCI_ASSERT(PNULL != (_DEST_PTR)); \
233 if ((_SIZE)>0) { memset((_DEST_PTR), (_VALUE), (_SIZE)); } \
238 /**---------------------------------------------------------------------------*
240 **---------------------------------------------------------------------------*/
241 /*****************************************************************************/
242 // Description: The function is used to disable IRQ and save old status to
244 // Global resource dependence:
247 /*****************************************************************************/
248 PUBLIC void SCI_DisableIRQ(void);
250 /*****************************************************************************/
251 // Description: The function is used to restore the old IRQ status.
252 // Global resource dependence:
255 /*****************************************************************************/
256 PUBLIC void SCI_RestoreIRQ(void);
261 /**---------------------------------------------------------------------------*
263 **---------------------------------------------------------------------------*/
264 /*****************************************************************************/
265 // Description: This function retrieves the number of milliseconds that
266 // have elapsed since the system was started.
267 // Global resource dependence:
268 // Author: Richard.Yang
269 // Note: The elapsed time is stored as a uint32 value. Therefore,
270 // the time will wrap around to zero if the system is run
271 // continuously for 49.7 days.
272 /*****************************************************************************/
273 PUBLIC uint32 SCI_GetTickCount(void); // Number of ticks.
277 /*****************************************************************************/
278 // Description: This function put a message to the trace buffer which log
279 // level is no more than LOG_LEVEL_LOW.
280 // This function put a message to the trace buffer.
281 // 1.msg_trace_info.buf_is_send == TRACE_BUF_SEND
282 // Send the messages to the application tool when buffer
284 // 2.msg_trace_info.buf_is_send == TRACE_BUF_COVER
285 // Always cover the oldest message when buffer is full.
286 // Global resource dependence:
287 // Author: Richard.Yang
289 /*****************************************************************************/
290 PUBLIC uint32 SCI_TraceLow(
291 const char *x_format, ...);
299 /**---------------------------------------------------------------------------*
301 **---------------------------------------------------------------------------*/
306 #endif // End of _OS_API_H