Skip to content

Commit d462717

Browse files
committed
Update ARMCC pre_main to be in C
Switch pre_main from assembly to C for ARMCC. This function does not need to be in assembly.
1 parent 38ae4f9 commit d462717

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

rtos/rtx/TARGET_CORTEX_A/RTX_CM_lib.h

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*---------------------------------------------------------------------------*/
3434

3535
#if defined (__CC_ARM)
36+
#include <rt_misc.h>
3637
#pragma O3
3738
#define __USED __attribute__((used))
3839
#elif defined (__GNUC__)
@@ -442,25 +443,12 @@ void pre_main()
442443
void * armcc_heap_base;
443444
void * armcc_heap_top;
444445

445-
__asm void pre_main (void)
446-
{
447-
IMPORT __rt_lib_init
448-
IMPORT main
449-
IMPORT armcc_heap_base
450-
IMPORT armcc_heap_top
446+
int main(void);
451447

452-
LDR R0,=armcc_heap_base
453-
LDR R1,=armcc_heap_top
454-
LDR R0,[R0]
455-
LDR R1,[R1]
456-
/* Save link register (keep 8 byte alignment with dummy R4) */
457-
PUSH {R4, LR}
458-
BL __rt_lib_init
459-
BL main
460-
/* Return to the thread destroy function.
461-
*/
462-
POP {R4, PC}
463-
ALIGN
448+
void pre_main (void)
449+
{
450+
__rt_lib_init((unsigned)armcc_heap_base, (unsigned)armcc_heap_top);
451+
main();
464452
}
465453

466454
__asm void __rt_entry (void) {

rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "mbed_error.h"
3535

3636
#if defined (__CC_ARM)
37+
#include <rt_misc.h>
3738
#pragma O3
3839
#define __USED __attribute__((used))
3940
#elif defined (__GNUC__)
@@ -593,25 +594,12 @@ void pre_main()
593594
void * armcc_heap_base;
594595
void * armcc_heap_top;
595596

596-
__asm void pre_main (void)
597-
{
598-
IMPORT __rt_lib_init
599-
IMPORT main
600-
IMPORT armcc_heap_base
601-
IMPORT armcc_heap_top
597+
int main(void);
602598

603-
LDR R0,=armcc_heap_base
604-
LDR R1,=armcc_heap_top
605-
LDR R0,[R0]
606-
LDR R1,[R1]
607-
/* Save link register (keep 8 byte alignment with dummy R4) */
608-
PUSH {R4, LR}
609-
BL __rt_lib_init
610-
BL main
611-
/* Return to the thread destroy function.
612-
*/
613-
POP {R4, PC}
614-
ALIGN
599+
void pre_main (void)
600+
{
601+
__rt_lib_init((unsigned)armcc_heap_base, (unsigned)armcc_heap_top);
602+
main();
615603
}
616604

617605
/* The single memory model is checking for stack collision at run time, verifing

0 commit comments

Comments
 (0)