From: Amos Waterland Subject: [PATCH] Virtual console driver on /dev/xvc0 (take two) Date: Fri, 4 Aug 2006 13:15:14 -0400 Message-ID: <20060804171514.GA7375@kvasir.watson.ibm.com> References: <20060802214226.GA14656@kvasir.watson.ibm.com> <659b9a19c91fde3126cb6c3ec32a8eaa@cl.cam.ac.uk> <20060803230747.GA28588@kvasir.watson.ibm.com> <07eaf363aa125b61f9928223b9f857b4@cl.cam.ac.uk> <1154701424.8735.2.camel@orodruin.boston.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1154701424.8735.2.camel@orodruin.boston.redhat.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeremy Katz Cc: Jimi Xenidis , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Use the low-density serial console major and the next free minor according to the Lanana. Since it would be awkward to say 'xencons=xvc187', use name_base to allow /dev/xvc0 to be major/minor 204/187. To use, put `xencons=xvc0' in your Linux .config, and run `mknod /dev/xvc0 c 204 187' in your rootfs. Built and booted up to nfsroot on a JS21 ppc64 blade both on bare hardware and as a dom0. Signed-off-by: Amos Waterland --- drivers/xen/console/console.c | 29 +++++++++++++++++++++++++++-- include/linux/major.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff -r 17aa29a18b08 drivers/xen/console/console.c --- a/drivers/xen/console/console.c Thu Jul 27 18:57:20 2006 -0400 +++ b/drivers/xen/console/console.c Fri Aug 04 13:04:06 2006 -0400 @@ -63,13 +63,20 @@ * 'xencons=off' [XC_OFF]: Console is disabled. * 'xencons=tty' [XC_TTY]: Console attached to '/dev/tty[0-9]+'. * 'xencons=ttyS' [XC_SERIAL]: Console attached to '/dev/ttyS[0-9]+'. + * 'xencons=xvc' [XC_XVC]: Console attached to '/dev/xvc[0-9]+'. * [XC_DEFAULT]: DOM0 -> XC_SERIAL ; all others -> XC_TTY. * * NB. In mode XC_TTY, we create dummy consoles for tty2-63. This suppresses * warnings from standard distro startup scripts. */ -static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT; +static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL, XC_XVC } + xc_mode = XC_DEFAULT; static int xc_num = -1; + +/* If we are in XC_XVC mode (a virtual console at /dev/xvcX), we need to + * comply with Lanana and use a minor under the low density serial major. + */ +#define XEN_XVC_MINOR 187 #ifdef CONFIG_MAGIC_SYSRQ static unsigned long sysrq_requested; @@ -85,6 +92,8 @@ static int __init xencons_setup(char *st xc_mode = XC_SERIAL; else if (!strncmp(str, "tty", 3)) xc_mode = XC_TTY; + else if (!strncmp(str, "xvc", 3)) + xc_mode = XC_XVC; else if (!strncmp(str, "off", 3)) xc_mode = XC_OFF; @@ -95,6 +104,11 @@ static int __init xencons_setup(char *st xc_num = n; break; case XC_TTY: + n = simple_strtol(str+3, &q, 10); + if (q > (str + 3)) + xc_num = n; + break; + case XC_XVC: n = simple_strtol(str+3, &q, 10); if (q > (str + 3)) xc_num = n; @@ -192,7 +206,7 @@ static int __init xen_console_init(void) if (xc_mode == XC_DEFAULT) xc_mode = XC_SERIAL; kcons_info.write = kcons_write_dom0; - if (xc_mode == XC_SERIAL) + if (xc_mode == XC_SERIAL || xc_mode == XC_XVC) kcons_info.flags |= CON_ENABLED; } else { if (xc_mode == XC_DEFAULT) @@ -201,6 +215,12 @@ static int __init xen_console_init(void) } switch (xc_mode) { + case XC_XVC: + strcpy(kcons_info.name, "xvc"); + if (xc_num == -1) + xc_num = 0; + break; + case XC_SERIAL: strcpy(kcons_info.name, "ttyS"); if (xc_num == -1) @@ -597,6 +617,11 @@ static int __init xencons_init(void) DRV(xencons_driver)->name = "ttyS"; DRV(xencons_driver)->minor_start = 64 + xc_num; DRV(xencons_driver)->name_base = 0 + xc_num; + } else if (xc_mode == XC_XVC) { + DRV(xencons_driver)->name = "xvc"; + DRV(xencons_driver)->major = LOW_DENS_SERIAL_MAJOR; + DRV(xencons_driver)->minor_start = XEN_XVC_MINOR; + DRV(xencons_driver)->name_base = xc_num; } else { DRV(xencons_driver)->name = "tty"; DRV(xencons_driver)->minor_start = xc_num; diff -r 17aa29a18b08 include/linux/major.h --- a/include/linux/major.h Thu Jul 27 18:57:20 2006 -0400 +++ b/include/linux/major.h Fri Aug 04 13:04:06 2006 -0400 @@ -158,6 +158,7 @@ #define MSR_MAJOR 202 #define CPUID_MAJOR 203 +#define LOW_DENS_SERIAL_MAJOR 204 #define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */