⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 retarget.c

📁 arm7的源代码
💻 C
字号:
/*
** Copyright (C) ARM Limited, 2002. All rights reserved.
*/

#include <stdio.h>
#include <rt_misc.h>

extern unsigned int bottom_of_heap;    //defined in heap.s


extern void core_init(void);
extern void clock_speed(int);

/*
The functions below are patched onto main - in later versions of ARM tools,
callouts from C Library Initialisation code will be available.
__rt_entry could be used instead of main
*/


extern void $Super$$main(void);

void $Sub$$main(void)
{
 #ifdef SET_CLOCK
  clock_speed(100);
 #endif 
  
  core_init();                    // does some extra setup work
  $Super$$main();                 // calls the original function

}


/*
This function re-implements the C Library semihosted function. The stack pointer 
has aready been set and is passed back to the funtion, The base of the heap is
set from the scatter file
*/

__value_in_regs struct __initial_stackheap __user_initial_stackheap(
        unsigned R0, unsigned SP, unsigned R2, unsigned SL)
{
    struct __initial_stackheap config;
    
    config.heap_base = (unsigned int)&bottom_of_heap; // defined in heap.s
                                                      // placed by scatterfile   
    config.stack_base = SP;   // inherit SP from the execution environment

    return config;
}

/*
Below is an equivalent example assembler version of __user_initial_stackheap.

It will be entered with the value of the stackpointer in r1 (as set in init.s), 
this does not need to be changed and so can be passed unmodified out of the 
function. 

    IMPORT bottom_of_heap
    EXPORT __user_initial_stackheap

__user_initial_stackheap    
    LDR   r0,=bottom_of_heap
    MOV   pc,lr
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -