ia64/xen-unstable

changeset 16320:d945240821e7

Small cleanups to console-input-redirect code in Xen.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Mon Nov 05 16:37:48 2007 +0000 (2007-11-05)
parents dfe9c0c10a2c
children bfb1cb958632
files xen/drivers/char/console.c
line diff
     1.1 --- a/xen/drivers/char/console.c	Mon Nov 05 13:23:55 2007 +0000
     1.2 +++ b/xen/drivers/char/console.c	Mon Nov 05 16:37:48 2007 +0000
     1.3 @@ -43,7 +43,7 @@ string_param("console", opt_console);
     1.4  /* Char 1: CTRL+<char1> is used to switch console input between Xen and DOM0 */
     1.5  /* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
     1.6  /*         boots. Any other value, or omitting the char, enables auto-switch */
     1.7 -static unsigned char opt_conswitch[5] = "a";
     1.8 +static unsigned char opt_conswitch[3] = "a";
     1.9  string_param("conswitch", opt_conswitch);
    1.10  
    1.11  /* sync_console: force synchronous console output (useful for debugging). */
    1.12 @@ -267,19 +267,18 @@ static void sercon_puts(const char *s)
    1.13  }
    1.14  
    1.15  /* CTRL-<switch_char> switches input direction between Xen and DOM0. */
    1.16 -#define SWITCH_CODE (opt_conswitch[0]-'a'+1)
    1.17 +#define switch_code (opt_conswitch[0]-'a'+1)
    1.18  static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */
    1.19  
    1.20  static void switch_serial_input(void)
    1.21  {
    1.22      static char *input_str[2] = { "DOM0", "Xen" };
    1.23      xen_rx = !xen_rx;
    1.24 -    if ( (SWITCH_CODE != 0) && (dom0 != NULL) )
    1.25 -    {
    1.26 -        printk("*** Serial input -> %s "
    1.27 -               "(type 'CTRL-%c' three times to switch input to %s).\n",
    1.28 -               input_str[xen_rx], opt_conswitch[0], input_str[!xen_rx]);
    1.29 -    }
    1.30 +    printk("*** Serial input -> %s", input_str[xen_rx]);
    1.31 +    if ( switch_code )
    1.32 +        printk(" (type 'CTRL-%c' three times to switch input to %s)",
    1.33 +               opt_conswitch[0], input_str[!xen_rx]);
    1.34 +    printk("\n");
    1.35  }
    1.36  
    1.37  static void __serial_rx(char c, struct cpu_user_regs *regs)
    1.38 @@ -298,20 +297,19 @@ static void serial_rx(char c, struct cpu
    1.39  {
    1.40      static int switch_code_count = 0;
    1.41  
    1.42 -    if ( (SWITCH_CODE != 0) && (c == SWITCH_CODE) )
    1.43 +    if ( switch_code && (c == switch_code) )
    1.44      {
    1.45          /* We eat CTRL-<switch_char> in groups of 3 to switch console input. */
    1.46          if ( ++switch_code_count == 3 )
    1.47          {
    1.48              switch_serial_input();
    1.49              switch_code_count = 0;
    1.50 -            return;
    1.51          }
    1.52 +        return;
    1.53      }
    1.54 -    else
    1.55 -    {
    1.56 -        switch_code_count = 0;
    1.57 -    }
    1.58 +
    1.59 +    for ( ; switch_code_count != 0; switch_code_count-- )
    1.60 +        __serial_rx(switch_code, regs);
    1.61  
    1.62      /* Finally process the just-received character. */
    1.63      __serial_rx(c, regs);