1
1
/*----------------------------------------------------------------------------
2
- * CMSIS-RTOS - RTX
2
+ * RL-ARM - RTX
3
3
*----------------------------------------------------------------------------
4
4
* Name: RTX_CM_LIB.H
5
5
* Purpose: RTX Kernel System Configuration
6
- * Rev.: V4.79
6
+ * Rev.: V4.73
7
7
*----------------------------------------------------------------------------
8
8
*
9
- * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
9
+ * Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH
10
10
* All rights reserved.
11
11
* Redistribution and use in source and binary forms, with or without
12
12
* modification, are permitted provided that the following conditions are met:
15
15
* - Redistributions in binary form must reproduce the above copyright
16
16
* notice, this list of conditions and the following disclaimer in the
17
17
* documentation and/or other materials provided with the distribution.
18
- * - Neither the name of ARM nor the names of its contributors may be used
19
- * to endorse or promote products derived from this software without
18
+ * - Neither the name of ARM nor the names of its contributors may be used
19
+ * to endorse or promote products derived from this software without
20
20
* specific prior written permission.
21
21
*
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
25
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26
26
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
31
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
32
* POSSIBILITY OF SUCH DAMAGE.
33
33
*---------------------------------------------------------------------------*/
@@ -63,10 +63,9 @@ typedef uint32_t OS_RESULT;
63
63
64
64
#define runtask_id () rt_tsk_self()
65
65
#define mutex_init (m ) rt_mut_init(m)
66
- #define mutex_wait (m ) os_mut_wait(m,0xFFFFU )
66
+ #define mutex_wait (m ) os_mut_wait(m,0xFFFF )
67
67
#define mutex_rel (m ) os_mut_release(m)
68
68
69
- extern uint8_t os_running ;
70
69
extern OS_TID rt_tsk_self (void );
71
70
extern void rt_mut_init (OS_ID mutex );
72
71
extern OS_RESULT rt_mut_release (OS_ID mutex );
@@ -141,14 +140,6 @@ void __iar_system_Mtxunlock(__iar_Rmtx *);
141
140
* Global Variables
142
141
*---------------------------------------------------------------------------*/
143
142
144
- #if (OS_TASKCNT == 0 )
145
- #error "Invalid number of concurrent running threads!"
146
- #endif
147
-
148
- #if (OS_PRIVCNT >= OS_TASKCNT )
149
- #error "Too many threads with user-provided stack size!"
150
- #endif
151
-
152
143
#if (OS_TIMERS != 0 )
153
144
#define OS_TASK_CNT (OS_TASKCNT + 1)
154
145
#ifndef __MBED_CMSIS_RTOS_CA9
@@ -163,32 +154,24 @@ void __iar_system_Mtxunlock(__iar_Rmtx *);
163
154
#endif
164
155
#endif
165
156
166
- #ifndef OS_STKINIT
167
- #define OS_STKINIT 0
168
- #endif
169
-
170
157
uint16_t const os_maxtaskrun = OS_TASK_CNT ;
171
158
#ifdef __MBED_CMSIS_RTOS_CA9
172
- uint32_t const os_stackinfo = (OS_STKINIT << 28 ) | ( OS_STKCHECK <<24 ) | (OS_IDLESTKSIZE * 4 );
159
+ uint32_t const os_stackinfo = (OS_STKCHECK <<24 )| (OS_IDLESTKSIZE * 4 );
173
160
#else
174
- uint32_t const os_stackinfo = (OS_STKINIT << 28 ) | ( OS_STKCHECK <<24 ) | (OS_PRIV_CNT <<16 ) | (OS_STKSIZE * 4 );
161
+ uint32_t const os_stackinfo = (OS_STKCHECK <<24 )| (OS_PRIV_CNT <<16 ) | (OS_STKSIZE * 4 );
175
162
#endif
176
163
uint32_t const os_rrobin = (OS_ROBIN << 16 ) | OS_ROBINTOUT ;
177
164
uint32_t const os_tickfreq = OS_CLOCK ;
178
165
uint16_t const os_tickus_i = OS_CLOCK /1000000 ;
179
166
uint16_t const os_tickus_f = (((uint64_t )(OS_CLOCK - 1000000 * (OS_CLOCK /1000000 )))<<16 )/1000000 ;
180
167
uint32_t const os_trv = OS_TRV ;
181
- #if defined(FEATURE_UVISOR ) && defined(TARGET_UVISOR_SUPPORTED )
182
- uint8_t const os_flags = 0 ;
183
- #else /* defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED) */
184
168
uint8_t const os_flags = OS_RUNPRIV ;
185
- #endif /* defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED) */
186
169
187
170
/* Export following defines to uVision debugger. */
188
171
__USED uint32_t const CMSIS_RTOS_API_Version = osCMSIS ;
189
172
__USED uint32_t const CMSIS_RTOS_RTX_Version = osCMSIS_RTX ;
190
173
__USED uint32_t const os_clockrate = OS_TICK ;
191
- __USED uint32_t const os_timernum = 0U ;
174
+ __USED uint32_t const os_timernum = 0 ;
192
175
193
176
/* Memory pool for TCB allocation */
194
177
_declare_box (mp_tcb , OS_TCB_SIZE , OS_TASK_CNT );
@@ -233,14 +216,14 @@ osMessageQId osMessageQId_osTimerMessageQ;
233
216
#else
234
217
osThreadDef_t os_thread_def_osTimerThread = { NULL };
235
218
osThreadId osThreadId_osTimerThread ;
236
- osMessageQDef (osTimerMessageQ , 0U , void * );
219
+ osMessageQDef (osTimerMessageQ , 0 , void * );
237
220
osMessageQId osMessageQId_osTimerMessageQ ;
238
221
#endif
239
222
240
223
/* Legacy RTX User Timers not used */
241
- uint32_t os_tmr = 0U ;
224
+ uint32_t os_tmr = 0 ;
242
225
uint32_t const * m_tmr = NULL ;
243
- uint16_t const mp_tmr_size = 0U ;
226
+ uint16_t const mp_tmr_size = 0 ;
244
227
245
228
/* singleton mutex */
246
229
osMutexId singleton_mutex_id ;
@@ -289,8 +272,8 @@ void *__user_perthread_libspace (void) {
289
272
/* Provide a separate libspace for each task. */
290
273
uint32_t idx ;
291
274
292
- idx = ( os_running != 0U ) ? runtask_id () : 0U ;
293
- if (idx == 0U ) {
275
+ idx = runtask_id ();
276
+ if (idx == 0 ) {
294
277
/* RTX not running yet. */
295
278
return (& __libspace_start );
296
279
}
@@ -316,7 +299,7 @@ int _mutex_initialize (OS_ID *mutex) {
316
299
317
300
__attribute__((used )) void _mutex_acquire (OS_ID * mutex ) {
318
301
/* Acquire a system mutex, lock stdlib resources. */
319
- if (os_running ) {
302
+ if (runtask_id () ) {
320
303
/* RTX running, acquire a mutex. */
321
304
mutex_wait (* mutex );
322
305
}
@@ -327,7 +310,7 @@ __attribute__((used)) void _mutex_acquire (OS_ID *mutex) {
327
310
328
311
__attribute__((used )) void _mutex_release (OS_ID * mutex ) {
329
312
/* Release a system mutex, unlock stdlib resources. */
330
- if (os_running ) {
313
+ if (runtask_id () ) {
331
314
/* RTX running, release a mutex. */
332
315
mutex_rel (* mutex );
333
316
}
@@ -420,9 +403,9 @@ void __iar_system_Mtxunlock(__iar_Rmtx *mutex)
420
403
extern void pre_main (void );
421
404
#ifdef __MBED_CMSIS_RTOS_CA9
422
405
uint32_t os_thread_def_stack_main [(4 * OS_MAINSTKSIZE ) / sizeof (uint32_t )];
423
- osThreadDef_t os_thread_def_main = {(os_pthread )pre_main , osPriorityNormal , 1U , 4 * OS_MAINSTKSIZE , os_thread_def_stack_main };
406
+ osThreadDef_t os_thread_def_main = {(os_pthread )pre_main , osPriorityNormal , 1 , 4 * OS_MAINSTKSIZE , os_thread_def_stack_main };
424
407
#else
425
- osThreadDef_t os_thread_def_main = {(os_pthread )pre_main , osPriorityNormal , 1U , 4 * OS_MAINSTKSIZE };
408
+ osThreadDef_t os_thread_def_main = {(os_pthread )pre_main , osPriorityNormal , 1 , 4 * OS_MAINSTKSIZE };
426
409
#endif
427
410
428
411
#if defined (__CC_ARM )
@@ -502,21 +485,14 @@ __asm void __rt_entry (void) {
502
485
#endif
503
486
504
487
#elif defined (__GNUC__ )
505
-
506
- osMutexDef (malloc_mutex );
507
- static osMutexId malloc_mutex_id ;
508
- osMutexDef (env_mutex );
509
- static osMutexId env_mutex_id ;
510
-
511
488
extern int atexit (void (* func )(void ));
512
489
extern void __libc_fini_array (void );
513
490
extern void __libc_init_array (void );
514
491
extern int main (int argc , char * * argv );
515
492
516
493
void pre_main (void ) {
517
494
singleton_mutex_id = osMutexCreate (osMutex (singleton_mutex ));
518
- malloc_mutex_id = osMutexCreate (osMutex (malloc_mutex ));
519
- env_mutex_id = osMutexCreate (osMutex (env_mutex ));
495
+ atexit (__libc_fini_array );
520
496
__libc_init_array ();
521
497
main (0 , NULL );
522
498
}
@@ -535,29 +511,6 @@ __attribute__((naked)) void software_init_hook_rtos (void) {
535
511
);
536
512
}
537
513
538
- // Opaque declaration of _reent structure
539
- struct _reent ;
540
-
541
- void __rtos_malloc_lock ( struct _reent * _r )
542
- {
543
- osMutexWait (malloc_mutex_id , osWaitForever );
544
- }
545
-
546
- void __rtos_malloc_unlock ( struct _reent * _r )
547
- {
548
- osMutexRelease (malloc_mutex_id );
549
- }
550
-
551
- void __rtos_env_lock ( struct _reent * _r )
552
- {
553
- osMutexWait (env_mutex_id , osWaitForever );
554
- }
555
-
556
- void __rtos_env_unlock ( struct _reent * _r )
557
- {
558
- osMutexRelease (env_mutex_id );
559
- }
560
-
561
514
#elif defined (__ICCARM__)
562
515
extern void * __vector_core_a9 ;
563
516
extern int __low_level_init (void );
@@ -580,7 +533,7 @@ void pre_main(void) {
580
533
}
581
534
582
535
#pragma required=__vector_core_a9
583
- void __iar_program_start (void )
536
+ void __iar_program_start ( void )
584
537
{
585
538
__iar_init_core ();
586
539
__iar_init_vfp ();
@@ -603,6 +556,8 @@ void __iar_program_start(void)
603
556
604
557
#endif
605
558
559
+
606
560
/*----------------------------------------------------------------------------
607
561
* end of file
608
562
*---------------------------------------------------------------------------*/
563
+
0 commit comments