2 * SCLP ASCII access driver
4 * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
6 * This work is licensed under the terms of the GNU GPL, version 2 or (at
7 * your option) any later version. See the COPYING file in the top-level
14 static char _sccb
[PAGE_SIZE
] __attribute__((__aligned__(4096)));
16 /* Perform service call. Return 0 on success, non-zero otherwise. */
17 static int sclp_service_call(unsigned int command
, void *sccb
)
22 " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */
25 : "=&d" (cc
) : "d" (command
), "a" (__pa(sccb
))
35 static void sclp_set_write_mask(void)
37 WriteEventMask
*sccb
= (void *)_sccb
;
39 sccb
->h
.length
= sizeof(WriteEventMask
);
40 sccb
->mask_length
= sizeof(unsigned int);
41 sccb
->receive_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
42 sccb
->cp_receive_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
43 sccb
->send_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
44 sccb
->cp_send_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
46 sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK
, sccb
);
51 sclp_set_write_mask();
54 static int _strlen(const char *str
)
57 for (i
= 0; *str
; i
++)
62 static void _memcpy(char *dest
, const char *src
, int len
)
65 for (i
= 0; i
< len
; i
++)
69 void sclp_print(const char *str
)
71 int len
= _strlen(str
);
72 WriteEventData
*sccb
= (void *)_sccb
;
74 sccb
->h
.length
= sizeof(WriteEventData
) + len
;
75 sccb
->h
.function_code
= SCLP_FC_NORMAL_WRITE
;
76 sccb
->ebh
.length
= sizeof(EventBufferHeader
) + len
;
77 sccb
->ebh
.type
= SCLP_EVENT_ASCII_CONSOLE_DATA
;
79 _memcpy(sccb
->data
, str
, len
);
81 sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA
, sccb
);