source: rtems/bsps/m68k/gen68360/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: 10.0 KB
Line 
1/*
2 *
3 *  This file contains the entry point for the application.
4 *  It jumps to the BSP which is responsible for performing
5 *  all initialization.
6 *
7 *  COPYRIGHT (c) 1989-1999.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may in
11 *  the file LICENSE in this distribution or at
12 *  http://www.rtems.org/license/LICENSE.
13 *
14 * Based on the `gen68302' board support package, and covered by the
15 * original distribution terms.
16 *
17 * W. Eric Norum
18 * Saskatchewan Accelerator Laboratory
19 * University of Saskatchewan
20 * Saskatoon, Saskatchewan, CANADA
21 * eric@skatter.usask.ca
22 */
23
24#include <rtems/asm.h>
25
26BEGIN_CODE
27        /*
28         * Step 1: Decide on Reset Stack Pointer and Initial Program Counter
29         */
30Entry:
31        .long   m360+1024               |   0: Initial SSP
32        .long   start                   |   1: Initial PC
33        .long   _uhoh                   |   2: Bus error
34        .long   _uhoh                   |   3: Address error
35        .long   _uhoh                   |   4: Illegal instruction
36        .long   _uhoh                   |   5: Zero division
37        .long   _uhoh                   |   6: CHK, CHK2 instruction
38        .long   _uhoh                   |   7: TRAPcc, TRAPV instructions
39        .long   _uhoh                   |   8: Privilege violation
40        .long   _uhoh                   |   9: Trace
41        .long   _uhoh                   |  10: Line 1010 emulator
42        .long   _uhoh                   |  11: Line 1111 emulator
43        .long   _uhoh                   |  12: Hardware breakpoint
44        .long   _uhoh                   |  13: Reserved for coprocessor violation
45        .long   _uhoh                   |  14: Format error
46        .long   _uhoh                   |  15: Uninitialized interrupt
47        .long   _uhoh                   |  16: Unassigned, reserved
48        .long   _uhoh                   |  17:
49        .long   _uhoh                   |  18:
50        .long   _uhoh                   |  19:
51        .long   _uhoh                   |  20:
52        .long   _uhoh                   |  21:
53        .long   _uhoh                   |  22:
54        .long   _uhoh                   |  23:
55        .long   _spuriousInterrupt      |  24: Spurious interrupt
56        .long   _uhoh                   |  25: Level 1 interrupt autovector
57        .long   _uhoh                   |  26: Level 2 interrupt autovector
58        .long   _uhoh                   |  27: Level 3 interrupt autovector
59        .long   _uhoh                   |  28: Level 4 interrupt autovector
60        .long   _uhoh                   |  29: Level 5 interrupt autovector
61        .long   _uhoh                   |  30: Level 6 interrupt autovector
62        .long   _uhoh                   |  31: Level 7 interrupt autovector
63        .long   _uhoh                   |  32: Trap instruction (0-15)
64        .long   _uhoh                   |  33:
65        .long   _uhoh                   |  34:
66        .long   _uhoh                   |  35:
67        .long   _uhoh                   |  36:
68        .long   _uhoh                   |  37:
69        .long   _uhoh                   |  38:
70        .long   _uhoh                   |  39:
71        .long   _uhoh                   |  40:
72        .long   _uhoh                   |  41:
73        .long   _uhoh                   |  42:
74        .long   _uhoh                   |  43:
75        .long   _uhoh                   |  44:
76        .long   _uhoh                   |  45:
77        .long   _uhoh                   |  46:
78        .long   _uhoh                   |  47:
79        .long   _uhoh                   |  48: Reserved for coprocessor
80        .long   _uhoh                   |  49:
81        .long   _uhoh                   |  50:
82        .long   _uhoh                   |  51:
83        .long   _uhoh                   |  52:
84        .long   _uhoh                   |  53:
85        .long   _uhoh                   |  54:
86        .long   _uhoh                   |  55:
87        .long   _uhoh                   |  56:
88        .long   _uhoh                   |  57:
89        .long   _uhoh                   |  58:
90        .long   _uhoh                   |  59: Unassigned, reserved
91        .long   _uhoh                   |  60:
92        .long   _uhoh                   |  61:
93        .long   _uhoh                   |  62:
94        .long   _uhoh                   |  63:
95        .long   _uhoh                   |  64: User defined vectors (192)
96        .long   _uhoh                   |  65:
97        .long   _uhoh                   |  66:
98        .long   _uhoh                   |  67:
99        .long   _uhoh                   |  68:
100        .long   _uhoh                   |  69:
101        .long   _uhoh                   |  70:
102        .long   _uhoh                   |  71:
103        .long   _uhoh                   |  72:
104        .long   _uhoh                   |  73:
105        .long   _uhoh                   |  74:
106        .long   _uhoh                   |  75:
107        .long   _uhoh                   |  76:
108        .long   _uhoh                   |  77:
109        .long   _uhoh                   |  78:
110        .long   _uhoh                   |  79:
111        .long   _uhoh                   |  80:
112        .long   _uhoh                   |  81:
113        .long   _uhoh                   |  82:
114        .long   _uhoh                   |  83:
115        .long   _uhoh                   |  84:
116        .long   _uhoh                   |  85:
117        .long   _uhoh                   |  86:
118        .long   _uhoh                   |  87:
119        .long   _uhoh                   |  88:
120        .long   _uhoh                   |  89:
121        .long   _uhoh                   |  90:
122        .long   _uhoh                   |  91:
123        .long   _uhoh                   |  92:
124        .long   _uhoh                   |  93:
125        .long   _uhoh                   |  94:
126        .long   _uhoh                   |  95:
127        .long   _uhoh                   |  96:
128        .long   _uhoh                   |  97:
129        .long   _uhoh                   |  98:
130        .long   _uhoh                   |  99:
131        .long   _uhoh                   | 100:
132        .long   _uhoh                   | 101:
133        .long   _uhoh                   | 102:
134        .long   _uhoh                   | 103:
135        .long   _uhoh                   | 104:
136        .long   _uhoh                   | 105:
137        .long   _uhoh                   | 106:
138        .long   _uhoh                   | 107:
139        .long   _uhoh                   | 108:
140        .long   _uhoh                   | 109:
141        .long   _uhoh                   | 110:
142        .long   _uhoh                   | 111:
143        .long   _uhoh                   | 112:
144        .long   _uhoh                   | 113:
145        .long   _uhoh                   | 114:
146        .long   _uhoh                   | 115:
147        .long   _uhoh                   | 116:
148        .long   _uhoh                   | 117:
149        .long   _uhoh                   | 118:
150        .long   _uhoh                   | 119:
151        .long   _uhoh                   | 120:
152        .long   _uhoh                   | 121:
153        .long   _uhoh                   | 122:
154        .long   _uhoh                   | 123:
155        .long   _uhoh                   | 124:
156        .long   _uhoh                   | 125:
157        .long   _uhoh                   | 126:
158        .long   _uhoh                   | 127:
159        .long   _uhoh                   | 128:
160        .long   _uhoh                   | 129:
161        .long   _uhoh                   | 130:
162        .long   _uhoh                   | 131:
163        .long   _uhoh                   | 132:
164        .long   _uhoh                   | 133:
165        .long   _uhoh                   | 134:
166        .long   _uhoh                   | 135:
167        .long   _uhoh                   | 136:
168        .long   _uhoh                   | 137:
169        .long   _uhoh                   | 138:
170        .long   _uhoh                   | 139:
171        .long   _uhoh                   | 140:
172        .long   _uhoh                   | 141:
173        .long   _uhoh                   | 142:
174        .long   _uhoh                   | 143:
175        .long   _uhoh                   | 144:
176        .long   _uhoh                   | 145:
177        .long   _uhoh                   | 146:
178        .long   _uhoh                   | 147:
179        .long   _uhoh                   | 148:
180        .long   _uhoh                   | 149:
181        .long   _uhoh                   | 150:
182        .long   _uhoh                   | 151:
183        .long   _uhoh                   | 152:
184        .long   _uhoh                   | 153:
185        .long   _uhoh                   | 154:
186        .long   _uhoh                   | 155:
187        .long   _uhoh                   | 156:
188        .long   _uhoh                   | 157:
189        .long   _uhoh                   | 158:
190        .long   _uhoh                   | 159:
191        .long   _uhoh                   | 160:
192        .long   _uhoh                   | 161:
193        .long   _uhoh                   | 162:
194        .long   _uhoh                   | 163:
195        .long   _uhoh                   | 164:
196        .long   _uhoh                   | 165:
197        .long   _uhoh                   | 166:
198        .long   _uhoh                   | 167:
199        .long   _uhoh                   | 168:
200        .long   _uhoh                   | 169:
201        .long   _uhoh                   | 170:
202        .long   _uhoh                   | 171:
203        .long   _uhoh                   | 172:
204        .long   _uhoh                   | 173:
205        .long   _uhoh                   | 174:
206        .long   _uhoh                   | 175:
207        .long   _uhoh                   | 176:
208        .long   _uhoh                   | 177:
209        .long   _uhoh                   | 178:
210        .long   _uhoh                   | 179:
211        .long   _uhoh                   | 180:
212        .long   _uhoh                   | 181:
213        .long   _uhoh                   | 182:
214        .long   _uhoh                   | 183:
215        .long   _uhoh                   | 184:
216        .long   _uhoh                   | 185:
217        .long   _uhoh                   | 186:
218        .long   _uhoh                   | 187:
219        .long   _uhoh                   | 188:
220        .long   _uhoh                   | 189:
221        .long   _uhoh                   | 190:
222        .long   _uhoh                   | 191:
223        .long   _uhoh                   | 192:
224        .long   _uhoh                   | 193:
225        .long   _uhoh                   | 194:
226        .long   _uhoh                   | 195:
227        .long   _uhoh                   | 196:
228        .long   _uhoh                   | 197:
229        .long   _uhoh                   | 198:
230        .long   _uhoh                   | 199:
231        .long   _uhoh                   | 200:
232        .long   _uhoh                   | 201:
233        .long   _uhoh                   | 202:
234        .long   _uhoh                   | 203:
235        .long   _uhoh                   | 204:
236        .long   _uhoh                   | 205:
237        .long   _uhoh                   | 206:
238        .long   _uhoh                   | 207:
239        .long   _uhoh                   | 208:
240        .long   _uhoh                   | 209:
241        .long   _uhoh                   | 210:
242        .long   _uhoh                   | 211:
243        .long   _uhoh                   | 212:
244        .long   _uhoh                   | 213:
245        .long   _uhoh                   | 214:
246        .long   _uhoh                   | 215:
247        .long   _uhoh                   | 216:
248        .long   _uhoh                   | 217:
249        .long   _uhoh                   | 218:
250        .long   _uhoh                   | 219:
251        .long   _uhoh                   | 220:
252        .long   _uhoh                   | 221:
253        .long   _uhoh                   | 222:
254        .long   _uhoh                   | 223:
255        .long   _uhoh                   | 224:
256        .long   _uhoh                   | 225:
257        .long   _uhoh                   | 226:
258        .long   _uhoh                   | 227:
259        .long   _uhoh                   | 228:
260        .long   _uhoh                   | 229:
261        .long   _uhoh                   | 230:
262        .long   _uhoh                   | 231:
263        .long   _uhoh                   | 232:
264        .long   _uhoh                   | 233:
265        .long   _uhoh                   | 234:
266        .long   _uhoh                   | 235:
267        .long   _uhoh                   | 236:
268        .long   _uhoh                   | 237:
269        .long   _uhoh                   | 238:
270        .long   _uhoh                   | 239:
271        .long   _uhoh                   | 240:
272        .long   _uhoh                   | 241:
273        .long   _uhoh                   | 242:
274        .long   _uhoh                   | 243:
275        .long   _uhoh                   | 244:
276        .long   _uhoh                   | 245:
277        .long   _uhoh                   | 246:
278        .long   _uhoh                   | 247:
279        .long   _uhoh                   | 248:
280        .long   _uhoh                   | 249:
281        .long   _uhoh                   | 250:
282        .long   _uhoh                   | 251:
283        .long   _uhoh                   | 252:
284        .long   _uhoh                   | 253:
285        .long   _uhoh                   | 254:
286        .long   _uhoh                   | 255:
287
288/*
289 * Default trap handler
290 * With an oscilloscope you can see AS* stop
291 */
292        PUBLIC (_uhoh)
293_uhoh:  nop                             | Leave spot for breakpoint
294        stop    #0x2700                 | Stop with interrupts disabled
295        bra.l   _uhoh                   | Stuck forever
296
297/*
298 * Log, but otherwise ignore, spurious interrupts
299 */
300        PUBLIC (_spuriousInterrupt)
301_spuriousInterrupt:
302        addql   #1,_M68kSpuriousInterruptCount
303        rte
304
305/*
306 * Place the low-order 3 octets of the board's ethernet address at
307 * a `well-known' fixed location relative to the startup location.
308 */
309        .align 2
310        .word   0                       | Padding
311ethernet_address_buffer:
312        .word   0x08F3                  | Default address
313        .word   0xDEAD
314        .word   0xCAFE
315
316/*
317 * Initial PC
318 */
319.globl start
320start:
321        /*
322         * Step 2: Stay in Supervisor Mode
323         */
324#if ( M68K_HAS_SEPARATE_STACKS == 1 )
325        oriw    #0x3000,sr              | Switch to Master Stack Pointer
326        lea     SYM(m360)+1024-64,a7    | Put stack in dual-port ram
327                                        | a little below the interrupt stack
328#endif
329
330        /*
331         * Step 3: Write the VBR
332         */
333        lea     Entry,a0                | Get base of vector table
334        movec   a0,vbr                  | Set up the VBR
335
336        /*
337         * Step 4: Write the MBAR
338         */
339        movec   dfc,d1                  | Save destination register
340        moveq   #7,d0                   | CPU-space funcction code
341        movec   d0,dfc                  | Set destination function code register
342        movel   #m360+0x101,d0          | MBAR value (mask CPU space accesses)
343        movesl  d0,0x3FF00              | Set MBAR
344        movec   d1,dfc                  | Restore destination register
345
346        /*
347         * Step 5: Verify a dual-port RAM location
348         */
349        lea     m360,a0                 | Point a0 to first DPRAM location
350        moveb   #0x33,d0                | Set the test value
351        moveb   d0,a0@                  | Set the memory location
352        cmpb    a0@,d0                  | Does it read back?
353        bne     _uhoh                   | If not, bad news!
354        notb    d0                      | Flip bits
355        moveb   d0,a0@                  | Set the memory location
356        cmpb    a0@,d0                  | Does it read back?
357        bne     _uhoh                   | If not, bad news!
358
359        /*
360         * Remaining steps are handled by C code
361         */
362        jmp     _Init68360              | Start C code (which never returns)
363
364/*
365 * Copy DATA segment, clear BSS segment, set up real stack, start C program.
366 * Assume that DATA and BSS sizes are multiples of 4.
367 */
368        PUBLIC (_CopyDataClearBSSAndStart)
369_CopyDataClearBSSAndStart:
370        lea     _copy_start,a0          | Get start of DATA in RAM
371        lea     etext,a2                | Get start of DATA in ROM
372        cmpl    a0,a2                   | Are they the same?
373        beq.s   NOCOPY                  | Yes, no copy necessary
374        lea     _copy_end,a1            | Get end of DATA in RAM
375        bra.s   COPYLOOPTEST            | Branch into copy loop
376COPYLOOP:
377        movel   a2@+,a0@+               | Copy word from ROM to RAM
378COPYLOOPTEST:
379        cmpl    a1,a0                   | Done?
380        bcs.s   COPYLOOP                | No, skip
381NOCOPY:
382
383        lea     _clear_start,a0         | Get start of BSS
384        lea     _clear_end,a1           | Get end of BSS
385        clrl    d0                      | Value to set
386        bra.s   ZEROLOOPTEST            | Branch into clear loop
387ZEROLOOP:
388        movel   d0,a0@+                 | Clear a word
389ZEROLOOPTEST:
390        cmpl    a1,a0                   | Done?
391        bcs.s   ZEROLOOP                | No, skip
392
393        movel   #_Configuration_Interrupt_stack_area_end,a7 | set master stack pointer
394        movel   d0,a7@-                 | command line
395        jsr     boot_card               | Call C main
396
397        PUBLIC (_mainDone)
398_mainDone:
399        nop                             | Leave spot for breakpoint
400        movew   #1,a7                   | Force a double bus error
401        movel   d0,a7@-                 | This should cause a RESET
402        stop    #0x2700                 | Stop with interrupts disabled
403        bra.l   _mainDone               | Stuck forever
404
405        .align 2
406END_CODE
407
408BEGIN_DATA_DCL
409        .align 2
410        PUBLIC (environ)
411environ:
412        .long   0
413        PUBLIC (_M68kSpuriousInterruptCount)
414_M68kSpuriousInterruptCount:
415        .long   0
416END_DATA_DCL
417
418END
Note: See TracBrowser for help on using the repository browser.