Mercurial > ecos
annotate packages/hal/synth/arch/current/src/synth_entry.c @ 3291:68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
the .init_array section as well as .ctors (needed for gcc 4.7 and
later)
| author | jlarmour |
|---|---|
| date | Fri, 03 Oct 2014 15:13:21 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
1 //========================================================================== |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
2 // |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
3 // synth_entry.c |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
4 // |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
5 // Entry code for Linux synthetic target. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
6 // |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
7 //========================================================================== |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
161
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
16 // version. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
161
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
21 // for more details. |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
33 // General Public License v2. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
161
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2399
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
39 //========================================================================== |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
40 //#####DESCRIPTIONBEGIN#### |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
41 // |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
42 // Author(s): proven |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
43 // Contributors:proven, jskov, bartv |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
44 // Date: 1999-01-06 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
45 // Purpose: Entry point for Linux synthetic target. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
46 // |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
47 //####DESCRIPTIONEND#### |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
48 // |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
49 //========================================================================= |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
50 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
51 #include <pkgconf/system.h> |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
52 #include <pkgconf/hal.h> |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
53 #include <cyg/infra/cyg_type.h> |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
54 #include <cyg/infra/cyg_ass.h> |
| 2244 | 55 #include <cyg/infra/diag.h> |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
56 #include <cyg/hal/hal_arch.h> |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
57 #include <cyg/hal/hal_intr.h> |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
58 #include <cyg/hal/hal_io.h> |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
59 #include CYGHWR_MEMORY_LAYOUT_H |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
60 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
61 /*------------------------------------------------------------------------*/ |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
62 /* C++ support - run initial constructors */ |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
63 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
64 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
65 cyg_bool cyg_hal_stop_constructors; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
66 #endif |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
67 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
68 typedef void (*pfunc) (void); |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
69 extern pfunc __CTOR_LIST__[]; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
70 extern pfunc __CTOR_END__[]; |
|
3291
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
71 extern pfunc __init_array_start__[]; |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
72 extern pfunc __init_array_end__[]; |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
73 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
74 void |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
75 cyg_hal_invoke_constructors (void) |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
76 { |
|
3291
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
77 /* Note: We appear to be running the constructors twice here, but |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
78 * this is not actually the case. |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
79 * gcc 4.7 changed the way static constructors are linked: |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
80 * - Prior to gcc 4.7, they appeared in the .ctors section of the |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
81 * ELF * image. |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
82 * - Since gcc 4.7, they moved to .init_array and in the reverse |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
83 * order. |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
84 * |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
85 * For us to look for both (both here and in synth.ld) is harmless, |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
86 * because the constructors are only linked once, and we are not |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
87 * too worried about squeezing every last byte of code size out of |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
88 * the synth target. |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
89 * |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
90 * - wry, 2014-10-01 |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
91 */ |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
92 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
93 static pfunc *p = &__CTOR_END__[-1]; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
94 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
95 cyg_hal_stop_constructors = 0; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
96 for (; p >= __CTOR_LIST__; p--) { |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
97 (*p) (); |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
98 if (cyg_hal_stop_constructors) { |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
99 p--; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
100 break; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
101 } |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
102 } |
|
3291
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
103 for (p = &__init_array_start__[0]; p != (__init_array_end__); p++) { |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
104 (*p) (); |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
105 if (cyg_hal_stop_constructors) { |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
106 p++; |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
107 break; |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
108 } |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
109 } |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
110 #else |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
111 pfunc *p; |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
112 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
113 for (p = &__CTOR_END__[-1]; p >= __CTOR_LIST__; p--) |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
114 (*p) (); |
|
3291
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
115 for (p = &__init_array_start__[0]; p != (__init_array_end__); p++) |
|
68c8985fd5f0
* src/synth.ld src/synth_entry.c: Look for static constructors in
jlarmour
parents:
2729
diff
changeset
|
116 (*p) (); |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
117 #endif |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
118 } |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
119 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
120 // ---------------------------------------------------------------------------- |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
121 // The low-level entry point is platform-specific, typically in the |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
122 // assember file vectors.S. However that entry point simply jumps |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
123 // directly here, with no further processing or stack manipulation. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
124 // The HAL specification defines clearly what should happen during |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
125 // startup. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
126 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
127 externC void cyg_start( void ); |
|
332
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
128 externC void synth_hardware_init(void); |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
129 externC void synth_hardware_init2(void); |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
130 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
131 void _linux_entry( void ) |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
132 { |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
133 // "Initialize various cpu status registers, including disabling interrupts." |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
134 // That is a no-op for the synthetic target, in particular interrupts are |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
135 // already disabled. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
136 |
|
2103
9169038683a3
Replace use of brk() system call with linker script magic to obtain
bartv
parents:
1093
diff
changeset
|
137 // "Set up any CPU memory controller to access ROM, RAM, and I/O |
|
9169038683a3
Replace use of brk() system call with linker script magic to obtain
bartv
parents:
1093
diff
changeset
|
138 // devices correctly". The ROM and RAM are set up via the linker |
|
9169038683a3
Replace use of brk() system call with linker script magic to obtain
bartv
parents:
1093
diff
changeset
|
139 // script and taken care of automatically during loading. There |
|
9169038683a3
Replace use of brk() system call with linker script magic to obtain
bartv
parents:
1093
diff
changeset
|
140 // are no memory-mapped devices. Arguably the auxiliary should be |
|
9169038683a3
Replace use of brk() system call with linker script magic to obtain
bartv
parents:
1093
diff
changeset
|
141 // started up here, but instead that is left to platform |
|
9169038683a3
Replace use of brk() system call with linker script magic to obtain
bartv
parents:
1093
diff
changeset
|
142 // initialization. |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
143 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
144 // "Enable the cache". Effectively the synthetic target has no cache, |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
145 // anything provided by the hardware is not readily accessible. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
146 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
147 // "Set up the stack pointer". The system starts up a program with a |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
148 // suitable stack. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
149 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
150 // "Initialize any global pointer register". There is no such register. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
151 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
152 // Perform platform-specific initialization. Actually, all Linux |
|
332
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
153 // platforms can share this. It involves setting up signal handlers, |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
154 // starting the I/O auxiliary, and so on. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
155 synth_hardware_init(); |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
156 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
157 // This is not a ROM startup, so no need to worry about copying the |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
158 // .data section. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
159 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
160 // "Zero the .bss section". Linux will have done this for us. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
161 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
162 // "Create a suitable C stack frame". Already done. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
163 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
164 // Invoke the C++ constructors. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
165 cyg_hal_invoke_constructors(); |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
166 |
|
332
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
167 // Once the C++ constructors have been invoked, a second stage |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
168 // of hardware initialization is desirable. At this point all |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
169 // eCos device drivers should have been initialized so the |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
170 // I/O auxiliary will have loaded the appropriate support |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
171 // scripts, and the auxiliary can now map the window(s) on to |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
172 // the display and generally operate normally. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
173 synth_hardware_init2(); |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
210
diff
changeset
|
174 |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
175 // "Call cyg_start()". OK. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
176 cyg_start(); |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
177 |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
178 // "Drop into an infinite loop". Not a good idea for the synthetic |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
179 // target. Instead, exit. |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
180 cyg_hal_sys_exit(0); |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
181 } |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
182 |
|
448
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
183 // ---------------------------------------------------------------------------- |
|
1093
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
184 // Stub functions needed for linking with various versions of gcc |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
185 // configured for Linux rather than i386-elf. |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
186 |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
187 #if (__GNUC__ < 3) |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
188 // 2.95.x libgcc.a __pure_virtual() calls __write(). |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
189 int __write(void) |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
190 { |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
191 return -1; |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
192 } |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
193 #endif |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
194 |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
195 #if (__GNUC__ >= 3) |
|
448
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
196 // Versions of gcc/g++ after 3.0 (approx.), when configured for Linux |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
197 // native development (specifically, --with-__cxa_enable), have |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
198 // additional dependencies related to the destructors for static |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
199 // objects. When compiling C++ code with static objects the compiler |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
200 // inserts a call to __cxa_atexit() with __dso_handle as one of the |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
201 // arguments. __cxa_atexit() would normally be provided by glibc, and |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
202 // __dso_handle is part of crtstuff.c. Synthetic target applications |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
203 // are linked rather differently, so either a differently-configured |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
204 // compiler is needed or dummy versions of these symbols should be |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
205 // provided. If these symbols are not actually used then providing |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
206 // them is still harmless, linker garbage collection will remove them. |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
207 |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
208 void |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
209 __cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3) |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
210 { |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
211 } |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
212 void* __dso_handle = (void*) &__dso_handle; |
|
c3adb3b974a2
Update synthetic target to cope with recent gcc changes
bartv
parents:
332
diff
changeset
|
213 |
|
1093
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
214 // gcc 3.2.2 (approx). The libsupc++ version of the new operator pulls |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
215 // in exception handling code, even when using the nothrow version and |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
216 // building with -fno-exceptions. libgcc_eh.a provides the necessary |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
217 // functions, but requires a dl_iterate_phdr() function. That is related |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
218 // to handling dynamically loaded code so is not applicable to eCos. |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
219 int |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
220 dl_iterate_phdr(void* arg1, void* arg2) |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
221 { |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
222 return -1; |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
223 } |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
224 #endif |
|
c04ca65eec48
Try to resolve linking problems for C++ code built with the native
bartv
parents:
448
diff
changeset
|
225 |
| 2244 | 226 #if (__GNUC__ >= 4) |
| 227 // First noticed with gcc 4.1.1. There is now code to detect stack | |
| 228 // smashing. | |
| 229 void __attribute__ ((noreturn)) | |
| 230 __stack_chk_fail_local(void) | |
| 231 { | |
| 232 CYG_FAIL("Stack smashing detected, aborting"); | |
| 233 diag_printf("Application error: stack smashing detected.\n"); | |
| 234 cyg_hal_sys_exit(1); | |
| 235 for (;;); | |
| 236 } | |
|
2399
ca28b7d466b8
* src/synth_entry.c (__stack_chk_fail): another new function
asl
parents:
2244
diff
changeset
|
237 // Another symbol which indicates a similar problem occurred. |
|
ca28b7d466b8
* src/synth_entry.c (__stack_chk_fail): another new function
asl
parents:
2244
diff
changeset
|
238 void __stack_chk_fail(void) |
|
ca28b7d466b8
* src/synth_entry.c (__stack_chk_fail): another new function
asl
parents:
2244
diff
changeset
|
239 { |
|
ca28b7d466b8
* src/synth_entry.c (__stack_chk_fail): another new function
asl
parents:
2244
diff
changeset
|
240 __stack_chk_fail_local(); |
|
ca28b7d466b8
* src/synth_entry.c (__stack_chk_fail): another new function
asl
parents:
2244
diff
changeset
|
241 } |
| 2244 | 242 #endif |
| 243 | |
|
161
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
244 //----------------------------------------------------------------------------- |
|
ac086aa3217e
Merge from eCos master repository on 2001-06-08-21:11:51-BST
jlarmour
parents:
diff
changeset
|
245 // End of entry.c |
