~ubuntu-branches/ubuntu/hardy/silo/hardy-proposed

« back to all changes in this revision

Viewing changes to first-isofs/crt0.S

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2007-10-25 09:28:08 UTC
  • mfrom: (15.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071025092808-1yhj12t7s4zqsfu5
Tags: 1.4.13a+git20070930-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build with -fno-stack-protector.
  - Change silo.postinst to automatically update the boot block without
    invoking siloconfig and keep asking questions on upgrades.
  - Convert silo.conf to use /dev/disk/by-uuid.
  - Ubuntu maintainer foobar.
  - Fix debian/rules call to dh_installdocs.
  - Drop the requirement of gcc-4.1 and start using default gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Linux SPARC/UltraSPARC Loader Bootstrap
 
2
 
 
3
   Copyright (C) 1996,1997,1998,2000 Jakub Jelinek
 
4
                 1998 Jan Vondrak
 
5
                 1996 Pete A. Zaitcev
 
6
                 1996 Miguel de Icaza
 
7
                 2001,2003 Ben Collins
 
8
 
 
9
   This program is free software; you can redistribute it and/or modify
 
10
   it under the terms of the GNU General Public License as published by
 
11
   the Free Software Foundation; either version 2 of the License, or
 
12
   (at your option) any later version.
 
13
   
 
14
   This program is distributed in the hope that it will be useful,
 
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
   GNU General Public License for more details.
 
18
 
 
19
   You should have received a copy of the GNU General Public License
 
20
   along with this program; if not, write to the Free Software
 
21
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
22
   USA.  */
 
23
 
 
24
#define COPY    jmpl    %o7 + (copy - _start), %l7
 
25
 
 
26
        .text
 
27
        .global _start
 
28
        .align  16
 
29
_start:
 
30
        call    1f
 
31
         mov    %o7, %l0
 
32
 
 
33
1:
 
34
        /* Move ourselves up */                 ! %l0 = original start
 
35
        set     __bss_start + 16, %i1           ! %i1 = original end
 
36
        set     _start, %l1                     ! %i0 = %l1 = relocated start
 
37
        mov     %l1, %i0                        ! %l2 = code length
 
38
        COPY
 
39
         sub    %i1, %l1, %l2
 
40
 
 
41
        /* Jump to relocated code */
 
42
        sethi   %hi(_end), %l0
 
43
        jmpl    %i0 + (jumphere - _start), %g0
 
44
         or     %l0, %lo(_end), %l0             ! %l0 = _end
 
45
 
 
46
        .align  32
 
47
jumphere:
 
48
        /* Clear BSS */
 
49
5:      add     %l0, %i3, %l0
 
50
        add     %i1, %i3, %i1
 
51
        andcc   %i1, 4, %g0
 
52
        sub     %l0, %i1, %i2                   ! %i2 = BSS length
 
53
        be      1f
 
54
         mov    %g0, %g1
 
55
 
 
56
        st      %g0, [%i1]
 
57
        add     %i1, 4, %i1
 
58
1:
 
59
        subcc   %i2, 32, %i2
 
60
        std     %g0, [%i1]
 
61
        std     %g0, [%i1 + 8]
 
62
        std     %g0, [%i1 + 16]
 
63
        std     %g0, [%i1 + 24]
 
64
        bgu     1b
 
65
         add    %i1, 32, %i1
 
66
 
 
67
        tst     %o4                             ! if not Ultra,
 
68
        be      1f                              ! skip %pstate modification
 
69
         nop
 
70
 
 
71
        rdpr    %pstate, %l1
 
72
        or      %l1, 8, %l1
 
73
        wrpr    %l1, 0, %pstate
 
74
1:
 
75
 
 
76
        ! Set up a stack
 
77
setup_stack:
 
78
        set     0x400000, %l1
 
79
        save    %l1, -64, %sp
 
80
 
 
81
        ! Call cd_main() to start the whole thingie up
 
82
 
 
83
0:      call    flush_icache
 
84
         mov    %i6, %o2                        ! Cif sp on sun4u
 
85
        mov     %i4, %o1                        ! Cif handler on sun4u
 
86
        call    cd_main
 
87
         mov    %i0, %o0                        ! Prom vector or cifh on sun4m
 
88
        call    flush_icache
 
89
         nop
 
90
        jmpl    %o0 + %g0, %g0                  ! Jump to return address from cd_main()
 
91
         restore
 
92
 
 
93
/* l0 from, l1 to, l2 len, l7 ret. Returns from + len in l0 */
 
94
copy:
 
95
        ld      [%l0], %l3
 
96
        ld      [%l0 + 4], %l4
 
97
        ld      [%l0 + 8], %l5
 
98
        ld      [%l0 + 12], %l6
 
99
        subcc   %l2, 16, %l2
 
100
        add     %l0, 16, %l0
 
101
        st      %l3, [%l1]
 
102
        st      %l4, [%l1 + 4]
 
103
        st      %l5, [%l1 + 8]
 
104
        st      %l6, [%l1 + 12]
 
105
        bgu     copy
 
106
         add    %l1, 16, %l1
 
107
 
 
108
        jmpl    %l7 + 8, %g0
 
109
         nop
 
110
 
 
111
flush_icache:
 
112
        tst     %i4                     /* quit unless it's Sun4u */
 
113
        be      0f
 
114
         nop
 
115
 
 
116
        /* Careful, we cannot read the %ver register on sun4v because
 
117
         * there that register is hyperprivileged and we are executing
 
118
         * in privileged mode.
 
119
         *
 
120
         * This early on it's difficult to portably detect sun4v as
 
121
         * that requires OBP calls.  So do this super-ugly trick of
 
122
         * trying to set the PSTATE_AG bit in %pstate which will read
 
123
         * back as zero on sun4u.
 
124
         */
 
125
        rdpr    %pstate, %l0
 
126
        or      %l0, 0x1, %l1
 
127
        wrpr    %l1, %pstate
 
128
        rdpr    %pstate, %l1
 
129
        wrpr    %l0, %pstate
 
130
        andcc   %l1, 0x1, %g0
 
131
        be,pn   %xcc, 0f
 
132
         nop
 
133
 
 
134
        rdpr    %ver, %l0
 
135
        srlx    %l0, (32 + 16), %l1
 
136
        cmp     %l1, 0x3e
 
137
        bne,pt  %xcc, 99f
 
138
         sllx   %l0, 16, %l0
 
139
        srlx    %l0, (32 + 16), %l1
 
140
        cmp     %l1, 0x14
 
141
        bgeu,pt %xcc, 0f                /* quit if Ultra-III or derivative */
 
142
         nop
 
143
99:
 
144
        rdpr    %ver, %l0
 
145
        srlx    %l0, 32, %l0
 
146
        sethi   %hi(0x40003), %l1
 
147
        or      %l1, %lo(0x40003), %l1
 
148
        cmp     %l0, %l1
 
149
        be      0f                      /* quit if HAL SPARC64-III */
 
150
         nop
 
151
        sethi   %hi(0x40004), %l1
 
152
        or      %l1, %lo(0x40004), %l1
 
153
        cmp     %l0, %l1
 
154
        be      0f                      /* quit if HAL SPARC64-IV */
 
155
         nop
 
156
        clr     %l0
 
157
        sethi   %hi(16384), %l1
 
158
        stxa    %g0, [%l0] 0x67         /* ASI_IC_TAG */
 
159
1:
 
160
        add     %l0, 32, %l0
 
161
        cmp     %l0, %l1
 
162
        blu,a,pt %xcc, 1b
 
163
         stxa   %g0, [%l0] 0x67         /* ASI_IC_TAG */
 
164
0:
 
165
        retl
 
166
         nop
 
167
 
 
168
        .section        ".rodata"
 
169
        .word   _start