Statistics
| Revision:

root / branch / belin / Emb_App / crt0mr.a30 @ 495

History | View | Annotate | Download (7.86 KB)

1
; ****************************************************************
2
;                                                                 
3
;	MR308 start up program for C language                     
4
;	COPYRIGHT(C) 2003 RENESAS TECHNOLOGY CORPORATION 
5
;	AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED
6
;	MR308 V.1.10 Release 1
7
;                                                                 
8
; ****************************************************************
9
;	"$Id: crt0mr.a30 318 2006-07-26 07:54:55Z inui $"
10
;*A1* 2005-02-28 for ES
11
;
12
	.LIST	OFF
13
	.INCLUDE	c_sec.inc
14
	.INCLUDE	mr308.inc
15
	.INCLUDE	sys_rom.inc
16
	.INCLUDE	sys_ram.inc
17
	.LIST	ON
18

    
19
	.GLB	__SYS_INITIAL
20
	.GLB	__END_INIT
21
	.GLB	__init_sys,__init_tsk
22

    
23
	.IF		M16C70!=0
24
regoffset	.EQU	-0220H
25
	.ELSE
26
regoffset	.EQU	0
27
	.ENDIF
28

    
29
;-----------------------------------------------------------------
30
; SBDATA area definition
31
;-----------------------------------------------------------------
32
	.GLB	__SB__
33
	.SB	__SB__
34

    
35
;=================================================================
36
; Initialize Macro declaration
37
;-----------------------------------------------------------------
38
N_BZERO	.MACRO	TOP_,SECT_
39
	MOV.B	#00H, R0L
40
	MOV.L	#TOP_, A1
41
	MOV.W	#sizeof SECT_, R3
42
	SSTR.B
43
	.ENDM
44

    
45
N_BCOPY .MACRO	FROM_,TO_,SECT_
46
	MOV.L	#FROM_,A0
47
	MOV.L	#TO_,A1
48
	MOV.W	#sizeof SECT_, R3
49
	SMOVF.B
50
	.ENDM
51

    
52
BZERO	.MACRO	TOP_,SECT_
53
	.local	_end, _loop
54

    
55
	MOV.L	#TOP_, A1
56
	MOV.B	#00H, R0L
57
	MOV.L	#(sizeof SECT_ & 0FFFFFFH), R3R1
58
	XCHG.W	R1,R3
59
_loop:
60
	SSTR.B
61
	CMP.W	#0,R1
62
	JEQ	_end
63
	MOV.B	R0L,[A1]
64
	ADD.L	#1,A1
65
	MOV.W	#0FFFFH,R3
66
	SUB.W	#1,R1
67
	JMP	_loop	
68
_end:
69
	.ENDM
70

    
71
BCOPY	.MACRO	FROM_,TO_,SECT_
72
	.local	_end, _loop
73

    
74
	MOV.L	#FROM_,A0
75
	MOV.L	#TO_,A1
76
	MOV.L	#(sizeof SECT_ & 0FFFFFFH), R3R1
77
	XCHG.W	R1,R3
78
_loop:
79
	SMOVF.B
80
	CMP.W	#0,R1
81
	JEQ	_end
82
	MOV.B	[A0],[A1]
83
	ADD.L	#1,A1
84
	ADD.L	#1,A0
85
	MOV.W	#0FFFFH,R3
86
	SUB.W	#1,R1
87
	JMP	_loop	
88
_end:
89
	.ENDM
90

    
91
;=================================================================
92
; Interrupt section start
93
;-----------------------------------------------------------------
94
	.SECTION	MR_KERNEL,CODE,ALIGN
95

    
96
;-----------------------------------------------------------------
97
; after reset,this program will start
98
;-----------------------------------------------------------------
99
__SYS_INITIAL:
100
;	LDC	#__Sys_Sp,ISP	; set initial ISP
101

    
102
;	MOV.B	#2,0AH
103
	MOV.B	#00,PMOD		; Set Processor Mode Register
104
	MOV.B	#0,0AH
105
	LDC	#0010H,FLG
106
	LDC	#__SB__,SB
107
	LDC	#0000H,FLG
108
	LDC	#__Sys_Sp,FB
109
	LDC	#__SB__,SB
110

    
111
; +-----------------------------------------------------+
112
; |     ISSUE SYSTEM CALL DATA INITIALIZE               |
113
; +-----------------------------------------------------+
114
	; For PD308
115
	__INIT_ISSUE_SYSCALL
116

    
117
;=================================================================
118
; MR_RAM zero clear
119
;--------------------------------------------------------
120
	N_BZERO	MR_RAM_NE_top,MR_RAM_NE
121
	N_BZERO	MR_RAM_NO_top,MR_RAM_NO
122
	BZERO	MR_RAM_top,MR_RAM
123

    
124
;=================================================================
125
; NEAR area initialize.
126
;--------------------------------------------------------
127
; bss zero clear
128
;--------------------------------------------------------
129
	N_BZERO	bss_SE_top,bss_SE
130
	N_BZERO	bss_SO_top,bss_SO
131

    
132
	N_BZERO	bss_NE_top,bss_NE
133
	N_BZERO	bss_NO_top,bss_NO
134

    
135
;--------------------------------------------------------
136
; initialize data section
137
;--------------------------------------------------------
138
	N_BCOPY data_SEI_top,data_SE_top,data_SE
139
	N_BCOPY	data_SOI_top,data_SO_top,data_SO
140
	N_BCOPY	data_NEI_top,data_NE_top,data_NE
141
	N_BCOPY	data_NOI_top,data_NO_top,data_NO
142

    
143
;=================================================================
144
; FAR area initialize.
145
;--------------------------------------------------------
146
; bss zero clear
147
;--------------------------------------------------------
148
	BZERO	bss_FE_top,bss_FE
149
	BZERO	bss_FO_top,bss_FO
150

    
151
;--------------------------------------------------------
152
; Copy edata_E(O) section from edata_EI(OI) section
153
;--------------------------------------------------------
154
	BCOPY	data_FEI_top,data_FE_top,data_FE
155
	BCOPY	data_FOI_top,data_FO_top,data_FO
156

    
157
	LDC	#__Sys_Sp,SP
158
	LDC	#__Sys_Sp,FB
159

    
160

    
161
;-----------------------------------------------------------------
162
; Set System IPL and Set Interrupt Vector
163
;-----------------------------------------------------------------
164
	MOV.B	#0,R0L
165
	MOV.B	#__SYS_IPL,R0H
166
	LDC	R0,FLG
167
	LDC	#__INT_VECTOR,INTB
168

    
169
; +-----------------------------------------------------+
170
; |     System timer interrupt setting                  |
171
; +-----------------------------------------------------+
172
    .IF	USE_TIMER
173
	MOV.B	#stmr_mod_val,stmr_mod_reg+regoffset	; set timer mode
174
	MOV.W	#stmr_cnt,stmr_ctr_reg+regoffset	; set interval count
175
	MOV.B	#stmr_int_IPL,stmr_int_reg		; set timer IPL
176
	OR.B	#stmr_bit+1,stmr_start+regoffset	; system timer start
177
    .ENDIF
178

    
179
; +-----------------------------------------------------+
180
; |     System timer initialize                         |
181
; +-----------------------------------------------------+
182
    .IF	USE_SYSTEM_TIME
183
	MOV.W	#__D_Sys_TIME_L,__Sys_time+4
184
	MOV.W	#__D_Sys_TIME_M,__Sys_time+2
185
	MOV.W	#__D_Sys_TIME_H,__Sys_time
186
    .ENDIF
187

    
188
; +-----------------------------------------------------+
189
; |     User Initial Routine ( if there are )           |
190
; +-----------------------------------------------------+
191
; Initialize standard I/O
192
	.GLB	__init
193
;	JSR.A	__init
194

    
195
; +-----------------------------------------------------+
196
; |     Initalization of System Data Area               |
197
; +-----------------------------------------------------+
198
	JSR.W	__init_sys
199
	JSR.W	__init_tsk
200

    
201
    .IF	__MR_TIMEOUT
202
	.GLB	__init_tout
203
	JSR.W	__init_tout
204
    .ENDIF
205

    
206
    .IF	__NUM_FLG
207
	.GLB	__init_flg
208
	JSR.W	__init_flg
209
    .ENDIF
210

    
211
    .IF	__NUM_SEM
212
	.GLB	__init_sem
213
	JSR.W	__init_sem
214
    .ENDIF
215

    
216
    .IF	__NUM_DTQ
217
	.GLB	__init_dtq
218
	JSR.W	__init_dtq
219
    .ENDIF
220

    
221
    .IF	__NUM_VDTQ			;*A1*
222
	.GLB	__init_vdtq
223
	JSR.W	__init_vdtq
224
    .ENDIF
225

    
226
    .IF	__NUM_MBX
227
	.GLB	__init_mbx
228
	JSR.W	__init_mbx
229
    .ENDIF
230

    
231
    .IF	ALARM_HANDLER
232
	.GLB	__init_alh
233
	JSR.W	__init_alh
234
    .ENDIF
235

    
236
    .IF	CYCLIC_HANDLER
237
	.GLB	__init_cyh
238
	JSR.W	__init_cyh
239
    .ENDIF
240

    
241
    .IF	__NUM_MPF			;*A1*
242
	; Fixed Memory Pool
243
	.GLB	__init_mpf
244
	JSR.W	__init_mpf
245
    .ENDIF
246

    
247
    .IF	__NUM_MPL			;*A1*
248
	; Variable Memory Pool
249
	.GLB	__init_mpl
250
	JSR.W	__init_mpl
251
    .ENDIF
252

    
253

    
254
	; For PD308
255
	__LAST_INITIAL
256

    
257
__END_INIT:
258

    
259
; +-----------------------------------------------------+
260
; |        Start initial active task                    |
261
; +-----------------------------------------------------+
262
	__START_TASK
263

    
264
	.GLB	__rdyq_search
265
	JMP.W	__rdyq_search
266

    
267
; +---------------------------------------------+
268
; |     Define Dummy                            |
269
; +---------------------------------------------+
270
	.GLB	__SYS_DMY_INH
271
__SYS_DMY_INH:
272
	REIT
273

    
274
.IF	CUSTOM_SYS_END
275
; +---------------------------------------------+
276
; | Syscall exit rouitne to customize
277
; +---------------------------------------------+
278
	.GLB	__sys_end
279
__sys_end:
280
	; Customize here.
281
	REIT
282
.ENDIF
283

    
284
; +---------------------------------------------+
285
; |             exit() function                 |
286
; +---------------------------------------------+
287
	.GLB	_exit,$exit
288
_exit:
289
$exit:
290
	JMP	_exit
291

    
292
.IF USE_TIMER
293
; +---------------------------------------------+
294
; |       System clock interrupt handler        |
295
; +---------------------------------------------+
296
	.GLB		__SYS_STMR_INH
297
	.ALIGN
298
__SYS_STMR_INH:
299
	; process issue system call
300
	; For PD308
301
	__ISSUE_SYSCALL
302

    
303
	; System timer interrupt handler
304
	_STMR_hdr
305

    
306
	ret_int
307
.ENDIF
308

    
309
	.END
310

    
311
; ****************************************************************
312
;	COPYRIGHT(C) 2003 RENESAS TECHNOLOGY CORPORATION 
313
;	AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED
314
; ****************************************************************