Statistics
| Branch: | Revision:

root / qemu-char.h @ 2d6c1ef4

History | View | Annotate | Download (4.4 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 87ecb68b pbrook
    void *opaque;
69 87ecb68b pbrook
    QEMUBH *bh;
70 5ccfae10 aliguori
    char *label;
71 5ccfae10 aliguori
    char *filename;
72 73cdf3f2 Alexander Graf
    int opened;
73 2d6c1ef4 Amit Shah
    int assigned; /* chardev assigned to a device */
74 72cf2d4f Blue Swirl
    QTAILQ_ENTRY(CharDriverState) next;
75 87ecb68b pbrook
};
76 87ecb68b pbrook
77 33521634 Gerd Hoffmann
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename);
78 191bc01b Gerd Hoffmann
CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
79 191bc01b Gerd Hoffmann
                                    void (*init)(struct CharDriverState *s));
80 ceecf1d1 aurel32
CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s));
81 c48855e1 Paolo Bonzini
void qemu_chr_set_echo(struct CharDriverState *chr, bool echo);
82 9596ebb7 pbrook
void qemu_chr_close(CharDriverState *chr);
83 8b7968f7 Stefan Weil
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
84 8b7968f7 Stefan Weil
    GCC_FMT_ATTR(2, 3);
85 87ecb68b pbrook
int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
86 87ecb68b pbrook
void qemu_chr_send_event(CharDriverState *s, int event);
87 87ecb68b pbrook
void qemu_chr_add_handlers(CharDriverState *s,
88 7b27a769 Juan Quintela
                           IOCanReadHandler *fd_can_read,
89 87ecb68b pbrook
                           IOReadHandler *fd_read,
90 87ecb68b pbrook
                           IOEventHandler *fd_event,
91 87ecb68b pbrook
                           void *opaque);
92 87ecb68b pbrook
int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
93 127338e6 Amit Shah
void qemu_chr_generic_open(CharDriverState *s);
94 87ecb68b pbrook
int qemu_chr_can_read(CharDriverState *s);
95 87ecb68b pbrook
void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
96 7d174059 Mark McLoughlin
int qemu_chr_get_msgfd(CharDriverState *s);
97 bd9bdce6 balrog
void qemu_chr_accept_input(CharDriverState *s);
98 588b3832 Luiz Capitulino
void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
99 588b3832 Luiz Capitulino
void qemu_chr_info(Monitor *mon, QObject **ret_data);
100 c845f401 Gerd Hoffmann
CharDriverState *qemu_chr_find(const char *name);
101 87ecb68b pbrook
102 6cbf4c8c Cam Macdonell
/* add an eventfd to the qemu devices that are polled */
103 6cbf4c8c Cam Macdonell
CharDriverState *qemu_chr_open_eventfd(int eventfd);
104 6cbf4c8c Cam Macdonell
105 0e82f34d aliguori
extern int term_escape_char;
106 0e82f34d aliguori
107 999bd67c Luiz Capitulino
/* memory chardev */
108 999bd67c Luiz Capitulino
void qemu_chr_init_mem(CharDriverState *chr);
109 999bd67c Luiz Capitulino
void qemu_chr_close_mem(CharDriverState *chr);
110 999bd67c Luiz Capitulino
QString *qemu_chr_mem_to_qs(CharDriverState *chr);
111 999bd67c Luiz Capitulino
size_t qemu_chr_mem_osize(const CharDriverState *chr);
112 999bd67c Luiz Capitulino
113 87ecb68b pbrook
/* async I/O support */
114 87ecb68b pbrook
115 87ecb68b pbrook
int qemu_set_fd_handler2(int fd,
116 7b27a769 Juan Quintela
                         IOCanReadHandler *fd_read_poll,
117 87ecb68b pbrook
                         IOHandler *fd_read,
118 87ecb68b pbrook
                         IOHandler *fd_write,
119 87ecb68b pbrook
                         void *opaque);
120 87ecb68b pbrook
int qemu_set_fd_handler(int fd,
121 87ecb68b pbrook
                        IOHandler *fd_read,
122 87ecb68b pbrook
                        IOHandler *fd_write,
123 87ecb68b pbrook
                        void *opaque);
124 87ecb68b pbrook
#endif