Commit 0ec7b3e7 authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Paolo Bonzini
Browse files

char: rename CharDriverState Chardev



Pick a uniform chardev type name.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent d5cafc73
Loading
Loading
Loading
Loading
+29 −27
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@
#define BUF_SIZE 256

typedef struct {
    CharDriverState parent;
    Chardev parent;

    brlapi_handle_t *brlapi;
    int brlapi_fd;
@@ -98,7 +98,7 @@ typedef struct {
    uint8_t out_buf_used, out_buf_ptr;

    QEMUTimer *cellCount_timer;
} BaumDriverState;
} BaumChardev;

/* Let's assume NABCC by default */
enum way {
@@ -223,7 +223,7 @@ static const uint8_t nabcc_translation[2][256] = {
};

/* The guest OS has started discussing with us, finish initializing BrlAPI */
static int baum_deferred_init(BaumDriverState *baum)
static int baum_deferred_init(BaumChardev *baum)
{
    int tty = BRLAPI_TTY_DEFAULT;
    QemuConsole *con;
@@ -253,9 +253,9 @@ static int baum_deferred_init(BaumDriverState *baum)
}

/* The serial port can receive more of our data */
static void baum_accept_input(struct CharDriverState *chr)
static void baum_accept_input(struct Chardev *chr)
{
    BaumDriverState *baum = (BaumDriverState *)chr;
    BaumChardev *baum = (BaumChardev *)chr;
    int room, first;

    if (!baum->out_buf_used)
@@ -279,9 +279,9 @@ static void baum_accept_input(struct CharDriverState *chr)
}

/* We want to send a packet */
static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len)
static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len)
{
    CharDriverState *chr = (CharDriverState *)baum;
    Chardev *chr = (Chardev *)baum;
    uint8_t io_buf[1 + 2 * len], *cur = io_buf;
    int room;
    *cur++ = ESC;
@@ -322,14 +322,14 @@ static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len
/* Called when the other end seems to have a wrong idea of our display size */
static void baum_cellCount_timer_cb(void *opaque)
{
    BaumDriverState *baum = opaque;
    BaumChardev *baum = opaque;
    uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
    DPRINTF("Timeout waiting for DisplayData, sending cell count\n");
    baum_write_packet(baum, cell_count, sizeof(cell_count));
}

/* Try to interpret a whole incoming packet */
static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
{
    const uint8_t *cur = buf;
    uint8_t req = 0;
@@ -470,9 +470,9 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
}

/* The other end is writing some data.  Store it and try to interpret */
static int baum_write(CharDriverState *chr, const uint8_t *buf, int len)
static int baum_write(Chardev *chr, const uint8_t *buf, int len)
{
    BaumDriverState *baum = (BaumDriverState *)chr;
    BaumChardev *baum = (BaumChardev *)chr;
    int tocopy, cur, eaten, orig_len = len;

    if (!len)
@@ -511,14 +511,16 @@ static int baum_write(CharDriverState *chr, const uint8_t *buf, int len)
}

/* Send the key code to the other end */
static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) {
static void baum_send_key(BaumChardev *baum, uint8_t type, uint8_t value)
{
    uint8_t packet[] = { type, value };
    DPRINTF("writing key %x %x\n", type, value);
    baum_write_packet(baum, packet, sizeof(packet));
}

static void baum_send_key2(BaumDriverState *baum, uint8_t type, uint8_t value,
                           uint8_t value2) {
static void baum_send_key2(BaumChardev *baum, uint8_t type, uint8_t value,
                           uint8_t value2)
{
    uint8_t packet[] = { type, value, value2 };
    DPRINTF("writing key %x %x\n", type, value);
    baum_write_packet(baum, packet, sizeof(packet));
@@ -527,7 +529,7 @@ static void baum_send_key2(BaumDriverState *baum, uint8_t type, uint8_t value,
/* We got some data on the BrlAPI socket */
static void baum_chr_read(void *opaque)
{
    BaumDriverState *baum = opaque;
    BaumChardev *baum = opaque;
    brlapi_keyCode_t code;
    int ret;
    if (!baum->brlapi)
@@ -611,9 +613,9 @@ static void baum_chr_read(void *opaque)
    }
}

static void baum_free(struct CharDriverState *chr)
static void baum_free(struct Chardev *chr)
{
    BaumDriverState *baum = (BaumDriverState *)chr;
    BaumChardev *baum = (BaumChardev *)chr;

    timer_free(baum->cellCount_timer);
    if (baum->brlapi) {
@@ -622,7 +624,7 @@ static void baum_free(struct CharDriverState *chr)
    }
}

static CharDriverState *chr_baum_init(const CharDriver *driver,
static Chardev *chr_baum_init(const CharDriver *driver,
                              const char *id,
                              ChardevBackend *backend,
                              ChardevReturn *ret,
@@ -630,15 +632,15 @@ static CharDriverState *chr_baum_init(const CharDriver *driver,
                              Error **errp)
{
    ChardevCommon *common = backend->u.braille.data;
    BaumDriverState *baum;
    CharDriverState *chr;
    BaumChardev *baum;
    Chardev *chr;
    brlapi_handle_t *handle;

    chr = qemu_chr_alloc(driver, common, errp);
    if (!chr) {
        return NULL;
    }
    baum = (BaumDriverState *)chr;
    baum = (BaumChardev *)chr;

    handle = g_malloc0(brlapi_getHandleSize());
    baum->brlapi = handle;
@@ -666,7 +668,7 @@ fail_handle:
static void register_types(void)
{
    static const CharDriver driver = {
        .instance_size = sizeof(BaumDriverState),
        .instance_size = sizeof(BaumChardev),
        .kind = CHARDEV_BACKEND_KIND_BRAILLE,
        .create = chr_baum_init,
        .chr_write = baum_write,
+21 −21
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
#define MSMOUSE_HI2(n) (((n) & 0xc0) >> 6)

typedef struct {
    CharDriverState parent;
    Chardev parent;

    QemuInputHandlerState *hs;
    int axis[INPUT_AXIS__MAX];
@@ -39,11 +39,11 @@ typedef struct {
    bool btnc[INPUT_BUTTON__MAX];
    uint8_t outbuf[32];
    int outlen;
} MouseState;
} MouseChardev;

static void msmouse_chr_accept_input(CharDriverState *chr)
static void msmouse_chr_accept_input(Chardev *chr)
{
    MouseState *mouse = (MouseState *)chr;
    MouseChardev *mouse = (MouseChardev *)chr;
    int len;

    len = qemu_chr_be_can_write(chr);
@@ -61,7 +61,7 @@ static void msmouse_chr_accept_input(CharDriverState *chr)
    }
}

static void msmouse_queue_event(MouseState *mouse)
static void msmouse_queue_event(MouseChardev *mouse)
{
    unsigned char bytes[4] = { 0x40, 0x00, 0x00, 0x00 };
    int dx, dy, count = 3;
@@ -98,7 +98,7 @@ static void msmouse_queue_event(MouseState *mouse)
static void msmouse_input_event(DeviceState *dev, QemuConsole *src,
                                InputEvent *evt)
{
    MouseState *mouse = (MouseState *)dev;
    MouseChardev *mouse = (MouseChardev *)dev;
    InputMoveEvent *move;
    InputBtnEvent *btn;

@@ -122,22 +122,22 @@ static void msmouse_input_event(DeviceState *dev, QemuConsole *src,

static void msmouse_input_sync(DeviceState *dev)
{
    MouseState *mouse = (MouseState *)dev;
    CharDriverState *chr = (CharDriverState *)dev;
    MouseChardev *mouse = (MouseChardev *)dev;
    Chardev *chr = (Chardev *)dev;

    msmouse_queue_event(mouse);
    msmouse_chr_accept_input(chr);
}

static int msmouse_chr_write (struct CharDriverState *s, const uint8_t *buf, int len)
static int msmouse_chr_write(struct Chardev *s, const uint8_t *buf, int len)
{
    /* Ignore writes to mouse port */
    return len;
}

static void msmouse_chr_free(struct CharDriverState *chr)
static void msmouse_chr_free(struct Chardev *chr)
{
    MouseState *mouse = (MouseState *)chr;
    MouseChardev *mouse = (MouseChardev *)chr;

    qemu_input_handler_unregister(mouse->hs);
}
@@ -149,7 +149,7 @@ static QemuInputHandler msmouse_handler = {
    .sync  = msmouse_input_sync,
};

static CharDriverState *qemu_chr_open_msmouse(const CharDriver *driver,
static Chardev *qemu_chr_open_msmouse(const CharDriver *driver,
                                      const char *id,
                                      ChardevBackend *backend,
                                      ChardevReturn *ret,
@@ -157,8 +157,8 @@ static CharDriverState *qemu_chr_open_msmouse(const CharDriver *driver,
                                      Error **errp)
{
    ChardevCommon *common = backend->u.msmouse.data;
    MouseState *mouse;
    CharDriverState *chr;
    MouseChardev *mouse;
    Chardev *chr;

    chr = qemu_chr_alloc(driver, common, errp);
    if (!chr) {
@@ -166,7 +166,7 @@ static CharDriverState *qemu_chr_open_msmouse(const CharDriver *driver,
    }
    *be_opened = false;

    mouse = (MouseState *)chr;
    mouse = (MouseChardev *)chr;
    mouse->hs = qemu_input_handler_register((DeviceState *)mouse,
                                            &msmouse_handler);

@@ -177,7 +177,7 @@ static CharDriverState *qemu_chr_open_msmouse(const CharDriver *driver,
static void register_types(void)
{
    static const CharDriver driver = {
        .instance_size = sizeof(MouseState),
        .instance_size = sizeof(MouseChardev),
        .kind = CHARDEV_BACKEND_KIND_MSMOUSE,
        .create = qemu_chr_open_msmouse,
        .chr_write = msmouse_chr_write,
+2 −2
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ static void rng_egd_chr_read(void *opaque, const uint8_t *buf, int size)
static void rng_egd_opened(RngBackend *b, Error **errp)
{
    RngEgd *s = RNG_EGD(b);
    CharDriverState *chr;
    Chardev *chr;

    if (s->chr_name == NULL) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
@@ -125,7 +125,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
static char *rng_egd_get_chardev(Object *obj, Error **errp)
{
    RngEgd *s = RNG_EGD(obj);
    CharDriverState *chr = qemu_chr_fe_get_driver(&s->chr);
    Chardev *chr = qemu_chr_fe_get_driver(&s->chr);

    if (chr && chr->label) {
        return g_strdup(chr->label);
+14 −14
Original line number Diff line number Diff line
@@ -30,14 +30,14 @@
#define BUF_SIZE 32

typedef struct {
    CharDriverState parent;
    Chardev parent;

    uint8_t in_buf[32];
    int in_buf_used;
} TestdevCharState;
} TestdevChardev;

/* Try to interpret a whole incoming packet */
static int testdev_eat_packet(TestdevCharState *testdev)
static int testdev_eat_packet(TestdevChardev *testdev)
{
    const uint8_t *cur = testdev->in_buf;
    int len = testdev->in_buf_used;
@@ -78,9 +78,9 @@ static int testdev_eat_packet(TestdevCharState *testdev)
}

/* The other end is writing some data.  Store it and try to interpret */
static int testdev_write(CharDriverState *chr, const uint8_t *buf, int len)
static int testdev_write(Chardev *chr, const uint8_t *buf, int len)
{
    TestdevCharState *testdev = (TestdevCharState *)chr;
    TestdevChardev *testdev = (TestdevChardev *)chr;
    int tocopy, eaten, orig_len = len;

    while (len) {
@@ -103,15 +103,15 @@ static int testdev_write(CharDriverState *chr, const uint8_t *buf, int len)
    return orig_len;
}

static CharDriverState *chr_testdev_init(const CharDriver *driver,
static Chardev *chr_testdev_init(const CharDriver *driver,
                                 const char *id,
                                 ChardevBackend *backend,
                                 ChardevReturn *ret,
                                 bool *be_opened,
                                 Error **errp)
{
    TestdevCharState *testdev = g_new0(TestdevCharState, 1);;
    CharDriverState *chr = (CharDriverState *)testdev;
    TestdevChardev *testdev = g_new0(TestdevChardev, 1);;
    Chardev *chr = (Chardev *)testdev;

    chr->driver = driver;

@@ -121,7 +121,7 @@ static CharDriverState *chr_testdev_init(const CharDriver *driver,
static void register_types(void)
{
    static const CharDriver driver = {
        .instance_size = sizeof(TestdevCharState),
        .instance_size = sizeof(TestdevChardev),
        .kind = CHARDEV_BACKEND_KIND_TESTDEV,
        .create = chr_testdev_init,
        .chr_write = testdev_write,
+6 −6
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ typedef struct GDBState {
    int running_state;
#else
    CharBackend chr;
    CharDriverState *mon_chr;
    Chardev *mon_chr;
#endif
    char syscall_buf[256];
    gdb_syscall_complete_cb current_syscall_cb;
@@ -1473,7 +1473,7 @@ void gdb_exit(CPUArchState *env, int code)
  GDBState *s;
  char buf[4];
#ifndef CONFIG_USER_ONLY
  CharDriverState *chr;
  Chardev *chr;
#endif

  s = gdbserver_state;
@@ -1698,7 +1698,7 @@ static void gdb_monitor_output(GDBState *s, const char *msg, int len)
    put_packet(s, buf);
}

static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len)
static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len)
{
    const char *p = (const char *)buf;
    int max_sz;
@@ -1729,11 +1729,11 @@ int gdbserver_start(const char *device)
{
    GDBState *s;
    char gdbstub_device_name[128];
    CharDriverState *chr = NULL;
    CharDriverState *mon_chr;
    Chardev *chr = NULL;
    Chardev *mon_chr;
    ChardevCommon common = { 0 };
    static const CharDriver driver = {
        .instance_size = sizeof(CharDriverState),
        .instance_size = sizeof(Chardev),
        .kind = -1,
        .chr_write = gdb_monitor_write,
    };
Loading