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>
13 LC_EXT_NEW_PSW = 0x58 # addr of ext int handler
14 LC_EXT_NEW_PSW_64 = 0x1b0 # addr of ext int handler 64 bit
15 LC_EXT_INT_PARAM = 0x80 # addr of ext int parameter
16 LC_EXT_INT_CODE = 0x86 # addr of ext int code
20 # Subroutine which waits synchronously until either an external interruption
21 # or a timeout occurs.
24 # R2 = 0 for no timeout, non-zero for timeout in (approximated) seconds
27 # R2 = 0 on interrupt, 2 on timeout
28 # R3 = external interruption parameter if R2=0
32 stm %r6,%r15,24(%r15) # save registers
33 basr %r13,0 # get base register
35 ahi %r15,-96 # create stack frame
36 la %r8,LC_EXT_NEW_PSW # register int handler
37 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)
45 mvc .LoldpswS1-.LbaseS1(16,%r13),0(%r8)
48 epsw %r6,%r7 # set current addressing mode
49 nill %r6,0x1 # in new psw (31 or 64 bit mode)
53 lhi %r6,0x0200 # cr mask for ext int (cr0.54)
56 ahi %r6,0x0800 # cr mask for clock int (cr0.52)
57 stck .LtimeS1-.LbaseS1(%r13) # initiate timeout
58 al %r2,.LtimeS1-.LbaseS1(%r13)
59 st %r2,.LtimeS1-.LbaseS1(%r13)
60 sckc .LtimeS1-.LbaseS1(%r13)
63 stctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # enable required interrupts
64 l %r0,.LctlS1-.LbaseS1(%r13)
65 lhi %r1,~(0x200 | 0x800) # clear old values
67 or %r1,%r6 # set new value
68 st %r1,.LctlS1-.LbaseS1(%r13)
69 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13)
70 st %r0,.LctlS1-.LbaseS1(%r13)
71 lhi %r2,2 # return code for timeout
73 lpsw .LwaitpswS1-.LbaseS1(%r13) # wait until interrupt
75 lh %r7,LC_EXT_INT_CODE
76 chi %r7,0x1004 # timeout?
78 chi %r7,0x2401 # service int?
81 l %r3,LC_EXT_INT_PARAM
83 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # restore interrupt setting
85 mvc 0(16,%r8),.LoldpswS1-.LbaseS1(%r13)
86 lm %r6,%r15,120(%r15) # restore registers
87 br %r14 # return to caller
91 .long 0, 0, 0, 0 # old ext int PSW
93 .long 0x00080000, 0x80000000+.LwaitS1 # PSW to handle ext int
96 .quad 0, .LwaitS1 # PSW to handle ext int, 64 bit
99 .long 0x010a0000, 0x00000000+.LloopS1 # PSW to wait for ext int
101 .quad 0 # current time
103 .long 0 # CT0 contents
106 # Subroutine to synchronously issue a service call.
113 # R2 = 0 on success, 1 on failure
114 # R3 = sccb response code if R2 = 0
118 stm %r6,%r15,24(%r15) # save registers
119 ahi %r15,-96 # create stack frame
120 lr %r6,%r2 # save command word
121 lr %r7,%r3 # save sccb address
123 lhi %r2,1 # error return code
124 .insn rre,0xb2200000,%r6,%r7 # servc
125 brc 1,.LendS2 # exit if not operational
126 brc 8,.LnotbusyS2 # go on if not busy
127 sr %r2,%r2 # wait until no longer busy
128 bras %r14,_sclp_wait_int
131 sr %r2,%r2 # wait until result
132 bras %r14,_sclp_wait_int
136 lm %r6,%r15,120(%r15) # restore registers
140 # Subroutine to set up the SCLP interface.
143 # R2 = 0 to activate, non-zero to deactivate
146 # R2 = 0 on success, non-zero on failure
150 stm %r6,%r15,24(%r15) # save registers
151 ahi %r15,-96 # create stack frame
152 basr %r13,0 # get base register
154 l %r6,.LsccbS0-.LbaseS3(%r13) # prepare init mask sccb
155 mvc 0(.LinitendS3-.LinitsccbS3,%r6),.LinitsccbS3-.LbaseS3(%r13)
156 ltr %r2,%r2 # initialization?
157 jz .LdoinitS3 # go ahead
159 xc .LinitmaskS3-.LinitsccbS3(8,%r6),.LinitmaskS3-.LinitsccbS3(%r6)
161 l %r2,.LwritemaskS3-.LbaseS3(%r13)# get command word
162 lr %r3,%r6 # get sccb address
163 bras %r14,_sclp_servc # issue service call
164 ltr %r2,%r2 # servc successful?
166 chi %r3,0x20 # write mask successful?
169 la %r2,.LinitmaskS3-.LinitsccbS3(%r6)
170 l %r1,0(%r2) # receive mask ok?
174 l %r1,4(%r2) # send mask ok?
180 lhi %r2,1 # error return code
182 lm %r6,%r15,120(%r15) # restore registers
185 .long 0x00780005 # SCLP command for write mask
187 .word .LinitendS3-.LinitsccbS3
200 # Subroutine which prints a given text to the SCLP console.
203 # R2 = address of nil-terminated ASCII text
206 # R2 = 0 on success, 1 on failure
210 stm %r6,%r15,24(%r15) # save registers
211 ahi %r15,-96 # create stack frame
212 basr %r13,0 # get base register
214 l %r8,.LsccbS0-.LbaseS4(%r13) # prepare write data sccb
215 mvc 0(.LmtoS4-.LwritesccbS4,%r8),.LwritesccbS4-.LbaseS4(%r13)
216 la %r7,.LmtoS4-.LwritesccbS4(%r8) # current mto addr
218 l %r10,.Lascebc-.LbaseS4(%r13) # address of translation table
221 mvc 0(.LmtoendS4-.LmtoS4,%r7),.LmtoS4-.LbaseS4(%r13)
222 lhi %r6,.LmtoendS4-.LmtoS4 # current mto length
224 ic %r0,0(%r2) # get character
226 ltr %r0,%r0 # end of string?
228 chi %r0,0x15 # end of line (NL)?
230 stc %r0,0(%r6,%r7) # copy to mto
232 tr 0(1,%r11),0(%r10) # translate to EBCDIC
236 sth %r6,0(%r7) # update mto length
237 lh %r9,.LmdbS4-.LwritesccbS4(%r8) # update mdb length
239 sth %r9,.LmdbS4-.LwritesccbS4(%r8)
240 lh %r9,.LevbufS4-.LwritesccbS4(%r8)# update evbuf length
242 sth %r9,.LevbufS4-.LwritesccbS4(%r8)
243 lh %r9,0(%r8) # update sccb length
246 ar %r7,%r6 # update current mto address
247 ltr %r0,%r0 # more characters?
249 l %r2,.LwritedataS4-.LbaseS4(%r13)# write data
251 bras %r14,_sclp_servc
252 ltr %r2,%r2 # servc successful?
254 chi %r3,0x20 # write data successful?
256 lhi %r2,1 # error return code
258 lm %r6,%r15,120(%r15) # restore registers
262 # Function which prints a given text to the SCLP console.
265 # R2 = address of nil-terminated ASCII text
268 # R2 = 0 on success, 1 on failure
271 ENTRY(_sclp_print_early)
272 stm %r6,%r15,24(%r15) # save registers
273 ahi %r15,-96 # create stack frame
278 stmh %r6,%r15,96(%r15) # store upper register halves
281 lr %r10,%r2 # save string pointer
283 bras %r14,_sclp_setup # enable console
287 bras %r14,_sclp_print # print string
291 bras %r14,_sclp_setup # disable console
296 lmh %r6,%r15,96(%r15) # store upper register halves
300 lm %r6,%r15,120(%r15) # restore registers
304 .long 0x00760005 # SCLP command for write data
307 .word .LmtoS4-.LwritesccbS4
314 .word .LmtoS4-.LevbufS4
321 .word .LmtoS4-.LmdbS4
331 .byte 0,0,0,0,0,0,0,0
337 .byte 0,0,0,0,0,0,0,0,0,0
338 .byte 0,0,0,0,0,0,0,0
339 .byte 0,0,0,0,0,0,0,0
342 .word .LmtoendS4-.LmtoS4
351 .long _sclp_work_area
355 .section .data,"aw",@progbits