ia64/xen-unstable

changeset 1071:3c5a1857d74a

bitkeeper revision 1.708 (4023646fZm2rfkmti9YyHcNFsoBG1Q)

properly initialize com2
author ach61@labyrinth.cl.cam.ac.uk
date Fri Feb 06 09:54:55 2004 +0000 (2004-02-06)
parents d261b3bfa00c
children cb4ec9996b12
files xen/drivers/char/xen_serial.c
line diff
     1.1 --- a/xen/drivers/char/xen_serial.c	Thu Feb 05 20:27:49 2004 +0000
     1.2 +++ b/xen/drivers/char/xen_serial.c	Fri Feb 06 09:54:55 2004 +0000
     1.3 @@ -53,10 +53,11 @@
     1.4  #define SERIAL_COM1 0x3f8
     1.5  #define SERIAL_COM2 0x2f8
     1.6  
     1.7 +void initialize_serial_port(int base);
     1.8 +
     1.9  int serial_com_base = SERIAL_COM1;
    1.10  int debug_com_base  = SERIAL_COM1;
    1.11  
    1.12 -
    1.13  static int serial_echo = 0;       /* default is not to echo; change with '~' */
    1.14  
    1.15  void toggle_echo(u_char key, void *dev_id, struct pt_regs *regs) 
    1.16 @@ -67,6 +68,7 @@ void toggle_echo(u_char key, void *dev_i
    1.17  void debug_set_com_port(int port)
    1.18  {
    1.19      debug_com_base = port == 1 ? SERIAL_COM1 : SERIAL_COM2;
    1.20 +    if (port == 2) initialize_serial_port(SERIAL_COM2);
    1.21  }
    1.22  
    1.23  int debug_testchar()                                /* character available? */
    1.24 @@ -153,8 +155,6 @@ static void serial_rx_int(int irq, void 
    1.25  
    1.26  void initialize_serial() 
    1.27  {
    1.28 -    int rc; 
    1.29 -
    1.30      if ( !SERIAL_ENABLED )
    1.31          return;
    1.32  
    1.33 @@ -162,19 +162,44 @@ void initialize_serial()
    1.34      
    1.35      /* setup key handler */
    1.36      add_key_handler('~', toggle_echo, "toggle serial echo");
    1.37 -    
    1.38 +
    1.39 +    initialize_serial_port(SERIAL_COM1);
    1.40 +}
    1.41 +
    1.42 +/* warning: no protection against duplicate initialization */
    1.43 +void initialize_serial_port(int base)
    1.44 +{    
    1.45 +    int rc; 
    1.46 +
    1.47      /* This assumes we have a 16550. It's pretty darned likely really! */
    1.48      /* Clear FIFOs, enable, trigger at 1 byte */
    1.49      outb(NS16550_FCR_TRG1 | NS16550_FCR_ENABLE |
    1.50           NS16550_FCR_CLRX  | NS16550_FCR_CLTX, 
    1.51 -         serial_com_base + NS16550_FCR);
    1.52 +         base + NS16550_FCR);
    1.53  
    1.54      /* Enable receive interrupts. Also remember to keep DTR/RTS asserted. */
    1.55      outb(NS16550_MCR_OUT2|NS16550_MCR_DTR|NS16550_MCR_RTS, 
    1.56 -         serial_com_base + NS16550_MCR);
    1.57 +         base + NS16550_MCR);
    1.58      outb(NS16550_IER_ERDAI, 
    1.59 -         serial_com_base + NS16550_IER );
    1.60 +         base + NS16550_IER );
    1.61  
    1.62 -    if( (rc = request_irq(4, serial_rx_int, SA_NOPROFILE, "serial", 0)) )
    1.63 -	printk("initialize_serial: failed to get IRQ4, rc=%d\n", rc); 
    1.64 +    switch(base)
    1.65 +    {
    1.66 +    case SERIAL_COM1 :
    1.67 +    {
    1.68 +        if( (rc = request_irq(4, serial_rx_int, SA_NOPROFILE, "serial 1", 0)) )
    1.69 +	  printk("initialize_serial: failed to get IRQ4, rc=%d\n", rc); 
    1.70 +	break;
    1.71 +    }
    1.72 +    case SERIAL_COM2 :
    1.73 +    {
    1.74 +        if( (rc = request_irq(3, serial_rx_int, SA_NOPROFILE, "serial 2", 0)) )
    1.75 +	  printk("initialize_serial: failed to get IRQ3, rc=%d\n", rc); 
    1.76 +	break;
    1.77 +    }
    1.78 +    default :
    1.79 +    {
    1.80 +	  printk("initialize_serial: unknown serial base: 0x%d\n", base); 
    1.81 +    }
    1.82 +    }
    1.83  }