source: rtems/bsps/powerpc/haleakala/start/start.S @ 90232bc

5
Last change on this file since 90232bc was 84e59b7c, checked in by Sebastian Huber <sebastian.huber@…>, on 11/15/18 at 19:47:22

bsps/powerpc: Use interrupt stack for init stack

Move start.o to separate file.

Update #3459.

  • Property mode set to 100644
File size: 6.3 KB
Line 
1/*  dlentry.s
2 *
3 *  This file contains the entry code for RTEMS programs starting
4 *  after download to RAM
5 *
6 *  Author:     Thomas Doerfler <td@imd.m.isar.de>
7 *              IMD Ingenieurbuero fuer Microcomputertechnik
8 *
9 *  COPYRIGHT (c) 1998 by IMD
10 *
11 *  Changes from IMD are covered by the original distributions terms.
12 *  This file has been derived from the papyrus BSP:
13 *
14 *  This file contains the entry veneer for RTEMS programs
15 *  downloaded to Papyrus.
16 *
17 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
18 *
19 *  COPYRIGHT (c) 1995 by i-cubed ltd.
20 *
21 *  To anyone who acknowledges that this file is provided "AS IS"
22 *  without any express or implied warranty:
23 *      permission to use, copy, modify, and distribute this file
24 *      for any purpose is hereby granted without fee, provided that
25 *      the above copyright notice and this notice appears in all
26 *      copies, and that the name of i-cubed limited not be used in
27 *      advertising or publicity pertaining to distribution of the
28 *      software without specific, written prior permission.
29 *      i-cubed limited makes no representations about the suitability
30 *      of this software for any purpose.
31 *
32 *  derived from "helas403/dlentry.S":
33 *
34 *  Further changes to derive for the PPC405CR/GP/GPr/EX/EXr
35 *  by Michael Hamel ADInstruments Ltd 2008
36 */
37
38#include <rtems/asm.h>
39
40/*
41 *  The virtex ELF link scripts support three special sections:
42 *    .entry    The actual entry point
43 *    .vectors  The section containing the interrupt entry veneers.
44 */
45
46/*
47 *  Downloaded code loads the vectors separately to 0x00000100,
48 *  so .entry can be over 256 bytes.
49 *
50 *  The other sections are linked in the following order:
51 *    .entry
52 *    .text
53 *    .data
54 *    .bss
55 * see linker command file for section placement
56 *
57 *  The initial stack is set to _ISR_Stack_area_end.
58 *
59 *  All the entry veneer has to do is to clear the BSS.
60 */
61
62/*
63 *  GDB likes to have debugging information for the entry veneer.
64 *  Here was some DWARF information. IMD removed it, because we
65 *  could not check, whether it was still correct. Sorry.
66
67 */
68
69
70                        .section .entry
71
72                        PUBLIC_VAR (start)
73                        PUBLIC_VAR (download_entry)
74                        PUBLIC_VAR (__rtems_entry_point)
75
76SYM(start):
77SYM(download_entry):
78SYM(__rtems_entry_point):
79
80                        .extern SYM (boot_card)
81
82                        bl      .startup                /* First word is branch to reset_entry */
83
84
85/*---------------------------------------------------------------------------
86 * Parameters from linker
87 *--------------------------------------------------------------------------*/
88
89base_addr:
90toc_pointer:
91                .long   s.got
92bss_length:
93                .long   bss.size
94bss_addr:
95                .long   bss.start
96sbss_length:
97                .long   sbss.size
98sbss_addr:
99                .long   sbss.start
100stack_top:
101                .long   _ISR_Stack_area_end
102PUBLIC_VAR (text_addr)
103text_addr:
104        .long   text.start
105PUBLIC_VAR (text_length)
106text_length:
107        .long   text.size
108
109/*---------------------------------------------------------------------------
110 * Reset_entry.
111 *--------------------------------------------------------------------------*/
112.startup:
113                        /* Get entrypoint address in R1 so we can find linker variables */
114                        mflr    r1
115
116                        /* Initialise procesor registers generally */
117                        bl              init405
118
119                        /* Clear .bss and .sbss */
120                        bl              bssclr
121
122                        /*-------------------------------------------------------------------
123                         * C_setup.
124                         *------------------------------------------------------------------*/
125                        lwz     r1,stack_top - base_addr(r1)         /* Now set R1 to stack_top */
126                        addi    r1,r1,-56-4         /* start stack at text_addr - 56 */
127                        li              r3,0
128                        stw             r3, 0(r1)                       /* Clear stack chain */
129                        stw             r3, 4(r1)
130                        stw             r3, 8(r1)
131                        stw             r3, 12(r1)
132
133                        bl              __eabi                          /* Initialise EABI: sets up r2 & r13 */
134
135                        li              r3, 0                   /* command line */
136
137                        b       SYM (boot_card)          /* call the first C routine */
138
139/*---------------------------------------------------------------------------
140 * bssclr.
141 *--------------------------------------------------------------------------*/
142bssclr:         lwz     r2,bss_addr-base_addr(r1)   /* start of bss set by loader */
143                        lwz     r3,bss_length-base_addr(r1) /* bss length */
144                        srwi.   r3,r3,2         /* div 4 to get # of words */
145                        li              r0,0
146                        beq             dosbss                                  /* no bss */
147                        mtctr   r3                      /* set ctr reg */
148                        subi    r2,r2,4
149clear_bss:      stwu    r0,4(r2)
150                        bdnz    clear_bss               /* decrement counter and loop */
151
152dosbss:         lwz     r2,sbss_addr-base_addr(r1)   /* start of sbss set by loader */
153                        lwz     r3,sbss_length-base_addr(r1) /* sbss length */
154                        slwi.   r3,r3,2                                 /* div 4 to get # of words */
155                        subi    r2,r2,4
156                        beqlr                           /* no sbss */
157                        mtctr   r3                      /* set ctr reg */
158clear_sbss:     stwu    r0,4(r2)
159                        bdnz    clear_sbss               /* decrement counter and loop */
160
161                        blr                             /* return */
162
163
164/*---------------------------------------------------------------------------
165 * Generic 405 register setup
166 *--------------------------------------------------------------------------*/
167init405:
168                        li              r0, 0
169                        mtmsr   r0
170                        mticcr  r0
171                        mtdccr  r0
172
173                        li              r3,0x7FFC       # 405EX-specific
174                        mtsgr   r3                      # Clear guarded mode on all storage except PCIe region
175
176                        mtsler  r0                      # Storage is all big-endian
177                        mtsu0r  r0                      # and uncompressed
178
179                        iccci   r3,0                    # Invalidate the instruction cache
180                        li              r3,1                    # Enable F800 0000 to FFFF FFFF
181                        oris    r3,r3,0xC000    # Enable 0000 0000 to 0FFF FFFF
182                        mticcr  r3
183                        isync
184
185                        li              r3,0
186                        li              r4,256          # 405 has 128 or 256 32-byte lines: do 256
187                        mtctr   r4                      # set loop ctr
188dcloop:         dccci   0,r3            # invalidate line
189                        addi    r3,r3,0x20      # bump to next line
190                        bdnz    dcloop
191                        mtdcwr  r0                      # Select write-back caching
192                        lis             r3,0xC000       # Enable 0000 0000 to 0FFF FFFF
193                        # mtdccr        r3                      # Enable data cache
194
195                        mtevpr  r0
196                        mtesr   r0
197                        mtxer   r0
198
199                        lwarx   r3,r0,r0                # get some data/set resv bit
200                        stwcx.  r3,r0,r0                # store out and clear resv bit
201
202                        lis             r3,0xDEAD
203                        ori             r3,r3,0xBEEF    # Make distintive uninitialised value
204                        mr              r4, r3
205                        mr              r5, r3
206                        mr              r6, r3
207                        mr              r7, r3
208                        mr              r8, r3
209                        mr              r9, r3
210                        mr              r10, r3
211                        mr              r11, r3
212                        mr              r12, r3
213                        mr              r13, r3
214                        mr              r14, r3
215                        mr              r15, r3
216                        mr              r16, r3
217                        mr              r17, r3
218                        mr              r18, r3
219                        mr              r19, r3
220                        mr              r20, r3
221                        mr              r21, r3
222                        mr              r22, r3
223                        mr              r23, r3
224                        mr              r24, r3
225                        mr              r25, r3
226                        mr              r26, r3
227                        mr              r27, r3
228                        mr              r28, r3
229                        mr              r29, r3
230                        mr              r30, r3
231                        mr              r31, r3
232
233                        blr
234
235.L_text_e:
236
237                        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.