summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/csb360/start/start.S
blob: c89e04985fc65facd57e63521887125c3e95c526 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/*
 *  CSB360 startup code
 *
 *  This file contains the entry point for the application.
 *  The name of this entry point is compiler dependent.
 *  It jumps to the BSP which is responsible for performing
 *  all initialization.
 *
 *  Copyright (C) 2004 Cogent Computer Systems
 *  Author: Jay Monkman <jtm@lopingdog.com>
 *
 *  Based on start.S from mcf520elite BSP:
 *    Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
 *    Author: Victor V. Vengerov <vvv@oktet.ru>
 *	
 *  Based on work:
 *    David Fiddes, D.J@fiddes.surfaid.org
 *    http://www.calm.hw.ac.uk/davidf/coldfire/
 *
 *  COPYRIGHT (c) 1989-1998.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright assigned to U.S. Government, 1994.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#include <rtems/asm.h>
#include <bsp.h>

BEGIN_CODE

/* Initial stack situated in on-chip static memory */
#define INITIAL_STACK BSP_MEM_ADDR_SRAM+BSP_MEM_SIZE_SRAM-4

	PUBLIC	(INTERRUPT_VECTOR)
SYM(INTERRUPT_VECTOR):
	.long   INITIAL_STACK		| 00: initial SSP
	.long	start			| 01: Initial PC
	.long	_unexp_exception	| 02: Access Error
	.long	_unexp_exception	| 03: Address Error
	.long	_unexp_exception	| 04: Illegal Instruction
	.long	_reserved_int		| 05: Reserved
	.long	_reserved_int		| 06: Reserved
	.long	_reserved_int		| 07: Reserved
	.long	_unexp_exception	| 08: Priveledge Violation
	.long	_unexp_exception	| 09: Trace
	.long	_unexp_exception	| 0A: Unimplemented A-Line
	.long	_unexp_exception	| 0B: Unimplemented F-Line
	.long	_unexp_exception	| 0C: Debug interrupt
	.long	_reserved_int		| 0D: Reserved
	.long	_unexp_exception	| 0E: Format error
	.long	_unexp_exception	| 0F: Uninitialized interrupt
	.long	_reserved_int		| 10: Reserved
	.long	_reserved_int		| 11: Reserved
	.long	_reserved_int		| 12: Reserved
	.long	_reserved_int		| 13: Reserved
	.long	_reserved_int		| 14: Reserved
	.long	_reserved_int		| 15: Reserved
	.long	_reserved_int		| 16: Reserved
	.long	_reserved_int		| 17: Reserved
	.long	_spurious_int		| 18: Spurious interrupt
	.long	_avec1_int		| 19: Autovector Level 1
	.long	_avec2_int		| 1A: Autovector Level 2
	.long	_avec3_int		| 1B: Autovector Level 3
	.long	_avec4_int		| 1C: Autovector Level 4
	.long	_avec5_int		| 1D: Autovector Level 5
	.long	_avec6_int		| 1E: Autovector Level 6
	.long	_avec7_int		| 1F: Autovector Level 7
	.long	_unexp_exception	| 20: TRAP #0
	.long	_unexp_exception	| 21: TRAP #1
	.long	_unexp_exception	| 22: TRAP #2
	.long	_unexp_exception	| 23: TRAP #3
	.long	_unexp_exception	| 24: TRAP #4
	.long	_unexp_exception	| 25: TRAP #5
	.long	_unexp_exception	| 26: TRAP #6
	.long	_unexp_exception	| 27: TRAP #7
	.long	_unexp_exception	| 28: TRAP #8
	.long	_unexp_exception	| 29: TRAP #9
	.long	_unexp_exception	| 2A: TRAP #10
	.long	_unexp_exception	| 2B: TRAP #11
	.long	_unexp_exception	| 2C: TRAP #12
	.long	_unexp_exception	| 2D: TRAP #13
	.long	_unexp_exception	| 2E: TRAP #14
	.long	_unexp_exception	| 2F: TRAP #15
	.long	_reserved_int		| 30: Reserved
	.long	_reserved_int		| 31: Reserved
	.long	_reserved_int		| 32: Reserved
	.long	_reserved_int		| 33: Reserved
	.long	_reserved_int		| 34: Reserved
	.long	_reserved_int		| 35: Reserved
	.long	_reserved_int		| 36: Reserved
	.long	_reserved_int		| 37: Reserved
	.long	_reserved_int		| 38: Reserved
	.long	_reserved_int		| 39: Reserved
	.long	_reserved_int		| 3A: Reserved
	.long	_reserved_int		| 3B: Reserved
	.long	_reserved_int		| 3C: Reserved
	.long	_reserved_int		| 3D: Reserved
	.long	_reserved_int		| 3E: Reserved
	.long	_reserved_int		| 3F: Reserved

	.long	_unexp_int		| 40-FF: User defined interrupts
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| 50:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| 60:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| 70:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| 80:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| 90:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| A0:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| B0:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| C0:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| D0:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| E0:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	.long	_unexp_int		| F0:
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int
	.long	_unexp_int

	PUBLIC(start)
SYM(start):
	move.w	#0x2700,sr		| First turn off all interrupts!

	move.l	#(BSP_RAMBAR + MCF5272_RAMBAR_V), d0
	movec	d0,rambar0		| ...so we have a stack

	move.l	#(INITIAL_STACK),sp	| Set up stack again (may be we are
					| going here from monitor or with
					| BDM interface assistance)
	
	/*
	 * Remainder of the startup code is handled by C code
	 */
	jmp	SYM(init5272)		| Start C code (which never returns)

/***************************************************************************
   Function : clear_bss

   Description : clear BSS segment
 ***************************************************************************/
	PUBLIC (clear_bss)
SYM(clear_bss):
	lea	clear_start,a0		| Get start of BSS
	lea	clear_end,a1		| Get end of BSS
	clrl	d0			| Value to set
	bra.s	ZEROLOOPTEST		| Branch into clear loop
ZEROLOOP:
	movel	d0,a0@+			| Clear a word
ZEROLOOPTEST:
	cmpl	a1,a0			| Done?
	bcs.s	ZEROLOOP		| No, skip

	rts




	PUBLIC (start_csb360)
SYM(start_csb360):
	/*
	 * Right : Now we're ready to boot RTEMS
	 */
	clrl	d0			| Pass in null to all boot_card() params
 	movel	d0,a7@-			| environp
	movel	d0,a7@-			| argv
	movel	d0,a7@-			| argc
	jsr	SYM(boot_card)		| Call C boot_card function to startup RTEMS


	
# Wait forever
_stop:
	nop
	stop	#0x2700
	jmp	_stop

# The following labelled nops is a placeholders for breakpoints
_unexp_exception:
	nop
	jmp	_stop

_unexp_int:
	nop
	jmp	_stop

_reserved_int:
	nop
	jmp	_stop

_spurious_int:
	nop
	jmp	_stop

_avec1_int:
	nop
	jmp	_unexp_int

_avec2_int:
	nop
	jmp	_unexp_int

_avec3_int:
	nop
	jmp	_unexp_int 

_avec4_int:
	nop
	jmp	_unexp_int

_avec5_int:
	nop
	jmp	_unexp_int

_avec6_int:
	nop
	jmp	_unexp_int

_avec7_int:
	nop
	jmp	_unexp_int


END_CODE

END