source: rtems/c/src/lib/libbsp/powerpc/haleakala/dlentry/dlentry.S @ 1b6151a

4.104.115
Last change on this file since 1b6151a was 1b6151a, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 03/27/10 at 20:41:18

removed "bootbard calling" warning

  • 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 *  $Id$
33 *
34 *  derived from "helas403/dlentry.S":
35 *
36 *  Further changes to derive for the PPC405CR/GP/GPr/EX/EXr
37 *  by Michael Hamel ADInstruments Ltd 2008
38 *
39 *
40 *  Id: dlentry.S,v 1.2 2000/08/02 16:30:57 joel Exp
41 */
42
43#include <rtems/asm.h>
44
45/*
46 *  The virtex ELF link scripts support three special sections:
47 *    .entry    The actual entry point
48 *    .vectors  The section containing the interrupt entry veneers.
49 */
50
51/*
52 *  Downloaded code loads the vectors separately to 0x00000100,
53 *  so .entry can be over 256 bytes.
54 *
55 *  The other sections are linked in the following order:
56 *    .entry
57 *    .text
58 *    .data
59 *    .bss
60 * see linker command file for section placement
61 *
62 *  The initial stack is set to stack.end
63 *
64 *  All the entry veneer has to do is to clear the BSS.
65 */
66
67/*
68 *  GDB likes to have debugging information for the entry veneer.
69 *  Here was some DWARF information. IMD removed it, because we
70 *  could not check, whether it was still correct. Sorry.
71
72 */
73
74
75                        .section .entry
76
77                        PUBLIC_VAR (start)
78                        PUBLIC_VAR (download_entry)
79                        PUBLIC_VAR (__rtems_entry_point)
80
81SYM(start):
82SYM(download_entry):
83SYM(__rtems_entry_point):
84
85                        .extern SYM (boot_card)
86
87                        bl      .startup                /* First word is branch to reset_entry */
88
89
90/*---------------------------------------------------------------------------
91 * Parameters from linker
92 *--------------------------------------------------------------------------*/
93
94base_addr:
95toc_pointer:
96                .long   s.got
97bss_length:
98                .long   bss.size
99bss_addr:
100                .long   bss.start
101sbss_length:
102                .long   sbss.size
103sbss_addr:
104                .long   sbss.start
105stack_top:
106                .long   stack.end
107PUBLIC_VAR (text_addr)
108text_addr:
109        .long   text.start
110PUBLIC_VAR (text_length)
111text_length:
112        .long   text.size
113
114/*---------------------------------------------------------------------------
115 * Reset_entry.
116 *--------------------------------------------------------------------------*/
117.startup:
118                        /* Get entrypoint address in R1 so we can find linker variables */
119                        mflr    r1
120
121                        /* Initialise procesor registers generally */
122                        bl              init405
123
124                        /* Clear .bss and .sbss */
125                        bl              bssclr
126
127                        /*-------------------------------------------------------------------
128                         * C_setup.
129                         *------------------------------------------------------------------*/
130                        lwz     r1,stack_top - base_addr(r1)         /* Now set R1 to stack_top */
131                        addi    r1,r1,-56-4         /* start stack at text_addr - 56 */
132                        li              r3,0
133                        stw             r3, 0(r1)                       /* Clear stack chain */
134                        stw             r3, 4(r1)
135                        stw             r3, 8(r1)
136                        stw             r3, 12(r1)
137
138                        bl              __eabi                          /* Initialise EABI: sets up r2 & r13 */
139
140                        li              r3, 0                   /* command line */
141
142                        b       SYM (boot_card)          /* call the first C routine */
143
144/*---------------------------------------------------------------------------
145 * bssclr.
146 *--------------------------------------------------------------------------*/
147bssclr:         lwz     r2,bss_addr-base_addr(r1)   /* start of bss set by loader */
148                        lwz     r3,bss_length-base_addr(r1) /* bss length */
149                        srwi.   r3,r3,2         /* div 4 to get # of words */
150                        li              r0,0
151                        beq             dosbss                                  /* no bss */
152                        mtctr   r3                      /* set ctr reg */
153                        subi    r2,r2,4
154clear_bss:      stwu    r0,4(r2)
155                        bdnz    clear_bss               /* decrement counter and loop */
156
157dosbss:         lwz     r2,sbss_addr-base_addr(r1)   /* start of sbss set by loader */
158                        lwz     r3,sbss_length-base_addr(r1) /* sbss length */
159                        slwi.   r3,r3,2                                 /* div 4 to get # of words */
160                        subi    r2,r2,4
161                        beqlr                           /* no sbss */
162                        mtctr   r3                      /* set ctr reg */
163clear_sbss:     stwu    r0,4(r2)
164                        bdnz    clear_sbss               /* decrement counter and loop */
165
166                        blr                             /* return */
167
168
169/*---------------------------------------------------------------------------
170 * Generic 405 register setup
171 *--------------------------------------------------------------------------*/
172init405:
173                        li              r0, 0
174                        mtmsr   r0
175                        mticcr  r0
176                        mtdccr  r0
177
178                        li              r3,0x7FFC       # 405EX-specific
179                        mtsgr   r3                      # Clear guarded mode on all storage except PCIe region
180
181                        mtsler  r0                      # Storage is all big-endian
182                        mtsu0r  r0                      # and uncompressed
183
184                        iccci   r3,0                    # Invalidate the instruction cache
185                        li              r3,1                    # Enable F800 0000 to FFFF FFFF
186                        oris    r3,r3,0xC000    # Enable 0000 0000 to 0FFF FFFF
187                        mticcr  r3
188                        isync
189
190                        li              r3,0
191                        li              r4,256          # 405 has 128 or 256 32-byte lines: do 256
192                        mtctr   r4                      # set loop ctr
193dcloop:         dccci   0,r3            # invalidate line
194                        addi    r3,r3,0x20      # bump to next line
195                        bdnz    dcloop
196                        mtdcwr  r0                      # Select write-back caching
197                        lis             r3,0xC000       # Enable 0000 0000 to 0FFF FFFF
198                        # mtdccr        r3                      # Enable data cache
199
200                        mtevpr  r0
201                        mtesr   r0
202                        mtxer   r0
203
204                        lwarx   r3,r0,r0                # get some data/set resv bit
205                        stwcx.  r3,r0,r0                # store out and clear resv bit
206
207                        lis             r3,0xDEAD
208                        ori             r3,r3,0xBEEF    # Make distintive uninitialised value
209                        mr              r4, r3
210                        mr              r5, r3
211                        mr              r6, r3
212                        mr              r7, r3
213                        mr              r8, r3
214                        mr              r9, r3
215                        mr              r10, r3
216                        mr              r11, r3
217                        mr              r12, r3
218                        mr              r13, r3
219                        mr              r14, r3
220                        mr              r15, r3
221                        mr              r16, r3
222                        mr              r17, r3
223                        mr              r18, r3
224                        mr              r19, r3
225                        mr              r20, r3
226                        mr              r21, r3
227                        mr              r22, r3
228                        mr              r23, r3
229                        mr              r24, r3
230                        mr              r25, r3
231                        mr              r26, r3
232                        mr              r27, r3
233                        mr              r28, r3
234                        mr              r29, r3
235                        mr              r30, r3
236                        mr              r31, r3
237
238                        blr
239
240.L_text_e:
241
242                        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.