source: rtems/c/src/lib/libbsp/powerpc/haleakala/dlentry/dlentry.S @ 976b159

4.104.115
Last change on this file since 976b159 was 0aa4b0f, checked in by Chris Johns <chrisj@…>, on 04/28/09 at 06:32:31

2009-04-28 Chris Johns <chrisj@…>

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