source: rtems/c/src/lib/libbsp/powerpc/papyrus/flashentry/flashentry.s @ 80e2c29e

4.104.114.84.95
Last change on this file since 80e2c29e was 80e2c29e, checked in by Joel Sherrill <joel.sherrill@…>, on 08/22/95 at 17:11:19

Added file .. fixed RCS Id

  • Property mode set to 100644
File size: 8.2 KB
RevLine 
[80e2c29e]1/*  dlentry.s   1.0 - 95/08/08
2 *
3 *  This file contains the entry veneer for RTEMS programs
4 *  stored in Papyrus' flash ROM.
5 *
6 *  Author:     Andrew Bray <andy@i-cubed.demon.co.uk>
7 *
8 *  COPYRIGHT (c) 1995 by i-cubed ltd.
9 *
10 *  To anyone who acknowledges that this file is provided "AS IS"
11 *  without any express or implied warranty:
12 *      permission to use, copy, modify, and distribute this file
13 *      for any purpose is hereby granted without fee, provided that
14 *      the above copyright notice and this notice appears in all
15 *      copies, and that the name of i-cubed limited not be used in
16 *      advertising or publicity pertaining to distribution of the
17 *      software without specific, written prior permission.
18 *      i-cubed limited makes no representations about the suitability
19 *      of this software for any purpose.
20 */
21
22#include "asm.h"
23
24/*
25 *  The Papyrus ELF link scripts support three special sections:
26 *    .entry    The actual entry point, this must contain less
27 *              than 256 bytes of code/data to fit below the
28 *              .vectors section.  This always preceeds any other
29 *              code or data.
30 *    .vectors  The section containing the interrupt entry veneers.
31 *    .entry2   Any code overflowing from .entry
32 *    .descriptors The PowerOpen function indirection blocks.
33 */
34
35/*
36 *  Flash sections are linked in the following order:
37 *    .entry
38 *    .vectors
39 *    .entry2
40 *    .text
41 *    .descriptors
42 *    .data
43 *    .bss
44 *  usually starting from 0xFFF00000.
45 *
46 *  The initial stack is set to run BELOW the final location of
47 *  the initialised data.
48 *
49 *  All the entry veneer has to do is to copy the initialised data
50 *  to its final location and clear the BSS.
51 */
52
53/*
54 *  GDB likes to have debugging information for the entry veneer.
55 *  Here is some DWARF information.
56 */
57
58#if PPC_ASM == PPC_ASM_ELF
59        .section .entry,"ax",@progbits
60.L_text_b:
61.L_LC1:
62        .previous
63
64.section        .debug_sfnames
65.L_sfnames_b:
66        .byte "/home/andy/powerpc/rtems-3.2.0/c/src/lib/libcpu/ppc/ppc403/flashentry/"
67        .byte 0
68.L_F0:
69        .byte "flashentry.s"
70        .byte 0
71        .previous
72
73.section        .line
74.L_line_b:
75        .4byte  .L_line_e-.L_line_b
76        .4byte  .L_text_b
77.L_LE1:
78.L_line_last:
79        .4byte  0x0
80        .2byte  0xffff
81        .4byte  .L_text_e-.L_text_b
82.L_line_e:
83        .previous
84
85.section        .debug_srcinfo
86.L_srcinfo_b:
87        .4byte  .L_line_b
88        .4byte  .L_sfnames_b
89        .4byte  .L_text_b
90        .4byte  .L_text_e
91        .4byte  0xffffffff
92        .4byte  .L_LE1-.L_line_b
93        .4byte  .L_F0-.L_sfnames_b
94        .4byte  .L_line_last-.L_line_b
95        .4byte  0xffffffff
96        .previous
97
98.section        .debug_pubnames
99        .4byte  .L_debug_b
100        .4byte  .L_P0
101        .byte "flash_entry"
102        .byte 0
103        .4byte  0x0
104        .byte 0
105        .previous
106
107.section        .debug_aranges
108        .4byte  .L_debug_b
109        .4byte  .L_text_b
110        .4byte  .L_text_e-.L_text_b
111        .4byte  0
112        .4byte  0
113        .4byte  0
114        .4byte  0
115        .4byte  0
116        .4byte  0
117        .4byte  0x0
118        .4byte  0x0
119        .previous
120
121.section        .debug
122.L_debug_b:
123.L_D1:
124        .4byte  .L_D1_e-.L_D1
125        .2byte  0x11    /* TAG_compile_unit */
126        .2byte  0x12    /* AT_sibling */
127        .4byte  .L_D2
128        .2byte  0x38    /* AT_name */
129        .byte "flashentry.s"
130        .byte 0
131        .2byte  0x258   /* AT_producer */
132        .byte "GAS 2.5.2"
133        .byte 0
134        .2byte  0x111   /* AT_low_pc */
135        .4byte  .L_text_b
136        .2byte  0x121   /* AT_high_pc */
137        .4byte  .L_text_e
138        .2byte  0x106   /* AT_stmt_list */
139        .4byte  .L_line_b
140        .2byte  0x1b8   /* AT_comp_dir */
141        .byte "/home/andy/powerpc/rtems-3.2.0/c/src/lib/libcpu/ppc/ppc403/dlentry/"
142        .byte 0
143        .2byte  0x8006  /* AT_sf_names */
144        .4byte  .L_sfnames_b
145        .2byte  0x8016  /* AT_src_info */
146        .4byte  .L_srcinfo_b
147.L_D1_e:
148.L_P0:
149.L_D3:
150        .4byte  .L_D3_e-.L_D3
151        .2byte  0x6     /* TAG_global_subroutine */
152        .2byte  0x12    /* AT_sibling */
153        .4byte  .L_D4
154        .2byte  0x38    /* AT_name */
155        .byte "flash_entry"
156        .byte 0
157        .2byte  0x278   /* AT_prototyped */
158        .byte 0
159        .2byte  0x111   /* AT_low_pc */
160        .4byte  .L_text_b
161        .2byte  0x121   /* AT_high_pc */
162        .4byte  .L_text_e
163        .2byte  0x8041  /* AT_body_begin */
164        .4byte  .L_text_b
165        .2byte  0x8051  /* AT_body_end */
166        .4byte  .L_text_e
167.L_D3_e:
168
169.L_D4:
170        .4byte  .L_D4_e-.L_D4
171        .align 2
172.L_D4_e:
173.L_D2:
174        .previous
175#endif
176                               
177/*-------------------------------------------------------------------------------
178 * ROM Vector area.
179 *------------------------------------------------------------------------------*/
180#if PPC_ASM == PPC_ASM_ELF
181        .section .entry
182#else
183        .csect .text[PR]
184#endif
185        PUBLIC_VAR (flash_entry)
186SYM (flash_entry):
187        bl      .startup
188base_addr:     
189
190/*-------------------------------------------------------------------------------
191 * Parameters from linker
192 *------------------------------------------------------------------------------*/
193toc_pointer:
194#if PPC_ASM == PPC_ASM_ELF
195        .long   s.got
196#else
197        .long   TOC[tc0]
198#endif
199text_length:   
200        .long   t.size
201text_addr:
202        .long   t.start
203data_length:   
204        .long   copy.size
205data_addr:     
206        .long   copy.dest
207bss_length:     
208        .long   bss.size
209bss_addr:       
210        .long   bss.start
211
212/*-------------------------------------------------------------------------------
213 * Reset_entry.
214 *------------------------------------------------------------------------------*/
215.startup:
216        /* Get start address */
217        mflr    r1
218
219        /* Assume Bank regs set up..., cache etc. */
220
221        /*-----------------------------------------------------------------------
222         * Check the DRAM where STACK+ DATA+ BBS will be placed.  If this is OK
223         * we will return here.
224         *----------------------------------------------------------------------*/
225        bl      rom2ram
226        /*-----------------------------------------------------------------------
227         * Enable two 128MB cachable regions.
228         *----------------------------------------------------------------------*/
229        addis   r2,r0,0x8000
230        addi    r2,r2,0x0001
231        mticcr  r2
232        mtdccr  r2
233        /*-----------------------------------------------------------------------
234         * C_setup.
235         *----------------------------------------------------------------------*/
236        lwz     r2,toc_pointer-base_addr(r1)       /* set r2 to toc */
237        lwz     r1,data_addr-base_addr(r1)         /* set r1 to data_addr */
238        addi    r1,r1,-56                /* start stack at data_addr - 56 */
239        addi    r3,r0,0x0                /* clear r3 */
240        stw     r3, 0(r1)                /* Clear stack chain */
241        stw     r3, 4(r1)
242        stw     r3, 8(r1)
243        stw     r3, 12(r1)
244        .extern .main
245        b       .main            /* call the first C routine */
246
247/*-------------------------------------------------------------------------------
248 * Rom2ram.
249 *------------------------------------------------------------------------------*/
250rom2ram:
251        lwz     r2,data_addr-base_addr(r1)        /* start of data set by loader */
252        lwz     r3,data_length-base_addr(r1)      /* data length */
253        rlwinm  r3,r3,30,0x3FFFFFFF     /* form length/4 */
254        mtctr   r3                      /* set ctr reg */
255        /*-----------------------------------------------------------------------
256         * Calculate offset of data in image.
257         *----------------------------------------------------------------------*/
258        lwz     r5,text_length-base_addr(r1)      /* get text length */
259        lwz     r4,text_addr-base_addr(r1)      /* get text length */
260        add     r4,r4,r5                /* r4 = data pointer */
261move_data:
262        lswi    r6,r4,0x4               /* load r6 */
263        stswi   r6,r2,0x4               /* store r6 */
264        addi    r4,r4,0x4               /* update r4 */
265        addi    r2,r2,0x4               /* update r2 */
266        bdnz    move_data               /* decrement counter and loop */
267        /*-----------------------------------------------------------------------
268         * Data move finished, zero out bss.
269         *----------------------------------------------------------------------*/
270        lwz     r2,bss_addr-base_addr(r1)         /* start of bss set by loader */
271        lwz     r3,bss_length-base_addr(r1)       /* bss length */
272        rlwinm. r3,r3,30,0x3FFFFFFF     /* form length/4 */
273        beqlr                           /* no bss */
274        mtctr   r3                      /* set ctr reg */
275        xor     r6,r6,r6                /* r6 = 0 */
276clear_bss:
277        stswi   r6,r2,0x4               /* store r6 */
278        addi    r3,r2,0x4               /* update r2 */
279        bdnz    clear_bss               /* decrement counter and loop */
280        blr                             /* return */
281.L_text_e:
282
283#if PPC_ABI == PPC_ABI_POWEROPEN
284        DESCRIPTOR (startup)
285#endif
Note: See TracBrowser for help on using the repository browser.