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 #include <linux/linkage.h>
14 LC_EXT_NEW_PSW = 0x58 # addr of ext int handler
15 LC_EXT_NEW_PSW_64 = 0x1b0 # addr of ext int handler 64 bit
16 LC_EXT_INT_PARAM = 0x80 # addr of ext int parameter
17 LC_EXT_INT_CODE = 0x86 # addr of ext int code
21 # Subroutine which waits synchronously until either an external interruption
22 # or a timeout occurs.
25 # R2 = 0 for no timeout, non-zero for timeout in (approximated) seconds
28 # R2 = 0 on interrupt, 2 on timeout
29 # R3 = external interruption parameter if R2=0
33 stm %r6,%r15,24(%r15) # save registers
34 basr %r13,0 # get base register
36 ahi %r15,-96 # create stack frame
37 la %r8,LC_EXT_NEW_PSW # register int handler
38 la %r9,.LextpswS1-.LbaseS1(%r13)
41 la %r8,LC_EXT_NEW_PSW_64 # register int handler 64 bit
42 la %r9,.LextpswS1_64-.LbaseS1(%r13)
44 mvc .LoldpswS1-.LbaseS1(16,%r13),0(%r8)
46 epsw %r6,%r7 # set current addressing mode
47 nill %r6,0x1 # in new psw (31 or 64 bit mode)
50 lhi %r6,0x0200 # cr mask for ext int (cr0.54)
53 ahi %r6,0x0800 # cr mask for clock int (cr0.52)
54 stck .LtimeS1-.LbaseS1(%r13) # initiate timeout
55 al %r2,.LtimeS1-.LbaseS1(%r13)
56 st %r2,.LtimeS1-.LbaseS1(%r13)
57 sckc .LtimeS1-.LbaseS1(%r13)
60 stctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # enable required interrupts
61 l %r0,.LctlS1-.LbaseS1(%r13)
62 lhi %r1,~(0x200 | 0x800) # clear old values
64 or %r1,%r6 # set new value
65 st %r1,.LctlS1-.LbaseS1(%r13)
66 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13)
67 st %r0,.LctlS1-.LbaseS1(%r13)
68 lhi %r2,2 # return code for timeout
70 lpsw .LwaitpswS1-.LbaseS1(%r13) # wait until interrupt
72 lh %r7,LC_EXT_INT_CODE
73 chi %r7,EXT_IRQ_CLK_COMP # timeout?
75 chi %r7,EXT_IRQ_SERVICE_SIG # service int?
78 l %r3,LC_EXT_INT_PARAM
80 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # restore interrupt setting
82 mvc 0(16,%r8),.LoldpswS1-.LbaseS1(%r13)
83 lm %r6,%r15,120(%r15) # restore registers
84 br %r14 # return to caller
88 .long 0, 0, 0, 0 # old ext int PSW
90 .long 0x00080000, 0x80000000+.LwaitS1 # PSW to handle ext int
92 .quad 0, .LwaitS1 # PSW to handle ext int, 64 bit
94 .long 0x010a0000, 0x00000000+.LloopS1 # PSW to wait for ext int
96 .quad 0 # current time
98 .long 0 # CT0 contents
101 # Subroutine to synchronously issue a service call.
108 # R2 = 0 on success, 1 on failure
109 # R3 = sccb response code if R2 = 0
113 stm %r6,%r15,24(%r15) # save registers
114 ahi %r15,-96 # create stack frame
115 lr %r6,%r2 # save command word
116 lr %r7,%r3 # save sccb address
118 lhi %r2,1 # error return code
119 .insn rre,0xb2200000,%r6,%r7 # servc
120 brc 1,.LendS2 # exit if not operational
121 brc 8,.LnotbusyS2 # go on if not busy
122 sr %r2,%r2 # wait until no longer busy
123 bras %r14,_sclp_wait_int
126 sr %r2,%r2 # wait until result
127 bras %r14,_sclp_wait_int
131 lm %r6,%r15,120(%r15) # restore registers
135 # Subroutine to set up the SCLP interface.
138 # R2 = 0 to activate, non-zero to deactivate
141 # R2 = 0 on success, non-zero on failure
145 stm %r6,%r15,24(%r15) # save registers
146 ahi %r15,-96 # create stack frame
147 basr %r13,0 # get base register
149 l %r6,.LsccbS0-.LbaseS3(%r13) # prepare init mask sccb
150 mvc 0(.LinitendS3-.LinitsccbS3,%r6),.LinitsccbS3-.LbaseS3(%r13)
151 ltr %r2,%r2 # initialization?
152 jz .LdoinitS3 # go ahead
154 xc .LinitmaskS3-.LinitsccbS3(8,%r6),.LinitmaskS3-.LinitsccbS3(%r6)
156 l %r2,.LwritemaskS3-.LbaseS3(%r13)# get command word
157 lr %r3,%r6 # get sccb address
158 bras %r14,_sclp_servc # issue service call
159 ltr %r2,%r2 # servc successful?
161 chi %r3,0x20 # write mask successful?
164 la %r2,.LinitmaskS3-.LinitsccbS3(%r6)
165 l %r1,0(%r2) # receive mask ok?
169 l %r1,4(%r2) # send mask ok?
175 lhi %r2,1 # error return code
177 lm %r6,%r15,120(%r15) # restore registers
180 .long 0x00780005 # SCLP command for write mask
182 .word .LinitendS3-.LinitsccbS3
195 # Subroutine which prints a given text to the SCLP console.
198 # R2 = address of nil-terminated ASCII text
201 # R2 = 0 on success, 1 on failure
205 stm %r6,%r15,24(%r15) # save registers
206 ahi %r15,-96 # create stack frame
207 basr %r13,0 # get base register
209 l %r8,.LsccbS0-.LbaseS4(%r13) # prepare write data sccb
210 mvc 0(.LmtoS4-.LwritesccbS4,%r8),.LwritesccbS4-.LbaseS4(%r13)
211 la %r7,.LmtoS4-.LwritesccbS4(%r8) # current mto addr
213 l %r10,.Lascebc-.LbaseS4(%r13) # address of translation table
216 mvc 0(.LmtoendS4-.LmtoS4,%r7),.LmtoS4-.LbaseS4(%r13)
217 lhi %r6,.LmtoendS4-.LmtoS4 # current mto length
219 ic %r0,0(%r2) # get character
221 ltr %r0,%r0 # end of string?
223 chi %r0,0x0a # end of line (NL)?
225 stc %r0,0(%r6,%r7) # copy to mto
227 tr 0(1,%r11),0(%r10) # translate to EBCDIC
231 sth %r6,0(%r7) # update mto length
232 lh %r9,.LmdbS4-.LwritesccbS4(%r8) # update mdb length
234 sth %r9,.LmdbS4-.LwritesccbS4(%r8)
235 lh %r9,.LevbufS4-.LwritesccbS4(%r8)# update evbuf length
237 sth %r9,.LevbufS4-.LwritesccbS4(%r8)
238 lh %r9,0(%r8) # update sccb length
241 ar %r7,%r6 # update current mto address
242 ltr %r0,%r0 # more characters?
244 l %r2,.LwritedataS4-.LbaseS4(%r13)# write data
246 bras %r14,_sclp_servc
247 ltr %r2,%r2 # servc successful?
249 chi %r3,0x20 # write data successful?
251 lhi %r2,1 # error return code
253 lm %r6,%r15,120(%r15) # restore registers
257 # Function which prints a given text to the SCLP console.
260 # R2 = address of nil-terminated ASCII text
263 # R2 = 0 on success, 1 on failure
266 ENTRY(_sclp_print_early)
267 stm %r6,%r15,24(%r15) # save registers
268 ahi %r15,-96 # create stack frame
272 stmh %r6,%r15,96(%r15) # store upper register halves
274 lmh %r0,%r15,.Lzeroes-.(%r13) # clear upper register halves
276 lr %r10,%r2 # save string pointer
278 bras %r14,_sclp_setup # enable console
282 bras %r14,_sclp_print # print string
286 bras %r14,_sclp_setup # disable console
290 lgfr %r2,%r2 # sign extend return value
291 lmh %r6,%r15,96(%r15) # restore upper register halves
294 lm %r6,%r15,120(%r15) # restore registers
300 .long 0x00760005 # SCLP command for write data
303 .word .LmtoS4-.LwritesccbS4
310 .word .LmtoS4-.LevbufS4
317 .word .LmtoS4-.LmdbS4
327 .byte 0,0,0,0,0,0,0,0
333 .byte 0,0,0,0,0,0,0,0,0,0
334 .byte 0,0,0,0,0,0,0,0
335 .byte 0,0,0,0,0,0,0,0
338 .word .LmtoendS4-.LmtoS4
347 .long _sclp_work_area
351 .section .data,"aw",@progbits