| 1013 |
return s->chr_write(s, buf, len); |
return s->chr_write(s, buf, len); |
| 1014 |
} |
} |
| 1015 |
|
|
| 1016 |
|
void qemu_chr_set_serial_parameters(CharDriverState *s, |
| 1017 |
|
int speed, int parity, |
| 1018 |
|
int data_bits, int stop_bits) |
| 1019 |
|
{ |
| 1020 |
|
if (s->chr_set_serial_parameters) |
| 1021 |
|
s->chr_set_serial_parameters(s, speed, parity, data_bits, stop_bits); |
| 1022 |
|
} |
| 1023 |
|
|
| 1024 |
|
void qemu_chr_set_serial_break(CharDriverState *s, int enable) |
| 1025 |
|
{ |
| 1026 |
|
if (s->chr_set_serial_break) |
| 1027 |
|
s->chr_set_serial_break(s, enable); |
| 1028 |
|
} |
| 1029 |
|
|
| 1030 |
|
|
| 1031 |
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...) |
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...) |
| 1032 |
{ |
{ |
| 1033 |
char buf[4096]; |
char buf[4096]; |
| 1126 |
{ |
{ |
| 1127 |
FDCharDriver *s = chr->opaque; |
FDCharDriver *s = chr->opaque; |
| 1128 |
|
|
| 1129 |
if (nographic && s->fd_in == 0) { |
if (s->fd_in >= 0) { |
| 1130 |
s->fd_can_read = fd_can_read; |
if (nographic && s->fd_in == 0) { |
| 1131 |
s->fd_read = fd_read; |
s->fd_can_read = fd_can_read; |
| 1132 |
s->fd_opaque = opaque; |
s->fd_read = fd_read; |
| 1133 |
} else { |
s->fd_opaque = opaque; |
| 1134 |
qemu_add_fd_read_handler(s->fd_in, fd_can_read, fd_read, opaque); |
} else { |
| 1135 |
|
qemu_add_fd_read_handler(s->fd_in, fd_can_read, fd_read, opaque); |
| 1136 |
|
} |
| 1137 |
} |
} |
| 1138 |
} |
} |
| 1139 |
|
|
| 1159 |
return chr; |
return chr; |
| 1160 |
} |
} |
| 1161 |
|
|
| 1162 |
|
CharDriverState *qemu_chr_open_file_out(const char *file_out) |
| 1163 |
|
{ |
| 1164 |
|
int fd_out; |
| 1165 |
|
|
| 1166 |
|
fd_out = open(file_out, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY); |
| 1167 |
|
if (fd_out < 0) |
| 1168 |
|
return NULL; |
| 1169 |
|
return qemu_chr_open_fd(-1, fd_out); |
| 1170 |
|
} |
| 1171 |
|
|
| 1172 |
|
CharDriverState *qemu_chr_open_pipe(const char *filename) |
| 1173 |
|
{ |
| 1174 |
|
int fd; |
| 1175 |
|
|
| 1176 |
|
fd = open(filename, O_RDWR | O_BINARY); |
| 1177 |
|
if (fd < 0) |
| 1178 |
|
return NULL; |
| 1179 |
|
return qemu_chr_open_fd(fd, fd); |
| 1180 |
|
} |
| 1181 |
|
|
| 1182 |
|
|
| 1183 |
/* for STDIO, we handle the case where several clients use it |
/* for STDIO, we handle the case where several clients use it |
| 1184 |
(nographic mode) */ |
(nographic mode) */ |
| 1185 |
|
|
| 1372 |
fprintf(stderr, "char device redirected to %s\n", slave_name); |
fprintf(stderr, "char device redirected to %s\n", slave_name); |
| 1373 |
return qemu_chr_open_fd(master_fd, master_fd); |
return qemu_chr_open_fd(master_fd, master_fd); |
| 1374 |
} |
} |
| 1375 |
|
|
| 1376 |
|
static void tty_serial_init(int fd, int speed, |
| 1377 |
|
int parity, int data_bits, int stop_bits) |
| 1378 |
|
{ |
| 1379 |
|
struct termios tty; |
| 1380 |
|
speed_t spd; |
| 1381 |
|
|
| 1382 |
|
tcgetattr (0, &tty); |
| 1383 |
|
|
| 1384 |
|
switch(speed) { |
| 1385 |
|
case 50: |
| 1386 |
|
spd = B50; |
| 1387 |
|
break; |
| 1388 |
|
case 75: |
| 1389 |
|
spd = B75; |
| 1390 |
|
break; |
| 1391 |
|
case 300: |
| 1392 |
|
spd = B300; |
| 1393 |
|
break; |
| 1394 |
|
case 600: |
| 1395 |
|
spd = B600; |
| 1396 |
|
break; |
| 1397 |
|
case 1200: |
| 1398 |
|
spd = B1200; |
| 1399 |
|
break; |
| 1400 |
|
case 2400: |
| 1401 |
|
spd = B2400; |
| 1402 |
|
break; |
| 1403 |
|
case 4800: |
| 1404 |
|
spd = B4800; |
| 1405 |
|
break; |
| 1406 |
|
case 9600: |
| 1407 |
|
spd = B9600; |
| 1408 |
|
break; |
| 1409 |
|
case 19200: |
| 1410 |
|
spd = B19200; |
| 1411 |
|
break; |
| 1412 |
|
case 38400: |
| 1413 |
|
spd = B38400; |
| 1414 |
|
break; |
| 1415 |
|
case 57600: |
| 1416 |
|
spd = B57600; |
| 1417 |
|
break; |
| 1418 |
|
default: |
| 1419 |
|
case 115200: |
| 1420 |
|
spd = B115200; |
| 1421 |
|
break; |
| 1422 |
|
} |
| 1423 |
|
|
| 1424 |
|
cfsetispeed(&tty, spd); |
| 1425 |
|
cfsetospeed(&tty, spd); |
| 1426 |
|
|
| 1427 |
|
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |
| 1428 |
|
|INLCR|IGNCR|ICRNL|IXON); |
| 1429 |
|
tty.c_oflag |= OPOST; |
| 1430 |
|
tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG); |
| 1431 |
|
tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS); |
| 1432 |
|
switch(data_bits) { |
| 1433 |
|
default: |
| 1434 |
|
case 8: |
| 1435 |
|
tty.c_cflag |= CS8; |
| 1436 |
|
break; |
| 1437 |
|
case 7: |
| 1438 |
|
tty.c_cflag |= CS7; |
| 1439 |
|
break; |
| 1440 |
|
case 6: |
| 1441 |
|
tty.c_cflag |= CS6; |
| 1442 |
|
break; |
| 1443 |
|
case 5: |
| 1444 |
|
tty.c_cflag |= CS5; |
| 1445 |
|
break; |
| 1446 |
|
} |
| 1447 |
|
switch(parity) { |
| 1448 |
|
default: |
| 1449 |
|
case 'N': |
| 1450 |
|
break; |
| 1451 |
|
case 'E': |
| 1452 |
|
tty.c_cflag |= PARENB; |
| 1453 |
|
break; |
| 1454 |
|
case 'O': |
| 1455 |
|
tty.c_cflag |= PARENB | PARODD; |
| 1456 |
|
break; |
| 1457 |
|
} |
| 1458 |
|
|
| 1459 |
|
tcsetattr (fd, TCSANOW, &tty); |
| 1460 |
|
} |
| 1461 |
|
|
| 1462 |
|
static void tty_set_serial_parameters(CharDriverState *chr, |
| 1463 |
|
int speed, int parity, |
| 1464 |
|
int data_bits, int stop_bits) |
| 1465 |
|
{ |
| 1466 |
|
FDCharDriver *s = chr->opaque; |
| 1467 |
|
tty_serial_init(s->fd_in, speed, parity, data_bits, stop_bits); |
| 1468 |
|
} |
| 1469 |
|
|
| 1470 |
|
static void tty_set_serial_break(CharDriverState *chr, int enable) |
| 1471 |
|
{ |
| 1472 |
|
FDCharDriver *s = chr->opaque; |
| 1473 |
|
/* XXX: find a better solution */ |
| 1474 |
|
if (enable) |
| 1475 |
|
tcsendbreak(s->fd_in, 1); |
| 1476 |
|
} |
| 1477 |
|
|
| 1478 |
|
CharDriverState *qemu_chr_open_tty(const char *filename) |
| 1479 |
|
{ |
| 1480 |
|
CharDriverState *chr; |
| 1481 |
|
int fd; |
| 1482 |
|
|
| 1483 |
|
fd = open(filename, O_RDWR); |
| 1484 |
|
if (fd < 0) |
| 1485 |
|
return NULL; |
| 1486 |
|
fcntl(fd, F_SETFL, O_NONBLOCK); |
| 1487 |
|
tty_serial_init(fd, 115200, 'N', 8, 1); |
| 1488 |
|
chr = qemu_chr_open_fd(fd, fd); |
| 1489 |
|
if (!chr) |
| 1490 |
|
return NULL; |
| 1491 |
|
chr->chr_set_serial_parameters = tty_set_serial_parameters; |
| 1492 |
|
chr->chr_set_serial_break = tty_set_serial_break; |
| 1493 |
|
return chr; |
| 1494 |
|
} |
| 1495 |
|
|
| 1496 |
#else |
#else |
| 1497 |
CharDriverState *qemu_chr_open_pty(void) |
CharDriverState *qemu_chr_open_pty(void) |
| 1498 |
{ |
{ |
| 1504 |
|
|
| 1505 |
CharDriverState *qemu_chr_open(const char *filename) |
CharDriverState *qemu_chr_open(const char *filename) |
| 1506 |
{ |
{ |
| 1507 |
|
const char *p; |
| 1508 |
if (!strcmp(filename, "vc")) { |
if (!strcmp(filename, "vc")) { |
| 1509 |
return text_console_init(&display_state); |
return text_console_init(&display_state); |
| 1510 |
} else if (!strcmp(filename, "null")) { |
} else if (!strcmp(filename, "null")) { |
| 1511 |
return qemu_chr_open_null(); |
return qemu_chr_open_null(); |
| 1512 |
|
} else if (strstart(filename, "file:", &p)) { |
| 1513 |
|
return qemu_chr_open_file_out(p); |
| 1514 |
|
} else if (strstart(filename, "pipe:", &p)) { |
| 1515 |
|
return qemu_chr_open_pipe(p); |
| 1516 |
} else |
} else |
| 1517 |
#ifndef _WIN32 |
#ifndef _WIN32 |
| 1518 |
if (!strcmp(filename, "pty")) { |
if (!strcmp(filename, "pty")) { |
| 1521 |
return qemu_chr_open_stdio(); |
return qemu_chr_open_stdio(); |
| 1522 |
} else |
} else |
| 1523 |
#endif |
#endif |
| 1524 |
|
#if defined(__linux__) |
| 1525 |
|
if (strstart(filename, "/dev/", NULL)) { |
| 1526 |
|
return qemu_chr_open_tty(filename); |
| 1527 |
|
} else |
| 1528 |
|
#endif |
| 1529 |
{ |
{ |
| 1530 |
return NULL; |
return NULL; |
| 1531 |
} |
} |
| 3179 |
"-no-code-copy disable code copy acceleration\n" |
"-no-code-copy disable code copy acceleration\n" |
| 3180 |
#endif |
#endif |
| 3181 |
#ifdef TARGET_I386 |
#ifdef TARGET_I386 |
|
"-isa simulate an ISA-only system (default is PCI system)\n" |
|
| 3182 |
"-std-vga simulate a standard VGA card with VESA Bochs Extensions\n" |
"-std-vga simulate a standard VGA card with VESA Bochs Extensions\n" |
| 3183 |
" (default is CL-GD5446 PCI VGA)\n" |
" (default is CL-GD5446 PCI VGA)\n" |
| 3184 |
#endif |
#endif |