Revision e5b0bc44 console.c

b/console.c
132 132
    int esc_params[MAX_ESC_PARAMS];
133 133
    int nb_esc_params;
134 134

  
135
    /* kbd read handler */
136
    IOCanRWHandler *fd_can_read; 
137
    IOReadHandler *fd_read;
138
    void *fd_opaque;
135
    CharDriverState *chr;
139 136
    /* fifo for key pressed */
140 137
    QEMUFIFO out_fifo;
141 138
    uint8_t out_fifo_buf[16];
......
1021 1018
    return len;
1022 1019
}
1023 1020

  
1024
static void console_chr_add_read_handler(CharDriverState *chr, 
1025
                                         IOCanRWHandler *fd_can_read, 
1026
                                         IOReadHandler *fd_read, void *opaque)
1027
{
1028
    TextConsole *s = chr->opaque;
1029
    s->fd_can_read = fd_can_read;
1030
    s->fd_read = fd_read;
1031
    s->fd_opaque = opaque;
1032
}
1033

  
1034 1021
static void console_send_event(CharDriverState *chr, int event)
1035 1022
{
1036 1023
    TextConsole *s = chr->opaque;
......
1052 1039
    int len;
1053 1040
    uint8_t buf[16];
1054 1041
    
1055
    len = s->fd_can_read(s->fd_opaque);
1042
    len = qemu_chr_can_read(s->chr);
1056 1043
    if (len > s->out_fifo.count)
1057 1044
        len = s->out_fifo.count;
1058 1045
    if (len > 0) {
1059 1046
        if (len > sizeof(buf))
1060 1047
            len = sizeof(buf);
1061 1048
        qemu_fifo_read(&s->out_fifo, buf, len);
1062
        s->fd_read(s->fd_opaque, buf, len);
1049
        qemu_chr_read(s->chr, buf, len);
1063 1050
    }
1064 1051
    /* characters are pending: we send them a bit later (XXX:
1065 1052
       horrible, should change char device API) */
......
1110 1097
        } else {
1111 1098
                *q++ = keysym;
1112 1099
        }
1113
        if (s->fd_read) {
1100
        if (s->chr->chr_read) {
1114 1101
            qemu_fifo_write(&s->out_fifo, buf, q - buf);
1115 1102
            kbd_send_chars(s);
1116 1103
        }
......
1186 1173
    }
1187 1174
    chr->opaque = s;
1188 1175
    chr->chr_write = console_puts;
1189
    chr->chr_add_read_handler = console_chr_add_read_handler;
1190 1176
    chr->chr_send_event = console_send_event;
1191 1177

  
1178
    s->chr = chr;
1192 1179
    s->out_fifo.buf = s->out_fifo_buf;
1193 1180
    s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
1194 1181
    s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);

Also available in: Unified diff