• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 ** Copyright (C) ARM Limited, 2005. All rights reserved.
3 */
4 
5 #if defined(__cplusplus)
6 #include <cstdio>
7 #else
8 #include <stdio.h>
9 #endif
10 #include <rt_misc.h>
11 
12 // Heap base from scatter file
13 extern int Image$$HEAP$$ZI$$Base;
14 //#pragma import(__use_two_region_memory)
15 
16 extern void core_init(void);
17 
18 /*
19 The functions below are patched onto main.
20 */
21 
22 extern void $Super$$main(void);
23 
$Sub$$main(void)24 void $Sub$$main(void)
25 {
26   core_init();                    // does some extra setup work
27 
28   $Super$$main();                 // calls the original function
29 }
30 
31 
32 /*
33 This function re-implements the C Library semihosted function. The stack pointer
34 has aready been set and is passed back to the function, The base of the heap is
35 set from the scatter file
36 */
__user_initial_stackheap(unsigned R0,unsigned SP,unsigned R2,unsigned SL)37 __value_in_regs struct __initial_stackheap __user_initial_stackheap(
38         unsigned R0, unsigned SP, unsigned R2, unsigned SL)
39 {
40     struct __initial_stackheap config;
41 
42     config.heap_base = (unsigned int)&Image$$HEAP$$ZI$$Base; // placed by scatterfile
43     config.stack_base = SP;   // inherit SP from the execution environment
44 
45     return config;
46 }
47