* [Qemu-devel] [patch] serial access
@ 2004-11-03 21:32 Thierry Baldo
0 siblings, 0 replies; only message in thread
From: Thierry Baldo @ 2004-11-03 21:32 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
Hi.
I propose this attached patch (0.6.0) for serial access (physical or
pseudo-tty):
physical:
$ qemu -serial /dev/ttyS0
or
pseudo-tty:
$ qemu -serial /dev/ttys0
with another terminal:
$ minicom -o -p /dev/ptys0
Cheers.
--
Thierry
[-- Attachment #2: qemu_serial.patch --]
[-- Type: application/octet-stream, Size: 4419 bytes --]
diff -ru ./hw/pc.c ../qemu-0.6.0/hw/pc.c
--- ./hw/pc.c 2004-07-10 20:20:09.000000000 +0200
+++ ../qemu-0.6.0/hw/pc.c 2004-08-14 15:09:02.000000000 +0200
@@ -471,8 +471,10 @@
pic_init();
pit = pit_init(0x40, 0);
- fd = serial_open_device();
+ fd = serial_open_device(0);
serial_init(0x3f8, 4, fd);
+ fd = serial_open_device(1);
+ serial_init(0x2f8, 3, fd);
if (pci_enabled) {
for(i = 0; i < nb_nics; i++) {
diff -ru ./hw/ppc_chrp.c ../qemu-0.6.0/hw/ppc_chrp.c
--- ./hw/ppc_chrp.c 2004-07-10 20:20:09.000000000 +0200
+++ ../qemu-0.6.0/hw/ppc_chrp.c 2004-08-14 15:18:58.000000000 +0200
@@ -200,8 +200,10 @@
pic_init();
/* XXX: use Mac Serial port */
- fd = serial_open_device();
+ fd = serial_open_device(0);
serial_init(0x3f8, 4, fd);
+ fd = serial_open_device(1);
+ serial_init(0x2f8, 3, fd);
for(i = 0; i < nb_nics; i++) {
pci_ne2000_init(pci_bus, &nd_table[i]);
diff -ru ./hw/ppc_prep.c ../qemu-0.6.0/hw/ppc_prep.c
--- ./hw/ppc_prep.c 2004-07-10 20:20:09.000000000 +0200
+++ ../qemu-0.6.0/hw/ppc_prep.c 2004-08-14 15:18:30.000000000 +0200
@@ -492,8 +492,10 @@
pic_init();
// pit = pit_init(0x40, 0);
- fd = serial_open_device();
+ fd = serial_open_device(0);
serial_init(0x3f8, 4, fd);
+ fd = serial_open_device(1);
+ serial_init(0x2f8, 3, fd);
nb_nics1 = nb_nics;
if (nb_nics1 > NE2000_NB_MAX)
nb_nics1 = NE2000_NB_MAX;
diff -ru ./vl.c ../qemu-0.6.0/vl.c
--- ./vl.c 2004-07-10 20:20:09.000000000 +0200
+++ ../qemu-0.6.0/vl.c 2004-08-20 21:24:17.000000000 +0200
@@ -139,6 +139,7 @@
int graphic_width = 800;
int graphic_height = 600;
int graphic_depth = 15;
+const char *serial[MAX_SERIAL];
/***********************************************************/
/* x86 ISA bus support */
@@ -953,14 +954,14 @@
#ifdef _WIN32
-int serial_open_device(void)
+int serial_open_device(int num)
{
return -1;
}
#else
-int serial_open_device(void)
+int serial_open_device(int num)
{
if (serial_console == NULL && nographic) {
/* use console for serial port */
@@ -978,7 +979,13 @@
fprintf(stderr, "Serial port redirected to %s\n", slave_name);
return master_fd;
#else
- return -1;
+ const char *name = serial[num];
+ if (num < 0 || num > MAX_SERIAL || name == NULL) {
+ return -1;
+ }
+ int fd = open (name, O_RDWR);
+ if (fd == -1) fprintf (stderr, "Cannot open %s for serial %d\n", name, num);
+ return fd;
#endif
}
}
@@ -2112,6 +2119,8 @@
"-d item1,... output log to %s (use -d ? for a list of log items)\n"
"-hdachs c,h,s force hard disk 0 geometry (usually qemu can guess it)\n"
"-L path set the directory for the BIOS and VGA BIOS\n"
+ "-serial0 path set the path for using serial 0 (/dev/ttys0)\n"
+ "-serial1 path set the path for using serial 1 (/dev/ttys1)\n"
#ifdef USE_CODE_COPY
"-no-code-copy disable code copy acceleration\n"
#endif
@@ -2184,6 +2193,8 @@
QEMU_OPTION_cirrusvga,
QEMU_OPTION_g,
QEMU_OPTION_std_vga,
+ QEMU_OPTION_serial0,
+ QEMU_OPTION_serial1,
};
typedef struct QEMUOption {
@@ -2239,6 +2250,9 @@
/* temporary options */
{ "pci", 0, QEMU_OPTION_pci },
{ "cirrusvga", 0, QEMU_OPTION_cirrusvga },
+
+ { "serial0", HAS_ARG, QEMU_OPTION_serial0 },
+ { "serial1", HAS_ARG, QEMU_OPTION_serial1 },
{ NULL },
};
@@ -2527,6 +2541,12 @@
case QEMU_OPTION_std_vga:
cirrus_vga_enabled = 0;
break;
+ case QEMU_OPTION_serial0:
+ serial[0] = optarg;
+ break;
+ case QEMU_OPTION_serial1:
+ serial[1] = optarg;
+ break;
case QEMU_OPTION_g:
{
const char *p;
diff -ru ./vl.h ../qemu-0.6.0/vl.h
--- ./vl.h 2004-07-10 20:20:09.000000000 +0200
+++ ../qemu-0.6.0/vl.h 2004-11-03 22:00:19.000000000 +0100
@@ -216,7 +216,7 @@
void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
-int serial_open_device(void);
+int serial_open_device(int num);
extern int vm_running;
@@ -774,4 +774,8 @@
int gdbserver_start(int port);
+/* serial */
+
+#define MAX_SERIAL 2
+
#endif /* VL_H */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-11-03 21:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03 21:32 [Qemu-devel] [patch] serial access Thierry Baldo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).