pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 1 | #ifndef QEMU_CHAR_H |
| 2 | #define QEMU_CHAR_H |
| 3 | |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 4 | #include "qemu-common.h" |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 5 | #include "qemu-queue.h" |
Gerd Hoffmann | 191bc01 | 2009-09-10 10:58:35 +0200 | [diff] [blame] | 6 | #include "qemu-option.h" |
| 7 | #include "qemu-config.h" |
Luiz Capitulino | 588b383 | 2009-12-10 17:16:08 -0200 | [diff] [blame] | 8 | #include "qobject.h" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 9 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 10 | /* character device */ |
| 11 | |
aliguori | 2724b18 | 2009-03-05 23:01:47 +0000 | [diff] [blame] | 12 | #define CHR_EVENT_BREAK 0 /* serial break char */ |
| 13 | #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ |
Amit Shah | b6b8df5 | 2009-10-07 18:31:16 +0530 | [diff] [blame] | 14 | #define CHR_EVENT_OPENED 2 /* new connection established */ |
aliguori | 2724b18 | 2009-03-05 23:01:47 +0000 | [diff] [blame] | 15 | #define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */ |
| 16 | #define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */ |
Amit Shah | 793cbfb | 2009-08-11 21:27:48 +0530 | [diff] [blame] | 17 | #define CHR_EVENT_CLOSED 5 /* connection closed */ |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 18 | |
| 19 | |
| 20 | #define CHR_IOCTL_SERIAL_SET_PARAMS 1 |
| 21 | typedef struct { |
| 22 | int speed; |
| 23 | int parity; |
| 24 | int data_bits; |
| 25 | int stop_bits; |
| 26 | } QEMUSerialSetParams; |
| 27 | |
| 28 | #define CHR_IOCTL_SERIAL_SET_BREAK 2 |
| 29 | |
| 30 | #define CHR_IOCTL_PP_READ_DATA 3 |
| 31 | #define CHR_IOCTL_PP_WRITE_DATA 4 |
| 32 | #define CHR_IOCTL_PP_READ_CONTROL 5 |
| 33 | #define CHR_IOCTL_PP_WRITE_CONTROL 6 |
| 34 | #define CHR_IOCTL_PP_READ_STATUS 7 |
| 35 | #define CHR_IOCTL_PP_EPP_READ_ADDR 8 |
| 36 | #define CHR_IOCTL_PP_EPP_READ 9 |
| 37 | #define CHR_IOCTL_PP_EPP_WRITE_ADDR 10 |
| 38 | #define CHR_IOCTL_PP_EPP_WRITE 11 |
aurel32 | 563e3c6 | 2008-08-22 08:57:09 +0000 | [diff] [blame] | 39 | #define CHR_IOCTL_PP_DATA_DIR 12 |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 40 | |
aurel32 | f066404 | 2008-08-22 21:25:00 +0000 | [diff] [blame] | 41 | #define CHR_IOCTL_SERIAL_SET_TIOCM 13 |
| 42 | #define CHR_IOCTL_SERIAL_GET_TIOCM 14 |
aliguori | 81174da | 2008-08-11 14:17:04 +0000 | [diff] [blame] | 43 | |
| 44 | #define CHR_TIOCM_CTS 0x020 |
| 45 | #define CHR_TIOCM_CAR 0x040 |
| 46 | #define CHR_TIOCM_DSR 0x100 |
| 47 | #define CHR_TIOCM_RI 0x080 |
| 48 | #define CHR_TIOCM_DTR 0x002 |
| 49 | #define CHR_TIOCM_RTS 0x004 |
| 50 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 51 | typedef void IOEventHandler(void *opaque, int event); |
| 52 | |
| 53 | struct CharDriverState { |
aurel32 | ceecf1d | 2009-01-18 14:08:04 +0000 | [diff] [blame] | 54 | void (*init)(struct CharDriverState *s); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 55 | int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); |
| 56 | void (*chr_update_read_handler)(struct CharDriverState *s); |
| 57 | int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); |
Mark McLoughlin | 7d17405 | 2009-07-22 09:11:39 +0100 | [diff] [blame] | 58 | int (*get_msgfd)(struct CharDriverState *s); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 59 | IOEventHandler *chr_event; |
Juan Quintela | 7b27a76 | 2010-03-11 17:55:39 +0100 | [diff] [blame] | 60 | IOCanReadHandler *chr_can_read; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 61 | IOReadHandler *chr_read; |
| 62 | void *handler_opaque; |
| 63 | void (*chr_send_event)(struct CharDriverState *chr, int event); |
| 64 | void (*chr_close)(struct CharDriverState *chr); |
balrog | bd9bdce | 2007-11-25 00:55:06 +0000 | [diff] [blame] | 65 | void (*chr_accept_input)(struct CharDriverState *chr); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 66 | void *opaque; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 67 | QEMUBH *bh; |
aliguori | 5ccfae1 | 2008-10-31 17:31:29 +0000 | [diff] [blame] | 68 | char *label; |
| 69 | char *filename; |
Alexander Graf | 73cdf3f | 2010-04-01 18:42:39 +0200 | [diff] [blame] | 70 | int opened; |
Blue Swirl | 72cf2d4 | 2009-09-12 07:36:22 +0000 | [diff] [blame] | 71 | QTAILQ_ENTRY(CharDriverState) next; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
Gerd Hoffmann | 3352163 | 2009-12-08 13:11:49 +0100 | [diff] [blame] | 74 | QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); |
Gerd Hoffmann | 191bc01 | 2009-09-10 10:58:35 +0200 | [diff] [blame] | 75 | CharDriverState *qemu_chr_open_opts(QemuOpts *opts, |
| 76 | void (*init)(struct CharDriverState *s)); |
aurel32 | ceecf1d | 2009-01-18 14:08:04 +0000 | [diff] [blame] | 77 | CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s)); |
pbrook | 9596ebb | 2007-11-18 01:44:38 +0000 | [diff] [blame] | 78 | void qemu_chr_close(CharDriverState *chr); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 79 | void qemu_chr_printf(CharDriverState *s, const char *fmt, ...); |
| 80 | int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len); |
| 81 | void qemu_chr_send_event(CharDriverState *s, int event); |
| 82 | void qemu_chr_add_handlers(CharDriverState *s, |
Juan Quintela | 7b27a76 | 2010-03-11 17:55:39 +0100 | [diff] [blame] | 83 | IOCanReadHandler *fd_can_read, |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 84 | IOReadHandler *fd_read, |
| 85 | IOEventHandler *fd_event, |
| 86 | void *opaque); |
| 87 | int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); |
Amit Shah | 127338e | 2009-11-03 19:59:56 +0530 | [diff] [blame] | 88 | void qemu_chr_generic_open(CharDriverState *s); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 89 | int qemu_chr_can_read(CharDriverState *s); |
| 90 | void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len); |
Mark McLoughlin | 7d17405 | 2009-07-22 09:11:39 +0100 | [diff] [blame] | 91 | int qemu_chr_get_msgfd(CharDriverState *s); |
balrog | bd9bdce | 2007-11-25 00:55:06 +0000 | [diff] [blame] | 92 | void qemu_chr_accept_input(CharDriverState *s); |
Luiz Capitulino | 588b383 | 2009-12-10 17:16:08 -0200 | [diff] [blame] | 93 | void qemu_chr_info_print(Monitor *mon, const QObject *ret_data); |
| 94 | void qemu_chr_info(Monitor *mon, QObject **ret_data); |
Gerd Hoffmann | c845f40 | 2009-09-10 10:58:52 +0200 | [diff] [blame] | 95 | CharDriverState *qemu_chr_find(const char *name); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 96 | |
aliguori | 0e82f34 | 2008-10-31 18:44:40 +0000 | [diff] [blame] | 97 | extern int term_escape_char; |
| 98 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 99 | /* async I/O support */ |
| 100 | |
| 101 | int qemu_set_fd_handler2(int fd, |
Juan Quintela | 7b27a76 | 2010-03-11 17:55:39 +0100 | [diff] [blame] | 102 | IOCanReadHandler *fd_read_poll, |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 103 | IOHandler *fd_read, |
| 104 | IOHandler *fd_write, |
| 105 | void *opaque); |
| 106 | int qemu_set_fd_handler(int fd, |
| 107 | IOHandler *fd_read, |
| 108 | IOHandler *fd_write, |
| 109 | void *opaque); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 110 | #endif |