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
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}
47