ia64/xen-unstable

changeset 6019:33bb0b41aa73

On x86, Xen does not claim any serial port unless the user
explicitly specifies a 'com1=' or 'com2=' configuration
string. This prevents users from being surprised when Xen
stops domain0 from accessing serial port registers.

On ia64 we still allow serial ports to get automatically
configured and locked down even if no 'com1' is specified
on the command line. This maintains the default preferred
by the IA64 developers.

Also, the method for specifying 'use existing baud rate'
has changed. Instead of specifying com1=0, you must now
specify e.g., com1=auto

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Aug 03 14:44:19 2005 +0000 (2005-08-03)
parents d9442abaa980
children 60c4cd9ebaa1
files docs/src/user.tex xen/arch/ia64/xensetup.c xen/drivers/char/ns16550.c xen/include/xen/serial.h
line diff
     1.1 --- a/docs/src/user.tex	Wed Aug 03 12:51:35 2005 +0000
     1.2 +++ b/docs/src/user.tex	Wed Aug 03 14:44:19 2005 +0000
     1.3 @@ -1709,8 +1709,11 @@ editing \path{grub.conf}.
     1.4   For example: `com1=9600, 8n1, 0x408, 5' maps COM1 to a
     1.5   9600-baud port, 8 data bits, no parity, 1 stop bit,
     1.6   I/O port base 0x408, IRQ 5.
     1.7 - If the I/O base and IRQ are standard (com1:0x3f8,4;
     1.8 - com2:0x2f8,3) then they need not be specified. 
     1.9 + If some configuration options are standard (e.g., I/O base and IRQ),
    1.10 + then only a prefix of the full configuration string need be
    1.11 + specified. If the baud rate is pre-configured (e.g., by the
    1.12 + bootloader) then you can specify `auto' in place of a numeric baud
    1.13 + rate. 
    1.14  
    1.15  \item [console=$<$specifier list$>$ ] 
    1.16   Specify the destination for Xen console I/O.
     2.1 --- a/xen/arch/ia64/xensetup.c	Wed Aug 03 12:51:35 2005 +0000
     2.2 +++ b/xen/arch/ia64/xensetup.c	Wed Aug 03 14:44:19 2005 +0000
     2.3 @@ -131,12 +131,14 @@ void early_cmdline_parse(char **cmdline_
     2.4  }
     2.5  
     2.6  struct ns16550_defaults ns16550_com1 = {
     2.7 +    .baud      = BAUD_AUTO,
     2.8      .data_bits = 8,
     2.9      .parity    = 'n',
    2.10      .stop_bits = 1
    2.11  };
    2.12  
    2.13  struct ns16550_defaults ns16550_com2 = {
    2.14 +    .baud      = BAUD_AUTO,
    2.15      .data_bits = 8,
    2.16      .parity    = 'n',
    2.17      .stop_bits = 1
     3.1 --- a/xen/drivers/char/ns16550.c	Wed Aug 03 12:51:35 2005 +0000
     3.2 +++ b/xen/drivers/char/ns16550.c	Wed Aug 03 14:44:19 2005 +0000
     3.3 @@ -15,7 +15,12 @@
     3.4  #include <xen/serial.h>
     3.5  #include <asm/io.h>
     3.6  
     3.7 -/* Config serial port with a string <baud>,DPS,<io-base>,<irq>. */
     3.8 +/*
     3.9 + * Configure serial port with a string <baud>,DPS,<io-base>,<irq>.
    3.10 + * The tail of the string can be omitted if platform defaults are sufficient.
    3.11 + * If the baud rate is pre-configured, perhaps by a bootloader, then 'auto'
    3.12 + * can be specified in place of a numeric baud rate.
    3.13 + */
    3.14  static char opt_com1[30] = "", opt_com2[30] = "";
    3.15  string_param("com1", opt_com1);
    3.16  string_param("com2", opt_com2);
    3.17 @@ -154,7 +159,7 @@ static void ns16550_init_preirq(struct s
    3.18      ns_write_reg(uart, IER, 0);
    3.19  
    3.20      /* Line control and baud-rate generator. */
    3.21 -    if ( uart->baud != 0 )
    3.22 +    if ( uart->baud != BAUD_AUTO )
    3.23      {
    3.24          ns_write_reg(uart, LCR, lcr | LCR_DLAB);
    3.25          ns_write_reg(uart, DLL, 115200/uart->baud); /* baud lo */
    3.26 @@ -244,38 +249,50 @@ static void ns16550_parse_port_config(st
    3.27  {
    3.28      int baud;
    3.29  
    3.30 +    /* No user-specified configuration? */
    3.31      if ( (conf == NULL) || (*conf == '\0') )
    3.32 -        goto config_parsed;
    3.33 +    {
    3.34 +        /* Some platforms may automatically probe the UART configuartion. */
    3.35 +        if ( uart->baud != 0 )
    3.36 +            goto config_parsed;
    3.37 +        return;
    3.38 +    }
    3.39  
    3.40 -    if ( (baud = simple_strtol(conf, &conf, 10)) != 0 )
    3.41 +    if ( strncmp(conf, "auto", 4) == 0 )
    3.42 +    {
    3.43 +        uart->baud = BAUD_AUTO;
    3.44 +        conf += 4;
    3.45 +    }
    3.46 +    else if ( (baud = simple_strtoul(conf, &conf, 10)) != 0 )
    3.47          uart->baud = baud;
    3.48  
    3.49      if ( *conf != ',' )
    3.50          goto config_parsed;
    3.51      conf++;
    3.52  
    3.53 -    uart->data_bits = simple_strtol(conf, &conf, 10);
    3.54 +    uart->data_bits = simple_strtoul(conf, &conf, 10);
    3.55  
    3.56      uart->parity = parse_parity_char(*conf);
    3.57      conf++;
    3.58  
    3.59 -    uart->stop_bits = simple_strtol(conf, &conf, 10);
    3.60 +    uart->stop_bits = simple_strtoul(conf, &conf, 10);
    3.61  
    3.62      if ( *conf == ',' )
    3.63      {
    3.64          conf++;
    3.65 -        uart->io_base = simple_strtol(conf, &conf, 0);
    3.66 +        uart->io_base = simple_strtoul(conf, &conf, 0);
    3.67  
    3.68          if ( *conf == ',' )
    3.69          {
    3.70              conf++;
    3.71 -            uart->irq = simple_strtol(conf, &conf, 10);
    3.72 +            uart->irq = simple_strtoul(conf, &conf, 10);
    3.73          }
    3.74      }
    3.75  
    3.76   config_parsed:
    3.77      /* Sanity checks. */
    3.78 -    if ( (uart->baud != 0) && ((uart->baud < 1200) || (uart->baud > 115200)) )
    3.79 +    if ( (uart->baud != BAUD_AUTO) &&
    3.80 +         ((uart->baud < 1200) || (uart->baud > 115200)) )
    3.81          PARSE_ERR("Baud rate %d outside supported range.", uart->baud);
    3.82      if ( (uart->data_bits < 5) || (uart->data_bits > 8) )
    3.83          PARSE_ERR("%d data bits are unsupported.", uart->data_bits);
     4.1 --- a/xen/include/xen/serial.h	Wed Aug 03 12:51:35 2005 +0000
     4.2 +++ b/xen/include/xen/serial.h	Wed Aug 03 14:44:19 2005 +0000
     4.3 @@ -113,8 +113,9 @@ void serial_tx_interrupt(struct serial_p
     4.4  /*
     4.5   * Initialisers for individual uart drivers.
     4.6   */
     4.7 +/* NB. Any default value can be 0 if it is unknown and must be specified. */
     4.8  struct ns16550_defaults {
     4.9 -    int baud;      /* default baud rate; 0 == pre-configured */
    4.10 +    int baud;      /* default baud rate; BAUD_AUTO == pre-configured */
    4.11      int data_bits; /* default data bits (5, 6, 7 or 8) */
    4.12      int parity;    /* default parity (n, o, e, m or s) */
    4.13      int stop_bits; /* default stop bits (1 or 2) */
    4.14 @@ -123,6 +124,9 @@ struct ns16550_defaults {
    4.15  };
    4.16  void ns16550_init(int index, struct ns16550_defaults *defaults);
    4.17  
    4.18 +/* Baud rate was pre-configured before invoking the UART driver. */
    4.19 +#define BAUD_AUTO (-1)
    4.20 +
    4.21  #endif /* __XEN_SERIAL_H__ */
    4.22  
    4.23  /*