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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [linux-2.6/] [linux-2.6.24/] [arch/] [powerpc/] [boot/] [crt0.S] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 xianfeng
/*
2
 * Copyright (C) Paul Mackerras 1997.
3
 *
4
 * This program is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU General Public License
6
 * as published by the Free Software Foundation; either version
7
 * 2 of the License, or (at your option) any later version.
8
 *
9
 * NOTE: this code runs in 32 bit mode and is packaged as ELF32.
10
 */
11
 
12
#include "ppc_asm.h"
13
 
14
        .text
15
        /* a procedure descriptor used when booting this as a COFF file */
16
        .globl  _zimage_start_opd
17
_zimage_start_opd:
18
        .long   _zimage_start, 0, 0, 0
19
 
20
        .weak   _zimage_start
21
        .globl  _zimage_start
22
_zimage_start:
23
        .globl  _zimage_start_lib
24
_zimage_start_lib:
25
        /* Work out the offset between the address we were linked at
26
           and the address where we're running. */
27
        bl      1f
28
1:      mflr    r0
29
        lis     r9,1b@ha
30
        addi    r9,r9,1b@l
31
        subf.   r0,r9,r0
32
        beq     3f              /* if running at same address as linked */
33
 
34
        /* The .got2 section contains a list of addresses, so add
35
           the address offset onto each entry. */
36
        lis     r9,__got2_start@ha
37
        addi    r9,r9,__got2_start@l
38
        lis     r8,__got2_end@ha
39
        addi    r8,r8,__got2_end@l
40
        subf.   r8,r9,r8
41
        beq     3f
42
        srwi.   r8,r8,2
43
        mtctr   r8
44
        add     r9,r0,r9
45
2:      lwz     r8,0(r9)
46
        add     r8,r8,r0
47
        stw     r8,0(r9)
48
        addi    r9,r9,4
49
        bdnz    2b
50
 
51
        /* Do a cache flush for our text, in case the loader didn't */
52
3:      lis     r9,_start@ha
53
        addi    r9,r9,_start@l
54
        add     r9,r0,r9
55
        lis     r8,_etext@ha
56
        addi    r8,r8,_etext@l
57
        add     r8,r0,r8
58
4:      dcbf    r0,r9
59
        icbi    r0,r9
60
        addi    r9,r9,0x20
61
        cmplw   cr0,r9,r8
62
        blt     4b
63
        sync
64
        isync
65
 
66
        /* Clear the BSS */
67
        lis     r9,__bss_start@ha
68
        addi    r9,r9,__bss_start@l
69
        add     r9,r0,r9
70
        lis     r8,_end@ha
71
        addi    r8,r8,_end@l
72
        add     r8,r0,r8
73
        li      r10,0
74
5:      stw     r10,0(r9)
75
        addi    r9,r9,4
76
        cmplw   cr0,r9,r8
77
        blt     5b
78
 
79
        /* Possibly set up a custom stack */
80
.weak   _platform_stack_top
81
        lis     r8,_platform_stack_top@ha
82
        addi    r8,r8,_platform_stack_top@l
83
        cmpwi   r8,0
84
        beq     6f
85
        add     r8,r0,r8
86
        lwz     r1,0(r8)
87
        add     r1,r0,r1
88
        li      r0,0
89
        stwu    r0,-16(r1)      /* establish a stack frame */
90
6:
91
 
92
        /* Call platform_init() */
93
        bl      platform_init
94
 
95
        /* Call start */
96
        b       start

powered by: WebSVN 2.1.0

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