1
/* First stage loader bootstrap for flash of a JavaStation.
3
Copyright (C) 1996,1997,2000 Jakub Jelinek
4
Copyright (C) 1999,2000 Pete Zaitcev
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21
#define BLOCK_START 0x300 /* We are not a.out, so can use anything */
22
#include "ieee32.h" /* IEEE32_OFFSET */
23
#define LOAD_OFF 1024 /* Skip PROM interface buffer */
37
sethi %hi(0x4000), buffer
39
1: sethi %hi(0x10000), dest
42
add buffer, %lo(chosen), %o1
44
add buffer, %lo(finddevice), %o0
48
add buffer, %lo(stdout), %o0
49
ld [dest + 256], stdouth
55
* Get phandle of flash memory.
56
* Unlike other first stage loaders
57
* we do not use "/chosen"."bootpath" value.
58
* It's a feature, not a bug.
60
add buffer, %lo(flashs), %o1
62
add buffer, %lo(finddevice), %o0
63
ld [dest + 16], fd /* phandle of /flash-memory */
66
* Get "reg". We use it to find the base address,
67
* which is different for 4MB, 8MB and 16MB SIMMs.
70
add buffer, %lo(regs), %o0
71
ld [dest + 260], %i2 /* 20400000 for 8MB SIMM */
74
* Load 4 blocks of second stage loader with the map,
75
* then all other blocks at 0x10000 (dest).
76
* First of them will have an 'L' header embedded.
78
or buffer, BLOCK_START, %l1
79
add %l1, (3 * 512), %i5 /* Will read 4 blocks of block map */
82
* But before we start the loop, get the block 0 number.
83
* In other loaders we get it for free when 16 blocks of
84
* bootstrap are loaded. In flash it is outside of ELF.
86
add %i2, IEEE32_OFFSET, %i4
95
sll %i3, 9, %o3 /* Convert blocks into bytes */
96
/* srl %i3, 23, %o2 */ /* %o2 and %o3 make an 41 bits offset */
100
* We use ASI=20 (BYPASS) to spare remapping work. Lazy, but works.
101
* We do not unroll the loop because flash is slow and RAM is tight.
103
mov 512, %i0 /* running cnt */
104
mov %l1, %i1 /* running dest */
105
add %i2, %o3, %i4 /* running source (physical addr) */
106
/* We conviniently ignore upper bits of offset for flash is small. */
123
add dest, LOAD_OFF, %l1
126
ldub [dest + LOAD_OFF + 0x08], %o0
132
/* flush dest + LOAD_OFF */ /* XXX Write-through cache on IIep */
134
clr %o4 /* Important - not Ultra */
135
or promvec, 1, %o0 /* XXX Gross... */
137
jmpl dest + LOAD_OFF, %g0
141
add buffer, %lo(exits), %o0
146
* getprop(node:fd, name:%o0) {
147
* cif_handler:promvec("getprops", node, name, dest+256, 1024);
151
add buffer, %lo(getprops), %o2
163
jmpl promvec + %g0, %g0
173
ba prom31 /* one of many tail recustion -O's */
174
add buffer, %lo(write), %o0
185
jmpl promvec + %g0, %g0
200
jmpl promvec + %g0, %g0
216
.asciz "/flash-memory"