Lines Matching +full:max +full:- +full:len

2 #include "qemu/error-report.h"
6 #include "chardev/char-fe.h"
9 #include "hw/qdev-properties.h"
10 #include "hw/qdev-properties-system.h"
22 #define TYPE_VIO_SPAPR_VTY_DEVICE "spapr-vty"
29 return VTERM_BUFSIZE - (dev->in - dev->out); in OBJECT_DECLARE_SIMPLE_TYPE()
37 if ((dev->in == dev->out) && size) { in vty_receive()
39 spapr_vio_irq_pulse(&dev->sdev); in vty_receive()
42 if (dev->in - dev->out >= VTERM_BUFSIZE) { in vty_receive()
45 error_report("VTY input buffer exhausted - characters dropped." in vty_receive()
51 dev->buf[dev->in++ % VTERM_BUFSIZE] = buf[i]; in vty_receive()
55 static int vty_getchars(SpaprVioDevice *sdev, uint8_t *buf, int max) in vty_getchars() argument
60 while ((n < max) && (dev->out != dev->in)) { in vty_getchars()
69 if (n > 0 && (buf[n - 1] == '\r') && in vty_getchars()
70 (dev->buf[dev->out % VTERM_BUFSIZE] == '\0')) { in vty_getchars()
73 buf[n++] = dev->buf[dev->out++ % VTERM_BUFSIZE]; in vty_getchars()
76 qemu_chr_fe_accept_input(&dev->chardev); in vty_getchars()
81 void vty_putchars(SpaprVioDevice *sdev, uint8_t *buf, int len) in vty_putchars() argument
87 qemu_chr_fe_write_all(&dev->chardev, buf, len); in vty_putchars()
94 if (!qemu_chr_fe_backend_connected(&dev->chardev)) { in spapr_vty_realize()
99 qemu_chr_fe_set_handlers(&dev->chardev, vty_can_receive, in spapr_vty_realize()
108 target_ulong len = args[1]; in h_put_term_char() local
119 if (len > 16) { in h_put_term_char()
126 vty_putchars(sdev, buf, len); in h_put_term_char()
135 target_ulong *len = args + 0; in h_get_term_char() local
146 *len = vty_getchars(sdev, buf, sizeof(buf)); in h_get_term_char()
147 if (*len < 16) { in h_get_term_char()
148 memset(buf + *len, 0, 16 - *len); in h_get_term_char()
161 dev = qdev_new("spapr-vty"); in spapr_vty_create()
163 qdev_realize_and_unref(dev, &bus->bus, &error_fatal); in spapr_vty_create()
190 k->realize = spapr_vty_realize; in spapr_vty_class_init()
191 k->dt_name = "vty"; in spapr_vty_class_init()
192 k->dt_type = "serial"; in spapr_vty_class_init()
193 k->dt_compatible = "hvterm1"; in spapr_vty_class_init()
194 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); in spapr_vty_class_init()
196 dc->vmsd = &vmstate_spapr_vty; in spapr_vty_class_init()
218 QTAILQ_FOREACH(kid, &bus->bus.children, sibling) { in spapr_vty_get_default()
219 DeviceState *iter = kid->child; in spapr_vty_get_default()
235 if (sdev->reg < selected->reg) { in spapr_vty_get_default()
247 sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in vty_lookup()
254 return spapr_vty_get_default(spapr->vio_bus); in vty_lookup()