ia64/xen-unstable

changeset 406:ca730caf1aad

bitkeeper revision 1.194 (3eaec3046yAItB06JdZkroeL7XKJxA)

xl_ide.c, xl_block.h, xl_block.c, defconfig:
Fix Xenolinux to use major 22 for /dev/hdc and /dev/hdd. Added TMPFS to defconfig.
author kaf24@scramble.cl.cam.ac.uk
date Tue Apr 29 18:23:00 2003 +0000 (2003-04-29)
parents e82d0032ab3f
children b780057c9d40
files xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c
line diff
     1.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig	Tue Apr 29 15:47:27 2003 +0000
     1.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/defconfig	Tue Apr 29 18:23:00 2003 +0000
     1.3 @@ -157,7 +157,7 @@ CONFIG_JBD=y
     1.4  # CONFIG_JFFS_FS is not set
     1.5  # CONFIG_JFFS2_FS is not set
     1.6  # CONFIG_CRAMFS is not set
     1.7 -# CONFIG_TMPFS is not set
     1.8 +CONFIG_TMPFS=y
     1.9  CONFIG_RAMFS=y
    1.10  CONFIG_ISO9660_FS=y
    1.11  CONFIG_JOLIET=y
     2.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Tue Apr 29 15:47:27 2003 +0000
     2.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Tue Apr 29 18:23:00 2003 +0000
     2.3 @@ -49,10 +49,16 @@ inline unsigned short xldev_to_physdev(k
     2.4  
     2.5      switch ( MAJOR(xldev) ) 
     2.6      { 
     2.7 -    case XLIDE_MAJOR: 
     2.8 -        physdev = XENDEV_IDE + (MINOR(xldev) >> XLIDE_PARTN_SHIFT);
     2.9 +    case XLIDE_MAJOR_0: 
    2.10 +        physdev = XENDEV_IDE + (0*XLIDE_DEVS_PER_MAJOR) +
    2.11 +            (MINOR(xldev) >> XLIDE_PARTN_SHIFT);
    2.12  	break; 
    2.13 -	
    2.14 +
    2.15 +    case XLIDE_MAJOR_1:
    2.16 +	physdev = XENDEV_IDE + (1*XLIDE_DEVS_PER_MAJOR) +
    2.17 +            (MINOR(xldev) >> XLIDE_PARTN_SHIFT);
    2.18 +        break;
    2.19 +
    2.20      case XLSCSI_MAJOR: 
    2.21          physdev = XENDEV_SCSI + (MINOR(xldev) >> XLSCSI_PARTN_SHIFT);
    2.22  	break; 
    2.23 @@ -74,8 +80,12 @@ static inline struct gendisk *xldev_to_g
    2.24  
    2.25      switch ( MAJOR(xldev) ) 
    2.26      { 
    2.27 -    case XLIDE_MAJOR: 
    2.28 -        gd = xlide_gendisk;
    2.29 +    case XLIDE_MAJOR_0: 
    2.30 +        gd = xlide_gendisk[0];
    2.31 +	break; 
    2.32 +	
    2.33 +    case XLIDE_MAJOR_1: 
    2.34 +        gd = xlide_gendisk[1];
    2.35  	break; 
    2.36  	
    2.37      case XLSCSI_MAJOR: 
    2.38 @@ -157,7 +167,7 @@ int xenolinux_block_ioctl(struct inode *
    2.39      case BLKSSZGET:
    2.40  	switch ( MAJOR(dev) )
    2.41          {
    2.42 -	case XLIDE_MAJOR: 
    2.43 +	case XLIDE_MAJOR_0: 
    2.44  	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET, 
    2.45  			  xlide_hwsect(MINOR(dev)));
    2.46  	    return xlide_hwsect(MINOR(dev)); 
     3.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h	Tue Apr 29 15:47:27 2003 +0000
     3.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h	Tue Apr 29 18:23:00 2003 +0000
     3.3 @@ -40,18 +40,33 @@
     3.4  #endif
     3.5  
     3.6  /* XL IDE and SCSI use same major/minor numbers as normal Linux devices. */
     3.7 -#define XLIDE_MAJOR IDE0_MAJOR
     3.8 +#define XLIDE_MAJOR_0 IDE0_MAJOR
     3.9 +#define XLIDE_MAJOR_1 IDE1_MAJOR
    3.10  #define XLSCSI_MAJOR SCSI_DISK0_MAJOR
    3.11  
    3.12 -/* IDE has < 64 partitions per device. VIRT and SCSI have < 16. */
    3.13 -#define PARTN_SHIFT(_dev) ((MAJOR(_dev)==IDE0_MAJOR) ? 6 : 4)
    3.14  #define XLIDE_PARTN_SHIFT  6
    3.15  #define XLSCSI_PARTN_SHIFT 4
    3.16  #define XLVIRT_PARTN_SHIFT 4
    3.17  
    3.18 -#define XLIDE_DEVS_PER_MAJOR  (256 >> XLIDE_PARTN_SHIFT)
    3.19 -#define XLSCSI_DEVS_PER_MAJOR (256 >> XLSCSI_PARTN_SHIFT)
    3.20 -#define XLVIRT_DEVS_PER_MAJOR (256 >> XLVIRT_PARTN_SHIFT)
    3.21 +static inline int PARTN_SHIFT(kdev_t dev)
    3.22 +{
    3.23 +    switch ( MAJOR(dev) )
    3.24 +    {
    3.25 +    case XLIDE_MAJOR_0:
    3.26 +    case XLIDE_MAJOR_1:
    3.27 +        return XLIDE_PARTN_SHIFT;
    3.28 +    case XLSCSI_MAJOR:
    3.29 +        return XLSCSI_PARTN_SHIFT;
    3.30 +    case XLVIRT_MAJOR:
    3.31 +        return XLVIRT_PARTN_SHIFT;
    3.32 +    default:
    3.33 +        BUG();
    3.34 +    }
    3.35 +}
    3.36 +
    3.37 +#define XLIDE_DEVS_PER_MAJOR   2
    3.38 +#define XLSCSI_DEVS_PER_MAJOR 16
    3.39 +#define XLVIRT_DEVS_PER_MAJOR 16
    3.40  
    3.41  /*
    3.42   * We have one of these per XL-IDE, XL-SCSI, and XL-VIRT device.
    3.43 @@ -77,7 +92,7 @@ extern void do_xlblk_request (request_qu
    3.44  extern int  xlide_init(xen_disk_info_t *xdi);
    3.45  extern int  xlide_hwsect(int minor); 
    3.46  extern void xlide_cleanup(void); 
    3.47 -extern struct gendisk *xlide_gendisk;
    3.48 +extern struct gendisk *xlide_gendisk[];
    3.49  
    3.50  /* Fake SCSI subsystem. */
    3.51  extern int  xlscsi_init(xen_disk_info_t *xdi);
     4.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c	Tue Apr 29 15:47:27 2003 +0000
     4.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c	Tue Apr 29 18:23:00 2003 +0000
     4.3 @@ -5,8 +5,6 @@
     4.4   */
     4.5  
     4.6  #include "xl_block.h"
     4.7 -
     4.8 -#define MAJOR_NR XLIDE_MAJOR 
     4.9  #include <linux/blk.h>
    4.10  
    4.11  #define XLIDE_MAX         256
    4.12 @@ -15,7 +13,7 @@ static int xlide_blksize_size[XLIDE_MAX]
    4.13  static int xlide_hardsect_size[XLIDE_MAX];
    4.14  static int xlide_max_sectors[XLIDE_MAX];
    4.15  
    4.16 -struct gendisk *xlide_gendisk = NULL;
    4.17 +struct gendisk *xlide_gendisk[2] = { NULL };
    4.18  
    4.19  static struct block_device_operations xlide_block_fops = 
    4.20  {
    4.21 @@ -31,63 +29,41 @@ int xlide_hwsect(int minor)
    4.22      return xlide_hardsect_size[minor]; 
    4.23  } 
    4.24  
    4.25 -
    4.26 -int xlide_init(xen_disk_info_t *xdi) 
    4.27 +static int get_major(int major)
    4.28  {
    4.29 -    int i, result, units, minors, disk;
    4.30 -    unsigned short minor; 
    4.31 -    struct gendisk *gd;
    4.32 -    char buf[64]; 
    4.33 -
    4.34 -    /* If we don't have any usable IDE devices we may as well bail now. */
    4.35 -    units = 0;
    4.36 -    for ( i = 0; i < xdi->count; i++ )
    4.37 -        if ( IS_IDE_XENDEV(xdi->disks[i].device) &&
    4.38 -             ((xdi->disks[i].device & XENDEV_IDX_MASK) <
    4.39 -              XLIDE_DEVS_PER_MAJOR) ) 
    4.40 -            units++;
    4.41 -    if ( units == 0 ) return 0;
    4.42 -
    4.43 -    SET_MODULE_OWNER(&xlide_block_fops);
    4.44 +    int r = register_blkdev(major, XLIDE_MAJOR_NAME, &xlide_block_fops);
    4.45 +    if ( r < 0 )
    4.46 +        printk (KERN_ALERT "XL IDE: can't get major %d\n", XLIDE_MAJOR_0);
    4.47 +    return r;
    4.48 +}
    4.49  
    4.50 -    result = register_blkdev(XLIDE_MAJOR, XLIDE_MAJOR_NAME, 
    4.51 -                             &xlide_block_fops);
    4.52 -    if ( result < 0 )
    4.53 -    {
    4.54 -	printk (KERN_ALERT "XL IDE: can't get major %d\n", XLIDE_MAJOR);
    4.55 -	return result;
    4.56 -    }
    4.57 +static struct gendisk *setup_major(xen_disk_info_t *xdi, int base, int major)
    4.58 +{
    4.59 +    int i, minors, disk, units = 2;
    4.60 +    unsigned short minor; 
    4.61 +    unsigned char buf[64];
    4.62 +    struct gendisk *gd;
    4.63  
    4.64 -    /* Initialize global arrays. */
    4.65 -    for ( i = 0; i < XLIDE_MAX; i++ )
    4.66 -    {
    4.67 -	xlide_blksize_size[i]  = 512;
    4.68 -	xlide_hardsect_size[i] = 512;
    4.69 -	xlide_max_sectors[i]   = 128;
    4.70 -    }
    4.71 +    blk_size[major]      = NULL;
    4.72 +    blksize_size[major]  = xlide_blksize_size + base*XLIDE_DEVS_PER_MAJOR;
    4.73 +    hardsect_size[major] = xlide_hardsect_size + base*XLIDE_DEVS_PER_MAJOR;
    4.74 +    max_sectors[major]   = xlide_max_sectors + base*XLIDE_DEVS_PER_MAJOR;
    4.75 +    read_ahead[major]    = 8;
    4.76  
    4.77 -    blk_size[XLIDE_MAJOR]      = NULL;
    4.78 -    blksize_size[XLIDE_MAJOR]  = xlide_blksize_size;
    4.79 -    hardsect_size[XLIDE_MAJOR] = xlide_hardsect_size;
    4.80 -    max_sectors[XLIDE_MAJOR]   = xlide_max_sectors;
    4.81 -    read_ahead[XLIDE_MAJOR]    = 8;
    4.82 -
    4.83 -    blk_init_queue(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), do_xlblk_request);
    4.84 +    blk_init_queue(BLK_DEFAULT_QUEUE(major), do_xlblk_request);
    4.85  
    4.86      /*
    4.87 -     * Turn off barking 'headactive' mode. We dequeue buffer heads as
    4.88 -     * soon as we pass them down to Xen.
    4.89 +     * Turn off barking 'headactive' mode. We dequeue buffer heads as soon as 
    4.90 +     * we pass them down to Xen.
    4.91       */
    4.92 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), 0);
    4.93 -
    4.94 -    units = XLIDE_MAX >> XLIDE_PARTN_SHIFT;
    4.95 +    blk_queue_headactive(BLK_DEFAULT_QUEUE(major), 0);
    4.96  
    4.97      /* Construct an appropriate gendisk structure. */
    4.98      minors    = units * (1<<XLIDE_PARTN_SHIFT);
    4.99      gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
   4.100      gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
   4.101      gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
   4.102 -    gd->major        = XLIDE_MAJOR;
   4.103 +    gd->major        = major;
   4.104      gd->major_name   = XLIDE_MAJOR_NAME;
   4.105      gd->minor_shift  = XLIDE_PARTN_SHIFT; 
   4.106      gd->max_p	     = 1<<XLIDE_PARTN_SHIFT;
   4.107 @@ -102,92 +78,123 @@ int xlide_init(xen_disk_info_t *xdi)
   4.108      memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
   4.109      memset(gd->flags, 0, sizeof(*gd->flags) * units);
   4.110      memset(gd->real_devices, 0, sizeof(xl_disk_t) * units);
   4.111 -    xlide_gendisk = gd;
   4.112      add_gendisk(gd);
   4.113      
   4.114      /* Now register each disk in turn. */
   4.115      for ( i = 0; i < xdi->count; i++ )
   4.116      {
   4.117          disk  = xdi->disks[i].device & XENDEV_IDX_MASK;
   4.118 -	minor = disk << XLIDE_PARTN_SHIFT; 
   4.119 +        minor = (disk-base) << XLIDE_PARTN_SHIFT; 
   4.120  
   4.121 -
   4.122 -        if ( !IS_IDE_XENDEV(xdi->disks[i].device) || 
   4.123 -             (disk >= XLIDE_DEVS_PER_MAJOR) ) 
   4.124 +        if ( !IS_IDE_XENDEV(xdi->disks[i].device) ||
   4.125 +             (disk < base) || (disk >= (base + XLIDE_DEVS_PER_MAJOR)) ) 
   4.126              continue;
   4.127  
   4.128          ((xl_disk_t *)gd->real_devices)[disk].capacity =
   4.129              xdi->disks[i].capacity;
   4.130  
   4.131 -
   4.132 -	switch (xdi->disks[i].type) { 
   4.133 -	case XD_TYPE_CDROM:
   4.134 -	    set_device_ro(MKDEV(XLIDE_MAJOR, minor), 1); 
   4.135 -	    // fall through
   4.136 +        switch (xdi->disks[i].type) 
   4.137 +        { 
   4.138 +        case XD_TYPE_CDROM:
   4.139 +            set_device_ro(MKDEV(major, minor), 1); 
   4.140  
   4.141 -	case XD_TYPE_FLOPPY: 
   4.142 -	case XD_TYPE_TAPE:
   4.143 -	    gd->flags[disk] = GENHD_FL_REMOVABLE; 
   4.144 -	    printk(KERN_ALERT "Skipping partition check on %s /dev/%s\n", 
   4.145 -		   xdi->disks[i].type == XD_TYPE_CDROM ? "cdrom" : 
   4.146 -		   (xdi->disks[i].type == XD_TYPE_TAPE ? "tape" : "floppy"), 
   4.147 -		   disk_name(gd, minor, buf)); 
   4.148 -	    break; 
   4.149 +        case XD_TYPE_FLOPPY: 
   4.150 +        case XD_TYPE_TAPE:
   4.151 +            gd->flags[disk] = GENHD_FL_REMOVABLE; 
   4.152 +            printk(KERN_ALERT "Skipping partition check on %s /dev/%s\n", 
   4.153 +                   xdi->disks[i].type==XD_TYPE_CDROM ? "cdrom" : 
   4.154 +                   (xdi->disks[i].type==XD_TYPE_TAPE ? "tape" : "floppy"), 
   4.155 +                   disk_name(gd, minor, buf)); 
   4.156 +            break; 
   4.157  
   4.158 -	case XD_TYPE_DISK: 
   4.159 -	    register_disk(gd, MKDEV(XLIDE_MAJOR, minor), 1<<XLIDE_PARTN_SHIFT, 
   4.160 -			  &xlide_block_fops, xdi->disks[i].capacity);
   4.161 -	    break; 
   4.162 +        case XD_TYPE_DISK: 
   4.163 +            register_disk(gd, 
   4.164 +                          MKDEV(major, minor), 
   4.165 +                          1<<XLIDE_PARTN_SHIFT, 
   4.166 +                          &xlide_block_fops, xdi->disks[i].capacity);
   4.167 +            break; 
   4.168  
   4.169 -	default: 
   4.170 -	    printk(KERN_ALERT "XenoLinux: unknown ide device type %d\n", 
   4.171 -		   xdi->disks[i].type); 
   4.172 -	    break; 
   4.173 -	}
   4.174 +        default: 
   4.175 +            printk(KERN_ALERT "XenoLinux: unknown ide device type %d\n", 
   4.176 +                   xdi->disks[i].type); 
   4.177 +            break; 
   4.178 +        }
   4.179 +    }
   4.180 +
   4.181 +    return gd;
   4.182 +}
   4.183  
   4.184  
   4.185 +int xlide_init(xen_disk_info_t *xdi) 
   4.186 +{
   4.187 +    int i, units;
   4.188 +
   4.189 +    /* If we don't have any usable IDE devices we may as well bail now. */
   4.190 +    units = 0;
   4.191 +    for ( i = 0; i < xdi->count; i++ )
   4.192 +        if ( IS_IDE_XENDEV(xdi->disks[i].device) &&
   4.193 +             ((xdi->disks[i].device & XENDEV_IDX_MASK) <
   4.194 +              XLIDE_DEVS_PER_MAJOR) ) 
   4.195 +            units++;
   4.196 +    if ( units == 0 ) return 0;
   4.197 +
   4.198 +    SET_MODULE_OWNER(&xlide_block_fops);
   4.199 +    
   4.200 +    if ( get_major(XLIDE_MAJOR_0) < 0 )
   4.201 +        return 0;
   4.202 +    if ( get_major(XLIDE_MAJOR_1) < 0 )
   4.203 +    {
   4.204 +        (void)unregister_blkdev(XLIDE_MAJOR_0, XLIDE_MAJOR_NAME);
   4.205 +        return 0;
   4.206      }
   4.207  
   4.208 -    printk(KERN_ALERT 
   4.209 -	   "XenoLinux Virtual IDE Device Driver installed [device: %d]\n",
   4.210 -	   XLIDE_MAJOR);
   4.211 +    /* Initialize global arrays. */
   4.212 +    for ( i = 0; i < XLIDE_MAX; i++ )
   4.213 +    {
   4.214 +        xlide_blksize_size[i]  = 512;
   4.215 +        xlide_hardsect_size[i] = 512;
   4.216 +        xlide_max_sectors[i]   = 128;
   4.217 +    }
   4.218 +
   4.219 +    xlide_gendisk[0] = setup_major(xdi, 0, XLIDE_MAJOR_0);
   4.220 +    xlide_gendisk[1] = setup_major(xdi, 2, XLIDE_MAJOR_1);
   4.221  
   4.222      return 0;
   4.223  }
   4.224  
   4.225  
   4.226 -void xlide_cleanup(void)
   4.227 +static void cleanup_major(int major)
   4.228  {
   4.229 -    if ( xlide_gendisk == NULL ) return;
   4.230 -
   4.231 -    blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLIDE_MAJOR));
   4.232 +    blk_cleanup_queue(BLK_DEFAULT_QUEUE(major));
   4.233  
   4.234 -    xlide_gendisk = NULL;
   4.235 -
   4.236 -    read_ahead[XLIDE_MAJOR] = 0;
   4.237 +    read_ahead[major] = 0;
   4.238  
   4.239 -    if ( blksize_size[XLIDE_MAJOR] != NULL )
   4.240 +    if ( blksize_size[major] != NULL )
   4.241      { 
   4.242 -	kfree(blksize_size[XLIDE_MAJOR]);
   4.243 -        blksize_size[XLIDE_MAJOR] = NULL;
   4.244 +	kfree(blksize_size[major]);
   4.245 +        blksize_size[major] = NULL;
   4.246      }
   4.247  
   4.248 -    if ( hardsect_size[XLIDE_MAJOR] != NULL )
   4.249 +    if ( hardsect_size[major] != NULL )
   4.250      { 
   4.251 -	kfree(hardsect_size[XLIDE_MAJOR]);
   4.252 -        hardsect_size[XLIDE_MAJOR] = NULL;
   4.253 +	kfree(hardsect_size[major]);
   4.254 +        hardsect_size[major] = NULL;
   4.255      }
   4.256      
   4.257 -    if ( max_sectors[XLIDE_MAJOR] != NULL )
   4.258 +    if ( max_sectors[major] != NULL )
   4.259      { 
   4.260 -	kfree(max_sectors[XLIDE_MAJOR]);
   4.261 -        max_sectors[XLIDE_MAJOR] = NULL;
   4.262 +	kfree(max_sectors[major]);
   4.263 +        max_sectors[major] = NULL;
   4.264      }
   4.265      
   4.266 -    if ( unregister_blkdev(XLIDE_MAJOR, XLIDE_MAJOR_NAME) != 0 )
   4.267 -    {
   4.268 -	printk(KERN_ALERT
   4.269 -	       "XenoLinux Virtual IDE Device Driver uninstalled w/ errs\n");
   4.270 -    }
   4.271 +    (void)unregister_blkdev(major, XLIDE_MAJOR_NAME);
   4.272  }
   4.273  
   4.274 +void xlide_cleanup(void)
   4.275 +{
   4.276 +    if ( xlide_gendisk[0] == NULL ) return;
   4.277 +    xlide_gendisk[0] = NULL;
   4.278 +    cleanup_major(XLIDE_MAJOR_0);
   4.279 +    cleanup_major(XLIDE_MAJOR_1);
   4.280 +}
   4.281 +