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
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
41
/* Jump to relocated code */
43
jmpl %i0 + (jumphere - _start), %g0
44
or %l0, %lo(_end), %l0 ! %l0 = _end
52
sub %l0, %i1, %i2 ! %i2 = BSS length
67
tst %o4 ! if not Ultra,
68
be 1f ! skip %pstate modification
81
! Call cd_main() to start the whole thingie up
84
mov %i6, %o2 ! Cif sp on sun4u
85
mov %i4, %o1 ! Cif handler on sun4u
87
mov %i0, %o0 ! Prom vector or cifh on sun4m
90
jmpl %o0 + %g0, %g0 ! Jump to return address from cd_main()
93
/* l0 from, l1 to, l2 len, l7 ret. Returns from + len in l0 */
112
tst %i4 /* quit unless it's Sun4u */
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.
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.
135
srlx %l0, (32 + 16), %l1
139
srlx %l0, (32 + 16), %l1
141
bgeu,pt %xcc, 0f /* quit if Ultra-III or derivative */
146
sethi %hi(0x40003), %l1
147
or %l1, %lo(0x40003), %l1
149
be 0f /* quit if HAL SPARC64-III */
151
sethi %hi(0x40004), %l1
152
or %l1, %lo(0x40004), %l1
154
be 0f /* quit if HAL SPARC64-IV */
157
sethi %hi(16384), %l1
158
stxa %g0, [%l0] 0x67 /* ASI_IC_TAG */
163
stxa %g0, [%l0] 0x67 /* ASI_IC_TAG */