source: rtems/c/src/lib/libbsp/powerpc/score603e/start/start.S @ 820d1ab0

4.104.115
Last change on this file since 820d1ab0 was 820d1ab0, checked in by Chris Johns <chrisj@…>, on 04/28/09 at 06:34:00

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

  • start/start.S: Update for boot_card command line change.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * This is based on the mvme-crt0.S file from libgloss/rs6000.
3 * crt0.S -- startup file for PowerPC systems.
4 *
5 * Copyright (c) 1995 Cygnus Support
6 *
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice is included verbatim in any distributions. No written agreement,
11 * license, or royalty fee is required for any of the authorized uses.
12 * Modifications to this software may be copyrighted by their authors
13 * and need not follow the licensing terms described here, provided that
14 * the new terms are clearly indicated on the first page of each file where
15 * they apply.
16 *
17 *  $Id$
18 */
19
20#warning Call to boot_card has changed and needs checking.
21#warning The call is "void boot_card(const char* cmdline);"
22#warning You need to pass a NULL.
23#warning Please check and remove these warnings.
24       
25#include "ppc-asm.h"
26
27        .file   "start.s"
28        .section ".got2","aw"
29        .align  2
30
31.LCTOC1 = .+32768
32
33        .extern FUNC_NAME(atexit)
34        .globl  FUNC_NAME(__atexit)
35        .section ".sdata","aw"
36        .align  2
37FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
38        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
39
40        .section ".fixup","aw"
41        .align  2
42        .long   FUNC_NAME(__atexit)
43
44        .section ".got2","aw"
45.Ltable = .-.LCTOC1
46        .long   .LCTOC1                 /* address we think .LCTOC1 is loaded at */
47
48.Lbss_start = .-.LCTOC1
49        .long   _edata                 /* includes sbss and bss */
50
51.Lend = .-.LCTOC1
52        .long   _end
53
54.Lstack = .-.LCTOC1                     /* stack address if set by user */
55        .long   __stack
56
57        .text
58.Lptr:
59        .long .LCTOC1-.Laddr
60
61        .globl  _start
62        .type   _start,@function
63_start:
64        b       past_constants
65                                        /* Set MSR */
66        .long   _etext                  /* end of code space */
67        .long   _edata                  /* end of code and data space */
68
69past_constants:
70        lis     r5,0
71        mr      r4,r5
72        ori     r4,r4,0x0000            /* 0x2030  */
73        mtmsr   r4
74
75        /* The first generation board needed initialization here but the */
76        /* second does not. */
77
78        bl      .Laddr                  /* get current address */
79.Laddr:
80        mflr    r4                      /* real address of .Laddr */
81        lwz     r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
82        add     r5,r5,r4                /* correct to real pointer */
83        lwz     r4,.Ltable(r5)          /* get linker's idea of where .Laddr is */
84        subf    r4,r4,r5                /* calculate difference between where linked and current */
85
86        /* clear bss */
87        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
88        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
89        add     r6,r6,r4                /* adjust pointers */
90        add     r7,r7,r4
91
92        cmplw   1,r6,r7
93        bc      4,4,.Ldone
94
95        subf    r8,r6,r7                /* number of bytes to zero */
96        srwi    r9,r8,2                 /* number of words to zero */
97        mtctr   r9
98        li      r0,0                    /* zero to clear memory */
99        addi    r6,r6,-4                /* adjust so we can use stwu */
100.Lloop:
101        stwu    r0,4(r6)                /* zero bss */
102        bdnz    .Lloop
103
104.Ldone:
105
106        lwz     r0,.Lstack(r5)          /* stack address or 0 */
107        cmplwi  1,r0,0                  /* equal to 0? */
108        bc      12,6,.Lnostack          /* use default stack if == 0 */
109        mr      sp,r0                   /* use user defined stack */
110
111.Lnostack:
112
113        lis     r13,_SDA_BASE_@ha
114        la      r13,_SDA_BASE_@l(r13)           /* Read-write small data */
115
116        /* set up initial stack frame */
117        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
118        lis     r0,0
119        stw     r0,0(sp)                /* clear back chain */
120        stwu    sp,-56(sp)              /* push another stack frame */
121
122        li      r3, 0                   /* command line */
123        /* Let her rip */
124        bl      FUNC_NAME(boot_card)
125
126        /* return value from boot_card is argument to exit */
127        bl      FUNC_NAME(exit)
128        trap
129.Lstart:
130        .size   _start,.Lstart-_start
Note: See TracBrowser for help on using the repository browser.