source: rtems/bsps/m32c/m32cbsp/start/start.S @ fbcd7c8f

Last change on this file since fbcd7c8f was fbcd7c8f, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 20, 2018 at 8:19:28 AM

bsps: Move start files to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2
3Copyright (c) 2005 Red Hat Incorporated.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9    Redistributions of source code must retain the above copyright
10    notice, this list of conditions and the following disclaimer.
11
12    Redistributions in binary form must reproduce the above copyright
13    notice, this list of conditions and the following disclaimer in the
14    documentation and/or other materials provided with the distribution.
15
16    The name of Red Hat Incorporated may not be used to endorse
17    or promote products derived from this software without specific
18    prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23DISCLAIMED.  IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
24DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31*/
32
33#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
34#define A16
35#define A(n,w) n
36#define W w
37#define ALIGN 1
38#else
39#define A24
40#define A(n,w) w
41#define W l
42#define ALIGN 2
43#endif
44
45        .text
46
47        .global _start
48_start:
49.LFB2:
50        fset    U       /* User stack */
51        ldc     #__stack,sp
52
53#ifdef A16
54        mov.b   #%hi8(__romdatastart),r1h
55        mov.w   #%lo16(__romdatastart),a0
56        mov.w   #__datastart,a1
57#else
58        mov.l   #__romdatastart,a0
59        mov.l   #__datastart,a1
60#endif
61        mov.w   #__romdatacopysize,r3
62        shl.w   #-1,r3
63        smovf.w
64
65#ifdef A16
66        mov.w   #__bssstart,a1
67#else
68        mov.l   #__bssstart,a1
69#endif
70        mov.w   #__bsssize,r3
71        shl.w   #-1,r3
72        mov.w   #0,r0
73        sstr.w
74
75        /* jsr.a        __m32c_init */
76
77        jsr.a   _boot_card
78.LFE2:
79
80#ifdef A24
81        /* rv in r0, ok for arg0 */
82#else
83        mov.w   r0,r1
84#endif
85
86        .global _bsp_reset
87_bsp_reset:
88        jsr.a   _sys_exit
89
90        .text
91
92        .global _m32c_run_preinit_array
93        .type   _m32c_run_preinit_array,@function
94_m32c_run_preinit_array:
95        mov.W   #__preinit_array_start,a0
96        mov.W   #__preinit_array_end,a1
97        jmp.w   _m32c_run_inilist
98
99        .global _m32c_run_init_array
100        .type   _m32c_run_init_array,@function
101_m32c_run_init_array:
102        mov.W   #__init_array_start,a0
103        mov.W   #__init_array_end,a1
104        jmp.w   _m32c_run_inilist
105
106        .global _m32c_run_fini_array
107        .type   _m32c_run_fini_array,@function
108_m32c_run_fini_array:
109        mov.W   #__fini_array_start,a0
110        mov.W   #__fini_array_end,a1
111        /* fall through */
112
113_m32c_run_inilist:
114next_inilist:
115        cmp.W   a0,a1
116        jeq     done_inilist
117        pushm   a0,a1
118        mov.W   [a0],a0
119#ifdef A16
120        mov.b:s #0,a1   /* zero extends */
121        jsri.a  a1a0
122#else
123        jsri.a  a0
124#endif
125        popm    a0,a1
126        add.W   A(#2,#4),a0
127        jmp.b   next_inilist
128done_inilist:
129        rts
130
131        .section        .init,"ax",@progbits
132
133        .global __init
134        .global __m32c_init
135__init:
136__m32c_init:
137        enter   #0
138        exitd
139
140        .section        .fini,"ax",@progbits
141
142        .global __fini
143        .global __m32c_fini
144__fini:
145__m32c_fini:
146        enter   #0
147        jsr.a   _m32c_run_fini_array
148        exitd
149
150
151;;; Provide Dwarf unwinding information that will help GDB stop
152;;; backtraces at the right place.  This is stolen from assembly
153;;; code generated by GCC with -dA.
154        .section        .debug_frame,"",@progbits
155.Lframe0:
156        .4byte  .LECIE0-.LSCIE0 ; Length of Common Information Entry
157.LSCIE0:
158        .4byte  0xffffffff      ; CIE Identifier Tag
159        .byte   0x1     ; CIE Version
160        .ascii "\0"     ; CIE Augmentation
161        .uleb128 0x1    ; CIE Code Alignment Factor
162        .sleb128 -1     ; CIE Data Alignment Factor
163        .byte   0xd     ; CIE RA Column
164        .byte   0xc     ; DW_CFA_def_cfa
165        .uleb128 0xc
166        .uleb128 0x3
167        .byte   0x8d    ; DW_CFA_offset, column 0xd
168        .uleb128 0x3
169        .p2align ALIGN
170.LECIE0:
171.LSFDE0:
172        .4byte  .LEFDE0-.LASFDE0        ; FDE Length
173.LASFDE0:
174        .4byte  .Lframe0        ; FDE CIE offset
175        .4byte  .LFB2           ; FDE initial location
176        .4byte  .LFE2-.LFB2     ; FDE address range
177        .byte   0xf             ; DW_CFA_def_cfa_expression
178        .uleb128 1              ; length of expression
179        .byte   0x30            ; DW_OP_lit0
180        .p2align ALIGN
181.LEFDE0:
182
183        .text
Note: See TracBrowser for help on using the repository browser.