ia64/xen-unstable

changeset 1803:49364b76a968

bitkeeper revision 1.1096 (40f6851bgE09CI90pLVdOYUODRx7ww)

Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
author kaf24@scramble.cl.cam.ac.uk
date Thu Jul 15 13:22:35 2004 +0000 (2004-07-15)
parents a825d179881d 6c8f0ff82dd5
children 6e21cf718ee1 70dea4b6904d
files .rootkeys linux-2.4.26-xen-sparse/arch/xen/drivers/console/console.c linux-2.4.26-xen-sparse/mkbuildtree linux-2.6.7-xen-sparse/drivers/xen/console/console.c
line diff
     1.1 --- a/.rootkeys	Thu Jul 15 12:52:00 2004 +0000
     1.2 +++ b/.rootkeys	Thu Jul 15 13:22:35 2004 +0000
     1.3 @@ -61,7 +61,6 @@ 4075806d4-j7vN0Mn0bklI1cRUX1vQ linux-2.4
     1.4  4075806d3fJqqDC1pYYPTZPc575iKg linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/frontend/main.c
     1.5  4075806dibjCcfuXv6CINMhxWTw3jQ linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/frontend/vbd.c
     1.6  3e5a4e65G3e2s0ghPMgiJ-gBTUJ0uQ linux-2.4.26-xen-sparse/arch/xen/drivers/console/Makefile
     1.7 -3e5a4e651TH-SXHoufurnWjgl5bfOA linux-2.4.26-xen-sparse/arch/xen/drivers/console/console.c
     1.8  3e5a4e656nfFISThfbyXQOA6HN6YHw linux-2.4.26-xen-sparse/arch/xen/drivers/dom0/Makefile
     1.9  3e5a4e65BXtftInNHUC2PjDfPhdZZA linux-2.4.26-xen-sparse/arch/xen/drivers/dom0/core.c
    1.10  40420a6ebRqDjufoN1WSJvolEW2Wjw linux-2.4.26-xen-sparse/arch/xen/drivers/evtchn/Makefile
    1.11 @@ -195,7 +194,7 @@ 40f56239-JNIaTzlviVJohVdoYOUpw linux-2.6
    1.12  40f56239y9naBTXe40Pi2J_z3p-d1g linux-2.6.7-xen-sparse/drivers/xen/block/block.h
    1.13  40f56239BVfPsXBiWQitXgDRtOsiqg linux-2.6.7-xen-sparse/drivers/xen/block/vbd.c
    1.14  40f56239fsLjvtD8YBRAWphps4FDjg linux-2.6.7-xen-sparse/drivers/xen/console/Makefile
    1.15 -40f56239afE58Oot-9omHGqq4UJ--A linux-2.6.7-xen-sparse/drivers/xen/console/console.c
    1.16 +3e5a4e651TH-SXHoufurnWjgl5bfOA linux-2.6.7-xen-sparse/drivers/xen/console/console.c
    1.17  40f56239KYxO0YabhPzCTeUuln-lnA linux-2.6.7-xen-sparse/drivers/xen/evtchn/Makefile
    1.18  40f56239DoibTX6R-ZYd3QTXAB8_TA linux-2.6.7-xen-sparse/drivers/xen/evtchn/evtchn.c
    1.19  40f56239lrg_Ob0BJ8WBFS1zeg2CYw linux-2.6.7-xen-sparse/drivers/xen/net/Kconfig
     2.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/console/console.c	Thu Jul 15 12:52:00 2004 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,625 +0,0 @@
     2.4 -/******************************************************************************
     2.5 - * console.c
     2.6 - * 
     2.7 - * Virtual console driver.
     2.8 - * 
     2.9 - * Copyright (c) 2002-2004, K A Fraser.
    2.10 - */
    2.11 -
    2.12 -#include <linux/config.h>
    2.13 -#include <linux/module.h>
    2.14 -#include <linux/errno.h>
    2.15 -#include <linux/signal.h>
    2.16 -#include <linux/sched.h>
    2.17 -#include <linux/interrupt.h>
    2.18 -#include <linux/tty.h>
    2.19 -#include <linux/tty_flip.h>
    2.20 -#include <linux/serial.h>
    2.21 -#include <linux/major.h>
    2.22 -#include <linux/ptrace.h>
    2.23 -#include <linux/ioport.h>
    2.24 -#include <linux/mm.h>
    2.25 -#include <linux/slab.h>
    2.26 -#include <linux/init.h>
    2.27 -#include <linux/console.h>
    2.28 -#include <asm/evtchn.h>
    2.29 -#include <asm/io.h>
    2.30 -#include <asm/irq.h>
    2.31 -#include <asm/uaccess.h>
    2.32 -#include <asm/hypervisor.h>
    2.33 -#include <asm/hypervisor-ifs/event_channel.h>
    2.34 -#include <asm/ctrl_if.h>
    2.35 -
    2.36 -/*
    2.37 - * Modes:
    2.38 - *  'xencons=off'  [XC_OFF]:     Console is disabled.
    2.39 - *  'xencons=tty'  [XC_TTY]:     Console attached to '/dev/tty[0-9]+'.
    2.40 - *  'xencons=ttyS' [XC_SERIAL]:  Console attached to '/dev/ttyS[0-9]+'.
    2.41 - *                 [XC_DEFAULT]: DOM0 -> XC_SERIAL ; all others -> XC_TTY.
    2.42 - * 
    2.43 - * NB. In mode XC_TTY, we create dummy consoles for tty2-63. This suppresses
    2.44 - * warnings from standard distro startup scripts.
    2.45 - */
    2.46 -static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
    2.47 -
    2.48 -static int __init xencons_setup(char *str)
    2.49 -{
    2.50 -    if ( !strcmp(str, "tty") )
    2.51 -        xc_mode = XC_TTY;
    2.52 -    else if ( !strcmp(str, "ttyS") )
    2.53 -        xc_mode = XC_SERIAL;
    2.54 -    else if ( !strcmp(str, "off") )
    2.55 -        xc_mode = XC_OFF;
    2.56 -    return 1;
    2.57 -}
    2.58 -__setup("xencons", xencons_setup);
    2.59 -
    2.60 -/* The kernel and user-land drivers share a common transmit buffer. */
    2.61 -#define WBUF_SIZE     4096
    2.62 -#define WBUF_MASK(_i) ((_i)&(WBUF_SIZE-1))
    2.63 -static char wbuf[WBUF_SIZE];
    2.64 -static unsigned int wc, wp; /* write_cons, write_prod */
    2.65 -
    2.66 -/* This lock protects accesses to the common transmit buffer. */
    2.67 -static spinlock_t xencons_lock = SPIN_LOCK_UNLOCKED;
    2.68 -
    2.69 -/* Common transmit-kick routine. */
    2.70 -static void __xencons_tx_flush(void);
    2.71 -
    2.72 -/* This task is used to defer sending console data until there is space. */
    2.73 -static void xencons_tx_flush_task_routine(void *data);
    2.74 -static struct tq_struct xencons_tx_flush_task = {
    2.75 -    routine: xencons_tx_flush_task_routine
    2.76 -};
    2.77 -
    2.78 -
    2.79 -/******************** Kernel console driver ********************************/
    2.80 -
    2.81 -static void kcons_write(
    2.82 -    struct console *c, const char *s, unsigned int count)
    2.83 -{
    2.84 -    int           i;
    2.85 -    unsigned long flags;
    2.86 -
    2.87 -    spin_lock_irqsave(&xencons_lock, flags);
    2.88 -    
    2.89 -    for ( i = 0; i < count; i++ )
    2.90 -    {
    2.91 -        if ( (wp - wc) >= (WBUF_SIZE - 1) )
    2.92 -            break;
    2.93 -        if ( (wbuf[WBUF_MASK(wp++)] = s[i]) == '\n' )
    2.94 -            wbuf[WBUF_MASK(wp++)] = '\r';
    2.95 -    }
    2.96 -
    2.97 -    __xencons_tx_flush();
    2.98 -
    2.99 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.100 -}
   2.101 -
   2.102 -static void kcons_write_dom0(
   2.103 -    struct console *c, const char *s, unsigned int count)
   2.104 -{
   2.105 -    int rc;
   2.106 -
   2.107 -    while ( count > 0 )
   2.108 -    {
   2.109 -        if ( (rc = HYPERVISOR_console_io(CONSOLEIO_write, count, s)) > 0 )
   2.110 -        {
   2.111 -            count -= rc;
   2.112 -            s += rc;
   2.113 -        }
   2.114 -	else
   2.115 -	    break;
   2.116 -    }
   2.117 -}
   2.118 -
   2.119 -static kdev_t kcons_device(struct console *c)
   2.120 -{
   2.121 -    return MKDEV(TTY_MAJOR, (xc_mode == XC_SERIAL) ? 64 : 1);
   2.122 -}
   2.123 -
   2.124 -static struct console kcons_info = {
   2.125 -    device:  kcons_device,
   2.126 -    flags:   CON_PRINTBUFFER,
   2.127 -    index:   -1
   2.128 -};
   2.129 -
   2.130 -void xen_console_init(void)
   2.131 -{
   2.132 -    if ( start_info.flags & SIF_INITDOMAIN )
   2.133 -    {
   2.134 -        if ( xc_mode == XC_DEFAULT )
   2.135 -            xc_mode = XC_SERIAL;
   2.136 -        kcons_info.write = kcons_write_dom0;
   2.137 -    }
   2.138 -    else
   2.139 -    {
   2.140 -        if ( xc_mode == XC_DEFAULT )
   2.141 -            xc_mode = XC_TTY;
   2.142 -        kcons_info.write = kcons_write;
   2.143 -    }
   2.144 -
   2.145 -    if ( xc_mode == XC_OFF )
   2.146 -        return;
   2.147 -
   2.148 -    if ( xc_mode == XC_SERIAL )
   2.149 -        strcpy(kcons_info.name, "ttyS");
   2.150 -    else
   2.151 -        strcpy(kcons_info.name, "tty");
   2.152 -
   2.153 -    register_console(&kcons_info);
   2.154 -}
   2.155 -
   2.156 -
   2.157 -/*** Useful function for console debugging -- goes straight to Xen. ***/
   2.158 -asmlinkage int xprintk(const char *fmt, ...)
   2.159 -{
   2.160 -    va_list args;
   2.161 -    int printk_len;
   2.162 -    static char printk_buf[1024];
   2.163 -    
   2.164 -    /* Emit the output into the temporary buffer */
   2.165 -    va_start(args, fmt);
   2.166 -    printk_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
   2.167 -    va_end(args);
   2.168 -
   2.169 -    /* Send the processed output directly to Xen. */
   2.170 -    kcons_write_dom0(NULL, printk_buf, printk_len);
   2.171 -
   2.172 -    return 0;
   2.173 -}
   2.174 -
   2.175 -/*** Forcibly flush console data before dying. ***/
   2.176 -void xencons_force_flush(void)
   2.177 -{
   2.178 -    ctrl_msg_t msg;
   2.179 -    int        sz;
   2.180 -
   2.181 -    /* Emergency console is synchronous, so there's nothing to flush. */
   2.182 -    if ( start_info.flags & SIF_INITDOMAIN )
   2.183 -        return;
   2.184 -
   2.185 -    /*
   2.186 -     * We use dangerous control-interface functions that require a quiescent
   2.187 -     * system and no interrupts. Try to ensure this with a global cli().
   2.188 -     */
   2.189 -    cli();
   2.190 -
   2.191 -    /* Spin until console data is flushed through to the domain controller. */
   2.192 -    while ( (wc != wp) && !ctrl_if_transmitter_empty() )
   2.193 -    {
   2.194 -        /* Interrupts are disabled -- we must manually reap responses. */
   2.195 -        ctrl_if_discard_responses();
   2.196 -
   2.197 -        if ( (sz = wp - wc) == 0 )
   2.198 -            continue;
   2.199 -        if ( sz > sizeof(msg.msg) )
   2.200 -            sz = sizeof(msg.msg);
   2.201 -        if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
   2.202 -            sz = WBUF_SIZE - WBUF_MASK(wc);
   2.203 -
   2.204 -        msg.type    = CMSG_CONSOLE;
   2.205 -        msg.subtype = CMSG_CONSOLE_DATA;
   2.206 -        msg.length  = sz;
   2.207 -        memcpy(msg.msg, &wbuf[WBUF_MASK(wc)], sz);
   2.208 -            
   2.209 -        if ( ctrl_if_send_message_noblock(&msg, NULL, 0) == 0 )
   2.210 -            wc += sz;
   2.211 -    }
   2.212 -}
   2.213 -
   2.214 -
   2.215 -/******************** User-space console driver (/dev/console) ************/
   2.216 -
   2.217 -static struct tty_driver xencons_driver;
   2.218 -static int xencons_refcount;
   2.219 -static struct tty_struct *xencons_table[MAX_NR_CONSOLES];
   2.220 -static struct termios *xencons_termios[MAX_NR_CONSOLES];
   2.221 -static struct termios *xencons_termios_locked[MAX_NR_CONSOLES];
   2.222 -static struct tty_struct *xencons_tty;
   2.223 -static int xencons_priv_irq;
   2.224 -static char x_char;
   2.225 -
   2.226 -/* Non-privileged receive callback. */
   2.227 -static void xencons_rx(ctrl_msg_t *msg, unsigned long id)
   2.228 -{
   2.229 -    int           i;
   2.230 -    unsigned long flags;
   2.231 -
   2.232 -    spin_lock_irqsave(&xencons_lock, flags);
   2.233 -    if ( xencons_tty != NULL )
   2.234 -    {
   2.235 -        for ( i = 0; i < msg->length; i++ )
   2.236 -            tty_insert_flip_char(xencons_tty, msg->msg[i], 0);
   2.237 -        tty_flip_buffer_push(xencons_tty);
   2.238 -    }
   2.239 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.240 -
   2.241 -    msg->length = 0;
   2.242 -    ctrl_if_send_response(msg);
   2.243 -}
   2.244 -
   2.245 -/* Privileged and non-privileged transmit worker. */
   2.246 -static void __xencons_tx_flush(void)
   2.247 -{
   2.248 -    int        sz, work_done = 0;
   2.249 -    ctrl_msg_t msg;
   2.250 -
   2.251 -    if ( start_info.flags & SIF_INITDOMAIN )
   2.252 -    {
   2.253 -        if ( x_char )
   2.254 -        {
   2.255 -            kcons_write_dom0(NULL, &x_char, 1);
   2.256 -            x_char = 0;
   2.257 -            work_done = 1;
   2.258 -        }
   2.259 -
   2.260 -        while ( wc != wp )
   2.261 -        {
   2.262 -            sz = wp - wc;
   2.263 -            if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
   2.264 -                sz = WBUF_SIZE - WBUF_MASK(wc);
   2.265 -            kcons_write_dom0(NULL, &wbuf[WBUF_MASK(wc)], sz);
   2.266 -            wc += sz;
   2.267 -            work_done = 1;
   2.268 -        }
   2.269 -    }
   2.270 -    else
   2.271 -    {
   2.272 -        while ( x_char )
   2.273 -        {
   2.274 -            msg.type    = CMSG_CONSOLE;
   2.275 -            msg.subtype = CMSG_CONSOLE_DATA;
   2.276 -            msg.length  = 1;
   2.277 -            msg.msg[0]  = x_char;
   2.278 -
   2.279 -            if ( ctrl_if_send_message_noblock(&msg, NULL, 0) == 0 )
   2.280 -                x_char = 0;
   2.281 -            else if ( ctrl_if_enqueue_space_callback(&xencons_tx_flush_task) )
   2.282 -                break;
   2.283 -
   2.284 -            work_done = 1;
   2.285 -        }
   2.286 -
   2.287 -        while ( wc != wp )
   2.288 -        {
   2.289 -            sz = wp - wc;
   2.290 -            if ( sz > sizeof(msg.msg) )
   2.291 -                sz = sizeof(msg.msg);
   2.292 -            if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
   2.293 -                sz = WBUF_SIZE - WBUF_MASK(wc);
   2.294 -
   2.295 -            msg.type    = CMSG_CONSOLE;
   2.296 -            msg.subtype = CMSG_CONSOLE_DATA;
   2.297 -            msg.length  = sz;
   2.298 -            memcpy(msg.msg, &wbuf[WBUF_MASK(wc)], sz);
   2.299 -            
   2.300 -            if ( ctrl_if_send_message_noblock(&msg, NULL, 0) == 0 )
   2.301 -                wc += sz;
   2.302 -            else if ( ctrl_if_enqueue_space_callback(&xencons_tx_flush_task) )
   2.303 -                break;
   2.304 -
   2.305 -            work_done = 1;
   2.306 -        }
   2.307 -    }
   2.308 -
   2.309 -    if ( work_done && (xencons_tty != NULL) )
   2.310 -    {
   2.311 -        wake_up_interruptible(&xencons_tty->write_wait);
   2.312 -        if ( (xencons_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
   2.313 -             (xencons_tty->ldisc.write_wakeup != NULL) )
   2.314 -            (xencons_tty->ldisc.write_wakeup)(xencons_tty);
   2.315 -    }
   2.316 -}
   2.317 -
   2.318 -/* Non-privileged transmit kicker. */
   2.319 -static void xencons_tx_flush_task_routine(void *data)
   2.320 -{
   2.321 -    unsigned long flags;
   2.322 -    spin_lock_irqsave(&xencons_lock, flags);
   2.323 -    __xencons_tx_flush();
   2.324 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.325 -}
   2.326 -
   2.327 -/* Privileged receive callback and transmit kicker. */
   2.328 -static void xencons_priv_interrupt(int irq, void *dev_id, struct pt_regs *regs)
   2.329 -{
   2.330 -    static char   rbuf[16];
   2.331 -    int           i, l;
   2.332 -    unsigned long flags;
   2.333 -
   2.334 -    spin_lock_irqsave(&xencons_lock, flags);
   2.335 -
   2.336 -    if ( xencons_tty != NULL )
   2.337 -    {
   2.338 -        /* Receive work. */
   2.339 -        while ( (l = HYPERVISOR_console_io(CONSOLEIO_read, 16, rbuf)) > 0 )
   2.340 -            for ( i = 0; i < l; i++ )
   2.341 -                tty_insert_flip_char(xencons_tty, rbuf[i], 0);
   2.342 -        if ( xencons_tty->flip.count != 0 )
   2.343 -            tty_flip_buffer_push(xencons_tty);
   2.344 -    }
   2.345 -
   2.346 -    /* Transmit work. */
   2.347 -    __xencons_tx_flush();
   2.348 -
   2.349 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.350 -}
   2.351 -
   2.352 -static int xencons_write_room(struct tty_struct *tty)
   2.353 -{
   2.354 -    return WBUF_SIZE - (wp - wc);
   2.355 -}
   2.356 -
   2.357 -static int xencons_chars_in_buffer(struct tty_struct *tty)
   2.358 -{
   2.359 -    return wp - wc;
   2.360 -}
   2.361 -
   2.362 -static void xencons_send_xchar(struct tty_struct *tty, char ch)
   2.363 -{
   2.364 -    unsigned long flags;
   2.365 -
   2.366 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.367 -        return;
   2.368 -
   2.369 -    spin_lock_irqsave(&xencons_lock, flags);
   2.370 -    x_char = ch;
   2.371 -    __xencons_tx_flush();
   2.372 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.373 -}
   2.374 -
   2.375 -static void xencons_throttle(struct tty_struct *tty)
   2.376 -{
   2.377 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.378 -        return;
   2.379 -
   2.380 -    if ( I_IXOFF(tty) )
   2.381 -        xencons_send_xchar(tty, STOP_CHAR(tty));
   2.382 -}
   2.383 -
   2.384 -static void xencons_unthrottle(struct tty_struct *tty)
   2.385 -{
   2.386 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.387 -        return;
   2.388 -
   2.389 -    if ( I_IXOFF(tty) )
   2.390 -    {
   2.391 -        if ( x_char != 0 )
   2.392 -            x_char = 0;
   2.393 -        else
   2.394 -            xencons_send_xchar(tty, START_CHAR(tty));
   2.395 -    }
   2.396 -}
   2.397 -
   2.398 -static void xencons_flush_buffer(struct tty_struct *tty)
   2.399 -{
   2.400 -    unsigned long flags;
   2.401 -
   2.402 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.403 -        return;
   2.404 -
   2.405 -    spin_lock_irqsave(&xencons_lock, flags);
   2.406 -    wc = wp = 0;
   2.407 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.408 -}
   2.409 -
   2.410 -static inline int __xencons_put_char(int ch)
   2.411 -{
   2.412 -    char _ch = (char)ch;
   2.413 -    if ( (wp - wc) == WBUF_SIZE )
   2.414 -        return 0;
   2.415 -    wbuf[WBUF_MASK(wp++)] = _ch;
   2.416 -    return 1;
   2.417 -}
   2.418 -
   2.419 -static int xencons_write(struct tty_struct *tty, int from_user,
   2.420 -                       const u_char * buf, int count)
   2.421 -{
   2.422 -    int i;
   2.423 -    unsigned long flags;
   2.424 -
   2.425 -    if ( from_user && verify_area(VERIFY_READ, buf, count) )
   2.426 -        return -EINVAL;
   2.427 -
   2.428 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.429 -        return count;
   2.430 -
   2.431 -    spin_lock_irqsave(&xencons_lock, flags);
   2.432 -
   2.433 -    for ( i = 0; i < count; i++ )
   2.434 -    {
   2.435 -        char ch;
   2.436 -        if ( from_user )
   2.437 -            __get_user(ch, buf + i);
   2.438 -        else
   2.439 -            ch = buf[i];
   2.440 -        if ( !__xencons_put_char(ch) )
   2.441 -            break;
   2.442 -    }
   2.443 -
   2.444 -    if ( i != 0 )
   2.445 -        __xencons_tx_flush();
   2.446 -
   2.447 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.448 -
   2.449 -    return i;
   2.450 -}
   2.451 -
   2.452 -static void xencons_put_char(struct tty_struct *tty, u_char ch)
   2.453 -{
   2.454 -    unsigned long flags;
   2.455 -
   2.456 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.457 -        return;
   2.458 -
   2.459 -    spin_lock_irqsave(&xencons_lock, flags);
   2.460 -    (void)__xencons_put_char(ch);
   2.461 -    spin_unlock_irqrestore(&xencons_lock, flags);
   2.462 -}
   2.463 -
   2.464 -static void xencons_flush_chars(struct tty_struct *tty)
   2.465 -{
   2.466 -    unsigned long flags;
   2.467 -
   2.468 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.469 -        return;
   2.470 -
   2.471 -    spin_lock_irqsave(&xencons_lock, flags);
   2.472 -    __xencons_tx_flush();
   2.473 -    spin_unlock_irqrestore(&xencons_lock, flags);    
   2.474 -}
   2.475 -
   2.476 -static void xencons_wait_until_sent(struct tty_struct *tty, int timeout)
   2.477 -{
   2.478 -    unsigned long orig_jiffies = jiffies;
   2.479 -
   2.480 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.481 -        return;
   2.482 -
   2.483 -    while ( tty->driver.chars_in_buffer(tty) )
   2.484 -    {
   2.485 -        set_current_state(TASK_INTERRUPTIBLE);
   2.486 -        schedule_timeout(1);
   2.487 -        if ( signal_pending(current) )
   2.488 -            break;
   2.489 -        if ( (timeout != 0) && time_after(jiffies, orig_jiffies + timeout) )
   2.490 -            break;
   2.491 -    }
   2.492 -    
   2.493 -    set_current_state(TASK_RUNNING);
   2.494 -}
   2.495 -
   2.496 -static int xencons_open(struct tty_struct *tty, struct file *filp)
   2.497 -{
   2.498 -    int line;
   2.499 -    unsigned long flags;
   2.500 -
   2.501 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.502 -        return 0;
   2.503 -
   2.504 -    MOD_INC_USE_COUNT;
   2.505 -    line = MINOR(tty->device) - tty->driver.minor_start;
   2.506 -    if ( line != 0 )
   2.507 -    {
   2.508 -        MOD_DEC_USE_COUNT;
   2.509 -        return -ENODEV;
   2.510 -    }
   2.511 -
   2.512 -    spin_lock_irqsave(&xencons_lock, flags);
   2.513 -    tty->driver_data = NULL;
   2.514 -    if ( xencons_tty == NULL )
   2.515 -        xencons_tty = tty;
   2.516 -    __xencons_tx_flush();
   2.517 -    spin_unlock_irqrestore(&xencons_lock, flags);    
   2.518 -
   2.519 -    return 0;
   2.520 -}
   2.521 -
   2.522 -static void xencons_close(struct tty_struct *tty, struct file *filp)
   2.523 -{
   2.524 -    unsigned long flags;
   2.525 -
   2.526 -    if ( MINOR(tty->device) != xencons_driver.minor_start )
   2.527 -        return;
   2.528 -
   2.529 -    if ( tty->count == 1 )
   2.530 -    {
   2.531 -        tty->closing = 1;
   2.532 -        tty_wait_until_sent(tty, 0);
   2.533 -        if ( tty->driver.flush_buffer != NULL )
   2.534 -            tty->driver.flush_buffer(tty);
   2.535 -        if ( tty->ldisc.flush_buffer != NULL )
   2.536 -            tty->ldisc.flush_buffer(tty);
   2.537 -        tty->closing = 0;
   2.538 -        spin_lock_irqsave(&xencons_lock, flags);
   2.539 -        xencons_tty = NULL;
   2.540 -        spin_unlock_irqrestore(&xencons_lock, flags);    
   2.541 -    }
   2.542 -
   2.543 -    MOD_DEC_USE_COUNT;
   2.544 -}
   2.545 -
   2.546 -static int __init xencons_init(void)
   2.547 -{
   2.548 -    memset(&xencons_driver, 0, sizeof(struct tty_driver));
   2.549 -    xencons_driver.magic           = TTY_DRIVER_MAGIC;
   2.550 -    xencons_driver.major           = TTY_MAJOR;
   2.551 -    xencons_driver.type            = TTY_DRIVER_TYPE_SERIAL;
   2.552 -    xencons_driver.subtype         = SERIAL_TYPE_NORMAL;
   2.553 -    xencons_driver.init_termios    = tty_std_termios;
   2.554 -    xencons_driver.flags           = 
   2.555 -        TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_NO_DEVFS;
   2.556 -    xencons_driver.refcount        = &xencons_refcount;
   2.557 -    xencons_driver.table           = xencons_table;
   2.558 -    xencons_driver.termios         = xencons_termios;
   2.559 -    xencons_driver.termios_locked  = xencons_termios_locked;
   2.560 -
   2.561 -    if ( xc_mode == XC_OFF )
   2.562 -        return 0;
   2.563 -
   2.564 -    if ( xc_mode == XC_SERIAL )
   2.565 -    {
   2.566 -        xencons_driver.name        = "ttyS";
   2.567 -        xencons_driver.minor_start = 64;
   2.568 -        xencons_driver.num         = 1;
   2.569 -    }
   2.570 -    else
   2.571 -    {
   2.572 -        xencons_driver.name        = "tty";
   2.573 -        xencons_driver.minor_start = 1;
   2.574 -        xencons_driver.num         = MAX_NR_CONSOLES;
   2.575 -    }
   2.576 -
   2.577 -    xencons_driver.open            = xencons_open;
   2.578 -    xencons_driver.close           = xencons_close;
   2.579 -    xencons_driver.write           = xencons_write;
   2.580 -    xencons_driver.write_room      = xencons_write_room;
   2.581 -    xencons_driver.put_char        = xencons_put_char;
   2.582 -    xencons_driver.flush_chars     = xencons_flush_chars;
   2.583 -    xencons_driver.chars_in_buffer = xencons_chars_in_buffer;
   2.584 -    xencons_driver.send_xchar      = xencons_send_xchar;
   2.585 -    xencons_driver.flush_buffer    = xencons_flush_buffer;
   2.586 -    xencons_driver.throttle        = xencons_throttle;
   2.587 -    xencons_driver.unthrottle      = xencons_unthrottle;
   2.588 -    xencons_driver.wait_until_sent = xencons_wait_until_sent;
   2.589 -
   2.590 -    if ( tty_register_driver(&xencons_driver) )
   2.591 -        panic("Couldn't register Xen virtual console driver as %s\n",xencons_driver.name);
   2.592 -
   2.593 -    if ( start_info.flags & SIF_INITDOMAIN )
   2.594 -    {
   2.595 -        xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE);
   2.596 -        (void)request_irq(xencons_priv_irq,
   2.597 -                          xencons_priv_interrupt, 0, "console", NULL);
   2.598 -    }
   2.599 -    else
   2.600 -    {
   2.601 -        (void)ctrl_if_register_receiver(CMSG_CONSOLE, xencons_rx, 0);
   2.602 -    }
   2.603 -
   2.604 -    printk("Xen virtual console successfully installed as %s\n",xencons_driver.name);
   2.605 -    
   2.606 -    return 0;
   2.607 -}
   2.608 -
   2.609 -static void __exit xencons_fini(void)
   2.610 -{
   2.611 -    int ret;
   2.612 -
   2.613 -    if ( (ret = tty_unregister_driver(&xencons_driver)) != 0 )
   2.614 -        printk(KERN_ERR "Unable to unregister Xen console driver: %d\n", ret);
   2.615 -
   2.616 -    if ( start_info.flags & SIF_INITDOMAIN )
   2.617 -    {
   2.618 -        free_irq(xencons_priv_irq, NULL);
   2.619 -        unbind_virq_from_irq(VIRQ_CONSOLE);
   2.620 -    }
   2.621 -    else
   2.622 -    {
   2.623 -        ctrl_if_unregister_receiver(CMSG_CONSOLE, xencons_rx);
   2.624 -    }
   2.625 -}
   2.626 -
   2.627 -module_init(xencons_init);
   2.628 -module_exit(xencons_fini);
     3.1 --- a/linux-2.4.26-xen-sparse/mkbuildtree	Thu Jul 15 12:52:00 2004 +0000
     3.2 +++ b/linux-2.4.26-xen-sparse/mkbuildtree	Thu Jul 15 13:22:35 2004 +0000
     3.3 @@ -102,6 +102,8 @@ for i in `find . -type l`; do rm -f $i; 
     3.4  relative_lndir ${RS}
     3.5  rm -f mkbuildtree
     3.6  
     3.7 +LINUX_26=${RS}/../linux-2.6.7-xen-sparse
     3.8 +
     3.9  ## There are a whole bunch of special symlinks, mostly for files
    3.10  ## which are identical in the i386 and xen-i386 architecture-dependent
    3.11  ## subdirectories.
    3.12 @@ -220,3 +222,7 @@ ln -sf ../../i386/lib/usercopy.c
    3.13  cd ../mm
    3.14  ln -sf ../../i386/mm/extable.c 
    3.15  ln -sf ../../i386/mm/pageattr.c 
    3.16 +cd ../drivers/console
    3.17 +ln -sf ../../../../${LINUX_26}/drivers/xen/console/console.c 
    3.18 +#cd ../netif/frontend
    3.19 +#ln -sf ../../../../../${LINUX_26}/drivers/xen/net/network.c main.c
     4.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/console/console.c	Thu Jul 15 12:52:00 2004 +0000
     4.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/console/console.c	Thu Jul 15 13:22:35 2004 +0000
     4.3 @@ -7,6 +7,7 @@
     4.4   */
     4.5  
     4.6  #include <linux/config.h>
     4.7 +#include <linux/version.h>
     4.8  #include <linux/module.h>
     4.9  #include <linux/errno.h>
    4.10  #include <linux/signal.h>
    4.11 @@ -22,12 +23,12 @@
    4.12  #include <linux/slab.h>
    4.13  #include <linux/init.h>
    4.14  #include <linux/console.h>
    4.15 -#include <asm-xen/evtchn.h>
    4.16  #include <asm/io.h>
    4.17  #include <asm/irq.h>
    4.18  #include <asm/uaccess.h>
    4.19  #include <asm/hypervisor.h>
    4.20  #include <asm/hypervisor-ifs/event_channel.h>
    4.21 +#include <asm-xen/evtchn.h>
    4.22  #include <asm-xen/ctrl_if.h>
    4.23  
    4.24  /*
    4.25 @@ -63,22 +64,24 @@ static unsigned int wc, wp; /* write_con
    4.26  /* This lock protects accesses to the common transmit buffer. */
    4.27  static spinlock_t xencons_lock = SPIN_LOCK_UNLOCKED;
    4.28  
    4.29 -static struct tty_driver *xencons_driver;
    4.30 -
    4.31 -#define NUM_XENCONS 1
    4.32 -
    4.33  /* Common transmit-kick routine. */
    4.34  static void __xencons_tx_flush(void);
    4.35  
    4.36  /* This task is used to defer sending console data until there is space. */
    4.37  static void xencons_tx_flush_task_routine(void *data);
    4.38 -#if 0				/* XXXcl tq */
    4.39 +
    4.40 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    4.41 +static struct tty_driver *xencons_driver;
    4.42 +static DECLARE_WORK(xencons_tx_flush_task,
    4.43 +                    xencons_tx_flush_task_routine,
    4.44 +                    NULL);
    4.45 +#else
    4.46 +static struct tty_driver xencons_driver;
    4.47  static struct tq_struct xencons_tx_flush_task = {
    4.48      routine: xencons_tx_flush_task_routine
    4.49  };
    4.50 -#else
    4.51 -static DECLARE_WORK(xencons_tx_flush_task, xencons_tx_flush_task_routine,
    4.52 -                    NULL);
    4.53 +#define irqreturn_t void
    4.54 +#define IRQ_HANDLED
    4.55  #endif
    4.56  
    4.57  
    4.58 @@ -112,7 +115,8 @@ static void kcons_write_dom0(
    4.59  
    4.60      while ( count > 0 )
    4.61      {
    4.62 -        if ( (rc = HYPERVISOR_console_io(CONSOLEIO_write, count, (char *)s)) > 0 )
    4.63 +        if ( (rc = HYPERVISOR_console_io(CONSOLEIO_write,
    4.64 +                                         count, (char *)s)) > 0 )
    4.65          {
    4.66              count -= rc;
    4.67              s += rc;
    4.68 @@ -122,11 +126,18 @@ static void kcons_write_dom0(
    4.69      }
    4.70  }
    4.71  
    4.72 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    4.73  static struct tty_driver *kcons_device(struct console *c, int *index)
    4.74  {
    4.75      *index = c->index;
    4.76      return xencons_driver;
    4.77  }
    4.78 +#else
    4.79 +static kdev_t kcons_device(struct console *c)
    4.80 +{
    4.81 +    return MKDEV(TTY_MAJOR, (xc_mode == XC_SERIAL) ? 64 : 1);
    4.82 +}
    4.83 +#endif
    4.84  
    4.85  static struct console kcons_info = {
    4.86      device:  kcons_device,
    4.87 @@ -134,7 +145,13 @@ static struct console kcons_info = {
    4.88      index:   -1
    4.89  };
    4.90  
    4.91 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    4.92 +#define __RETCODE 0
    4.93  static int __init xen_console_init(void)
    4.94 +#else
    4.95 +#define __RETCODE
    4.96 +void xen_console_init(void)
    4.97 +#endif
    4.98  {
    4.99      if ( start_info.flags & SIF_INITDOMAIN )
   4.100      {
   4.101 @@ -150,7 +167,7 @@ static int __init xen_console_init(void)
   4.102      }
   4.103  
   4.104      if ( xc_mode == XC_OFF )
   4.105 -        return 0;
   4.106 +        return __RETCODE;
   4.107  
   4.108      if ( xc_mode == XC_SERIAL )
   4.109          strcpy(kcons_info.name, "ttyS");
   4.110 @@ -158,10 +175,11 @@ static int __init xen_console_init(void)
   4.111          strcpy(kcons_info.name, "tty");
   4.112  
   4.113      register_console(&kcons_info);
   4.114 -    return 0;
   4.115 +    return __RETCODE;
   4.116  }
   4.117 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   4.118  console_initcall(xen_console_init);
   4.119 -
   4.120 +#endif
   4.121  
   4.122  /*** Useful function for console debugging -- goes straight to Xen. ***/
   4.123  asmlinkage int xprintk(const char *fmt, ...)
   4.124 @@ -223,6 +241,16 @@ void xencons_force_flush(void)
   4.125  
   4.126  /******************** User-space console driver (/dev/console) ************/
   4.127  
   4.128 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   4.129 +#define DRV(_d)         (_d)
   4.130 +#define TTY_INDEX(_tty) ((_tty)->index)
   4.131 +#else
   4.132 +static int xencons_refcount;
   4.133 +static struct tty_struct *xencons_table[MAX_NR_CONSOLES];
   4.134 +#define DRV(_d)         (&(_d))
   4.135 +#define TTY_INDEX(_tty) (MINOR((_tty)->device) - xencons_driver.minor_start)
   4.136 +#endif
   4.137 +
   4.138  static struct termios *xencons_termios[MAX_NR_CONSOLES];
   4.139  static struct termios *xencons_termios_locked[MAX_NR_CONSOLES];
   4.140  static struct tty_struct *xencons_tty;
   4.141 @@ -284,11 +312,7 @@ static void __xencons_tx_flush(void)
   4.142  
   4.143              if ( ctrl_if_send_message_noblock(&msg, NULL, 0) == 0 )
   4.144                  x_char = 0;
   4.145 -#if 0				/* XXXcl tq */
   4.146              else if ( ctrl_if_enqueue_space_callback(&xencons_tx_flush_task) )
   4.147 -#else
   4.148 -            else if ( ctrl_if_enqueue_space_callback(&xencons_tx_flush_task) )
   4.149 -#endif
   4.150                  break;
   4.151  
   4.152              work_done = 1;
   4.153 @@ -309,11 +333,7 @@ static void __xencons_tx_flush(void)
   4.154              
   4.155              if ( ctrl_if_send_message_noblock(&msg, NULL, 0) == 0 )
   4.156                  wc += sz;
   4.157 -#if 0				/* XXXcl tq */
   4.158              else if ( ctrl_if_enqueue_space_callback(&xencons_tx_flush_task) )
   4.159 -#else
   4.160 -            else if ( ctrl_if_enqueue_space_callback(&xencons_tx_flush_task) )
   4.161 -#endif
   4.162                  break;
   4.163  
   4.164              work_done = 1;
   4.165 @@ -339,7 +359,8 @@ static void xencons_tx_flush_task_routin
   4.166  }
   4.167  
   4.168  /* Privileged receive callback and transmit kicker. */
   4.169 -static irqreturn_t xencons_priv_interrupt(int irq, void *dev_id, struct pt_regs *regs)
   4.170 +static irqreturn_t xencons_priv_interrupt(int irq, void *dev_id,
   4.171 +                                          struct pt_regs *regs)
   4.172  {
   4.173      static char   rbuf[16];
   4.174      int           i, l;
   4.175 @@ -379,6 +400,9 @@ static void xencons_send_xchar(struct tt
   4.176  {
   4.177      unsigned long flags;
   4.178  
   4.179 +    if ( TTY_INDEX(tty) != 0 )
   4.180 +        return;
   4.181 +
   4.182      spin_lock_irqsave(&xencons_lock, flags);
   4.183      x_char = ch;
   4.184      __xencons_tx_flush();
   4.185 @@ -387,12 +411,18 @@ static void xencons_send_xchar(struct tt
   4.186  
   4.187  static void xencons_throttle(struct tty_struct *tty)
   4.188  {
   4.189 +    if ( TTY_INDEX(tty) != 0 )
   4.190 +        return;
   4.191 +
   4.192      if ( I_IXOFF(tty) )
   4.193          xencons_send_xchar(tty, STOP_CHAR(tty));
   4.194  }
   4.195  
   4.196  static void xencons_unthrottle(struct tty_struct *tty)
   4.197  {
   4.198 +    if ( TTY_INDEX(tty) != 0 )
   4.199 +        return;
   4.200 +
   4.201      if ( I_IXOFF(tty) )
   4.202      {
   4.203          if ( x_char != 0 )
   4.204 @@ -406,6 +436,9 @@ static void xencons_flush_buffer(struct 
   4.205  {
   4.206      unsigned long flags;
   4.207  
   4.208 +    if ( TTY_INDEX(tty) != 0 )
   4.209 +        return;
   4.210 +
   4.211      spin_lock_irqsave(&xencons_lock, flags);
   4.212      wc = wp = 0;
   4.213      spin_unlock_irqrestore(&xencons_lock, flags);
   4.214 @@ -429,6 +462,9 @@ static int xencons_write(struct tty_stru
   4.215      if ( from_user && verify_area(VERIFY_READ, buf, count) )
   4.216          return -EINVAL;
   4.217  
   4.218 +    if ( TTY_INDEX(tty) != 0 )
   4.219 +        return count;
   4.220 +
   4.221      spin_lock_irqsave(&xencons_lock, flags);
   4.222  
   4.223      for ( i = 0; i < count; i++ )
   4.224 @@ -454,6 +490,9 @@ static void xencons_put_char(struct tty_
   4.225  {
   4.226      unsigned long flags;
   4.227  
   4.228 +    if ( TTY_INDEX(tty) != 0 )
   4.229 +        return;
   4.230 +
   4.231      spin_lock_irqsave(&xencons_lock, flags);
   4.232      (void)__xencons_put_char(ch);
   4.233      spin_unlock_irqrestore(&xencons_lock, flags);
   4.234 @@ -463,6 +502,9 @@ static void xencons_flush_chars(struct t
   4.235  {
   4.236      unsigned long flags;
   4.237  
   4.238 +    if ( TTY_INDEX(tty) != 0 )
   4.239 +        return;
   4.240 +
   4.241      spin_lock_irqsave(&xencons_lock, flags);
   4.242      __xencons_tx_flush();
   4.243      spin_unlock_irqrestore(&xencons_lock, flags);    
   4.244 @@ -472,7 +514,10 @@ static void xencons_wait_until_sent(stru
   4.245  {
   4.246      unsigned long orig_jiffies = jiffies;
   4.247  
   4.248 -    while ( tty->driver->chars_in_buffer(tty) )
   4.249 +    if ( TTY_INDEX(tty) != 0 )
   4.250 +        return;
   4.251 +
   4.252 +    while ( DRV(tty->driver)->chars_in_buffer(tty) )
   4.253      {
   4.254          set_current_state(TASK_INTERRUPTIBLE);
   4.255          schedule_timeout(1);
   4.256 @@ -487,16 +532,12 @@ static void xencons_wait_until_sent(stru
   4.257  
   4.258  static int xencons_open(struct tty_struct *tty, struct file *filp)
   4.259  {
   4.260 -    int line;
   4.261      unsigned long flags;
   4.262  
   4.263 +    if ( TTY_INDEX(tty) != 0 )
   4.264 +        return -ENODEV;
   4.265 +
   4.266      MOD_INC_USE_COUNT;
   4.267 -    line = tty->index;
   4.268 -    if ( line < 0 || line >= NUM_XENCONS )
   4.269 -    {
   4.270 -        MOD_DEC_USE_COUNT;
   4.271 -        return -ENODEV;
   4.272 -    }
   4.273  
   4.274      spin_lock_irqsave(&xencons_lock, flags);
   4.275      tty->driver_data = NULL;
   4.276 @@ -512,12 +553,15 @@ static void xencons_close(struct tty_str
   4.277  {
   4.278      unsigned long flags;
   4.279  
   4.280 +    if ( TTY_INDEX(tty) != 0 )
   4.281 +        return;
   4.282 +
   4.283      if ( tty->count == 1 )
   4.284      {
   4.285          tty->closing = 1;
   4.286          tty_wait_until_sent(tty, 0);
   4.287 -        if ( tty->driver->flush_buffer != NULL )
   4.288 -            tty->driver->flush_buffer(tty);
   4.289 +        if ( DRV(tty->driver)->flush_buffer != NULL )
   4.290 +            DRV(tty->driver)->flush_buffer(tty);
   4.291          if ( tty->ldisc.flush_buffer != NULL )
   4.292              tty->ldisc.flush_buffer(tty);
   4.293          tty->closing = 0;
   4.294 @@ -529,6 +573,7 @@ static void xencons_close(struct tty_str
   4.295      MOD_DEC_USE_COUNT;
   4.296  }
   4.297  
   4.298 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   4.299  static struct tty_operations xencons_ops = {
   4.300      .open = xencons_open,
   4.301      .close = xencons_close,
   4.302 @@ -543,42 +588,66 @@ static struct tty_operations xencons_ops
   4.303      .unthrottle = xencons_unthrottle,
   4.304      .wait_until_sent = xencons_wait_until_sent,
   4.305  };
   4.306 +#endif
   4.307  
   4.308  static int __init xencons_init(void)
   4.309  {
   4.310 -    xencons_driver = alloc_tty_driver(NUM_XENCONS); /* XXX */
   4.311 -    if (!xencons_driver)
   4.312 -	return -ENOMEM;
   4.313 -
   4.314 -    xencons_driver->major           = TTY_MAJOR;
   4.315 -    xencons_driver->type            = TTY_DRIVER_TYPE_SERIAL;
   4.316 -    xencons_driver->subtype         = SERIAL_TYPE_NORMAL;
   4.317 -    xencons_driver->init_termios    = tty_std_termios;
   4.318 -    xencons_driver->flags           = 
   4.319 -        TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_NO_DEVFS;
   4.320 -    xencons_driver->termios         = xencons_termios;
   4.321 -    xencons_driver->termios_locked  = xencons_termios_locked;
   4.322 -
   4.323      if ( xc_mode == XC_OFF )
   4.324          return 0;
   4.325  
   4.326 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   4.327 +    xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ? 
   4.328 +                                      1 : MAX_NR_CONSOLES);
   4.329 +    if ( xencons_driver == NULL )
   4.330 +        return -ENOMEM;
   4.331 +#else
   4.332 +    memset(&xencons_driver, 0, sizeof(struct tty_driver));
   4.333 +    xencons_driver.magic       = TTY_DRIVER_MAGIC;
   4.334 +    xencons_driver.refcount    = &xencons_refcount;
   4.335 +    xencons_driver.table       = xencons_table;
   4.336 +    xencons_driver.num         = (xc_mode == XC_SERIAL) ? 1 : MAX_NR_CONSOLES;
   4.337 +#endif
   4.338 +
   4.339 +    DRV(xencons_driver)->major           = TTY_MAJOR;
   4.340 +    DRV(xencons_driver)->type            = TTY_DRIVER_TYPE_SERIAL;
   4.341 +    DRV(xencons_driver)->subtype         = SERIAL_TYPE_NORMAL;
   4.342 +    DRV(xencons_driver)->init_termios    = tty_std_termios;
   4.343 +    DRV(xencons_driver)->flags           = 
   4.344 +        TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_NO_DEVFS;
   4.345 +    DRV(xencons_driver)->termios         = xencons_termios;
   4.346 +    DRV(xencons_driver)->termios_locked  = xencons_termios_locked;
   4.347 +
   4.348      if ( xc_mode == XC_SERIAL )
   4.349      {
   4.350 -        xencons_driver->name        = "ttyS";
   4.351 -        xencons_driver->minor_start = 64;
   4.352 -        xencons_driver->num         = 1;
   4.353 +        DRV(xencons_driver)->name        = "ttyS";
   4.354 +        DRV(xencons_driver)->minor_start = 64;
   4.355      }
   4.356      else
   4.357      {
   4.358 -        xencons_driver->name        = "tty";
   4.359 -        xencons_driver->minor_start = 1;
   4.360 -        xencons_driver->num         = MAX_NR_CONSOLES;
   4.361 +        DRV(xencons_driver)->name        = "tty";
   4.362 +        DRV(xencons_driver)->minor_start = 1;
   4.363      }
   4.364  
   4.365 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   4.366      tty_set_operations(xencons_driver, &xencons_ops);
   4.367 +#else
   4.368 +    xencons_driver.open            = xencons_open;
   4.369 +    xencons_driver.close           = xencons_close;
   4.370 +    xencons_driver.write           = xencons_write;
   4.371 +    xencons_driver.write_room      = xencons_write_room;
   4.372 +    xencons_driver.put_char        = xencons_put_char;
   4.373 +    xencons_driver.flush_chars     = xencons_flush_chars;
   4.374 +    xencons_driver.chars_in_buffer = xencons_chars_in_buffer;
   4.375 +    xencons_driver.send_xchar      = xencons_send_xchar;
   4.376 +    xencons_driver.flush_buffer    = xencons_flush_buffer;
   4.377 +    xencons_driver.throttle        = xencons_throttle;
   4.378 +    xencons_driver.unthrottle      = xencons_unthrottle;
   4.379 +    xencons_driver.wait_until_sent = xencons_wait_until_sent;
   4.380 +#endif
   4.381  
   4.382 -    if ( tty_register_driver(xencons_driver) )
   4.383 -        panic("Couldn't register Xen virtual console driver as %s\n",xencons_driver->name);
   4.384 +    if ( tty_register_driver(DRV(xencons_driver)) )
   4.385 +        panic("Couldn't register Xen virtual console driver as %s\n",
   4.386 +              DRV(xencons_driver)->name);
   4.387  
   4.388      if ( start_info.flags & SIF_INITDOMAIN )
   4.389      {
   4.390 @@ -591,7 +660,8 @@ static int __init xencons_init(void)
   4.391          (void)ctrl_if_register_receiver(CMSG_CONSOLE, xencons_rx, 0);
   4.392      }
   4.393  
   4.394 -    printk("Xen virtual console successfully installed as %s\n",xencons_driver->name);
   4.395 +    printk("Xen virtual console successfully installed as %s\n",
   4.396 +           DRV(xencons_driver)->name);
   4.397      
   4.398      return 0;
   4.399  }
   4.400 @@ -600,7 +670,7 @@ static void __exit xencons_fini(void)
   4.401  {
   4.402      int ret;
   4.403  
   4.404 -    if ( (ret = tty_unregister_driver(xencons_driver)) != 0 )
   4.405 +    if ( (ret = tty_unregister_driver(DRV(xencons_driver))) != 0 )
   4.406          printk(KERN_ERR "Unable to unregister Xen console driver: %d\n", ret);
   4.407  
   4.408      if ( start_info.flags & SIF_INITDOMAIN )