~ubuntu-branches/ubuntu/quantal/silo/quantal

« back to all changes in this revision

Viewing changes to first/fd.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
/* First stage loader bootstrap for both v0, v2 and SUNW,Ultra's IEEE 1275 PROM
 
2
   designed for the romfs.
 
3
   
 
4
   Copyright (C) 1996,1997,1998,2000 Jakub Jelinek
 
5
   
 
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.
 
10
   
 
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.
 
15
 
 
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,
 
19
   USA.  */
 
20
 
 
21
#define BLOCK_START     0x3dc
 
22
#define promvec         %l5
 
23
#define buffer          %l0
 
24
#define fd              %l6
 
25
#define stdouth         %l7
 
26
#define promvers        %l7
 
27
#define dest            %l4
 
28
 
 
29
        .text
 
30
        .align 4
 
31
        .global _start, letter_here, digit_here
 
32
 
 
33
_start:
 
34
bootmain:
 
35
        tst     %o4
 
36
        be      sparc_v8
 
37
        sethi   %hi(0x4000), buffer
 
38
        or      buffer, (BLOCK_START + 3 * 512), %i5
 
39
        sethi   %hi(0x10000), dest
 
40
        mov     %o4, promvec
 
41
 
 
42
        add     buffer, %lo(chosen), %o1
 
43
        call    prom11
 
44
         add    buffer, %lo(finddevice), %o0
 
45
        ldx     [dest + 32], fd
 
46
        call    getprop
 
47
         add    buffer, %lo(stdout), %o0
 
48
        lduw    [dest + 256], stdouth
 
49
        call    putchar
 
50
         mov    'S', %o0
 
51
        call    getprop
 
52
         add    buffer, %lo(bootpath), %o0
 
53
        add     dest, 256, %o0
 
54
        mov     ':', %o4
 
55
2:
 
56
        ldub    [%o0], %o3
 
57
        brz,pn  %o3, 3f
 
58
         cmp    %o3, %o4
 
59
        bne,a,pt %icc, 2b
 
60
         inc    %o0
 
61
3:
 
62
        stb     %o4, [%o0]
 
63
letter_here:
 
64
        mov     0xDD, %o4
 
65
        stb     %o4, [%o0 + 1]
 
66
        stb     %g0, [%o0 + 2]
 
67
        add     dest, 256, %o1
 
68
        call    prom11
 
69
         add    buffer, %lo(open), %o0
 
70
 
 
71
        ldx     [dest + 32], fd
 
72
        or      buffer, BLOCK_START, %l2
 
73
 
 
74
        lduw    [%l2], %l3
 
75
        add     %l3, 4, %l3
 
76
        sll     %l3, 9, %o3
 
77
        srl     %l3, 23, %o2
 
78
        call    rwprom31
 
79
         add    buffer, %lo(seek), %o0
 
80
        ldx     [dest + 48], %o0
 
81
        brlz,pn %o0, 9f
 
82
         lduw   [%l2 - 4], %l3
 
83
 
 
84
        call    putchar
 
85
         mov    'I', %o0
 
86
 
 
87
        sub     %l3, 2048, %l3
 
88
        mov     %l3, %o3
 
89
        add     dest, 1024, %o2
 
90
        call    rwprom31
 
91
         add    buffer, %lo(read), %o0
 
92
        ldx     [dest + 48], %o0
 
93
        cmp     %o0, %l3
 
94
        bne,pn  %icc, 9f
 
95
         mov    fd, %o1
 
96
 
 
97
        call    prom11
 
98
         add    buffer, %lo(close), %o0
 
99
        ldub    [dest + 1024 + 0x08], %o0
 
100
        cmp     %o0, 'L'
 
101
        bne,a,pn %icc, 10f
 
102
         add    buffer, %lo(exit), %o0
 
103
 
 
104
        call    putchar
 
105
         flush  dest + 1024
 
106
 
 
107
        mov     promvec, %o4
 
108
        jmpl    dest + 1024, %g0
 
109
         clr    %l3
 
110
putchar:
 
111
        stb     %o0, [buffer]
 
112
        mov     stdouth, %o1
 
113
        mov     buffer, %o2
 
114
        mov     1, %o3
 
115
        ba,pt   %xcc, prom31
 
116
         add    buffer, %lo(write), %o0
 
117
9:
 
118
        add     buffer, %lo(exit), %o0
 
119
10:
 
120
        call    prom11
 
121
getprop:
 
122
         stx    %o0, [dest + 32]
 
123
        add     dest, 256, %o0
 
124
        stx     %o0, [dest + 40]
 
125
        mov     1024, %o0
 
126
        stx     %o0, [dest + 48]
 
127
        mov     fd, %o1
 
128
        add     buffer, %lo(getprops), %o0
 
129
        mov     4, %o2
 
130
        stx     %o2, [dest + 8]
 
131
2:
 
132
        ba,pt   %xcc, 1f
 
133
prom11:
 
134
         mov    1, %o2
 
135
        stx     %o2, [dest + 8]
 
136
1:
 
137
        stx     %o0, [dest]
 
138
        stx     %o2, [dest + 16]
 
139
        stx     %o1, [dest + 24]
 
140
        jmpl    promvec + %g0, %g0
 
141
         mov    dest, %o0
 
142
rwprom31:
 
143
        mov     fd, %o1
 
144
prom31:
 
145
        mov     3, %o4
 
146
        stx     %o4, [dest + 8]
 
147
        stx     %o2, [dest + 32]
 
148
        ba,pt   %xcc, 2b
 
149
         stx    %o3, [dest + 40]
 
150
 
 
151
finddevice:
 
152
        .asciz  "finddevice"
 
153
getprops:
 
154
        .asciz  "getprop"
 
155
bootpath:
 
156
        .asciz  "bootpath"
 
157
stdout:
 
158
        .asciz  "stdout"
 
159
open:
 
160
        .asciz  "open"
 
161
close:
 
162
        .asciz  "close"
 
163
seek:
 
164
        .asciz  "seek"
 
165
read:
 
166
        .asciz  "read"
 
167
write:
 
168
        .asciz  "write"
 
169
chosen:
 
170
        .asciz  "/chosen"
 
171
exit:
 
172
        .asciz  "exit"
 
173
 
 
174
        .align  512
 
175
sparc_v8:
 
176
        mov     %o0, promvec
 
177
        ld      [promvec+4], promvers
 
178
        sethi   %hi(0x4000), buffer
 
179
        sethi   %hi(0x10000), dest
 
180
        call    putchar_v8
 
181
         mov    'S', %o0
 
182
 
 
183
        tst     promvers
 
184
        bne,a   1f
 
185
         ld     [promvec+136], %o0              ! pv_v2bootargs.bootpath
 
186
 
 
187
        ld      [promvec+128], %o0
 
188
        ld      [%o0], %o3                      ! o3 = *pv_v0bootargs
 
189
        lduh    [%o3+132], %o1                  ! 'sd', 'fd' or whatever
 
190
        sll     %o1, 8, %o1
 
191
        or      %o1, '(', %o1
 
192
        sll     %o1, 8, %o1
 
193
        ld      [%o3+136], %o0                  ! controler id (hope it is less than 10)
 
194
        add     %o0, '0', %o0
 
195
        or      %o1, %o0, %o2
 
196
        mov     ',', %o1
 
197
        sll     %o1, 8, %o1
 
198
        ld      [%o3+140], %o4                  ! unit id (again, hope nobody uses wide on v0 prom)
 
199
        add     %o4, '0', %o4
 
200
        or      %o4, %o1, %o4
 
201
        sll     %o4, 16, %o4
 
202
        or      %o4, %o1, %o4
 
203
digit_here:
 
204
        or      %o4, 0xDD, %o3
 
205
        std     %o2, [buffer + 0x400]           ! put the 'sd(i,j,k' somewhere...
 
206
        mov     ')', %o2
 
207
        sll     %o2, 8, %o2
 
208
        sth     %o2, [buffer + 0x408]           ! put there the rest ')\0' as well...
 
209
        b       4f
 
210
        ld      [promvec+36], %o1               ! pv_v0devops.v0_devopen
 
211
1:
 
212
        ld      [promvec+172], %o1
 
213
        ld      [%o0], %o0
 
214
        add     buffer, 0x400, %o2
 
215
        mov     ':', %o4
 
216
2:
 
217
        ldub    [%o0], %o3
 
218
        tst     %o3
 
219
        be      3f
 
220
         cmp    %o3, %o4
 
221
 
 
222
        be      3f
 
223
         stb    %o3, [%o2]
 
224
        add     %o2, 1, %o2
 
225
        b       2b
 
226
         add    %o0, 1, %o0
 
227
3:
 
228
        stb     %o4, [%o2]
 
229
        ldub    [buffer + (letter_here - _start + 3)], %o4
 
230
        stb     %o4, [%o2 + 1]
 
231
        stb     %g0, [%o2 + 2]
 
232
4:
 
233
        call    %o1
 
234
         add    buffer, 0x400, %o0
 
235
 
 
236
        mov     %o0, fd
 
237
        or      buffer, BLOCK_START, %l2
 
238
 
 
239
        ld      [%l2], %l3
 
240
        tst     promvers
 
241
        bne     6f
 
242
         add    %l3, 4, %l3
 
243
        ld      [promvec+44], %o4               ! pv_v0devops.v0_rdblkdev
 
244
        ld      [%l2 - 4], %l2
 
245
        srl     %l2, 9, %l2
 
246
        sub     %l2, 4, %l2
 
247
        mov     %l2, %o1
 
248
        mov     %l3, %o2
 
249
        mov     dest, %o3
 
250
        call    %o4
 
251
         mov    fd, %o0
 
252
        mov     %o0, %l3
 
253
        
 
254
        call    putchar_v8
 
255
         mov    'I', %o0
 
256
 
 
257
        cmp     %l3, %l2
 
258
        b,a     0f
 
259
6:
 
260
        ld      [promvec+188], %o4              ! pv_v2devops.v2_dev_seek
 
261
        mov     %g0, %o1
 
262
        sll     %l3, 9, %o2
 
263
        call    %o4
 
264
         mov    fd, %o0
 
265
        cmp     %o0, -1
 
266
        be      9f
 
267
         ld     [%l2 - 4], %l3
 
268
        call    putchar_v8
 
269
         mov    'I', %o0
 
270
 
 
271
        ld      [promvec+180], %o4              ! pv_v2devops.v2_dev_read
 
272
        sub     %l3, 2048, %l3
 
273
        mov     %l3, %o2
 
274
        mov     dest, %o1
 
275
        call    %o4
 
276
         mov    fd, %o0
 
277
        cmp     %o0, %l3
 
278
0:
 
279
        bne     9f
 
280
         ldub   [dest + 0x08], %o0
 
281
        cmp     %o0, 'L'
 
282
        bne     9f
 
283
         clr    %l3
 
284
 
 
285
        call    putchar_v8
 
286
         ld     [promvec+176], %l1              ! pv_v2devops.v2_dev_close
 
287
 
 
288
        tst     promvers
 
289
        be,a    8f
 
290
         ld     [promvec+40], %l1               ! pv_v0devops.v0_dev_close
 
291
8:
 
292
        call    %l1
 
293
         mov    fd, %o0
 
294
        clr     %o4                             ! we are not an Ultra
 
295
        jmpl    dest + %g0, %g0
 
296
         mov    promvec, %o0
 
297
9:
 
298
        ld      [promvec+116], %g1
 
299
        jmpl    %g1 + %g0, %g0
 
300
putchar_v8:
 
301
        tst     promvers
 
302
        bne     1f
 
303
         ld     [promvec+92], %o1               ! pv_nbputchar
 
304
 
 
305
        jmpl    %o1 + %g0, %g0
 
306
         or     buffer, (BLOCK_START + 3 * 512), %i5
 
307
1:
 
308
        stb     %o0, [buffer]
 
309
        ld      [promvec+148], %o0              ! pv_v2bootargs.fd_stdout
 
310
        ld      [promvec+184], %o3              ! pv_v2devops.v2_dev_write
 
311
        mov     buffer, %o1
 
312
        ld      [%o0], %o0
 
313
        mov     1, %o2
 
314
        jmpl    %o3 + %g0, %g0
 
315
         or     buffer, (BLOCK_START + 3 * 512), %i5