source: rtems/c/src/lib/libbsp/m32c/m32cbsp/start/start.S @ 6e868d87

4.115
Last change on this file since 6e868d87 was de237f4, checked in by Joel Sherrill <joel.sherrill@…>, on 04/07/10 at 21:50:11

2010-04-07 Joel Sherrill <joel.sherrill@…>

  • start/start.S: Verify boot_card() is passed a NULL.
  • 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        jsr.a   _sys_exit
87
88        .text
89
90        .global _m32c_run_preinit_array
91        .type   _m32c_run_preinit_array,@function
92_m32c_run_preinit_array:
93        mov.W   #__preinit_array_start,a0
94        mov.W   #__preinit_array_end,a1
95        jmp.w   _m32c_run_inilist
96
97        .global _m32c_run_init_array
98        .type   _m32c_run_init_array,@function
99_m32c_run_init_array:
100        mov.W   #__init_array_start,a0
101        mov.W   #__init_array_end,a1
102        jmp.w   _m32c_run_inilist
103
104        .global _m32c_run_fini_array
105        .type   _m32c_run_fini_array,@function
106_m32c_run_fini_array:
107        mov.W   #__fini_array_start,a0
108        mov.W   #__fini_array_end,a1
109        /* fall through */
110
111_m32c_run_inilist:
112next_inilist:
113        cmp.W   a0,a1
114        jeq     done_inilist
115        pushm   a0,a1
116        mov.W   [a0],a0
117#ifdef A16
118        mov.b:s #0,a1   /* zero extends */
119        jsri.a  a1a0
120#else
121        jsri.a  a0
122#endif
123        popm    a0,a1
124        add.W   A(#2,#4),a0
125        jmp.b   next_inilist
126done_inilist:
127        rts
128
129        .section        .init,"ax",@progbits
130
131        .global __init
132        .global __m32c_init
133__init:
134__m32c_init:
135        enter   #0
136        exitd
137
138        .section        .fini,"ax",@progbits
139
140        .global __fini
141        .global __m32c_fini
142__fini:
143__m32c_fini:
144        enter   #0
145        jsr.a   _m32c_run_fini_array
146        exitd
147
148
149;;; Provide Dwarf unwinding information that will help GDB stop
150;;; backtraces at the right place.  This is stolen from assembly
151;;; code generated by GCC with -dA.
152        .section        .debug_frame,"",@progbits
153.Lframe0:
154        .4byte  .LECIE0-.LSCIE0 ; Length of Common Information Entry
155.LSCIE0:
156        .4byte  0xffffffff      ; CIE Identifier Tag
157        .byte   0x1     ; CIE Version
158        .ascii "\0"     ; CIE Augmentation
159        .uleb128 0x1    ; CIE Code Alignment Factor
160        .sleb128 -1     ; CIE Data Alignment Factor
161        .byte   0xd     ; CIE RA Column
162        .byte   0xc     ; DW_CFA_def_cfa
163        .uleb128 0xc
164        .uleb128 0x3
165        .byte   0x8d    ; DW_CFA_offset, column 0xd
166        .uleb128 0x3
167        .p2align ALIGN
168.LECIE0:
169.LSFDE0:
170        .4byte  .LEFDE0-.LASFDE0        ; FDE Length
171.LASFDE0:
172        .4byte  .Lframe0        ; FDE CIE offset
173        .4byte  .LFB2           ; FDE initial location
174        .4byte  .LFE2-.LFB2     ; FDE address range
175        .byte   0xf             ; DW_CFA_def_cfa_expression
176        .uleb128 1              ; length of expression
177        .byte   0x30            ; DW_OP_lit0
178        .p2align ALIGN
179.LEFDE0:
180
181        .text
Note: See TracBrowser for help on using the repository browser.