source: rtems/bsps/m68k/mcf52235/start/start.S @ 511dc4b

5
Last change on this file since 511dc4b was 511dc4b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/19/18 at 07:09:51

Rework initialization and interrupt stack support

Statically initialize the interrupt stack area
(_Configuration_Interrupt_stack_area_begin,
_Configuration_Interrupt_stack_area_end, and
_Configuration_Interrupt_stack_size) via <rtems/confdefs.h>. Place the
interrupt stack area in a special section ".rtemsstack.interrupt". Let
BSPs define the optimal placement of this section in their linker
command files (e.g. in a fast on-chip memory).

This change makes makes the CPU_HAS_SOFTWARE_INTERRUPT_STACK and
CPU_HAS_HARDWARE_INTERRUPT_STACK CPU port defines superfluous, since the
low level initialization code has all information available via global
symbols.

This change makes the CPU_ALLOCATE_INTERRUPT_STACK CPU port define
superfluous, since the interrupt stacks are allocated by confdefs.h for
all architectures. There is no need for BSP-specific linker command
file magic (except the section placement), see previous ARM linker
command file as a bad example.

Remove _CPU_Install_interrupt_stack(). Initialize the hardware
interrupt stack in _CPU_Initialize() if necessary (e.g.
m68k_install_interrupt_stack()).

The optional _CPU_Interrupt_stack_setup() is still useful to customize
the registration of the interrupt stack area in the per-CPU information.

The initialization stack can reuse the interrupt stack, since

  • interrupts are disabled during the sequential system initialization, and
  • the boot_card() function does not return.

This stack resuse saves memory.

Changes per architecture:

arm:

  • Mostly replace the linker symbol based configuration of stacks with the standard <rtems/confdefs.h> configuration via CONFIGURE_INTERRUPT_STACK_SIZE. The size of the FIQ, ABT and UND mode stack is still defined via linker symbols. These modes are rarely used in applications and the default values provided by the BSP should be sufficient in most cases.
  • Remove the bsp_processor_count linker symbol hack used for the SMP support. This is possible since the interrupt stack area is now allocated by the linker and not allocated from the heap. This makes some configure.ac stuff obsolete. Remove the now superfluous BSP variants altcycv_devkit_smp and realview_pbx_a9_qemu_smp.

bfin:

  • Remove unused magic linker command file allocation of initialization stack. Maybe a previous linker command file copy and paste problem? In the start.S the initialization stack is set to a hard coded value.

lm32, m32c, mips, nios2, riscv, sh, v850:

  • Remove magic linker command file allocation of initialization stack. Reuse interrupt stack for initialization stack.

m68k:

  • Remove magic linker command file allocation of initialization stack. Reuse interrupt stack for initialization stack.

powerpc:

  • Remove magic linker command file allocation of initialization stack. Reuse interrupt stack for initialization stack.
  • Used dedicated memory region (REGION_RTEMSSTACK) for the interrupt stack on BSPs using the shared linkcmds.base (replacement for REGION_RWEXTRA).

sparc:

  • Remove the hard coded initialization stack. Use the interrupt stack for the initialization stack on the boot processor. This saves 16KiB of RAM.

Update #3459.

  • Property mode set to 100644
File size: 12.6 KB
RevLine 
[3aac2db]1/*
2 *  mcf52235 startup code
3 *
4 *  This file contains the entry point for the application.
5 *  The name of this entry point is compiler dependent.
6 *  It jumps to the BSP which is responsible for performing
7 *  all initialization.
8 *
9 *  COPYRIGHT (c) 1989-1998.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[3aac2db]15 */
16
17#include <rtems/asm.h>
18
19BEGIN_CODE
[d4b4664b]20
[3aac2db]21    PUBLIC (_INTERRUPT_VECTOR)
22SYM(_INTERRUPT_VECTOR):
23
[511dc4b]24    .long   _Configuration_Interrupt_stack_area_end /* 00 Initial 'SSP' */
[3aac2db]25    .long   SYM(start) /* 01 Initial PC */
26    .long   SYM(_uhoh) /* 02 Access Error */
27    .long   SYM(_uhoh) /* 03 Address Error */
28    .long   SYM(_uhoh) /* 04 Illegal Instruction */
[9374e9b0]29    .long   SYM(_uhoh) /* 05 Divide by Zero */
[3aac2db]30    .long   SYM(_uhoh) /* 06 Reserved */
31    .long   SYM(_uhoh) /* 07 Reserved */
32    .long   SYM(_uhoh) /* 08 Privilege Violation */
33    .long   SYM(_uhoh) /* 09 Trace */
34    .long   SYM(_uhoh) /* 10 Unimplemented A-Line */
35    .long   SYM(_uhoh) /* 11 Unimplemented F-Line */
36    .long   SYM(_uhoh) /* 12 Debug Interrupt */
37    .long   SYM(_uhoh) /* 13 Reserved */
38    .long   SYM(_uhoh) /* 14 Format Error */
[9374e9b0]39    .long   SYM(_uhoh) /* 15 Reserved */
[3aac2db]40    .long   SYM(_uhoh) /* 16 Reserved */
41    .long   SYM(_uhoh) /* 17 Reserved */
42    .long   SYM(_uhoh) /* 18 Reserved */
43    .long   SYM(_uhoh) /* 19 Reserved */
44    .long   SYM(_uhoh) /* 20 Reserved */
45    .long   SYM(_uhoh) /* 21 Reserved */
46    .long   SYM(_uhoh) /* 22 Reserved */
47    .long   SYM(_uhoh) /* 23 Reserved */
48    .long   SYM(_spuriousInterrupt) /* 24 Spurious Interrupt */
[9374e9b0]49    .long   SYM(_uhoh) /* 25 Reserved */
50    .long   SYM(_uhoh) /* 26 Reserved */
51    .long   SYM(_uhoh) /* 27 Reserved */
52    .long   SYM(_uhoh) /* 28 Reserved */
53    .long   SYM(_uhoh) /* 29 Reserved */
54    .long   SYM(_uhoh) /* 30 Reserved */
55    .long   SYM(_uhoh) /* 31 Reserved */
[3aac2db]56    .long   SYM(_uhoh) /* 32 TRAP #0 */
57    .long   SYM(_uhoh) /* 33 TRAP #1 */
58    .long   SYM(_uhoh) /* 34 TRAP #2 */
59    .long   SYM(_uhoh) /* 35 TRAP #3 */
60    .long   SYM(_uhoh) /* 36 TRAP #4 */
61    .long   SYM(_uhoh) /* 37 TRAP #5 */
62    .long   SYM(_uhoh) /* 38 TRAP #6 */
63    .long   SYM(_uhoh) /* 39 TRAP #7 */
64    .long   SYM(_uhoh) /* 40 TRAP #8 */
65    .long   SYM(_uhoh) /* 41 TRAP #9 */
66    .long   SYM(_uhoh) /* 42 TRAP #10 */
67    .long   SYM(_uhoh) /* 43 TRAP #11 */
68    .long   SYM(_uhoh) /* 44 TRAP #12 */
69    .long   SYM(_uhoh) /* 45 TRAP #13 */
70    .long   SYM(_uhoh) /* 46 TRAP #14 */
71    .long   SYM(_uhoh) /* 47 TRAP #15 */
72    .long   SYM(_uhoh) /* 48 Reserved */
73    .long   SYM(_uhoh) /* 49 Reserved */
74    .long   SYM(_uhoh) /* 50 Reserved */
75    .long   SYM(_uhoh) /* 51 Reserved */
76    .long   SYM(_uhoh) /* 52 Reserved */
77    .long   SYM(_uhoh) /* 53 Reserved */
78    .long   SYM(_uhoh) /* 54 Reserved */
79    .long   SYM(_uhoh) /* 55 Reserved */
80    .long   SYM(_uhoh) /* 56 Reserved */
81    .long   SYM(_uhoh) /* 57 Reserved */
82    .long   SYM(_uhoh) /* 58 Reserved */
83    .long   SYM(_uhoh) /* 59 Reserved */
84    .long   SYM(_uhoh) /* 60 Reserved */
85    .long   SYM(_uhoh) /* 61 Reserved */
86    .long   SYM(_uhoh) /* 62 Reserved */
87    .long   SYM(_uhoh) /* 63 Reserved */
88
89    /* INTC0 */
90
91    .long   SYM(_uhoh) /* 64*/
92    .long   SYM(_uhoh) /* 65*/
93    .long   SYM(_uhoh) /* 66*/
94    .long   SYM(_uhoh) /* 67*/
95    .long   SYM(_uhoh) /* 68*/
96    .long   SYM(_uhoh) /* 69*/
97    .long   SYM(_uhoh) /* 70*/
98    .long   SYM(_uhoh) /* 71*/
99    .long   SYM(_uhoh) /* 72*/
100    .long   SYM(_uhoh) /* 73*/
101    .long   SYM(_uhoh) /* 74*/
102    .long   SYM(_uhoh) /* 75*/
103    .long   SYM(_uhoh) /* 76*/
104    .long   SYM(_uhoh) /* 77*/
105    .long   SYM(_uhoh) /* 78*/
106    .long   SYM(_uhoh) /* 79*/
107    .long   SYM(_uhoh) /* 80*/
108    .long   SYM(_uhoh) /* 81*/
109    .long   SYM(_uhoh) /* 82*/
110    .long   SYM(_uhoh) /* 83*/
111    .long   SYM(_uhoh) /* 84*/
112    .long   SYM(_uhoh) /* 85*/
113    .long   SYM(_uhoh) /* 86*/
114    .long   SYM(_uhoh) /* 87*/
115    .long   SYM(_uhoh) /* 88*/
116    .long   SYM(_uhoh) /* 89*/
117    .long   SYM(_uhoh) /* 90*/
118    .long   SYM(_uhoh) /* 91*/
119    .long   SYM(_uhoh) /* 92*/
120    .long   SYM(_uhoh) /* 93*/
121    .long   SYM(_uhoh) /* 94*/
122    .long   SYM(_uhoh) /* 95*/
123    .long   SYM(_uhoh) /* 96*/
124    .long   SYM(_uhoh) /* 97*/
125    .long   SYM(_uhoh) /* 98*/
126    .long   SYM(_uhoh) /* 99*/
127    .long   SYM(_uhoh) /* 100*/
128    .long   SYM(_uhoh) /* 101*/
129    .long   SYM(_uhoh) /* 102*/
130    .long   SYM(_uhoh) /* 103*/
131    .long   SYM(_uhoh) /* 104*/
132    .long   SYM(_uhoh) /* 105*/
133    .long   SYM(_uhoh) /* 106*/
134    .long   SYM(_uhoh) /* 107*/
135    .long   SYM(_uhoh) /* 108*/
136    .long   SYM(_uhoh) /* 109*/
137    .long   SYM(_uhoh) /* 110*/
138    .long   SYM(_uhoh) /* 111*/
139    .long   SYM(_uhoh) /* 112*/
140    .long   SYM(_uhoh) /* 113*/
141    .long   SYM(_uhoh) /* 114*/
142    .long   SYM(_uhoh) /* 115*/
143    .long   SYM(_uhoh) /* 116*/
144    .long   SYM(_uhoh) /* 117*/
145    .long   SYM(_uhoh) /* 118*/
146    .long   SYM(_uhoh) /* 119*/
147    .long   SYM(_uhoh) /* 120*/
148    .long   SYM(_uhoh) /* 121*/
149    .long   SYM(_uhoh) /* 122*/
150    .long   SYM(_uhoh) /* 123*/
151    .long   SYM(_uhoh) /* 124*/
152    .long   SYM(_uhoh) /* 125*/
153    .long   SYM(_uhoh) /* 126*/
154    .long   SYM(_uhoh) /* 127*/
155
156    /* INTC1 */
157
158    .long   SYM(_uhoh) /* 128*/
159    .long   SYM(_uhoh) /* 129*/
160    .long   SYM(_uhoh) /* 130*/
161    .long   SYM(_uhoh) /* 131*/
162    .long   SYM(_uhoh) /* 132*/
163    .long   SYM(_uhoh) /* 133*/
164    .long   SYM(_uhoh) /* 134*/
165    .long   SYM(_uhoh) /* 135*/
166    .long   SYM(_uhoh) /* 136*/
167    .long   SYM(_uhoh) /* 137*/
168    .long   SYM(_uhoh) /* 138*/
169    .long   SYM(_uhoh) /* 139*/
170    .long   SYM(_uhoh) /* 140*/
171    .long   SYM(_uhoh) /* 141*/
172    .long   SYM(_uhoh) /* 142*/
173    .long   SYM(_uhoh) /* 143*/
174    .long   SYM(_uhoh) /* 144*/
175    .long   SYM(_uhoh) /* 145*/
176    .long   SYM(_uhoh) /* 146*/
177    .long   SYM(_uhoh) /* 147*/
178    .long   SYM(_uhoh) /* 148*/
179    .long   SYM(_uhoh) /* 149*/
180    .long   SYM(_uhoh) /* 150*/
181    .long   SYM(_uhoh) /* 151*/
182    .long   SYM(_uhoh) /* 152*/
183    .long   SYM(_uhoh) /* 153*/
184    .long   SYM(_uhoh) /* 154*/
185    .long   SYM(_uhoh) /* 155*/
186    .long   SYM(_uhoh) /* 156*/
187    .long   SYM(_uhoh) /* 157*/
188    .long   SYM(_uhoh) /* 158*/
189    .long   SYM(_uhoh) /* 159*/
190    .long   SYM(_uhoh) /* 160*/
191    .long   SYM(_uhoh) /* 161*/
192    .long   SYM(_uhoh) /* 162*/
193    .long   SYM(_uhoh) /* 163*/
194    .long   SYM(_uhoh) /* 164*/
195    .long   SYM(_uhoh) /* 165*/
196    .long   SYM(_uhoh) /* 166*/
197    .long   SYM(_uhoh) /* 167*/
198    .long   SYM(_uhoh) /* 168*/
199    .long   SYM(_uhoh) /* 169*/
200    .long   SYM(_uhoh) /* 170*/
201    .long   SYM(_uhoh) /* 171*/
202    .long   SYM(_uhoh) /* 172*/
203    .long   SYM(_uhoh) /* 173*/
204    .long   SYM(_uhoh) /* 174*/
205    .long   SYM(_uhoh) /* 175*/
206    .long   SYM(_uhoh) /* 176*/
207    .long   SYM(_uhoh) /* 177*/
208    .long   SYM(_uhoh) /* 178*/
209    .long   SYM(_uhoh) /* 179*/
210    .long   SYM(_uhoh) /* 180*/
211    .long   SYM(_uhoh) /* 181*/
212    .long   SYM(_uhoh) /* 182*/
213    .long   SYM(_uhoh) /* 183*/
214    .long   SYM(_uhoh) /* 184*/
215    .long   SYM(_uhoh) /* 185*/
216    .long   SYM(_uhoh) /* 186*/
217    .long   SYM(_uhoh) /* 187*/
218    .long   SYM(_uhoh) /* 188*/
219    .long   SYM(_uhoh) /* 189*/
220    .long   SYM(_uhoh) /* 190*/
221    .long   SYM(_uhoh) /* 191*/
222    .long   SYM(_uhoh) /* 192*/
223
224    /* */
225
226    .long   SYM(_uhoh) /* 193*/
227    .long   SYM(_uhoh) /* 194*/
228    .long   SYM(_uhoh) /* 195*/
229    .long   SYM(_uhoh) /* 196*/
230    .long   SYM(_uhoh) /* 197*/
231    .long   SYM(_uhoh) /* 198*/
232    .long   SYM(_uhoh) /* 199*/
233    .long   SYM(_uhoh) /* 200*/
234    .long   SYM(_uhoh) /* 201*/
235    .long   SYM(_uhoh) /* 202*/
236    .long   SYM(_uhoh) /* 203*/
237    .long   SYM(_uhoh) /* 204*/
238    .long   SYM(_uhoh) /* 205*/
239    .long   SYM(_uhoh) /* 206*/
240    .long   SYM(_uhoh) /* 207*/
241    .long   SYM(_uhoh) /* 208*/
242    .long   SYM(_uhoh) /* 209*/
243    .long   SYM(_uhoh) /* 210*/
244    .long   SYM(_uhoh) /* 211*/
245    .long   SYM(_uhoh) /* 212*/
246    .long   SYM(_uhoh) /* 213*/
247    .long   SYM(_uhoh) /* 214*/
248    .long   SYM(_uhoh) /* 215*/
249    .long   SYM(_uhoh) /* 216*/
250    .long   SYM(_uhoh) /* 217*/
251    .long   SYM(_uhoh) /* 218*/
252    .long   SYM(_uhoh) /* 219*/
253    .long   SYM(_uhoh) /* 220*/
254    .long   SYM(_uhoh) /* 221*/
255    .long   SYM(_uhoh) /* 222*/
256    .long   SYM(_uhoh) /* 223*/
257    .long   SYM(_uhoh) /* 224*/
258    .long   SYM(_uhoh) /* 225*/
259    .long   SYM(_uhoh) /* 226*/
260    .long   SYM(_uhoh) /* 227*/
261    .long   SYM(_uhoh) /* 228*/
262    .long   SYM(_uhoh) /* 229*/
263    .long   SYM(_uhoh) /* 230*/
264    .long   SYM(_uhoh) /* 231*/
265    .long   SYM(_uhoh) /* 232*/
266    .long   SYM(_uhoh) /* 233*/
267    .long   SYM(_uhoh) /* 234*/
268    .long   SYM(_uhoh) /* 235*/
269    .long   SYM(_uhoh) /* 236*/
270    .long   SYM(_uhoh) /* 237*/
271    .long   SYM(_uhoh) /* 238*/
272    .long   SYM(_uhoh) /* 239*/
273    .long   SYM(_uhoh) /* 240*/
274    .long   SYM(_uhoh) /* 241*/
275    .long   SYM(_uhoh) /* 242*/
276    .long   SYM(_uhoh) /* 243*/
277    .long   SYM(_uhoh) /* 244*/
278    .long   SYM(_uhoh) /* 245*/
279    .long   SYM(_uhoh) /* 246*/
280    .long   SYM(_uhoh) /* 247*/
281    .long   SYM(_uhoh) /* 248*/
282    .long   SYM(_uhoh) /* 249*/
283    .long   SYM(_uhoh) /* 250*/
284    .long   SYM(_uhoh) /* 251*/
285    .long   SYM(_uhoh) /* 252*/
286    .long   SYM(_uhoh) /* 253*/
287    .long   SYM(_uhoh) /* 254*/
288    .long   SYM(_uhoh) /* 255*/
289
290/*
291 * We must write the flash configuration here.  This portion of flash is shadowed
292 * by some flash registers, so we can't put code here!
293 */
294
295    PUBLIC (_FLASH_CONFIGURATION_FIELD)
296SYM(_FLASH_CONFIGURATION_FIELD):
297
298_key_upper: .long   0x00000000
299_key_lower: .long   0x00000000
300_cfm_prot:  .long   0x00000000
301_cfm_sacc:  .long   0x00000000
302_cfm_dacc:  .long   0x00000000
303_cfm_msec:  .long   0x00000000
304
305/*
306 * Default trap handler
307 * With an oscilloscope you can see AS* stop
308 */
309.align 4
310    PUBLIC (_uhoh)
[d4b4664b]311SYM(_uhoh):
[3aac2db]312    nop                     | Leave spot for breakpoint
[d4b4664b]313    stop    #0x2700         | Stop with interrupts disabled
[3aac2db]314    bra.w   SYM(_uhoh)      | Stuck forever
315
[d4b4664b]316/*
[3aac2db]317 * Spurious Interrupt Handler
318 */
319.align 4
320    PUBLIC (_spuriousInterrupt)
321SYM(_spuriousInterrupt):
322    addql   #1, SYM(_M68kSpuriousInterruptCount)
323    rte
324
[d4b4664b]325/*
[3aac2db]326 * Write VBR Register
327 */
328.align 4
329    PUBLIC (_wr_vbr)
330SYM(_wr_vbr):
331    move.l  4(sp), d0
[d4b4664b]332    movec   d0, vbr
[3aac2db]333    nop
[d4b4664b]334    rts
[3aac2db]335
[d4b4664b]336/*
[3aac2db]337 * Board startup
338 * Disable watchdog, interrupts
339 * Enable sram
340 */
341.align 4
342    PUBLIC (start)
343SYM(start):
344
345    /* Mask off interupts */
346    move.w   #0x2700, sr
347
348    /* Save off reset values of D0 and D1 */
349    move.l  d0, d6
350    move.l  d1, d7
351
352    /* Initialize RAMBAR: locate SRAM and validate it */
[ec2ae9f]353    move.l  #RamBase, d0
[3aac2db]354    add.l   #0x21, d0
355    movec   d0, %rambar
356
[d4b4664b]357    /* Locate Stack Pointer */
[511dc4b]358    move.l  #_Configuration_Interrupt_stack_area_end, sp
[3aac2db]359
360    /* Initialize FLASHBAR */
361    move.l  #_FlashBase, d0
362    cmp.l   #0x00000000, d0
363    bne     _change_flashbar
364    add.l   #0x61, d0
365    movec   d0, %flashbar
366
367_continue_startup:
368
[d4b4664b]369    /* Locate Stack Pointer */
[511dc4b]370    move.l  #_Configuration_Interrupt_stack_area_end, sp
[3aac2db]371
372    /* Save off intial D0 and D1 to RAM */
373    move.l  d6, SYM(_d0_reset)
374    move.l  d7, SYM(_d1_reset)
375
376    /*
377     * Remainder of the startup code is handled by C code
378     * This never returns
379     */
380    jmp SYM(Init52235)
381
382_change_flashbar:
[d4b4664b]383    /*
384    * The following sequence is used to set FLASHBAR. Since we may
[3aac2db]385    * be executing from Flash, we must put the routine into SRAM for
386    * execution and then jump back to Flash using the new address.
387    *
388    * The following instructions are coded into the SRAM:
389    *
390    * move.l    #(__FLASH + 0x61),d0
391    * movec    d0, FLASHBAR
392    * jmp        _continue_startup
393    *
394    * An arbitrary SRAM address is chosen until the real address
395    * can be loaded.
396    *
397    * This routine is not necessary if the default Flash address
398    * (0x00000000) is used.
399    *
[d4b4664b]400    * If running in SRAM, change_flashbar should not be executed
[3aac2db]401    */
402
[ec2ae9f]403    move.l  #RamBase, a0
[3aac2db]404
405    /* Code "move.l #(__FLASH + 0x61),d0" into SRAM */
406    move.w  #0x203C, d0
407    move.w  d0, (a0)+
408    move.l  #_FlashBase, d0
409    add.l   #0x61, d0
410    move.l  d0, (a0)+
411
412    /* Code "movec d0,FLASHBAR" into SRAM */
413    move.l  #0x4e7b0C04, d0
414    move.l  d0, (a0)+
415
416    /* Code "jmp _continue_startup" into SRAM */
417    move.w  #0x4EF9, d0
418    move.w  d0, (a0)+
419    move.l  #_continue_startup, d0
420    move.l  d0, (a0)+
421
422    /* Jump to code segment in internal SRAM */
[ec2ae9f]423    jmp     RamBase
[3aac2db]424
425END_CODE
426
427
428BEGIN_DATA_DCL
429
430    .align 4
431
432PUBLIC (_M68kSpuriousInterruptCount)
433SYM (_M68kSpuriousInterruptCount):
434    .long   0
435
436PUBLIC (_d0_reset)
437SYM (_d0_reset):
438    .long   0
439
440PUBLIC (_d1_reset)
441SYM (_d1_reset):
442    .long   0
443
444END_DATA_DCL
445
446END
447
Note: See TracBrowser for help on using the repository browser.