secondary consoles in minos
PATCH v2 1/1 secondary consoles in minos
Hi all,
this is the new version of the patch "secondary consoles in minos":
minios is now exporting a standard compliant posix_openpt function instead of the non-standard openpty(void).
Signed-off-by Stefano Stabellini <[email protected]>
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 +3 -0
@@ -183,6 +183,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 +26 -3
@@ -167,6 +167,20 @@return 0 ; } +int posix_openpt (int flags) +{ +struct consfront_dev *dev; + +/* Ignore flags */ + + dev =init_consfront (NULL ); + dev->fd =alloc_fd (FTYPE_CONSOLE ); + files[dev->fd].cons.dev = dev; + +printk ("fd(%d) = posix_openpt\n" , dev->fd); +return (dev->fd); +} +int open (const char *pathname,int flags, ...) {int fs_fd, fd;
@@ -176,6 +190,8 @@printk ("open(%s) -> %d\n" , pathname, fd);return fd; } +if (!strncmp (pathname,"/dev/ptmx" ,strlen ("/dev/ptmx" ))) +return posix_openpt (flags);printk ("open(%s, %x)" , pathname, flags);switch (flags & ~O_ACCMODE ) {case 0 :
@@ -219,7 +235,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 +302,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 +430,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 +755,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);
@@ -1325,6 +1345,9 @@unsupported_function_crash (sysconf);unsupported_function (int, tcsetattr,-1 );unsupported_function (int, tcgetattr,0 ); +unsupported_function (int, grantpt,-1 ); +unsupported_function (int, unlockpt,-1 ); +unsupported_function(char *, ptsname, NULL);unsupported_function (int, poll,-1 );/* net/if.h */
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