aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2015-07-08 04:20:04 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-07-29 03:11:39 -0400
commit22362a0e23182d230527a5add690b4027860d7d3 (patch)
treefbdd8176032b6351e78d0a02525459a9e9ec4f34
parent1d2334cb7da37e4b0005ca1d194d4e10ca7119f4 (diff)
s390/sclp: convert early sclp console code to C
The 31-bit assembler code for the early sclp console is error prone as git commit fde24b54d976cc123506695c17db01438a11b673 "s390/sclp: clear upper register halves in _sclp_print_early" has shown. Convert the assembler code to C. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/Makefile2
-rw-r--r--arch/s390/include/asm/processor.h11
-rw-r--r--arch/s390/include/asm/sclp.h2
-rw-r--r--arch/s390/kernel/Makefile11
-rw-r--r--arch/s390/kernel/head.S1
-rw-r--r--arch/s390/kernel/sclp.S355
-rw-r--r--arch/s390/kernel/sclp.c160
7 files changed, 186 insertions, 356 deletions
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 667b1bca5681..e8d4423e4f85 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -33,6 +33,8 @@ mflags-$(CONFIG_MARCH_Z196) := -march=z196
33mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12 33mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12
34mflags-$(CONFIG_MARCH_Z13) := -march=z13 34mflags-$(CONFIG_MARCH_Z13) := -march=z13
35 35
36export CC_FLAGS_MARCH := $(mflags-y)
37
36aflags-y += $(mflags-y) 38aflags-y += $(mflags-y)
37cflags-y += $(mflags-y) 39cflags-y += $(mflags-y)
38 40
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index c417015c5304..085fb0d3c54e 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -233,6 +233,17 @@ static inline void __load_psw_mask (unsigned long mask)
233} 233}
234 234
235/* 235/*
236 * Extract current PSW mask
237 */
238static inline unsigned long __extract_psw(void)
239{
240 unsigned int reg1, reg2;
241
242 asm volatile("epsw %0,%1" : "=d" (reg1), "=a" (reg2));
243 return (((unsigned long) reg1) << 32) | ((unsigned long) reg2);
244}
245
246/*
236 * Rewind PSW instruction address by specified number of bytes. 247 * Rewind PSW instruction address by specified number of bytes.
237 */ 248 */
238static inline unsigned long __rewind_psw(psw_t psw, unsigned long ilc) 249static inline unsigned long __rewind_psw(psw_t psw, unsigned long ilc)
diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index f6ff06077631..821dde5f425d 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -79,6 +79,6 @@ int sclp_pci_configure(u32 fid);
79int sclp_pci_deconfigure(u32 fid); 79int sclp_pci_deconfigure(u32 fid);
80int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode); 80int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode);
81void sclp_early_detect(void); 81void sclp_early_detect(void);
82long _sclp_print_early(const char *); 82int _sclp_print_early(const char *);
83 83
84#endif /* _ASM_S390_SCLP_H */ 84#endif /* _ASM_S390_SCLP_H */
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index ffb87617a36c..b756c6348ac6 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -28,6 +28,17 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
28 28
29CFLAGS_sysinfo.o += -w 29CFLAGS_sysinfo.o += -w
30 30
31#
32# Use -march=z900 for sclp.c to be able to print an error message if
33# the kernel is started on a machine which is too old
34#
35CFLAGS_REMOVE_sclp.o = $(CC_FLAGS_FTRACE)
36ifneq ($(CC_FLAGS_MARCH),-march=z900)
37CFLAGS_REMOVE_sclp.o += $(CC_FLAGS_MARCH)
38CFLAGS_sclp.o += -march=z900
39endif
40GCOV_PROFILE_sclp.o := n
41
31obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o 42obj-y := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o
32obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o 43obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
33obj-y += debug.o irq.o ipl.o dis.o diag.o sclp.o vdso.o 44obj-y += debug.o irq.o ipl.o dis.o diag.o sclp.o vdso.o
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index 59b7c6470567..63c77fdb619e 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -370,6 +370,7 @@ ENTRY(startup_kdump)
370 xc 0x200(256),0x200 # partially clear lowcore 370 xc 0x200(256),0x200 # partially clear lowcore
371 xc 0x300(256),0x300 371 xc 0x300(256),0x300
372 xc 0xe00(256),0xe00 372 xc 0xe00(256),0xe00
373 lctlg %c0,%c15,0x200(%r0) # initialize control registers
373 stck __LC_LAST_UPDATE_CLOCK 374 stck __LC_LAST_UPDATE_CLOCK
374 spt 6f-.LPG0(%r13) 375 spt 6f-.LPG0(%r13)
375 mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13) 376 mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13)
diff --git a/arch/s390/kernel/sclp.S b/arch/s390/kernel/sclp.S
deleted file mode 100644
index ada0c07fe1a8..000000000000
--- a/arch/s390/kernel/sclp.S
+++ /dev/null
@@ -1,355 +0,0 @@
1/*
2 * Mini SCLP driver.
3 *
4 * Copyright IBM Corp. 2004, 2009
5 *
6 * Author(s): Peter Oberparleiter <Peter.Oberparleiter@de.ibm.com>,
7 * Heiko Carstens <heiko.carstens@de.ibm.com>,
8 *
9 */
10
11#include <linux/linkage.h>
12#include <asm/irq.h>
13
14LC_EXT_NEW_PSW = 0x58 # addr of ext int handler
15LC_EXT_NEW_PSW_64 = 0x1b0 # addr of ext int handler 64 bit
16LC_EXT_INT_PARAM = 0x80 # addr of ext int parameter
17LC_EXT_INT_CODE = 0x86 # addr of ext int code
18LC_AR_MODE_ID = 0xa3
19
20#
21# Subroutine which waits synchronously until either an external interruption
22# or a timeout occurs.
23#
24# Parameters:
25# R2 = 0 for no timeout, non-zero for timeout in (approximated) seconds
26#
27# Returns:
28# R2 = 0 on interrupt, 2 on timeout
29# R3 = external interruption parameter if R2=0
30#
31
32_sclp_wait_int:
33 stm %r6,%r15,24(%r15) # save registers
34 basr %r13,0 # get base register
35.LbaseS1:
36 ahi %r15,-96 # create stack frame
37 la %r8,LC_EXT_NEW_PSW # register int handler
38 la %r9,.LextpswS1-.LbaseS1(%r13)
39 tm LC_AR_MODE_ID,1
40 jno .Lesa1
41 la %r8,LC_EXT_NEW_PSW_64 # register int handler 64 bit
42 la %r9,.LextpswS1_64-.LbaseS1(%r13)
43.Lesa1:
44 mvc .LoldpswS1-.LbaseS1(16,%r13),0(%r8)
45 mvc 0(16,%r8),0(%r9)
46 epsw %r6,%r7 # set current addressing mode
47 nill %r6,0x1 # in new psw (31 or 64 bit mode)
48 nilh %r7,0x8000
49 stm %r6,%r7,0(%r8)
50 lhi %r6,0x0200 # cr mask for ext int (cr0.54)
51 ltr %r2,%r2
52 jz .LsetctS1
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)
58
59.LsetctS1:
60 stctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # enable required interrupts
61 l %r0,.LctlS1-.LbaseS1(%r13)
62 lhi %r1,~(0x200 | 0x800) # clear old values
63 nr %r1,%r0
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
69.LloopS1:
70 lpsw .LwaitpswS1-.LbaseS1(%r13) # wait until interrupt
71.LwaitS1:
72 lh %r7,LC_EXT_INT_CODE
73 chi %r7,EXT_IRQ_CLK_COMP # timeout?
74 je .LtimeoutS1
75 chi %r7,EXT_IRQ_SERVICE_SIG # service int?
76 jne .LloopS1
77 sr %r2,%r2
78 l %r3,LC_EXT_INT_PARAM
79.LtimeoutS1:
80 lctl %c0,%c0,.LctlS1-.LbaseS1(%r13) # restore interrupt setting
81 # restore old handler
82 mvc 0(16,%r8),.LoldpswS1-.LbaseS1(%r13)
83 lm %r6,%r15,120(%r15) # restore registers
84 br %r14 # return to caller
85
86 .align 8
87.LoldpswS1:
88 .long 0, 0, 0, 0 # old ext int PSW
89.LextpswS1:
90 .long 0x00080000, 0x80000000+.LwaitS1 # PSW to handle ext int
91.LextpswS1_64:
92 .quad 0, .LwaitS1 # PSW to handle ext int, 64 bit
93.LwaitpswS1:
94 .long 0x010a0000, 0x00000000+.LloopS1 # PSW to wait for ext int
95.LtimeS1:
96 .quad 0 # current time
97.LctlS1:
98 .long 0 # CT0 contents
99
100#
101# Subroutine to synchronously issue a service call.
102#
103# Parameters:
104# R2 = command word
105# R3 = sccb address
106#
107# Returns:
108# R2 = 0 on success, 1 on failure
109# R3 = sccb response code if R2 = 0
110#
111
112_sclp_servc:
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
117.LretryS2:
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
124 j .LretryS2 # retry
125.LnotbusyS2:
126 sr %r2,%r2 # wait until result
127 bras %r14,_sclp_wait_int
128 sr %r2,%r2
129 lh %r3,6(%r7)
130.LendS2:
131 lm %r6,%r15,120(%r15) # restore registers
132 br %r14
133
134#
135# Subroutine to set up the SCLP interface.
136#
137# Parameters:
138# R2 = 0 to activate, non-zero to deactivate
139#
140# Returns:
141# R2 = 0 on success, non-zero on failure
142#
143
144_sclp_setup:
145 stm %r6,%r15,24(%r15) # save registers
146 ahi %r15,-96 # create stack frame
147 basr %r13,0 # get base register
148.LbaseS3:
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
153 # clear masks
154 xc .LinitmaskS3-.LinitsccbS3(8,%r6),.LinitmaskS3-.LinitsccbS3(%r6)
155.LdoinitS3:
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?
160 jnz .LerrorS3
161 chi %r3,0x20 # write mask successful?
162 jne .LerrorS3
163 # check masks
164 la %r2,.LinitmaskS3-.LinitsccbS3(%r6)
165 l %r1,0(%r2) # receive mask ok?
166 n %r1,12(%r2)
167 cl %r1,0(%r2)
168 jne .LerrorS3
169 l %r1,4(%r2) # send mask ok?
170 n %r1,8(%r2)
171 cl %r1,4(%r2)
172 sr %r2,%r2
173 je .LendS3
174.LerrorS3:
175 lhi %r2,1 # error return code
176.LendS3:
177 lm %r6,%r15,120(%r15) # restore registers
178 br %r14
179.LwritemaskS3:
180 .long 0x00780005 # SCLP command for write mask
181.LinitsccbS3:
182 .word .LinitendS3-.LinitsccbS3
183 .byte 0,0,0,0
184 .word 0
185 .word 0
186 .word 4
187.LinitmaskS3:
188 .long 0x80000000
189 .long 0x40000000
190 .long 0
191 .long 0
192.LinitendS3:
193
194#
195# Subroutine which prints a given text to the SCLP console.
196#
197# Parameters:
198# R2 = address of nil-terminated ASCII text
199#
200# Returns:
201# R2 = 0 on success, 1 on failure
202#
203
204_sclp_print:
205 stm %r6,%r15,24(%r15) # save registers
206 ahi %r15,-96 # create stack frame
207 basr %r13,0 # get base register
208.LbaseS4:
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
212 sr %r0,%r0
213 l %r10,.Lascebc-.LbaseS4(%r13) # address of translation table
214.LinitmtoS4:
215 # initialize mto
216 mvc 0(.LmtoendS4-.LmtoS4,%r7),.LmtoS4-.LbaseS4(%r13)
217 lhi %r6,.LmtoendS4-.LmtoS4 # current mto length
218.LloopS4:
219 ic %r0,0(%r2) # get character
220 ahi %r2,1
221 ltr %r0,%r0 # end of string?
222 jz .LfinalizemtoS4
223 chi %r0,0x0a # end of line (NL)?
224 jz .LfinalizemtoS4
225 stc %r0,0(%r6,%r7) # copy to mto
226 la %r11,0(%r6,%r7)
227 tr 0(1,%r11),0(%r10) # translate to EBCDIC
228 ahi %r6,1
229 j .LloopS4
230.LfinalizemtoS4:
231 sth %r6,0(%r7) # update mto length
232 lh %r9,.LmdbS4-.LwritesccbS4(%r8) # update mdb length
233 ar %r9,%r6
234 sth %r9,.LmdbS4-.LwritesccbS4(%r8)
235 lh %r9,.LevbufS4-.LwritesccbS4(%r8)# update evbuf length
236 ar %r9,%r6
237 sth %r9,.LevbufS4-.LwritesccbS4(%r8)
238 lh %r9,0(%r8) # update sccb length
239 ar %r9,%r6
240 sth %r9,0(%r8)
241 ar %r7,%r6 # update current mto address
242 ltr %r0,%r0 # more characters?
243 jnz .LinitmtoS4
244 l %r2,.LwritedataS4-.LbaseS4(%r13)# write data
245 lr %r3,%r8
246 bras %r14,_sclp_servc
247 ltr %r2,%r2 # servc successful?
248 jnz .LendS4
249 chi %r3,0x20 # write data successful?
250 je .LendS4
251 lhi %r2,1 # error return code
252.LendS4:
253 lm %r6,%r15,120(%r15) # restore registers
254 br %r14
255
256#
257# Function which prints a given text to the SCLP console.
258#
259# Parameters:
260# R2 = address of nil-terminated ASCII text
261#
262# Returns:
263# R2 = 0 on success, 1 on failure
264#
265
266ENTRY(_sclp_print_early)
267 stm %r6,%r15,24(%r15) # save registers
268 ahi %r15,-96 # create stack frame
269 tm LC_AR_MODE_ID,1
270 jno .Lesa2
271 ahi %r15,-80
272 stmh %r6,%r15,96(%r15) # store upper register halves
273 basr %r13,0
274 lmh %r0,%r15,.Lzeroes-.(%r13) # clear upper register halves
275.Lesa2:
276 lr %r10,%r2 # save string pointer
277 lhi %r2,0
278 bras %r14,_sclp_setup # enable console
279 ltr %r2,%r2
280 jnz .LendS5
281 lr %r2,%r10
282 bras %r14,_sclp_print # print string
283 ltr %r2,%r2
284 jnz .LendS5
285 lhi %r2,1
286 bras %r14,_sclp_setup # disable console
287.LendS5:
288 tm LC_AR_MODE_ID,1
289 jno .Lesa3
290 lgfr %r2,%r2 # sign extend return value
291 lmh %r6,%r15,96(%r15) # restore upper register halves
292 ahi %r15,80
293.Lesa3:
294 lm %r6,%r15,120(%r15) # restore registers
295 br %r14
296.Lzeroes:
297 .fill 64,4,0
298
299.LwritedataS4:
300 .long 0x00760005 # SCLP command for write data
301.LwritesccbS4:
302 # sccb
303 .word .LmtoS4-.LwritesccbS4
304 .byte 0
305 .byte 0,0,0
306 .word 0
307
308 # evbuf
309.LevbufS4:
310 .word .LmtoS4-.LevbufS4
311 .byte 0x02
312 .byte 0
313 .word 0
314
315.LmdbS4:
316 # mdb
317 .word .LmtoS4-.LmdbS4
318 .word 1
319 .long 0xd4c4c240
320 .long 1
321
322 # go
323.LgoS4:
324 .word .LmtoS4-.LgoS4
325 .word 1
326 .long 0
327 .byte 0,0,0,0,0,0,0,0
328 .byte 0,0,0
329 .byte 0
330 .byte 0,0,0,0,0,0,0
331 .byte 0
332 .word 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
336
337.LmtoS4:
338 .word .LmtoendS4-.LmtoS4
339 .word 4
340 .word 0x1000
341 .byte 0
342 .byte 0,0,0
343.LmtoendS4:
344
345 # Global constants
346.LsccbS0:
347 .long _sclp_work_area
348.Lascebc:
349 .long _ascebc
350
351.section .data,"aw",@progbits
352 .balign 4096
353_sclp_work_area:
354 .fill 4096
355.previous
diff --git a/arch/s390/kernel/sclp.c b/arch/s390/kernel/sclp.c
new file mode 100644
index 000000000000..fa0bdff1d413
--- /dev/null
+++ b/arch/s390/kernel/sclp.c
@@ -0,0 +1,160 @@
1/*
2 * Copyright IBM Corp. 2015
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
4 */
5#include <linux/kernel.h>
6#include <asm/ebcdic.h>
7#include <asm/irq.h>
8#include <asm/lowcore.h>
9#include <asm/processor.h>
10#include <asm/sclp.h>
11
12static char _sclp_work_area[4096] __aligned(PAGE_SIZE);
13
14static void _sclp_wait_int(void)
15{
16 unsigned long cr0, cr0_new, psw_mask, addr;
17 psw_t psw_ext_save, psw_wait;
18
19 __ctl_store(cr0, 0, 0);
20 cr0_new = cr0 | 0x200;
21 __ctl_load(cr0_new, 0, 0);
22
23 psw_ext_save = S390_lowcore.external_new_psw;
24 psw_mask = __extract_psw() & (PSW_MASK_EA | PSW_MASK_BA);
25 S390_lowcore.external_new_psw.mask = psw_mask;
26 psw_wait.mask = psw_mask | PSW_MASK_EXT | PSW_MASK_WAIT;
27 S390_lowcore.ext_int_code = 0;
28
29 do {
30 asm volatile(
31 " larl %[addr],0f\n"
32 " stg %[addr],%[psw_wait_addr]\n"
33 " stg %[addr],%[psw_ext_addr]\n"
34 " lpswe %[psw_wait]\n"
35 "0:\n"
36 : [addr] "=&d" (addr),
37 [psw_wait_addr] "=Q" (psw_wait.addr),
38 [psw_ext_addr] "=Q" (S390_lowcore.external_new_psw.addr)
39 : [psw_wait] "Q" (psw_wait)
40 : "cc", "memory");
41 } while (S390_lowcore.ext_int_code != EXT_IRQ_SERVICE_SIG);
42
43 __ctl_load(cr0, 0, 0);
44 S390_lowcore.external_new_psw = psw_ext_save;
45}
46
47static int _sclp_servc(unsigned int cmd, char *sccb)
48{
49 unsigned int cc;
50
51 do {
52 asm volatile(
53 " .insn rre,0xb2200000,%1,%2\n"
54 " ipm %0\n"
55 : "=d" (cc) : "d" (cmd), "a" (sccb)
56 : "cc", "memory");
57 cc >>= 28;
58 if (cc == 3)
59 return -EINVAL;
60 _sclp_wait_int();
61 } while (cc != 0);
62 return (*(unsigned short *)(sccb + 6) == 0x20) ? 0 : -EIO;
63}
64
65static int _sclp_setup(int disable)
66{
67 static unsigned char init_sccb[] = {
68 0x00, 0x1c,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70 0x00, 0x04,
71 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
73 };
74 unsigned int *masks;
75 int rc;
76
77 memcpy(_sclp_work_area, init_sccb, 28);
78 masks = (unsigned int *)(_sclp_work_area + 12);
79 if (disable)
80 memset(masks, 0, 16);
81 /* SCLP write mask */
82 rc = _sclp_servc(0x00780005, _sclp_work_area);
83 if (rc)
84 return rc;
85 if ((masks[0] & masks[3]) != masks[0] ||
86 (masks[1] & masks[2]) != masks[1])
87 return -EIO;
88 return 0;
89}
90
91static int _sclp_print(const char *str)
92{
93 static unsigned char write_head[] = {
94 /* sccb header */
95 0x00, 0x52, /* 0 */
96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */
97 /* evbuf */
98 0x00, 0x4a, /* 8 */
99 0x02, 0x00, 0x00, 0x00, /* 10 */
100 /* mdb */
101 0x00, 0x44, /* 14 */
102 0x00, 0x01, /* 16 */
103 0xd4, 0xc4, 0xc2, 0x40, /* 18 */
104 0x00, 0x00, 0x00, 0x01, /* 22 */
105 /* go */
106 0x00, 0x38, /* 26 */
107 0x00, 0x01, /* 28 */
108 0x00, 0x00, 0x00, 0x00, /* 30 */
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 34 */
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 42 */
111 0x00, 0x00, 0x00, 0x00, /* 50 */
112 0x00, 0x00, /* 54 */
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 56 */
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 64 */
115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 72 */
116 0x00, 0x00, /* 80 */
117 };
118 static unsigned char write_mto[] = {
119 /* mto */
120 0x00, 0x0a, /* 0 */
121 0x00, 0x04, /* 2 */
122 0x10, 0x00, /* 4 */
123 0x00, 0x00, 0x00, 0x00 /* 6 */
124 };
125 unsigned char *ptr, ch;
126 unsigned int count;
127
128 memcpy(_sclp_work_area, write_head, sizeof(write_head));
129 ptr = _sclp_work_area + sizeof(write_head);
130 do {
131 memcpy(ptr, write_mto, sizeof(write_mto));
132 for (count = sizeof(write_mto); (ch = *str++) != 0; count++) {
133 if (ch == 0x0a)
134 break;
135 ptr[count] = _ascebc[ch];
136 }
137 /* Update length fields in mto, mdb, evbuf and sccb */
138 *(unsigned short *) ptr = count;
139 *(unsigned short *)(_sclp_work_area + 14) += count;
140 *(unsigned short *)(_sclp_work_area + 8) += count;
141 *(unsigned short *)(_sclp_work_area + 0) += count;
142 ptr += count;
143 } while (ch != 0);
144
145 /* SCLP write data */
146 return _sclp_servc(0x00760005, _sclp_work_area);
147}
148
149int _sclp_print_early(const char *str)
150{
151 int rc;
152
153 rc = _sclp_setup(0);
154 if (rc)
155 return rc;
156 rc = _sclp_print(str);
157 if (rc)
158 return rc;
159 return _sclp_setup(1);
160}