Revision 927d4878

b/backends/rng-egd.c
11 11
 */
12 12

  
13 13
#include "qemu/rng.h"
14
#include "qemu-char.h"
14
#include "char/char.h"
15 15
#include "qapi/qmp/qerror.h"
16 16
#include "hw/qdev.h" /* just for DEFINE_PROP_CHR */
17 17

  
b/bt-host.c
18 18
 */
19 19

  
20 20
#include "qemu-common.h"
21
#include "bt-host.h"
21
#include "bt/bt.h"
22 22
#include "qemu/main-loop.h"
23 23

  
24 24
#ifndef _WIN32
/dev/null
1
#ifndef BT_HOST_H
2
#define BT_HOST_H
3

  
4
/* BT HCI info */
5

  
6
struct HCIInfo {
7
    int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
8
    void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
9
    void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
10
    void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
11
    void *opaque;
12
    void (*evt_recv)(void *opaque, const uint8_t *data, int len);
13
    void (*acl_recv)(void *opaque, const uint8_t *data, int len);
14
};
15

  
16
/* bt-host.c */
17
struct HCIInfo *bt_host_hci(const char *id);
18
struct HCIInfo *qemu_next_hci(void);
19

  
20
#endif
b/bt-vhci.c
18 18
 */
19 19

  
20 20
#include "qemu-common.h"
21
#include "bt-host.h"
21
#include "bt/bt.h"
22 22
#include "hw/bt.h"
23 23
#include "qemu/main-loop.h"
24 24

  
b/event_notifier-posix.c
12 12

  
13 13
#include "qemu-common.h"
14 14
#include "qemu/event_notifier.h"
15
#include "qemu-char.h"
15
#include "char/char.h"
16 16
#include "qemu/main-loop.h"
17 17

  
18 18
#ifdef CONFIG_EVENTFD
b/gdbstub.c
30 30
#include "qemu.h"
31 31
#else
32 32
#include "monitor/monitor.h"
33
#include "qemu-char.h"
33
#include "char/char.h"
34 34
#include "sysemu/sysemu.h"
35 35
#include "exec/gdbstub.h"
36 36
#endif
b/hmp.c
15 15

  
16 16
#include "hmp.h"
17 17
#include "net/net.h"
18
#include "qemu-char.h"
18
#include "char/char.h"
19 19
#include "qemu/option.h"
20 20
#include "qemu/timer.h"
21 21
#include "qmp-commands.h"
b/hw/baum.c
22 22
 * THE SOFTWARE.
23 23
 */
24 24
#include "qemu-common.h"
25
#include "qemu-char.h"
25
#include "char/char.h"
26 26
#include "qemu/timer.h"
27 27
#include "usb.h"
28 28
#include "baum.h"
b/hw/bt-hci-csr.c
19 19
 */
20 20

  
21 21
#include "qemu-common.h"
22
#include "qemu-char.h"
22
#include "char/char.h"
23 23
#include "qemu/timer.h"
24 24
#include "irq.h"
25
#include "bt-host.h"
25
#include "bt/bt.h"
26 26
#include "bt.h"
27 27

  
28 28
struct csrhci_s {
b/hw/bt-hci.c
21 21
#include "qemu-common.h"
22 22
#include "qemu/timer.h"
23 23
#include "usb.h"
24
#include "bt-host.h"
24
#include "bt/bt.h"
25 25
#include "bt.h"
26 26

  
27 27
struct bt_hci_s {
b/hw/bt.c
18 18
 */
19 19

  
20 20
#include "qemu-common.h"
21
#include "bt-host.h"
21
#include "bt/bt.h"
22 22
#include "bt.h"
23 23

  
24 24
/* Slave implementations can ignore this */
b/hw/cadence_uart.c
17 17
 */
18 18

  
19 19
#include "sysbus.h"
20
#include "qemu-char.h"
20
#include "char/char.h"
21 21
#include "qemu/timer.h"
22 22

  
23 23
#ifdef CADENCE_UART_ERR_DEBUG
b/hw/ccid-card-emulated.c
32 32
#include <vcard_emul.h>
33 33

  
34 34
#include "qemu/thread.h"
35
#include "qemu-char.h"
35
#include "char/char.h"
36 36
#include "monitor/monitor.h"
37 37
#include "hw/ccid.h"
38 38

  
b/hw/ccid-card-passthru.c
8 8
 * See the COPYING file in the top-level directory.
9 9
 */
10 10

  
11
#include "qemu-char.h"
11
#include "char/char.h"
12 12
#include "qemu/sockets.h"
13 13
#include "monitor/monitor.h"
14 14
#include "hw/ccid.h"
b/hw/debugcon.c
25 25
 */
26 26

  
27 27
#include "hw.h"
28
#include "qemu-char.h"
28
#include "char/char.h"
29 29
#include "isa.h"
30 30
#include "pc.h"
31 31

  
b/hw/escc.c
25 25
#include "hw.h"
26 26
#include "sysbus.h"
27 27
#include "escc.h"
28
#include "qemu-char.h"
28
#include "char/char.h"
29 29
#include "ui/console.h"
30 30
#include "trace.h"
31 31

  
b/hw/etraxfs_ser.c
23 23
 */
24 24

  
25 25
#include "sysbus.h"
26
#include "qemu-char.h"
26
#include "char/char.h"
27 27
#include "qemu/log.h"
28 28

  
29 29
#define D(x)
b/hw/exynos4210_uart.c
21 21

  
22 22
#include "sysbus.h"
23 23
#include "sysemu/sysemu.h"
24
#include "qemu-char.h"
24
#include "char/char.h"
25 25

  
26 26
#include "exynos4210.h"
27 27

  
b/hw/grlib_apbuart.c
23 23
 */
24 24

  
25 25
#include "sysbus.h"
26
#include "qemu-char.h"
26
#include "char/char.h"
27 27

  
28 28
#include "trace.h"
29 29

  
b/hw/imx_serial.c
20 20
#include "hw.h"
21 21
#include "sysbus.h"
22 22
#include "sysemu/sysemu.h"
23
#include "qemu-char.h"
23
#include "char/char.h"
24 24
#include "imx.h"
25 25

  
26 26
//#define DEBUG_SERIAL 1
b/hw/ivshmem.c
24 24
#include "migration/migration.h"
25 25
#include "qapi/qmp/qerror.h"
26 26
#include "qemu/event_notifier.h"
27
#include "qemu-char.h"
27
#include "char/char.h"
28 28

  
29 29
#include <sys/mman.h>
30 30
#include <sys/types.h>
b/hw/leon3.c
24 24
#include "hw.h"
25 25
#include "qemu/timer.h"
26 26
#include "ptimer.h"
27
#include "qemu-char.h"
27
#include "char/char.h"
28 28
#include "sysemu/sysemu.h"
29 29
#include "boards.h"
30 30
#include "loader.h"
b/hw/lm32_juart.c
20 20
#include "hw.h"
21 21
#include "sysbus.h"
22 22
#include "trace.h"
23
#include "qemu-char.h"
23
#include "char/char.h"
24 24

  
25 25
#include "lm32_juart.h"
26 26

  
b/hw/lm32_uart.c
25 25
#include "hw.h"
26 26
#include "sysbus.h"
27 27
#include "trace.h"
28
#include "qemu-char.h"
28
#include "char/char.h"
29 29
#include "qemu/error-report.h"
30 30

  
31 31
enum {
b/hw/mcf_uart.c
7 7
 */
8 8
#include "hw.h"
9 9
#include "mcf.h"
10
#include "qemu-char.h"
10
#include "char/char.h"
11 11
#include "exec/address-spaces.h"
12 12

  
13 13
typedef struct {
b/hw/milkymist-uart.c
24 24
#include "hw.h"
25 25
#include "sysbus.h"
26 26
#include "trace.h"
27
#include "qemu-char.h"
27
#include "char/char.h"
28 28
#include "qemu/error-report.h"
29 29

  
30 30
enum {
b/hw/mips_fulong2e.c
30 30
#include "mips.h"
31 31
#include "mips_cpudevs.h"
32 32
#include "pci/pci.h"
33
#include "qemu-char.h"
33
#include "char/char.h"
34 34
#include "sysemu/sysemu.h"
35 35
#include "audio/audio.h"
36 36
#include "qemu/log.h"
b/hw/mips_malta.c
34 34
#include "mips.h"
35 35
#include "mips_cpudevs.h"
36 36
#include "pci/pci.h"
37
#include "qemu-char.h"
37
#include "char/char.h"
38 38
#include "sysemu/sysemu.h"
39 39
#include "sysemu/arch_init.h"
40 40
#include "boards.h"
b/hw/msmouse.c
23 23
 */
24 24
#include <stdlib.h>
25 25
#include "qemu-common.h"
26
#include "qemu-char.h"
26
#include "char/char.h"
27 27
#include "ui/console.h"
28 28
#include "msmouse.h"
29 29

  
b/hw/omap2.c
24 24
#include "omap.h"
25 25
#include "sysemu/sysemu.h"
26 26
#include "qemu/timer.h"
27
#include "qemu-char.h"
27
#include "char/char.h"
28 28
#include "flash.h"
29 29
#include "soc_dma.h"
30 30
#include "sysbus.h"
b/hw/omap_uart.c
17 17
 * You should have received a copy of the GNU General Public License along
18 18
 * with this program; if not, see <http://www.gnu.org/licenses/>.
19 19
 */
20
#include "qemu-char.h"
20
#include "char/char.h"
21 21
#include "hw.h"
22 22
#include "omap.h"
23 23
#include "serial.h"
b/hw/parallel.c
23 23
 * THE SOFTWARE.
24 24
 */
25 25
#include "hw.h"
26
#include "qemu-char.h"
26
#include "char/char.h"
27 27
#include "isa.h"
28 28
#include "pc.h"
29 29
#include "sysemu/sysemu.h"
b/hw/pl011.c
8 8
 */
9 9

  
10 10
#include "sysbus.h"
11
#include "qemu-char.h"
11
#include "char/char.h"
12 12

  
13 13
typedef struct {
14 14
    SysBusDevice busdev;
b/hw/pxa2xx.c
13 13
#include "serial.h"
14 14
#include "i2c.h"
15 15
#include "ssi.h"
16
#include "qemu-char.h"
16
#include "char/char.h"
17 17
#include "sysemu/blockdev.h"
18 18

  
19 19
static struct {
b/hw/qdev-properties.c
5 5
#include "hw/block-common.h"
6 6
#include "net/hub.h"
7 7
#include "qapi/visitor.h"
8
#include "qemu-char.h"
8
#include "char/char.h"
9 9

  
10 10
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
11 11
{
b/hw/s390x/sclpconsole.c
17 17

  
18 18
#include "sclp.h"
19 19
#include "event-facility.h"
20
#include "qemu-char.h"
20
#include "char/char.h"
21 21

  
22 22
typedef struct ASCIIConsoleData {
23 23
    EventBufferHeader ebh;
b/hw/serial.c
24 24
 */
25 25

  
26 26
#include "serial.h"
27
#include "qemu-char.h"
27
#include "char/char.h"
28 28
#include "qemu/timer.h"
29 29
#include "exec/address-spaces.h"
30 30

  
b/hw/sh_serial.c
26 26
 */
27 27
#include "hw.h"
28 28
#include "sh.h"
29
#include "qemu-char.h"
29
#include "char/char.h"
30 30
#include "exec/address-spaces.h"
31 31

  
32 32
//#define DEBUG_SERIAL
b/hw/spapr_events.c
26 26
 */
27 27
#include "cpu.h"
28 28
#include "sysemu/sysemu.h"
29
#include "qemu-char.h"
29
#include "char/char.h"
30 30
#include "hw/qdev.h"
31 31
#include "sysemu/device_tree.h"
32 32

  
b/hw/spapr_rtas.c
26 26
 */
27 27
#include "cpu.h"
28 28
#include "sysemu/sysemu.h"
29
#include "qemu-char.h"
29
#include "char/char.h"
30 30
#include "hw/qdev.h"
31 31
#include "sysemu/device_tree.h"
32 32

  
b/hw/spapr_vty.c
1 1
#include "qdev.h"
2
#include "qemu-char.h"
2
#include "char/char.h"
3 3
#include "hw/spapr.h"
4 4
#include "hw/spapr_vio.h"
5 5

  
b/hw/strongarm.c
30 30
#include "strongarm.h"
31 31
#include "qemu/error-report.h"
32 32
#include "arm-misc.h"
33
#include "qemu-char.h"
33
#include "char/char.h"
34 34
#include "sysemu/sysemu.h"
35 35
#include "ssi.h"
36 36

  
b/hw/usb/dev-bluetooth.c
21 21
#include "qemu-common.h"
22 22
#include "hw/usb.h"
23 23
#include "hw/usb/desc.h"
24
#include "bt-host.h"
24
#include "bt/bt.h"
25 25
#include "hw/bt.h"
26 26

  
27 27
struct USBBtState {
b/hw/usb/dev-serial.c
12 12
#include "qemu/error-report.h"
13 13
#include "hw/usb.h"
14 14
#include "hw/usb/desc.h"
15
#include "qemu-char.h"
15
#include "char/char.h"
16 16

  
17 17
//#define DEBUG_Serial
18 18

  
b/hw/virtio-console.c
10 10
 * the COPYING file in the top-level directory.
11 11
 */
12 12

  
13
#include "qemu-char.h"
13
#include "char/char.h"
14 14
#include "qemu/error-report.h"
15 15
#include "trace.h"
16 16
#include "virtio-serial.h"
b/hw/xen_backend.c
35 35
#include <sys/signal.h>
36 36

  
37 37
#include "hw.h"
38
#include "qemu-char.h"
38
#include "char/char.h"
39 39
#include "qemu/log.h"
40 40
#include "xen_backend.h"
41 41

  
b/hw/xen_console.c
30 30
#include <sys/mman.h>
31 31

  
32 32
#include "hw.h"
33
#include "qemu-char.h"
33
#include "char/char.h"
34 34
#include "xen_backend.h"
35 35

  
36 36
#include <xen/io/console.h>
b/hw/xenfb.c
37 37

  
38 38
#include "hw.h"
39 39
#include "ui/console.h"
40
#include "qemu-char.h"
40
#include "char/char.h"
41 41
#include "xen_backend.h"
42 42

  
43 43
#include <xen/event_channel.h>
b/hw/xgmac.c
25 25
 */
26 26

  
27 27
#include "sysbus.h"
28
#include "qemu-char.h"
28
#include "char/char.h"
29 29
#include "qemu/log.h"
30 30
#include "net/net.h"
31 31
#include "net/checksum.h"
b/hw/xilinx_uartlite.c
23 23
 */
24 24

  
25 25
#include "sysbus.h"
26
#include "qemu-char.h"
26
#include "char/char.h"
27 27

  
28 28
#define DUART(x)
29 29

  
b/hw/xtensa_lx60.c
36 36
#include "sysbus.h"
37 37
#include "flash.h"
38 38
#include "sysemu/blockdev.h"
39
#include "qemu-char.h"
39
#include "char/char.h"
40 40
#include "xtensa_bootparam.h"
41 41

  
42 42
typedef struct LxBoardDesc {
b/include/bt/bt.h
1
#ifndef BT_HOST_H
2
#define BT_HOST_H
3

  
4
/* BT HCI info */
5

  
6
struct HCIInfo {
7
    int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
8
    void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
9
    void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
10
    void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
11
    void *opaque;
12
    void (*evt_recv)(void *opaque, const uint8_t *data, int len);
13
    void (*acl_recv)(void *opaque, const uint8_t *data, int len);
14
};
15

  
16
/* bt-host.c */
17
struct HCIInfo *bt_host_hci(const char *id);
18
struct HCIInfo *qemu_next_hci(void);
19

  
20
#endif
b/include/char/char.h
1
#ifndef QEMU_CHAR_H
2
#define QEMU_CHAR_H
3

  
4
#include "qemu-common.h"
5
#include "qemu/queue.h"
6
#include "qemu/option.h"
7
#include "qemu/config-file.h"
8
#include "block/aio.h"
9
#include "qapi/qmp/qobject.h"
10
#include "qapi/qmp/qstring.h"
11
#include "qemu/main-loop.h"
12

  
13
/* character device */
14

  
15
#define CHR_EVENT_BREAK   0 /* serial break char */
16
#define CHR_EVENT_FOCUS   1 /* focus to this terminal (modal input needed) */
17
#define CHR_EVENT_OPENED  2 /* new connection established */
18
#define CHR_EVENT_MUX_IN  3 /* mux-focus was set to this terminal */
19
#define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
20
#define CHR_EVENT_CLOSED  5 /* connection closed */
21

  
22

  
23
#define CHR_IOCTL_SERIAL_SET_PARAMS   1
24
typedef struct {
25
    int speed;
26
    int parity;
27
    int data_bits;
28
    int stop_bits;
29
} QEMUSerialSetParams;
30

  
31
#define CHR_IOCTL_SERIAL_SET_BREAK    2
32

  
33
#define CHR_IOCTL_PP_READ_DATA        3
34
#define CHR_IOCTL_PP_WRITE_DATA       4
35
#define CHR_IOCTL_PP_READ_CONTROL     5
36
#define CHR_IOCTL_PP_WRITE_CONTROL    6
37
#define CHR_IOCTL_PP_READ_STATUS      7
38
#define CHR_IOCTL_PP_EPP_READ_ADDR    8
39
#define CHR_IOCTL_PP_EPP_READ         9
40
#define CHR_IOCTL_PP_EPP_WRITE_ADDR  10
41
#define CHR_IOCTL_PP_EPP_WRITE       11
42
#define CHR_IOCTL_PP_DATA_DIR        12
43

  
44
#define CHR_IOCTL_SERIAL_SET_TIOCM   13
45
#define CHR_IOCTL_SERIAL_GET_TIOCM   14
46

  
47
#define CHR_TIOCM_CTS	0x020
48
#define CHR_TIOCM_CAR	0x040
49
#define CHR_TIOCM_DSR	0x100
50
#define CHR_TIOCM_RI	0x080
51
#define CHR_TIOCM_DTR	0x002
52
#define CHR_TIOCM_RTS	0x004
53

  
54
typedef void IOEventHandler(void *opaque, int event);
55

  
56
struct CharDriverState {
57
    void (*init)(struct CharDriverState *s);
58
    int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
59
    void (*chr_update_read_handler)(struct CharDriverState *s);
60
    int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
61
    int (*get_msgfd)(struct CharDriverState *s);
62
    int (*chr_add_client)(struct CharDriverState *chr, int fd);
63
    IOEventHandler *chr_event;
64
    IOCanReadHandler *chr_can_read;
65
    IOReadHandler *chr_read;
66
    void *handler_opaque;
67
    void (*chr_close)(struct CharDriverState *chr);
68
    void (*chr_accept_input)(struct CharDriverState *chr);
69
    void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
70
    void (*chr_guest_open)(struct CharDriverState *chr);
71
    void (*chr_guest_close)(struct CharDriverState *chr);
72
    void *opaque;
73
    QEMUTimer *open_timer;
74
    char *label;
75
    char *filename;
76
    int opened;
77
    int avail_connections;
78
    QTAILQ_ENTRY(CharDriverState) next;
79
};
80

  
81
/**
82
 * @qemu_chr_new_from_opts:
83
 *
84
 * Create a new character backend from a QemuOpts list.
85
 *
86
 * @opts see qemu-config.c for a list of valid options
87
 * @init not sure..
88
 *
89
 * Returns: a new character backend
90
 */
91
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
92
                                    void (*init)(struct CharDriverState *s));
93

  
94
/**
95
 * @qemu_chr_new:
96
 *
97
 * Create a new character backend from a URI.
98
 *
99
 * @label the name of the backend
100
 * @filename the URI
101
 * @init not sure..
102
 *
103
 * Returns: a new character backend
104
 */
105
CharDriverState *qemu_chr_new(const char *label, const char *filename,
106
                              void (*init)(struct CharDriverState *s));
107

  
108
/**
109
 * @qemu_chr_delete:
110
 *
111
 * Destroy a character backend.
112
 */
113
void qemu_chr_delete(CharDriverState *chr);
114

  
115
/**
116
 * @qemu_chr_fe_set_echo:
117
 *
118
 * Ask the backend to override its normal echo setting.  This only really
119
 * applies to the stdio backend and is used by the QMP server such that you
120
 * can see what you type if you try to type QMP commands.
121
 *
122
 * @echo true to enable echo, false to disable echo
123
 */
124
void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo);
125

  
126
/**
127
 * @qemu_chr_fe_open:
128
 *
129
 * Open a character backend.  This function call is an indication that the
130
 * front end is ready to begin doing I/O.
131
 */
132
void qemu_chr_fe_open(struct CharDriverState *chr);
133

  
134
/**
135
 * @qemu_chr_fe_close:
136
 *
137
 * Close a character backend.  This function call indicates that the front end
138
 * no longer is able to process I/O.  To process I/O again, the front end will
139
 * call @qemu_chr_fe_open.
140
 */
141
void qemu_chr_fe_close(struct CharDriverState *chr);
142

  
143
/**
144
 * @qemu_chr_fe_printf:
145
 *
146
 * Write to a character backend using a printf style interface.
147
 *
148
 * @fmt see #printf
149
 */
150
void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...)
151
    GCC_FMT_ATTR(2, 3);
152

  
153
/**
154
 * @qemu_chr_fe_write:
155
 *
156
 * Write data to a character backend from the front end.  This function will
157
 * send data from the front end to the back end.
158
 *
159
 * @buf the data
160
 * @len the number of bytes to send
161
 *
162
 * Returns: the number of bytes consumed
163
 */
164
int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len);
165

  
166
/**
167
 * @qemu_chr_fe_ioctl:
168
 *
169
 * Issue a device specific ioctl to a backend.
170
 *
171
 * @cmd see CHR_IOCTL_*
172
 * @arg the data associated with @cmd
173
 *
174
 * Returns: if @cmd is not supported by the backend, -ENOTSUP, otherwise the
175
 *          return value depends on the semantics of @cmd
176
 */
177
int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg);
178

  
179
/**
180
 * @qemu_chr_fe_get_msgfd:
181
 *
182
 * For backends capable of fd passing, return the latest file descriptor passed
183
 * by a client.
184
 *
185
 * Returns: -1 if fd passing isn't supported or there is no pending file
186
 *          descriptor.  If a file descriptor is returned, subsequent calls to
187
 *          this function will return -1 until a client sends a new file
188
 *          descriptor.
189
 */
190
int qemu_chr_fe_get_msgfd(CharDriverState *s);
191

  
192
/**
193
 * @qemu_chr_be_can_write:
194
 *
195
 * Determine how much data the front end can currently accept.  This function
196
 * returns the number of bytes the front end can accept.  If it returns 0, the
197
 * front end cannot receive data at the moment.  The function must be polled
198
 * to determine when data can be received.
199
 *
200
 * Returns: the number of bytes the front end can receive via @qemu_chr_be_write
201
 */
202
int qemu_chr_be_can_write(CharDriverState *s);
203

  
204
/**
205
 * @qemu_chr_be_write:
206
 *
207
 * Write data from the back end to the front end.  Before issuing this call,
208
 * the caller should call @qemu_chr_be_can_write to determine how much data
209
 * the front end can currently accept.
210
 *
211
 * @buf a buffer to receive data from the front end
212
 * @len the number of bytes to receive from the front end
213
 */
214
void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len);
215

  
216

  
217
/**
218
 * @qemu_chr_be_event:
219
 *
220
 * Send an event from the back end to the front end.
221
 *
222
 * @event the event to send
223
 */
224
void qemu_chr_be_event(CharDriverState *s, int event);
225

  
226
void qemu_chr_add_handlers(CharDriverState *s,
227
                           IOCanReadHandler *fd_can_read,
228
                           IOReadHandler *fd_read,
229
                           IOEventHandler *fd_event,
230
                           void *opaque);
231

  
232
void qemu_chr_generic_open(CharDriverState *s);
233
void qemu_chr_accept_input(CharDriverState *s);
234
int qemu_chr_add_client(CharDriverState *s, int fd);
235
void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
236
void qemu_chr_info(Monitor *mon, QObject **ret_data);
237
CharDriverState *qemu_chr_find(const char *name);
238

  
239
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
240

  
241
/* add an eventfd to the qemu devices that are polled */
242
CharDriverState *qemu_chr_open_eventfd(int eventfd);
243

  
244
extern int term_escape_char;
245

  
246
/* memory chardev */
247
void qemu_chr_init_mem(CharDriverState *chr);
248
void qemu_chr_close_mem(CharDriverState *chr);
249
QString *qemu_chr_mem_to_qs(CharDriverState *chr);
250
size_t qemu_chr_mem_osize(const CharDriverState *chr);
251

  
252
CharDriverState *qemu_char_get_next_serial(void);
253

  
254
#endif
b/monitor.c
33 33
#include "exec/gdbstub.h"
34 34
#include "net/net.h"
35 35
#include "net/slirp.h"
36
#include "qemu-char.h"
36
#include "char/char.h"
37 37
#include "ui/qemu-spice.h"
38 38
#include "sysemu/sysemu.h"
39 39
#include "monitor/monitor.h"
b/net/slirp.c
35 35
#include "monitor/monitor.h"
36 36
#include "qemu/sockets.h"
37 37
#include "slirp/libslirp.h"
38
#include "qemu-char.h"
38
#include "char/char.h"
39 39

  
40 40
static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
41 41
{
b/qemu-char.c
26 26
#include "ui/console.h"
27 27
#include "sysemu/sysemu.h"
28 28
#include "qemu/timer.h"
29
#include "qemu-char.h"
29
#include "char/char.h"
30 30
#include "hw/usb.h"
31 31
#include "hw/baum.h"
32 32
#include "hw/msmouse.h"
/dev/null
1
#ifndef QEMU_CHAR_H
2
#define QEMU_CHAR_H
3

  
4
#include "qemu-common.h"
5
#include "qemu/queue.h"
6
#include "qemu/option.h"
7
#include "qemu/config-file.h"
8
#include "block/aio.h"
9
#include "qapi/qmp/qobject.h"
10
#include "qapi/qmp/qstring.h"
11
#include "qemu/main-loop.h"
12

  
13
/* character device */
14

  
15
#define CHR_EVENT_BREAK   0 /* serial break char */
16
#define CHR_EVENT_FOCUS   1 /* focus to this terminal (modal input needed) */
17
#define CHR_EVENT_OPENED  2 /* new connection established */
18
#define CHR_EVENT_MUX_IN  3 /* mux-focus was set to this terminal */
19
#define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
20
#define CHR_EVENT_CLOSED  5 /* connection closed */
21

  
22

  
23
#define CHR_IOCTL_SERIAL_SET_PARAMS   1
24
typedef struct {
25
    int speed;
26
    int parity;
27
    int data_bits;
28
    int stop_bits;
29
} QEMUSerialSetParams;
30

  
31
#define CHR_IOCTL_SERIAL_SET_BREAK    2
32

  
33
#define CHR_IOCTL_PP_READ_DATA        3
34
#define CHR_IOCTL_PP_WRITE_DATA       4
35
#define CHR_IOCTL_PP_READ_CONTROL     5
36
#define CHR_IOCTL_PP_WRITE_CONTROL    6
37
#define CHR_IOCTL_PP_READ_STATUS      7
38
#define CHR_IOCTL_PP_EPP_READ_ADDR    8
39
#define CHR_IOCTL_PP_EPP_READ         9
40
#define CHR_IOCTL_PP_EPP_WRITE_ADDR  10
41
#define CHR_IOCTL_PP_EPP_WRITE       11
42
#define CHR_IOCTL_PP_DATA_DIR        12
43

  
44
#define CHR_IOCTL_SERIAL_SET_TIOCM   13
45
#define CHR_IOCTL_SERIAL_GET_TIOCM   14
46

  
47
#define CHR_TIOCM_CTS	0x020
48
#define CHR_TIOCM_CAR	0x040
49
#define CHR_TIOCM_DSR	0x100
50
#define CHR_TIOCM_RI	0x080
51
#define CHR_TIOCM_DTR	0x002
52
#define CHR_TIOCM_RTS	0x004
53

  
54
typedef void IOEventHandler(void *opaque, int event);
55

  
56
struct CharDriverState {
57
    void (*init)(struct CharDriverState *s);
58
    int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
59
    void (*chr_update_read_handler)(struct CharDriverState *s);
60
    int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
61
    int (*get_msgfd)(struct CharDriverState *s);
62
    int (*chr_add_client)(struct CharDriverState *chr, int fd);
63
    IOEventHandler *chr_event;
64
    IOCanReadHandler *chr_can_read;
65
    IOReadHandler *chr_read;
66
    void *handler_opaque;
67
    void (*chr_close)(struct CharDriverState *chr);
68
    void (*chr_accept_input)(struct CharDriverState *chr);
69
    void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
70
    void (*chr_guest_open)(struct CharDriverState *chr);
71
    void (*chr_guest_close)(struct CharDriverState *chr);
72
    void *opaque;
73
    QEMUTimer *open_timer;
74
    char *label;
75
    char *filename;
76
    int opened;
77
    int avail_connections;
78
    QTAILQ_ENTRY(CharDriverState) next;
79
};
80

  
81
/**
82
 * @qemu_chr_new_from_opts:
83
 *
84
 * Create a new character backend from a QemuOpts list.
85
 *
86
 * @opts see qemu-config.c for a list of valid options
87
 * @init not sure..
88
 *
89
 * Returns: a new character backend
90
 */
91
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
92
                                    void (*init)(struct CharDriverState *s));
93

  
94
/**
95
 * @qemu_chr_new:
96
 *
97
 * Create a new character backend from a URI.
98
 *
99
 * @label the name of the backend
100
 * @filename the URI
101
 * @init not sure..
102
 *
103
 * Returns: a new character backend
104
 */
105
CharDriverState *qemu_chr_new(const char *label, const char *filename,
106
                              void (*init)(struct CharDriverState *s));
107

  
108
/**
109
 * @qemu_chr_delete:
110
 *
111
 * Destroy a character backend.
112
 */
113
void qemu_chr_delete(CharDriverState *chr);
114

  
115
/**
116
 * @qemu_chr_fe_set_echo:
117
 *
118
 * Ask the backend to override its normal echo setting.  This only really
119
 * applies to the stdio backend and is used by the QMP server such that you
120
 * can see what you type if you try to type QMP commands.
121
 *
122
 * @echo true to enable echo, false to disable echo
123
 */
124
void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo);
125

  
126
/**
127
 * @qemu_chr_fe_open:
128
 *
129
 * Open a character backend.  This function call is an indication that the
130
 * front end is ready to begin doing I/O.
131
 */
132
void qemu_chr_fe_open(struct CharDriverState *chr);
133

  
134
/**
135
 * @qemu_chr_fe_close:
136
 *
137
 * Close a character backend.  This function call indicates that the front end
138
 * no longer is able to process I/O.  To process I/O again, the front end will
139
 * call @qemu_chr_fe_open.
140
 */
141
void qemu_chr_fe_close(struct CharDriverState *chr);
142

  
143
/**
144
 * @qemu_chr_fe_printf:
145
 *
146
 * Write to a character backend using a printf style interface.
147
 *
148
 * @fmt see #printf
149
 */
150
void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...)
151
    GCC_FMT_ATTR(2, 3);
152

  
153
/**
154
 * @qemu_chr_fe_write:
155
 *
156
 * Write data to a character backend from the front end.  This function will
157
 * send data from the front end to the back end.
158
 *
159
 * @buf the data
160
 * @len the number of bytes to send
161
 *
162
 * Returns: the number of bytes consumed
163
 */
164
int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len);
165

  
166
/**
167
 * @qemu_chr_fe_ioctl:
168
 *
169
 * Issue a device specific ioctl to a backend.
170
 *
171
 * @cmd see CHR_IOCTL_*
172
 * @arg the data associated with @cmd
173
 *
174
 * Returns: if @cmd is not supported by the backend, -ENOTSUP, otherwise the
175
 *          return value depends on the semantics of @cmd
176
 */
177
int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg);
178

  
179
/**
180
 * @qemu_chr_fe_get_msgfd:
181
 *
182
 * For backends capable of fd passing, return the latest file descriptor passed
183
 * by a client.
184
 *
185
 * Returns: -1 if fd passing isn't supported or there is no pending file
186
 *          descriptor.  If a file descriptor is returned, subsequent calls to
187
 *          this function will return -1 until a client sends a new file
188
 *          descriptor.
189
 */
190
int qemu_chr_fe_get_msgfd(CharDriverState *s);
191

  
192
/**
193
 * @qemu_chr_be_can_write:
194
 *
195
 * Determine how much data the front end can currently accept.  This function
196
 * returns the number of bytes the front end can accept.  If it returns 0, the
197
 * front end cannot receive data at the moment.  The function must be polled
198
 * to determine when data can be received.
199
 *
200
 * Returns: the number of bytes the front end can receive via @qemu_chr_be_write
201
 */
202
int qemu_chr_be_can_write(CharDriverState *s);
203

  
204
/**
205
 * @qemu_chr_be_write:
206
 *
207
 * Write data from the back end to the front end.  Before issuing this call,
208
 * the caller should call @qemu_chr_be_can_write to determine how much data
209
 * the front end can currently accept.
210
 *
211
 * @buf a buffer to receive data from the front end
212
 * @len the number of bytes to receive from the front end
213
 */
214
void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len);
215

  
216

  
217
/**
218
 * @qemu_chr_be_event:
219
 *
220
 * Send an event from the back end to the front end.
221
 *
222
 * @event the event to send
223
 */
224
void qemu_chr_be_event(CharDriverState *s, int event);
225

  
226
void qemu_chr_add_handlers(CharDriverState *s,
227
                           IOCanReadHandler *fd_can_read,
228
                           IOReadHandler *fd_read,
229
                           IOEventHandler *fd_event,
230
                           void *opaque);
231

  
232
void qemu_chr_generic_open(CharDriverState *s);
233
void qemu_chr_accept_input(CharDriverState *s);
234
int qemu_chr_add_client(CharDriverState *s, int fd);
235
void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
236
void qemu_chr_info(Monitor *mon, QObject **ret_data);
237
CharDriverState *qemu_chr_find(const char *name);
238

  
239
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
240

  
241
/* add an eventfd to the qemu devices that are polled */
242
CharDriverState *qemu_chr_open_eventfd(int eventfd);
243

  
244
extern int term_escape_char;
245

  
246
/* memory chardev */
247
void qemu_chr_init_mem(CharDriverState *chr);
248
void qemu_chr_close_mem(CharDriverState *chr);
249
QString *qemu_chr_mem_to_qs(CharDriverState *chr);
250
size_t qemu_chr_mem_osize(const CharDriverState *chr);
251

  
252
CharDriverState *qemu_char_get_next_serial(void);
253

  
254
#endif
b/qmp.c
16 16
#include "qemu-common.h"
17 17
#include "sysemu/sysemu.h"
18 18
#include "qmp-commands.h"
19
#include "qemu-char.h"
19
#include "char/char.h"
20 20
#include "ui/qemu-spice.h"
21 21
#include "ui/vnc.h"
22 22
#include "sysemu/kvm.h"
b/qtest.c
13 13

  
14 14
#include "sysemu/qtest.h"
15 15
#include "hw/qdev.h"
16
#include "qemu-char.h"
16
#include "char/char.h"
17 17
#include "exec/ioport.h"
18 18
#include "exec/memory.h"
19 19
#include "hw/irq.h"
b/slirp/slirp.c
23 23
 */
24 24
#include "qemu-common.h"
25 25
#include "qemu/timer.h"
26
#include "qemu-char.h"
26
#include "char/char.h"
27 27
#include "slirp.h"
28 28
#include "hw/hw.h"
29 29

  
b/spice-qemu-char.c
1 1
#include "config-host.h"
2 2
#include "trace.h"
3 3
#include "ui/qemu-spice.h"
4
#include "qemu-char.h"
4
#include "char/char.h"
5 5
#include <spice.h>
6 6
#include <spice-experimental.h>
7 7

  
b/ui/console.c
25 25
#include "ui/console.h"
26 26
#include "qemu/timer.h"
27 27
#include "qmp-commands.h"
28
#include "qemu-char.h"
28
#include "char/char.h"
29 29

  
30 30
//#define DEBUG_CONSOLE
31 31
#define DEFAULT_BACKSCROLL 512
b/vl.c
126 126
#include "hw/xen.h"
127 127
#include "hw/qdev.h"
128 128
#include "hw/loader.h"
129
#include "bt-host.h"
129
#include "bt/bt.h"
130 130
#include "net/net.h"
131 131
#include "net/slirp.h"
132 132
#include "monitor/monitor.h"
......
134 134
#include "sysemu/sysemu.h"
135 135
#include "exec/gdbstub.h"
136 136
#include "qemu/timer.h"
137
#include "qemu-char.h"
137
#include "char/char.h"
138 138
#include "qemu/cache-utils.h"
139 139
#include "sysemu/blockdev.h"
140 140
#include "hw/block-common.h"

Also available in: Unified diff