summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sh/simsh4/start/start.S
blob: 3618cad5375f6214476b890e148338e5c727e487 (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
/*
 * start.S -- Initialization code for SH4 simulator BSP
 *
 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
 * Author: Victor V. Vengerov <vvv@oktet.ru>
 *
 * Based on work:
 *  Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and
 *           Bernd Becker (becker@faw.uni-ulm.de)
 *
 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *  Modified to reflect Hitachi EDK SH7045F:
 *  John M. Mills (jmills@tga.com)
 *  TGA Technologies, Inc.
 *  100 Pinnacle Way, Suite 140
 *  Norcross, GA 30071 U.S.A.
 *  
 *
 *  This modified file may be copied and distributed in accordance
 *  the above-referenced license. It is provided for critique and
 *  developmental purposes without any warranty nor representation
 *  by the authors or by TGA Technologies.
 *
 *  COPYRIGHT (c) 1999-2001.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  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 "asm.h"
#include "rtems/score/sh4_regs.h"

	BEGIN_CODE
	PUBLIC(start)

SYM (start):
        ! install the stack pointer
	mov.l	stack_k,r15

        mov.l   initial_sr_k,r0
        ldc     r0,ssr
        ldc     r0,sr

        ! Set up VBR register
        mov.l   _vbr_base_k,r0
        ldc     r0,vbr


#ifdef	START_HW_INIT	/* from $RTEMS_BSP.cfg */
	! Initialize minimal hardware
	mov.l	hw_init_k, r0
	jsr @r0
	nop		!dead slot
#endif /* START_HW_INIT */

	! zero out bss
	mov.l	edata_k,r0
	mov.l	end_k,r1
	mov	#0,r2
0:
	mov.l	r2,@r0
	add	#4,r0
	cmp/ge	r0,r1
	bt	0b

        ! initialise fpscr for gcc
        mov.l set_fpscr_k, r1
        jsr @r1
        nop

        ! Set FPSCR register
        mov.l   initial_fpscr_k,r0
        lds     r0,fpscr

	! call the mainline	
	mov #0,r4		! argc
	mov.l main_k,r0
	jsr @r0
	mov #0,r5		! argv - can place in dead slot

	! call exit
	mov	r0,r4
	mov.l	exit_k,r0
	jsr	@r0
	or	r0,r0

        ! stop the simulator
        trapa   #2
	nop

	.global	___trap34
___trap34:
	trapa	#34
!	tst	r1,r1	! r1 is errno
!	bt	ret
!	mov.l	perrno,r2
!	mov.l	r1,@r2
!ret:
	rts
	nop
	
!	.align	2
!perrno:
!	.long	_errno


	END_CODE

	.align 2
set_fpscr_k:
    .long   ___set_fpscr
_vbr_base_k:
        .long   SYM(_vbr_base)

stack_k:
	.long	SYM(stack)	
edata_k:
	.long	SYM(edata)
end_k:
	.long	SYM(end)
main_k:
	.long	SYM(boot_card)
exit_k:
	.long	SYM(exit)

#ifdef	START_HW_INIT	/* from $RTEMS_BSP.cfg */
hw_init_k:
	.long	SYM(early_hw_init)
#endif /* START_HW_INIT */

vects_k:
	.long	SYM(vectab)
vects_size:
	.word	255

    .align 2
initial_sr_k:
        .long   SH4_SR_MD | SH4_SR_RB | SH4_SR_IMASK
initial_fpscr_k:
#ifdef __SH4__
        .long   SH4_FPSCR_DN | SH4_FPSCR_PR | SH4_FPSCR_RM
#else
        .long   SH4_FPSCR_DN | SH4_FPSCR_RM
#endif

#ifdef __ELF__
	.section .stack,"aw"
#else
	.section .stack
#endif
SYM(stack):
	.long	0xdeaddead

#ifdef __ELF__
	.section .bss,"aw"
#else
	.section .bss
#endif

	.global __sh4sim_dummy_register
__sh4sim_dummy_register:
	.long	0