diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-02-02 09:50:21 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-02-02 09:50:21 +0000 |
commit | 2d6752d38d8acda6aae674a72b72be05482a58eb (patch) | |
tree | 9d35c5a56135b95194c1c439232125deb1fee73a /include | |
parent | 6fe791b5e3aca8a6de8a322e85e76d2f13338a7e (diff) | |
parent | 213dcb060f77a3e2704135d9c4da38b11673f8e9 (diff) |
Merge remote-tracking branch 'remotes/elmarco/tags/chr-split-pull-request' into staging
# gpg: Signature made Tue 31 Jan 2017 19:32:40 GMT
# gpg: using RSA key 0xDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>"
# gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5
* remotes/elmarco/tags/chr-split-pull-request: (41 commits)
char: headers clean-up
char: move parallel chardev in its own file
char: move serial chardev to its own file
char: move pty chardev in its own file
char: move pipe chardev in its own file
char: move console in its own file
char: move stdio in its own file
char: move file chardev in its own file
char: move udp chardev in its own file
char: move socket chardev to its own file
char: move win-stdio into its own file
char: move win chardev base class in its own file
char: move fd chardev in its own file
char: move QIOChannel-related stuff to char-io.h
char: remove unused READ_RETRIES
char: rename and move to header CHR_READ_BUF_LEN
char: move ringbuf/memory to its own file
char: move mux to its own file
char: move null chardev to its own file
char: make null_chr_write() the default method
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/sysemu/char.h | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/include/sysemu/char.h b/include/sysemu/char.h index da0e7dd494..450881d42c 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -2,12 +2,7 @@ #define QEMU_CHAR_H #include "qemu-common.h" -#include "qemu/queue.h" #include "qemu/option.h" -#include "qemu/config-file.h" -#include "block/aio.h" -#include "qapi/qmp/qobject.h" -#include "qapi/qmp/qstring.h" #include "qemu/main-loop.h" #include "qemu/bitmap.h" #include "qom/object.h" @@ -22,6 +17,7 @@ typedef enum { CHR_EVENT_CLOSED /* connection closed */ } QEMUChrEvent; +#define CHR_READ_BUF_LEN 4096 #define CHR_IOCTL_SERIAL_SET_PARAMS 1 typedef struct { @@ -74,7 +70,7 @@ typedef enum { QEMU_CHAR_FEATURE_REPLAY, QEMU_CHAR_FEATURE_LAST, -} CharDriverFeature; +} ChardevFeature; /* This is the backend as seen by frontend, the actual backend is * Chardev */ @@ -88,8 +84,6 @@ typedef struct CharBackend { int fe_open; } CharBackend; -typedef struct CharDriver CharDriver; - struct Chardev { Object parent_obj; @@ -143,7 +137,7 @@ Chardev *qemu_chr_new(const char *label, const char *filename); * @qemu_chr_fe_disconnect: * * Close a fd accpeted by character backend. - * Without associated CharDriver, do nothing. + * Without associated Chardev, do nothing. */ void qemu_chr_fe_disconnect(CharBackend *be); @@ -158,7 +152,7 @@ void qemu_chr_cleanup(void); * @qemu_chr_fe_wait_connected: * * Wait for characted backend to be connected, return < 0 on error or - * if no assicated CharDriver. + * if no assicated Chardev. */ int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp); @@ -185,19 +179,12 @@ Chardev *qemu_chr_new_noreplay(const char *label, const char *filename); void qemu_chr_delete(Chardev *chr); /** - * @qemu_chr_free: - * - * Destroy a character backend. - */ -void qemu_chr_free(Chardev *chr); - -/** * @qemu_chr_fe_set_echo: * * Ask the backend to override its normal echo setting. This only really * applies to the stdio backend and is used by the QMP server such that you * can see what you type if you try to type QMP commands. - * Without associated CharDriver, do nothing. + * Without associated Chardev, do nothing. * * @echo true to enable echo, false to disable echo */ @@ -208,7 +195,7 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo); * * Set character frontend open status. This is an indication that the * front end is ready (or not) to begin doing I/O. - * Without associated CharDriver, do nothing. + * Without associated Chardev, do nothing. */ void qemu_chr_fe_set_open(CharBackend *be, int fe_open); @@ -217,7 +204,7 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open); * * Write to a character backend using a printf style interface. This * function is thread-safe. It does nothing without associated - * CharDriver. + * Chardev. * * @fmt see #printf */ @@ -230,7 +217,7 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...) * If the backend is connected, create and add a #GSource that fires * when the given condition (typically G_IO_OUT|G_IO_HUP or G_IO_HUP) * is active; return the #GSource's tag. If it is disconnected, - * or without associated CharDriver, return 0. + * or without associated Chardev, return 0. * * @cond the condition to poll for * @func the function to call when the condition happens @@ -251,7 +238,7 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, * @buf the data * @len the number of bytes to send * - * Returns: the number of bytes consumed (0 if no assicated CharDriver) + * Returns: the number of bytes consumed (0 if no assicated Chardev) */ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); @@ -266,7 +253,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); * @buf the data * @len the number of bytes to send * - * Returns: the number of bytes consumed (0 if no assicated CharDriver) + * Returns: the number of bytes consumed (0 if no assicated Chardev) */ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); @@ -278,7 +265,7 @@ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); * @buf the data buffer * @len the number of bytes to read * - * Returns: the number of bytes read (0 if no assicated CharDriver) + * Returns: the number of bytes read (0 if no assicated Chardev) */ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len); @@ -291,7 +278,7 @@ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len); * @arg the data associated with @cmd * * Returns: if @cmd is not supported by the backend or there is no - * associated CharDriver, -ENOTSUP, otherwise the return + * associated Chardev, -ENOTSUP, otherwise the return * value depends on the semantics of @cmd */ int qemu_chr_fe_ioctl(CharBackend *be, int cmd, void *arg); @@ -331,7 +318,7 @@ int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int num); * result in overwriting the fd array with the new value without being send. * Upon writing the message the fd array is freed. * - * Returns: -1 if fd passing isn't supported or no associated CharDriver. + * Returns: -1 if fd passing isn't supported or no associated Chardev. */ int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num); @@ -382,7 +369,7 @@ void qemu_chr_be_event(Chardev *s, int event); * @qemu_chr_fe_init: * * Initializes a front end for the given CharBackend and - * CharDriver. Call qemu_chr_fe_deinit() to remove the association and + * Chardev. Call qemu_chr_fe_deinit() to remove the association and * release the driver. * * Returns: false on error. @@ -393,16 +380,16 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp); * @qemu_chr_fe_get_driver: * * Returns the driver associated with a CharBackend or NULL if no - * associated CharDriver. + * associated Chardev. */ Chardev *qemu_chr_fe_get_driver(CharBackend *be); /** * @qemu_chr_fe_deinit: * - * Dissociate the CharBackend from the CharDriver. + * Dissociate the CharBackend from the Chardev. * - * Safe to call without associated CharDriver. + * Safe to call without associated Chardev. */ void qemu_chr_fe_deinit(CharBackend *b); @@ -421,7 +408,7 @@ void qemu_chr_fe_deinit(CharBackend *b); * Set the front end char handlers. The front end takes the focus if * any of the handler is non-NULL. * - * Without associated CharDriver, nothing is changed. + * Without associated Chardev, nothing is changed. */ void qemu_chr_fe_set_handlers(CharBackend *b, IOCanReadHandler *fd_can_read, @@ -436,7 +423,7 @@ void qemu_chr_fe_set_handlers(CharBackend *b, * * Take the focus (if the front end is muxed). * - * Without associated CharDriver, nothing is changed. + * Without associated Chardev, nothing is changed. */ void qemu_chr_fe_take_focus(CharBackend *b); @@ -446,10 +433,12 @@ int qemu_chr_add_client(Chardev *s, int fd); Chardev *qemu_chr_find(const char *name); bool qemu_chr_has_feature(Chardev *chr, - CharDriverFeature feature); + ChardevFeature feature); void qemu_chr_set_feature(Chardev *chr, - CharDriverFeature feature); + ChardevFeature feature); QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); +int qemu_chr_write_all(Chardev *s, const uint8_t *buf, int len); +int qemu_chr_wait_connected(Chardev *chr, Error **errp); #define TYPE_CHARDEV "chardev" #define CHARDEV(obj) OBJECT_CHECK(Chardev, (obj), TYPE_CHARDEV) @@ -472,8 +461,6 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); #define TYPE_CHARDEV_SOCKET "chardev-socket" #define TYPE_CHARDEV_UDP "chardev-udp" -#define CHARDEV_IS_MUX(chr) \ - object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX) #define CHARDEV_IS_RINGBUF(chr) \ object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_RINGBUF) #define CHARDEV_IS_PTY(chr) \ @@ -483,6 +470,7 @@ typedef struct ChardevClass { ObjectClass parent_class; bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ + void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); void (*open)(Chardev *chr, ChardevBackend *backend, bool *be_opened, Error **errp); @@ -496,24 +484,15 @@ typedef struct ChardevClass { int (*set_msgfds)(Chardev *s, int *fds, int num); int (*chr_add_client)(Chardev *chr, int fd); int (*chr_wait_connected)(Chardev *chr, Error **errp); - void (*chr_free)(Chardev *chr); void (*chr_disconnect)(Chardev *chr); void (*chr_accept_input)(Chardev *chr); void (*chr_set_echo)(Chardev *chr, bool echo); void (*chr_set_fe_open)(Chardev *chr, int fe_open); } ChardevClass; -struct CharDriver { - ChardevBackendKind kind; - const char *alias; - void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); -}; - Chardev *qemu_chardev_new(const char *id, const char *typename, ChardevBackend *backend, Error **errp); -void register_char_driver(const CharDriver *driver); - extern int term_escape_char; /* console.c */ |