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

4.104.114.84.95
Last change on this file since 02cb8dc9 was 15c48f4c, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/00 at 16:30:57

Properly pass argc, argc, and environp to boot_card.

  • Property mode set to 100644
File size: 4.4 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 "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
50/*
51 * On entry to download_entry, R3 will hold a pointer to a Board Info
52 *  Block (boardinfo_t). This should be copied as soon as possible
53 *  to the global M860_binfo. (The block should be copied, _NOT_
54 *  the pointer)
55 */
56
57        .section ".entry"  /* This might have to be the first thing in the
58                            * text section. At one time, it had to be
59                            * first, but I don't believe it is true
60                            * andy more. */
61        PUBLIC_VAR (start)
62SYM(start):
63        bl      .startup
64base_addr:     
65
66/*
67 * Parameters from linker
68 */
69toc_pointer:   
70        .long   s.got
71bss_length:     
72        .long   bss.size
73bss_addr:       
74        .long   bss.start
75
76PUBLIC_VAR (text_addr)
77text_addr:
78        .long   text.start
79
80PUBLIC_VAR (text_length)
81text_length:
82        .long   text.size
83
84
85/*
86 * Initialization code
87 */
88.startup:
89        /* Get start address */
90        mflr    r1
91       
92        /* clear the bss section */
93        bl      bssclr
94
95/*
96 * Copy the Board Info Block
97 */
98        .extern SYM(M860_binfo)
99        lis     r6, SYM(M860_binfo)@ha
100        addi    r6, r6, SYM(M860_binfo)@l
101
102        lhz     r4, 0(r3)                /* Load the size of the block */
103        rlwinm. r4, r4, 30, 0x3fffffff   /* get number of words */
104
105        mtctr   r4
106
107cpy_b:  lwz     r5, 0(r3)                /* In with the old ...  */
108        stw     r5, 0(r6)                /* ... Out with the new */
109        addi    r6, r6, 0x4              /* Go to the next word */
110        addi    r3, r3, 0x4
111        bdnz    cpy_b                    /* decrement counter and loop */
112
113/*
114 * C_setup.
115 */
116
117        /* set toc */
118        lwz r2, toc_pointer-base_addr(r1)
119
120        /* Set up stack pointer = beginning of text section - 56 */
121        addi    r1, r1, -56-4
122
123        lis     r9, 0xff00
124        addi    r10, 0, -16384
125        sth     r10, 0x950(r9)
126
127        lis     r9, 0x0000
128        addi    r9, r9, 0x0007
129        mtspr   0x9e, r9
130
131        lis     r5,environ@ha
132        la      r5,environ@l(r5)        /* environp */
133        li      r4, 0                   /* argv */
134        li      r3, 0                   /* argc */
135        .extern SYM (boot_card)
136        bl      SYM (boot_card)                  /* call the first C routine */
137loopstop:
138        b       loopstop
139
140/*
141 * bssclr - zero out bss
142 */
143bssclr:
144        lwz     r4, bss_addr-base_addr(r1)      /* Start of bss */
145        lwz     r5, bss_length-base_addr(r1)    /* Length of bss */
146
147        rlwinm. r5,r5,30,0x3FFFFFFF             /* form length/4 */
148        beqlr                                   /* no bss */
149        mtctr   r5                              /* set ctr reg */
150        xor     r6,r6,r6                        /* r6 = 0 */
151clear_bss:
152        stswi   r6,r4,0x4                       /* store r6 */
153        addi    r4,r4,0x4                       /* update r2 */
154
155        bdnz    clear_bss                       /* dec counter and loop */
156        blr                                     /* return */
157
158        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.