convert gitignore files to hgignore files
[hvf.git] / installer / loader_asm.s
blob7cb4d25968e398a34eb6626ed513e77022427e3d
2 # Copyright (c) 2007-2011 Josef 'Jeff' Sipek
5 #include "loader.h"
7 .text
8 .align 4
9 .globl __wait_for_attn
10 .type __wait_for_attn, @function
11 __wait_for_attn:
12 LARL %r4,WAITPSW # wait for the interrupt
13 LPSWE 0(%r4)
15 # int __do_io(u32 sch);
16 .align 4
17 .globl __do_io
18 .type __do_io, @function
19 __do_io:
20 LGR %r1,%r2 # load subsystem ID
22 LA %r2,0xfff # error return code
24 LARL %r4,ORB
25 SSCH 0(%r4) # issue IO
26 BCR 7, %r14 # return on error
28 LARL %r4,WAITPSW # wait for the interrupt
29 LPSWE 0(%r4)
32 # The IO interrupt handler; it's very much like a continuation of __do_io
34 .globl IOHANDLER
35 IOHANDLER:
36 # is this for us?
37 LARL %r1,MAGICVAL
38 L %r1,0(%r1)
39 C %r1,0xbc
40 BRC 7,IONOTDONE
42 # it is!
44 LLGF %r1,0xb8 # load subsystem ID
46 LARL %r4,IRB
47 TSCH 0(%r4)
49 # check the Channel Status for != 0
50 XGR %r2,%r2
51 IC %r2,9(%r4)
52 NILL %r2,0xbf # get rid of SLI
53 LTR %r2,%r2
54 BCR 7,%r14 # error, let's bail
56 # check the Device Status
57 XGR %r1,%r1
58 IC %r1,8(%r4)
60 # unit check, unit except?
61 LR %r2,%r1
62 NILL %r2,0x03
63 BCR 4,%r14 # error return
65 # attention, DE?
66 XGR %r2,%r2
67 NILL %r1,0x84
68 BCR 4,%r14 # ok return
70 IONOTDONE:
71 LPSWE 0x170
74 # The PGM interrupt handler
76 .globl PGMHANDLER
77 PGMHANDLER:
78 STMG %r1,%r3,0x200
80 # r3 = 0x80000000
81 XGR %r3, %r3
82 LHI %r3, 0x8
83 SLL %r3, 20
85 # is ILC == 3?
86 LGH %r2,0x8C
87 CGHI %r2,0x0006
88 BNE ERR(%r3)
90 # grab the old PSW address, subtract length of TPROT, and compare it
91 # with the TPROT opcode (0xe501)
92 LG %r1,0x158
93 AGHI %r1,-6
94 LLGH %r2,TPROTOP(%r3)
95 LLGH %r1,0(%r1)
96 CGR %r2,%r1
97 BNE ERR(%r3)
99 # set CC=3
100 OI 0x152,0x30
102 LMG %r1,%r3,0x200
104 LPSWE 0x150
106 ERR:
107 .byte 0x00, 0x00
111 # Useful data
113 .data
114 .globl TPROTOP
115 TPROTOP:
116 .byte 0xe5, 0x01
118 .align 8
119 .globl IOPSW
120 IOPSW:
121 .byte 0x00
122 # bits value name desc
123 # 0 0 <zero>
124 # 1 0 PER Mask (R) disabled
125 # 2-4 0 <zero>
126 # 5 0 DAT Mode (T) disabled
127 # 6 0 I/O Mask (IO) enabled
128 # 7 0 External Mask (EX) disabled
130 .byte 0x00
131 # bits value name desc
132 # 8-11 0 Key
133 # 12 0 <one>
134 # 13 0 Machine-Check Mask (M) disabled
135 # 14 0 Wait State (W) executing
136 # 15 0 Problem State (P) supervisor state
138 .byte 0x00
139 # bits value name desc
140 # 16-17 0 Address-Space Control (AS) disabled
141 # 18-19 0 Condition Code (CC)
142 # 20-23 0 Program Mask exceptions disabled
144 .byte 0x01
145 # bits value name desc
146 # 24-30 0 <zero>
147 # 31 1 Extended Addressing (EA) EA + BA = 64 mode
149 .byte 0x80, 0x00, 0x00, 0x00
150 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
151 # bits value name desc
152 # 32 1 Basic Addressing (BA) BA = 31, !BA = 24
153 # 33-63 0 <zero>
154 # 64-127 addr Instruction Address Address to exec
156 .globl WAITPSW
157 WAITPSW:
158 .byte 0x02
159 # bits value name desc
160 # 0 0 <zero>
161 # 1 0 PER Mask (R) disabled
162 # 2-4 0 <zero>
163 # 5 0 DAT Mode (T) disabled
164 # 6 1 I/O Mask (IO) enabled
165 # 7 0 External Mask (EX) disabled
167 .byte 0x02
168 # bits value name desc
169 # 8-11 0 Key
170 # 12 0 <zero>
171 # 13 0 Machine-Check Mask (M) disabled
172 # 14 1 Wait State (W) not executing
173 # 15 0 Problem State (P) supervisor state
175 .byte 0x00
176 # bits value name desc
177 # 16-17 0 Address-Space Control (AS) disabled
178 # 18-19 0 Condition Code (CC)
179 # 20-23 0 Program Mask exceptions disabled
181 .byte 0x01
182 # bits value name desc
183 # 24-30 0 <zero>
184 # 31 1 Extended Addressing (EA) EA + BA = 64 mode
186 .byte 0x80, 0x00, 0x00, 0x00
187 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
188 # bits value name desc
189 # 32 1 Basic Addressing (BA) BA = 31, !BA = 24
190 # 33-63 0 <zero>
191 # 64-127 addr Instruction Address Address to exec
193 .globl IRB
194 IRB:
195 .8byte 0x00
196 .8byte 0x00
197 .8byte 0x00
198 .8byte 0x00
199 .8byte 0x00
200 .8byte 0x00
201 .8byte 0x00
202 .8byte 0x00
203 .8byte 0x00
204 .8byte 0x00
205 .8byte 0x00
206 .8byte 0x00
208 .align 4
209 .globl ORB
210 ORB:
211 .8byte 0x00
212 .8byte 0x00
213 .8byte 0x00
214 .8byte 0x00
216 .globl MAGICVAL
217 MAGICVAL:
218 .4byte 0x12345678