diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
-index 1f88907..bb8d97b 100644
+index 1f88907..f887570 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -15,6 +15,8 @@
#include <asm/io.h>
/*
-@@ -336,6 +338,52 @@ static int check_existence(struct ns16550 *uart)
+@@ -336,6 +338,53 @@ static int check_existence(struct ns16550 *uart)
return (status == 0x90);
}
-+static void
++static int
+magic_uart_config (struct ns16550 *uart)
+{
+ uint16_t class;
+ {
+ for (d = 0; d < 0x20; ++d)
+ {
-+ for (f = 0; f < 0x20; ++f)
++ for (f = 0; f < 0x8; ++f)
+ {
+
+ class = pci_conf_read16 (b, d, f, PCI_CLASS_DEVICE);
+
+ bar0 = pci_conf_read32 (b, d, f, PCI_BASE_ADDRESS_0);
+
-+/*Not IO*/
++ /* Not IO */
+ if (!(bar0 & 1))
+ continue;
+
+ len = pci_conf_read32 (b, d, f, PCI_BASE_ADDRESS_0);
+ pci_conf_write32 (b, d, f, PCI_BASE_ADDRESS_0, bar0);
+
-+/*Not 8 bytes*/
++ /* Not 8 bytes */
+ if (len != 0xfffffff9)
+ continue;
+
+ uart->io_base = bar0 & 0xfffe;
+ uart->irq = 0;
+
-+ return;
++ return 0;
+
+ }
+
+ }
+ }
++ return -1;
+}
+
+
#define PARSE_ERR(_f, _a...) \
do { \
printk( "ERROR: " _f "\n" , ## _a ); \
-@@ -355,7 +403,6 @@ static void __init ns16550_parse_port_config(
- goto config_parsed;
- return;
- }
--
- if ( strncmp(conf, "auto", 4) == 0 )
- {
- uart->baud = BAUD_AUTO;
-@@ -384,7 +431,13 @@ static void __init ns16550_parse_port_config(
+@@ -384,7 +432,14 @@ static void __init ns16550_parse_port_config(
if ( *conf == ',' )
{
conf++;
- uart->io_base = simple_strtoul(conf, &conf, 0);
+
+ if ( strncmp(conf,"magic",5) == 0 ) {
-+ magic_uart_config(uart);
++ if (magic_uart_config(uart))
++ return;
+ conf+=5;
+ } else {
+ uart->io_base = simple_strtoul(conf, &conf, 0);