Skip to content

Commit 61d08c8

Browse files
TomoYamanakaadbridge
authored andcommitted
Revert "[RZ/A1H]Support RTX v4.80 for Cortex-A and a few Malloc API"
This reverts commit e71f79a.
1 parent 4a4ab8b commit 61d08c8

38 files changed

+1410
-1350
lines changed

rtos/RtosTimer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ class RtosTimer {
144144
mbed::Callback<void()> _function;
145145
osTimerId _timer_id;
146146
osTimerDef_t _timer;
147-
#ifdef CMSIS_OS_RTX
147+
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
148+
uint32_t _timer_data[5];
149+
#else
148150
uint32_t _timer_data[6];
149151
#endif
150152
};

rtos/rtx/TARGET_CORTEX_A/HAL_CA.c

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*----------------------------------------------------------------------------
2-
* CMSIS-RTOS - RTX
2+
* RL-ARM - RTX
33
*----------------------------------------------------------------------------
44
* Name: HAL_CA.C
55
* Purpose: Hardware Abstraction Layer for Cortex-A
6-
* Rev.: V4.77 plus changes for RTX-Ax
6+
* Rev.:
77
*----------------------------------------------------------------------------
88
*
9-
* Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH, 2012-2015 ARM Limited
9+
* Copyright (c) 2012 ARM Limited
1010
* All rights reserved.
1111
* Redistribution and use in source and binary forms, with or without
1212
* modification, are permitted provided that the following conditions are met:
@@ -15,19 +15,19 @@
1515
* - Redistributions in binary form must reproduce the above copyright
1616
* notice, this list of conditions and the following disclaimer in the
1717
* 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
2020
* specific prior written permission.
2121
*
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
2424
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2525
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
2626
* 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)
3131
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3232
* POSSIBILITY OF SUCH DAMAGE.
3333
*---------------------------------------------------------------------------*/
@@ -44,14 +44,14 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
4444

4545
/* Prepare a complete interrupt frame for first task start */
4646
size = p_TCB->priv_stack >> 2;
47-
if (size == 0U) {
47+
if (size == 0) {
4848
size = (U16)os_stackinfo >> 2;
4949
}
5050
/* Write to the top of stack. */
5151
stk = &p_TCB->stack[size];
5252

5353
/* Auto correct to 8-byte ARM stack alignment. */
54-
if ((U32)stk & 0x04U) {
54+
if ((U32)stk & 0x04) {
5555
stk--;
5656
}
5757

@@ -69,10 +69,10 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
6969
/* Assign a void pointer to R0. */
7070
stk[8] = (U32)p_TCB->msg;
7171
/* Clear R1-R12,LR registers. */
72-
for (i = 0U; i < 8U; i++) {
73-
stk[i] = 0U;
72+
for (i = 0; i < 8; i++) {
73+
stk[i] = 0;
7474
}
75-
for (i = 9U; i < 14U; i++) {
75+
for (i = 9; i < 14; i++) {
7676
stk[i] = 0;
7777
}
7878

@@ -82,20 +82,6 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
8282
/* Task entry point. */
8383
p_TCB->ptask = task_body;
8484

85-
/* Initialize stack with magic pattern. */
86-
if (os_stackinfo & 0x10000000U) {
87-
if (size > (16U+1U)) {
88-
for (i = ((size - 16U)/2U) - 1U; i; i--) {
89-
stk -= 2U;
90-
stk[1] = MAGIC_PATTERN;
91-
stk[0] = MAGIC_PATTERN;
92-
}
93-
if (--stk > p_TCB->stack) {
94-
*stk = MAGIC_PATTERN;
95-
}
96-
}
97-
}
98-
9985
/* Set a magic word for checking of stack overflow. */
10086
p_TCB->stack[0] = MAGIC_WORD;
10187
}
@@ -107,13 +93,13 @@ static __inline U32 *rt_ret_regs (P_TCB p_TCB) {
10793
/* Get pointer to task return value registers (R0..R3) in Stack */
10894
if (p_TCB->stack_frame & 0x4) {
10995
/* NEON/D32 Stack Frame: D0-31,FPSCR,Reserved,R4-R11,R0-R3,R12,LR,PC,xPSR */
110-
return (U32 *)(p_TCB->tsk_stack + (8U*4U) + (2U*4U) + (32U*8U));
96+
return (U32 *)(p_TCB->tsk_stack + 8*4 + 2*4 + 32*8);
11197
} else if (p_TCB->stack_frame & 0x2) {
11298
/* VFP/D16 Stack Frame: D0-D15/S0-31,FPSCR,Reserved,R4-R11,R0-R3,R12,LR,PC,xPSR */
113-
return (U32 *)(p_TCB->tsk_stack + (8U*4U) + (2U*4U) + (32U*4U));
99+
return (U32 *)(p_TCB->tsk_stack + 8*4 + 2*4 + 32*4);
114100
} else {
115101
/* Basic Stack Frame: R4-R11,R0-R3,R12,LR,PC,xPSR */
116-
return (U32 *)(p_TCB->tsk_stack + (8U*4U));
102+
return (U32 *)(p_TCB->tsk_stack + 8*4);
117103
}
118104
}
119105

rtos/rtx/TARGET_CORTEX_A/RTX_CM_lib.h

Lines changed: 28 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*----------------------------------------------------------------------------
2-
* CMSIS-RTOS - RTX
2+
* RL-ARM - RTX
33
*----------------------------------------------------------------------------
44
* Name: RTX_CM_LIB.H
55
* Purpose: RTX Kernel System Configuration
6-
* Rev.: V4.79
6+
* Rev.: V4.73
77
*----------------------------------------------------------------------------
88
*
9-
* Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
9+
* Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH
1010
* All rights reserved.
1111
* Redistribution and use in source and binary forms, with or without
1212
* modification, are permitted provided that the following conditions are met:
@@ -15,19 +15,19 @@
1515
* - Redistributions in binary form must reproduce the above copyright
1616
* notice, this list of conditions and the following disclaimer in the
1717
* 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
2020
* specific prior written permission.
2121
*
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
2424
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2525
* ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
2626
* 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)
3131
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3232
* POSSIBILITY OF SUCH DAMAGE.
3333
*---------------------------------------------------------------------------*/
@@ -63,10 +63,9 @@ typedef uint32_t OS_RESULT;
6363

6464
#define runtask_id() rt_tsk_self()
6565
#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)
6767
#define mutex_rel(m) os_mut_release(m)
6868

69-
extern uint8_t os_running;
7069
extern OS_TID rt_tsk_self (void);
7170
extern void rt_mut_init (OS_ID mutex);
7271
extern OS_RESULT rt_mut_release (OS_ID mutex);
@@ -141,14 +140,6 @@ void __iar_system_Mtxunlock(__iar_Rmtx *);
141140
* Global Variables
142141
*---------------------------------------------------------------------------*/
143142

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-
152143
#if (OS_TIMERS != 0)
153144
#define OS_TASK_CNT (OS_TASKCNT + 1)
154145
#ifndef __MBED_CMSIS_RTOS_CA9
@@ -163,32 +154,24 @@ void __iar_system_Mtxunlock(__iar_Rmtx *);
163154
#endif
164155
#endif
165156

166-
#ifndef OS_STKINIT
167-
#define OS_STKINIT 0
168-
#endif
169-
170157
uint16_t const os_maxtaskrun = OS_TASK_CNT;
171158
#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);
173160
#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);
175162
#endif
176163
uint32_t const os_rrobin = (OS_ROBIN << 16) | OS_ROBINTOUT;
177164
uint32_t const os_tickfreq = OS_CLOCK;
178165
uint16_t const os_tickus_i = OS_CLOCK/1000000;
179166
uint16_t const os_tickus_f = (((uint64_t)(OS_CLOCK-1000000*(OS_CLOCK/1000000)))<<16)/1000000;
180167
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) */
184168
uint8_t const os_flags = OS_RUNPRIV;
185-
#endif /* defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED) */
186169

187170
/* Export following defines to uVision debugger. */
188171
__USED uint32_t const CMSIS_RTOS_API_Version = osCMSIS;
189172
__USED uint32_t const CMSIS_RTOS_RTX_Version = osCMSIS_RTX;
190173
__USED uint32_t const os_clockrate = OS_TICK;
191-
__USED uint32_t const os_timernum = 0U;
174+
__USED uint32_t const os_timernum = 0;
192175

193176
/* Memory pool for TCB allocation */
194177
_declare_box (mp_tcb, OS_TCB_SIZE, OS_TASK_CNT);
@@ -233,14 +216,14 @@ osMessageQId osMessageQId_osTimerMessageQ;
233216
#else
234217
osThreadDef_t os_thread_def_osTimerThread = { NULL };
235218
osThreadId osThreadId_osTimerThread;
236-
osMessageQDef(osTimerMessageQ, 0U, void *);
219+
osMessageQDef(osTimerMessageQ, 0, void *);
237220
osMessageQId osMessageQId_osTimerMessageQ;
238221
#endif
239222

240223
/* Legacy RTX User Timers not used */
241-
uint32_t os_tmr = 0U;
224+
uint32_t os_tmr = 0;
242225
uint32_t const *m_tmr = NULL;
243-
uint16_t const mp_tmr_size = 0U;
226+
uint16_t const mp_tmr_size = 0;
244227

245228
/* singleton mutex */
246229
osMutexId singleton_mutex_id;
@@ -289,8 +272,8 @@ void *__user_perthread_libspace (void) {
289272
/* Provide a separate libspace for each task. */
290273
uint32_t idx;
291274

292-
idx = (os_running != 0U) ? runtask_id () : 0U;
293-
if (idx == 0U) {
275+
idx = runtask_id ();
276+
if (idx == 0) {
294277
/* RTX not running yet. */
295278
return (&__libspace_start);
296279
}
@@ -316,7 +299,7 @@ int _mutex_initialize (OS_ID *mutex) {
316299

317300
__attribute__((used)) void _mutex_acquire (OS_ID *mutex) {
318301
/* Acquire a system mutex, lock stdlib resources. */
319-
if (os_running) {
302+
if (runtask_id ()) {
320303
/* RTX running, acquire a mutex. */
321304
mutex_wait (*mutex);
322305
}
@@ -327,7 +310,7 @@ __attribute__((used)) void _mutex_acquire (OS_ID *mutex) {
327310

328311
__attribute__((used)) void _mutex_release (OS_ID *mutex) {
329312
/* Release a system mutex, unlock stdlib resources. */
330-
if (os_running) {
313+
if (runtask_id ()) {
331314
/* RTX running, release a mutex. */
332315
mutex_rel (*mutex);
333316
}
@@ -420,9 +403,9 @@ void __iar_system_Mtxunlock(__iar_Rmtx *mutex)
420403
extern void pre_main (void);
421404
#ifdef __MBED_CMSIS_RTOS_CA9
422405
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 };
424407
#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 };
426409
#endif
427410

428411
#if defined (__CC_ARM)
@@ -502,21 +485,14 @@ __asm void __rt_entry (void) {
502485
#endif
503486

504487
#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-
511488
extern int atexit(void (*func)(void));
512489
extern void __libc_fini_array(void);
513490
extern void __libc_init_array (void);
514491
extern int main(int argc, char **argv);
515492

516493
void pre_main(void) {
517494
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);
520496
__libc_init_array();
521497
main(0, NULL);
522498
}
@@ -535,29 +511,6 @@ __attribute__((naked)) void software_init_hook_rtos (void) {
535511
);
536512
}
537513

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-
561514
#elif defined (__ICCARM__)
562515
extern void* __vector_core_a9;
563516
extern int __low_level_init(void);
@@ -580,7 +533,7 @@ void pre_main(void) {
580533
}
581534

582535
#pragma required=__vector_core_a9
583-
void __iar_program_start(void)
536+
void __iar_program_start( void )
584537
{
585538
__iar_init_core();
586539
__iar_init_vfp();
@@ -603,6 +556,8 @@ void __iar_program_start(void)
603556

604557
#endif
605558

559+
606560
/*----------------------------------------------------------------------------
607561
* end of file
608562
*---------------------------------------------------------------------------*/
563+

0 commit comments

Comments
 (0)