Lines Matching defs:chr
163 CharDriverState *chr;
167 QTAILQ_FOREACH(chr, &chardevs, next) {
168 qemu_chr_reset(chr);
230 /* chr driver being released. */
247 static int null_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
254 CharDriverState *chr;
256 chr = g_malloc0(sizeof(CharDriverState));
257 chr->chr_write = null_chr_write;
258 return chr;
287 static int mux_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
289 MuxDriver *d = chr->opaque;
338 static void mux_print_help(CharDriverState *chr)
352 chr->chr_write(chr, (uint8_t *)cbuf, strlen(cbuf));
356 chr->chr_write(chr, (uint8_t *)ebuf, strlen(ebuf));
358 chr->chr_write(chr, (uint8_t *)&mux_help[i][j], 1);
369 static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
378 mux_print_help(chr);
383 chr->chr_write(chr,(uint8_t *)term,strlen(term));
391 qemu_chr_event(chr, CHR_EVENT_BREAK);
416 static void mux_chr_accept_input(CharDriverState *chr)
418 MuxDriver *d = chr->opaque;
431 CharDriverState *chr = opaque;
432 MuxDriver *d = chr->opaque;
444 CharDriverState *chr = opaque;
445 MuxDriver *d = chr->opaque;
452 if (mux_proc_byte(chr, d, buf[i])) {
464 CharDriverState *chr = opaque;
465 MuxDriver *d = chr->opaque;
473 static void mux_chr_update_read_handler(CharDriverState *chr)
475 MuxDriver *d = chr->opaque;
481 d->ext_opaque[d->mux_cnt] = chr->handler_opaque;
482 d->chr_can_read[d->mux_cnt] = chr->chr_can_read;
483 d->chr_read[d->mux_cnt] = chr->chr_read;
484 d->chr_event[d->mux_cnt] = chr->chr_event;
488 mux_chr_event, chr);
500 CharDriverState *chr;
503 chr = g_malloc0(sizeof(CharDriverState));
506 chr->opaque = d;
509 chr->chr_write = mux_chr_write;
510 chr->chr_update_read_handler = mux_chr_update_read_handler;
511 chr->chr_accept_input = mux_chr_accept_input;
513 chr->chr_guest_open = NULL;
514 chr->chr_guest_close = NULL;
517 qemu_chr_generic_open(chr);
519 return chr;
608 static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
610 FDCharDriver *s = chr->opaque;
616 CharDriverState *chr = opaque;
617 FDCharDriver *s = chr->opaque;
619 s->max_size = qemu_chr_can_read(chr);
625 CharDriverState *chr = opaque;
626 FDCharDriver *s = chr->opaque;
639 qemu_chr_event(chr, CHR_EVENT_CLOSED);
643 qemu_chr_read(chr, buf, size);
647 static void fd_chr_update_read_handler(CharDriverState *chr)
649 FDCharDriver *s = chr->opaque;
655 fd_chr_read, NULL, chr);
660 static void fd_chr_close(struct CharDriverState *chr)
662 FDCharDriver *s = chr->opaque;
672 qemu_chr_event(chr, CHR_EVENT_CLOSED);
678 CharDriverState *chr;
681 chr = g_malloc0(sizeof(CharDriverState));
685 chr->opaque = s;
686 chr->chr_write = fd_chr_write;
687 chr->chr_update_read_handler = fd_chr_update_read_handler;
688 chr->chr_close = fd_chr_close;
690 qemu_chr_generic_open(chr);
692 return chr;
756 CharDriverState *chr = opaque;
759 if (term_fifo_size != 0 && qemu_chr_can_read(chr) > 0) {
760 qemu_chr_read(chr, term_fifo, 1);
774 CharDriverState *chr = opaque;
780 qemu_chr_event(chr, CHR_EVENT_CLOSED);
784 if (qemu_chr_can_read(chr) > 0) {
785 qemu_chr_read(chr, buf, 1);
803 static void qemu_chr_set_echo_stdio(CharDriverState *chr, bool echo)
825 static void qemu_chr_close_stdio(struct CharDriverState *chr)
830 fd_chr_close(chr);
835 CharDriverState *chr;
846 chr = qemu_chr_open_fd(0, 1);
847 chr->chr_close = qemu_chr_close_stdio;
848 chr->chr_set_echo = qemu_chr_set_echo_stdio;
849 qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);
853 qemu_chr_set_echo(chr, false);
855 return chr;
925 static void pty_chr_update_read_handler(CharDriverState *chr);
926 static void pty_chr_state(CharDriverState *chr, int connected);
928 static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
930 PtyCharDriver *s = chr->opaque;
934 pty_chr_update_read_handler(chr);
942 CharDriverState *chr = opaque;
943 PtyCharDriver *s = chr->opaque;
945 s->read_bytes = qemu_chr_can_read(chr);
951 CharDriverState *chr = opaque;
952 PtyCharDriver *s = chr->opaque;
964 pty_chr_state(chr, 0);
968 pty_chr_state(chr, 1);
969 qemu_chr_read(chr, buf, size);
973 static void pty_chr_update_read_handler(CharDriverState *chr)
975 PtyCharDriver *s = chr->opaque;
978 pty_chr_read, NULL, chr);
991 static void pty_chr_state(CharDriverState *chr, int connected)
993 PtyCharDriver *s = chr->opaque;
1005 qemu_chr_generic_open(chr);
1012 struct CharDriverState *chr = opaque;
1013 PtyCharDriver *s = chr->opaque;
1020 pty_chr_state(chr, 1);
1025 pty_chr_update_read_handler(chr);
1028 static void pty_chr_close(struct CharDriverState *chr)
1030 PtyCharDriver *s = chr->opaque;
1037 qemu_chr_event(chr, CHR_EVENT_CLOSED);
1042 CharDriverState *chr;
1055 chr = g_malloc0(sizeof(CharDriverState));
1069 chr->filename = g_malloc(len);
1070 snprintf(chr->filename, len, "pty:%s", q_ptsname(s->fd));
1074 chr->opaque = s;
1075 chr->chr_write = pty_chr_write;
1076 chr->chr_update_read_handler = pty_chr_update_read_handler;
1077 chr->chr_close = pty_chr_close;
1079 s->timer = timer_new(QEMU_CLOCK_REALTIME, SCALE_MS, pty_chr_timer, chr);
1081 return chr;
1199 static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg)
1201 FDCharDriver *s = chr->opaque;
1266 static void qemu_chr_close_tty(CharDriverState *chr)
1268 FDCharDriver *s = chr->opaque;
1275 fd_chr_close(chr);
1285 CharDriverState *chr;
1293 chr = qemu_chr_open_fd(fd, fd);
1294 if (!chr) {
1298 chr->chr_ioctl = tty_serial_ioctl;
1299 chr->chr_close = qemu_chr_close_tty;
1300 return chr;
1326 static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
1328 ParallelCharDriver *drv = chr->opaque;
1407 static void pp_close(CharDriverState *chr)
1409 ParallelCharDriver *drv = chr->opaque;
1416 qemu_chr_event(chr, CHR_EVENT_CLOSED);
1422 CharDriverState *chr;
1439 chr = g_malloc0(sizeof(CharDriverState));
1440 chr->chr_write = null_chr_write;
1441 chr->chr_ioctl = pp_ioctl;
1442 chr->chr_close = pp_close;
1443 chr->opaque = drv;
1445 qemu_chr_generic_open(chr);
1447 return chr;
1452 static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
1454 int fd = (int)(intptr_t)chr->opaque;
1492 CharDriverState *chr;
1499 chr = g_malloc0(sizeof(CharDriverState));
1500 chr->opaque = (void *)(intptr_t)fd;
1501 chr->chr_write = null_chr_write;
1502 chr->chr_ioctl = pp_ioctl;
1503 return chr;
1525 static void win_chr_close(CharDriverState *chr)
1527 WinCharState *s = chr->opaque;
1542 qemu_del_polling_cb(win_chr_pipe_poll, chr);
1544 qemu_del_polling_cb(win_chr_poll, chr);
1546 qemu_chr_event(chr, CHR_EVENT_CLOSED);
1549 static int win_chr_init(CharDriverState *chr, const char *filename)
1551 WinCharState *s = chr->opaque;
1608 qemu_add_polling_cb(win_chr_poll, chr);
1612 win_chr_close(chr);
1616 static int win_chr_write(CharDriverState *chr, const uint8_t *buf, int len1)
1618 WinCharState *s = chr->opaque;
1650 static int win_chr_read_poll(CharDriverState *chr)
1652 WinCharState *s = chr->opaque;
1654 s->max_size = qemu_chr_can_read(chr);
1658 static void win_chr_readfile(CharDriverState *chr)
1660 WinCharState *s = chr->opaque;
1676 qemu_chr_read(chr, buf, size);
1680 static void win_chr_read(CharDriverState *chr)
1682 WinCharState *s = chr->opaque;
1689 win_chr_readfile(chr);
1694 CharDriverState *chr = opaque;
1695 WinCharState *s = chr->opaque;
1702 win_chr_read_poll(chr);
1703 win_chr_read(chr);
1712 CharDriverState *chr;
1715 chr = g_malloc0(sizeof(CharDriverState));
1717 chr->opaque = s;
1718 chr->chr_write = win_chr_write;
1719 chr->chr_close = win_chr_close;
1721 if (win_chr_init(chr, filename) < 0) {
1723 free(chr);
1726 qemu_chr_generic_open(chr);
1727 return chr;
1732 CharDriverState *chr = opaque;
1733 WinCharState *s = chr->opaque;
1739 win_chr_read_poll(chr);
1740 win_chr_read(chr);
1746 static int win_chr_pipe_init(CharDriverState *chr, const char *filename)
1748 WinCharState *s = chr->opaque;
1800 qemu_add_polling_cb(win_chr_pipe_poll, chr);
1804 win_chr_close(chr);
1812 CharDriverState *chr;
1815 chr = g_malloc0(sizeof(CharDriverState));
1817 chr->opaque = s;
1818 chr->chr_write = win_chr_write;
1819 chr->chr_close = win_chr_close;
1821 if (win_chr_pipe_init(chr, filename) < 0) {
1823 free(chr);
1826 qemu_chr_generic_open(chr);
1827 return chr;
1832 CharDriverState *chr;
1835 chr = g_malloc0(sizeof(CharDriverState));
1838 chr->opaque = s;
1839 chr->chr_write = win_chr_write;
1840 qemu_chr_generic_open(chr);
1841 return chr;
1875 static int udp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
1877 NetCharDriver *s = chr->opaque;
1884 CharDriverState *chr = opaque;
1885 NetCharDriver *s = chr->opaque;
1887 s->max_size = qemu_chr_can_read(chr);
1893 qemu_chr_read(chr, &s->buf[s->bufptr], 1);
1895 s->max_size = qemu_chr_can_read(chr);
1902 CharDriverState *chr = opaque;
1903 NetCharDriver *s = chr->opaque;
1914 qemu_chr_read(chr, &s->buf[s->bufptr], 1);
1916 s->max_size = qemu_chr_can_read(chr);
1920 static void udp_chr_update_read_handler(CharDriverState *chr)
1922 NetCharDriver *s = chr->opaque;
1926 udp_chr_read, NULL, chr);
1930 static void udp_chr_close(CharDriverState *chr)
1932 NetCharDriver *s = chr->opaque;
1942 CharDriverState *chr
1946 chr = g_malloc0(sizeof(CharDriverState));
1958 chr->opaque = s;
1959 chr->chr_write = udp_chr_write;
1960 chr->chr_update_read_handler = udp_chr_update_read_handler;
1961 chr->chr_close = udp_chr_close;
1962 return chr;
1965 if (chr)
1966 free(chr);
1989 static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
1991 TCPCharDriver *s = chr->opaque;
2002 CharDriverState *chr = opaque;
2003 TCPCharDriver *s = chr->opaque;
2006 s->max_size = qemu_chr_can_read(chr);
2012 static void tcp_chr_process_IAC_bytes(CharDriverState *chr,
2039 qemu_chr_event(chr, CHR_EVENT_BREAK);
2060 static int tcp_get_msgfd(CharDriverState *chr)
2062 TCPCharDriver *s = chr->opaque;
2069 static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg)
2071 TCPCharDriver *s = chr->opaque;
2092 static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
2094 TCPCharDriver *s = chr->opaque;
2113 unix_process_msgfd(chr, &msg);
2118 static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
2120 TCPCharDriver *s = chr->opaque;
2127 CharDriverState *chr = opaque;
2128 TCPCharDriver *s = chr->opaque;
2137 size = tcp_chr_recv(chr, (void *)buf, len);
2142 qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
2147 qemu_chr_event(chr, CHR_EVENT_CLOSED);
2150 tcp_chr_process_IAC_bytes(chr, s, buf, &size);
2152 qemu_chr_read(chr, buf, size);
2165 CharDriverState *chr = opaque;
2166 TCPCharDriver *s = chr->opaque;
2170 tcp_chr_read, NULL, chr);
2171 qemu_chr_generic_open(chr);
2191 CharDriverState *chr = opaque;
2192 TCPCharDriver *s = chr->opaque;
2210 tcp_chr_connect(chr);
2213 static void tcp_chr_close(CharDriverState *chr)
2215 TCPCharDriver *s = chr->opaque;
2225 qemu_chr_event(chr, CHR_EVENT_CLOSED);
2230 CharDriverState *chr = NULL;
2247 chr = g_malloc0(sizeof(CharDriverState));
2276 chr->opaque = s;
2277 chr->chr_write = tcp_chr_write;
2278 chr->chr_close = tcp_chr_close;
2279 chr->get_msgfd = tcp_get_msgfd;
2283 qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
2291 tcp_chr_connect(chr);
2295 chr->filename = g_malloc(256);
2297 snprintf(chr->filename, 256, "unix:%s%s",
2301 snprintf(chr->filename, 256, "telnet:%s:%s%s",
2305 snprintf(chr->filename, 256, "tcp:%s:%s%s",
2312 chr->filename);
2313 tcp_chr_accept(chr);
2316 return chr;
2322 g_free(chr);
2334 static int mem_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
2336 MemoryDriver *d = chr->opaque;
2353 void qemu_chr_init_mem(CharDriverState *chr)
2362 memset(chr, 0, sizeof(*chr));
2363 chr->opaque = d;
2364 chr->chr_write = mem_chr_write;
2367 QString *qemu_chr_mem_to_qs(CharDriverState *chr)
2369 MemoryDriver *d = chr->opaque;
2374 void qemu_chr_close_mem(CharDriverState *chr)
2376 MemoryDriver *d = chr->opaque;
2379 g_free(chr->opaque);
2380 chr->opaque = NULL;
2381 chr->chr_write = NULL;
2384 size_t qemu_chr_mem_osize(const CharDriverState *chr)
2386 const MemoryDriver *d = chr->opaque;
2594 CharDriverState *chr;
2617 chr = backend_table[i].open(opts);
2618 if (!chr) {
2624 if (!chr->filename)
2625 chr->filename = g_strdup(qemu_opt_get(opts, "backend"));
2626 chr->init = init;
2627 QTAILQ_INSERT_TAIL(&chardevs, chr, next);
2630 CharDriverState *base = chr;
2634 chr = qemu_chr_open_mux(base);
2635 chr->filename = base->filename;
2636 chr->avail_connections = MAX_MUX;
2637 QTAILQ_INSERT_TAIL(&chardevs, chr, next);
2639 chr->avail_connections = 1;
2641 chr->label = g_strdup(qemu_opts_id(opts));
2642 return chr;
2648 CharDriverState *chr;
2659 chr = qemu_chr_open_opts(opts, init);
2660 if (chr && qemu_opt_get_bool(opts, "mux", 0)) {
2661 monitor_init(chr, MONITOR_USE_READLINE);
2664 return chr;
2667 void qemu_chr_set_echo(struct CharDriverState *chr, bool echo)
2669 if (chr->chr_set_echo) {
2670 chr->chr_set_echo(chr, echo);
2674 void qemu_chr_guest_open(struct CharDriverState *chr)
2676 if (chr->chr_guest_open) {
2677 chr->chr_guest_open(chr);
2681 void qemu_chr_guest_close(struct CharDriverState *chr)
2683 if (chr->chr_guest_close) {
2684 chr->chr_guest_close(chr);
2688 void qemu_chr_close(CharDriverState *chr)
2690 QTAILQ_REMOVE(&chardevs, chr, next);
2691 if (chr->chr_close)
2692 chr->chr_close(chr);
2693 g_free(chr->filename);
2694 g_free(chr->label);
2695 g_free(chr);
2716 CharDriverState *chr;
2720 QTAILQ_FOREACH(chr, &chardevs, next) {
2722 chr->label, chr->filename);
2731 CharDriverState *chr;
2733 QTAILQ_FOREACH(chr, &chardevs, next) {
2734 if (strcmp(chr->label, name) != 0)
2736 return chr;