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

4.11
Last change on this file since ce134f74 was ce134f74, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 2, 2014 at 5:30:01 PM

score603e/start/start.S: Add start symbol to eliminate warning

  • Property mode set to 100644
File size: 3.4 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
18#include "ppc-asm.h"
19
20        .file   "start.s"
21        .section ".got2","aw"
22        .align  2
23
24.LCTOC1 = .+32768
25
26        .extern FUNC_NAME(atexit)
27        .globl  FUNC_NAME(__atexit)
28        .section ".sdata","aw"
29        .align  2
30FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
31        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
32
33        .section ".fixup","aw"
34        .align  2
35        .long   FUNC_NAME(__atexit)
36
37        .section ".got2","aw"
38.Ltable = .-.LCTOC1
39        .long   .LCTOC1                 /* address we think .LCTOC1 is loaded at */
40
41.Lbss_start = .-.LCTOC1
42        .long   _edata                 /* includes sbss and bss */
43
44.Lend = .-.LCTOC1
45        .long   _end
46
47.Lstack = .-.LCTOC1                     /* stack address if set by user */
48        .long   __stack
49
50        .text
51.Lptr:
52        .long .LCTOC1-.Laddr
53
54        .globl  start
55        .globl  _start
56        .type   start,@function
57        .type   _start,@function
58start:
59_start:
60        b       past_constants
61                                        /* Set MSR */
62        .long   _etext                  /* end of code space */
63        .long   _edata                  /* end of code and data space */
64
65past_constants:
66        lis     r5,0
67        mr      r4,r5
68        ori     r4,r4,0x0000            /* 0x2030  */
69        mtmsr   r4
70
71        /* The first generation board needed initialization here but the */
72        /* second does not. */
73
74        bl      .Laddr                  /* get current address */
75.Laddr:
76        mflr    r4                      /* real address of .Laddr */
77        lwz     r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
78        add     r5,r5,r4                /* correct to real pointer */
79        lwz     r4,.Ltable(r5)          /* get linker's idea of where .Laddr is */
80        subf    r4,r4,r5                /* calculate difference between where linked and current */
81
82        /* clear bss */
83        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
84        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
85        add     r6,r6,r4                /* adjust pointers */
86        add     r7,r7,r4
87
88        cmplw   1,r6,r7
89        bc      4,4,.Ldone
90
91        subf    r8,r6,r7                /* number of bytes to zero */
92        srwi    r9,r8,2                 /* number of words to zero */
93        mtctr   r9
94        li      r0,0                    /* zero to clear memory */
95        addi    r6,r6,-4                /* adjust so we can use stwu */
96.Lloop:
97        stwu    r0,4(r6)                /* zero bss */
98        bdnz    .Lloop
99
100.Ldone:
101
102        lwz     r0,.Lstack(r5)          /* stack address or 0 */
103        cmplwi  1,r0,0                  /* equal to 0? */
104        bc      12,6,.Lnostack          /* use default stack if == 0 */
105        mr      sp,r0                   /* use user defined stack */
106
107.Lnostack:
108
109        lis     r13,_SDA_BASE_@ha
110        la      r13,_SDA_BASE_@l(r13)           /* Read-write small data */
111
112        /* set up initial stack frame */
113        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
114        lis     r0,0
115        stw     r0,0(sp)                /* clear back chain */
116        stwu    sp,-56(sp)              /* push another stack frame */
117
118        li      r3, 0                   /* command line */
119        /* Let her rip */
120        bl      FUNC_NAME(boot_card)
121
122        /* return value from boot_card is argument to exit */
123        bl      FUNC_NAME(exit)
124        trap
125.Lstart:
126        .size   _start,.Lstart-_start
Note: See TracBrowser for help on using the repository browser.