From 8228e353d8906bf43399ca0ef28446c5c48bb686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 26 Jan 2017 17:19:46 +0400 Subject: chardev: move headers to include/chardev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So they are all in one place. The following patch will move serial & parallel declarations to the respective headers. Signed-off-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé --- MAINTAINERS | 1 + backends/baum.c | 2 +- backends/msmouse.c | 2 +- backends/rng-egd.c | 2 +- backends/testdev.c | 2 +- backends/wctablet.c | 2 +- chardev/char-console.c | 2 +- chardev/char-fd.c | 6 +- chardev/char-fd.h | 44 ---- chardev/char-file.c | 6 +- chardev/char-io.c | 2 +- chardev/char-io.h | 46 ---- chardev/char-mux.c | 4 +- chardev/char-mux.h | 63 ----- chardev/char-null.c | 2 +- chardev/char-parallel.c | 6 +- chardev/char-parallel.h | 32 --- chardev/char-pipe.c | 6 +- chardev/char-pty.c | 4 +- chardev/char-ringbuf.c | 2 +- chardev/char-serial.c | 6 +- chardev/char-serial.h | 35 --- chardev/char-socket.c | 4 +- chardev/char-stdio.c | 8 +- chardev/char-udp.c | 4 +- chardev/char-win-stdio.c | 4 +- chardev/char-win-stdio.h | 29 --- chardev/char-win.c | 2 +- chardev/char-win.h | 51 ---- chardev/char.c | 10 +- gdbstub.c | 2 +- hmp.c | 2 +- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx31.c | 2 +- hw/arm/fsl-imx6.c | 2 +- hw/arm/omap2.c | 2 +- hw/arm/pxa2xx.c | 2 +- hw/arm/strongarm.c | 2 +- hw/bt/hci-csr.c | 2 +- hw/char/cadence_uart.c | 2 +- hw/char/debugcon.c | 2 +- hw/char/digic-uart.c | 2 +- hw/char/escc.c | 2 +- hw/char/etraxfs_ser.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/char/ipoctal232.c | 2 +- hw/char/lm32_juart.c | 2 +- hw/char/lm32_uart.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/milkymist-uart.c | 2 +- hw/char/omap_uart.c | 2 +- hw/char/parallel.c | 2 +- hw/char/pl011.c | 2 +- hw/char/sclpconsole-lm.c | 2 +- hw/char/sclpconsole.c | 2 +- hw/char/serial.c | 2 +- hw/char/sh_serial.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/terminal3270.c | 2 +- hw/char/virtio-console.c | 2 +- hw/char/xen_console.c | 2 +- hw/char/xilinx_uartlite.c | 2 +- hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 2 +- hw/ipmi/ipmi_bmc_extern.c | 2 +- hw/isa/pc87312.c | 2 +- hw/mips/boston.c | 2 +- hw/misc/ivshmem.c | 2 +- hw/usb/ccid-card-passthru.c | 2 +- hw/usb/dev-serial.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio/vhost-user.c | 2 +- hw/xen/xen-common.c | 2 +- hw/xtensa/xtfpga.c | 2 +- include/chardev/char-fd.h | 44 ++++ include/chardev/char-io.h | 46 ++++ include/chardev/char-mux.h | 63 +++++ include/chardev/char-parallel.h | 32 +++ include/chardev/char-serial.h | 35 +++ include/chardev/char-win-stdio.h | 29 +++ include/chardev/char-win.h | 51 ++++ include/chardev/char.h | 499 ++++++++++++++++++++++++++++++++++++++ include/hw/char/bcm2835_aux.h | 2 +- include/hw/char/cadence_uart.h | 2 +- include/hw/char/digic-uart.h | 2 +- include/hw/char/imx_serial.h | 2 +- include/hw/char/serial.h | 4 +- include/hw/char/stm32f2xx_usart.h | 2 +- include/sysemu/char.h | 499 -------------------------------------- monitor.c | 2 +- net/colo-compare.c | 2 +- net/filter-mirror.c | 2 +- net/slirp.c | 2 +- net/vhost-user.c | 2 +- qmp.c | 2 +- qtest.c | 2 +- replay/replay-char.c | 2 +- slirp/slirp.c | 2 +- spice-qemu-char.c | 2 +- tests/postcopy-test.c | 2 +- tests/test-char.c | 2 +- tests/vhost-user-test.c | 2 +- ui/console.c | 2 +- ui/gtk.c | 2 +- vl.c | 2 +- 106 files changed, 912 insertions(+), 911 deletions(-) delete mode 100644 chardev/char-fd.h delete mode 100644 chardev/char-io.h delete mode 100644 chardev/char-mux.h delete mode 100644 chardev/char-parallel.h delete mode 100644 chardev/char-serial.h delete mode 100644 chardev/char-win-stdio.h delete mode 100644 chardev/char-win.h create mode 100644 include/chardev/char-fd.h create mode 100644 include/chardev/char-io.h create mode 100644 include/chardev/char-mux.h create mode 100644 include/chardev/char-parallel.h create mode 100644 include/chardev/char-serial.h create mode 100644 include/chardev/char-win-stdio.h create mode 100644 include/chardev/char-win.h create mode 100644 include/chardev/char.h delete mode 100644 include/sysemu/char.h diff --git a/MAINTAINERS b/MAINTAINERS index 7df088259b..48e2964ed8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1238,6 +1238,7 @@ M: Paolo Bonzini M: Marc-André Lureau S: Maintained F: chardev/ +F: include/chardev/ F: backends/msmouse.c F: backends/testdev.c diff --git a/backends/baum.c b/backends/baum.c index 2eddcae119..302dd9666c 100644 --- a/backends/baum.c +++ b/backends/baum.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/timer.h" #include "hw/usb.h" #include "ui/console.h" diff --git a/backends/msmouse.c b/backends/msmouse.c index d2c3162f1e..0ffd137ce8 100644 --- a/backends/msmouse.c +++ b/backends/msmouse.c @@ -23,7 +23,7 @@ */ #include "qemu/osdep.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "ui/console.h" #include "ui/input.h" diff --git a/backends/rng-egd.c b/backends/rng-egd.c index 380b19a0a1..5448f6e5f5 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "sysemu/rng.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" diff --git a/backends/testdev.c b/backends/testdev.c index 7df9248a13..031e9a23e8 100644 --- a/backends/testdev.c +++ b/backends/testdev.c @@ -25,7 +25,7 @@ */ #include "qemu/osdep.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #define BUF_SIZE 32 diff --git a/backends/wctablet.c b/backends/wctablet.c index a4d3ae098a..07a4cde956 100644 --- a/backends/wctablet.c +++ b/backends/wctablet.c @@ -32,7 +32,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "ui/console.h" #include "ui/input.h" #include "trace.h" diff --git a/chardev/char-console.c b/chardev/char-console.c index 8d972c1506..535ed65136 100644 --- a/chardev/char-console.c +++ b/chardev/char-console.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "char-win.h" +#include "chardev/char-win.h" static void qemu_chr_open_win_con(Chardev *chr, ChardevBackend *backend, diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 0b182c552c..1584a3de20 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -25,11 +25,11 @@ #include "qemu/sockets.h" #include "qapi/error.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "io/channel-file.h" -#include "char-fd.h" -#include "char-io.h" +#include "chardev/char-fd.h" +#include "chardev/char-io.h" /* Called with chr_write_lock held. */ static int fd_chr_write(Chardev *chr, const uint8_t *buf, int len) diff --git a/chardev/char-fd.h b/chardev/char-fd.h deleted file mode 100644 index d8327982fb..0000000000 --- a/chardev/char-fd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_FD_H -#define CHAR_FD_H - -#include "io/channel.h" -#include "sysemu/char.h" - -typedef struct FDChardev { - Chardev parent; - Chardev *chr; - QIOChannel *ioc_in, *ioc_out; - int max_size; -} FDChardev; - -#define TYPE_CHARDEV_FD "chardev-fd" - -#define FD_CHARDEV(obj) OBJECT_CHECK(FDChardev, (obj), TYPE_CHARDEV_FD) - -void qemu_chr_open_fd(Chardev *chr, int fd_in, int fd_out); -int qmp_chardev_open_file_source(char *src, int flags, Error **errp); - -#endif /* CHAR_FD_H */ diff --git a/chardev/char-file.c b/chardev/char-file.c index aed4ae1569..a57b88aaf2 100644 --- a/chardev/char-file.c +++ b/chardev/char-file.c @@ -24,12 +24,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #ifdef _WIN32 -#include "char-win.h" +#include "chardev/char-win.h" #else -#include "char-fd.h" +#include "chardev/char-fd.h" #endif static void qmp_chardev_open_file(Chardev *chr, diff --git a/chardev/char-io.c b/chardev/char-io.c index b5708eef45..f81052481a 100644 --- a/chardev/char-io.c +++ b/chardev/char-io.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "char-io.h" +#include "chardev/char-io.h" typedef struct IOWatchPoll { GSource parent; diff --git a/chardev/char-io.h b/chardev/char-io.h deleted file mode 100644 index 55973a7671..0000000000 --- a/chardev/char-io.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_IO_H -#define CHAR_IO_H - -#include "qemu-common.h" -#include "io/channel.h" -#include "sysemu/char.h" - -/* Can only be used for read */ -GSource *io_add_watch_poll(Chardev *chr, - QIOChannel *ioc, - IOCanReadHandler *fd_can_read, - QIOChannelFunc fd_read, - gpointer user_data, - GMainContext *context); - -void remove_fd_in_watch(Chardev *chr); - -int io_channel_send(QIOChannel *ioc, const void *buf, size_t len); - -int io_channel_send_full(QIOChannel *ioc, const void *buf, size_t len, - int *fds, size_t nfds); - -#endif /* CHAR_IO_H */ diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 37d42c65c6..106c682e7f 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -24,9 +24,9 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/block-backend.h" -#include "char-mux.h" +#include "chardev/char-mux.h" /* MUX driver for serial I/O splitting */ diff --git a/chardev/char-mux.h b/chardev/char-mux.h deleted file mode 100644 index 3f41dfcfd2..0000000000 --- a/chardev/char-mux.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_MUX_H -#define CHAR_MUX_H - -#include "sysemu/char.h" - -extern bool muxes_realized; - -#define MAX_MUX 4 -#define MUX_BUFFER_SIZE 32 /* Must be a power of 2. */ -#define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1) -typedef struct MuxChardev { - Chardev parent; - CharBackend *backends[MAX_MUX]; - CharBackend chr; - int focus; - int mux_cnt; - int term_got_escape; - int max_size; - /* Intermediate input buffer catches escape sequences even if the - currently active device is not accepting any input - but only until it - is full as well. */ - unsigned char buffer[MAX_MUX][MUX_BUFFER_SIZE]; - int prod[MAX_MUX]; - int cons[MAX_MUX]; - int timestamps; - - /* Protected by the Chardev chr_write_lock. */ - int linestart; - int64_t timestamps_start; -} MuxChardev; - -#define MUX_CHARDEV(obj) OBJECT_CHECK(MuxChardev, (obj), TYPE_CHARDEV_MUX) -#define CHARDEV_IS_MUX(chr) \ - object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX) - -void mux_chr_set_handlers(Chardev *chr, GMainContext *context); -void mux_set_focus(Chardev *chr, int focus); -void mux_chr_send_all_event(Chardev *chr, int event); - -#endif /* CHAR_MUX_H */ diff --git a/chardev/char-null.c b/chardev/char-null.c index dc0d68ab2d..90bafe76f4 100644 --- a/chardev/char-null.c +++ b/chardev/char-null.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" static void null_chr_open(Chardev *chr, ChardevBackend *backend, diff --git a/chardev/char-parallel.c b/chardev/char-parallel.c index 3fa22ce29d..bce89f8c36 100644 --- a/chardev/char-parallel.c +++ b/chardev/char-parallel.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qapi/error.h" #include @@ -41,8 +41,8 @@ #endif #endif -#include "char-fd.h" -#include "char-parallel.h" +#include "chardev/char-fd.h" +#include "chardev/char-parallel.h" #if defined(__linux__) diff --git a/chardev/char-parallel.h b/chardev/char-parallel.h deleted file mode 100644 index 26742f9d5c..0000000000 --- a/chardev/char-parallel.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_PARALLEL_H -#define CHAR_PARALLEL_H - -#if defined(__linux__) || defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || defined(__DragonFly__) -#define HAVE_CHARDEV_PARPORT 1 -#endif - -#endif /* CHAR_PARALLEL_H */ diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c index aae950a22b..3a95e4c1b2 100644 --- a/chardev/char-pipe.c +++ b/chardev/char-pipe.c @@ -23,12 +23,12 @@ */ #include "qemu/osdep.h" #include "qapi/error.h" -#include "sysemu/char.h" +#include "chardev/char.h" #ifdef _WIN32 -#include "char-win.h" +#include "chardev/char-win.h" #else -#include "char-fd.h" +#include "chardev/char-fd.h" #endif #ifdef _WIN32 diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 35a175d796..e5d20a0e6a 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -24,12 +24,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "io/channel-file.h" #include "qemu/sockets.h" #include "qemu/error-report.h" -#include "char-io.h" +#include "chardev/char-io.h" #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ diff --git a/chardev/char-ringbuf.c b/chardev/char-ringbuf.c index d130069e88..df52b04d22 100644 --- a/chardev/char-ringbuf.c +++ b/chardev/char-ringbuf.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qmp-commands.h" #include "qemu/base64.h" diff --git a/chardev/char-serial.c b/chardev/char-serial.c index fef3a91c77..2f8f83821d 100644 --- a/chardev/char-serial.c +++ b/chardev/char-serial.c @@ -27,14 +27,14 @@ #include "qapi/error.h" #ifdef _WIN32 -#include "char-win.h" +#include "chardev/char-win.h" #else #include #include -#include "char-fd.h" +#include "chardev/char-fd.h" #endif -#include "char-serial.h" +#include "chardev/char-serial.h" #ifdef _WIN32 diff --git a/chardev/char-serial.h b/chardev/char-serial.h deleted file mode 100644 index 64a27f63b1..0000000000 --- a/chardev/char-serial.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_SERIAL_H -#define CHAR_SERIAL_H - -#ifdef _WIN32 -#define HAVE_CHARDEV_SERIAL 1 -#elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ - || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ - || defined(__GLIBC__) -#define HAVE_CHARDEV_SERIAL 1 -#endif - -#endif diff --git a/chardev/char-socket.c b/chardev/char-socket.c index e2fb7f7cd5..ccc499cfa1 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -22,14 +22,14 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "io/channel-socket.h" #include "io/channel-tls.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/clone-visitor.h" -#include "char-io.h" +#include "chardev/char-io.h" /***********************************************************/ /* TCP Net console */ diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index be4a65962c..6f5d798d7b 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -25,14 +25,14 @@ #include "qemu/sockets.h" #include "qapi/error.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #ifdef _WIN32 -#include "char-win.h" -#include "char-win-stdio.h" +#include "chardev/char-win.h" +#include "chardev/char-win-stdio.h" #else #include -#include "char-fd.h" +#include "chardev/char-fd.h" #endif #ifndef _WIN32 diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 607647642a..4ee11d3ebf 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "io/channel-socket.h" #include "qapi/error.h" -#include "char-io.h" +#include "chardev/char-io.h" /***********************************************************/ /* UDP Net console */ diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c index eb44afc17a..efcf7827eb 100644 --- a/chardev/char-win-stdio.c +++ b/chardev/char-win-stdio.c @@ -23,8 +23,8 @@ */ #include "qemu/osdep.h" #include "qapi/error.h" -#include "char-win.h" -#include "char-win-stdio.h" +#include "chardev/char-win.h" +#include "chardev/char-win-stdio.h" typedef struct { Chardev parent; diff --git a/chardev/char-win-stdio.h b/chardev/char-win-stdio.h deleted file mode 100644 index d7314f734d..0000000000 --- a/chardev/char-win-stdio.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_WIN_STDIO_H -#define CHAR_WIN_STDIO_H - -#define TYPE_CHARDEV_WIN_STDIO "chardev-win-stdio" - -#endif /* CHAR_WIN_STDIO_H */ diff --git a/chardev/char-win.c b/chardev/char-win.c index ec9a731be9..05518e0958 100644 --- a/chardev/char-win.c +++ b/chardev/char-win.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" -#include "char-win.h" +#include "chardev/char-win.h" static void win_chr_read(Chardev *chr, DWORD len) { diff --git a/chardev/char-win.h b/chardev/char-win.h deleted file mode 100644 index 4994425e9e..0000000000 --- a/chardev/char-win.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef CHAR_WIN_H -#define CHAR_WIN_H - -#include "sysemu/char.h" - -typedef struct { - Chardev parent; - - bool keep_open; /* console do not close file */ - HANDLE file, hrecv, hsend; - OVERLAPPED orecv; - BOOL fpipe; - - /* Protected by the Chardev chr_write_lock. */ - OVERLAPPED osend; -} WinChardev; - -#define NSENDBUF 2048 -#define NRECVBUF 2048 - -#define TYPE_CHARDEV_WIN "chardev-win" -#define WIN_CHARDEV(obj) OBJECT_CHECK(WinChardev, (obj), TYPE_CHARDEV_WIN) - -void win_chr_set_file(Chardev *chr, HANDLE file, bool keep_open); -int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp); -int win_chr_pipe_poll(void *opaque); - -#endif /* CHAR_WIN_H */ diff --git a/chardev/char.c b/chardev/char.c index 26607c1c6b..02142b480e 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -28,16 +28,16 @@ #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/error-report.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qmp-commands.h" #include "qapi-visit.h" #include "sysemu/replay.h" #include "qemu/help_option.h" -#include "char-mux.h" -#include "char-io.h" -#include "char-parallel.h" -#include "char-serial.h" +#include "chardev/char-mux.h" +#include "chardev/char-io.h" +#include "chardev/char-parallel.h" +#include "chardev/char-serial.h" /***********************************************************/ /* character device */ diff --git a/gdbstub.c b/gdbstub.c index 86eed4f97c..6515c635dc 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -25,7 +25,7 @@ #include "qemu.h" #else #include "monitor/monitor.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "exec/gdbstub.h" #endif diff --git a/hmp.c b/hmp.c index 20f5daba5e..97d4822e52 100644 --- a/hmp.c +++ b/hmp.c @@ -17,7 +17,7 @@ #include "hmp.h" #include "net/net.h" #include "net/eth.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/block-backend.h" #include "sysemu/sysemu.h" #include "qemu/config-file.h" diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index 9056f27bf8..40666b68a3 100644 --- a/hw/arm/fsl-imx25.c +++ b/hw/arm/fsl-imx25.c @@ -30,7 +30,7 @@ #include "sysemu/sysemu.h" #include "exec/address-spaces.h" #include "hw/boards.h" -#include "sysemu/char.h" +#include "chardev/char.h" static void fsl_imx25_init(Object *obj) { diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c index d7e2d832b2..c30130667e 100644 --- a/hw/arm/fsl-imx31.c +++ b/hw/arm/fsl-imx31.c @@ -27,7 +27,7 @@ #include "sysemu/sysemu.h" #include "exec/address-spaces.h" #include "hw/boards.h" -#include "sysemu/char.h" +#include "chardev/char.h" static void fsl_imx31_init(Object *obj) { diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index 6969e734ad..27773c9c47 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -24,7 +24,7 @@ #include "qemu-common.h" #include "hw/arm/fsl-imx6.h" #include "sysemu/sysemu.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/error-report.h" #define NAME_SIZE 20 diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c index 8afb854c74..9eabbaeea5 100644 --- a/hw/arm/omap2.c +++ b/hw/arm/omap2.c @@ -30,7 +30,7 @@ #include "hw/arm/omap.h" #include "sysemu/sysemu.h" #include "qemu/timer.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/block/flash.h" #include "hw/arm/soc_dma.h" #include "hw/sysbus.h" diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c index eea551dc16..0d43cc707c 100644 --- a/hw/arm/pxa2xx.c +++ b/hw/arm/pxa2xx.c @@ -17,7 +17,7 @@ #include "hw/char/serial.h" #include "hw/i2c/i2c.h" #include "hw/ssi/ssi.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "qemu/cutils.h" diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index 3311cc38a4..66cad198d4 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -34,7 +34,7 @@ #include "strongarm.h" #include "qemu/error-report.h" #include "hw/arm/arm.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "hw/ssi/ssi.h" #include "qemu/cutils.h" diff --git a/hw/bt/hci-csr.c b/hw/bt/hci-csr.c index 3c193848fc..cc2087392e 100644 --- a/hw/bt/hci-csr.c +++ b/hw/bt/hci-csr.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/timer.h" #include "qemu/bswap.h" #include "hw/irq.h" diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 4dcee571c0..cf4c1d56ff 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -23,7 +23,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/timer.h" #include "qemu/log.h" #include "hw/char/cadence_uart.h" diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c index 80dce07e7f..77d91c8558 100644 --- a/hw/char/debugcon.c +++ b/hw/char/debugcon.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hw.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/isa/isa.h" #include "hw/i386/pc.h" diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index 029f5bbf5e..4f1dec7f1d 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -29,7 +29,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/log.h" #include "hw/char/digic-uart.h" diff --git a/hw/char/escc.c b/hw/char/escc.c index 9228091cec..df89d58eed 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -26,7 +26,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "hw/char/escc.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "ui/console.h" #include "ui/input.h" #include "trace.h" diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c index 54383878e0..33e3e16397 100644 --- a/hw/char/etraxfs_ser.c +++ b/hw/char/etraxfs_ser.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/log.h" #define D(x) diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index bff706ab3a..94952fb90f 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -23,7 +23,7 @@ #include "hw/sysbus.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/arm/exynos4210.h" diff --git a/hw/char/grlib_apbuart.c b/hw/char/grlib_apbuart.c index db686e6a6f..39d1133c61 100644 --- a/hw/char/grlib_apbuart.c +++ b/hw/char/grlib_apbuart.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "trace.h" diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c index 93929c2880..b8a3c92c9e 100644 --- a/hw/char/ipoctal232.c +++ b/hw/char/ipoctal232.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" #include "hw/ipack/ipack.h" #include "qemu/bitops.h" -#include "sysemu/char.h" +#include "chardev/char.h" /* #define DEBUG_IPOCTAL */ diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c index f8c1e0d076..6b0633e518 100644 --- a/hw/char/lm32_juart.c +++ b/hw/char/lm32_juart.c @@ -21,7 +21,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "trace.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/char/lm32_juart.h" diff --git a/hw/char/lm32_uart.c b/hw/char/lm32_uart.c index 7f3597c4b0..a7610c28ce 100644 --- a/hw/char/lm32_uart.c +++ b/hw/char/lm32_uart.c @@ -26,7 +26,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "trace.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/error-report.h" enum { diff --git a/hw/char/mcf_uart.c b/hw/char/mcf_uart.c index e69672f4e9..b639b53c83 100644 --- a/hw/char/mcf_uart.c +++ b/hw/char/mcf_uart.c @@ -9,7 +9,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "hw/m68k/mcf.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "exec/address-spaces.h" #include "qapi/error.h" diff --git a/hw/char/milkymist-uart.c b/hw/char/milkymist-uart.c index ae8e2f3554..5ef847c5eb 100644 --- a/hw/char/milkymist-uart.c +++ b/hw/char/milkymist-uart.c @@ -25,7 +25,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "trace.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/error-report.h" enum { diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c index 31ebb1592c..6fd1b9cf6b 100644 --- a/hw/char/omap_uart.c +++ b/hw/char/omap_uart.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/hw.h" #include "hw/arm/omap.h" #include "hw/char/serial.h" diff --git a/hw/char/parallel.c b/hw/char/parallel.c index c71a4a0f4f..c926df0bee 100644 --- a/hw/char/parallel.c +++ b/hw/char/parallel.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hw.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/isa/isa.h" #include "hw/i386/pc.h" #include "sysemu/sysemu.h" diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 24ea9738b6..1757035bb3 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -9,7 +9,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/log.h" #include "trace.h" diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 07d6ebd112..755d514188 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -17,7 +17,7 @@ #include "hw/qdev.h" #include "qemu/thread.h" #include "qemu/error-report.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/s390x/sclp.h" #include "hw/s390x/event-facility.h" diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c index b78f240a73..0fd3cb4887 100644 --- a/hw/char/sclpconsole.c +++ b/hw/char/sclpconsole.c @@ -19,7 +19,7 @@ #include "hw/s390x/sclp.h" #include "hw/s390x/event-facility.h" -#include "sysemu/char.h" +#include "chardev/char.h" typedef struct ASCIIConsoleData { EventBufferHeader ebh; diff --git a/hw/char/serial.c b/hw/char/serial.c index 03d890ca24..aa336333be 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "hw/char/serial.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qapi/error.h" #include "qemu/timer.h" #include "exec/address-spaces.h" diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c index 303eb0a678..80c7696d8d 100644 --- a/hw/char/sh_serial.c +++ b/hw/char/sh_serial.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "hw/hw.h" #include "hw/sh4/sh.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "exec/address-spaces.h" #include "qapi/error.h" diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index e30c8da57c..2317e45404 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -4,7 +4,7 @@ #include "qemu-common.h" #include "cpu.h" #include "hw/qdev.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c index b2dda01baa..c043104185 100644 --- a/hw/char/terminal3270.c +++ b/hw/char/terminal3270.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/s390x/3270-ccw.h" /* Enough spaces for different window sizes. */ diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 798d9b69fd..8418db6a07 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/error-report.h" #include "trace.h" #include "hw/virtio/virtio-serial.h" diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index c01f41090e..1cdbe59f8a 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -25,7 +25,7 @@ #include "qapi/error.h" #include "hw/hw.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/xen/xen_backend.h" #include "qapi/error.h" diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c index 37d313b429..bcebdae3da 100644 --- a/hw/char/xilinx_uartlite.c +++ b/hw/char/xilinx_uartlite.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #define DUART(x) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 79c2014135..4da0c6a24e 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -20,7 +20,7 @@ #include "hw/block/block.h" #include "net/hub.h" #include "qapi/visitor.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/iothread.h" static void get_pointer(Object *obj, Visitor *v, Property *prop, diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index fa3617db2d..9f1a497322 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -9,7 +9,7 @@ #include "hw/block/block.h" #include "net/hub.h" #include "qapi/visitor.h" -#include "sysemu/char.h" +#include "chardev/char.h" void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c index e8e3d250b6..35285383fd 100644 --- a/hw/ipmi/ipmi_bmc_extern.c +++ b/hw/ipmi/ipmi_bmc_extern.c @@ -30,7 +30,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/timer.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "hw/ipmi/ipmi.h" diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c index c707d24db4..5ce9f0a062 100644 --- a/hw/isa/pc87312.c +++ b/hw/isa/pc87312.c @@ -30,7 +30,7 @@ #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "sysemu/sysemu.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "trace.h" diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 53d1e0ce45..a4677f7da4 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -35,7 +35,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/log.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/device_tree.h" #include "sysemu/sysemu.h" #include "sysemu/qtest.h" diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 475e36a4c7..cd064dcf8c 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -29,7 +29,7 @@ #include "qemu/error-report.h" #include "qemu/event_notifier.h" #include "qom/object_interfaces.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/hostmem.h" #include "sysemu/qtest.h" #include "qapi/visitor.h" diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index a41b0d6ec5..c2096b25ab 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -9,7 +9,7 @@ */ #include "qemu/osdep.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/error-report.h" #include "qemu/sockets.h" #include "ccid.h" diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 76ceca1f5c..4df995109b 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -15,7 +15,7 @@ #include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "sysemu/char.h" +#include "chardev/char.h" //#define DEBUG_Serial diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index ad5ef783a6..c862c1adea 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -33,7 +33,7 @@ #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/iov.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include #include diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index dde094abb4..44c9d8c954 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -13,7 +13,7 @@ #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "hw/virtio/virtio-net.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index a9055e9eba..0bed5770c9 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" #include "hw/xen/xen_backend.h" #include "qmp-commands.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/accel.h" #include "migration/migration.h" diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 4636f8e934..d5ac080d4a 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -40,7 +40,7 @@ #include "hw/sysbus.h" #include "hw/block/flash.h" #include "sysemu/block-backend.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/device_tree.h" #include "qemu/error-report.h" #include "bootparam.h" diff --git a/include/chardev/char-fd.h b/include/chardev/char-fd.h new file mode 100644 index 0000000000..55ae5b47b0 --- /dev/null +++ b/include/chardev/char-fd.h @@ -0,0 +1,44 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_FD_H +#define CHAR_FD_H + +#include "io/channel.h" +#include "chardev/char.h" + +typedef struct FDChardev { + Chardev parent; + Chardev *chr; + QIOChannel *ioc_in, *ioc_out; + int max_size; +} FDChardev; + +#define TYPE_CHARDEV_FD "chardev-fd" + +#define FD_CHARDEV(obj) OBJECT_CHECK(FDChardev, (obj), TYPE_CHARDEV_FD) + +void qemu_chr_open_fd(Chardev *chr, int fd_in, int fd_out); +int qmp_chardev_open_file_source(char *src, int flags, Error **errp); + +#endif /* CHAR_FD_H */ diff --git a/include/chardev/char-io.h b/include/chardev/char-io.h new file mode 100644 index 0000000000..9638da5100 --- /dev/null +++ b/include/chardev/char-io.h @@ -0,0 +1,46 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_IO_H +#define CHAR_IO_H + +#include "qemu-common.h" +#include "io/channel.h" +#include "chardev/char.h" + +/* Can only be used for read */ +GSource *io_add_watch_poll(Chardev *chr, + QIOChannel *ioc, + IOCanReadHandler *fd_can_read, + QIOChannelFunc fd_read, + gpointer user_data, + GMainContext *context); + +void remove_fd_in_watch(Chardev *chr); + +int io_channel_send(QIOChannel *ioc, const void *buf, size_t len); + +int io_channel_send_full(QIOChannel *ioc, const void *buf, size_t len, + int *fds, size_t nfds); + +#endif /* CHAR_IO_H */ diff --git a/include/chardev/char-mux.h b/include/chardev/char-mux.h new file mode 100644 index 0000000000..45cdfc7e67 --- /dev/null +++ b/include/chardev/char-mux.h @@ -0,0 +1,63 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_MUX_H +#define CHAR_MUX_H + +#include "chardev/char.h" + +extern bool muxes_realized; + +#define MAX_MUX 4 +#define MUX_BUFFER_SIZE 32 /* Must be a power of 2. */ +#define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1) +typedef struct MuxChardev { + Chardev parent; + CharBackend *backends[MAX_MUX]; + CharBackend chr; + int focus; + int mux_cnt; + int term_got_escape; + int max_size; + /* Intermediate input buffer catches escape sequences even if the + currently active device is not accepting any input - but only until it + is full as well. */ + unsigned char buffer[MAX_MUX][MUX_BUFFER_SIZE]; + int prod[MAX_MUX]; + int cons[MAX_MUX]; + int timestamps; + + /* Protected by the Chardev chr_write_lock. */ + int linestart; + int64_t timestamps_start; +} MuxChardev; + +#define MUX_CHARDEV(obj) OBJECT_CHECK(MuxChardev, (obj), TYPE_CHARDEV_MUX) +#define CHARDEV_IS_MUX(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX) + +void mux_chr_set_handlers(Chardev *chr, GMainContext *context); +void mux_set_focus(Chardev *chr, int focus); +void mux_chr_send_all_event(Chardev *chr, int event); + +#endif /* CHAR_MUX_H */ diff --git a/include/chardev/char-parallel.h b/include/chardev/char-parallel.h new file mode 100644 index 0000000000..26742f9d5c --- /dev/null +++ b/include/chardev/char-parallel.h @@ -0,0 +1,32 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_PARALLEL_H +#define CHAR_PARALLEL_H + +#if defined(__linux__) || defined(__FreeBSD__) || \ + defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#define HAVE_CHARDEV_PARPORT 1 +#endif + +#endif /* CHAR_PARALLEL_H */ diff --git a/include/chardev/char-serial.h b/include/chardev/char-serial.h new file mode 100644 index 0000000000..64a27f63b1 --- /dev/null +++ b/include/chardev/char-serial.h @@ -0,0 +1,35 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_SERIAL_H +#define CHAR_SERIAL_H + +#ifdef _WIN32 +#define HAVE_CHARDEV_SERIAL 1 +#elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ + || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ + || defined(__GLIBC__) +#define HAVE_CHARDEV_SERIAL 1 +#endif + +#endif diff --git a/include/chardev/char-win-stdio.h b/include/chardev/char-win-stdio.h new file mode 100644 index 0000000000..d7314f734d --- /dev/null +++ b/include/chardev/char-win-stdio.h @@ -0,0 +1,29 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_WIN_STDIO_H +#define CHAR_WIN_STDIO_H + +#define TYPE_CHARDEV_WIN_STDIO "chardev-win-stdio" + +#endif /* CHAR_WIN_STDIO_H */ diff --git a/include/chardev/char-win.h b/include/chardev/char-win.h new file mode 100644 index 0000000000..fa59e9e423 --- /dev/null +++ b/include/chardev/char-win.h @@ -0,0 +1,51 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef CHAR_WIN_H +#define CHAR_WIN_H + +#include "chardev/char.h" + +typedef struct { + Chardev parent; + + bool keep_open; /* console do not close file */ + HANDLE file, hrecv, hsend; + OVERLAPPED orecv; + BOOL fpipe; + + /* Protected by the Chardev chr_write_lock. */ + OVERLAPPED osend; +} WinChardev; + +#define NSENDBUF 2048 +#define NRECVBUF 2048 + +#define TYPE_CHARDEV_WIN "chardev-win" +#define WIN_CHARDEV(obj) OBJECT_CHECK(WinChardev, (obj), TYPE_CHARDEV_WIN) + +void win_chr_set_file(Chardev *chr, HANDLE file, bool keep_open); +int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp); +int win_chr_pipe_poll(void *opaque); + +#endif /* CHAR_WIN_H */ diff --git a/include/chardev/char.h b/include/chardev/char.h new file mode 100644 index 0000000000..fffc0f40d4 --- /dev/null +++ b/include/chardev/char.h @@ -0,0 +1,499 @@ +#ifndef QEMU_CHAR_H +#define QEMU_CHAR_H + +#include "qemu-common.h" +#include "qemu/option.h" +#include "qemu/main-loop.h" +#include "qemu/bitmap.h" +#include "qom/object.h" + +#define IAC_EOR 239 +#define IAC_SE 240 +#define IAC_NOP 241 +#define IAC_BREAK 243 +#define IAC_IP 244 +#define IAC_SB 250 +#define IAC 255 + +/* character device */ + +typedef enum { + CHR_EVENT_BREAK, /* serial break char */ + CHR_EVENT_OPENED, /* new connection established */ + CHR_EVENT_MUX_IN, /* mux-focus was set to this terminal */ + CHR_EVENT_MUX_OUT, /* mux-focus will move on */ + CHR_EVENT_CLOSED /* connection closed */ +} QEMUChrEvent; + +#define CHR_READ_BUF_LEN 4096 + +#define CHR_IOCTL_SERIAL_SET_PARAMS 1 +typedef struct { + int speed; + int parity; + int data_bits; + int stop_bits; +} QEMUSerialSetParams; + +#define CHR_IOCTL_SERIAL_SET_BREAK 2 + +#define CHR_IOCTL_PP_READ_DATA 3 +#define CHR_IOCTL_PP_WRITE_DATA 4 +#define CHR_IOCTL_PP_READ_CONTROL 5 +#define CHR_IOCTL_PP_WRITE_CONTROL 6 +#define CHR_IOCTL_PP_READ_STATUS 7 +#define CHR_IOCTL_PP_EPP_READ_ADDR 8 +#define CHR_IOCTL_PP_EPP_READ 9 +#define CHR_IOCTL_PP_EPP_WRITE_ADDR 10 +#define CHR_IOCTL_PP_EPP_WRITE 11 +#define CHR_IOCTL_PP_DATA_DIR 12 + +struct ParallelIOArg { + void *buffer; + int count; +}; + +#define CHR_IOCTL_SERIAL_SET_TIOCM 13 +#define CHR_IOCTL_SERIAL_GET_TIOCM 14 + +#define CHR_TIOCM_CTS 0x020 +#define CHR_TIOCM_CAR 0x040 +#define CHR_TIOCM_DSR 0x100 +#define CHR_TIOCM_RI 0x080 +#define CHR_TIOCM_DTR 0x002 +#define CHR_TIOCM_RTS 0x004 + +typedef void IOEventHandler(void *opaque, int event); + +typedef enum { + /* Whether the chardev peer is able to close and + * reopen the data channel, thus requiring support + * for qemu_chr_wait_connected() to wait for a + * valid connection */ + QEMU_CHAR_FEATURE_RECONNECTABLE, + /* Whether it is possible to send/recv file descriptors + * over the data channel */ + QEMU_CHAR_FEATURE_FD_PASS, + /* Whether replay or record mode is enabled */ + QEMU_CHAR_FEATURE_REPLAY, + + QEMU_CHAR_FEATURE_LAST, +} ChardevFeature; + +/* This is the backend as seen by frontend, the actual backend is + * Chardev */ +typedef struct CharBackend { + Chardev *chr; + IOEventHandler *chr_event; + IOCanReadHandler *chr_can_read; + IOReadHandler *chr_read; + void *opaque; + int tag; + int fe_open; +} CharBackend; + +struct Chardev { + Object parent_obj; + + QemuMutex chr_write_lock; + CharBackend *be; + char *label; + char *filename; + int logfd; + int be_open; + GSource *gsource; + DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); +}; + +/** + * @qemu_chr_new_from_opts: + * + * Create a new character backend from a QemuOpts list. + * + * @opts see qemu-config.c for a list of valid options + * + * Returns: a new character backend + */ +Chardev *qemu_chr_new_from_opts(QemuOpts *opts, + Error **errp); + +/** + * @qemu_chr_parse_common: + * + * Parse the common options available to all character backends. + * + * @opts the options that still need parsing + * @backend a new backend + */ +void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); + +/** + * @qemu_chr_new: + * + * Create a new character backend from a URI. + * + * @label the name of the backend + * @filename the URI + * + * Returns: a new character backend + */ +Chardev *qemu_chr_new(const char *label, const char *filename); + + +/** + * @qemu_chr_fe_disconnect: + * + * Close a fd accpeted by character backend. + * Without associated Chardev, do nothing. + */ +void qemu_chr_fe_disconnect(CharBackend *be); + +/** + * @qemu_chr_cleanup: + * + * Delete all chardevs (when leaving qemu) + */ +void qemu_chr_cleanup(void); + +/** + * @qemu_chr_fe_wait_connected: + * + * Wait for characted backend to be connected, return < 0 on error or + * if no assicated Chardev. + */ +int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp); + +/** + * @qemu_chr_new_noreplay: + * + * Create a new character backend from a URI. + * Character device communications are not written + * into the replay log. + * + * @label the name of the backend + * @filename the URI + * + * Returns: a new character backend + */ +Chardev *qemu_chr_new_noreplay(const char *label, const char *filename); + +/** + * @qemu_chr_fe_set_echo: + * + * Ask the backend to override its normal echo setting. This only really + * applies to the stdio backend and is used by the QMP server such that you + * can see what you type if you try to type QMP commands. + * Without associated Chardev, do nothing. + * + * @echo true to enable echo, false to disable echo + */ +void qemu_chr_fe_set_echo(CharBackend *be, bool echo); + +/** + * @qemu_chr_fe_set_open: + * + * Set character frontend open status. This is an indication that the + * front end is ready (or not) to begin doing I/O. + * Without associated Chardev, do nothing. + */ +void qemu_chr_fe_set_open(CharBackend *be, int fe_open); + +/** + * @qemu_chr_fe_printf: + * + * Write to a character backend using a printf style interface. This + * function is thread-safe. It does nothing without associated + * Chardev. + * + * @fmt see #printf + */ +void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); + +/** + * @qemu_chr_fe_add_watch: + * + * If the backend is connected, create and add a #GSource that fires + * when the given condition (typically G_IO_OUT|G_IO_HUP or G_IO_HUP) + * is active; return the #GSource's tag. If it is disconnected, + * or without associated Chardev, return 0. + * + * @cond the condition to poll for + * @func the function to call when the condition happens + * @user_data the opaque pointer to pass to @func + * + * Returns: the source tag + */ +guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, + GIOFunc func, void *user_data); + +/** + * @qemu_chr_fe_write: + * + * Write data to a character backend from the front end. This function + * will send data from the front end to the back end. This function + * is thread-safe. + * + * @buf the data + * @len the number of bytes to send + * + * Returns: the number of bytes consumed (0 if no assicated Chardev) + */ +int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); + +/** + * @qemu_chr_fe_write_all: + * + * Write data to a character backend from the front end. This function will + * send data from the front end to the back end. Unlike @qemu_chr_fe_write, + * this function will block if the back end cannot consume all of the data + * attempted to be written. This function is thread-safe. + * + * @buf the data + * @len the number of bytes to send + * + * Returns: the number of bytes consumed (0 if no assicated Chardev) + */ +int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); + +/** + * @qemu_chr_fe_read_all: + * + * Read data to a buffer from the back end. + * + * @buf the data buffer + * @len the number of bytes to read + * + * Returns: the number of bytes read (0 if no assicated Chardev) + */ +int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len); + +/** + * @qemu_chr_fe_ioctl: + * + * Issue a device specific ioctl to a backend. This function is thread-safe. + * + * @cmd see CHR_IOCTL_* + * @arg the data associated with @cmd + * + * Returns: if @cmd is not supported by the backend or there is no + * associated Chardev, -ENOTSUP, otherwise the return + * value depends on the semantics of @cmd + */ +int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg); + +/** + * @qemu_chr_fe_get_msgfd: + * + * For backends capable of fd passing, return the latest file descriptor passed + * by a client. + * + * Returns: -1 if fd passing isn't supported or there is no pending file + * descriptor. If a file descriptor is returned, subsequent calls to + * this function will return -1 until a client sends a new file + * descriptor. + */ +int qemu_chr_fe_get_msgfd(CharBackend *be); + +/** + * @qemu_chr_fe_get_msgfds: + * + * For backends capable of fd passing, return the number of file received + * descriptors and fills the fds array up to num elements + * + * Returns: -1 if fd passing isn't supported or there are no pending file + * descriptors. If file descriptors are returned, subsequent calls to + * this function will return -1 until a client sends a new set of file + * descriptors. + */ +int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num); + +/** + * @qemu_chr_fe_set_msgfds: + * + * For backends capable of fd passing, set an array of fds to be passed with + * the next send operation. + * A subsequent call to this function before calling a write function will + * result in overwriting the fd array with the new value without being send. + * Upon writing the message the fd array is freed. + * + * Returns: -1 if fd passing isn't supported or no associated Chardev. + */ +int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num); + +/** + * @qemu_chr_be_can_write: + * + * Determine how much data the front end can currently accept. This function + * returns the number of bytes the front end can accept. If it returns 0, the + * front end cannot receive data at the moment. The function must be polled + * to determine when data can be received. + * + * Returns: the number of bytes the front end can receive via @qemu_chr_be_write + */ +int qemu_chr_be_can_write(Chardev *s); + +/** + * @qemu_chr_be_write: + * + * Write data from the back end to the front end. Before issuing this call, + * the caller should call @qemu_chr_be_can_write to determine how much data + * the front end can currently accept. + * + * @buf a buffer to receive data from the front end + * @len the number of bytes to receive from the front end + */ +void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len); + +/** + * @qemu_chr_be_write_impl: + * + * Implementation of back end writing. Used by replay module. + * + * @buf a buffer to receive data from the front end + * @len the number of bytes to receive from the front end + */ +void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len); + +/** + * @qemu_chr_be_event: + * + * Send an event from the back end to the front end. + * + * @event the event to send + */ +void qemu_chr_be_event(Chardev *s, int event); + +/** + * @qemu_chr_fe_init: + * + * Initializes a front end for the given CharBackend and + * Chardev. Call qemu_chr_fe_deinit() to remove the association and + * release the driver. + * + * Returns: false on error. + */ +bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp); + +/** + * @qemu_chr_fe_get_driver: + * + * Returns the driver associated with a CharBackend or NULL if no + * associated Chardev. + */ +Chardev *qemu_chr_fe_get_driver(CharBackend *be); + +/** + * @qemu_chr_fe_deinit: + * + * Dissociate the CharBackend from the Chardev. + * + * Safe to call without associated Chardev. + */ +void qemu_chr_fe_deinit(CharBackend *b); + +/** + * @qemu_chr_fe_set_handlers: + * @b: a CharBackend + * @fd_can_read: callback to get the amount of data the frontend may + * receive + * @fd_read: callback to receive data from char + * @fd_event: event callback + * @opaque: an opaque pointer for the callbacks + * @context: a main loop context or NULL for the default + * @set_open: whether to call qemu_chr_fe_set_open() implicitely when + * any of the handler is non-NULL + * + * Set the front end char handlers. The front end takes the focus if + * any of the handler is non-NULL. + * + * Without associated Chardev, nothing is changed. + */ +void qemu_chr_fe_set_handlers(CharBackend *b, + IOCanReadHandler *fd_can_read, + IOReadHandler *fd_read, + IOEventHandler *fd_event, + void *opaque, + GMainContext *context, + bool set_open); + +/** + * @qemu_chr_fe_take_focus: + * + * Take the focus (if the front end is muxed). + * + * Without associated Chardev, nothing is changed. + */ +void qemu_chr_fe_take_focus(CharBackend *b); + +void qemu_chr_fe_accept_input(CharBackend *be); +int qemu_chr_add_client(Chardev *s, int fd); +Chardev *qemu_chr_find(const char *name); + +bool qemu_chr_has_feature(Chardev *chr, + ChardevFeature feature); +void qemu_chr_set_feature(Chardev *chr, + ChardevFeature feature); +QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); +int qemu_chr_write_all(Chardev *s, const uint8_t *buf, int len); +int qemu_chr_wait_connected(Chardev *chr, Error **errp); + +#define TYPE_CHARDEV "chardev" +#define CHARDEV(obj) OBJECT_CHECK(Chardev, (obj), TYPE_CHARDEV) +#define CHARDEV_CLASS(klass) \ + OBJECT_CLASS_CHECK(ChardevClass, (klass), TYPE_CHARDEV) +#define CHARDEV_GET_CLASS(obj) \ + OBJECT_GET_CLASS(ChardevClass, (obj), TYPE_CHARDEV) + +#define TYPE_CHARDEV_NULL "chardev-null" +#define TYPE_CHARDEV_MUX "chardev-mux" +#define TYPE_CHARDEV_RINGBUF "chardev-ringbuf" +#define TYPE_CHARDEV_PTY "chardev-pty" +#define TYPE_CHARDEV_CONSOLE "chardev-console" +#define TYPE_CHARDEV_STDIO "chardev-stdio" +#define TYPE_CHARDEV_PIPE "chardev-pipe" +#define TYPE_CHARDEV_MEMORY "chardev-memory" +#define TYPE_CHARDEV_PARALLEL "chardev-parallel" +#define TYPE_CHARDEV_FILE "chardev-file" +#define TYPE_CHARDEV_SERIAL "chardev-serial" +#define TYPE_CHARDEV_SOCKET "chardev-socket" +#define TYPE_CHARDEV_UDP "chardev-udp" + +#define CHARDEV_IS_RINGBUF(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_RINGBUF) +#define CHARDEV_IS_PTY(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_PTY) + +typedef struct ChardevClass { + ObjectClass parent_class; + + bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ + void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); + + void (*open)(Chardev *chr, ChardevBackend *backend, + bool *be_opened, Error **errp); + + int (*chr_write)(Chardev *s, const uint8_t *buf, int len); + int (*chr_sync_read)(Chardev *s, const uint8_t *buf, int len); + GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond); + void (*chr_update_read_handler)(Chardev *s, GMainContext *context); + int (*chr_ioctl)(Chardev *s, int cmd, void *arg); + int (*get_msgfds)(Chardev *s, int* fds, int num); + int (*set_msgfds)(Chardev *s, int *fds, int num); + int (*chr_add_client)(Chardev *chr, int fd); + int (*chr_wait_connected)(Chardev *chr, Error **errp); + void (*chr_disconnect)(Chardev *chr); + void (*chr_accept_input)(Chardev *chr); + void (*chr_set_echo)(Chardev *chr, bool echo); + void (*chr_set_fe_open)(Chardev *chr, int fe_open); +} ChardevClass; + +Chardev *qemu_chardev_new(const char *id, const char *typename, + ChardevBackend *backend, Error **errp); + +extern int term_escape_char; + +/* console.c */ +void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp); + +#endif diff --git a/include/hw/char/bcm2835_aux.h b/include/hw/char/bcm2835_aux.h index 6865f154bc..2a051c5646 100644 --- a/include/hw/char/bcm2835_aux.h +++ b/include/hw/char/bcm2835_aux.h @@ -9,7 +9,7 @@ #define BCM2835_AUX_H #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #define TYPE_BCM2835_AUX "bcm2835-aux" #define BCM2835_AUX(obj) OBJECT_CHECK(BCM2835AuxState, (obj), TYPE_BCM2835_AUX) diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h index c836db4b74..eed7d8d358 100644 --- a/include/hw/char/cadence_uart.h +++ b/include/hw/char/cadence_uart.h @@ -19,7 +19,7 @@ #ifndef CADENCE_UART_H #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/timer.h" #define CADENCE_UART_RX_FIFO_SIZE 16 diff --git a/include/hw/char/digic-uart.h b/include/hw/char/digic-uart.h index 340c8e1111..370b48a6c5 100644 --- a/include/hw/char/digic-uart.h +++ b/include/hw/char/digic-uart.h @@ -19,7 +19,7 @@ #define HW_CHAR_DIGIC_UART_H #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #define TYPE_DIGIC_UART "digic-uart" #define DIGIC_UART(obj) \ diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h index 4cc3fbc395..05500f5346 100644 --- a/include/hw/char/imx_serial.h +++ b/include/hw/char/imx_serial.h @@ -19,7 +19,7 @@ #define IMX_SERIAL_H #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #define TYPE_IMX_SERIAL "imx.serial" #define IMX_SERIAL(obj) OBJECT_CHECK(IMXSerialState, (obj), TYPE_IMX_SERIAL) diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index daebb076c2..01dcd2a8d2 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -28,10 +28,10 @@ #include "hw/hw.h" #include "sysemu/sysemu.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "exec/memory.h" #include "qemu/fifo8.h" -#include "sysemu/char.h" +#include "chardev/char.h" #define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */ diff --git a/include/hw/char/stm32f2xx_usart.h b/include/hw/char/stm32f2xx_usart.h index 3267523270..4259dbeb1e 100644 --- a/include/hw/char/stm32f2xx_usart.h +++ b/include/hw/char/stm32f2xx_usart.h @@ -26,7 +26,7 @@ #define HW_STM32F2XX_USART_H #include "hw/sysbus.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "hw/hw.h" #define USART_SR 0x00 diff --git a/include/sysemu/char.h b/include/sysemu/char.h deleted file mode 100644 index fffc0f40d4..0000000000 --- a/include/sysemu/char.h +++ /dev/null @@ -1,499 +0,0 @@ -#ifndef QEMU_CHAR_H -#define QEMU_CHAR_H - -#include "qemu-common.h" -#include "qemu/option.h" -#include "qemu/main-loop.h" -#include "qemu/bitmap.h" -#include "qom/object.h" - -#define IAC_EOR 239 -#define IAC_SE 240 -#define IAC_NOP 241 -#define IAC_BREAK 243 -#define IAC_IP 244 -#define IAC_SB 250 -#define IAC 255 - -/* character device */ - -typedef enum { - CHR_EVENT_BREAK, /* serial break char */ - CHR_EVENT_OPENED, /* new connection established */ - CHR_EVENT_MUX_IN, /* mux-focus was set to this terminal */ - CHR_EVENT_MUX_OUT, /* mux-focus will move on */ - CHR_EVENT_CLOSED /* connection closed */ -} QEMUChrEvent; - -#define CHR_READ_BUF_LEN 4096 - -#define CHR_IOCTL_SERIAL_SET_PARAMS 1 -typedef struct { - int speed; - int parity; - int data_bits; - int stop_bits; -} QEMUSerialSetParams; - -#define CHR_IOCTL_SERIAL_SET_BREAK 2 - -#define CHR_IOCTL_PP_READ_DATA 3 -#define CHR_IOCTL_PP_WRITE_DATA 4 -#define CHR_IOCTL_PP_READ_CONTROL 5 -#define CHR_IOCTL_PP_WRITE_CONTROL 6 -#define CHR_IOCTL_PP_READ_STATUS 7 -#define CHR_IOCTL_PP_EPP_READ_ADDR 8 -#define CHR_IOCTL_PP_EPP_READ 9 -#define CHR_IOCTL_PP_EPP_WRITE_ADDR 10 -#define CHR_IOCTL_PP_EPP_WRITE 11 -#define CHR_IOCTL_PP_DATA_DIR 12 - -struct ParallelIOArg { - void *buffer; - int count; -}; - -#define CHR_IOCTL_SERIAL_SET_TIOCM 13 -#define CHR_IOCTL_SERIAL_GET_TIOCM 14 - -#define CHR_TIOCM_CTS 0x020 -#define CHR_TIOCM_CAR 0x040 -#define CHR_TIOCM_DSR 0x100 -#define CHR_TIOCM_RI 0x080 -#define CHR_TIOCM_DTR 0x002 -#define CHR_TIOCM_RTS 0x004 - -typedef void IOEventHandler(void *opaque, int event); - -typedef enum { - /* Whether the chardev peer is able to close and - * reopen the data channel, thus requiring support - * for qemu_chr_wait_connected() to wait for a - * valid connection */ - QEMU_CHAR_FEATURE_RECONNECTABLE, - /* Whether it is possible to send/recv file descriptors - * over the data channel */ - QEMU_CHAR_FEATURE_FD_PASS, - /* Whether replay or record mode is enabled */ - QEMU_CHAR_FEATURE_REPLAY, - - QEMU_CHAR_FEATURE_LAST, -} ChardevFeature; - -/* This is the backend as seen by frontend, the actual backend is - * Chardev */ -typedef struct CharBackend { - Chardev *chr; - IOEventHandler *chr_event; - IOCanReadHandler *chr_can_read; - IOReadHandler *chr_read; - void *opaque; - int tag; - int fe_open; -} CharBackend; - -struct Chardev { - Object parent_obj; - - QemuMutex chr_write_lock; - CharBackend *be; - char *label; - char *filename; - int logfd; - int be_open; - GSource *gsource; - DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); -}; - -/** - * @qemu_chr_new_from_opts: - * - * Create a new character backend from a QemuOpts list. - * - * @opts see qemu-config.c for a list of valid options - * - * Returns: a new character backend - */ -Chardev *qemu_chr_new_from_opts(QemuOpts *opts, - Error **errp); - -/** - * @qemu_chr_parse_common: - * - * Parse the common options available to all character backends. - * - * @opts the options that still need parsing - * @backend a new backend - */ -void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); - -/** - * @qemu_chr_new: - * - * Create a new character backend from a URI. - * - * @label the name of the backend - * @filename the URI - * - * Returns: a new character backend - */ -Chardev *qemu_chr_new(const char *label, const char *filename); - - -/** - * @qemu_chr_fe_disconnect: - * - * Close a fd accpeted by character backend. - * Without associated Chardev, do nothing. - */ -void qemu_chr_fe_disconnect(CharBackend *be); - -/** - * @qemu_chr_cleanup: - * - * Delete all chardevs (when leaving qemu) - */ -void qemu_chr_cleanup(void); - -/** - * @qemu_chr_fe_wait_connected: - * - * Wait for characted backend to be connected, return < 0 on error or - * if no assicated Chardev. - */ -int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp); - -/** - * @qemu_chr_new_noreplay: - * - * Create a new character backend from a URI. - * Character device communications are not written - * into the replay log. - * - * @label the name of the backend - * @filename the URI - * - * Returns: a new character backend - */ -Chardev *qemu_chr_new_noreplay(const char *label, const char *filename); - -/** - * @qemu_chr_fe_set_echo: - * - * Ask the backend to override its normal echo setting. This only really - * applies to the stdio backend and is used by the QMP server such that you - * can see what you type if you try to type QMP commands. - * Without associated Chardev, do nothing. - * - * @echo true to enable echo, false to disable echo - */ -void qemu_chr_fe_set_echo(CharBackend *be, bool echo); - -/** - * @qemu_chr_fe_set_open: - * - * Set character frontend open status. This is an indication that the - * front end is ready (or not) to begin doing I/O. - * Without associated Chardev, do nothing. - */ -void qemu_chr_fe_set_open(CharBackend *be, int fe_open); - -/** - * @qemu_chr_fe_printf: - * - * Write to a character backend using a printf style interface. This - * function is thread-safe. It does nothing without associated - * Chardev. - * - * @fmt see #printf - */ -void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...) - GCC_FMT_ATTR(2, 3); - -/** - * @qemu_chr_fe_add_watch: - * - * If the backend is connected, create and add a #GSource that fires - * when the given condition (typically G_IO_OUT|G_IO_HUP or G_IO_HUP) - * is active; return the #GSource's tag. If it is disconnected, - * or without associated Chardev, return 0. - * - * @cond the condition to poll for - * @func the function to call when the condition happens - * @user_data the opaque pointer to pass to @func - * - * Returns: the source tag - */ -guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, - GIOFunc func, void *user_data); - -/** - * @qemu_chr_fe_write: - * - * Write data to a character backend from the front end. This function - * will send data from the front end to the back end. This function - * is thread-safe. - * - * @buf the data - * @len the number of bytes to send - * - * Returns: the number of bytes consumed (0 if no assicated Chardev) - */ -int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); - -/** - * @qemu_chr_fe_write_all: - * - * Write data to a character backend from the front end. This function will - * send data from the front end to the back end. Unlike @qemu_chr_fe_write, - * this function will block if the back end cannot consume all of the data - * attempted to be written. This function is thread-safe. - * - * @buf the data - * @len the number of bytes to send - * - * Returns: the number of bytes consumed (0 if no assicated Chardev) - */ -int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); - -/** - * @qemu_chr_fe_read_all: - * - * Read data to a buffer from the back end. - * - * @buf the data buffer - * @len the number of bytes to read - * - * Returns: the number of bytes read (0 if no assicated Chardev) - */ -int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len); - -/** - * @qemu_chr_fe_ioctl: - * - * Issue a device specific ioctl to a backend. This function is thread-safe. - * - * @cmd see CHR_IOCTL_* - * @arg the data associated with @cmd - * - * Returns: if @cmd is not supported by the backend or there is no - * associated Chardev, -ENOTSUP, otherwise the return - * value depends on the semantics of @cmd - */ -int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg); - -/** - * @qemu_chr_fe_get_msgfd: - * - * For backends capable of fd passing, return the latest file descriptor passed - * by a client. - * - * Returns: -1 if fd passing isn't supported or there is no pending file - * descriptor. If a file descriptor is returned, subsequent calls to - * this function will return -1 until a client sends a new file - * descriptor. - */ -int qemu_chr_fe_get_msgfd(CharBackend *be); - -/** - * @qemu_chr_fe_get_msgfds: - * - * For backends capable of fd passing, return the number of file received - * descriptors and fills the fds array up to num elements - * - * Returns: -1 if fd passing isn't supported or there are no pending file - * descriptors. If file descriptors are returned, subsequent calls to - * this function will return -1 until a client sends a new set of file - * descriptors. - */ -int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num); - -/** - * @qemu_chr_fe_set_msgfds: - * - * For backends capable of fd passing, set an array of fds to be passed with - * the next send operation. - * A subsequent call to this function before calling a write function will - * result in overwriting the fd array with the new value without being send. - * Upon writing the message the fd array is freed. - * - * Returns: -1 if fd passing isn't supported or no associated Chardev. - */ -int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num); - -/** - * @qemu_chr_be_can_write: - * - * Determine how much data the front end can currently accept. This function - * returns the number of bytes the front end can accept. If it returns 0, the - * front end cannot receive data at the moment. The function must be polled - * to determine when data can be received. - * - * Returns: the number of bytes the front end can receive via @qemu_chr_be_write - */ -int qemu_chr_be_can_write(Chardev *s); - -/** - * @qemu_chr_be_write: - * - * Write data from the back end to the front end. Before issuing this call, - * the caller should call @qemu_chr_be_can_write to determine how much data - * the front end can currently accept. - * - * @buf a buffer to receive data from the front end - * @len the number of bytes to receive from the front end - */ -void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len); - -/** - * @qemu_chr_be_write_impl: - * - * Implementation of back end writing. Used by replay module. - * - * @buf a buffer to receive data from the front end - * @len the number of bytes to receive from the front end - */ -void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len); - -/** - * @qemu_chr_be_event: - * - * Send an event from the back end to the front end. - * - * @event the event to send - */ -void qemu_chr_be_event(Chardev *s, int event); - -/** - * @qemu_chr_fe_init: - * - * Initializes a front end for the given CharBackend and - * Chardev. Call qemu_chr_fe_deinit() to remove the association and - * release the driver. - * - * Returns: false on error. - */ -bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp); - -/** - * @qemu_chr_fe_get_driver: - * - * Returns the driver associated with a CharBackend or NULL if no - * associated Chardev. - */ -Chardev *qemu_chr_fe_get_driver(CharBackend *be); - -/** - * @qemu_chr_fe_deinit: - * - * Dissociate the CharBackend from the Chardev. - * - * Safe to call without associated Chardev. - */ -void qemu_chr_fe_deinit(CharBackend *b); - -/** - * @qemu_chr_fe_set_handlers: - * @b: a CharBackend - * @fd_can_read: callback to get the amount of data the frontend may - * receive - * @fd_read: callback to receive data from char - * @fd_event: event callback - * @opaque: an opaque pointer for the callbacks - * @context: a main loop context or NULL for the default - * @set_open: whether to call qemu_chr_fe_set_open() implicitely when - * any of the handler is non-NULL - * - * Set the front end char handlers. The front end takes the focus if - * any of the handler is non-NULL. - * - * Without associated Chardev, nothing is changed. - */ -void qemu_chr_fe_set_handlers(CharBackend *b, - IOCanReadHandler *fd_can_read, - IOReadHandler *fd_read, - IOEventHandler *fd_event, - void *opaque, - GMainContext *context, - bool set_open); - -/** - * @qemu_chr_fe_take_focus: - * - * Take the focus (if the front end is muxed). - * - * Without associated Chardev, nothing is changed. - */ -void qemu_chr_fe_take_focus(CharBackend *b); - -void qemu_chr_fe_accept_input(CharBackend *be); -int qemu_chr_add_client(Chardev *s, int fd); -Chardev *qemu_chr_find(const char *name); - -bool qemu_chr_has_feature(Chardev *chr, - ChardevFeature feature); -void qemu_chr_set_feature(Chardev *chr, - ChardevFeature feature); -QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); -int qemu_chr_write_all(Chardev *s, const uint8_t *buf, int len); -int qemu_chr_wait_connected(Chardev *chr, Error **errp); - -#define TYPE_CHARDEV "chardev" -#define CHARDEV(obj) OBJECT_CHECK(Chardev, (obj), TYPE_CHARDEV) -#define CHARDEV_CLASS(klass) \ - OBJECT_CLASS_CHECK(ChardevClass, (klass), TYPE_CHARDEV) -#define CHARDEV_GET_CLASS(obj) \ - OBJECT_GET_CLASS(ChardevClass, (obj), TYPE_CHARDEV) - -#define TYPE_CHARDEV_NULL "chardev-null" -#define TYPE_CHARDEV_MUX "chardev-mux" -#define TYPE_CHARDEV_RINGBUF "chardev-ringbuf" -#define TYPE_CHARDEV_PTY "chardev-pty" -#define TYPE_CHARDEV_CONSOLE "chardev-console" -#define TYPE_CHARDEV_STDIO "chardev-stdio" -#define TYPE_CHARDEV_PIPE "chardev-pipe" -#define TYPE_CHARDEV_MEMORY "chardev-memory" -#define TYPE_CHARDEV_PARALLEL "chardev-parallel" -#define TYPE_CHARDEV_FILE "chardev-file" -#define TYPE_CHARDEV_SERIAL "chardev-serial" -#define TYPE_CHARDEV_SOCKET "chardev-socket" -#define TYPE_CHARDEV_UDP "chardev-udp" - -#define CHARDEV_IS_RINGBUF(chr) \ - object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_RINGBUF) -#define CHARDEV_IS_PTY(chr) \ - object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_PTY) - -typedef struct ChardevClass { - ObjectClass parent_class; - - bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ - void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); - - void (*open)(Chardev *chr, ChardevBackend *backend, - bool *be_opened, Error **errp); - - int (*chr_write)(Chardev *s, const uint8_t *buf, int len); - int (*chr_sync_read)(Chardev *s, const uint8_t *buf, int len); - GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond); - void (*chr_update_read_handler)(Chardev *s, GMainContext *context); - int (*chr_ioctl)(Chardev *s, int cmd, void *arg); - int (*get_msgfds)(Chardev *s, int* fds, int num); - int (*set_msgfds)(Chardev *s, int *fds, int num); - int (*chr_add_client)(Chardev *chr, int fd); - int (*chr_wait_connected)(Chardev *chr, Error **errp); - void (*chr_disconnect)(Chardev *chr); - void (*chr_accept_input)(Chardev *chr); - void (*chr_set_echo)(Chardev *chr, bool echo); - void (*chr_set_fe_open)(Chardev *chr, int fe_open); -} ChardevClass; - -Chardev *qemu_chardev_new(const char *id, const char *typename, - ChardevBackend *backend, Error **errp); - -extern int term_escape_char; - -/* console.c */ -void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp); - -#endif diff --git a/monitor.c b/monitor.c index baa73c98b7..29b71ff2bc 100644 --- a/monitor.c +++ b/monitor.c @@ -35,7 +35,7 @@ #include "exec/gdbstub.h" #include "net/net.h" #include "net/slirp.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "ui/qemu-spice.h" #include "sysemu/numa.h" #include "monitor/monitor.h" diff --git a/net/colo-compare.c b/net/colo-compare.c index 2639c7f0a2..619335d5e8 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -25,7 +25,7 @@ #include "qom/object.h" #include "qemu/typedefs.h" #include "net/queue.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/sockets.h" #include "qapi-visit.h" #include "net/colo.h" diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 8b1b06977d..7adc2c10d2 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -20,7 +20,7 @@ #include "qemu/main-loop.h" #include "qemu/error-report.h" #include "trace.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/iov.h" #include "qemu/sockets.h" diff --git a/net/slirp.c b/net/slirp.c index c705a60b62..af3e8b22ac 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -37,7 +37,7 @@ #include "qemu/sockets.h" #include "slirp/libslirp.h" #include "slirp/ip6.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "qapi/error.h" diff --git a/net/vhost-user.c b/net/vhost-user.c index 00a0c1cbc5..77d2ce22a6 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -12,7 +12,7 @@ #include "clients.h" #include "net/vhost_net.h" #include "net/vhost-user.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qmp-commands.h" diff --git a/qmp.c b/qmp.c index 84638e2b2b..7ee9bcfdcf 100644 --- a/qmp.c +++ b/qmp.c @@ -21,7 +21,7 @@ #include "qemu/config-file.h" #include "qemu/uuid.h" #include "qmp-commands.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" #include "sysemu/kvm.h" diff --git a/qtest.c b/qtest.c index 5aa6636ca8..dbf70a7018 100644 --- a/qtest.c +++ b/qtest.c @@ -17,7 +17,7 @@ #include "cpu.h" #include "sysemu/qtest.h" #include "hw/qdev.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "exec/ioport.h" #include "exec/memory.h" #include "hw/irq.h" diff --git a/replay/replay-char.c b/replay/replay-char.c index aa65955942..cbf7c04a9f 100755 --- a/replay/replay-char.c +++ b/replay/replay-char.c @@ -14,7 +14,7 @@ #include "sysemu/replay.h" #include "replay-internal.h" #include "sysemu/sysemu.h" -#include "sysemu/char.h" +#include "chardev/char.h" /* Char drivers that generate qemu_chr_be_write events that should be saved into the log. */ diff --git a/slirp/slirp.c b/slirp/slirp.c index 2f2ec2c1b3..3b92cb54ce 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "qemu/error-report.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "slirp.h" #include "hw/hw.h" #include "qemu/cutils.h" diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 4d1c76e8a4..1c6c2e3969 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include "trace-root.h" #include "ui/qemu-spice.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/error-report.h" #include #include diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c index e86f87656a..8142f2ab90 100644 --- a/tests/postcopy-test.c +++ b/tests/postcopy-test.c @@ -16,7 +16,7 @@ #include "qemu/option.h" #include "qemu/range.h" #include "qemu/sockets.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "hw/nvram/chrp_nvram.h" diff --git a/tests/test-char.c b/tests/test-char.c index 124d0c5439..9340c55058 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -4,7 +4,7 @@ #include "qemu-common.h" #include "qemu/config-file.h" #include "qemu/sockets.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qom/qom-qobject.h" diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 9095af267e..acc392d046 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -16,7 +16,7 @@ #include "qemu/option.h" #include "qemu/range.h" #include "qemu/sockets.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "sysemu/sysemu.h" #include "libqos/libqos.h" #include "libqos/pci-pc.h" diff --git a/ui/console.c b/ui/console.c index ac66b3c910..6cf795a23d 100644 --- a/ui/console.c +++ b/ui/console.c @@ -27,7 +27,7 @@ #include "hw/qdev-core.h" #include "qemu/timer.h" #include "qmp-commands.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "trace.h" #include "exec/memory.h" diff --git a/ui/gtk.c b/ui/gtk.c index 0213ad0efc..5bd87c265a 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -54,7 +54,7 @@ #include "qmp-commands.h" #include "x_keymap.h" #include "keymaps.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qom/object.h" #define MAX_VCS 10 diff --git a/vl.c b/vl.c index 993690d450..8456a94438 100644 --- a/vl.c +++ b/vl.c @@ -81,7 +81,7 @@ int main(int argc, char **argv) #include "sysemu/numa.h" #include "exec/gdbstub.h" #include "qemu/timer.h" -#include "sysemu/char.h" +#include "chardev/char.h" #include "qemu/bitmap.h" #include "qemu/log.h" #include "sysemu/blockdev.h" -- cgit v1.2.1