ia64/xen-unstable

changeset 12650:8832712b0b37

[LINUX] console: Add option to use /dev/xvc0, major=204, minor=191.

The major/minor has now been allocated to us by lanana.org.

This is based on previous patches from:
Jeremy Katz <katzj@redhat.com>
Amos Waterland <apw@us.ibm.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Nov 29 11:37:59 2006 +0000 (2006-11-29)
parents 15e80a946a6a
children 9164f836943d
files linux-2.6-xen-sparse/drivers/xen/console/console.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Nov 29 11:07:51 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Nov 29 11:37:59 2006 +0000
     1.3 @@ -64,14 +64,21 @@
     1.4   *  'xencons=off'  [XC_OFF]:     Console is disabled.
     1.5   *  'xencons=tty'  [XC_TTY]:     Console attached to '/dev/tty[0-9]+'.
     1.6   *  'xencons=ttyS' [XC_SERIAL]:  Console attached to '/dev/ttyS[0-9]+'.
     1.7 + *  'xencons=xvc'  [XC_SERIAL]:  Console attached to '/dev/xvc0'.
     1.8   *                 [XC_DEFAULT]: DOM0 -> XC_SERIAL ; all others -> XC_TTY.
     1.9   * 
    1.10   * NB. In mode XC_TTY, we create dummy consoles for tty2-63. This suppresses
    1.11   * warnings from standard distro startup scripts.
    1.12   */
    1.13 -static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
    1.14 +static enum {
    1.15 +	XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL, XC_XVC
    1.16 +} xc_mode = XC_DEFAULT;
    1.17  static int xc_num = -1;
    1.18  
    1.19 +/* /dev/xvc0 device number allocated by lanana.org. */
    1.20 +#define XEN_XVC_MAJOR 204
    1.21 +#define XEN_XVC_MINOR 191
    1.22 +
    1.23  #ifdef CONFIG_MAGIC_SYSRQ
    1.24  static unsigned long sysrq_requested;
    1.25  extern int sysrq_enabled;
    1.26 @@ -82,27 +89,23 @@ static int __init xencons_setup(char *st
    1.27  	char *q;
    1.28  	int n;
    1.29  
    1.30 -	if (!strncmp(str, "ttyS", 4))
    1.31 +	if (!strncmp(str, "ttyS", 4)) {
    1.32  		xc_mode = XC_SERIAL;
    1.33 -	else if (!strncmp(str, "tty", 3))
    1.34 +		str += 4;
    1.35 +	} else if (!strncmp(str, "tty", 3)) {
    1.36  		xc_mode = XC_TTY;
    1.37 -	else if (!strncmp(str, "off", 3))
    1.38 +		str += 3;
    1.39 +	} else if (!strncmp(str, "xvc", 3)) {
    1.40 +		xc_mode = XC_XVC;
    1.41 +		str += 3;
    1.42 +	} else if (!strncmp(str, "off", 3)) {
    1.43  		xc_mode = XC_OFF;
    1.44 +		str += 3;
    1.45 +	}
    1.46  
    1.47 -	switch (xc_mode) {
    1.48 -	case XC_SERIAL:
    1.49 -		n = simple_strtol(str+4, &q, 10);
    1.50 -		if (q > (str + 4))
    1.51 -			xc_num = n;
    1.52 -		break;
    1.53 -	case XC_TTY:
    1.54 -		n = simple_strtol(str+3, &q, 10);
    1.55 -		if (q > (str + 3))
    1.56 -			xc_num = n;
    1.57 -		break;
    1.58 -	default:
    1.59 -		break;
    1.60 -	}
    1.61 +	n = simple_strtol(str, &q, 10);
    1.62 +	if (q != str)
    1.63 +		xc_num = n;
    1.64  
    1.65  	return 1;
    1.66  }
    1.67 @@ -201,6 +204,12 @@ static int __init xen_console_init(void)
    1.68  	}
    1.69  
    1.70  	switch (xc_mode) {
    1.71 +	case XC_XVC:
    1.72 +		strcpy(kcons_info.name, "xvc");
    1.73 +		if (xc_num == -1)
    1.74 +			xc_num = 0;
    1.75 +		break;
    1.76 +
    1.77  	case XC_SERIAL:
    1.78  		strcpy(kcons_info.name, "ttyS");
    1.79  		if (xc_num == -1)
    1.80 @@ -305,7 +314,7 @@ void dom0_init_screen_info(const struct 
    1.81  /******************** User-space console driver (/dev/console) ************/
    1.82  
    1.83  #define DRV(_d)         (_d)
    1.84 -#define DUMMY_TTY(_tty) ((xc_mode != XC_SERIAL) &&		\
    1.85 +#define DUMMY_TTY(_tty) ((xc_mode == XC_TTY) &&		\
    1.86  			 ((_tty)->index != (xc_num - 1)))
    1.87  
    1.88  static struct termios *xencons_termios[MAX_NR_CONSOLES];
    1.89 @@ -628,8 +637,8 @@ static int __init xencons_init(void)
    1.90  			return rc;
    1.91  	}
    1.92  
    1.93 -	xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ?
    1.94 -					  1 : MAX_NR_CONSOLES);
    1.95 +	xencons_driver = alloc_tty_driver((xc_mode == XC_TTY) ?
    1.96 +					  MAX_NR_CONSOLES : 1);
    1.97  	if (xencons_driver == NULL)
    1.98  		return -ENOMEM;
    1.99  
   1.100 @@ -644,14 +653,23 @@ static int __init xencons_init(void)
   1.101  	DRV(xencons_driver)->termios         = xencons_termios;
   1.102  	DRV(xencons_driver)->termios_locked  = xencons_termios_locked;
   1.103  
   1.104 -	if (xc_mode == XC_SERIAL) {
   1.105 +	switch (xc_mode) {
   1.106 +	case XC_XVC:
   1.107 +		DRV(xencons_driver)->name        = "xvc";
   1.108 +		DRV(xencons_driver)->major       = XEN_XVC_MAJOR;
   1.109 +		DRV(xencons_driver)->minor_start = XEN_XVC_MINOR;
   1.110 +		DRV(xencons_driver)->name_base   = xc_num;
   1.111 +		break;
   1.112 +	case XC_SERIAL:
   1.113  		DRV(xencons_driver)->name        = "ttyS";
   1.114  		DRV(xencons_driver)->minor_start = 64 + xc_num;
   1.115 -		DRV(xencons_driver)->name_base   = 0 + xc_num;
   1.116 -	} else {
   1.117 +		DRV(xencons_driver)->name_base   = xc_num;
   1.118 +		break;
   1.119 +	default:
   1.120  		DRV(xencons_driver)->name        = "tty";
   1.121  		DRV(xencons_driver)->minor_start = 1;
   1.122  		DRV(xencons_driver)->name_base   = 1;
   1.123 +		break;
   1.124  	}
   1.125  
   1.126  	tty_set_operations(xencons_driver, &xencons_ops);