Statistics
| Branch: | Revision:

root / qemu-char.h @ 42138043

History | View | Annotate | Download (4.6 kB)

1 87ecb68b pbrook
#ifndef QEMU_CHAR_H
2 87ecb68b pbrook
#define QEMU_CHAR_H
3 87ecb68b pbrook
4 376253ec aliguori
#include "qemu-common.h"
5 72cf2d4f Blue Swirl
#include "qemu-queue.h"
6 191bc01b Gerd Hoffmann
#include "qemu-option.h"
7 191bc01b Gerd Hoffmann
#include "qemu-config.h"
8 588b3832 Luiz Capitulino
#include "qobject.h"
9 999bd67c Luiz Capitulino
#include "qstring.h"
10 376253ec aliguori
11 87ecb68b pbrook
/* character device */
12 87ecb68b pbrook
13 2724b180 aliguori
#define CHR_EVENT_BREAK   0 /* serial break char */
14 2724b180 aliguori
#define CHR_EVENT_FOCUS   1 /* focus to this terminal (modal input needed) */
15 b6b8df56 Amit Shah
#define CHR_EVENT_OPENED  2 /* new connection established */
16 2724b180 aliguori
#define CHR_EVENT_MUX_IN  3 /* mux-focus was set to this terminal */
17 2724b180 aliguori
#define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */
18 793cbfb5 Amit Shah
#define CHR_EVENT_CLOSED  5 /* connection closed */
19 87ecb68b pbrook
20 87ecb68b pbrook
21 87ecb68b pbrook
#define CHR_IOCTL_SERIAL_SET_PARAMS   1
22 87ecb68b pbrook
typedef struct {
23 87ecb68b pbrook
    int speed;
24 87ecb68b pbrook
    int parity;
25 87ecb68b pbrook
    int data_bits;
26 87ecb68b pbrook
    int stop_bits;
27 87ecb68b pbrook
} QEMUSerialSetParams;
28 87ecb68b pbrook
29 87ecb68b pbrook
#define CHR_IOCTL_SERIAL_SET_BREAK    2
30 87ecb68b pbrook
31 87ecb68b pbrook
#define CHR_IOCTL_PP_READ_DATA        3
32 87ecb68b pbrook
#define CHR_IOCTL_PP_WRITE_DATA       4
33 87ecb68b pbrook
#define CHR_IOCTL_PP_READ_CONTROL     5
34 87ecb68b pbrook
#define CHR_IOCTL_PP_WRITE_CONTROL    6
35 87ecb68b pbrook
#define CHR_IOCTL_PP_READ_STATUS      7
36 87ecb68b pbrook
#define CHR_IOCTL_PP_EPP_READ_ADDR    8
37 87ecb68b pbrook
#define CHR_IOCTL_PP_EPP_READ         9
38 87ecb68b pbrook
#define CHR_IOCTL_PP_EPP_WRITE_ADDR  10
39 87ecb68b pbrook
#define CHR_IOCTL_PP_EPP_WRITE       11
40 563e3c6e aurel32
#define CHR_IOCTL_PP_DATA_DIR        12
41 87ecb68b pbrook
42 f0664048 aurel32
#define CHR_IOCTL_SERIAL_SET_TIOCM   13
43 f0664048 aurel32
#define CHR_IOCTL_SERIAL_GET_TIOCM   14
44 81174dae aliguori
45 81174dae aliguori
#define CHR_TIOCM_CTS        0x020
46 81174dae aliguori
#define CHR_TIOCM_CAR        0x040
47 81174dae aliguori
#define CHR_TIOCM_DSR        0x100
48 81174dae aliguori
#define CHR_TIOCM_RI        0x080
49 81174dae aliguori
#define CHR_TIOCM_DTR        0x002
50 81174dae aliguori
#define CHR_TIOCM_RTS        0x004
51 81174dae aliguori
52 87ecb68b pbrook
typedef void IOEventHandler(void *opaque, int event);
53 87ecb68b pbrook
54 87ecb68b pbrook
struct CharDriverState {
55 ceecf1d1 aurel32
    void (*init)(struct CharDriverState *s);
56 87ecb68b pbrook
    int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
57 87ecb68b pbrook
    void (*chr_update_read_handler)(struct CharDriverState *s);
58 87ecb68b pbrook
    int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
59 7d174059 Mark McLoughlin
    int (*get_msgfd)(struct CharDriverState *s);
60 87ecb68b pbrook
    IOEventHandler *chr_event;
61 7b27a769 Juan Quintela
    IOCanReadHandler *chr_can_read;
62 87ecb68b pbrook
    IOReadHandler *chr_read;
63 87ecb68b pbrook
    void *handler_opaque;
64 87ecb68b pbrook
    void (*chr_send_event)(struct CharDriverState *chr, int event);
65 87ecb68b pbrook
    void (*chr_close)(struct CharDriverState *chr);
66 bd9bdce6 balrog
    void (*chr_accept_input)(struct CharDriverState *chr);
67 c48855e1 Paolo Bonzini
    void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
68 7c32c4fe Hans de Goede
    void (*chr_guest_open)(struct CharDriverState *chr);
69 7c32c4fe Hans de Goede
    void (*chr_guest_close)(struct CharDriverState *chr);
70 87ecb68b pbrook
    void *opaque;
71 87ecb68b pbrook
    QEMUBH *bh;
72 5ccfae10 aliguori
    char *label;
73 5ccfae10 aliguori
    char *filename;
74 73cdf3f2 Alexander Graf
    int opened;
75 d5b27167 Kusanagi Kouichi
    int avail_connections;
76 72cf2d4f Blue Swirl
    QTAILQ_ENTRY(CharDriverState) next;
77 87ecb68b pbrook
};
78 87ecb68b pbrook
79 33521634 Gerd Hoffmann
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
80 191bc01b Gerd Hoffmann
CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
81 191bc01b Gerd Hoffmann
                                    void (*init)(struct CharDriverState *s));
82 ceecf1d1 aurel32
CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s));
83 c48855e1 Paolo Bonzini
void qemu_chr_set_echo(struct CharDriverState *chr, bool echo);
84 7c32c4fe Hans de Goede
void qemu_chr_guest_open(struct CharDriverState *chr);
85 7c32c4fe Hans de Goede
void qemu_chr_guest_close(struct CharDriverState *chr);
86 9596ebb7 pbrook
void qemu_chr_close(CharDriverState *chr);
87 8b7968f7 Stefan Weil
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
88 8b7968f7 Stefan Weil
    GCC_FMT_ATTR(2, 3);
89 87ecb68b pbrook
int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
90 87ecb68b pbrook
void qemu_chr_send_event(CharDriverState *s, int event);
91 87ecb68b pbrook
void qemu_chr_add_handlers(CharDriverState *s,
92 7b27a769 Juan Quintela
                           IOCanReadHandler *fd_can_read,
93 87ecb68b pbrook
                           IOReadHandler *fd_read,
94 87ecb68b pbrook
                           IOEventHandler *fd_event,
95 87ecb68b pbrook
                           void *opaque);
96 87ecb68b pbrook
int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
97 127338e6 Amit Shah
void qemu_chr_generic_open(CharDriverState *s);
98 87ecb68b pbrook
int qemu_chr_can_read(CharDriverState *s);
99 87ecb68b pbrook
void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
100 7d174059 Mark McLoughlin
int qemu_chr_get_msgfd(CharDriverState *s);
101 bd9bdce6 balrog
void qemu_chr_accept_input(CharDriverState *s);
102 588b3832 Luiz Capitulino
void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
103 588b3832 Luiz Capitulino
void qemu_chr_info(Monitor *mon, QObject **ret_data);
104 c845f401 Gerd Hoffmann
CharDriverState *qemu_chr_find(const char *name);
105 87ecb68b pbrook
106 6cbf4c8c Cam Macdonell
/* add an eventfd to the qemu devices that are polled */
107 6cbf4c8c Cam Macdonell
CharDriverState *qemu_chr_open_eventfd(int eventfd);
108 6cbf4c8c Cam Macdonell
109 0e82f34d aliguori
extern int term_escape_char;
110 0e82f34d aliguori
111 999bd67c Luiz Capitulino
/* memory chardev */
112 999bd67c Luiz Capitulino
void qemu_chr_init_mem(CharDriverState *chr);
113 999bd67c Luiz Capitulino
void qemu_chr_close_mem(CharDriverState *chr);
114 999bd67c Luiz Capitulino
QString *qemu_chr_mem_to_qs(CharDriverState *chr);
115 999bd67c Luiz Capitulino
size_t qemu_chr_mem_osize(const CharDriverState *chr);
116 999bd67c Luiz Capitulino
117 87ecb68b pbrook
/* async I/O support */
118 87ecb68b pbrook
119 87ecb68b pbrook
int qemu_set_fd_handler2(int fd,
120 7b27a769 Juan Quintela
                         IOCanReadHandler *fd_read_poll,
121 87ecb68b pbrook
                         IOHandler *fd_read,
122 87ecb68b pbrook
                         IOHandler *fd_write,
123 87ecb68b pbrook
                         void *opaque);
124 87ecb68b pbrook
int qemu_set_fd_handler(int fd,
125 87ecb68b pbrook
                        IOHandler *fd_read,
126 87ecb68b pbrook
                        IOHandler *fd_write,
127 87ecb68b pbrook
                        void *opaque);
128 87ecb68b pbrook
#endif