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
))
34 static void sclp_set_write_mask(void)
36 WriteEventMask
*sccb
= (void*)_sccb
;
38 sccb
->h
.length
= sizeof(WriteEventMask
);
39 sccb
->mask_length
= sizeof(unsigned int);
40 sccb
->receive_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
41 sccb
->cp_receive_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
42 sccb
->send_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
43 sccb
->cp_send_mask
= SCLP_EVENT_MASK_MSG_ASCII
;
45 sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK
, sccb
);
50 sclp_set_write_mask();
53 static int _strlen(const char *str
)
56 for (i
= 0; *str
; i
++)
61 static void _memcpy(char *dest
, const char *src
, int len
)
64 for (i
= 0; i
< len
; i
++)
68 void sclp_print(const char *str
)
70 int len
= _strlen(str
);
71 WriteEventData
*sccb
= (void*)_sccb
;
73 sccb
->h
.length
= sizeof(WriteEventData
) + len
;
74 sccb
->h
.function_code
= SCLP_FC_NORMAL_WRITE
;
75 sccb
->ebh
.length
= sizeof(EventBufferHeader
) + len
;
76 sccb
->ebh
.type
= SCLP_EVENT_ASCII_CONSOLE_DATA
;
78 _memcpy(sccb
->data
, str
, len
);
80 sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA
, sccb
);