ia64/xen-unstable

changeset 1769:a37ede4b5d41

bitkeeper revision 1.1071.1.3 (40f3f494hMH1GKUQuCB0vUKhJyfyoA)

Add a conswitch command-line option to Xen.
author kaf24@scramble.cl.cam.ac.uk
date Tue Jul 13 14:41:24 2004 +0000 (2004-07-13)
parents c4061a2a3309
children c82c495264af
files README.CD docs/HOWTOs/Xen-HOWTO xen/common/kernel.c xen/drivers/char/console.c
line diff
     1.1 --- a/README.CD	Tue Jul 13 14:16:56 2004 +0000
     1.2 +++ b/README.CD	Tue Jul 13 14:41:24 2004 +0000
     1.3 @@ -307,6 +307,16 @@ that may be able to help diagnose proble
     1.4                    transmitted/received character.
     1.5   [NB. Default for this option is 'com1,tty']
     1.6  
     1.7 + conswitch=<switch-char><auto-switch-char>
     1.8 +                  Specify how to switch serial-console input between
     1.9 +                  Xen and DOM0. The required sequence is CTRL-<switch_char>
    1.10 +                  pressed three times. Specifying '`' disables switching.
    1.11 +                  The <auto-switch-char> specifies whether Xen should
    1.12 +                  auto-switch input to DOM0 when it boots -- if it is 'x'
    1.13 +                  then auto-switching is disabled. Any other value, or
    1.14 +                  omitting the character, enables auto-switching.
    1.15 + [NB. Default for this option is 'a']
    1.16 +
    1.17   dom0_mem=xxx 	  Set the initial amount of memory for domain0.
    1.18  
    1.19   pdb=xxx          Enable the pervasive debugger.  See docs/pdb.txt
     2.1 --- a/docs/HOWTOs/Xen-HOWTO	Tue Jul 13 14:16:56 2004 +0000
     2.2 +++ b/docs/HOWTOs/Xen-HOWTO	Tue Jul 13 14:41:24 2004 +0000
     2.3 @@ -253,6 +253,16 @@ The following is a list of command line 
     2.4                    transmitted/received character.
     2.5   [NB. Default for this option is 'com1,tty']
     2.6  
     2.7 + conswitch=<switch-char><auto-switch-char>
     2.8 +                  Specify how to switch serial-console input between
     2.9 +                  Xen and DOM0. The required sequence is CTRL-<switch_char>
    2.10 +                  pressed three times. Specifying '`' disables switching.
    2.11 +                  The <auto-switch-char> specifies whether Xen should
    2.12 +                  auto-switch input to DOM0 when it boots -- if it is 'x'
    2.13 +                  then auto-switching is disabled. Any other value, or
    2.14 +                  omitting the character, enables auto-switching.
    2.15 + [NB. Default for this option is 'a']
    2.16 +
    2.17   dom0_mem=xxx     Set the maximum amount of memory for domain0.
    2.18  
    2.19   tbuf_size=xxx    Set the size of the per-cpu trace buffers, in pages
     3.1 --- a/xen/common/kernel.c	Tue Jul 13 14:16:56 2004 +0000
     3.2 +++ b/xen/common/kernel.c	Tue Jul 13 14:41:24 2004 +0000
     3.3 @@ -40,6 +40,11 @@ void start_of_day(void);
     3.4  
     3.5  /* opt_console: comma-separated list of console outputs. */
     3.6  unsigned char opt_console[30] = "com1,vga";
     3.7 +/* opt_conswitch: a character pair controlling console switching. */
     3.8 +/* Char 1: CTRL+<char1> is used to switch console input between Xen and DOM0 */
     3.9 +/* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
    3.10 +/*         boots. Any other value, or omitting the char, enables auto-switch */
    3.11 +unsigned char opt_conswitch[5] = "a"; /* NB. '`' would disable switching. */
    3.12  /* opt_com[12]: Config serial port with a string <baud>,DPS,<io-base>,<irq>. */
    3.13  unsigned char opt_com1[30] = "", opt_com2[30] = "";
    3.14  /* opt_dom0_mem: Kilobytes of memory allocated to domain 0. */
    3.15 @@ -82,6 +87,7 @@ static struct {
    3.16      void *var;
    3.17  } opts[] = {
    3.18      { "console",           OPT_STR,  &opt_console },
    3.19 +    { "conswitch",         OPT_STR,  &opt_conswitch },
    3.20      { "com1",              OPT_STR,  &opt_com1 },
    3.21      { "com2",              OPT_STR,  &opt_com2 },
    3.22      { "dom0_mem",          OPT_UINT, &opt_dom0_mem }, 
     4.1 --- a/xen/drivers/char/console.c	Tue Jul 13 14:16:56 2004 +0000
     4.2 +++ b/xen/drivers/char/console.c	Tue Jul 13 14:41:24 2004 +0000
     4.3 @@ -17,6 +17,8 @@
     4.4  #include <xen/keyhandler.h>
     4.5  #include <asm/uaccess.h>
     4.6  
     4.7 +extern unsigned char opt_console[], opt_conswitch[];
     4.8 +
     4.9  static int xpos, ypos;
    4.10  static unsigned char *video = __va(0xB8000);
    4.11  
    4.12 @@ -227,17 +229,18 @@ long read_console_ring(unsigned long str
    4.13  static char serial_rx_ring[SERIAL_RX_SIZE];
    4.14  static unsigned int serial_rx_cons, serial_rx_prod;
    4.15  
    4.16 -/* CTRL-a switches input direction between Xen and DOM0. */
    4.17 -#define CTRL_A 0x01
    4.18 +/* CTRL-<switch_char> switches input direction between Xen and DOM0. */
    4.19 +#define SWITCH_CODE (opt_conswitch[0]-'a'+1)
    4.20  static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */
    4.21  
    4.22  static void switch_serial_input(void)
    4.23  {
    4.24      static char *input_str[2] = { "DOM0", "Xen" };
    4.25      xen_rx = !xen_rx;
    4.26 -    printk("*** Serial input -> %s "
    4.27 -           "(type 'CTRL-a' three times to switch input to %s).\n",
    4.28 -           input_str[xen_rx], input_str[!xen_rx]);
    4.29 +    if ( SWITCH_CODE != 0 )
    4.30 +        printk("*** Serial input -> %s "
    4.31 +               "(type 'CTRL-%c' three times to switch input to %s).\n",
    4.32 +               input_str[xen_rx], opt_conswitch[0], input_str[!xen_rx]);
    4.33  }
    4.34  
    4.35  static void __serial_rx(unsigned char c, struct pt_regs *regs)
    4.36 @@ -264,20 +267,20 @@ static void __serial_rx(unsigned char c,
    4.37  
    4.38  static void serial_rx(unsigned char c, struct pt_regs *regs)
    4.39  {
    4.40 -    static int ctrl_a_count = 0;
    4.41 +    static int switch_code_count = 0;
    4.42  
    4.43 -    if ( c == CTRL_A )
    4.44 +    if ( (SWITCH_CODE != 0) && (c == SWITCH_CODE) )
    4.45      {
    4.46 -        /* We eat CTRL-a in groups of three to switch console input. */
    4.47 -        if ( ++ctrl_a_count == 3 )
    4.48 +        /* We eat CTRL-<switch_char> in groups of 3 to switch console input. */
    4.49 +        if ( ++switch_code_count == 3 )
    4.50          {
    4.51              switch_serial_input();
    4.52 -            ctrl_a_count = 0;
    4.53 +            switch_code_count = 0;
    4.54          }
    4.55      }
    4.56      else
    4.57      {
    4.58 -        ctrl_a_count = 0;
    4.59 +        switch_code_count = 0;
    4.60      }
    4.61  
    4.62      /* Finally process the just-received character. */
    4.63 @@ -395,7 +398,6 @@ void set_printk_prefix(const char *prefi
    4.64  
    4.65  void init_console(void)
    4.66  {
    4.67 -    extern unsigned char opt_console[];
    4.68      unsigned char *p;
    4.69  
    4.70      /* Where should console output go? */
    4.71 @@ -418,6 +420,15 @@ void console_endboot(int disable_vga)
    4.72  {
    4.73      if ( disable_vga )
    4.74          vgacon_enabled = 0;
    4.75 +
    4.76 +    /*
    4.77 +     * If user specifies so, we fool the switch routine to redirect input
    4.78 +     * straight back to Xen. I use this convoluted method so we still print
    4.79 +     * a useful 'how to switch' message.
    4.80 +     */
    4.81 +    if ( opt_conswitch[1] == 'x' )
    4.82 +        xen_rx = !xen_rx;
    4.83 +
    4.84      /* Serial input is directed to DOM0 by default. */
    4.85      switch_serial_input();
    4.86  }