ia64/xen-unstable

changeset 1175:fb4fdb5334db

bitkeeper revision 1.791 (4051e177NL-NMtt0z6bgf0S1imnoVg)

console.c:
Robustify console-input switching.
author kaf24@scramble.cl.cam.ac.uk
date Fri Mar 12 16:12:39 2004 +0000 (2004-03-12)
parents 576575968828
children c5f25855d2cb
files xen/drivers/char/console.c
line diff
     1.1 --- a/xen/drivers/char/console.c	Fri Mar 12 16:03:47 2004 +0000
     1.2 +++ b/xen/drivers/char/console.c	Fri Mar 12 16:12:39 2004 +0000
     1.3 @@ -229,24 +229,31 @@ static unsigned int serial_rx_cons, seri
     1.4  
     1.5  /* CTRL-a switches input direction between Xen and DOM0. */
     1.6  #define CTRL_A 0x01
     1.7 +static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */
     1.8 +
     1.9 +static void switch_serial_input(void)
    1.10 +{
    1.11 +    static char *input_str[2] = { "DOM0", "Xen" };
    1.12 +    xen_rx = !xen_rx;
    1.13 +    printk("\n*** Serial input -> %s "
    1.14 +           "(type 'CTRL-a' three times to switch input to %s).\n",
    1.15 +           input_str[xen_rx], input_str[!xen_rx]);
    1.16 +}
    1.17  
    1.18  static void serial_rx(unsigned char c, struct pt_regs *regs)
    1.19  {
    1.20      key_handler *handler;
    1.21      unsigned long cpu_mask;
    1.22      struct task_struct *p;
    1.23 -    static char *input_str[2] = { "DOM0", "Xen" };
    1.24 -    static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */
    1.25 +    static int ctrl_a_count = 0;
    1.26  
    1.27 -    if ( c == CTRL_A )
    1.28 +    if ( (ctrl_a_count = (c == CTRL_A) ? ctrl_a_count+1 : 0) >= 3 )
    1.29      {
    1.30 -        xen_rx = !xen_rx;
    1.31 -        serial_putc(sercon_handle, '\n');
    1.32 -        printk("*** Serial input -> %s "
    1.33 -               "(type 'CTRL-a' to switch input to %s).\n",
    1.34 -               input_str[xen_rx], input_str[!xen_rx]);
    1.35 +        switch_serial_input();
    1.36 +        ctrl_a_count = 0;
    1.37      }
    1.38 -    else if ( xen_rx )
    1.39 +
    1.40 +    if ( xen_rx )
    1.41      {
    1.42          if ( (handler = get_key_handler(c)) != NULL )
    1.43              (*handler)(c, NULL, regs);
    1.44 @@ -460,7 +467,7 @@ void console_endboot(int disable_vga)
    1.45      if ( disable_vga )
    1.46          vgacon_enabled = 0;
    1.47      /* Serial input is directed to DOM0 by default. */
    1.48 -    serial_rx(CTRL_A, NULL);
    1.49 +    switch_serial_input();
    1.50  }
    1.51  
    1.52