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

« back to all changes in this revision

Viewing changes to first/ultra.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 SUNW,Ultra's IEEE 1275 PROM
 
2
   
 
3
   Copyright (C) 1996,1997,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     0x1dc
 
21
#define promvec         %l5
 
22
#define buffer          %l0
 
23
#define fd              %l6
 
24
#define stdouth         %l7
 
25
#define dest            %l4
 
26
 
 
27
        .text
 
28
        .align 4
 
29
        .global _start, letter_here, number_here
 
30
 
 
31
_start:
 
32
        sethi   %hi(0x4000), buffer
 
33
        or      buffer, (BLOCK_START + 3 * 512), %i5
 
34
        sethi   %hi(0x10000), dest
 
35
        mov     %o4, promvec
 
36
 
 
37
        add     buffer, %lo(chosen), %o1
 
38
        call    prom11
 
39
         add    buffer, %lo(finddevice), %o0
 
40
        ldx     [dest + 32], fd
 
41
        call    getprop
 
42
         add    buffer, %lo(stdout), %o0
 
43
        lduw    [dest + 256], stdouth
 
44
        call    putchar
 
45
         mov    'S', %o0
 
46
        call    getprop
 
47
         add    buffer, %lo(bootpath), %o0
 
48
        add     dest, 256, %o0
 
49
        mov     ':', %o4
 
50
2:
 
51
        ldub    [%o0], %o3
 
52
        brz,pn  %o3, 3f
 
53
         cmp    %o3, %o4
 
54
        bne,a,pt %icc, 2b
 
55
         inc    %o0
 
56
3:
 
57
        stb     %o4, [%o0]
 
58
letter_here:
 
59
        mov     0xDD, %o4
 
60
        stb     %o4, [%o0 + 1]
 
61
        stb     %g0, [%o0 + 2]
 
62
        add     dest, 256, %o1
 
63
        call    prom11
 
64
         add    buffer, %lo(open), %o0
 
65
 
 
66
        ldx     [dest + 32], fd
 
67
        or      buffer, BLOCK_START, %l1
 
68
        mov     %l1, %l2
 
69
5:
 
70
        lduw    [%l2], %l3
 
71
        add     %l2, 4, %l2
 
72
        brz,pn  %l3, 7f
 
73
         sll    %l3, 9, %o3
 
74
        srl     %l3, 23, %o2
 
75
        call    rwprom31
 
76
         add    buffer, %lo(seek), %o0
 
77
        ldx     [dest + 48], %o0
 
78
        brlz,pn %o0, 9f
 
79
         mov    512, %o3
 
80
        mov     %l1, %o2
 
81
        call    rwprom31
 
82
         add    buffer, %lo(read), %o0
 
83
        ldx     [dest + 48], %o0
 
84
        cmp     %o0, 512
 
85
        bne,pn  %icc, 9f
 
86
         cmp    %l1, %i5
 
87
 
 
88
        bne,pt  %xcc, 5b
 
89
         add    %l1, 512, %l1
 
90
 
 
91
        call    putchar
 
92
         mov    'I', %o0
 
93
        ba,pt   %xcc, 5b
 
94
         add    dest, 1024, %l1
 
95
7:
 
96
        mov     fd, %o1
 
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
number_here:
 
110
         mov    0xFF, %l3
 
111
putchar:
 
112
        stb     %o0, [buffer]
 
113
        mov     stdouth, %o1
 
114
        mov     buffer, %o2
 
115
        mov     1, %o3
 
116
        ba,pt   %xcc, prom31
 
117
         add    buffer, %lo(write), %o0
 
118
9:
 
119
        add     buffer, %lo(exit), %o0
 
120
10:
 
121
        call    prom11
 
122
getprop:
 
123
         stx    %o0, [dest + 32]
 
124
        add     dest, 256, %o0
 
125
        stx     %o0, [dest + 40]
 
126
        mov     1024, %o0
 
127
        stx     %o0, [dest + 48]
 
128
        mov     fd, %o1
 
129
        add     buffer, %lo(getprops), %o0
 
130
        mov     4, %o2
 
131
        stx     %o2, [dest + 8]
 
132
2:
 
133
        ba,pt   %xcc, 1f
 
134
prom11:
 
135
         mov    1, %o2
 
136
        stx     %o2, [dest + 8]
 
137
1:
 
138
        stx     %o0, [dest]
 
139
        stx     %o2, [dest + 16]
 
140
        stx     %o1, [dest + 24]
 
141
        jmpl    promvec + %g0, %g0
 
142
         mov    dest, %o0
 
143
rwprom31:
 
144
        mov     fd, %o1
 
145
prom31:
 
146
        mov     3, %o4
 
147
        stx     %o4, [dest + 8]
 
148
        stx     %o2, [dest + 32]
 
149
        ba,pt   %xcc, 2b
 
150
         stx    %o3, [dest + 40]
 
151
 
 
152
finddevice:
 
153
        .asciz  "finddevice"
 
154
getprops:
 
155
        .asciz  "getprop"
 
156
bootpath:
 
157
        .asciz  "bootpath"
 
158
stdout:
 
159
        .asciz  "stdout"
 
160
open:
 
161
        .asciz  "open"
 
162
close:
 
163
        .asciz  "close"
 
164
seek:
 
165
        .asciz  "seek"
 
166
read:
 
167
        .asciz  "read"
 
168
write:
 
169
        .asciz  "write"
 
170
chosen:
 
171
        .asciz  "/chosen"
 
172
exit:
 
173
        .asciz  "exit"