2 # Copyright (c) 2007 Josef 'Jeff' Sipek
10 .type __do_io, @function
19 # r14 = r14 & 0x7fffffff don't ask, it's strangely retarded
22 NR
%r14, %r1 # mask out the bit
24 # set up the interrupt handler
25 MVC
0x1f0(16),IOPSW
(%r4) # SET NEW IO PSW
26 LA %r1,IOHANDLER
(%r4) # GET HANDLER ADDRESS
27 STG
%r1,0x1f0+8 # SAVE IN NEW PSW
29 L %r1, 0xb8 # load subsystem ID
31 SSCH ORB
(%r4) # issue IO
33 # Load Control Register 6 with I/O interrupt subclass mask
34 STCTG
6,6,TMPVAR
(%r4) # GET CR6
35 OI TMPVAR+
4(%r4),0xFF # enable all
36 LCTLG
6,6,TMPVAR
(%r4) # RELOAD MODIFIED CR6
39 7) Enable the PSW for I/O interrupts and go into wait state (you need bits 6, 12 & 14 set to 1 in the PSW : X'020A000000000000' is a good example)
44 # The IO interrupt handler
55 L %r1, 0xb8 # load subsystem ID
60 FIXME: we should do more checking!
62 11) If Unit check or Channel Status|=0 : An I/O error occurred and act accordingly
63 12) If unit exception : End of media (for tape & cards) and act accordingly
64 13) If device end : I/O Completed.. Perform post I/O stuff (like advancing your pointers) and back to step 3
67 # unit check? (end of media?)
71 LA %r2,1 # return 1 - end of medium
72 BCR 4,%r14 # unit chk => return
74 # check the SCSW.. If CE Only : LPSW Old I/O PSW
77 LA %r2,0 # means IO done
78 BCR 4,%r14 # device end => return
84 # The PGM interrupt handler
100 # grab the old PSW address, subtract length of TPROT, and compare it
101 # with the TPROT opcode (0xe501)
104 LLGH
%r2,TPROTOP
(%r3)
132 # bits value name desc
134 # 1 0 PER Mask (R) disabled
136 # 5 0 DAT Mode (T) disabled
137 # 6 0 I/O Mask (IO) enabled
138 # 7 0 External Mask (EX) disabled
141 # bits value name desc
144 # 13 0 Machine-Check Mask (M) disabled
145 # 14 0 Wait State (W) executing
146 # 15 0 Problem State (P) supervisor state
149 # bits value name desc
150 # 16-17 0 Address-Space Control (AS) disabled
151 # 18-19 0 Condition Code (CC)
152 # 20-23 0 Program Mask exceptions disabled
155 # bits value name desc
157 # 31 1 Extended Addressing (EA) EA + BA = 64 mode
171 # bits value name desc
172 # 32 1 Basic Addressing (BA) BA = 31, !BA = 24
174 # 64-127 addr Instruction Address Address to exec
179 # bits value name desc
181 # 1 0 PER Mask (R) disabled
183 # 5 0 DAT Mode (T) disabled
184 # 6 1 I/O Mask (IO) enabled
185 # 7 0 External Mask (EX) disabled
188 # bits value name desc
191 # 13 0 Machine-Check Mask (M) disabled
192 # 14 1 Wait State (W) not executing
193 # 15 0 Problem State (P) supervisor state
196 # bits value name desc
197 # 16-17 0 Address-Space Control (AS) disabled
198 # 18-19 0 Condition Code (CC)
199 # 20-23 0 Program Mask exceptions disabled
202 # bits value name desc
204 # 31 1 Extended Addressing (EA) EA + BA = 64 mode
218 # bits value name desc
219 # 32 1 Basic Addressing (BA) BA = 31, !BA = 24
221 # 64-127 addr Instruction Address Address to exec