source: rtems/c/src/lib/libbsp/sh/gensh4/start/start.S @ 359e537

4.104.115
Last change on this file since 359e537 was 359e537, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 05:09:41

Whitespace removal.

  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*
2 * start.S -- Initialization code for SH7750 generic BSP
3 *
4 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
5 * Author: Victor V. Vengerov <vvv@oktet.ru>
6 *
7 * Based on work:
8 *  Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and
9 *           Bernd Becker (becker@faw.uni-ulm.de)
10 *
11 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
12 *
13 *  This program is distributed in the hope that it will be useful,
14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 *  Modified to reflect Hitachi EDK SH7045F:
18 *  John M. Mills (jmills@tga.com)
19 *  TGA Technologies, Inc.
20 *  100 Pinnacle Way, Suite 140
21 *  Norcross, GA 30071 U.S.A.
22 *
23 *
24 *  This modified file may be copied and distributed in accordance
25 *  the above-referenced license. It is provided for critique and
26 *  developmental purposes without any warranty nor representation
27 *  by the authors or by TGA Technologies.
28 *
29 *  COPYRIGHT (c) 1999-2001.
30 *  On-Line Applications Research Corporation (OAR).
31 *
32 *  The license and distribution terms for this file may be
33 *  found in the file LICENSE in this distribution or at
34 *  http://www.rtems.com/license/LICENSE.
35 *
36 *  $Id$
37 */
38
39#include <rtems/asm.h>
40#include "rtems/score/sh4_regs.h"
41#include "rtems/score/sh7750_regs.h"
42
43#warning Call to boot_card has changed and needs checking.
44#warning The call is "void boot_card(const char* cmdline);"
45#warning Please check and remove these warnings.
46
47        BEGIN_CODE
48        PUBLIC(start)
49
50/*
51 * Algorithm of the first part of the start():
52 *
53 * 1. Initialize stack
54 * 2. Are we from reset or from gdb? Set value for boot_mode in r9.
55 * 3. Initialize hardware if we are from reset. Cache is off.
56 * 4. Copy data from flash to ram; set up boot mode and jump to real address.
57 * 5. Zero out bss.
58 * 6. Turn memory cach on.
59 */
60
61SYM (start):
62        ! install the stack pointer
63        mov.l   stack_k,r15
64
65        mov.l   initial_sr_k,r0
66        ldc     r0,ssr
67        ldc     r0,sr
68
69        ! let us see if we are from gdb stub or from power-on reset
70        bsr     fake_func
71        nop
72fake_func:
73
74        sts     pr, r0
75        shlr8   r0
76        mov.l   reset_pc_value_shift_8_k, r1
77        cmp/eq  r0, r1
78        movt    r9      ! r9 == ! boot_mode
79        neg     r9, r9
80        add     #1, r9  ! r9 == boot_mode
81
82        ! what is in boot_mode?
83        cmp/pl  r9      ! r9 > 0  ->  T = 1
84
85        ! if boot_mode != SH4_BOOT_MODE_FLASH
86        bt      hw_init_end
87        nop
88
89#if defined(START_HW_INIT)      /* from $RTEMS_BSP.cfg */
90        ! Initialize minimal hardware
91        ! to run hw_init we need to calculate its address
92        ! as it is before data coping
93        mov.l   hw_init_k, r0
94        mov.l   copy_start_k, r1
95        mov.l   copy_end_k, r2
96        cmp/ge  r0, r1
97        bt      0f
98        cmp/ge  r0, r2
99        bf      0f
100        ! if  copy_start <= hw_init <= copy_end  then
101        neg     r1, r1
102        mov.l   copy_start_in_rom_k, r3
103        add     r1,r0
104        add     r3, r0
1050:
106        jsr @r0
107        nop             !delay slot
108#endif /* START_HW_INIT */
109hw_init_end:
110
111        ! copy data from rom to ram
112        mov.l   copy_start_k, r0
113        mov.l   copy_end_k, r1
114        mov.l   copy_start_in_rom_k, r2
115
116        ! if copy_from == copy_to do not copy anything
117        cmp/eq  r0, r2
118        bt      real_address
119        nop
120
121copy_data_cycle:
122        cmp/ge  r1, r0
123        bt      end_of_copy_data_cycle
124        nop
125        mov.l   @r2+, r3
126        mov.l   r3, @r0
127        add     #4, r0
128        bra     copy_data_cycle
129        nop
130
131end_of_copy_data_cycle:
132        ! go to 0x8....... adresses
133        mov.l   real_address_k, r0
134        lds     r0, pr
135        rts
136        nop
137real_address:
138        ! write boot_mode to ram
139        mov.l   boot_mode_k, r5
140        mov.l   r9, @r5
141
142zero_bss:
143        ! zero out bss
144        mov.l   __bss_start_k,r0
145        mov.l   __bss_end_k,r1
146        mov     #0,r2
1470:
148        mov.l   r2,@r0
149        add     #4,r0
150        cmp/ge  r0,r1
151        bt      0b
152        nop
153
154        ! Turn cache on
155        mov.l   cache_on_k, r0
156        jsr @r0
157        nop     !delay slot
158
159        ! Save old value of VBR register. We will need it to allow
160        ! debugger agent hook exceptions.
161        mov.l   __VBR_Saved_k,r0
162        stc     vbr,r5
163        mov.l   r5,@r0
164        ! Set up VBR register
165        mov.l   _vbr_base_k,r0
166        ldc     r0,vbr
167
168        ! initialise fpscr for gcc
169        mov.l set_fpscr_k, r1
170        jsr @r1
171        nop
172
173        ! Set FPSCR register
174        mov.l   initial_fpscr_k,r0
175        lds     r0,fpscr
176
177        ! call the mainline
178        mov #0,r4               ! argc
179        mov.l main_k,r0
180        jsr @r0
181        nop
182
183        ! call exit
184        mov     r0,r4
185        mov.l   exit_k,r0
186        jsr     @r0
187        or      r0,r0
188
189        .global _stop
190_stop:
191        mov     #11,r0
192        mov     #0,r4
193        trapa   #0x3f
194        nop
195__stop:
196        bra     __stop
197        nop
198
199        END_CODE
200
201        .align 2
202copy_start_k:
203        .long copy_start
204copy_end_k:
205        .long copy_end
206copy_start_in_rom_k:
207        .long copy_start_in_rom
208
209real_address_k:
210        .long real_address
211set_fpscr_k:
212    .long   ___set_fpscr
213_vbr_base_k:
214        .long   SYM(_vbr_base)
215__VBR_Saved_k:
216        .long   SYM(_VBR_Saved)
217stack_k:
218        .long   SYM(stack)
219__bss_start_k:
220        .long   __bss_start
221__bss_end_k:
222        .LONG   __bss_end
223main_k:
224        .long   SYM(boot_card)
225exit_k:
226        .long   SYM(_exit)
227
228#ifdef  START_HW_INIT   /* from $RTEMS_BSP.cfg */
229hw_init_k:
230        .long   SYM(early_hw_init)
231#endif /* START_HW_INIT */
232
233cache_on_k:
234        .long   SYM(bsp_cache_on)
235
236vects_k:
237        .long   SYM(vectab)
238vects_size:
239        .word   255
240
241    .align 2
242initial_sr_k:
243        .long   SH4_SR_MD | SH4_SR_IMASK
244initial_fpscr_k:
245#ifdef __SH4__
246        .long   SH4_FPSCR_DN | SH4_FPSCR_PR | SH4_FPSCR_RM
247#else
248        .long   SH4_FPSCR_DN | SH4_FPSCR_RM
249#endif
250
251reset_pc_value_shift_8_k:
252        .long   0xa00000
253
254boot_mode_k:
255        .long   _boot_mode
256
257#ifdef __ELF__
258        .section .stack,"aw"
259#else
260        .section .stack
261#endif
262SYM(stack):
263        .long   0xdeaddead
264
265#ifdef __ELF__
266        .section .bss,"aw"
267#else
268        .section .bss
269#endif
270
271        .global __sh4sim_dummy_register
272__sh4sim_dummy_register:
273        .long   0
274
275        .section    .data
276        .global _boot_mode
277_boot_mode:
278        .long   0
Note: See TracBrowser for help on using the repository browser.