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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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