source: rtems/c/src/lib/libbsp/powerpc/haleakala/dlentry/dlentry.S @ 574fb67

4.104.114.95
Last change on this file since 574fb67 was 3c6fe2e, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/14/08 at 08:46:06

added haleakala BSP contributed by Michael Hamel

  • Property mode set to 100644
File size: 6.4 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                        lis             r5,environ@ha
141                        la              r5,environ@l(r5)        /* environp */
142                        li              r4, 0                   /* argv */
143                        li              r3, 0                   /* argc */
144                       
145                        b       SYM (boot_card)          /* call the first C routine */
146
147/*---------------------------------------------------------------------------
148 * bssclr.
149 *--------------------------------------------------------------------------*/
150bssclr:         lwz     r2,bss_addr-base_addr(r1)   /* start of bss set by loader */
151                        lwz     r3,bss_length-base_addr(r1) /* bss length */
152                        srwi.   r3,r3,2         /* div 4 to get # of words */
153                        li              r0,0
154                        beq             dosbss                                  /* no bss */
155                        mtctr   r3                      /* set ctr reg */
156                        subi    r2,r2,4
157clear_bss:      stwu    r0,4(r2)
158                        bdnz    clear_bss               /* decrement counter and loop */
159
160dosbss:         lwz     r2,sbss_addr-base_addr(r1)   /* start of sbss set by loader */
161                        lwz     r3,sbss_length-base_addr(r1) /* sbss length */
162                        slwi.   r3,r3,2                                 /* div 4 to get # of words */
163                        subi    r2,r2,4
164                        beqlr                           /* no sbss */
165                        mtctr   r3                      /* set ctr reg */
166clear_sbss:     stwu    r0,4(r2)
167                        bdnz    clear_sbss               /* decrement counter and loop */
168
169                        blr                             /* return */
170
171
172/*---------------------------------------------------------------------------
173 * Generic 405 register setup
174 *--------------------------------------------------------------------------*/
175init405:
176                        li              r0, 0   
177                        mtmsr   r0
178                        mticcr  r0
179                        mtdccr  r0
180                                               
181                        li              r3,0x7FFC       # 405EX-specific
182                        mtsgr   r3                      # Clear guarded mode on all storage except PCIe region
183
184                        mtsler  r0                      # Storage is all big-endian
185                        mtsu0r  r0                      # and uncompressed
186
187                        iccci   r3,0                    # Invalidate the instruction cache
188                        li              r3,1                    # Enable F800 0000 to FFFF FFFF
189                        oris    r3,r3,0xC000    # Enable 0000 0000 to 0FFF FFFF
190                        mticcr  r3
191                        isync
192
193                        li              r3,0
194                        li              r4,256          # 405 has 128 or 256 32-byte lines: do 256
195                        mtctr   r4                      # set loop ctr
196dcloop:         dccci   0,r3            # invalidate line
197                        addi    r3,r3,0x20      # bump to next line
198                        bdnz    dcloop
199                        mtdcwr  r0                      # Select write-back caching
200                        lis             r3,0xC000       # Enable 0000 0000 to 0FFF FFFF
201                        # mtdccr        r3                      # Enable data cache
202                       
203                        mtevpr  r0
204                        mtesr   r0
205                        mtxer   r0
206                       
207                        lwarx   r3,r0,r0                # get some data/set resv bit
208                        stwcx.  r3,r0,r0                # store out and clear resv bit 
209
210                        lis             r3,0xDEAD
211                        ori             r3,r3,0xBEEF    # Make distintive uninitialised value
212                        mr              r4, r3
213                        mr              r5, r3
214                        mr              r6, r3
215                        mr              r7, r3
216                        mr              r8, r3
217                        mr              r9, r3
218                        mr              r10, r3
219                        mr              r11, r3
220                        mr              r12, r3
221                        mr              r13, r3
222                        mr              r14, r3
223                        mr              r15, r3
224                        mr              r16, r3
225                        mr              r17, r3
226                        mr              r18, r3
227                        mr              r19, r3
228                        mr              r20, r3
229                        mr              r21, r3
230                        mr              r22, r3
231                        mr              r23, r3
232                        mr              r24, r3
233                        mr              r25, r3
234                        mr              r26, r3
235                        mr              r27, r3
236                        mr              r28, r3
237                        mr              r29, r3
238                        mr              r30, r3
239                        mr              r31, r3
240
241                        blr
242
243.L_text_e:
244
245                        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.