OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [psim/] [start/] [start.S] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: start.S,v 1.2 2001-09-27 12:01:02 chris Exp $
18
 */
19
 
20
#include "ppc-asm.h"
21
 
22
        .file   "startsim.s"
23
        .section ".got2","aw"
24
        .align  2
25
 
26
.LCTOC1 = .+32768
27
 
28
        .extern FUNC_NAME(atexit)
29
        .globl  FUNC_NAME(__atexit)
30
        .section ".sdata","aw"
31
        .align  2
32
FUNC_NAME(__atexit):                    /* tell C's eabi-ctor's we have an atexit function */
33
        .long   FUNC_NAME(atexit)@fixup /* and that it is to register __do_global_dtors */
34
 
35
        .section ".fixup","aw"
36
        .align  2
37
        .long   FUNC_NAME(__atexit)
38
 
39
        .section ".got2","aw"
40
.Ltable = .-.LCTOC1
41
        .long   .LCTOC1                 /* address we think .LCTOC1 is loaded at */
42
 
43
.Lbss_start = .-.LCTOC1
44
        .long   __bss_start
45
 
46
.Lend = .-.LCTOC1
47
        .long   _end
48
 
49
.Lstack = .-.LCTOC1                     /* stack address if set by user */
50
        .long   __stack
51
 
52
        .text
53
.Lptr:
54
        .long .LCTOC1-.Laddr
55
 
56
        .globl  _start
57
        .type   _start,@function
58
_start:
59
        bl      .Laddr                  /* get current address */
60
.Laddr:
61
        mflr    r4                      /* real address of .Laddr */
62
        lwz     r5,(.Lptr-.Laddr)(r4)   /* linker generated address of .LCTOC1 */
63
        add     r5,r5,r4                /* correct to real pointer */
64
        lwz     r4,.Ltable(r5)          /* get linker's idea of where .Laddr is */
65
        subf    r4,r4,r5                /* calculate difference between where linked and current */
66
 
67
        /* clear bss */
68
        lwz     r6,.Lbss_start(r5)      /* calculate beginning of the BSS */
69
        lwz     r7,.Lend(r5)            /* calculate end of the BSS */
70
        add     r6,r6,r4                /* adjust pointers */
71
        add     r7,r7,r4
72
 
73
        cmplw   1,r6,r7
74
        bc      4,4,.Ldone
75
 
76
        subf    r8,r6,r7                /* number of bytes to zero */
77
        srwi    r9,r8,2                 /* number of words to zero */
78
        mtctr   r9
79
        li      r0,0                    /* zero to clear memory */
80
        addi    r6,r6,-4                /* adjust so we can use stwu */
81
.Lloop:
82
        stwu    r0,4(r6)                /* zero bss */
83
        bdnz    .Lloop
84
 
85
.Ldone:
86
 
87
        lwz     r0,.Lstack(r5)          /* stack address or 0 */
88
        cmplwi  1,r0,0                  /* equal to 0? */
89
        bc      12,6,.Lnostack          /* use default stack if == 0 */
90
        mr      sp,r0                   /* use user defined stack */
91
 
92
.Lnostack:
93
        /* set up initial stack frame */
94
        addi    sp,sp,-4                /* make sure we don't overwrite debug mem */
95
        lis     r0,0
96
        stw     r0,0(sp)                /* clear back chain */
97
        stwu    sp,-56(sp)              /* push another stack frame */
98
 
99
        /* Let her rip */
100
        bl      FUNC_NAME(boot_card)
101
 
102
        /* return value from boot_card is argument to exit */
103
        bl      FUNC_NAME(exit)
104
        trap
105
.Lstart:
106
        .size   _start,.Lstart-_start

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.