- Timestamp:
-
10/21/05 19:40:54 (19 years ago)
- Author:
-
JoelSherrill
- Comment:
-
/* PowerPC Initialisation */ more format corrections
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v2
|
v3
|
|
37 | 37 | BSP should call (gcc provided) '''_eabi()''' very early to set up a SYSV/EABI compliant environment (load r2/r13, stack align etc.). If you don't do this, e.g., SYSV/EABI short data areas won't work (see gcc -msdata -meabi options). |
38 | 38 | |
39 | | RTEMS calls '''''init()''' which among other things works through the C++ static constructor list -- provided that your linker stript and '''bsp''specs''' files are correct. See [wiki:#InitMagic C++ .init Linker Magic] on how it works. |
| 39 | RTEMS calls '''init()''' which among other things works through the C++ static constructor list -- provided that your linker stript and '''bsp_specs''' files are correct. See [wiki:#InitMagic C++ .init Linker Magic] on how it works. |
40 | 40 | |
41 | | * However''', there is a problem here, in that '''''eabi()''' ends up calling '''''init()''' (actually, '''__init()*, we renamed to fix the problem described here) when it is still too early to initialize the C++ environment. |
| 41 | * However, there is a problem here, in that '''eabi()''' ends up calling '''init()''' (actually, '''__init()''', we renamed to fix the problem described here) when it is still too early to initialize the C++ environment. |
42 | 42 | |
43 | | '''Note''' both details are of the 'seems to work' type. You won't notice anything if you don't call '''''eabi()''' until you try to use an essential SYSV/EABI feature. Likewise, calling '''''init()''' too early might not cause problems in many cases until one of your constructors uses an yet unavailable feature provided by RTEMS such as '''malloc()'''. |
| 43 | '''Note''' both details are of the 'seems to work' type. You won't notice anything if you don't call '''eabi()''' until you try to use an essential SYSV/EABI feature. Likewise, calling '''init()''' too early might not cause problems in many cases until one of your constructors uses an yet unavailable feature provided by RTEMS such as '''malloc()'''. |
44 | 44 | |
45 | 45 | For the PowerPC a typical chicken + egg. problem exists - |
46 | 46 | |
47 | 47 | ##we want to call '''_eabi()''' early (libbsp/powerpc/shared/start/start.S) |
48 | | ##we want to prevent '''_''init()''' from being called too early (by '''''eabi()''') |
| 48 | ##we want to prevent '''_init()''' from being called too early (by '''eabi()''') |
49 | 49 | ##we want to call '''__init()''' at the apropriate time. |
50 | 50 | ##we dont want to hack gcc. |
51 | 51 | |
52 | 52 | Here's the solution using the '''.init''' magic as described in the appendix - |
53 | | * an additional startup file '''rtems''crti.S''' ''terminates'' '''''_init()''' |
| 53 | * an additional startup file '''rtems_crti.S''' terminates '''_init()''' |
54 | 54 | * so it becomes a no-op and introduces a new '''_init()''' entry point |
55 | 55 | * to be used by RTEMS ([wiki:ThreadHandler ThreadHandler]). |
… |
… |
|
79 | 79 | Here's what happens (properly linked executable) : |
80 | 80 | |
81 | | <verbatim></verbatim> |
82 | | |
83 | 81 | ##BSP '''start.s''' calls '''_eabi()'''; SYSVI/EABI environment setup |
84 | | ##'''''eabi()''' calls '''''_init()''' |
| 82 | ##'''eabi()''' calls '''_init()''' |
85 | 83 | ##'''__init()''' returns immediately |
86 | 84 | ##BSP initializes |