source: rtems/c/src/lib/libbsp/powerpc/eth_comm/start/start.S @ bb7bef4e

4.104.114.84.95
Last change on this file since bb7bef4e was bb7bef4e, checked in by Eric Norum <WENorum@…>, on 10/26/04 at 14:12:06

Remove environ common declaration -- it broke newlib.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*  dlentry.s
2 *
3 *  $Id$
4 *
5 *  This file contains the entry veneer for RTEMS programs
6 *  downloaded to the eth-comm board.
7 *
8 * This file was written by Jay Monkman (jmonkman@fracsa.com)
9 * It was based on the dlentry.s file for the Papyrus BSP,
10 * written by:
11 *
12 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
13 *
14 *  COPYRIGHT (c) 1995 by i-cubed ltd.
15 *
16 *  To anyone who acknowledges that this file is provided "AS IS"
17 *  without any express or implied warranty:
18 *      permission to use, copy, modify, and distribute this file
19 *      for any purpose is hereby granted without fee, provided that
20 *      the above copyright notice and this notice appears in all
21 *      copies, and that the name of i-cubed limited not be used in
22 *      advertising or publicity pertaining to distribution of the
23 *      software without specific, written prior permission.
24 *      i-cubed limited makes no representations about the suitability
25 *      of this software for any purpose.
26 *
27 */
28
29#include <rtems/asm.h>
30
31/*
32 *  The initial stack is set to run BELOW the code base address.
33 *  (between the vectors and text sections)
34 *
35 *  All the entry veneer has to do is to clear the BSS.
36 */
37
38/*
39 *  GDB likes to have debugging information for the entry veneer.
40 *  Here is some DWARF information.
41 */
42/*
43 * There was some debugging info here, but I removed it because I
44 * couldn't get it to work. It isn't really necessary as far as I
45 * can tell. It should still be in the papyrus BSP. -Jay
46 */
47
48/*
49 * On entry to download_entry, R3 will hold a pointer to a Board Info
50 *  Block (boardinfo_t). This should be copied as soon as possible
51 *  to the global M860_binfo. (The block should be copied, _NOT_
52 *  the pointer)
53 */
54
55        .section ".entry"  /* This might have to be the first thing in the
56                            * text section. At one time, it had to be
57                            * first, but I don't believe it is true
58                            * andy more. */
59        PUBLIC_VAR (start)
60SYM(start):
61        bl      .startup
62base_addr:
63
64/*
65 * Parameters from linker
66 */
67toc_pointer:
68        .long   s.got
69bss_length:
70        .long   bss.size
71bss_addr:
72        .long   bss.start
73
74PUBLIC_VAR (text_addr)
75text_addr:
76        .long   text.start
77
78PUBLIC_VAR (text_length)
79text_length:
80        .long   text.size
81
82/*
83 * Initialization code
84 */
85.startup:
86        /* Get start address */
87        mflr    r1
88
89        /* clear the bss section */
90        bl      bssclr
91
92/*
93 * Copy the Board Info Block
94 */
95        .extern SYM(M860_binfo)
96        lis     r6, SYM(M860_binfo)@ha
97        addi    r6, r6, SYM(M860_binfo)@l
98
99        lhz     r4, 0(r3)                /* Load the size of the block */
100        rlwinm. r4, r4, 30, 0x3fffffff   /* get number of words */
101
102        mtctr   r4
103
104cpy_b:  lwz     r5, 0(r3)                /* In with the old ...  */
105        stw     r5, 0(r6)                /* ... Out with the new */
106        addi    r6, r6, 0x4              /* Go to the next word */
107        addi    r3, r3, 0x4
108        bdnz    cpy_b                    /* decrement counter and loop */
109
110/*
111 * C_setup.
112 */
113
114        /* set toc */
115        lwz r2, toc_pointer-base_addr(r1)
116
117        /* Set up stack pointer = beginning of text section - 56 */
118        addi    r1, r1, -56-4
119
120        lis     r9, 0xff00
121        addi    r10, 0, -16384
122        sth     r10, 0x950(r9)
123
124        lis     r9, 0x0000
125        addi    r9, r9, 0x0007
126        mtspr   0x9e, r9
127
128        lis     r5,environ@ha
129        la      r5,environ@l(r5)        /* environp */
130        li      r4, 0                   /* argv */
131        li      r3, 0                   /* argc */
132        .extern SYM (boot_card)
133        bl      SYM (boot_card)                  /* call the first C routine */
134loopstop:
135        b       loopstop
136
137/*
138 * bssclr - zero out bss
139 */
140bssclr:
141        lwz     r4, bss_addr-base_addr(r1)      /* Start of bss */
142        lwz     r5, bss_length-base_addr(r1)    /* Length of bss */
143
144        rlwinm. r5,r5,30,0x3FFFFFFF             /* form length/4 */
145        beqlr                                   /* no bss */
146        mtctr   r5                              /* set ctr reg */
147        xor     r6,r6,r6                        /* r6 = 0 */
148clear_bss:
149        stswi   r6,r4,0x4                       /* store r6 */
150        addi    r4,r4,0x4                       /* update r2 */
151
152        bdnz    clear_bss                       /* dec counter and loop */
153        blr                                     /* return */
Note: See TracBrowser for help on using the repository browser.