[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] On x86, Xen does not claim any serial port unless the user



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 33bb0b41aa73cf27fb2314f5f47caf5ab345415a
# Parent  d9442abaa9809f251e402286a87a8eef8135e4fe
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@xxxxxxxxxxxxx>

diff -r d9442abaa980 -r 33bb0b41aa73 docs/src/user.tex
--- a/docs/src/user.tex Wed Aug  3 12:51:35 2005
+++ b/docs/src/user.tex Wed Aug  3 14:44:19 2005
@@ -1709,8 +1709,11 @@
  For example: `com1=9600, 8n1, 0x408, 5' maps COM1 to a
  9600-baud port, 8 data bits, no parity, 1 stop bit,
  I/O port base 0x408, IRQ 5.
- If the I/O base and IRQ are standard (com1:0x3f8,4;
- com2:0x2f8,3) then they need not be specified. 
+ If some configuration options are standard (e.g., I/O base and IRQ),
+ then only a prefix of the full configuration string need be
+ specified. If the baud rate is pre-configured (e.g., by the
+ bootloader) then you can specify `auto' in place of a numeric baud
+ rate. 
 
 \item [console=$<$specifier list$>$ ] 
  Specify the destination for Xen console I/O.
diff -r d9442abaa980 -r 33bb0b41aa73 xen/arch/ia64/xensetup.c
--- a/xen/arch/ia64/xensetup.c  Wed Aug  3 12:51:35 2005
+++ b/xen/arch/ia64/xensetup.c  Wed Aug  3 14:44:19 2005
@@ -131,12 +131,14 @@
 }
 
 struct ns16550_defaults ns16550_com1 = {
+    .baud      = BAUD_AUTO,
     .data_bits = 8,
     .parity    = 'n',
     .stop_bits = 1
 };
 
 struct ns16550_defaults ns16550_com2 = {
+    .baud      = BAUD_AUTO,
     .data_bits = 8,
     .parity    = 'n',
     .stop_bits = 1
diff -r d9442abaa980 -r 33bb0b41aa73 xen/drivers/char/ns16550.c
--- a/xen/drivers/char/ns16550.c        Wed Aug  3 12:51:35 2005
+++ b/xen/drivers/char/ns16550.c        Wed Aug  3 14:44:19 2005
@@ -15,7 +15,12 @@
 #include <xen/serial.h>
 #include <asm/io.h>
 
-/* Config serial port with a string <baud>,DPS,<io-base>,<irq>. */
+/*
+ * Configure serial port with a string <baud>,DPS,<io-base>,<irq>.
+ * The tail of the string can be omitted if platform defaults are sufficient.
+ * If the baud rate is pre-configured, perhaps by a bootloader, then 'auto'
+ * can be specified in place of a numeric baud rate.
+ */
 static char opt_com1[30] = "", opt_com2[30] = "";
 string_param("com1", opt_com1);
 string_param("com2", opt_com2);
@@ -154,7 +159,7 @@
     ns_write_reg(uart, IER, 0);
 
     /* Line control and baud-rate generator. */
-    if ( uart->baud != 0 )
+    if ( uart->baud != BAUD_AUTO )
     {
         ns_write_reg(uart, LCR, lcr | LCR_DLAB);
         ns_write_reg(uart, DLL, 115200/uart->baud); /* baud lo */
@@ -244,38 +249,50 @@
 {
     int baud;
 
+    /* No user-specified configuration? */
     if ( (conf == NULL) || (*conf == '\0') )
-        goto config_parsed;
-
-    if ( (baud = simple_strtol(conf, &conf, 10)) != 0 )
+    {
+        /* Some platforms may automatically probe the UART configuartion. */
+        if ( uart->baud != 0 )
+            goto config_parsed;
+        return;
+    }
+
+    if ( strncmp(conf, "auto", 4) == 0 )
+    {
+        uart->baud = BAUD_AUTO;
+        conf += 4;
+    }
+    else if ( (baud = simple_strtoul(conf, &conf, 10)) != 0 )
         uart->baud = baud;
 
     if ( *conf != ',' )
         goto config_parsed;
     conf++;
 
-    uart->data_bits = simple_strtol(conf, &conf, 10);
+    uart->data_bits = simple_strtoul(conf, &conf, 10);
 
     uart->parity = parse_parity_char(*conf);
     conf++;
 
-    uart->stop_bits = simple_strtol(conf, &conf, 10);
+    uart->stop_bits = simple_strtoul(conf, &conf, 10);
 
     if ( *conf == ',' )
     {
         conf++;
-        uart->io_base = simple_strtol(conf, &conf, 0);
+        uart->io_base = simple_strtoul(conf, &conf, 0);
 
         if ( *conf == ',' )
         {
             conf++;
-            uart->irq = simple_strtol(conf, &conf, 10);
+            uart->irq = simple_strtoul(conf, &conf, 10);
         }
     }
 
  config_parsed:
     /* Sanity checks. */
-    if ( (uart->baud != 0) && ((uart->baud < 1200) || (uart->baud > 115200)) )
+    if ( (uart->baud != BAUD_AUTO) &&
+         ((uart->baud < 1200) || (uart->baud > 115200)) )
         PARSE_ERR("Baud rate %d outside supported range.", uart->baud);
     if ( (uart->data_bits < 5) || (uart->data_bits > 8) )
         PARSE_ERR("%d data bits are unsupported.", uart->data_bits);
diff -r d9442abaa980 -r 33bb0b41aa73 xen/include/xen/serial.h
--- a/xen/include/xen/serial.h  Wed Aug  3 12:51:35 2005
+++ b/xen/include/xen/serial.h  Wed Aug  3 14:44:19 2005
@@ -113,8 +113,9 @@
 /*
  * Initialisers for individual uart drivers.
  */
+/* NB. Any default value can be 0 if it is unknown and must be specified. */
 struct ns16550_defaults {
-    int baud;      /* default baud rate; 0 == pre-configured */
+    int baud;      /* default baud rate; BAUD_AUTO == pre-configured */
     int data_bits; /* default data bits (5, 6, 7 or 8) */
     int parity;    /* default parity (n, o, e, m or s) */
     int stop_bits; /* default stop bits (1 or 2) */
@@ -122,6 +123,9 @@
     unsigned long io_base; /* default io_base address */
 };
 void ns16550_init(int index, struct ns16550_defaults *defaults);
+
+/* Baud rate was pre-configured before invoking the UART driver. */
+#define BAUD_AUTO (-1)
 
 #endif /* __XEN_SERIAL_H__ */
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.