ia64/xen-unstable

changeset 156:01e412fb646d

bitkeeper revision 1.22.5.2 (3e4cda483kJoy5YzPXw3Pl7VBmCgGg)

compile-time support (!) for mounting local root
author smh22@boulderdash.cl.cam.ac.uk
date Fri Feb 14 12:00:08 2003 +0000 (2003-02-14)
parents ba73696088e6
children dad92510ffbb
files .rootkeys xen-2.4.16/common/domain.c xenolinux-2.4.16-sparse/arch/xeno/drivers/block/block.c
line diff
     1.1 --- a/.rootkeys	Fri Feb 14 11:58:16 2003 +0000
     1.2 +++ b/.rootkeys	Fri Feb 14 12:00:08 2003 +0000
     1.3 @@ -275,7 +275,6 @@ 3ddb79b7_rLvYZU3tOY6Wwuw_Sg3_w xenolinux
     1.4  3ddb79b8L4xnwrcvWk6nAbgKVbNkSA xenolinux-2.4.16-sparse/arch/xeno/config.in
     1.5  3ddb79b7v_Be34as7_mlzFlw65hOjQ xenolinux-2.4.16-sparse/arch/xeno/defconfig
     1.6  3ddb79b7KUvtx0knQJoRaBDZQeNidg xenolinux-2.4.16-sparse/arch/xeno/drivers/block/Makefile
     1.7 -3ddb79b6Rc0uAOGFthIFxq1KGWZ_Iw xenolinux-2.4.16-sparse/arch/xeno/drivers/block/block.c
     1.8  3e4a8cb7JECr--r1ipnrkd7NKdbUqQ xenolinux-2.4.16-sparse/arch/xeno/drivers/block/xl_block.c
     1.9  3e4a8cb7SLWsLTXQjv7ng6-3hL4pCA xenolinux-2.4.16-sparse/arch/xeno/drivers/block/xl_block_test.c
    1.10  3ddb79b7LLVJBGynxHSOh9A9l97sug xenolinux-2.4.16-sparse/arch/xeno/drivers/console/Makefile
     2.1 --- a/xen-2.4.16/common/domain.c	Fri Feb 14 11:58:16 2003 +0000
     2.2 +++ b/xen-2.4.16/common/domain.c	Fri Feb 14 12:00:08 2003 +0000
     2.3 @@ -760,7 +760,11 @@ int setup_guestos(struct task_struct *p,
     2.4          unsigned char nfsroot[70];
     2.5          snprintf(nfsroot, 70, opt_nfsroot, dom); 
     2.6          snprintf(boot, 200,
     2.7 +#if 1
     2.8                  " root=/dev/nfs ip=%s:%s:%s:%s::eth0:off nfsroot=%s",
     2.9 +#else
    2.10 +                " ro root=/dev/xhda7 ip=%s:%s:%s:%s::eth0:off arfle=%s",
    2.11 +#endif
    2.12                   quad_to_str(opt_ipbase + dom, ipbase),
    2.13                   quad_to_str(opt_nfsserv, nfsserv),
    2.14                   quad_to_str(opt_gateway, gateway),
     3.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/block/block.c	Fri Feb 14 11:58:16 2003 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,392 +0,0 @@
     3.4 -/******************************************************************************
     3.5 - * block.c
     3.6 - * 
     3.7 - * Virtual block driver for XenoLinux.
     3.8 - * 
     3.9 - * adapted from network.c
    3.10 - */
    3.11 -
    3.12 -#include <linux/config.h>
    3.13 -#include <linux/module.h>
    3.14 -
    3.15 -#include <linux/kernel.h>
    3.16 -#include <linux/sched.h>
    3.17 -#include <linux/slab.h>
    3.18 -#include <linux/string.h>
    3.19 -#include <linux/errno.h>
    3.20 -
    3.21 -#include <asm/hypervisor-ifs/block.h>
    3.22 -
    3.23 -#ifdef UNDEFINED
    3.24 -
    3.25 -#include <linux/netdevice.h>
    3.26 -#include <linux/inetdevice.h>
    3.27 -#include <linux/etherdevice.h>
    3.28 -#include <linux/skbuff.h>
    3.29 -#include <linux/init.h>
    3.30 -
    3.31 -#include <net/sock.h>
    3.32 -
    3.33 -#define BLK_TX_IRQ _EVENT_BLK_TX
    3.34 -#define BLK_RX_IRQ _EVENT_BLK_RX
    3.35 -
    3.36 -#define TX_MAX_ENTRIES (TX_RING_SIZE - 2)
    3.37 -#define RX_MAX_ENTRIES (RX_RING_SIZE - 2)
    3.38 -
    3.39 -#define TX_RING_INC(_i)    (((_i)+1) & (TX_RING_SIZE-1))
    3.40 -#define RX_RING_INC(_i)    (((_i)+1) & (RX_RING_SIZE-1))
    3.41 -#define TX_RING_ADD(_i,_j) (((_i)+(_j)) & (TX_RING_SIZE-1))
    3.42 -#define RX_RING_ADD(_i,_j) (((_i)+(_j)) & (RX_RING_SIZE-1))
    3.43 -
    3.44 -#define RX_BUF_SIZE 1600 /* Ethernet MTU + plenty of slack! */
    3.45 -
    3.46 -
    3.47 -
    3.48 -int	    network_probe(struct net_device *dev);
    3.49 -static int  network_open(struct net_device *dev);
    3.50 -static int  network_start_xmit(struct sk_buff *skb, struct net_device *dev);
    3.51 -static int  network_close(struct net_device *dev);
    3.52 -static struct net_device_stats *network_get_stats(struct net_device *dev);
    3.53 -static void network_rx_int(int irq, void *dev_id, struct pt_regs *ptregs);
    3.54 -static void network_tx_int(int irq, void *dev_id, struct pt_regs *ptregs);
    3.55 -static void network_tx_buf_gc(struct net_device *dev);
    3.56 -static void network_alloc_rx_buffers(struct net_device *dev);
    3.57 -static void network_free_rx_buffers(struct net_device *dev);
    3.58 -
    3.59 -static struct net_device dev_net_xeno;
    3.60 -
    3.61 -/*
    3.62 - * RX RING:   RX_IDX <= rx_cons <= rx_prod
    3.63 - * TX RING:   TX_IDX <= tx_cons <= tx_prod
    3.64 - * (*_IDX allocated privately here, *_cons & *_prod shared with hypervisor)
    3.65 - */
    3.66 -struct net_private
    3.67 -{
    3.68 -    struct net_device_stats stats;
    3.69 -    struct sk_buff **tx_skb_ring;
    3.70 -    struct sk_buff **rx_skb_ring;
    3.71 -    atomic_t tx_entries;
    3.72 -    unsigned int rx_idx, tx_idx, tx_full;
    3.73 -    net_ring_t *net_ring;
    3.74 -    spinlock_t tx_lock;
    3.75 -};
    3.76 -
    3.77 - 
    3.78 -int __init network_probe(struct net_device *dev)
    3.79 -{
    3.80 -    SET_MODULE_OWNER(dev);
    3.81 -
    3.82 -    memcpy(dev->dev_addr, "\xFE\xFD\x00\x00\x00\x00", 6);
    3.83 -
    3.84 -    dev->open = network_open;
    3.85 -    dev->hard_start_xmit = network_start_xmit;
    3.86 -    dev->stop = network_close;
    3.87 -    dev->get_stats = network_get_stats;
    3.88 -
    3.89 -    ether_setup(dev);
    3.90 -    
    3.91 -    return 0;
    3.92 -}
    3.93 -
    3.94 -
    3.95 -static int network_open(struct net_device *dev)
    3.96 -{
    3.97 -    struct net_private *np;
    3.98 -    int error;
    3.99 -
   3.100 -    np = kmalloc(sizeof(struct net_private), GFP_KERNEL);
   3.101 -    if ( np == NULL ) 
   3.102 -    {
   3.103 -        printk(KERN_WARNING "%s: No memory for private data\n", dev->name);
   3.104 -        return -ENOMEM;
   3.105 -    }
   3.106 -    memset(np, 0, sizeof(struct net_private));
   3.107 -    dev->priv = np;
   3.108 -
   3.109 -    spin_lock_init(&np->tx_lock);
   3.110 -
   3.111 -    atomic_set(&np->tx_entries, 0);
   3.112 -
   3.113 -    np->net_ring  = start_info.net_rings;
   3.114 -    np->net_ring->tx_prod = np->net_ring->tx_cons = np->net_ring->tx_event = 0;
   3.115 -    np->net_ring->rx_prod = np->net_ring->rx_cons = np->net_ring->rx_event = 0;
   3.116 -    np->net_ring->tx_ring = NULL;
   3.117 -    np->net_ring->rx_ring = NULL;
   3.118 -
   3.119 -    np->tx_skb_ring = kmalloc(TX_RING_SIZE * sizeof(struct sk_buff *),
   3.120 -                              GFP_KERNEL);
   3.121 -    np->rx_skb_ring = kmalloc(RX_RING_SIZE * sizeof(struct sk_buff *),
   3.122 -                              GFP_KERNEL);
   3.123 -    np->net_ring->tx_ring = kmalloc(TX_RING_SIZE * sizeof(tx_entry_t), 
   3.124 -                                  GFP_KERNEL);
   3.125 -    np->net_ring->rx_ring = kmalloc(RX_RING_SIZE * sizeof(rx_entry_t), 
   3.126 -                                  GFP_KERNEL);
   3.127 -    if ( (np->tx_skb_ring == NULL) || (np->rx_skb_ring == NULL) ||
   3.128 -         (np->net_ring->tx_ring == NULL) || (np->net_ring->rx_ring == NULL) )
   3.129 -    {
   3.130 -        printk(KERN_WARNING "%s; Could not allocate ring memory\n", dev->name);
   3.131 -        error = -ENOBUFS;
   3.132 -        goto fail;
   3.133 -    }
   3.134 -
   3.135 -    network_alloc_rx_buffers(dev);
   3.136 -
   3.137 -    error = request_irq(NET_RX_IRQ, network_rx_int, 0, "net-rx", dev);
   3.138 -    if ( error )
   3.139 -    {
   3.140 -        printk(KERN_WARNING "%s: Could not allocate receive interrupt\n",
   3.141 -               dev->name);
   3.142 -        goto fail;
   3.143 -    }
   3.144 -
   3.145 -    error = request_irq(NET_TX_IRQ, network_tx_int, 0, "net-tx", dev);
   3.146 -    if ( error )
   3.147 -    {
   3.148 -        printk(KERN_WARNING "%s: Could not allocate transmit interrupt\n",
   3.149 -               dev->name);
   3.150 -        free_irq(NET_RX_IRQ, dev);
   3.151 -        goto fail;
   3.152 -    }
   3.153 -
   3.154 -    printk("XenoLinux Virtual Network Driver installed as %s\n", dev->name);
   3.155 -
   3.156 -    netif_start_queue(dev);
   3.157 -
   3.158 -    MOD_INC_USE_COUNT;
   3.159 -
   3.160 -    return 0;
   3.161 -
   3.162 - fail:
   3.163 -    if ( np->net_ring->rx_ring ) kfree(np->net_ring->rx_ring);
   3.164 -    if ( np->net_ring->tx_ring ) kfree(np->net_ring->tx_ring);
   3.165 -    if ( np->rx_skb_ring ) kfree(np->rx_skb_ring);
   3.166 -    if ( np->tx_skb_ring ) kfree(np->tx_skb_ring);
   3.167 -    kfree(np);
   3.168 -    return error;
   3.169 -}
   3.170 -
   3.171 -
   3.172 -static void network_tx_buf_gc(struct net_device *dev)
   3.173 -{
   3.174 -    unsigned int i;
   3.175 -    struct net_private *np = dev->priv;
   3.176 -    struct sk_buff *skb;
   3.177 -    unsigned long flags;
   3.178 -
   3.179 -    spin_lock_irqsave(&np->tx_lock, flags);
   3.180 -
   3.181 -    for ( i = np->tx_idx; i != np->net_ring->tx_cons; i = TX_RING_INC(i) )
   3.182 -    {
   3.183 -        skb = np->tx_skb_ring[i];
   3.184 -        dev_kfree_skb_any(skb);
   3.185 -        atomic_dec(&np->tx_entries);
   3.186 -    }
   3.187 -
   3.188 -    np->tx_idx = i;
   3.189 -
   3.190 -    if ( np->tx_full && (atomic_read(&np->tx_entries) < TX_MAX_ENTRIES) )
   3.191 -    {
   3.192 -        np->tx_full = 0;
   3.193 -        netif_wake_queue(dev);
   3.194 -    }
   3.195 -
   3.196 -    spin_unlock_irqrestore(&np->tx_lock, flags);
   3.197 -}
   3.198 -
   3.199 -
   3.200 -static void network_alloc_rx_buffers(struct net_device *dev)
   3.201 -{
   3.202 -    unsigned int i;
   3.203 -    struct net_private *np = dev->priv;
   3.204 -    struct sk_buff *skb;
   3.205 -    unsigned int end = RX_RING_ADD(np->rx_idx, RX_MAX_ENTRIES);
   3.206 -
   3.207 -    for ( i = np->net_ring->rx_prod; i != end; i = RX_RING_INC(i) )
   3.208 -    {
   3.209 -        skb = dev_alloc_skb(RX_BUF_SIZE);
   3.210 -        if ( skb == NULL ) break;
   3.211 -        skb->dev = dev;
   3.212 -        skb_reserve(skb, 2); /* word align the IP header */
   3.213 -        np->rx_skb_ring[i] = skb;
   3.214 -        np->net_ring->rx_ring[i].addr = (unsigned long)skb->data;
   3.215 -        np->net_ring->rx_ring[i].size = RX_BUF_SIZE - 16; /* arbitrary */
   3.216 -    }
   3.217 -
   3.218 -    np->net_ring->rx_prod = i;
   3.219 -
   3.220 -    np->net_ring->rx_event = RX_RING_INC(np->rx_idx);
   3.221 -
   3.222 -    HYPERVISOR_net_update();
   3.223 -}
   3.224 -
   3.225 -
   3.226 -static void network_free_rx_buffers(struct net_device *dev)
   3.227 -{
   3.228 -    unsigned int i;
   3.229 -    struct net_private *np = dev->priv;
   3.230 -    struct sk_buff *skb;    
   3.231 -
   3.232 -    for ( i = np->rx_idx; i != np->net_ring->rx_prod; i = RX_RING_INC(i) )
   3.233 -    {
   3.234 -        skb = np->rx_skb_ring[i];
   3.235 -        dev_kfree_skb(skb);
   3.236 -    }
   3.237 -}
   3.238 -
   3.239 -
   3.240 -static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
   3.241 -{
   3.242 -    unsigned int i;
   3.243 -    struct net_private *np = (struct net_private *)dev->priv;
   3.244 -
   3.245 -    if ( np->tx_full )
   3.246 -    {
   3.247 -        printk(KERN_WARNING "%s: full queue wasn't stopped!\n", dev->name);
   3.248 -        netif_stop_queue(dev);
   3.249 -        return -ENOBUFS;
   3.250 -    }
   3.251 -
   3.252 -    i = np->net_ring->tx_prod;
   3.253 -    np->tx_skb_ring[i] = skb;
   3.254 -    np->net_ring->tx_ring[i].addr = (unsigned long)skb->data;
   3.255 -    np->net_ring->tx_ring[i].size = skb->len;
   3.256 -    np->net_ring->tx_prod = TX_RING_INC(i);
   3.257 -    atomic_inc(&np->tx_entries);
   3.258 -
   3.259 -    np->stats.tx_bytes += skb->len;
   3.260 -    np->stats.tx_packets++;
   3.261 -
   3.262 -    spin_lock_irq(&np->tx_lock);
   3.263 -    if ( atomic_read(&np->tx_entries) >= TX_MAX_ENTRIES )
   3.264 -    {
   3.265 -        np->tx_full = 1;
   3.266 -        netif_stop_queue(dev);
   3.267 -        np->net_ring->tx_event = TX_RING_ADD(np->tx_idx,
   3.268 -                                           atomic_read(&np->tx_entries) >> 1);
   3.269 -    }
   3.270 -    else
   3.271 -    {
   3.272 -        /* Avoid unnecessary tx interrupts. */
   3.273 -        np->net_ring->tx_event = TX_RING_INC(np->net_ring->tx_prod);
   3.274 -    }
   3.275 -    spin_unlock_irq(&np->tx_lock);
   3.276 -
   3.277 -    /* Must do this after setting tx_event: race with updates of tx_cons. */
   3.278 -    network_tx_buf_gc(dev);
   3.279 -
   3.280 -    HYPERVISOR_net_update();
   3.281 -
   3.282 -    return 0;
   3.283 -}
   3.284 -
   3.285 -
   3.286 -static void network_rx_int(int irq, void *dev_id, struct pt_regs *ptregs)
   3.287 -{
   3.288 -    unsigned int i;
   3.289 -    struct net_device *dev = (struct net_device *)dev_id;
   3.290 -    struct net_private *np = dev->priv;
   3.291 -    struct sk_buff *skb;
   3.292 -    
   3.293 - again:
   3.294 -    for ( i = np->rx_idx; i != np->net_ring->rx_cons; i = RX_RING_INC(i) )
   3.295 -    {
   3.296 -        skb = np->rx_skb_ring[i];
   3.297 -        skb_put(skb, np->net_ring->rx_ring[i].size);
   3.298 -        skb->protocol = eth_type_trans(skb, dev);
   3.299 -        np->stats.rx_packets++;
   3.300 -        np->stats.rx_bytes += np->net_ring->rx_ring[i].size;
   3.301 -        netif_rx(skb);
   3.302 -        dev->last_rx = jiffies;
   3.303 -    }
   3.304 -
   3.305 -    np->rx_idx = i;
   3.306 -
   3.307 -    network_alloc_rx_buffers(dev);
   3.308 -    
   3.309 -    /* Deal with hypervisor racing our resetting of rx_event. */
   3.310 -    smp_mb();
   3.311 -    if ( np->net_ring->rx_cons != i ) goto again;
   3.312 -}
   3.313 -
   3.314 -
   3.315 -static void network_tx_int(int irq, void *dev_id, struct pt_regs *ptregs)
   3.316 -{
   3.317 -    struct net_device *dev = (struct net_device *)dev_id;
   3.318 -    network_tx_buf_gc(dev);
   3.319 -}
   3.320 -
   3.321 -
   3.322 -static int network_close(struct net_device *dev)
   3.323 -{
   3.324 -    struct net_private *np = dev->priv;
   3.325 -
   3.326 -    netif_stop_queue(dev);
   3.327 -    free_irq(NET_RX_IRQ, dev);
   3.328 -    free_irq(NET_TX_IRQ, dev);
   3.329 -    network_free_rx_buffers(dev);
   3.330 -    kfree(np->net_ring->rx_ring);
   3.331 -    kfree(np->net_ring->tx_ring);
   3.332 -    kfree(np->rx_skb_ring);
   3.333 -    kfree(np->tx_skb_ring);
   3.334 -    kfree(np);
   3.335 -    MOD_DEC_USE_COUNT;
   3.336 -    return 0;
   3.337 -}
   3.338 -
   3.339 -
   3.340 -static struct net_device_stats *network_get_stats(struct net_device *dev)
   3.341 -{
   3.342 -    struct net_private *np = (struct net_private *)dev->priv;
   3.343 -    return &np->stats;
   3.344 -}
   3.345 -
   3.346 -
   3.347 -static int __init init_module(void)
   3.348 -{
   3.349 -    memset(&dev_net_xeno, 0, sizeof(dev_net_xeno));
   3.350 -    strcpy(dev_net_xeno.name, "eth%d");
   3.351 -    dev_net_xeno.init = network_probe;
   3.352 -    return (register_netdev(&dev_net_xeno) != 0) ? -EIO : 0;
   3.353 -}
   3.354 -
   3.355 -
   3.356 -static void __exit cleanup_module(void)
   3.357 -{
   3.358 -    unregister_netdev(&dev_net_xeno);
   3.359 -}
   3.360 -
   3.361 -#endif /* UNDEFINED */
   3.362 -
   3.363 -
   3.364 -static void block_initialize(void)
   3.365 -{
   3.366 -  blk_ring_t *blk_ring = start_info.blk_ring;
   3.367 -
   3.368 -  if ( blk_ring == NULL ) return;
   3.369 -
   3.370 -  blk_ring->tx_prod = blk_ring->tx_cons = blk_ring->tx_event = 0;
   3.371 -  blk_ring->rx_prod = blk_ring->rx_cons = blk_ring->rx_event = 0;
   3.372 -  blk_ring->tx_ring = NULL;
   3.373 -  blk_ring->rx_ring = NULL;
   3.374 -}
   3.375 -
   3.376 -
   3.377 -/*
   3.378 - * block_setup initialized the xeno block device driver
   3.379 - */
   3.380 -
   3.381 -static int __init init_module(void)
   3.382 -{
   3.383 -  block_initialize();
   3.384 -  printk("XenoLinux Virtual Block Device Driver installed\n");
   3.385 -  return 0;
   3.386 -}
   3.387 -
   3.388 -static void __exit cleanup_module(void)
   3.389 -{
   3.390 -  printk("XenoLinux Virtual Block Device Driver uninstalled\n");
   3.391 -}
   3.392 -
   3.393 -module_init(init_module);
   3.394 -module_exit(cleanup_module);
   3.395 -