]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[console] Allow console input and output to be disabled independently
authorMichael Brown <mcb30@ipxe.org>
Thu, 28 Nov 2013 05:41:45 +0000 (05:41 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 28 Nov 2013 05:54:53 +0000 (05:54 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/core/video_subr.c
src/arch/i386/interface/vmware/vmconsole.c
src/arch/x86/core/debugcon.c
src/core/console.c
src/core/serial_console.c
src/include/ipxe/console.h
src/net/tcp/syslogs.c
src/net/udp/syslog.c

index 306c6d56cc1b4fbd67f2a6ade903865763378c5f..3f701bd965b2c5c505eee7dcb2df7637dff19980 100644 (file)
@@ -104,7 +104,7 @@ static void vga_putc(int byte)
 
 struct console_driver vga_console __console_driver = {
        .putchar = vga_putc,
-       .disabled = 1,
+       .disabled = CONSOLE_DISABLED,
        .usage = CONSOLE_DIRECT_VGA,
 };
 
index 485105200148f8958183d54aed2bcc674610ce18..c6b9fff123032215f22d44ebd1d770d87b1e2f69 100644 (file)
@@ -102,7 +102,7 @@ static void vmconsole_putchar ( int character ) {
 /** VMware logfile console driver */
 struct console_driver vmconsole __console_driver = {
        .putchar = vmconsole_putchar,
-       .disabled = 1,
+       .disabled = CONSOLE_DISABLED,
        .usage = CONSOLE_VMWARE,
 };
 
index b89480aa5e18345de2deafc01b1b2ba0e1650a3d..263cb4af1c714f8d59a0db166da3520b2f178f5d 100644 (file)
@@ -74,7 +74,7 @@ static void debugcon_init ( void ) {
        check = inb ( DEBUG_PORT );
        if ( check != DEBUG_PORT_CHECK ) {
                DBG ( "Debug port not present; disabling console\n" );
-               debugcon_console.disabled = 1;
+               debugcon_console.disabled = CONSOLE_DISABLED;
        }
 }
 
index a26a3ef6398a9685c89a645e5024845ee8bb7f70..73baf7f66b86fb588597381d352c66e69e04e57a 100644 (file)
@@ -11,15 +11,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
 int console_usage = CONSOLE_USAGE_STDOUT;
 
 /**
- * Write a single character to each console device.
+ * Write a single character to each console device
  *
  * @v character                Character to be written
- * @ret None           -
- * @err None           -
  *
  * The character is written out to all enabled console devices, using
  * each device's console_driver::putchar() method.
- *
  */
 void putchar ( int character ) {
        struct console_driver *console;
@@ -29,7 +26,7 @@ void putchar ( int character ) {
                putchar ( '\r' );
 
        for_each_table_entry ( console, CONSOLES ) {
-               if ( ( ! console->disabled ) &&
+               if ( ( ! ( console->disabled & CONSOLE_DISABLED_OUTPUT ) ) &&
                     ( console_usage & console->usage ) &&
                     console->putchar )
                        console->putchar ( character );
@@ -37,23 +34,20 @@ void putchar ( int character ) {
 }
 
 /**
- * Check to see if any input is available on any console.
+ * Check to see if any input is available on any console
  *
- * @v None             -
- * @ret console                Console device that has input available, if any.
- * @ret NULL           No console device has input available.
- * @err None           -
+ * @ret console                Console device that has input available, or NULL
  *
  * All enabled console devices are checked once for available input
  * using each device's console_driver::iskey() method.  The first
  * console device that has available input will be returned, if any.
- *
  */
 static struct console_driver * has_input ( void ) {
        struct console_driver *console;
 
        for_each_table_entry ( console, CONSOLES ) {
-               if ( ( ! console->disabled ) && console->iskey ) {
+               if ( ( ! ( console->disabled & CONSOLE_DISABLED_INPUT ) ) &&
+                    console->iskey ) {
                        if ( console->iskey () )
                                return console;
                }
@@ -62,11 +56,9 @@ static struct console_driver * has_input ( void ) {
 }
 
 /**
- * Read a single character from any console.
+ * Read a single character from any console
  *
- * @v None             -
  * @ret character      Character read from a console.
- * @err None           -
  *
  * A character will be read from the first enabled console device that
  * has input available using that console's console_driver::getchar()
@@ -80,7 +72,6 @@ static struct console_driver * has_input ( void ) {
  * @endcode
  *
  * The character read will not be echoed back to any console.
- *
  */
 int getchar ( void ) {
        struct console_driver *console;
@@ -116,19 +107,16 @@ int getchar ( void ) {
        return character;
 }
 
-/** Check for available input on any console.
+/**
+ * Check for available input on any console
  *
- * @v None             -
- * @ret True           Input is available on a console
- * @ret False          Input is not available on any console
- * @err None           -
+ * @ret is_available   Input is available on a console
  *
  * All enabled console devices are checked once for available input
  * using each device's console_driver::iskey() method.  If any console
- * device has input available, this call will return True.  If this
- * call returns True, you can then safely call getchar() without
+ * device has input available, this call will return true.  If this
+ * call returns true, you can then safely call getchar() without
  * blocking.
- *
  */
 int iskey ( void ) {
        return has_input() ? 1 : 0;
index 3852a308c9b9a3100e1eea1d84176b71e01ae120..de9b84ca731940c9eb69aa986ce18d9869c59463 100644 (file)
@@ -30,7 +30,7 @@ struct console_driver serial_console __console_driver = {
        .putchar = serial_putc,
        .getchar = serial_getc,
        .iskey = serial_ischar,
-       .disabled = 1,
+       .disabled = CONSOLE_DISABLED,
        .usage = CONSOLE_SERIAL,
 };
 
index e2bf4be973a608056a94cc7d366c456f1b53f526..2fcc4150e87b764798b53905fbf622b67e971c56 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _IPXE_CONSOLE_H
 #define _IPXE_CONSOLE_H
 
+#include <stddef.h>
 #include <stdio.h>
 #include <ipxe/tables.h>
 
 
 FILE_LICENCE ( GPL2_OR_LATER );
 
+struct pixel_buffer;
+
+/** A console configuration */
+struct console_configuration {
+       /** Width */
+       unsigned int width;
+       /** Height */
+       unsigned int height;
+       /** Colour depth */
+       unsigned int bpp;
+       /** Background picture, if any */
+       struct pixel_buffer *pixbuf;
+};
+
 /**
  * A console driver
  *
@@ -25,58 +40,45 @@ FILE_LICENCE ( GPL2_OR_LATER );
  * #__console_driver.
  *
  * @note Consoles that cannot be used before their initialisation
- * function has completed should set #disabled=1 initially.  This
- * allows other console devices to still be used to print out early
- * debugging messages.
- *
+ * function has completed should set #disabled initially.  This allows
+ * other console devices to still be used to print out early debugging
+ * messages.
  */
 struct console_driver {
-       /** Console is disabled.
-        *
-        * The console's putchar(), getchar() and iskey() methods will
-        * not be called while #disabled==1.  Typically the console's
-        * initialisation functions will set #disabled=0 upon
-        * completion.
+       /**
+        * Console disabled flags
         *
+        * This is the bitwise OR of zero or more console disabled
+        * flags.
         */
        int disabled;
-
-       /** Write a character to the console.
+       /**
+        * Write a character to the console
         *
         * @v character         Character to be written
-        * @ret None            -
-        * @err None            -
-        *
         */
-       void ( *putchar ) ( int character );
-
-       /** Read a character from the console.
+       void ( * putchar ) ( int character );
+       /**
+        * Read a character from the console
         *
-        * @v None              -
         * @ret character       Character read
-        * @err None            -
         *
         * If no character is available to be read, this method will
         * block.  The character read should not be echoed back to the
         * console.
-        *
         */
-       int ( *getchar ) ( void );
-
-       /** Check for available input.
+       int ( * getchar ) ( void );
+       /**
+        * Check for available input
         *
-        * @v None              -
-        * @ret True            Input is available
-        * @ret False           Input is not available
-        * @err None            -
+        * @ret is_available    Input is available
         *
-        * This should return True if a subsequent call to getchar()
+        * This should return true if a subsequent call to getchar()
         * will not block.
-        *
         */
-       int ( *iskey ) ( void );
-
-       /** Console usage bitmask
+       int ( * iskey ) ( void );
+       /**
+        * Console usage bitmask
         *
         * This is the bitwise OR of zero or more @c CONSOLE_USAGE_XXX
         * values.
@@ -84,6 +86,15 @@ struct console_driver {
        int usage;
 };
 
+/** Console is disabled for input */
+#define CONSOLE_DISABLED_INPUT 0x0001
+
+/** Console is disabled for output */
+#define CONSOLE_DISABLED_OUTPUT 0x0002
+
+/** Console is disabled for all uses */
+#define CONSOLE_DISABLED ( CONSOLE_DISABLED_INPUT | CONSOLE_DISABLED_OUTPUT )
+
 /** Console driver table */
 #define CONSOLES __table ( struct console_driver, "consoles" )
 
index a4dc29753bab68bb5586af4d4313bf1d403d5185..bcda8b45cca667793618643b882eef61bd1c29b0 100644 (file)
@@ -178,7 +178,7 @@ static void syslogs_putchar ( int character ) {
 /** Encrypted syslog console driver */
 struct console_driver syslogs_console __console_driver = {
        .putchar = syslogs_putchar,
-       .disabled = 1,
+       .disabled = CONSOLE_DISABLED,
        .usage = CONSOLE_SYSLOGS,
 };
 
@@ -227,7 +227,7 @@ static int apply_syslogs_settings ( void ) {
        old_server = NULL;
 
        /* Reset encrypted syslog connection */
-       syslogs_console.disabled = 1;
+       syslogs_console.disabled = CONSOLE_DISABLED;
        intf_restart ( &syslogs, 0 );
 
        /* Do nothing unless we have a log server */
index 4bfba51e57e6755c77c2d4977b3597e05ee708fc..4210083d224cb815a03753e0aad8585d48a4f30a 100644 (file)
@@ -176,7 +176,7 @@ static void syslog_putchar ( int character ) {
 /** Syslog console driver */
 struct console_driver syslog_console __console_driver = {
        .putchar = syslog_putchar,
-       .disabled = 1,
+       .disabled = CONSOLE_DISABLED,
        .usage = CONSOLE_SYSLOG,
 };
 
@@ -222,7 +222,7 @@ static int apply_syslog_settings ( void ) {
        }
 
        /* Fetch log server */
-       syslog_console.disabled = 1;
+       syslog_console.disabled = CONSOLE_DISABLED;
        old_addr.s_addr = sin_logserver->sin_addr.s_addr;
        if ( ( len = fetch_ipv4_setting ( NULL, &syslog_setting,
                                          &sin_logserver->sin_addr ) ) >= 0 ) {