1
/* Linux SPARC/UltraSPARC Loader Bootstrap
3
Copyright (C) 1996,1997,1998,2000 Jakub Jelinek
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.
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.
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,
24
#define COPY jmpl %o7 + (copy - _start), %l7
28
.global silo_conf, silo_conf_part, boot_part
29
.global raid_dsk_number, silo_conf_parts, boot_parts
34
.byte 'L' ! This is for the primary loader to check if we are ok... :)
50
1: /* First store %l3 to raid_dsk_number */
51
stb %l3, [%l0 + (raid_dsk_number - _start)]
52
/* Move ourselves up - there are three chunks to move. */
56
sethi %hi(0x100000), %i3
57
1: set main_text_start, %l3
64
set main_rodata_start, %l3
65
set main_text_end, %l4
70
set main_data_start, %l3
71
set main_rodata_end, %l4
76
set __bss_start + 16, %i1
77
set main_data_end, %l4
83
sethi %hi(gzminpi), %l1
85
st %l0, [%l1 + %lo(gzminpi)]
87
/* Jump to relocated code */
89
jmpl %i0 + (jumphere - _start), %g0
90
or %l0, %lo(_end), %l0 ! %l0 = _end
98
sub %l0, %i1, %i2 ! %i2 = BSS length
113
tst %o4 ! if not Ultra,
114
be 1f ! skip %pstate modification
128
sethi %hi(gzminpi+0x100000), %l0
129
ld [%l0 + %lo(gzminpi)], %l1
130
sethi %hi(LARGE_RELOC), %l2
140
2: sethi %hi(LARGE_RELOC), %l2
150
4: st %l1, [%l0 + %lo(gzminpi)]
152
! Call my_main() to start the whole thingie up
155
mov %i6, %o2 ! Cif sp on sun4u
156
mov %i4, %o1 ! Cif handler on sun4u
158
mov %i0, %o0 ! Prom vector or cifh on sun4m
161
jmpl %o0 + %g0, %g0 ! Jump to return address from my_main()
164
/* l0 from, l1 to, l2 len, l7 ret. Returns from + len in l0 */
183
tst %i4 /* quit unless it's Sun4u */
187
/* Careful, we cannot read the %ver register on sun4v because
188
* there that register is hyperprivileged and we are executing
189
* in privileged mode.
191
* This early on it's difficult to portably detect sun4v as
192
* that requires OBP calls. So do this super-ugly trick of
193
* trying to set the PSTATE_AG bit in %pstate which will read
194
* back as zero on sun4u.
206
srlx %l0, (32 + 16), %l1
210
srlx %l0, (32 + 16), %l1
212
bgeu,pt %xcc, 0f /* quit if Ultra-III or derivative */
217
sethi %hi(0x40003), %l1
218
or %l1, %lo(0x40003), %l1
220
be 0f /* quit if HAL SPARC64-III */
222
sethi %hi(0x40004), %l1
223
or %l1, %lo(0x40004), %l1
225
be 0f /* quit if HAL SPARC64-IV */
228
sethi %hi(16384), %l1
229
stxa %g0, [%l0] 0x67 /* ASI_IC_TAG */
234
stxa %g0, [%l0] 0x67 /* ASI_IC_TAG */