]>
Commit | Line | Data |
---|---|---|
87ecb68b PB |
1 | #ifndef QEMU_CHAR_H |
2 | #define QEMU_CHAR_H | |
3 | ||
376253ec | 4 | #include "qemu-common.h" |
5ccfae10 | 5 | #include "sys-queue.h" |
376253ec | 6 | |
87ecb68b PB |
7 | /* character device */ |
8 | ||
2724b180 AL |
9 | #define CHR_EVENT_BREAK 0 /* serial break char */ |
10 | #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ | |
11 | #define CHR_EVENT_RESET 2 /* new connection established */ | |
12 | #define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */ | |
13 | #define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */ | |
793cbfb5 | 14 | #define CHR_EVENT_CLOSED 5 /* connection closed */ |
87ecb68b PB |
15 | |
16 | ||
17 | #define CHR_IOCTL_SERIAL_SET_PARAMS 1 | |
18 | typedef struct { | |
19 | int speed; | |
20 | int parity; | |
21 | int data_bits; | |
22 | int stop_bits; | |
23 | } QEMUSerialSetParams; | |
24 | ||
25 | #define CHR_IOCTL_SERIAL_SET_BREAK 2 | |
26 | ||
27 | #define CHR_IOCTL_PP_READ_DATA 3 | |
28 | #define CHR_IOCTL_PP_WRITE_DATA 4 | |
29 | #define CHR_IOCTL_PP_READ_CONTROL 5 | |
30 | #define CHR_IOCTL_PP_WRITE_CONTROL 6 | |
31 | #define CHR_IOCTL_PP_READ_STATUS 7 | |
32 | #define CHR_IOCTL_PP_EPP_READ_ADDR 8 | |
33 | #define CHR_IOCTL_PP_EPP_READ 9 | |
34 | #define CHR_IOCTL_PP_EPP_WRITE_ADDR 10 | |
35 | #define CHR_IOCTL_PP_EPP_WRITE 11 | |
563e3c6e | 36 | #define CHR_IOCTL_PP_DATA_DIR 12 |
87ecb68b | 37 | |
f0664048 AJ |
38 | #define CHR_IOCTL_SERIAL_SET_TIOCM 13 |
39 | #define CHR_IOCTL_SERIAL_GET_TIOCM 14 | |
81174dae AL |
40 | |
41 | #define CHR_TIOCM_CTS 0x020 | |
42 | #define CHR_TIOCM_CAR 0x040 | |
43 | #define CHR_TIOCM_DSR 0x100 | |
44 | #define CHR_TIOCM_RI 0x080 | |
45 | #define CHR_TIOCM_DTR 0x002 | |
46 | #define CHR_TIOCM_RTS 0x004 | |
47 | ||
87ecb68b PB |
48 | typedef void IOEventHandler(void *opaque, int event); |
49 | ||
50 | struct CharDriverState { | |
ceecf1d1 | 51 | void (*init)(struct CharDriverState *s); |
87ecb68b PB |
52 | int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); |
53 | void (*chr_update_read_handler)(struct CharDriverState *s); | |
54 | int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); | |
7d174059 | 55 | int (*get_msgfd)(struct CharDriverState *s); |
87ecb68b PB |
56 | IOEventHandler *chr_event; |
57 | IOCanRWHandler *chr_can_read; | |
58 | IOReadHandler *chr_read; | |
59 | void *handler_opaque; | |
60 | void (*chr_send_event)(struct CharDriverState *chr, int event); | |
61 | void (*chr_close)(struct CharDriverState *chr); | |
bd9bdce6 | 62 | void (*chr_accept_input)(struct CharDriverState *chr); |
87ecb68b PB |
63 | void *opaque; |
64 | int focus; | |
65 | QEMUBH *bh; | |
5ccfae10 AL |
66 | char *label; |
67 | char *filename; | |
68 | TAILQ_ENTRY(CharDriverState) next; | |
87ecb68b PB |
69 | }; |
70 | ||
ceecf1d1 | 71 | CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s)); |
9596ebb7 | 72 | void qemu_chr_close(CharDriverState *chr); |
87ecb68b PB |
73 | void qemu_chr_printf(CharDriverState *s, const char *fmt, ...); |
74 | int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len); | |
75 | void qemu_chr_send_event(CharDriverState *s, int event); | |
76 | void qemu_chr_add_handlers(CharDriverState *s, | |
77 | IOCanRWHandler *fd_can_read, | |
78 | IOReadHandler *fd_read, | |
79 | IOEventHandler *fd_event, | |
80 | void *opaque); | |
81 | int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); | |
82 | void qemu_chr_reset(CharDriverState *s); | |
2970a6c9 | 83 | void qemu_chr_initial_reset(void); |
87ecb68b PB |
84 | int qemu_chr_can_read(CharDriverState *s); |
85 | void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len); | |
7d174059 | 86 | int qemu_chr_get_msgfd(CharDriverState *s); |
bd9bdce6 | 87 | void qemu_chr_accept_input(CharDriverState *s); |
376253ec | 88 | void qemu_chr_info(Monitor *mon); |
87ecb68b | 89 | |
0e82f34d AL |
90 | extern int term_escape_char; |
91 | ||
87ecb68b PB |
92 | /* async I/O support */ |
93 | ||
94 | int qemu_set_fd_handler2(int fd, | |
95 | IOCanRWHandler *fd_read_poll, | |
96 | IOHandler *fd_read, | |
97 | IOHandler *fd_write, | |
98 | void *opaque); | |
99 | int qemu_set_fd_handler(int fd, | |
100 | IOHandler *fd_read, | |
101 | IOHandler *fd_write, | |
102 | void *opaque); | |
103 | ||
104 | #endif |