1138 |
|
|
1139 |
#define TERM_ESCAPE 0x01 /* ctrl-a is used for escape */ |
#define TERM_ESCAPE 0x01 /* ctrl-a is used for escape */ |
1140 |
|
|
1141 |
|
#define TERM_FIFO_MAX_SIZE 1 |
1142 |
|
|
1143 |
static int term_got_escape, client_index; |
static int term_got_escape, client_index; |
1144 |
|
static uint8_t term_fifo[TERM_FIFO_MAX_SIZE]; |
1145 |
|
int term_fifo_size; |
1146 |
|
|
1147 |
void term_print_help(void) |
void term_print_help(void) |
1148 |
{ |
{ |
1211 |
|
|
1212 |
chr = stdio_clients[client_index]; |
chr = stdio_clients[client_index]; |
1213 |
s = chr->opaque; |
s = chr->opaque; |
1214 |
buf[0] = ch; |
if (s->fd_can_read(s->fd_opaque) > 0) { |
1215 |
/* XXX: should queue the char if the device is not |
buf[0] = ch; |
|
ready */ |
|
|
if (s->fd_can_read(s->fd_opaque) > 0) |
|
1216 |
s->fd_read(s->fd_opaque, buf, 1); |
s->fd_read(s->fd_opaque, buf, 1); |
1217 |
|
} else if (term_fifo_size == 0) { |
1218 |
|
term_fifo[term_fifo_size++] = ch; |
1219 |
|
} |
1220 |
} |
} |
1221 |
} |
} |
1222 |
} |
} |
1223 |
|
|
1224 |
static int stdio_can_read(void *opaque) |
static int stdio_can_read(void *opaque) |
1225 |
{ |
{ |
1226 |
/* XXX: not strictly correct */ |
CharDriverState *chr; |
1227 |
return 1; |
FDCharDriver *s; |
1228 |
|
|
1229 |
|
if (client_index < stdio_nb_clients) { |
1230 |
|
chr = stdio_clients[client_index]; |
1231 |
|
s = chr->opaque; |
1232 |
|
/* try to flush the queue if needed */ |
1233 |
|
if (term_fifo_size != 0 && s->fd_can_read(s->fd_opaque) > 0) { |
1234 |
|
s->fd_read(s->fd_opaque, term_fifo, 1); |
1235 |
|
term_fifo_size = 0; |
1236 |
|
} |
1237 |
|
/* see if we can absorb more chars */ |
1238 |
|
if (term_fifo_size == 0) |
1239 |
|
return 1; |
1240 |
|
else |
1241 |
|
return 0; |
1242 |
|
} else { |
1243 |
|
return 1; |
1244 |
|
} |
1245 |
} |
} |
1246 |
|
|
1247 |
static void stdio_read(void *opaque, const uint8_t *buf, int size) |
static void stdio_read(void *opaque, const uint8_t *buf, int size) |