ia64/xen-unstable

changeset 1176:c5f25855d2cb

bitkeeper revision 1.792 (4051e6b8E8mkfvd_6g9fklSAWSPykA)

console.c:
More robustification.
author kaf24@scramble.cl.cam.ac.uk
date Fri Mar 12 16:35:04 2004 +0000 (2004-03-12)
parents fb4fdb5334db
children 5a9452d43df2 749d2ae3c3bd
files xen/drivers/char/console.c
line diff
     1.1 --- a/xen/drivers/char/console.c	Fri Mar 12 16:12:39 2004 +0000
     1.2 +++ b/xen/drivers/char/console.c	Fri Mar 12 16:35:04 2004 +0000
     1.3 @@ -235,23 +235,16 @@ static void switch_serial_input(void)
     1.4  {
     1.5      static char *input_str[2] = { "DOM0", "Xen" };
     1.6      xen_rx = !xen_rx;
     1.7 -    printk("\n*** Serial input -> %s "
     1.8 +    printk("*** Serial input -> %s "
     1.9             "(type 'CTRL-a' three times to switch input to %s).\n",
    1.10             input_str[xen_rx], input_str[!xen_rx]);
    1.11  }
    1.12  
    1.13 -static void serial_rx(unsigned char c, struct pt_regs *regs)
    1.14 +static void __serial_rx(unsigned char c, struct pt_regs *regs)
    1.15  {
    1.16      key_handler *handler;
    1.17      unsigned long cpu_mask;
    1.18      struct task_struct *p;
    1.19 -    static int ctrl_a_count = 0;
    1.20 -
    1.21 -    if ( (ctrl_a_count = (c == CTRL_A) ? ctrl_a_count+1 : 0) >= 3 )
    1.22 -    {
    1.23 -        switch_serial_input();
    1.24 -        ctrl_a_count = 0;
    1.25 -    }
    1.26  
    1.27      if ( xen_rx )
    1.28      {
    1.29 @@ -271,6 +264,29 @@ static void serial_rx(unsigned char c, s
    1.30      }
    1.31  }
    1.32  
    1.33 +static void serial_rx(unsigned char c, struct pt_regs *regs)
    1.34 +{
    1.35 +    static int ctrl_a_count = 0;
    1.36 +
    1.37 +    if ( c == CTRL_A )
    1.38 +    {
    1.39 +        /* We eat CTRL-a in groups of three to switch console input. */
    1.40 +        if ( ++ctrl_a_count == 3 )
    1.41 +        {
    1.42 +            switch_serial_input();
    1.43 +            ctrl_a_count = 0;
    1.44 +        }
    1.45 +    }
    1.46 +    else
    1.47 +    {
    1.48 +        /* Flush any pending CTRL-a's. They weren't for us. */
    1.49 +        for ( ; ctrl_a_count != 0; ctrl_a_count-- )
    1.50 +            __serial_rx(CTRL_A, regs);
    1.51 +        /* Finally process the just-received character. */
    1.52 +        __serial_rx(c, regs);
    1.53 +    }
    1.54 +}
    1.55 +
    1.56  long do_console_io(int cmd, int count, char *buffer)
    1.57  {
    1.58      char *kbuf;