4 #include "qemu-common.h"
5 #include "qemu-queue.h"
6 #include "qemu-option.h"
7 #include "qemu-config.h"
11 /* character device */
13 #define CHR_EVENT_BREAK 0 /* serial break char */
14 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
15 #define CHR_EVENT_OPENED 2 /* new connection established */
16 #define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */
17 #define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
18 #define CHR_EVENT_CLOSED 5 /* connection closed */
19 #define CHR_IOCTL_SERIAL_SET_PARAMS 6
25 } QEMUSerialSetParams
;
27 #define CHR_IOCTL_SERIAL_SET_BREAK 7
29 #define CHR_IOCTL_PP_READ_DATA 8
30 #define CHR_IOCTL_PP_WRITE_DATA 9
31 #define CHR_IOCTL_PP_READ_CONTROL 10
32 #define CHR_IOCTL_PP_WRITE_CONTROL 11
33 #define CHR_IOCTL_PP_READ_STATUS 12
34 #define CHR_IOCTL_PP_EPP_READ_ADDR 13
35 #define CHR_IOCTL_PP_EPP_READ 14
36 #define CHR_IOCTL_PP_EPP_WRITE_ADDR 15
37 #define CHR_IOCTL_PP_EPP_WRITE 16
38 #define CHR_IOCTL_PP_DATA_DIR 17
40 #define CHR_IOCTL_SERIAL_SET_TIOCM 18
41 #define CHR_IOCTL_SERIAL_GET_TIOCM 19
43 #define CHR_GET_MSGFD 20
44 #define CHR_SET_ECHO 21
46 #define CHR_TIOCM_CTS 0x020
47 #define CHR_TIOCM_CAR 0x040
48 #define CHR_TIOCM_DSR 0x100
49 #define CHR_TIOCM_RI 0x080
50 #define CHR_TIOCM_DTR 0x002
51 #define CHR_TIOCM_RTS 0x004
53 typedef int IOEventHandler(void *opaque
, int event
, void *data
);
55 #define MAX_CHAR_QUEUE_RING 1024
57 typedef struct CharQueue
61 uint8_t ring
[MAX_CHAR_QUEUE_RING
];
64 struct CharDriverState
{
65 void (*init
)(struct CharDriverState
*s
);
66 int (*chr_write
)(struct CharDriverState
*s
, const uint8_t *buf
, int len
);
67 IOEventHandler
*chr_ioctl
;
70 int (*chr_add_client
)(struct CharDriverState
*chr
, int fd
);
71 IOEventHandler
*chr_event
;
75 void (*chr_close
)(struct CharDriverState
*chr
);
76 void (*chr_guest_open
)(struct CharDriverState
*chr
);
77 void (*chr_guest_close
)(struct CharDriverState
*chr
);
83 int avail_connections
;
90 QTAILQ_ENTRY(CharDriverState
) next
;
93 QemuOpts
*qemu_chr_parse_compat(const char *label
, const char *filename
);
94 CharDriverState
*qemu_chr_open_opts(QemuOpts
*opts
,
95 void (*init
)(struct CharDriverState
*s
));
96 CharDriverState
*qemu_chr_open(const char *label
, const char *filename
, void (*init
)(struct CharDriverState
*s
));
98 void qemu_chr_fe_open(struct CharDriverState
*chr
);
99 void qemu_chr_fe_close(struct CharDriverState
*chr
);
100 void qemu_chr_close(CharDriverState
*chr
);
101 void qemu_chr_printf(CharDriverState
*s
, const char *fmt
, ...)
103 int qemu_chr_fe_write(CharDriverState
*s
, const uint8_t *buf
, int len
);
104 int qemu_chr_fe_read(CharDriverState
*s
, uint8_t *buf
, int len
);
106 void qemu_chr_fe_set_handlers(CharDriverState
*s
,
108 IOHandler
*chr_write
,
109 IOEventHandler
*chr_event
,
112 int qemu_chr_fe_ioctl(CharDriverState
*s
, int cmd
, void *arg
);
113 void qemu_chr_generic_open(CharDriverState
*s
);
114 int qemu_chr_be_can_write(CharDriverState
*s
);
115 int qemu_chr_be_write(CharDriverState
*s
, uint8_t *buf
, int len
);
116 int qemu_chr_be_read(CharDriverState
*s
, uint8_t *buf
, int len
);
118 static inline int qemu_chr_fe_get_msgfd(CharDriverState
*s
)
123 ret
= qemu_chr_fe_ioctl(s
, CHR_GET_MSGFD
, &fd
);
131 static inline void qemu_chr_fe_set_echo(CharDriverState
*chr
, bool echo
)
133 qemu_chr_fe_ioctl(chr
, CHR_SET_ECHO
, &echo
);
136 int qemu_chr_add_client(CharDriverState
*s
, int fd
);
137 void qemu_chr_info_print(Monitor
*mon
, const QObject
*ret_data
);
138 void qemu_chr_info(Monitor
*mon
, QObject
**ret_data
);
139 CharDriverState
*qemu_chr_find(const char *name
);
141 /* add an eventfd to the qemu devices that are polled */
142 CharDriverState
*qemu_chr_open_eventfd(int eventfd
);
144 extern int term_escape_char
;
147 void qemu_chr_init_mem(CharDriverState
*chr
);
148 void qemu_chr_close_mem(CharDriverState
*chr
);
149 QString
*qemu_chr_mem_to_qs(CharDriverState
*chr
);
150 size_t qemu_chr_mem_osize(const CharDriverState
*chr
);
152 /* async I/O support */
154 int qemu_set_fd_handler2(int fd
,
155 IOCanReadHandler
*fd_read_poll
,
159 int qemu_set_fd_handler(int fd
,