4 * Copyright IBM Corp. 2004,2009
6 * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>,
11 LC_EXT_NEW_PSW = 0x58 # addr of ext int handler
12 LC_EXT_INT_PARAM = 0x80 # addr of ext int parameter
13 LC_EXT_INT_CODE = 0x86 # addr of ext int code
16 # Subroutine which waits synchronously until either an external interruption
17 # or a timeout occurs.
20 # R2 = 0 for no timeout, non-zero for timeout in (approximated) seconds
23 # R2 = 0 on interrupt, 2 on timeout
24 # R3 = external interruption parameter if R2=0
28 stm %r6,%r15,24(%r15) # save registers
29 basr %r13,0 # get base register
31 ahi %r15,-96 # create stack frame
32 la %r8,LC_EXT_NEW_PSW # register int handler
33 mvc .LoldpswS1-.LbaseS1(8,%r13),0(%r8)
34 mvc 0(8,%r8),.LextpswS1-.LbaseS1(%r13)
35 lhi %r6,0x0200 # cr mask for ext int (cr0.54)
38 ahi %r6,0x0800 # cr mask for clock int (cr0.52)
39 stck .LtimeS1-.LbaseS1(%r13) # initiate timeout
40 al %r2,.LtimeS1-.LbaseS1(%r13)
41 st %r2,.LtimeS1-.LbaseS1(%r13)
42 sckc .LtimeS1-.LbaseS1(%r13)
45 stctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # enable required interrupts
46 l %r0,.LctlS1-.LbaseS1(%r13)
47 lhi %r1,~(0x200 | 0x800) # clear old values
49 or %r1,%r6 # set new value
50 st %r1,.LctlS1-.LbaseS1(%r13)
51 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13)
52 st %r0,.LctlS1-.LbaseS1(%r13)
53 lhi %r2,2 # return code for timeout
55 lpsw .LwaitpswS1-.LbaseS1(%r13) # wait until interrupt
57 lh %r7,LC_EXT_INT_CODE
58 chi %r7,0x1004 # timeout?
60 chi %r7,0x2401 # service int?
63 l %r3,LC_EXT_INT_PARAM
65 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # restore interrupt setting
67 mvc 0(8,%r8),.LoldpswS1-.LbaseS1(%r13)
68 lm %r6,%r15,120(%r15) # restore registers
69 br %r14 # return to caller
73 .long 0, 0 # old ext int PSW
75 .long 0x00080000, 0x80000000+.LwaitS1 # PSW to handle ext int
77 .long 0x010a0000, 0x00000000+.LloopS1 # PSW to wait for ext int
79 .quad 0 # current time
81 .long 0 # CT0 contents
84 # Subroutine to synchronously issue a service call.
91 # R2 = 0 on success, 1 on failure
92 # R3 = sccb response code if R2 = 0
96 stm %r6,%r15,24(%r15) # save registers
97 ahi %r15,-96 # create stack frame
98 lr %r6,%r2 # save command word
99 lr %r7,%r3 # save sccb address
101 lhi %r2,1 # error return code
102 .insn rre,0xb2200000,%r6,%r7 # servc
103 brc 1,.LendS2 # exit if not operational
104 brc 8,.LnotbusyS2 # go on if not busy
105 sr %r2,%r2 # wait until no longer busy
106 bras %r14,_sclp_wait_int
109 sr %r2,%r2 # wait until result
110 bras %r14,_sclp_wait_int
114 lm %r6,%r15,120(%r15) # restore registers
118 # Subroutine to set up the SCLP interface.
121 # R2 = 0 to activate, non-zero to deactivate
124 # R2 = 0 on success, non-zero on failure
128 stm %r6,%r15,24(%r15) # save registers
129 ahi %r15,-96 # create stack frame
130 basr %r13,0 # get base register
132 l %r6,.LsccbS0-.LbaseS3(%r13) # prepare init mask sccb
133 mvc 0(.LinitendS3-.LinitsccbS3,%r6),.LinitsccbS3-.LbaseS3(%r13)
134 ltr %r2,%r2 # initialization?
135 jz .LdoinitS3 # go ahead
137 xc .LinitmaskS3-.LinitsccbS3(8,%r6),.LinitmaskS3-.LinitsccbS3(%r6)
139 l %r2,.LwritemaskS3-.LbaseS3(%r13)# get command word
140 lr %r3,%r6 # get sccb address
141 bras %r14,_sclp_servc # issue service call
142 ltr %r2,%r2 # servc successful?
144 chi %r3,0x20 # write mask successful?
147 la %r2,.LinitmaskS3-.LinitsccbS3(%r6)
148 l %r1,0(%r2) # receive mask ok?
152 l %r1,4(%r2) # send mask ok?
158 lhi %r2,1 # error return code
160 lm %r6,%r15,120(%r15) # restore registers
163 .long 0x00780005 # SCLP command for write mask
165 .word .LinitendS3-.LinitsccbS3
178 # Subroutine which prints a given text to the SCLP console.
181 # R2 = address of nil-terminated ASCII text
184 # R2 = 0 on success, 1 on failure
188 stm %r6,%r15,24(%r15) # save registers
189 ahi %r15,-96 # create stack frame
190 basr %r13,0 # get base register
192 l %r8,.LsccbS0-.LbaseS4(%r13) # prepare write data sccb
193 mvc 0(.LmtoS4-.LwritesccbS4,%r8),.LwritesccbS4-.LbaseS4(%r13)
194 la %r7,.LmtoS4-.LwritesccbS4(%r8) # current mto addr
196 l %r10,.Lascebc-.LbaseS4(%r13) # address of translation table
199 mvc 0(.LmtoendS4-.LmtoS4,%r7),.LmtoS4-.LbaseS4(%r13)
200 lhi %r6,.LmtoendS4-.LmtoS4 # current mto length
202 ic %r0,0(%r2) # get character
204 ltr %r0,%r0 # end of string?
206 chi %r0,0x15 # end of line (NL)?
208 stc %r0,0(%r6,%r7) # copy to mto
210 tr 0(1,%r11),0(%r10) # translate to EBCDIC
214 sth %r6,0(%r7) # update mto length
215 lh %r9,.LmdbS4-.LwritesccbS4(%r8) # update mdb length
217 sth %r9,.LmdbS4-.LwritesccbS4(%r8)
218 lh %r9,.LevbufS4-.LwritesccbS4(%r8)# update evbuf length
220 sth %r9,.LevbufS4-.LwritesccbS4(%r8)
221 lh %r9,0(%r8) # update sccb length
224 ar %r7,%r6 # update current mto adress
225 ltr %r0,%r0 # more characters?
227 l %r2,.LwritedataS4-.LbaseS4(%r13)# write data
229 bras %r14,_sclp_servc
230 ltr %r2,%r2 # servc successful?
232 chi %r3,0x20 # write data successful?
234 lhi %r2,1 # error return code
236 lm %r6,%r15,120(%r15) # restore registers
240 # Function which prints a given text to the SCLP console.
243 # R2 = address of nil-terminated ASCII text
246 # R2 = 0 on success, 1 on failure
249 .globl _sclp_print_early
251 stm %r6,%r15,24(%r15) # save registers
252 ahi %r15,-96 # create stack frame
253 lr %r10,%r2 # save string pointer
255 bras %r14,_sclp_setup # enable console
259 bras %r14,_sclp_print # print string
263 bras %r14,_sclp_setup # disable console
265 lm %r6,%r15,120(%r15) # restore registers
269 .long 0x00760005 # SCLP command for write data
272 .word .LmtoS4-.LwritesccbS4
279 .word .LmtoS4-.LevbufS4
286 .word .LmtoS4-.LmdbS4
296 .byte 0,0,0,0,0,0,0,0
302 .byte 0,0,0,0,0,0,0,0,0,0
303 .byte 0,0,0,0,0,0,0,0
304 .byte 0,0,0,0,0,0,0,0
307 .word .LmtoendS4-.LmtoS4
316 .long _sclp_work_area
320 .section .data,"aw",@progbits