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

« back to all changes in this revision

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