blob: 3f010765a8b0c2c6f9634bc4ec2b399a8e84571e [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2** Copyright (C) ARM Limited, 2005. All rights reserved.
3*/
4
Christophe Lyon6f4d36f2011-07-19 16:18:19 +02005#if defined(__cplusplus)
6#include <cstdio>
7#else
Christophe Lyon073831a2011-01-24 17:37:40 +01008#include <stdio.h>
Christophe Lyon6f4d36f2011-07-19 16:18:19 +02009#endif
Christophe Lyon073831a2011-01-24 17:37:40 +010010#include <rt_misc.h>
11
12// Heap base from scatter file
13extern int Image$$HEAP$$ZI$$Base;
14//#pragma import(__use_two_region_memory)
15
16extern void core_init(void);
17
18/*
19The functions below are patched onto main.
20*/
21
22extern void $Super$$main(void);
23
24void $Sub$$main(void)
25{
26 core_init(); // does some extra setup work
27
28 $Super$$main(); // calls the original function
29}
30
31
32/*
33This function re-implements the C Library semihosted function. The stack pointer
34has aready been set and is passed back to the function, The base of the heap is
35set from the scatter file
36*/
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}