serial access
PATCH 1/1 serial access
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
qemu-0.6.0/hw/pc.c renamed from hw/pc.c +3 -1
@@ -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++) {
qemu-0.6.0/hw/ppc_chrp.c renamed from hw/ppc_chrp.c +3 -1
@@ -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]);
qemu-0.6.0/hw/ppc_prep.c renamed from hw/ppc_prep.c +3 -1
@@ -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 ;
qemu-0.6.0/vl.c renamed from vl.c +23 -3
@@ -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;
qemu-0.6.0/vl.h renamed from vl.h +5 -1
@@ -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 */