secondary consoles in minos
PATCH 1/1 secondary consoles in minos
Hi all,
this is an updated version of the patch "secondary consoles in minos" that didn't apply cleanly the first time.
extras/mini-os/console/console.c +8 -8
@@ -76,11 +76,11 @@#endif -void console_print (char *data,int length) +void console_print (struct consfront_dev *dev,char *data,int length) {char *curr_char, saved_char;int part_len; -int (*ring_send_fn)(const char *data,unsigned length); +int (*ring_send_fn)(struct consfront_dev *dev,const char *data,unsigned length);if (!console_initialised) ring_send_fn = xencons_ring_send_no_notify;
@@ -94,17 +94,17 @@ saved_char = *(curr_char+1 ); *(curr_char+1 ) ='\r' ; part_len = curr_char - data +2 ; -ring_send_fn (data, part_len); +ring_send_fn (dev, data, part_len); *(curr_char+1 ) = saved_char; data = curr_char+1 ; length -= part_len -1 ; } } -ring_send_fn (data, length); +ring_send_fn (dev, data, length);if (data[length-1 ] =='\n' ) -ring_send_fn ("\r" ,1 ); +ring_send_fn (dev,"\r" ,1 ); }void int direct,const char *fmt,va_list args)
@@ -123,7 +123,7 @@#endif (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (buf), buf); -console_print (buf,strlen (buf)); +console_print (NULL , buf,strlen (buf)); } }
@@ -151,7 +151,7 @@printk ("done.\n" ); } -void fini_console (void ) +void fini_console (struct consfront_dev *dev) { -/* Destruct the console and get the parameters of the restarted one */ +if (dev)free_consfront (dev); }
extras/mini-os/console/xencons_ring.c +217 -28
321 lines not on this page · raw message
extras/mini-os/include/console.h +35 -11
60 lines not on this page · raw message
extras/mini-os/include/lib.h +4 -0
@@ -101,6 +101,7 @@char *strdup (const char *s);#endif #include <mini-os/console.h> +int openpty (void );#define RAND_MIX 2654435769U
@@ -183,6 +184,9 @@struct {struct fbfront_dev *dev; } fb; +struct { +struct consfront_dev *dev; + } cons;struct {/* To each xenbus FD is associated a queue of watch events for this * FD. */
extras/mini-os/kernel.c +1 -1
@@ -562,7 +562,7 @@fini_gnttab ();/* Reset the console driver. */ -fini_console (); +fini_console (NULL );/* TODO: record new ring mfn & event in start_info */ /* Reset XenBus */
extras/mini-os/lib/sys.c +19 -3
@@ -167,6 +167,18 @@return 0 ; } +int openpty (void ) +{ +struct consfront_dev *dev; + + dev =init_consfront (NULL ); + dev->fd =alloc_fd (FTYPE_CONSOLE ); + files[dev->fd].cons.dev = dev; + +printk ("fd(%d) = openpty\n" , dev->fd); +return (dev->fd); +} +int open (const char *pathname,int flags, ...) {int fs_fd, fd;
@@ -219,7 +231,7 @@DEFINE_WAIT (w);while (1 ) {add_waiter (w, console_queue); - ret =xencons_ring_recv (buf, nbytes); + ret =xencons_ring_recv (files[fd].cons.dev, buf, nbytes);if (ret)break ;schedule ();
@@ -286,7 +298,7 @@ {switch (files[fd].type) {case FTYPE_CONSOLE : -console_print ((char *)buf, nbytes); +console_print (files[fd].cons.dev, (char *)buf, nbytes);return nbytes;case FTYPE_FILE : {ssize_t ret;
@@ -414,6 +426,10 @@return 0 ;case FTYPE_FB :shutdown_fbfront (files[fd].fb.dev); + files[fd].type =FTYPE_NONE ; +return 0 ; +case FTYPE_CONSOLE : +fini_console (files[fd].cons.dev); files[fd].type =FTYPE_NONE ;return 0 ;case FTYPE_NONE :
@@ -735,7 +751,7 @@break ;case FTYPE_CONSOLE :if (FD_ISSET (i, readfds)) { -if (xencons_ring_avail ()) +if (xencons_ring_avail (files[i].cons.dev)) n++;else FD_CLR (i, readfds);
stubdom/grub/mini-os.c +2 -2
@@ -329,7 +329,7 @@ serial_hw_put (int _c) {char c = _c; -console_print (&c,1 ); +console_print (NULL , &c,1 ); }int
@@ -337,7 +337,7 @@ {char key; -if (!xencons_ring_avail ()) +if (!xencons_ring_avail (NULL ))return -1 ;read (STDIN_FILENO , &key,1 );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 8 lines · Stefano Stabellini, le Tue 16 Jun 2009 16:38:53 +0100, a écrit :
extras/mini-os/console/xencons_ring.c +8
-0+struct consfront_dev *init_consfront (char *_nodename) +{ +static int consfrontends =1 ; + +if (!_nodename) +snprintf (nodename,sizeof (nodename),"device/console/%d" , consfrontends); +else +strncpy (nodename, _nodename,sizeof (nodename));
[...]
extras/mini-os/lib/sys.c line 176
Quoted 8 lines
extras/mini-os/lib/sys.c +8
-0+ +int openpty (void ) +{ +struct consfront_dev *dev; + + dev =init_consfront (NULL ); + dev->fd =alloc_fd (FTYPE_CONSOLE ); + files[dev->fd].cons.dev = dev;
Mmm, what would it be used for? It is a bit odd this way, as the standard openpty function does not work this way (it _creates_ the pty and returns the master part of the pty too, not only the slave part). I would have rather seen a mere addition to the open() function for a special path, as is done for LOG_PATH.
Samuel
Quoted 10 lines · Samuel Thibault
Quoted 8 lines · Stefano Stabellini, le Tue 16 Jun 2009 16:38:53 +0100, a écrit :
extras/mini-os/console/xencons_ring.c +8
-0+struct consfront_dev *init_consfront (char *_nodename) +{ +static int consfrontends =1 ; + +if (!_nodename) +snprintf (nodename,sizeof (nodename),"device/console/%d" , consfrontends); +else +strncpy (nodename, _nodename,sizeof (nodename));[...]
Quoted 15 lines
extras/mini-os/lib/sys.c line 176
Quoted 8 lines
extras/mini-os/lib/sys.c +8
-0+ +int openpty (void ) +{ +struct consfront_dev *dev; + + dev =init_consfront (NULL ); + dev->fd =alloc_fd (FTYPE_CONSOLE ); + files[dev->fd].cons.dev = dev;Mmm, what would it be used for? It is a bit odd this way, as the standard openpty function does not work this way (it _creates_ the pty and returns the master part of the pty too, not only the slave part). I would have rather seen a mere addition to the
open()function for a special path, as is done forLOG_PATH.
In qemu there is a differnt qemu_chr_open_pty per architecture so I have implemented a stubdom specific qemu_chr_open_pty that uses openpty(void).
I chose to create a new function called openpty because it is conceptually similar to the standard openpty, however I didn't want it to be standard compliant because it is not the same.
I realize it can be a little confusing, but I don't think that using another special case in the open() is much better.
Keir which one do you prefer?