Lines Matching +full:layer +full:- +full:buffer +full:- +full:offset
11 * option) any later version. See the COPYING file in the top-level directory.
17 #include "qemu/error-report.h"
22 #include "hw/qdev-properties.h"
23 #include "hw/qdev-properties-system.h"
24 #include "hw/s390x/event-facility.h"
25 #include "chardev/char-fe.h"
40 uint32_t iov_sclp; /* offset in buf for SCLP read operation */
41 uint32_t iov_bs; /* offset in buf for char layer read operation */
42 uint32_t iov_data_len; /* length of byte stream in buffer */
52 /* character layer call-back functions */ in DECLARE_INSTANCE_CHECKER()
54 /* Return number of bytes that fit into iov buffer */ in DECLARE_INSTANCE_CHECKER()
58 int avail = SIZE_BUFFER_VT220 - scon->iov_data_len; in DECLARE_INSTANCE_CHECKER()
61 scon->notify = true; in DECLARE_INSTANCE_CHECKER()
72 /* read data must fit into current buffer */ in chr_read()
73 assert(size <= SIZE_BUFFER_VT220 - scon->iov_data_len); in chr_read()
75 /* put byte-stream from character layer into buffer */ in chr_read()
76 memcpy(&scon->iov[scon->iov_bs], buf, size); in chr_read()
77 scon->iov_data_len += size; in chr_read()
78 scon->iov_sclp_rest += size; in chr_read()
79 scon->iov_bs += size; in chr_read()
80 scon->event.event_pending = true; in chr_read()
101 /* triggered by SCLP's read_event_data -
102 * copy console data byte-stream into provided (SCLP) buffer
111 avail--; in get_console_data()
112 /* if all data fit into provided SCLP buffer */ in get_console_data()
113 if (avail >= cons->iov_sclp_rest) { in get_console_data()
114 /* copy character byte-stream to SCLP buffer */ in get_console_data()
115 memcpy(buf, &cons->iov[cons->iov_sclp], cons->iov_sclp_rest); in get_console_data()
116 *size = cons->iov_sclp_rest + 1; in get_console_data()
117 cons->iov_sclp = 0; in get_console_data()
118 cons->iov_bs = 0; in get_console_data()
119 cons->iov_data_len = 0; in get_console_data()
120 cons->iov_sclp_rest = 0; in get_console_data()
121 event->event_pending = false; in get_console_data()
124 /* if provided buffer is too small, just copy part */ in get_console_data()
125 memcpy(buf, &cons->iov[cons->iov_sclp], avail); in get_console_data()
127 cons->iov_sclp_rest -= avail; in get_console_data()
128 cons->iov_sclp += avail; in get_console_data()
131 if (cons->notify) { in get_console_data()
132 cons->notify = false; in get_console_data()
145 if (!event->event_pending) { in read_event_data()
150 to = (uint8_t *)&acd->data; in read_event_data()
151 avail = *slen - sizeof(ASCIIConsoleData); in read_event_data()
154 acd->ebh.length = cpu_to_be16(sizeof(ASCIIConsoleData) + src_len); in read_event_data()
155 acd->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; in read_event_data()
156 acd->ebh.flags |= SCLP_EVENT_BUFFER_ACCEPTED; in read_event_data()
157 *slen = avail - src_len; in read_event_data()
163 * - write console data to character layer
171 if (!qemu_chr_fe_backend_connected(&scon->chr)) { in write_console_data()
178 return qemu_chr_fe_write_all(&scon->chr, buf, len); in write_console_data()
188 length = be16_to_cpu(evt_buf_hdr->length) - sizeof(EventBufferHeader); in write_event_data()
189 written = write_console_data(event, (uint8_t *)acd->data, length); in write_event_data()
192 /* set event buffer accepted flag */ in write_event_data()
193 evt_buf_hdr->flags |= SCLP_EVENT_BUFFER_ACCEPTED; in write_event_data()
195 /* written will be zero if a pty is not connected - don't treat as error */ in write_event_data()
197 /* event buffer not accepted due to error in character layer */ in write_event_data()
198 evt_buf_hdr->flags &= ~(SCLP_EVENT_BUFFER_ACCEPTED); in write_event_data()
222 /* tell character layer our call-back functions */
232 return -1; in console_init()
235 qemu_chr_fe_set_handlers(&scon->chr, chr_can_read, in console_init()
246 event->event_pending = false; in console_reset()
247 scon->iov_sclp = 0; in console_reset()
248 scon->iov_bs = 0; in console_reset()
249 scon->iov_data_len = 0; in console_reset()
250 scon->iov_sclp_rest = 0; in console_reset()
251 scon->notify = false; in console_reset()
266 dc->vmsd = &vmstate_sclpconsole; in console_class_init()
267 ec->init = console_init; in console_class_init()
268 ec->get_send_mask = send_mask; in console_class_init()
269 ec->get_receive_mask = receive_mask; in console_class_init()
270 ec->can_handle_event = can_handle_event; in console_class_init()
271 ec->read_event_data = read_event_data; in console_class_init()
272 ec->write_event_data = write_event_data; in console_class_init()
273 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); in console_class_init()