ia64/xen-unstable

changeset 264:2e679e814ec4

bitkeeper revision 1.110 (3e67f829AwB4Vv_qPsJlN_yjkdepyg)

xl_block.h:
new file
Many files:
Cleaned up new blkdev world.
.del-blk.h~f91949f6390760d:
Delete: xenolinux-2.4.21-pre4-sparse/include/linux/blk.h
.del-xl_block_test.c~b3dce903a84011b8:
Delete: xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block_test.c
.del-xeno-major.h~d739160829760724:
Delete: xen/include/hypervisor-ifs/xeno-major.h
.del-grok.c~eca1f7a23736b451:
Delete: xen/drivers/block/grok.c
author kaf24@labyrinth.cl.cam.ac.uk
date Fri Mar 07 01:38:49 2003 +0000 (2003-03-07)
parents 9888f92572ba
children 789c47e6318d
files .rootkeys xen/common/kernel.c xen/drivers/block/grok.c xen/drivers/block/xen_block.c xen/drivers/block/xen_segment.c xen/drivers/ide/ide-xeno.c xen/drivers/scsi/aacraid/linit.c xen/drivers/scsi/scsi.c xen/drivers/scsi/scsi_lib.c xen/drivers/scsi/scsi_module.c.inc xen/drivers/scsi/sd.c xen/include/hypervisor-ifs/block.h xen/include/hypervisor-ifs/xeno-major.h xen/include/xeno/major.h xen/include/xeno/segment.h xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/Makefile 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_block_test.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment_proc.c xenolinux-2.4.21-pre4-sparse/include/linux/blk.h xenolinux-2.4.21-pre4-sparse/include/linux/major.h xenolinux-2.4.21-pre4-sparse/init/do_mounts.c
line diff
     1.1 --- a/.rootkeys	Thu Mar 06 16:54:15 2003 +0000
     1.2 +++ b/.rootkeys	Fri Mar 07 01:38:49 2003 +0000
     1.3 @@ -251,7 +251,6 @@ 3ddb79beWzgPS8ozf2BL2g3ZkiWhhQ xen/drive
     1.4  3ddb79be04dyXzyXqDbMRS_1funwXQ xen/drivers/block/blkpg.c
     1.5  3ddb79beME_0abStePF6fU8XLuQnWw xen/drivers/block/elevator.c
     1.6  3ddb79beNQVrdGyoI4njXhgAjD6a4A xen/drivers/block/genhd.c
     1.7 -3e677183FxihZVsJDCnvV2S0-FEZyA xen/drivers/block/grok.c
     1.8  3ddb79beyWwLRP_BiM2t1JKgr_plEw xen/drivers/block/ll_rw_blk.c
     1.9  3e4a8cb7RhubVgsPwO7cK0pgAN8WCQ xen/drivers/block/xen_block.c
    1.10  3e5d129asHNyZOjBKTkqs-9AFzxemA xen/drivers/block/xen_segment.c
    1.11 @@ -383,7 +382,6 @@ 3ddb79c3uPGcP_l_2xyGgBSWd5aC-Q xen/inclu
    1.12  3ddb79c2YTaZwOqWin9-QNgHge5RVw xen/include/hypervisor-ifs/block.h
    1.13  3ddb79c25UE59iu4JJcbRalx95mvcg xen/include/hypervisor-ifs/hypervisor-if.h
    1.14  3ddb79c2oRPrzClk3zbTkRHlpumzKA xen/include/hypervisor-ifs/network.h
    1.15 -3e676eb5yHx7feWgYoqlwD2Z9WsY1w xen/include/hypervisor-ifs/xeno-major.h
    1.16  3ddb79c4qbCoOFHrv9sCGshbWzBVlQ xen/include/scsi/scsi.h
    1.17  3ddb79c4R4iVwqIIeychVQYmIH4FUg xen/include/scsi/scsi_ioctl.h
    1.18  3ddb79c4yw_mfd4Uikn3v_IOPRpa1Q xen/include/scsi/scsicam.h
    1.19 @@ -477,7 +475,7 @@ 3e6377f8Me8IqtvEhb70XFgOvqQH7A xenolinux
    1.20  3e6377fbMjXWAQd0XN0FWv4fDEo6fg xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/balloon/dom_mem_ops.h
    1.21  3e5a4e65iHEuC5sjFhj42XALYbLVRw xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/Makefile
    1.22  3e5a4e65pP5spJErBW69pJxSSdK9RA xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c
    1.23 -3e5a4e65GtI9JZRAjuRdXaxt_4ohyQ xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block_test.c
    1.24 +3e67f822FOPwqHiaRKbrskgWgoNL5g xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h
    1.25  3e677190SjkzJIvFifRVeYpIZOCtYA xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c
    1.26  3e677193nOKKTLJzcAu4SYdbZaia8g xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c
    1.27  3e676eb5RXnHzSHgA1BvM0B1aIm4qg xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c
    1.28 @@ -638,7 +636,6 @@ 3e5a4e68vggReonfTJ1gdzYjFaOSKw xenolinux
    1.29  3e5a4e68QPC4T0aOA61QgK2SGDPVVA xenolinux-2.4.21-pre4-sparse/include/asm-xeno/user.h
    1.30  3e5a4e68g2boOp0d45bjtwugxQ8zNw xenolinux-2.4.21-pre4-sparse/include/asm-xeno/vga.h
    1.31  3e5a4e68AB-TTHj1oXtqVJvUo9jzIg xenolinux-2.4.21-pre4-sparse/include/asm-xeno/xor.h
    1.32 -3e5a4e68-X9_qn9HYcRvUFNc8htBSw xenolinux-2.4.21-pre4-sparse/include/linux/blk.h
    1.33  3e5a4e68WLX3B8owTvktP3HHOtznPQ xenolinux-2.4.21-pre4-sparse/include/linux/major.h
    1.34  3e5a4e686V0nioX2ZpFf056sgvdiQw xenolinux-2.4.21-pre4-sparse/include/linux/sunrpc/debug.h
    1.35  3e5a4e68W_hpMlM3u_-QOKMp3gzcwQ xenolinux-2.4.21-pre4-sparse/init/do_mounts.c
     2.1 --- a/xen/common/kernel.c	Thu Mar 06 16:54:15 2003 +0000
     2.2 +++ b/xen/common/kernel.c	Fri Mar 07 01:38:49 2003 +0000
     2.3 @@ -42,6 +42,7 @@ void start_of_day(void);
     2.4  
     2.5  /* Command line options and variables. */
     2.6  unsigned long opt_dom0_ip = 0;
     2.7 +unsigned int opt_ser_baud = 9600;  /* default baud for COM1 */
     2.8  unsigned int opt_dom0_mem = 16000; /* default kbytes for DOM0 */
     2.9  unsigned int opt_ne_base = 0; /* NE2k NICs cannot be probed */
    2.10  unsigned char opt_ifname[10] = "eth0";
    2.11 @@ -52,6 +53,7 @@ static struct {
    2.12      int type;
    2.13      void *var;
    2.14  } opts[] = {
    2.15 +    { "ser_baud", OPT_UINT, &opt_ser_baud },
    2.16      { "dom0_ip",  OPT_IP,   &opt_dom0_ip },
    2.17      { "dom0_mem", OPT_UINT, &opt_dom0_mem }, 
    2.18      { "ne_base",  OPT_UINT, &opt_ne_base },
    2.19 @@ -69,12 +71,17 @@ void cmain (unsigned long magic, multibo
    2.20      unsigned char *cmdline;
    2.21      int i;
    2.22  
    2.23 -    init_serial();
    2.24 +    /*
    2.25 +     * Clear the screen. Note that serial output cannot be done properly until 
    2.26 +     * after command-line arguments have been parsed, and the required baud 
    2.27 +     * rate is known. Any messages before that will be output using the
    2.28 +     * seetings of the bootloader, for example. Maybe okay for error msgs...
    2.29 +     */
    2.30      cls();
    2.31  
    2.32      if ( magic != MULTIBOOT_BOOTLOADER_MAGIC )
    2.33      {
    2.34 -        printf("Invalid magic number: 0x%x\n", (unsigned)magic);
    2.35 +        printk("Invalid magic number: 0x%x\n", (unsigned)magic);
    2.36          return;
    2.37      }
    2.38  
    2.39 @@ -84,13 +91,13 @@ void cmain (unsigned long magic, multibo
    2.40       */
    2.41      if ( (mbi->flags & 9) != 9 )
    2.42      {
    2.43 -        printf("Bad flags passed by bootloader: 0x%x\n", (unsigned)mbi->flags);
    2.44 +        printk("Bad flags passed by bootloader: 0x%x\n", (unsigned)mbi->flags);
    2.45          return;
    2.46      }
    2.47  
    2.48      if ( mbi->mods_count == 0 )
    2.49      {
    2.50 -        printf("Require at least one module!\n");
    2.51 +        printk("Require at least one module!\n");
    2.52          return;
    2.53      }
    2.54  
    2.55 @@ -160,6 +167,9 @@ void cmain (unsigned long magic, multibo
    2.56          }
    2.57      }
    2.58  
    2.59 +    /* INITIALISE SERIAL LINE (printk will work okay from here on). */
    2.60 +    init_serial();
    2.61 +
    2.62      memcpy(&idle0_task_union, &first_task_struct, sizeof(first_task_struct));
    2.63  
    2.64      max_page = (mbi->mem_upper+1024) >> (PAGE_SHIFT - 10);
    2.65 @@ -213,9 +223,9 @@ void cmain (unsigned long magic, multibo
    2.66  
    2.67  void init_serial(void)
    2.68  {
    2.69 -    /* 9600 baud, no parity, 1 stop bit, 8 data bits. */
    2.70 +    /* 'opt_ser_baud' baud, no parity, 1 stop bit, 8 data bits. */
    2.71      outb(0x83, SERIAL_BASE+DATA_FORMAT);
    2.72 -    outb(12, SERIAL_BASE+DIVISOR_LO);
    2.73 +    outb(115200/opt_ser_baud, SERIAL_BASE+DIVISOR_LO);
    2.74      outb(0, SERIAL_BASE+DIVISOR_HI);
    2.75      outb(0x03, SERIAL_BASE+DATA_FORMAT);
    2.76  
     3.1 --- a/xen/drivers/block/grok.c	Thu Mar 06 16:54:15 2003 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,39 +0,0 @@
     3.4 -void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size)
     3.5 -{
     3.6 -	int i;
     3.7 -	int first_minor	= drive << dev->minor_shift;
     3.8 -	int end_minor	= first_minor + dev->max_p;
     3.9 -
    3.10 -	if(!dev->sizes)
    3.11 -		blk_size[dev->major] = NULL;
    3.12 -
    3.13 -	dev->part[first_minor].nr_sects = size;
    3.14 -#ifdef DEVFS_MUST_DIE
    3.15 -	/* No such device or no minors to use for partitions */
    3.16 -	if ( !size && dev->flags && (dev->flags[drive] & GENHD_FL_REMOVABLE) )
    3.17 -		devfs_register_partitions (dev, first_minor, 0);
    3.18 -#endif
    3.19 -
    3.20 -	if (!size || minors == 1)
    3.21 -		return;
    3.22 -
    3.23 -	if (dev->sizes) {
    3.24 -		dev->sizes[first_minor] = size >> (BLOCK_SIZE_BITS - 9);
    3.25 -		for (i = first_minor + 1; i < end_minor; i++)
    3.26 -			dev->sizes[i] = 0;
    3.27 -	}
    3.28 -	blk_size[dev->major] = dev->sizes;
    3.29 -#if 0
    3.30 -	/* XXX SMH: don't actually check partition details yet */
    3.31 -	check_partition(dev, MKDEV(dev->major, first_minor), 1 + first_minor);
    3.32 -#endif
    3.33 -
    3.34 - 	/*
    3.35 - 	 * We need to set the sizes array before we will be able to access
    3.36 - 	 * any of the partitions on this device.
    3.37 - 	 */
    3.38 -	if (dev->sizes != NULL) {	/* optional safeguard in ll_rw_blk.c */
    3.39 -		for (i = first_minor; i < end_minor; i++)
    3.40 -			dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9);
    3.41 -	}
    3.42 -}
     4.1 --- a/xen/drivers/block/xen_block.c	Thu Mar 06 16:54:15 2003 +0000
     4.2 +++ b/xen/drivers/block/xen_block.c	Fri Mar 07 01:38:49 2003 +0000
     4.3 @@ -38,6 +38,33 @@
     4.4  static kmem_cache_t *buffer_head_cachep;
     4.5  static atomic_t nr_pending;
     4.6  
     4.7 +#define NR_IDE_DEVS  20
     4.8 +#define NR_SCSI_DEVS 16
     4.9 +
    4.10 +static kdev_t ide_devs[NR_IDE_DEVS] = { 
    4.11 +    MKDEV(IDE0_MAJOR, 0), MKDEV(IDE0_MAJOR, 64),                /* hda, hdb */
    4.12 +    MKDEV(IDE1_MAJOR, 0), MKDEV(IDE1_MAJOR, 64),                /* hdc, hdd */
    4.13 +    MKDEV(IDE2_MAJOR, 0), MKDEV(IDE2_MAJOR, 64),                /* hde, hdf */
    4.14 +    MKDEV(IDE3_MAJOR, 0), MKDEV(IDE3_MAJOR, 64),                /* hdg, hdh */
    4.15 +    MKDEV(IDE4_MAJOR, 0), MKDEV(IDE4_MAJOR, 64),                /* hdi, hdj */
    4.16 +    MKDEV(IDE5_MAJOR, 0), MKDEV(IDE5_MAJOR, 64),                /* hdk, hdl */
    4.17 +    MKDEV(IDE6_MAJOR, 0), MKDEV(IDE6_MAJOR, 64),                /* hdm, hdn */
    4.18 +    MKDEV(IDE7_MAJOR, 0), MKDEV(IDE7_MAJOR, 64),                /* hdo, hdp */
    4.19 +    MKDEV(IDE8_MAJOR, 0), MKDEV(IDE8_MAJOR, 64),                /* hdq, hdr */
    4.20 +    MKDEV(IDE9_MAJOR, 0), MKDEV(IDE9_MAJOR, 64)                 /* hds, hdt */
    4.21 +};
    4.22 +
    4.23 +static kdev_t scsi_devs[NR_SCSI_DEVS] = { 
    4.24 +    MKDEV(SCSI_DISK0_MAJOR,   0), MKDEV(SCSI_DISK0_MAJOR,  16), /* sda, sdb */
    4.25 +    MKDEV(SCSI_DISK0_MAJOR,  32), MKDEV(SCSI_DISK0_MAJOR,  48), /* sdc, sdd */
    4.26 +    MKDEV(SCSI_DISK0_MAJOR,  64), MKDEV(SCSI_DISK0_MAJOR,  80), /* sde, sdf */
    4.27 +    MKDEV(SCSI_DISK0_MAJOR,  96), MKDEV(SCSI_DISK0_MAJOR, 112), /* sdg, sdh */
    4.28 +    MKDEV(SCSI_DISK0_MAJOR, 128), MKDEV(SCSI_DISK0_MAJOR, 144), /* sdi, sdj */
    4.29 +    MKDEV(SCSI_DISK0_MAJOR, 160), MKDEV(SCSI_DISK0_MAJOR, 176), /* sdk, sdl */
    4.30 +    MKDEV(SCSI_DISK0_MAJOR, 192), MKDEV(SCSI_DISK0_MAJOR, 208), /* sdm, sdn */
    4.31 +    MKDEV(SCSI_DISK0_MAJOR, 224), MKDEV(SCSI_DISK0_MAJOR, 240), /* sdo, sdp */
    4.32 +};
    4.33 +
    4.34  static void io_schedule(unsigned long unused);
    4.35  static int do_block_io_op_domain(struct task_struct *p, int max_to_do);
    4.36  static void dispatch_rw_block_io(struct task_struct *p, int index);
    4.37 @@ -247,7 +274,8 @@ static void dispatch_create_segment(stru
    4.38      if (p->domain != 0)
    4.39      {
    4.40          DPRINTK("dispatch_create_segment called by dom%d\n", p->domain);
    4.41 -        make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_SEG_CREATE, 1); 
    4.42 +        make_response(p, blk_ring->ring[index].req.id, 
    4.43 +                      XEN_BLOCK_SEG_CREATE, 1); 
    4.44          return;
    4.45      }
    4.46  
    4.47 @@ -266,30 +294,28 @@ static void dispatch_delete_segment(stru
    4.48  
    4.49  static void dispatch_probe_blk(struct task_struct *p, int index)
    4.50  {
    4.51 -    extern void ide_probe_devices(xen_disk_info_t *xdi, int *count, 
    4.52 -				  drive_t xdrives[]);
    4.53 -    extern void scsi_probe_devices(xen_disk_info_t *xdi, int *count,
    4.54 -                                   drive_t xdrives[]);
    4.55 +    extern void ide_probe_devices(xen_disk_info_t *xdi);
    4.56 +    extern void scsi_probe_devices(xen_disk_info_t *xdi);
    4.57  
    4.58      blk_ring_t *blk_ring = p->blk_ring_base;
    4.59      xen_disk_info_t *xdi;
    4.60  
    4.61      xdi = phys_to_virt((unsigned long)blk_ring->ring[index].req.buffer);    
    4.62  
    4.63 -    ide_probe_devices(xdi, &num_xdrives, xdrives);
    4.64 -    scsi_probe_devices(xdi, &num_xdrives, xdrives);
    4.65 +    ide_probe_devices(xdi);
    4.66 +    scsi_probe_devices(xdi);
    4.67  
    4.68      make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_PROBE_BLK, 0);
    4.69  }
    4.70  
    4.71  static void dispatch_probe_seg(struct task_struct *p, int index)
    4.72  {
    4.73 -    extern void xen_segment_probe(xen_disk_info_t *xdi, int *count);
    4.74 +    extern void xen_segment_probe(xen_disk_info_t *xdi);
    4.75      blk_ring_t *blk_ring = p->blk_ring_base;
    4.76      xen_disk_info_t *xdi;
    4.77  
    4.78      xdi = phys_to_virt((unsigned long)blk_ring->ring[index].req.buffer);    
    4.79 -    xen_segment_probe(xdi, &num_xdrives);
    4.80 +    xen_segment_probe(xdi);
    4.81  
    4.82      make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_PROBE_SEG, 0);
    4.83  }
    4.84 @@ -305,7 +331,7 @@ static void dispatch_rw_block_io(struct 
    4.85      unsigned long  sector_number = 0L;
    4.86      unsigned long buffer, pfn;
    4.87      struct pfn_info *page;
    4.88 -    int xen_device, phys_device = 0;
    4.89 +    int s, xen_device, phys_device = 0;
    4.90  
    4.91      operation = (blk_ring->ring[index].req.operation == XEN_BLOCK_WRITE) ? 
    4.92          WRITE : READ;
    4.93 @@ -336,7 +362,7 @@ static void dispatch_rw_block_io(struct 
    4.94          if ( pfn >= max_page )
    4.95          {
    4.96              DPRINTK("pfn out of range: %08lx\n", pfn);
    4.97 -            goto bad_descriptor;
    4.98 +            goto bad_descriptor_free_frames;
    4.99          }
   4.100  
   4.101          page = frame_table + pfn;
   4.102 @@ -346,7 +372,7 @@ static void dispatch_rw_block_io(struct 
   4.103          {
   4.104              DPRINTK("bad domain: expected %d, got %ld\n", 
   4.105                      p->domain, page->flags & PG_domain_mask);
   4.106 -            goto bad_descriptor;
   4.107 +            goto bad_descriptor_free_frames;
   4.108          }
   4.109  
   4.110          /* If reading into the frame, the frame must be writeable. */
   4.111 @@ -355,7 +381,7 @@ static void dispatch_rw_block_io(struct 
   4.112              if ( (page->flags & PG_type_mask) != PGT_writeable_page )
   4.113              {
   4.114                  DPRINTK("non-writeable page passed for block read\n");
   4.115 -                goto bad_descriptor;
   4.116 +                goto bad_descriptor_free_frames;
   4.117              }
   4.118              get_page_type(page);
   4.119          }
   4.120 @@ -371,42 +397,52 @@ static void dispatch_rw_block_io(struct 
   4.121      /* set just the important bits of the buffer header */
   4.122      memset (bh, 0, sizeof (struct buffer_head));
   4.123  
   4.124 -    /* map from virtual xeno devices to physical ide & scsi devices */
   4.125      xen_device = blk_ring->ring[index].req.device;
   4.126 -    if (IS_XHD_MAJOR(xen_device))
   4.127 +
   4.128 + again:
   4.129 +    switch ( (xen_device & XENDEV_TYPE_MASK) )
   4.130      {
   4.131 -        if (xen_device == XHDA_MAJOR)    	 phys_device = MKDEV(IDE0_MAJOR, 0);
   4.132 -        else if (xen_device == XHDB_MAJOR) phys_device = MKDEV(IDE1_MAJOR, 0);
   4.133 -        else if (xen_device == XHDC_MAJOR) phys_device = MKDEV(IDE2_MAJOR, 0);
   4.134 -        else if (xen_device == XHDD_MAJOR) phys_device = MKDEV(IDE3_MAJOR, 0);
   4.135 -        else
   4.136 +    case XENDEV_IDE:
   4.137 +        xen_device &= XENDEV_IDX_MASK;
   4.138 +        if ( xen_device >= NR_IDE_DEVS )
   4.139          {
   4.140 -            printk(KERN_ALERT "dispatch_rw_block_io: unknown device %d\n",
   4.141 -                   xen_device);
   4.142 -            BUG();
   4.143 +            DPRINTK("IDE device number out of range %d\n", xen_device);
   4.144 +            goto bad_descriptor_free_frames;
   4.145          }
   4.146 -
   4.147 -        block_number = blk_ring->ring[index].req.block_number;
   4.148 +        phys_device   = ide_devs[xen_device];
   4.149 +        block_number  = blk_ring->ring[index].req.block_number;
   4.150          sector_number = blk_ring->ring[index].req.sector_number;
   4.151 -    }
   4.152 -    else if (IS_VHD_MAJOR(xen_device))
   4.153 -    {
   4.154 -        int s;
   4.155 -        if (s = xen_segment_map_request(&phys_device, &block_number, 
   4.156 -                                        &sector_number,
   4.157 -                                        p, operation, xen_device,
   4.158 -                                        blk_ring->ring[index].req.block_number,
   4.159 -                                        blk_ring->ring[index].req.sector_number))
   4.160 +        break;
   4.161 +
   4.162 +    case XENDEV_SCSI:
   4.163 +        xen_device &= XENDEV_IDX_MASK;
   4.164 +        if ( xen_device >= NR_SCSI_DEVS )
   4.165          {
   4.166 -            DPRINTK("dispatch_rw_block_io: xen_seg_map_request status: %d\n", s);
   4.167 -            goto bad_descriptor;
   4.168 +            DPRINTK("SCSI device number out of range %d\n", xen_device);
   4.169 +            goto bad_descriptor_free_frames;
   4.170          }
   4.171 -    }
   4.172 -    else
   4.173 -    {
   4.174 -        printk (KERN_ALERT "dispatch_rw_block_io: unknown device %d\n",
   4.175 -                xen_device);
   4.176 -        BUG();
   4.177 +        phys_device   = scsi_devs[xen_device];
   4.178 +        block_number  = blk_ring->ring[index].req.block_number;
   4.179 +        sector_number = blk_ring->ring[index].req.sector_number;
   4.180 +        break;
   4.181 +
   4.182 +    case XENDEV_VIRTUAL:
   4.183 +        xen_device &= XENDEV_IDX_MASK;
   4.184 +        s = xen_segment_map_request(
   4.185 +            &xen_device, &block_number, &sector_number,
   4.186 +            p, operation, xen_device,
   4.187 +            blk_ring->ring[index].req.block_number,
   4.188 +            blk_ring->ring[index].req.sector_number);
   4.189 +        if ( s != 0 )
   4.190 +        {
   4.191 +            DPRINTK("xen_seg_map_request status: %d\n", s);
   4.192 +            goto bad_descriptor_free_frames;
   4.193 +        }
   4.194 +        goto again; /* Loop round to convert the virt IDE/SCSI identifier. */
   4.195 +
   4.196 +    default:
   4.197 +        DPRINTK("dispatch_rw_block_io: unknown device %d\n", xen_device);
   4.198 +        goto bad_descriptor_free_frames;
   4.199      }
   4.200      
   4.201      bh->b_blocknr       = block_number;
   4.202 @@ -435,7 +471,15 @@ static void dispatch_rw_block_io(struct 
   4.203      ll_rw_block(operation, 1, &bh);
   4.204      return;
   4.205  
   4.206 - bad_descriptor:
   4.207 + bad_descriptor_free_frames:
   4.208 +    while ( pfn > (buffer >> PAGE_SHIFT) )
   4.209 +    {
   4.210 +        page = frame_table + --pfn;
   4.211 +        put_page_tot(page);
   4.212 +        if ( operation == READ ) put_page_type(page);
   4.213 +    }
   4.214 +
   4.215 + bad_descriptor: 
   4.216      DPRINTK("dispatch rw blockio bad descriptor\n");
   4.217      make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_READ, 1);
   4.218  } 
     5.1 --- a/xen/drivers/block/xen_segment.c	Thu Mar 06 16:54:15 2003 +0000
     5.2 +++ b/xen/drivers/block/xen_segment.c	Fri Mar 07 01:38:49 2003 +0000
     5.3 @@ -14,10 +14,6 @@
     5.4  #include <asm/current.h>
     5.5  #include <asm/domain_page.h>
     5.6  #include <hypervisor-ifs/block.h>
     5.7 -#include <hypervisor-ifs/xeno-major.h>
     5.8 -
     5.9 -int     num_xdrives;
    5.10 -drive_t xdrives[XEN_MAX_DISK_COUNT];
    5.11  
    5.12  segment_t xsegments[XEN_MAX_SEGMENTS];
    5.13  
    5.14 @@ -27,69 +23,70 @@ segment_t xsegments[XEN_MAX_SEGMENTS];
    5.15   * xen_device must be a valid device.
    5.16   */
    5.17  
    5.18 -int xen_segment_map_request(int *phys_device,                         /* out */
    5.19 -			    unsigned long *block_number,              /* out */
    5.20 -			    unsigned long *sector_number,             /* out */
    5.21 -			    struct task_struct *domain,
    5.22 -			    int operation,
    5.23 -			    int xen_device,
    5.24 -			    int xen_block_number,
    5.25 -			    int xen_sector_number)
    5.26 +int xen_segment_map_request(
    5.27 +    int *phys_device,                         /* out */
    5.28 +    unsigned long *block_number,              /* out */
    5.29 +    unsigned long *sector_number,             /* out */
    5.30 +    struct task_struct *domain,
    5.31 +    int operation,
    5.32 +    int segment_number,
    5.33 +    int xen_block_number,
    5.34 +    int xen_sector_number)
    5.35  {
    5.36 -  segment_t *seg;
    5.37 -  int segment_number;                   /* segment number within this domain */
    5.38 -  int sum; 
    5.39 -  int loop;
    5.40 +    segment_t *seg;
    5.41 +    int sum; 
    5.42 +    int loop;
    5.43  
    5.44 -  segment_number = xen_device - XLSEG_MAJOR;
    5.45 -  seg = domain->segment_list[segment_number];
    5.46 +    if ( segment_number >= XEN_MAX_SEGMENTS )
    5.47 +    {
    5.48 +        /* No VHD. */
    5.49 +        return 1;
    5.50 +    }
    5.51  
    5.52 -  if (seg == NULL)
    5.53 -  {
    5.54 -    return 1;                                       /* oops.  no vhd exists! */
    5.55 -  }
    5.56 -
    5.57 -  /* check domain permissions */
    5.58 -  if (seg->domain != domain->domain)
    5.59 -  {
    5.60 -    return 2;                                  /* domain doesn't own segment */
    5.61 -  }
    5.62 +    seg = domain->segment_list[segment_number];
    5.63 +    
    5.64 +    if (seg == NULL)
    5.65 +    {
    5.66 +        /* oops.  no vhd exists! */
    5.67 +        return 1;
    5.68 +    }
    5.69  
    5.70 -  /* check rw access */
    5.71 -  if ((operation == WRITE && seg->mode != XEN_SEGMENT_RW) ||
    5.72 -      (operation == READ  && seg->mode == XEN_SEGMENT_UNUSED))
    5.73 -  {
    5.74 -    return 3;                                            /* access violation */
    5.75 -  }
    5.76 +    /* check domain permissions */
    5.77 +    if (seg->domain != domain->domain)
    5.78 +    {
    5.79 +        /* domain doesn't own segment */
    5.80 +        return 2;
    5.81 +    }
    5.82  
    5.83 -  /* find extent, check size */
    5.84 -  sum = 0; 
    5.85 -  loop = 0;
    5.86 -  while (loop < seg->num_extents && sum <= xen_block_number)
    5.87 -  {
    5.88 -    sum += seg->extents[loop++].size;
    5.89 -  }
    5.90 -  sum -= seg->extents[--loop].size;                                /* rewind */
    5.91 +    /* check rw access */
    5.92 +    if ((operation == WRITE && seg->mode != XEN_SEGMENT_RW) ||
    5.93 +        (operation == READ  && seg->mode == XEN_SEGMENT_UNUSED))
    5.94 +    {
    5.95 +        /* access violation */
    5.96 +        return 3;
    5.97 +    }
    5.98  
    5.99 -  if (sum + seg->extents[loop].size <= xen_block_number)
   5.100 -  {
   5.101 -    return 4;                   /* tried to read past the end of the segment */
   5.102 -  }
   5.103 -  *block_number = xen_block_number - sum + seg->extents[loop].offset;
   5.104 -  *sector_number = xen_sector_number - sum + seg->extents[loop].offset;;
   5.105 -
   5.106 -  /* get physical device from xdrives */
   5.107 -  *phys_device = MKDEV(xdrives[seg->extents[loop].disk].major, 0);
   5.108 +    /* find extent, check size */
   5.109 +    sum = 0; 
   5.110 +    loop = 0;
   5.111 +    while (loop < seg->num_extents && sum <= xen_block_number)
   5.112 +    {
   5.113 +        sum += seg->extents[loop++].size;
   5.114 +    }
   5.115 +    sum -= seg->extents[--loop].size;
   5.116  
   5.117 -  /*
   5.118 -  printk ("%d %lx %lx %lx %lx :  %lx %lx %lx %lx\n",
   5.119 -	  operation,
   5.120 -	  *block_number, xen_block_number, sum, seg->extents[loop].offset,
   5.121 -	  *sector_number, xen_sector_number, sum, seg->extents[loop].offset
   5.122 -	  );
   5.123 -  */
   5.124 +    if (sum + seg->extents[loop].size <= xen_block_number)
   5.125 +    {
   5.126 +        /* tried to read past the end of the segment */
   5.127 +        return 4;
   5.128 +    }
   5.129 +    *block_number = xen_block_number - sum + seg->extents[loop].offset;
   5.130 +    *sector_number = xen_sector_number - sum + seg->extents[loop].offset;;
   5.131  
   5.132 -  return 0;
   5.133 +    /* This actually needs to be passed thru one more indirection :-) */
   5.134 +    *phys_device = seg->extents[loop].disk;
   5.135 +
   5.136 +    return 0;
   5.137  }
   5.138  
   5.139  /*
   5.140 @@ -99,24 +96,25 @@ int xen_segment_map_request(int *phys_de
   5.141   */
   5.142  void xen_segment_probe (xen_disk_info_t *raw_xdi, int *count)
   5.143  {
   5.144 -  int loop, i;
   5.145 -  xen_disk_info_t *xdi = map_domain_mem(virt_to_phys(raw_xdi));
   5.146 +    int loop, i;
   5.147 +    xen_disk_info_t *xdi = map_domain_mem(virt_to_phys(raw_xdi));
   5.148  
   5.149 -  for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++ )
   5.150 -  {
   5.151 -    if (xsegments[loop].mode != XEN_SEGMENT_UNUSED)
   5.152 +    for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++ )
   5.153      {
   5.154 -      xdi->disks[xdi->count].type = XEN_DISK_VIRTUAL;
   5.155 -      for (i = 0; i < xsegments[loop].num_extents; i++)
   5.156 -      {
   5.157 -	xdi->disks[xdi->count].capacity += xsegments[loop].extents[i].size;
   5.158 -      }
   5.159 -      xdi->count++;
   5.160 +        if (xsegments[loop].mode != XEN_SEGMENT_UNUSED)
   5.161 +        {
   5.162 +            xdi->disks[xdi->count].type = XEN_DISK_VIRTUAL;
   5.163 +            for (i = 0; i < xsegments[loop].num_extents; i++)
   5.164 +            {
   5.165 +                xdi->disks[xdi->count].capacity += 
   5.166 +                    xsegments[loop].extents[i].size;
   5.167 +            }
   5.168 +            xdi->count++;
   5.169 +        }
   5.170      }
   5.171 -  }
   5.172  
   5.173 -  unmap_domain_mem(xdi);
   5.174 -  return;
   5.175 +    unmap_domain_mem(xdi);
   5.176 +    return;
   5.177  }
   5.178  
   5.179  /*
   5.180 @@ -127,18 +125,18 @@ void xen_segment_probe (xen_disk_info_t 
   5.181   */
   5.182  void xen_refresh_segment_list (struct task_struct *p)
   5.183  {
   5.184 -  int loop;
   5.185 +    int loop;
   5.186  
   5.187 -  for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++)
   5.188 -  {
   5.189 -    if (xsegments[loop].mode != XEN_SEGMENT_UNUSED &&
   5.190 -	xsegments[loop].domain == p->domain)
   5.191 +    for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++)
   5.192      {
   5.193 -      p->segment_list[xsegments[loop].segment_number] = &xsegments[loop];
   5.194 -      p->segment_count++;
   5.195 +        if (xsegments[loop].mode != XEN_SEGMENT_UNUSED &&
   5.196 +            xsegments[loop].domain == p->domain)
   5.197 +        {
   5.198 +            p->segment_list[xsegments[loop].segment_number] = &xsegments[loop];
   5.199 +            p->segment_count++;
   5.200 +        }
   5.201      }
   5.202 -  }
   5.203 -  return;
   5.204 +    return;
   5.205  }
   5.206  
   5.207  /*
   5.208 @@ -151,45 +149,45 @@ void xen_refresh_segment_list (struct ta
   5.209   */
   5.210  int xen_segment_create(xv_disk_t *xvd_in)
   5.211  {
   5.212 -  int idx;
   5.213 -  int loop;
   5.214 -  xv_disk_t *xvd = map_domain_mem(virt_to_phys(xvd_in));
   5.215 +    int idx;
   5.216 +    int loop;
   5.217 +    xv_disk_t *xvd = map_domain_mem(virt_to_phys(xvd_in));
   5.218  
   5.219 -  for (idx = 0; idx < XEN_MAX_SEGMENTS; idx++)
   5.220 -  {
   5.221 -    if (xsegments[idx].mode == XEN_SEGMENT_UNUSED) break;
   5.222 -  }
   5.223 -  if (idx == XEN_MAX_SEGMENTS)
   5.224 -  {
   5.225 -    printk (KERN_ALERT "xen_segment_create: unable to find free slot\n");
   5.226 -    unmap_domain_mem(xvd);
   5.227 -    return 1;
   5.228 -  }
   5.229 +    for (idx = 0; idx < XEN_MAX_SEGMENTS; idx++)
   5.230 +    {
   5.231 +        if (xsegments[idx].mode == XEN_SEGMENT_UNUSED) break;
   5.232 +    }
   5.233 +    if (idx == XEN_MAX_SEGMENTS)
   5.234 +    {
   5.235 +        printk (KERN_ALERT "xen_segment_create: unable to find free slot\n");
   5.236 +        unmap_domain_mem(xvd);
   5.237 +        return 1;
   5.238 +    }
   5.239  
   5.240 -  xsegments[idx].mode = xvd->mode;
   5.241 -  xsegments[idx].domain = xvd->domain;
   5.242 -  xsegments[idx].segment_number = xvd->segment;
   5.243 -  xsegments[idx].num_extents = xvd->ext_count;
   5.244 -  xsegments[idx].extents = (extent_t *)kmalloc(sizeof(extent_t)*xvd->ext_count,
   5.245 -					       GFP_KERNEL);
   5.246 +    xsegments[idx].mode = xvd->mode;
   5.247 +    xsegments[idx].domain = xvd->domain;
   5.248 +    xsegments[idx].segment_number = xvd->segment;
   5.249 +    xsegments[idx].num_extents = xvd->ext_count;
   5.250 +    xsegments[idx].extents = (extent_t *)kmalloc(
   5.251 +        sizeof(extent_t)*xvd->ext_count,
   5.252 +        GFP_KERNEL);
   5.253   
   5.254 -  /* could memcpy, but this is safer */
   5.255 -  for (loop = 0; loop < xvd->ext_count; loop++)
   5.256 -  {
   5.257 -    xsegments[idx].extents[loop].disk = xvd->extents[loop].disk;
   5.258 -    xsegments[idx].extents[loop].offset = xvd->extents[loop].offset;
   5.259 -    xsegments[idx].extents[loop].size = xvd->extents[loop].size;
   5.260 -    if (xsegments[idx].extents[loop].size == 0) 
   5.261 +    /* could memcpy, but this is safer */
   5.262 +    for (loop = 0; loop < xvd->ext_count; loop++)
   5.263      {
   5.264 -      printk (KERN_ALERT "xen_segment_create: extent %d is zero length\n",
   5.265 -	      loop);
   5.266 -      unmap_domain_mem(xvd);
   5.267 -      return 1;
   5.268 +        xsegments[idx].extents[loop].disk = xvd->extents[loop].disk;
   5.269 +        xsegments[idx].extents[loop].offset = xvd->extents[loop].offset;
   5.270 +        xsegments[idx].extents[loop].size = xvd->extents[loop].size;
   5.271 +        if (xsegments[idx].extents[loop].size == 0) 
   5.272 +        {
   5.273 +            printk("xen_segment_create: extent %d is zero length\n", loop);
   5.274 +            unmap_domain_mem(xvd);
   5.275 +            return 1;
   5.276 +        }
   5.277      }
   5.278 -  }
   5.279  
   5.280 -  unmap_domain_mem(xvd);
   5.281 -  return 0;
   5.282 +    unmap_domain_mem(xvd);
   5.283 +    return 0;
   5.284  }
   5.285  
   5.286  /*
   5.287 @@ -201,55 +199,49 @@ int xen_segment_create(xv_disk_t *xvd_in
   5.288   */
   5.289  int xen_segment_delete(struct task_struct *p, xv_disk_t *xvd)
   5.290  {
   5.291 -  return 0;
   5.292 +    return 0;
   5.293  }
   5.294  
   5.295  static void dump_segments(u_char key, void *dev_id, struct pt_regs *regs) 
   5.296  {
   5.297 -  int loop, i;
   5.298 -  struct task_struct *p;
   5.299 +    int loop, i;
   5.300 +    struct task_struct *p;
   5.301  
   5.302 -  printk (KERN_ALERT "xdrives\n");
   5.303 -  for (loop = 0; loop < num_xdrives; loop++)
   5.304 -  {
   5.305 -    printk (KERN_ALERT " %2d: major: 0x%d\n", loop, xdrives[loop].major);
   5.306 -  }
   5.307 -  
   5.308 -  printk (KERN_ALERT "segment list\n");
   5.309 -  for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++)
   5.310 -  {
   5.311 -    if (xsegments[loop].mode != XEN_SEGMENT_UNUSED)
   5.312 +    printk("segment list\n");
   5.313 +    for (loop = 0; loop < XEN_MAX_SEGMENTS; loop++)
   5.314      {
   5.315 -      printk (KERN_ALERT " %2d: %s dom%d, seg# %d, num_exts: %d\n",
   5.316 -	      loop, 
   5.317 -	      xsegments[loop].mode == XEN_SEGMENT_RO ? "RO" : "RW",
   5.318 -	      xsegments[loop].domain, xsegments[loop].segment_number,
   5.319 -	      xsegments[loop].num_extents);
   5.320 -      for (i = 0; i < xsegments[loop].num_extents; i++)
   5.321 -      {
   5.322 -	printk (KERN_ALERT "     ext %d: disk %d, offset 0x%lx, size 0x%lx\n",
   5.323 -		i, xsegments[loop].extents[i].disk,
   5.324 -		xsegments[loop].extents[i].offset,
   5.325 -		xsegments[loop].extents[i].size);
   5.326 -      } 
   5.327 +        if (xsegments[loop].mode != XEN_SEGMENT_UNUSED)
   5.328 +        {
   5.329 +            printk(" %2d: %s dom%d, seg# %d, num_exts: %d\n",
   5.330 +                   loop, 
   5.331 +                   xsegments[loop].mode == XEN_SEGMENT_RO ? "RO" : "RW",
   5.332 +                   xsegments[loop].domain, xsegments[loop].segment_number,
   5.333 +                   xsegments[loop].num_extents);
   5.334 +            for (i = 0; i < xsegments[loop].num_extents; i++)
   5.335 +            {
   5.336 +                printk("     ext %d: disk %d, offset 0x%lx, size 0x%lx\n",
   5.337 +                       i, xsegments[loop].extents[i].disk,
   5.338 +                       xsegments[loop].extents[i].offset,
   5.339 +                       xsegments[loop].extents[i].size);
   5.340 +            } 
   5.341 +        }
   5.342      }
   5.343 -  }
   5.344  
   5.345 -  printk (KERN_ALERT "segments by domain\n");
   5.346 -  p = current->next_task;
   5.347 -  do
   5.348 -  {
   5.349 -    printk (KERN_ALERT "  domain: %d\n", p->domain);
   5.350 -    for (loop = 0; loop < p->segment_count; loop++)
   5.351 +    printk("segments by domain\n");
   5.352 +    p = current->next_task;
   5.353 +    do
   5.354      {
   5.355 -      printk (KERN_ALERT "    mode:%d domain:%d seg:%d exts:%d\n",
   5.356 -	      p->segment_list[loop]->mode,
   5.357 -	      p->segment_list[loop]->domain,
   5.358 -	      p->segment_list[loop]->segment_number,
   5.359 -	      p->segment_list[loop]->num_extents);
   5.360 -    }
   5.361 -    p = p->next_task;
   5.362 -  } while (p != current);
   5.363 +        printk("  domain: %d\n", p->domain);
   5.364 +        for (loop = 0; loop < p->segment_count; loop++)
   5.365 +        {
   5.366 +            printk("    mode:%d domain:%d seg:%d exts:%d\n",
   5.367 +                   p->segment_list[loop]->mode,
   5.368 +                   p->segment_list[loop]->domain,
   5.369 +                   p->segment_list[loop]->segment_number,
   5.370 +                   p->segment_list[loop]->num_extents);
   5.371 +        }
   5.372 +        p = p->next_task;
   5.373 +    } while (p != current);
   5.374  }
   5.375  
   5.376  /*
   5.377 @@ -258,8 +250,7 @@ static void dump_segments(u_char key, vo
   5.378  
   5.379  void xen_segment_initialize(void)
   5.380  {
   5.381 -  memset (xdrives, 0, sizeof(xdrives));
   5.382 -  memset (xsegments, 0, sizeof(xsegments));
   5.383 +    memset (xsegments, 0, sizeof(xsegments));
   5.384  
   5.385 -  add_key_handler('S', dump_segments, "dump segments");
   5.386 +    add_key_handler('S', dump_segments, "dump segments");
   5.387  }
     6.1 --- a/xen/drivers/ide/ide-xeno.c	Thu Mar 06 16:54:15 2003 +0000
     6.2 +++ b/xen/drivers/ide/ide-xeno.c	Fri Mar 07 01:38:49 2003 +0000
     6.3 @@ -7,42 +7,33 @@
     6.4  #include <asm/domain_page.h>
     6.5  #include <asm/io.h>
     6.6  
     6.7 -void ide_probe_devices (xen_disk_info_t* xdi, int *count, drive_t xdrives[])
     6.8 +void ide_probe_devices(xen_disk_info_t* xdi)
     6.9  {
    6.10      int loop;
    6.11      unsigned int unit;
    6.12      xen_disk_info_t *xen_xdi = map_domain_mem(virt_to_phys(xdi));
    6.13 +    unsigned long capacity;
    6.14 +    ide_drive_t *drive;
    6.15      
    6.16 -    for (loop = 0; loop < MAX_HWIFS; ++loop) {
    6.17 -
    6.18 +    for ( loop = 0; loop < MAX_HWIFS; loop++ )
    6.19 +    {
    6.20  	ide_hwif_t *hwif = &ide_hwifs[loop];
    6.21 -	if (hwif->present) {
    6.22 -
    6.23 -	    for (unit = 0; unit < MAX_DRIVES; ++unit) {
    6.24 -		unsigned long capacity;
    6.25 -		ide_drive_t *drive = &hwif->drives[unit];
    6.26 +	if ( !hwif->present ) continue;
    6.27  
    6.28 -		/* only count drives with capacity > 0. this excludes cdroms */
    6.29 -		if (drive->present && (capacity = current_capacity(drive)))
    6.30 -		{
    6.31 -		    xen_xdi->disks[xen_xdi->count].type = XEN_DISK_IDE;
    6.32 -		    xen_xdi->disks[xen_xdi->count].capacity = capacity;
    6.33 -		    xdrives[xen_xdi->count].major = hwif->major;
    6.34 -		    xen_xdi->count++;
    6.35 +        for ( unit = 0; unit < MAX_DRIVES; unit++ )
    6.36 +        {
    6.37 +            drive = &hwif->drives[unit];
    6.38 +            if ( !drive->present ) continue;
    6.39 +            
    6.40 +            capacity = current_capacity(drive);
    6.41 +            xen_xdi->disks[xen_xdi->count].type = XEN_DISK_IDE;
    6.42 +            xen_xdi->disks[xen_xdi->count].capacity = capacity;
    6.43 +            xen_xdi->count++;
    6.44  
    6.45 -		    /*
    6.46 -		    printk (KERN_ALERT "IDE-XENO %d\n", xen_xdi->count);
    6.47 -		    printk (KERN_ALERT "  capacity 0x%lx\n", capacity);
    6.48 -		    printk (KERN_ALERT "  head     0x%x\n",  drive->bios_head);
    6.49 -		    printk (KERN_ALERT "  sector   0x%x\n",  drive->bios_sect);
    6.50 -		    printk (KERN_ALERT "  cylinder 0x%x\n",  drive->bios_cyl);
    6.51 -		    printk (KERN_ALERT "  major    0x%x\n",  hwif->major);
    6.52 -		    */
    6.53 -		}
    6.54 -	    }
    6.55 -	}
    6.56 +            printk("Disk %d: IDE-XENO capacity %ldkB (%ldMB)\n",
    6.57 +                   xen_xdi->count, capacity>>1, capacity>>11);
    6.58 +        }
    6.59      }
    6.60 -    *count = xen_xdi->count;
    6.61  
    6.62      unmap_domain_mem(xen_xdi);
    6.63  }
     7.1 --- a/xen/drivers/scsi/aacraid/linit.c	Thu Mar 06 16:54:15 2003 +0000
     7.2 +++ b/xen/drivers/scsi/aacraid/linit.c	Fri Mar 07 01:38:49 2003 +0000
     7.3 @@ -457,7 +457,7 @@ struct aac_driver_ident* aac_get_driver_
     7.4  static int aac_biosparm(Scsi_Disk *disk, kdev_t dev, int *geom)
     7.5  {
     7.6      struct diskparm *param = (struct diskparm *)geom;
     7.7 -    struct buffer_head * buf;
     7.8 +    /*struct buffer_head * buf;*/
     7.9      
    7.10      dprintk((KERN_DEBUG "aac_biosparm.\n"));
    7.11  
     8.1 --- a/xen/drivers/scsi/scsi.c	Thu Mar 06 16:54:15 2003 +0000
     8.2 +++ b/xen/drivers/scsi/scsi.c	Fri Mar 07 01:38:49 2003 +0000
     8.3 @@ -819,6 +819,7 @@ void scsi_wait_req (Scsi_Request * SRpnt
     8.4      DECLARE_COMPLETION(wait);
     8.5  #else 
     8.6      int wait = 1; 
     8.7 +    int usecs = 0;
     8.8  #endif
     8.9  
    8.10  
    8.11 @@ -846,9 +847,6 @@ void scsi_wait_req (Scsi_Request * SRpnt
    8.12         we've waited on &wait -- hence we deallocate the command structure
    8.13         if it hasn't been done already. This is not the correct behaviour 
    8.14         in xen ... hmm .. how to fix? */
    8.15 -    int usecs = 0; 
    8.16 -//    printk("scsi_wait_req: about to poll-wait, request is at %p\n", 
    8.17 -//           SRpnt->sr_request); 
    8.18      while(*(int *)(SRpnt->sr_request.waiting)) {
    8.19          udelay(500); 
    8.20          usecs += 500; 
     9.1 --- a/xen/drivers/scsi/scsi_lib.c	Thu Mar 06 16:54:15 2003 +0000
     9.2 +++ b/xen/drivers/scsi/scsi_lib.c	Fri Mar 07 01:38:49 2003 +0000
     9.3 @@ -431,9 +431,9 @@ static Scsi_Cmnd *__scsi_end_request(Scs
     9.4      }
     9.5  #else 
     9.6      /* XXX SMH: we're done -- flip the flag for the spinner :-| */
     9.7 -    if(req->waiting && (*(int *)(req->waiting) != NULL)) {
     9.8 +    if(req->waiting && (*(int *)(req->waiting) != 0)) {
     9.9  		printk("__scsi_end_request: flipping wait status on req %p\n", req); 
    9.10 -		*(int *)(req->waiting) = NULL; 
    9.11 +		*(int *)(req->waiting) = 0; 
    9.12      } // else printk("__scsi_end_request: no-one to notify!!\n"); 
    9.13  #endif
    9.14      req_finished_io(req);
    10.1 --- a/xen/drivers/scsi/scsi_module.c.inc	Thu Mar 06 16:54:15 2003 +0000
    10.2 +++ b/xen/drivers/scsi/scsi_module.c.inc	Fri Mar 07 01:38:49 2003 +0000
    10.3 @@ -32,40 +32,24 @@
    10.4  #include <xeno/module.h>
    10.5  #include <linux/init.h>
    10.6  
    10.7 +extern int scsi_register_module(int, void *);
    10.8 +extern int scsi_unregister_module(int, void *);
    10.9 +
   10.10  static int __init init_this_scsi_driver(void)
   10.11  {
   10.12 -	driver_template.module = THIS_MODULE;
   10.13 -	scsi_register_module(MODULE_SCSI_HA, &driver_template);
   10.14 -	if (driver_template.present)
   10.15 -		return 0;
   10.16 -
   10.17 -	scsi_unregister_module(MODULE_SCSI_HA, &driver_template);
   10.18 -	return -ENODEV;
   10.19 +    driver_template.module = THIS_MODULE;
   10.20 +    scsi_register_module(MODULE_SCSI_HA, &driver_template);
   10.21 +    if (driver_template.present)
   10.22 +        return 0;
   10.23 +    
   10.24 +    scsi_unregister_module(MODULE_SCSI_HA, &driver_template);
   10.25 +    return -ENODEV;
   10.26  }
   10.27  
   10.28  static void __exit exit_this_scsi_driver(void)
   10.29  {
   10.30 -	scsi_unregister_module(MODULE_SCSI_HA, &driver_template);
   10.31 +    scsi_unregister_module(MODULE_SCSI_HA, &driver_template);
   10.32  }
   10.33  
   10.34  module_init(init_this_scsi_driver);
   10.35  module_exit(exit_this_scsi_driver);
   10.36 -
   10.37 -/*
   10.38 - * Overrides for Emacs so that we almost follow Linus's tabbing style.
   10.39 - * Emacs will notice this stuff at the end of the file and automatically
   10.40 - * adjust the settings for this buffer only.  This must remain at the end
   10.41 - * of the file.
   10.42 - * ---------------------------------------------------------------------------
   10.43 - * Local variables:
   10.44 - * c-indent-level: 4
   10.45 - * c-brace-imaginary-offset: 0
   10.46 - * c-brace-offset: -4
   10.47 - * c-argdecl-indent: 4
   10.48 - * c-label-offset: -4
   10.49 - * c-continued-statement-offset: 4
   10.50 - * c-continued-brace-offset: 0
   10.51 - * indent-tabs-mode: nil
   10.52 - * tab-width: 8
   10.53 - * End:
   10.54 - */
    11.1 --- a/xen/drivers/scsi/sd.c	Thu Mar 06 16:54:15 2003 +0000
    11.2 +++ b/xen/drivers/scsi/sd.c	Fri Mar 07 01:38:49 2003 +0000
    11.3 @@ -1318,49 +1318,22 @@ static void sd_finish()
    11.4  void scsi_probe_devices(xen_disk_info_t *xdi)
    11.5  {
    11.6      Scsi_Disk *sd; 
    11.7 -    int i, base, diskinfo[4];
    11.8 -    xen_disk_info_t *xen_xdi = 
    11.9 -	(xen_disk_info_t *)map_domain_mem(virt_to_phys(xdi));
   11.10 -
   11.11 -    /* We've already had IDE probe => we need to append our info */
   11.12 -    base = xen_xdi->count; 
   11.13 +    int i;
   11.14 +    xen_disk_info_t *xen_xdi = map_domain_mem(virt_to_phys(xdi));
   11.15  
   11.16 -    for (sd = rscsi_disks, i = 0; i < sd_template.dev_max; i++, sd++) {
   11.17 -
   11.18 -        if (sd->device !=NULL) { 
   11.19 -
   11.20 -	    xen_xdi->disks[xen_xdi->count].type = XEN_DISK_SCSI; 
   11.21 -	    xen_xdi->disks[xen_xdi->count].capacity = sd->capacity; 
   11.22 -	    xen_xdi->count++; 
   11.23 +    for ( sd = rscsi_disks, i = 0; i < sd_template.dev_max; i++, sd++ )
   11.24 +    {
   11.25 +        if ( sd->device == NULL ) continue;
   11.26  
   11.27 -	    /* default bios params to most commonly used values */
   11.28 -	    diskinfo[0] = 0x40;
   11.29 -	    diskinfo[1] = 0x20;
   11.30 -	    diskinfo[2] = (sd->capacity) >> 11;
   11.31 -	    
   11.32 -	    /* override with calculated, extended default,
   11.33 -	       or driver values */
   11.34 -	    /* XXX SMH: gross in-line literal major number. XXX FIXME. */
   11.35 -	    if(sd->device->host->hostt->bios_param != NULL)
   11.36 -		sd->device->host->hostt->bios_param(
   11.37 -		    sd, MKDEV(SCSI_DISK0_MAJOR, 0), &diskinfo[0]);
   11.38 -	    else scsicam_bios_param(sd, MKDEV(SCSI_DISK0_MAJOR, 0), 
   11.39 -				    &diskinfo[0]);
   11.40 -
   11.41 -	    
   11.42 -	    printk (KERN_ALERT "SCSI-XENO %d\n", xen_xdi->count - base);
   11.43 -	    printk (KERN_ALERT "  capacity 0x%x\n", sd->capacity);
   11.44 -	    printk (KERN_ALERT "  head     0x%x\n", diskinfo[0]);
   11.45 -	    printk (KERN_ALERT "  sector   0x%x\n", diskinfo[1]);
   11.46 -	    printk (KERN_ALERT "  cylinder 0x%x\n", diskinfo[2]);
   11.47 -
   11.48 -
   11.49 -	}
   11.50 +        xen_xdi->disks[xen_xdi->count].type = XEN_DISK_SCSI; 
   11.51 +        xen_xdi->disks[xen_xdi->count].capacity = sd->capacity; 
   11.52 +        xen_xdi->count++; 
   11.53 +                
   11.54 +        printk("Disk %d: SCSI-XENO capacity %dkB (%dMB)\n",
   11.55 +               xen_xdi->count, sd->capacity>>1, sd->capacity>>11);
   11.56      }
   11.57  
   11.58      unmap_domain_mem(xen_xdi);
   11.59 -
   11.60 -    return; 
   11.61  }	
   11.62  
   11.63  
    12.1 --- a/xen/include/hypervisor-ifs/block.h	Thu Mar 06 16:54:15 2003 +0000
    12.2 +++ b/xen/include/hypervisor-ifs/block.h	Fri Mar 07 01:38:49 2003 +0000
    12.3 @@ -8,7 +8,23 @@
    12.4  #ifndef __BLOCK_H__
    12.5  #define __BLOCK_H__
    12.6  
    12.7 -#include <linux/kdev_t.h>
    12.8 +/*
    12.9 + * Device numbers
   12.10 + */
   12.11 +
   12.12 +#define XENDEV_TYPE_MASK      0xf000
   12.13 +#define XENDEV_IDX_MASK       0x0fff
   12.14 +#define XENDEV_TYPE_SHIFT     12
   12.15 +#define XENDEV_IDX_SHIFT      0
   12.16 +
   12.17 +#define XENDEV_IDE            (1 << XENDEV_TYPE_SHIFT)
   12.18 +#define XENDEV_SCSI           (2 << XENDEV_TYPE_SHIFT)
   12.19 +#define XENDEV_VIRTUAL        (3 << XENDEV_TYPE_SHIFT)
   12.20 +
   12.21 +#define MK_IDE_XENDEV(_i)     ((_i) | XENDEV_IDE)
   12.22 +#define MK_SCSI_XENDEV(_i)    ((_i) | XENDEV_SCSI)
   12.23 +#define MK_VIRTUAL_XENDEV(_i) ((_i) | XENDEV_VIRTUAL)
   12.24 +
   12.25  
   12.26  /*
   12.27   *
   12.28 @@ -40,7 +56,7 @@ typedef struct blk_ring_req_entry
   12.29      char *          buffer;
   12.30      unsigned long   block_number;      /* block number */
   12.31      unsigned short  block_size;        /* block size */
   12.32 -    kdev_t          device;
   12.33 +    unsigned short  device;
   12.34      unsigned long   sector_number;     /* real buffer location on disk */
   12.35  } blk_ring_req_entry_t;
   12.36  
   12.37 @@ -77,11 +93,6 @@ typedef struct xen_disk                 
   12.38  {
   12.39    int           type;                                           /* disk type */
   12.40    unsigned long capacity;
   12.41 -  unsigned char heads;                               /* hdreg.h::hd_geometry */
   12.42 -  unsigned char sectors;                             /* hdreg.h::hd_geometry */
   12.43 -  unsigned int  cylinders;                       /* hdreg.h::hd_big_geometry */
   12.44 -  unsigned long start;                               /* hdreg.h::hd_geometry */
   12.45 -  void *        gendisk;                               /* struct gendisk ptr */
   12.46  } xen_disk_t;
   12.47  
   12.48  typedef struct xen_disk_info
    13.1 --- a/xen/include/hypervisor-ifs/xeno-major.h	Thu Mar 06 16:54:15 2003 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,37 +0,0 @@
    13.4 -/*
    13.5 - * xeno_major.h
    13.6 - *
    13.7 - * shared definitions for block IO.
    13.8 - */
    13.9 -
   13.10 -/*
   13.11 - * this belongs in xenolinux/include/linux/major.h except that
   13.12 - * xen also needs access...
   13.13 - */
   13.14 -
   13.15 -
   13.16 -#ifndef __XENO_MAJOR_H__
   13.17 -#define __XENO_MAJOR_H__
   13.18 -
   13.19 -
   13.20 -#define XLBLK_MAJOR	123                   /* XenoLinux Block Device: xhd */
   13.21 -#define XHDA_MAJOR      123
   13.22 -#define XHDB_MAJOR      124
   13.23 -#define XHDC_MAJOR      125
   13.24 -#define XHDD_MAJOR      126
   13.25 -#define XLSEG_MAJOR     234                 /* XenoLinux Segment Device: vhd */
   13.26 -#define VHDA_MAJOR      234
   13.27 -#define VHDB_MAJOR      235
   13.28 -#define VHDC_MAJOR      236
   13.29 -#define VHDD_MAJOR      237
   13.30 -
   13.31 -
   13.32 -/*
   13.33 - * XenoLinux Block Device Tests
   13.34 - */
   13.35 -#define IS_XHD_MAJOR(M) ( (M) == XHDA_MAJOR || (M) == XHDB_MAJOR || \
   13.36 -                          (M) == XHDC_MAJOR || (M) == XHDD_MAJOR ? 1 : 0)
   13.37 -#define IS_VHD_MAJOR(M) ( (M) == VHDA_MAJOR || (M) == VHDB_MAJOR || \
   13.38 -                          (M) == VHDC_MAJOR || (M) == VHDD_MAJOR ? 1 : 0)
   13.39 -
   13.40 -#endif
    14.1 --- a/xen/include/xeno/major.h	Thu Mar 06 16:54:15 2003 +0000
    14.2 +++ b/xen/include/xeno/major.h	Fri Mar 07 01:38:49 2003 +0000
    14.3 @@ -144,9 +144,6 @@
    14.4  
    14.5  #define	UMEM_MAJOR	116	/* http://www.umem.com/ Battery Backed RAM */
    14.6  
    14.7 -/* note: 123, 124, 125, 126 and 234, 235, 236, 237 are defined in xeno_major */
    14.8 -#include <hypervisor-ifs/xeno-major.h>
    14.9 -
   14.10  #define RTF_MAJOR	150
   14.11  #define RAW_MAJOR	162
   14.12  
    15.1 --- a/xen/include/xeno/segment.h	Thu Mar 06 16:54:15 2003 +0000
    15.2 +++ b/xen/include/xeno/segment.h	Fri Mar 07 01:38:49 2003 +0000
    15.3 @@ -6,32 +6,19 @@
    15.4  void xen_segment_initialize(void);
    15.5  void xen_refresh_segment_list (struct task_struct *p);
    15.6  int xen_segment_create(xv_disk_t *xvd);
    15.7 -int xen_segment_map_request(int *phys_device,                         /* out */
    15.8 -			    unsigned long *block_number,              /* out */
    15.9 -			    unsigned long *sector_number,             /* out */
   15.10 -			    struct task_struct *domain,
   15.11 -			    int operation,
   15.12 -			    int xen_device,
   15.13 -			    int xen_block_number,
   15.14 -			    int xen_sector_number);
   15.15 +int xen_segment_map_request(
   15.16 +    int *phys_device,                         /* out */
   15.17 +    unsigned long *block_number,              /* out */
   15.18 +    unsigned long *sector_number,             /* out */
   15.19 +    struct task_struct *domain,
   15.20 +    int operation,
   15.21 +    int segment_number,
   15.22 +    int xen_block_number,
   15.23 +    int xen_sector_number);
   15.24  
   15.25  #define XEN_MAX_SEGMENTS 100     /* total number of segments across all doms */
   15.26  
   15.27  /*
   15.28 - * every physical disk that xen has access to is listed in the drives array.
   15.29 - * we export the drive# to domain 0.  to xen, each drive is just one long
   15.30 - * array of blocks.
   15.31 - */
   15.32 -
   15.33 -typedef struct drive
   15.34 -{
   15.35 -  unsigned int major; 
   15.36 -} drive_t;
   15.37 -
   15.38 -extern int     num_xdrives;
   15.39 -extern drive_t xdrives[XEN_MAX_DISK_COUNT];
   15.40 -
   15.41 -/*
   15.42   * virtual hard disks
   15.43   *
   15.44   * each segment is composed of a number of extents
   15.45 @@ -39,22 +26,22 @@ extern drive_t xdrives[XEN_MAX_DISK_COUN
   15.46  
   15.47  typedef struct extent
   15.48  {
   15.49 -  int disk;            /* index into drives array of where this extent lives */
   15.50 -  unsigned long offset;                                  /* offset into disk */
   15.51 -  unsigned long size;                                 /* size of this extent */
   15.52 +    int disk;                         /* A XEN_IDE_DEV or a XEN_SCSI_DEV */
   15.53 +    unsigned long offset;             /* offset into disk */
   15.54 +    unsigned long size;               /* size of this extent */
   15.55  } extent_t;
   15.56  
   15.57 -#define XEN_SEGMENT_UNUSED 0                                /* bzero default */
   15.58 +#define XEN_SEGMENT_UNUSED 0          /* bzero default */
   15.59  #define XEN_SEGMENT_RO XEN_DISK_READ_ONLY
   15.60  #define XEN_SEGMENT_RW XEN_DISK_READ_WRITE
   15.61  
   15.62  typedef struct segment
   15.63  {
   15.64 -  int mode;                                             /* UNUSED, RO, or RW */
   15.65 -  int domain;
   15.66 -  int segment_number;                           /* segment number for domain */
   15.67 -  int num_extents;                                      /* number of extents */
   15.68 -  extent_t *extents;
   15.69 +    int mode;                         /* UNUSED, RO, or RW */
   15.70 +    int domain;
   15.71 +    int segment_number;               /* segment number for domain */
   15.72 +    int num_extents;                  /* number of extents */
   15.73 +    extent_t *extents;
   15.74  } segment_t;
   15.75  
   15.76  #endif
    16.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/Makefile	Thu Mar 06 16:54:15 2003 +0000
    16.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/Makefile	Fri Mar 07 01:38:49 2003 +0000
    16.3 @@ -1,4 +1,3 @@
    16.4  O_TARGET := blk.o
    16.5 -obj-y := xl_block.o xl_ide.o xl_scsi.o xl_segment.o 
    16.6 -obj-y += xl_segment_proc.o xl_block_test.o
    16.7 +obj-y := xl_block.o xl_ide.o xl_scsi.o xl_segment.o xl_segment_proc.o
    16.8  include $(TOPDIR)/Rules.make
    17.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Thu Mar 06 16:54:15 2003 +0000
    17.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.c	Fri Mar 07 01:38:49 2003 +0000
    17.3 @@ -5,138 +5,83 @@
    17.4   * 
    17.5   */
    17.6  
    17.7 -#include <linux/config.h>
    17.8 -#include <linux/module.h>
    17.9 -
   17.10 -#include <linux/kernel.h>
   17.11 -#include <linux/sched.h>
   17.12 -#include <linux/slab.h>
   17.13 -#include <linux/string.h>
   17.14 -#include <linux/errno.h>
   17.15 -
   17.16 -#include <linux/fs.h>
   17.17 -#include <linux/hdreg.h>
   17.18 -#include <linux/blkdev.h>
   17.19 -#include <linux/major.h>
   17.20 -
   17.21 -#include <asm/hypervisor-ifs/block.h>
   17.22 -#include <asm/hypervisor-ifs/hypervisor-if.h>
   17.23 -#include <asm/io.h>
   17.24 -#include <asm/atomic.h>
   17.25 -#include <asm/uaccess.h>
   17.26 -
   17.27 +#include "xl_block.h"
   17.28  #include <linux/blk.h>
   17.29  
   17.30 -/* Copied from linux/ide.h */
   17.31 -typedef unsigned char	byte; 
   17.32 +typedef unsigned char byte; /* from linux/ide.h */
   17.33  
   17.34 -extern int  xlide_init(int xidx, int idx); 
   17.35 -extern int  xlide_hwsect(int minor); 
   17.36 -extern void xlide_cleanup(void); 
   17.37 -extern int  xlscsi_init(int xidx, int idx);
   17.38 -extern int  xlscsi_hwsect(int minor); 
   17.39 -extern void xlscsi_cleanup(void); 
   17.40 -
   17.41 -static int nide = 0;    // number of IDE devices we have 
   17.42 -static int nscsi = 0;   // number of SCSI devices we have 
   17.43 -
   17.44 -
   17.45 -#define XLBLK_MAX 32 /* XXX SMH: this the max of XLIDE_MAX and XLSCSI_MAX */
   17.46 +#define XLBLK_MAX 32
   17.47  
   17.48  #define XLBLK_RESPONSE_IRQ _EVENT_BLK_RESP
   17.49 -
   17.50 -#define DEBUG_IRQ    _EVENT_DEBUG 
   17.51 +#define DEBUG_IRQ          _EVENT_DEBUG 
   17.52  
   17.53 -#if 0
   17.54 -#define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   17.55 -#define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   17.56 -#else
   17.57 -#define DPRINTK(_f, _a...) ((void)0)
   17.58 -#define DPRINTK_IOCTL(_f, _a...) ((void)0)
   17.59 -#endif
   17.60 +#define PARTN_SHIFT 4
   17.61  
   17.62  static blk_ring_t *blk_ring;
   17.63  static unsigned int resp_cons; /* Response consumer for comms ring. */
   17.64 -
   17.65  static xen_disk_info_t xlblk_disk_info;
   17.66 -atomic_t xlblk_control_count;
   17.67 -
   17.68 -void xlblk_ide_register_disk(int, unsigned long);
   17.69 -void do_xlseg_requestX (request_queue_t *rq);
   17.70 -int hypervisor_request(void *          id,
   17.71 -                       int             operation,
   17.72 -                       char *          buffer,
   17.73 -                       unsigned long   block_number,
   17.74 -                       unsigned short  block_size,
   17.75 -                       kdev_t          device,
   17.76 -		       struct gendisk *gd);
   17.77 +static int xlblk_control_msg_pending;
   17.78  
   17.79 -/* ------------------------------------------------------------------------
   17.80 +/*
   17.81 + * Request queues with outstanding work, but ring is currently full.
   17.82 + * We need no special lock here, as we always access this with the
   17.83 + * io_request_lock held. We only need a small maximum list.
   17.84   */
   17.85 +#define MAX_PENDING 8
   17.86 +static request_queue_t *pending_queues[MAX_PENDING];
   17.87 +static int nr_pending;
   17.88  
   17.89 -/* Convert from a XenoLinux (major,minor) to the Xen-level 'physical' device */
   17.90 -static kdev_t xldev_to_physdev(kdev_t xldev) 
   17.91 +/* Convert from a XenoLinux major device to the Xen-level 'physical' device */
   17.92 +static inline unsigned short xldev_to_physdev(kdev_t xldev) 
   17.93  {
   17.94 -    int xlmajor = MAJOR(xldev); 
   17.95 -    int major, minor; 
   17.96 +    unsigned short physdev;
   17.97  
   17.98 -    switch(xlmajor) { 
   17.99 +    switch ( MAJOR(xldev) ) 
  17.100 +    { 
  17.101      case XLIDE_MAJOR: 
  17.102 -	major = IDE0_MAJOR; 
  17.103 -	minor = 0; /* we do minor offsetting manually by addition */
  17.104 +        physdev = XENDEV_IDE;
  17.105  	break; 
  17.106  	
  17.107      case XLSCSI_MAJOR: 
  17.108 -	major = SCSI_DISK0_MAJOR; 
  17.109 -	minor = 0; /* we do minor offsetting manually by addition */
  17.110 +        physdev = XENDEV_SCSI;
  17.111  	break; 
  17.112  
  17.113 +    case XLVIRT_MAJOR:
  17.114 +        physdev = XENDEV_VIRTUAL;
  17.115 +        break;
  17.116 +
  17.117      default: 
  17.118 -	panic("xldev_to_physdev: unhandled major %d\n", xlmajor); 
  17.119 -	break; 
  17.120 +        BUG();
  17.121      } 
  17.122  
  17.123 -    return MKDEV(major, minor); 
  17.124 +    physdev += (MINOR(xldev) >> PARTN_SHIFT);
  17.125 +
  17.126 +    return physdev;
  17.127  }
  17.128  
  17.129  
  17.130 -/*
  17.131 -** Locate the gendisk structure associated with a particular xenolinux disk; 
  17.132 -** this requires a scan of the xen_disk_info[] array currently which kind of
  17.133 -** sucks. However we can clean this whole area up later (i.e. post SOSP). 
  17.134 -*/
  17.135 -struct gendisk *xldev_to_gendisk(kdev_t xldev, int *t) 
  17.136 +static inline struct gendisk *xldev_to_gendisk(kdev_t xldev) 
  17.137  {
  17.138 -    int i, j, posn, type; 
  17.139 +    struct gendisk *gd = NULL;
  17.140  
  17.141 -    switch(MAJOR(xldev)) { 
  17.142 -	
  17.143 +    switch ( MAJOR(xldev) ) 
  17.144 +    { 
  17.145      case XLIDE_MAJOR: 
  17.146 -	type = 1; 
  17.147 -	posn = 1; 
  17.148 +        gd = xlide_gendisk;
  17.149  	break; 
  17.150  	
  17.151      case XLSCSI_MAJOR: 
  17.152 -	type = 2; 
  17.153 -	posn = 1; 
  17.154 +        gd = xlscsi_gendisk;
  17.155  	break; 
  17.156  
  17.157 -    default: 
  17.158 -	panic("xldev_to_gendisk: unhandled major %d\n", MAJOR(xldev)); 
  17.159 -	break; 
  17.160 -    } 
  17.161 -
  17.162 -
  17.163 -    for ( i = j = 0; i < xen_disk_info.count; i++ ) {
  17.164 -	if(xen_disk_info.disks[i].type == type)
  17.165 -	    if(++j == posn)
  17.166 -		break; 
  17.167 +    case XLVIRT_MAJOR:
  17.168 +        gd = xlsegment_gendisk;
  17.169 +        break;
  17.170      }
  17.171  
  17.172 -    if(t) 
  17.173 -	*t = type; 
  17.174 +    if ( gd == NULL ) BUG();
  17.175  
  17.176 -    return (xen_disk_info.disks[i].gendisk); 
  17.177 +    return gd;
  17.178  }
  17.179  
  17.180  int xenolinux_block_open(struct inode *inode, struct file *filep)
  17.181 @@ -156,7 +101,6 @@ int xenolinux_block_release(struct inode
  17.182  int xenolinux_block_ioctl(struct inode *inode, struct file *filep,
  17.183  			  unsigned command, unsigned long argument)
  17.184  {
  17.185 -    int minor_dev, type;
  17.186      struct hd_geometry *geo = (struct hd_geometry *)argument;
  17.187      struct gendisk *gd;     
  17.188      struct hd_struct *part; 
  17.189 @@ -167,16 +111,13 @@ int xenolinux_block_ioctl(struct inode *
  17.190      if (!capable(CAP_SYS_ADMIN)) return -EPERM;
  17.191      if (!inode)                  return -EINVAL;
  17.192  
  17.193 -    minor_dev = MINOR(inode->i_rdev);
  17.194 -    if (minor_dev >= XLBLK_MAX)  return -ENODEV;
  17.195 -    
  17.196 -    DPRINTK_IOCTL("command: 0x%x, argument: 0x%lx, minor: 0x%x\n",
  17.197 -                  command, (long) argument, minor_dev); 
  17.198 +    DPRINTK_IOCTL("command: 0x%x, argument: 0x%lx, dev: 0x%04x\n",
  17.199 +                  command, (long) argument, inode->i_rdev); 
  17.200    
  17.201 -    gd = xldev_to_gendisk(inode->i_rdev, &type); 
  17.202 -    part = &gd->part[minor_dev]; 
  17.203 +    gd = xldev_to_gendisk(inode->i_rdev);
  17.204 +    part = &gd->part[MINOR(inode->i_rdev)]; 
  17.205  
  17.206 -    switch (command)
  17.207 +    switch ( command )
  17.208      {
  17.209      case BLKGETSIZE:
  17.210          DPRINTK_IOCTL("   BLKGETSIZE: %x %lx\n", BLKGETSIZE, part->nr_sects); 
  17.211 @@ -187,23 +128,31 @@ int xenolinux_block_ioctl(struct inode *
  17.212  	break;
  17.213  
  17.214      case BLKSSZGET:
  17.215 -	switch(type) {
  17.216 -	case 1: 
  17.217 +	switch ( MAJOR(inode->i_rdev) )
  17.218 +        {
  17.219 +	case XLIDE_MAJOR: 
  17.220  	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET, 
  17.221 -			  xlide_hwsect(minor_dev));
  17.222 -	    return xlide_hwsect(minor_dev); 
  17.223 -	    break; 
  17.224 -	case 2: 
  17.225 +			  xlide_hwsect(MINOR(inode->i_rdev)));
  17.226 +	    return xlide_hwsect(MINOR(inode->i_rdev)); 
  17.227 +
  17.228 +	case XLSCSI_MAJOR: 
  17.229  	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET,
  17.230 -			  xlscsi_hwsect(minor_dev));
  17.231 -	    return xlscsi_hwsect(minor_dev); 
  17.232 -	    break; 
  17.233 +			  xlscsi_hwsect(MINOR(inode->i_rdev)));
  17.234 +	    return xlscsi_hwsect(MINOR(inode->i_rdev)); 
  17.235 +
  17.236 +        case XLVIRT_MAJOR:
  17.237 +	    DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET, 
  17.238 +			  xlsegment_hwsect(MINOR(inode->i_rdev)));
  17.239 +	    return xlsegment_hwsect(MINOR(inode->i_rdev)); 
  17.240  
  17.241  	default: 
  17.242 -	    printk("BLKSSZGET ioctl() on bogus type %d disk!\n", type); 
  17.243 -	    return 0; 
  17.244 +	    printk(KERN_ALERT "BLKSSZGET ioctl() on bogus disk!\n"); 
  17.245 +            return 0;
  17.246 +	}
  17.247  
  17.248 -	}
  17.249 +    case BLKBSZGET:                                        /* get block size */
  17.250 +        DPRINTK_IOCTL("   BLKBSZGET: %x\n", BLKBSZGET);
  17.251 +        break;
  17.252  
  17.253      case BLKBSZSET:                                        /* set block size */
  17.254          DPRINTK_IOCTL("   BLKBSZSET: %x\n", BLKBSZSET);
  17.255 @@ -217,11 +166,6 @@ int xenolinux_block_ioctl(struct inode *
  17.256          DPRINTK_IOCTL("   BLKRAFET: %x\n", BLKRAGET);
  17.257  	break;
  17.258  
  17.259 -    case BLKSSZGET:                                       /* get sector size */
  17.260 -        DPRINTK_IOCTL("   BLKSSZGET: %x 0x%x\n", BLKSSZGET,
  17.261 -                      xlblk_hardsect_size[minor_dev]);
  17.262 -	return xlblk_hardsect_size[minor_dev]; 
  17.263 -
  17.264      case HDIO_GETGEO:
  17.265          /* note: these values are complete garbage */
  17.266          DPRINTK_IOCTL("   HDIO_GETGEO: %x\n", HDIO_GETGEO);
  17.267 @@ -273,21 +217,20 @@ int xenolinux_block_revalidate(kdev_t de
  17.268   *   virtual address in the guest os.
  17.269   * block_number:  block to read
  17.270   * block_size:  size of each block
  17.271 - * device:  xhd or vhd
  17.272 - * gd: partition information if XEN_BLOCK_{READ,WRITE}
  17.273 + * device:  xhd*, ksd*, xvd*, ...
  17.274   */
  17.275 -int hypervisor_request(void *          id,
  17.276 -                       int             operation,
  17.277 -                       char *          buffer,
  17.278 -                       unsigned long   block_number,
  17.279 -                       unsigned short  block_size,
  17.280 -                       kdev_t          device,
  17.281 -		       struct gendisk *gd)
  17.282 +static int hypervisor_request(void *          id,
  17.283 +                              int             operation,
  17.284 +                              char *          buffer,
  17.285 +                              unsigned long   block_number,
  17.286 +                              unsigned short  block_size,
  17.287 +                              kdev_t          device)
  17.288  {
  17.289      int position;
  17.290      void *buffer_ma; 
  17.291      kdev_t phys_device = (kdev_t) 0;
  17.292      unsigned long sector_number = 0;
  17.293 +    struct gendisk *gd;
  17.294   
  17.295      /*
  17.296       * Bail if there's no room in the request communication ring. This may be 
  17.297 @@ -311,12 +254,10 @@ int hypervisor_request(void *          i
  17.298  
  17.299      case XEN_BLOCK_READ:
  17.300      case XEN_BLOCK_WRITE:
  17.301 -        phys_device =  xldev_to_physdev(device); 
  17.302 -	if (!IS_XHD_MAJOR(MAJOR(device)))
  17.303 -            phys_device = MAJOR(device);
  17.304 +        phys_device = xldev_to_physdev(device);
  17.305  	/* Compute real buffer location on disk */
  17.306  	sector_number = block_number;
  17.307 -	gd = xldev_to_gendisk(device, NULL); 
  17.308 +	gd = xldev_to_gendisk(device); 
  17.309  	sector_number += gd->part[MINOR(device)].start_sect;
  17.310          break;
  17.311  
  17.312 @@ -324,7 +265,7 @@ int hypervisor_request(void *          i
  17.313          panic("unknown op %d\n", operation);
  17.314      }
  17.315  
  17.316 -    /* Fill out a communications ring structure & trap to the hypervisor */
  17.317 +    /* Fill out a communications ring structure. */
  17.318      position = blk_ring->req_prod;
  17.319      blk_ring->ring[position].req.id            = id;
  17.320      blk_ring->ring[position].req.operation     = operation;
  17.321 @@ -344,7 +285,7 @@ int hypervisor_request(void *          i
  17.322   * do_xlblk_request
  17.323   *  read a block; request is in a request queue
  17.324   */
  17.325 -void do_xlblk_request (request_queue_t *rq)
  17.326 +void do_xlblk_request(request_queue_t *rq)
  17.327  {
  17.328      struct request *req;
  17.329      struct buffer_head *bh;
  17.330 @@ -373,10 +314,14 @@ void do_xlblk_request (request_queue_t *
  17.331  	{
  17.332              full = hypervisor_request(
  17.333                  bh, (rw == READ) ? XEN_BLOCK_READ : XEN_BLOCK_WRITE, 
  17.334 -                bh->b_data, bh->b_rsector, bh->b_size, bh->b_dev,
  17.335 -		(struct gendisk *)xlblk_disk_info.disks[0].gendisk);
  17.336 +                bh->b_data, bh->b_rsector, bh->b_size, bh->b_dev);
  17.337  
  17.338 -            if ( full ) goto out;
  17.339 +            if ( full )
  17.340 +            {
  17.341 +                pending_queues[nr_pending++] = rq;
  17.342 +                if ( nr_pending >= MAX_PENDING ) BUG();
  17.343 +                goto out;
  17.344 +            }
  17.345  
  17.346              queued++;
  17.347  
  17.348 @@ -411,15 +356,6 @@ void do_xlblk_request (request_queue_t *
  17.349  }
  17.350  
  17.351  
  17.352 -static struct block_device_operations xenolinux_block_fops = 
  17.353 -{
  17.354 -    open:               xenolinux_block_open,
  17.355 -    release:            xenolinux_block_release,
  17.356 -    ioctl:              xenolinux_block_ioctl,
  17.357 -    check_media_change: xenolinux_block_check,
  17.358 -    revalidate:         xenolinux_block_revalidate,
  17.359 -};
  17.360 -
  17.361  static void xlblk_response_int(int irq, void *dev_id, struct pt_regs *ptregs)
  17.362  {
  17.363      int i; 
  17.364 @@ -435,46 +371,56 @@ static void xlblk_response_int(int irq, 
  17.365  	blk_ring_resp_entry_t *bret = &blk_ring->ring[i].resp;
  17.366  	switch (bret->operation)
  17.367  	{
  17.368 -	  case XEN_BLOCK_READ :
  17.369 -  	  case XEN_BLOCK_WRITE :
  17.370 +        case XEN_BLOCK_READ:
  17.371 +        case XEN_BLOCK_WRITE:
  17.372  	    if ( (bh = bret->id) != NULL ) bh->b_end_io(bh, 1);
  17.373  	    break;
  17.374  	    
  17.375 -	  case XEN_BLOCK_SEG_CREATE :
  17.376 -	  case XEN_BLOCK_SEG_DELETE :
  17.377 -	  case XEN_BLOCK_PROBE_SEG :
  17.378 -	    atomic_dec(&xlblk_control_count);
  17.379 -	    break;
  17.380 +        case XEN_BLOCK_SEG_CREATE:
  17.381 +        case XEN_BLOCK_SEG_DELETE:
  17.382 +        case XEN_BLOCK_PROBE_SEG:
  17.383 +        case XEN_BLOCK_PROBE_BLK:
  17.384 +            xlblk_control_msg_pending = 0;
  17.385 +            break;
  17.386  	  
  17.387 -	  default:
  17.388 -	    break;
  17.389 +        default:
  17.390 +            BUG();
  17.391  	}
  17.392      }
  17.393      
  17.394      resp_cons = i;
  17.395  
  17.396 -    /* KAF: We can push work down at this point. We have the lock. */
  17.397 -    for (i = 0; i < xen_disk_info.count; i++) {
  17.398 -	/*
  17.399 -	** XXX SMH: this is pretty broken ... 
  17.400 -	**     a) should really only kick devs w/ outstanding work 
  17.401 -	**     b) should cover /all/ devs, not just first IDE & SCSI
  17.402 -	** KAF will fix this I'm sure. 
  17.403 -	*/
  17.404 -	do_xlblk_request(BLK_DEFAULT_QUEUE(IDE0_MAJOR));
  17.405 -	do_xlblk_request(BLK_DEFAULT_QUEUE(SCSI_DISK0_MAJOR));
  17.406 -        do_xlseg_requestX(BLK_DEFAULT_QUEUE(XLSEG_MAJOR));
  17.407 +    /* We kick pending request queues if the ring is reasonably empty. */
  17.408 +    if ( (nr_pending != 0) && 
  17.409 +         (((blk_ring->req_prod - resp_cons) & (BLK_RING_SIZE - 1)) < 
  17.410 +          (BLK_RING_SIZE >> 1)) )
  17.411 +    {
  17.412 +        do { do_xlblk_request(pending_queues[--nr_pending]); }
  17.413 +        while ( nr_pending != 0 );
  17.414      }
  17.415  
  17.416      spin_unlock_irqrestore(&io_request_lock, flags);
  17.417  }
  17.418  
  17.419  
  17.420 +/* Send a synchronous message to Xen. */
  17.421 +int xenolinux_control_msg(int operation, char *buffer)
  17.422 +{
  17.423 +    xlblk_control_msg_pending = 1; barrier();
  17.424 +    if ( hypervisor_request(NULL, operation, buffer, 0, 0, 0) )
  17.425 +        return -EAGAIN;
  17.426 +    HYPERVISOR_block_io_op();
  17.427 +    while ( xlblk_control_msg_pending ) barrier();    
  17.428 +    return 0;
  17.429 +}
  17.430 +
  17.431 +
  17.432  int __init xlblk_init(void)
  17.433  {
  17.434 -    int i, error, result;
  17.435 +    int error;
  17.436  
  17.437 -    atomic_set(&xlblk_control_count, 0);
  17.438 +    xlblk_control_msg_pending = 0;
  17.439 +    nr_pending = 0;
  17.440  
  17.441      /* This mapping was created early at boot time. */
  17.442      blk_ring = (blk_ring_t *)fix_to_virt(FIX_BLKRING_BASE);
  17.443 @@ -482,44 +428,26 @@ int __init xlblk_init(void)
  17.444      
  17.445      error = request_irq(XLBLK_RESPONSE_IRQ, xlblk_response_int, 0, 
  17.446  			"xlblk-response", NULL);
  17.447 -    if (error) {
  17.448 +    if ( error )
  17.449 +    {
  17.450  	printk(KERN_ALERT "Could not allocate receive interrupt\n");
  17.451  	goto fail;
  17.452      }
  17.453  
  17.454 -    /* probe for disk information */
  17.455 -    memset (&xlblk_disk_info, 0, sizeof(xlblk_disk_info));
  17.456 -    xlblk_disk_info.count = 0;
  17.457 +    /* Probe for disk information. */
  17.458 +    memset(&xlblk_disk_info, 0, sizeof(xlblk_disk_info));
  17.459 +    error = xenolinux_control_msg(XEN_BLOCK_PROBE_BLK, 
  17.460 +                                  (char *)&xlblk_disk_info);
  17.461 +    if ( error )
  17.462 +    {
  17.463 +        printk(KERN_ALERT "Could not probe disks (%d)\n", error);
  17.464 +        free_irq(XLBLK_RESPONSE_IRQ, NULL);
  17.465 +        goto fail;
  17.466 +    }
  17.467  
  17.468 -    if ( hypervisor_request(NULL, XEN_BLOCK_PROBE_BLK, 
  17.469 -			    (char *) &xlblk_disk_info,
  17.470 -                            0, 0, (kdev_t) 0, 
  17.471 -			    (struct gendisk *) NULL))
  17.472 -        BUG();
  17.473 -    HYPERVISOR_block_io_op();
  17.474 -    while ( blk_ring->resp_prod != 1 ) barrier();
  17.475 -    for ( i = 0; i < xlblk_disk_info.count; i++ )
  17.476 -    { 
  17.477 -	/* 
  17.478 -	** SMH: initialize all the disks we found; this is complicated a 
  17.479 -	** bit by the fact that we have both IDE and SCSI disks underneath 
  17.480 -	*/
  17.481 -	printk (KERN_ALERT "  %2d: type: %d, capacity: %ld\n",
  17.482 -		i, xlblk_disk_info.disks[i].type, 
  17.483 -		xlblk_disk_info.disks[i].capacity);
  17.484 -	
  17.485 -	switch(xen_disk_info.disks[i].type) { 
  17.486 -	case 1: 
  17.487 -	    xlide_init(i, nide++); 
  17.488 -	    break; 
  17.489 -	case 2: 
  17.490 -	    xlscsi_init(i, nscsi++); 
  17.491 -	    break; 
  17.492 -	default: 
  17.493 -	    printk("Unknown Xen disk type %d\n", xen_disk_info.disks[i].type);
  17.494 -	    break; 
  17.495 -	}
  17.496 -    }
  17.497 +    /* Pass the information to our fake IDE and SCSI susbystems. */
  17.498 +    xlide_init(&xlblk_disk_info);
  17.499 +    xlscsi_init(&xlblk_disk_info);
  17.500  
  17.501      return 0;
  17.502  
  17.503 @@ -529,25 +457,9 @@ int __init xlblk_init(void)
  17.504  
  17.505  static void __exit xlblk_cleanup(void)
  17.506  {
  17.507 -    int i; 
  17.508 -
  17.509 -    for ( i = 0; i < xen_disk_info.count; i++ )
  17.510 -    { 
  17.511 -	switch(xen_disk_info.disks[i].type) { 
  17.512 -	case 1: 
  17.513 -	    xlide_cleanup(); 
  17.514 -	    break; 
  17.515 -	case 2: 
  17.516 -	    xlscsi_cleanup(); 
  17.517 -	    break; 
  17.518 -	default: 
  17.519 -	    printk("Unknown Xen disk type %d\n", xen_disk_info.disks[i].type);
  17.520 -	    break; 
  17.521 -	}
  17.522 -
  17.523 -    }
  17.524 -
  17.525 -    return;
  17.526 +    xlide_cleanup();
  17.527 +    xlscsi_cleanup();
  17.528 +    free_irq(XLBLK_RESPONSE_IRQ, NULL);
  17.529  }
  17.530  
  17.531  
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block.h	Fri Mar 07 01:38:49 2003 +0000
    18.3 @@ -0,0 +1,64 @@
    18.4 +/******************************************************************************
    18.5 + * xl_block.h
    18.6 + * 
    18.7 + * Shared definitions between all levels of XenoLinux Virtual block devices.
    18.8 + */
    18.9 +
   18.10 +#ifndef __XL_BLOCK_H__
   18.11 +#define __XL_BLOCK_H__
   18.12 +
   18.13 +#include <linux/config.h>
   18.14 +#include <linux/module.h>
   18.15 +
   18.16 +#include <linux/kernel.h>
   18.17 +#include <linux/sched.h>
   18.18 +#include <linux/slab.h>
   18.19 +#include <linux/string.h>
   18.20 +#include <linux/errno.h>
   18.21 +
   18.22 +#include <linux/fs.h>
   18.23 +#include <linux/hdreg.h>
   18.24 +#include <linux/blkdev.h>
   18.25 +#include <linux/major.h>
   18.26 +
   18.27 +#include <asm/hypervisor-ifs/block.h>
   18.28 +#include <asm/hypervisor-ifs/hypervisor-if.h>
   18.29 +#include <asm/io.h>
   18.30 +#include <asm/atomic.h>
   18.31 +#include <asm/uaccess.h>
   18.32 +
   18.33 +#if 0
   18.34 +#define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   18.35 +#define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   18.36 +#else
   18.37 +#define DPRINTK(_f, _a...) ((void)0)
   18.38 +#define DPRINTK_IOCTL(_f, _a...) ((void)0)
   18.39 +#endif
   18.40 +
   18.41 +/* Generic layer. */
   18.42 +extern int xenolinux_control_msg(int operration, char *buffer);
   18.43 +extern int xenolinux_block_open(struct inode *inode, struct file *filep);
   18.44 +extern int xenolinux_block_release(struct inode *inode, struct file *filep);
   18.45 +extern int xenolinux_block_ioctl(struct inode *inode, struct file *filep,
   18.46 +				 unsigned command, unsigned long argument);
   18.47 +extern int xenolinux_block_check(kdev_t dev);
   18.48 +extern int xenolinux_block_revalidate(kdev_t dev);
   18.49 +extern void do_xlblk_request (request_queue_t *rq); 
   18.50 +
   18.51 +/* Fake IDE subsystem. */
   18.52 +extern int  xlide_init(xen_disk_info_t *xdi);
   18.53 +extern int  xlide_hwsect(int minor); 
   18.54 +extern void xlide_cleanup(void); 
   18.55 +extern struct gendisk *xlide_gendisk;
   18.56 +
   18.57 +/* Fake SCSI subsystem. */
   18.58 +extern int  xlscsi_init(xen_disk_info_t *xdi);
   18.59 +extern int  xlscsi_hwsect(int minor); 
   18.60 +extern void xlscsi_cleanup(void); 
   18.61 +extern struct gendisk *xlscsi_gendisk;
   18.62 +
   18.63 +/* Virtual block-device subsystem. */
   18.64 +extern int  xlsegment_hwsect(int minor); 
   18.65 +extern struct gendisk *xlsegment_gendisk;
   18.66 +
   18.67 +#endif /* __XL_BLOCK_H__ */
    19.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_block_test.c	Thu Mar 06 16:54:15 2003 +0000
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,255 +0,0 @@
    19.4 -/******************************************************************************
    19.5 - * xenolinux_block_test.c
    19.6 - * 
    19.7 - */
    19.8 -#define EXPORT_SYMTAB
    19.9 -
   19.10 -#include <linux/config.h>
   19.11 -#include <linux/module.h>
   19.12 -
   19.13 -#include <linux/kernel.h>
   19.14 -#include <linux/init.h>
   19.15 -#include <linux/proc_fs.h>
   19.16 -#include <linux/sched.h>
   19.17 -#include <asm/uaccess.h>
   19.18 -#include <linux/slab.h>
   19.19 -#include <linux/string.h>
   19.20 -#include <linux/errno.h>
   19.21 -#include <linux/delay.h>
   19.22 -
   19.23 -#include <asm/hypervisor-ifs/block.h>
   19.24 -#include <asm/hypervisor-ifs/hypervisor-if.h>
   19.25 -
   19.26 -/******************************************************************/
   19.27 -
   19.28 -static struct proc_dir_entry *bdt;
   19.29 -static blk_ring_req_entry_t meta;
   19.30 -static char * data;
   19.31 -
   19.32 -static int proc_read_bdt(char *page, char **start, off_t off,
   19.33 -			 int count, int *eof, void *data)
   19.34 -{
   19.35 -  switch (meta.operation)
   19.36 -  {
   19.37 -    case XEN_BLOCK_READ :
   19.38 -    case XEN_BLOCK_WRITE :
   19.39 -    {
   19.40 -      return proc_dump_block(page, start, off, count, eof, data);
   19.41 -    }
   19.42 -    case XEN_BLOCK_DEBUG :
   19.43 -    {
   19.44 -      return proc_dump_debug(page, start, off, count, eof, data);
   19.45 -    }
   19.46 -    default :
   19.47 -    {
   19.48 -      printk(KERN_ALERT 
   19.49 -	     "block device test error: unknown operation [%c]\n",
   19.50 -	     meta.operation);
   19.51 -      return -EINVAL;
   19.52 -    }
   19.53 -  }
   19.54 -}
   19.55 -
   19.56 -int proc_dump_debug(char *page, char **start, off_t off,
   19.57 -		    int count, int *eof, void *data)
   19.58 -{
   19.59 -  char header[100];
   19.60 -  char dump[1024];
   19.61 -
   19.62 -  sprintf (header, "Block Device Test: Debug Dump\n\n");
   19.63 -  
   19.64 -  sprintf (dump, "%s\n", meta.buffer);
   19.65 -  
   19.66 -  if (data)
   19.67 -  {
   19.68 -    kfree(data);
   19.69 -  }
   19.70 -
   19.71 -  strncpy (page, dump, count);
   19.72 -  return strlen(page);
   19.73 -}
   19.74 -
   19.75 -int proc_dump_block(char *page, char **start, off_t off,
   19.76 -		    int count, int *eof, void *data)
   19.77 -{
   19.78 -  char header[100];
   19.79 -  char dump[1024];
   19.80 -  char temp[100];
   19.81 -  int loop;
   19.82 -
   19.83 -  sprintf (header, "Block Device Test\n\n%s  blk num: %ld 0x%lx;  size: %d 0x%x;  device: 0x%x\n",
   19.84 -	   meta.operation == XEN_BLOCK_WRITE ? "write" : "read",
   19.85 -	   meta.block_number, meta.block_number,
   19.86 -	   meta.block_size, meta.block_size,
   19.87 -	   meta.device);
   19.88 -  
   19.89 -  sprintf (dump, "%s", header);
   19.90 -
   19.91 -  if (meta.buffer)
   19.92 -  {
   19.93 -    for (loop = 0; loop < 100; loop++)
   19.94 -    {
   19.95 -      int i = meta.buffer[loop];
   19.96 -    
   19.97 -      if (loop % 8 == 0)
   19.98 -      {
   19.99 -	sprintf (temp, "[%2d] ", loop);
  19.100 -	strcat(dump, temp);
  19.101 -      }
  19.102 -      else if (loop % 2 == 0)
  19.103 -      {
  19.104 -	strcat(dump, " ");
  19.105 -      }
  19.106 -
  19.107 -      sprintf (temp, " 0x%02x", i & 255);
  19.108 -      strcat(dump, temp);
  19.109 -      if ((loop + 1) % 8 == 0)
  19.110 -      {
  19.111 -	strcat(dump, "\n");
  19.112 -      }
  19.113 -    }
  19.114 -    strcat(dump, "\n\n");
  19.115 -  }
  19.116 -  
  19.117 -  if (data)
  19.118 -  {
  19.119 -    kfree(data);
  19.120 -  }
  19.121 -
  19.122 -  strncpy (page, dump, count);
  19.123 -  return strlen(page);
  19.124 -}
  19.125 -
  19.126 -int proc_write_bdt(struct file *file, const char *buffer,
  19.127 -		   unsigned long count, void *data)
  19.128 -{
  19.129 -  char *local = kmalloc((count + 1) * sizeof(char), GFP_KERNEL);
  19.130 -  char  opcode;
  19.131 -  int  block_number = 0;
  19.132 -  int  block_size = 0;
  19.133 -  int  device = 0;
  19.134 -
  19.135 -  if (copy_from_user(local, buffer, count))
  19.136 -  {
  19.137 -    return -EFAULT;
  19.138 -  }
  19.139 -  local[count] = '\0';
  19.140 -
  19.141 -  sscanf(local, "%c %i %i %i", 
  19.142 -	 &opcode, &block_number, &block_size, &device);
  19.143 -
  19.144 -  if (data)
  19.145 -  {
  19.146 -    kfree(data);
  19.147 -  }
  19.148 -
  19.149 -  if (opcode == 'r' || opcode == 'R')
  19.150 -  {
  19.151 -    meta.operation = XEN_BLOCK_READ;
  19.152 -  }
  19.153 -  else if (opcode == 'w' || opcode == 'W')
  19.154 -  {
  19.155 -    meta.operation = XEN_BLOCK_WRITE;
  19.156 -  }
  19.157 -  else if (opcode == 'd' || opcode == 'D')
  19.158 -  {
  19.159 -    meta.operation = XEN_BLOCK_DEBUG;
  19.160 -    block_size = 10000;
  19.161 -  }
  19.162 -  else if (opcode == 'c' || opcode == 'C')
  19.163 -  {
  19.164 -    xv_disk_t *xvd;
  19.165 -    int loop;
  19.166 -
  19.167 -    meta.operation = XEN_BLOCK_SEG_CREATE;
  19.168 -    data = kmalloc (sizeof(xv_disk_t), GFP_KERNEL);
  19.169 -    if (data == NULL)
  19.170 -    {
  19.171 -      kfree(local);
  19.172 -      return -ENOMEM;
  19.173 -    }
  19.174 -    
  19.175 -    xvd = (xv_disk_t *)data;
  19.176 -    xvd->mode = XEN_DISK_READ_WRITE;
  19.177 -    xvd->domain = block_number;
  19.178 -    xvd->segment = block_size;
  19.179 -    xvd->ext_count = device;
  19.180 -    for (loop = 0; loop < xvd->ext_count; loop++)
  19.181 -    {
  19.182 -      xvd->extents[loop].disk = block_number + 1;                  /* random */
  19.183 -      xvd->extents[loop].offset = block_size + 1;
  19.184 -      xvd->extents[loop].size = device + 1;
  19.185 -    }
  19.186 -  }
  19.187 -  else
  19.188 -  {
  19.189 -    printk(KERN_ALERT 
  19.190 -	   "block device test error: unknown opcode [%c]\n", opcode);
  19.191 -    return -EINVAL;
  19.192 -  }
  19.193 -
  19.194 -  if (data == NULL)
  19.195 -  {
  19.196 -    data = kmalloc(block_size * sizeof(char), GFP_KERNEL);
  19.197 -    if (data == NULL)
  19.198 -    {
  19.199 -      kfree(local);
  19.200 -      return -ENOMEM;
  19.201 -    }
  19.202 -  }
  19.203 -
  19.204 -  meta.block_number = block_number;
  19.205 -  meta.block_size   = block_size;
  19.206 -  meta.device       = device;
  19.207 -  meta.buffer       = data;
  19.208 -
  19.209 -  /* submit request */
  19.210 -  hypervisor_request(0, meta.operation, meta.buffer, 
  19.211 -		     meta.block_number, meta.block_size,
  19.212 -		     meta.device, 
  19.213 -		     (struct gendisk *) NULL);
  19.214 -  HYPERVISOR_block_io_op();
  19.215 -  mdelay(1000); /* should wait for a proper acknowledgement/response. */
  19.216 -
  19.217 -  kfree(local);
  19.218 -  return count;
  19.219 -}
  19.220 -			 
  19.221 -
  19.222 -static int __init init_module(void)
  19.223 -{
  19.224 -  int return_value = 0;
  19.225 -
  19.226 -  /* create proc entry */
  19.227 -  bdt = create_proc_entry("bdt", 0644, NULL);
  19.228 -  if (bdt == NULL)
  19.229 -  {
  19.230 -    return_value = -ENOMEM;
  19.231 -    goto error;
  19.232 -  }
  19.233 -  bdt->data       = NULL;
  19.234 -  bdt->read_proc  = proc_read_bdt;
  19.235 -  bdt->write_proc = proc_write_bdt;
  19.236 -  bdt->owner      = THIS_MODULE;
  19.237 -
  19.238 -  memset(&meta, 0, sizeof(meta));
  19.239 -  
  19.240 -  /* success */
  19.241 -  printk(KERN_ALERT "XenoLinux Block Device Test installed\n");
  19.242 -  return 0;
  19.243 -
  19.244 - error:
  19.245 -  return return_value;
  19.246 -}
  19.247 -
  19.248 -static void __exit cleanup_module(void)
  19.249 -{
  19.250 -  if (data)
  19.251 -  {
  19.252 -    kfree(data);
  19.253 -  }
  19.254 -  printk(KERN_ALERT "XenoLinux Block Device Test uninstalled\n");
  19.255 -}
  19.256 -
  19.257 -module_init(init_module);
  19.258 -module_exit(cleanup_module);
    20.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c	Thu Mar 06 16:54:15 2003 +0000
    20.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_ide.c	Fri Mar 07 01:38:49 2003 +0000
    20.3 @@ -5,49 +5,20 @@
    20.4   * 
    20.5   */
    20.6  
    20.7 -#include <linux/config.h>
    20.8 -#include <linux/module.h>
    20.9 +#include "xl_block.h"
   20.10  
   20.11 -#include <linux/kernel.h>
   20.12 -#include <linux/sched.h>
   20.13 -#include <linux/slab.h>
   20.14 -#include <linux/string.h>
   20.15 -#include <linux/errno.h>
   20.16 -
   20.17 -#include <linux/fs.h>
   20.18 -#include <linux/hdreg.h>
   20.19 -#include <linux/blkdev.h>
   20.20 -#include <linux/major.h>
   20.21 -
   20.22 -#define MAJOR_NR XLIDE_MAJOR   /* force defns in blk.h, must precede include */
   20.23 -static int xlide_major = XLIDE_MAJOR;
   20.24 +#define MAJOR_NR XLIDE_MAJOR 
   20.25  #include <linux/blk.h>
   20.26  
   20.27 -void xlide_ide_register_disk(int, unsigned long);
   20.28 -
   20.29 -#define XLIDE_MAX 32 /* Maximum minor devices we support */
   20.30 +/* We support up to 16 devices of up to 16 partitions each. */
   20.31 +#define XLIDE_MAX         256
   20.32  #define XLIDE_MAJOR_NAME "xhd"
   20.33 -#define IDE_PARTN_BITS 6                           /* from ide.h::PARTN_BITS */
   20.34 -#define IDE_PARTN_MASK ((1<<IDE_PARTN_BITS)-1)     /* from ide.h::PARTN_MASK */
   20.35 -static int xlide_blk_size[XLIDE_MAX];
   20.36 +#define IDE_PARTN_BITS    4
   20.37  static int xlide_blksize_size[XLIDE_MAX];
   20.38 -static int xlide_read_ahead; 
   20.39  static int xlide_hardsect_size[XLIDE_MAX];
   20.40  static int xlide_max_sectors[XLIDE_MAX];
   20.41  
   20.42 -extern xen_disk_info_t xen_disk_info;
   20.43 -
   20.44 -
   20.45 -extern int xenolinux_block_open(struct inode *inode, struct file *filep);
   20.46 -extern int xenolinux_block_release(struct inode *inode, struct file *filep);
   20.47 -extern int xenolinux_block_ioctl(struct inode *inode, struct file *filep,
   20.48 -				 unsigned command, unsigned long argument);
   20.49 -extern int xenolinux_block_check(kdev_t dev);
   20.50 -extern int xenolinux_block_revalidate(kdev_t dev);
   20.51 -
   20.52 -
   20.53 -extern void do_xlblk_request (request_queue_t *rq); 
   20.54 -
   20.55 +struct gendisk *xlide_gendisk;
   20.56  
   20.57  static struct block_device_operations xlide_block_fops = 
   20.58  {
   20.59 @@ -59,109 +30,92 @@ static struct block_device_operations xl
   20.60  };
   20.61  
   20.62  
   20.63 -/* tiny inteface fn */
   20.64  int xlide_hwsect(int minor) 
   20.65  {
   20.66      return xlide_hardsect_size[minor]; 
   20.67  } 
   20.68  
   20.69  
   20.70 -void xlide_register_disk(int xidx, int idx)
   20.71 +int xlide_init(xen_disk_info_t *xdi) 
   20.72  {
   20.73 -    int units;
   20.74 -    int minors;
   20.75 +    int i, result, units, minors, disk;
   20.76      struct gendisk *gd;
   20.77  
   20.78 -    /* plagarized from ide-probe.c::init_gendisk */
   20.79 -    units = 2; /* from ide.h::MAX_DRIVES */
   20.80 +    SET_MODULE_OWNER(&xlide_block_fops);
   20.81 +
   20.82 +    result = register_blkdev(XLIDE_MAJOR, XLIDE_MAJOR_NAME, 
   20.83 +                             &xlide_block_fops);
   20.84 +    if ( result < 0 )
   20.85 +    {
   20.86 +	printk (KERN_ALERT "XL IDE: can't get major %d\n", XLIDE_MAJOR);
   20.87 +	return result;
   20.88 +    }
   20.89 +
   20.90 +    /* Initialize global arrays. */
   20.91 +    for ( i = 0; i < XLIDE_MAX; i++ )
   20.92 +    {
   20.93 +	xlide_blksize_size[i]  = 512;
   20.94 +	xlide_hardsect_size[i] = 512;
   20.95 +	xlide_max_sectors[i]   = 128;
   20.96 +    }
   20.97  
   20.98 +    blk_size[XLIDE_MAJOR]      = NULL;
   20.99 +    blksize_size[XLIDE_MAJOR]  = xlide_blksize_size;
  20.100 +    hardsect_size[XLIDE_MAJOR] = xlide_hardsect_size;
  20.101 +    max_sectors[XLIDE_MAJOR]   = xlide_max_sectors;
  20.102 +    read_ahead[XLIDE_MAJOR]    = 8;
  20.103 +
  20.104 +    blk_init_queue(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), do_xlblk_request);
  20.105 +
  20.106 +    /*
  20.107 +     * Turn off barking 'headactive' mode. We dequeue buffer heads as
  20.108 +     * soon as we pass them down to Xen.
  20.109 +     */
  20.110 +    blk_queue_headactive(BLK_DEFAULT_QUEUE(XLIDE_MAJOR), 0);
  20.111 +
  20.112 +    /* Count number of IDE devices installed in the system. */
  20.113 +    units = 0;
  20.114 +    for ( i = 0; i < xdi->count; i++ )
  20.115 +        if ( xdi->disks[i].type == XEN_DISK_IDE ) units++;
  20.116 +
  20.117 +    /* Construct an appropriate gendisk structure. */
  20.118      minors    = units * (1<<IDE_PARTN_BITS);
  20.119 -    gd        = kmalloc (sizeof(struct gendisk), GFP_KERNEL);
  20.120 -    gd->sizes = kmalloc (minors * sizeof(int), GFP_KERNEL);
  20.121 -    gd->part  = kmalloc (minors * sizeof(struct hd_struct), GFP_KERNEL);
  20.122 -    memset(gd->part, 0, minors * sizeof(struct hd_struct));
  20.123 -    
  20.124 -    gd->major        = xlide_major;         /* XXX should be idx-specific */
  20.125 -    gd->major_name   = XLIDE_MAJOR_NAME;    /* XXX should be idx-specific */
  20.126 +    gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
  20.127 +    gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
  20.128 +    gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
  20.129 +    gd->major        = XLIDE_MAJOR;
  20.130 +    gd->major_name   = XLIDE_MAJOR_NAME;
  20.131      gd->minor_shift  = IDE_PARTN_BITS; 
  20.132      gd->max_p	     = 1<<IDE_PARTN_BITS;
  20.133      gd->nr_real	     = units;           
  20.134      gd->real_devices = NULL;          
  20.135      gd->next	     = NULL;            
  20.136      gd->fops         = &xlide_block_fops;
  20.137 -    gd->de_arr       = kmalloc (sizeof *gd->de_arr * units, GFP_KERNEL);
  20.138 -    gd->flags	     = kmalloc (sizeof *gd->flags * units, GFP_KERNEL);
  20.139 -
  20.140 -    if (gd->de_arr)  
  20.141 -	memset (gd->de_arr, 0, sizeof *gd->de_arr * units);
  20.142 -
  20.143 -    if (gd->flags) 
  20.144 -	memset (gd->flags, 0, sizeof *gd->flags * units);
  20.145 -
  20.146 +    gd->de_arr       = kmalloc(sizeof(*gd->de_arr) * units, GFP_KERNEL);
  20.147 +    gd->flags	     = kmalloc(sizeof(*gd->flags) * units, GFP_KERNEL);
  20.148 +    memset(gd->sizes, 0, minors * sizeof(int));
  20.149 +    memset(gd->part,  0, minors * sizeof(struct hd_struct));
  20.150 +    memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
  20.151 +    memset(gd->flags, 0, sizeof(*gd->flags) * units);
  20.152 +    xlide_gendisk = gd;
  20.153      add_gendisk(gd);
  20.154  
  20.155 -    xen_disk_info.disks[xidx].gendisk = gd;
  20.156 -
  20.157 -    /* XXX major should be idx-specific */
  20.158 -    register_disk(gd, MKDEV(xlide_major, 0), 1<<IDE_PARTN_BITS, 
  20.159 -		  &xlide_block_fops, xen_disk_info.disks[xidx].capacity);
  20.160 -
  20.161 -    return;
  20.162 -}
  20.163 -
  20.164 -
  20.165 -
  20.166 -/*
  20.167 -** Initialize a XenoLinux IDE disk; the 'xidx' is the index into the 
  20.168 -** xen_disk_info array so we can grab interesting values; the 'idx' is 
  20.169 -** a count of the number of XLSCSI disks we've seen so far, starting at 0
  20.170 -** XXX SMH: this is all so ugly because the xen_disk_info() structure and 
  20.171 -** array doesn't really give us what we want. Ho hum. To be tidied someday. 
  20.172 -*/
  20.173 -int xlide_init(int xidx, int idx) 
  20.174 -{
  20.175 -    int i, major, result;
  20.176 -
  20.177 -    SET_MODULE_OWNER(&xlide_block_fops);
  20.178 -
  20.179 -    major  = xlide_major + idx;  /* XXX assume we have a linear major space */
  20.180 -
  20.181 -    /* XXX SMH: name below should vary with major */
  20.182 -    result = register_blkdev(major, XLIDE_MAJOR_NAME, &xlide_block_fops);
  20.183 -    if (result < 0) {
  20.184 -	printk (KERN_ALERT "XL IDE: can't get major %d\n",
  20.185 -		major);
  20.186 -	return result;
  20.187 +    /* Now register each disk in turn. */
  20.188 +    disk = 0;
  20.189 +    for ( i = 0; i < xdi->count; i++ )
  20.190 +    {
  20.191 +        if ( xdi->disks[i].type != XEN_DISK_IDE ) continue;
  20.192 +        register_disk(gd, 
  20.193 +                      MKDEV(XLIDE_MAJOR, disk<<IDE_PARTN_BITS), 
  20.194 +                      1<<IDE_PARTN_BITS, 
  20.195 +                      &xlide_block_fops, 
  20.196 +                      xdi->disks[i].capacity);
  20.197 +        disk++;
  20.198      }
  20.199 -
  20.200 -    /* initialize global arrays in drivers/block/ll_rw_block.c */
  20.201 -    for (i = 0; i < XLIDE_MAX; i++) {
  20.202 -	xlide_blk_size[i]      = xen_disk_info.disks[0].capacity;
  20.203 -	xlide_blksize_size[i]  = 512;
  20.204 -	xlide_hardsect_size[i] = 512;
  20.205 -	xlide_max_sectors[i]   = 128;
  20.206 -    }
  20.207 -    xlide_read_ahead  = 8; 
  20.208 -
  20.209 -    blk_size[major]      = xlide_blk_size;
  20.210 -    blksize_size[major]  = xlide_blksize_size;
  20.211 -    hardsect_size[major] = xlide_hardsect_size;
  20.212 -    read_ahead[major]    = xlide_read_ahead; 
  20.213 -    max_sectors[major]   = xlide_max_sectors;
  20.214 -
  20.215 -    blk_init_queue(BLK_DEFAULT_QUEUE(major), do_xlblk_request);
  20.216 -
  20.217 -    /*
  20.218 -     * Turn off barking 'headactive' mode. We dequeue buffer heads as
  20.219 -     * soon as we pass them down to Xen.
  20.220 -     */
  20.221 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(major), 0);
  20.222 -
  20.223 -    xlide_register_disk(xidx, idx); 
  20.224 -
  20.225 +   
  20.226      printk(KERN_ALERT 
  20.227  	   "XenoLinux Virtual IDE Device Driver installed [device: %d]\n",
  20.228 -	   major);
  20.229 +	   XLIDE_MAJOR);
  20.230  
  20.231      return 0;
  20.232  }
  20.233 @@ -169,32 +123,34 @@ int xlide_init(int xidx, int idx)
  20.234  
  20.235  void xlide_cleanup(void)
  20.236  {
  20.237 -    /* CHANGE FOR MULTIQUEUE */
  20.238 -    blk_cleanup_queue(BLK_DEFAULT_QUEUE(xlide_major));
  20.239 +    blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLIDE_MAJOR));
  20.240 +
  20.241 +    xlide_gendisk = NULL;
  20.242 +
  20.243 +    read_ahead[XLIDE_MAJOR] = 0;
  20.244  
  20.245 -    /* clean up global arrays */
  20.246 -    read_ahead[xlide_major] = 0;
  20.247 -
  20.248 -    if (blk_size[xlide_major]) 
  20.249 -	kfree(blk_size[xlide_major]);
  20.250 -    blk_size[xlide_major] = NULL;
  20.251 +    if ( blksize_size[XLIDE_MAJOR] != NULL )
  20.252 +    { 
  20.253 +	kfree(blksize_size[XLIDE_MAJOR]);
  20.254 +        blksize_size[XLIDE_MAJOR] = NULL;
  20.255 +    }
  20.256  
  20.257 -    if (blksize_size[xlide_major]) 
  20.258 -	kfree(blksize_size[xlide_major]);
  20.259 -    blksize_size[xlide_major] = NULL;
  20.260 -
  20.261 -    if (hardsect_size[xlide_major]) 
  20.262 -	kfree(hardsect_size[xlide_major]);
  20.263 -    hardsect_size[xlide_major] = NULL;
  20.264 +    if ( hardsect_size[XLIDE_MAJOR] != NULL )
  20.265 +    { 
  20.266 +	kfree(hardsect_size[XLIDE_MAJOR]);
  20.267 +        hardsect_size[XLIDE_MAJOR] = NULL;
  20.268 +    }
  20.269      
  20.270 -    /* XXX: free each gendisk */
  20.271 -    if (unregister_blkdev(xlide_major, XLIDE_MAJOR_NAME))
  20.272 +    if ( max_sectors[XLIDE_MAJOR] != NULL )
  20.273 +    { 
  20.274 +	kfree(max_sectors[XLIDE_MAJOR]);
  20.275 +        max_sectors[XLIDE_MAJOR] = NULL;
  20.276 +    }
  20.277 +    
  20.278 +    if ( unregister_blkdev(XLIDE_MAJOR, XLIDE_MAJOR_NAME) != 0 )
  20.279 +    {
  20.280  	printk(KERN_ALERT
  20.281  	       "XenoLinux Virtual IDE Device Driver uninstalled w/ errs\n");
  20.282 -    else
  20.283 -	printk(KERN_ALERT 
  20.284 -	       "XenoLinux Virtual IDE Device Driver uninstalled\n");
  20.285 -
  20.286 -    return;
  20.287 +    }
  20.288  }
  20.289  
    21.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c	Thu Mar 06 16:54:15 2003 +0000
    21.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_scsi.c	Fri Mar 07 01:38:49 2003 +0000
    21.3 @@ -5,58 +5,20 @@
    21.4   * 
    21.5   */
    21.6  
    21.7 -#include <linux/config.h>
    21.8 -#include <linux/module.h>
    21.9 +#include "xl_block.h"
   21.10  
   21.11 -#include <linux/kernel.h>
   21.12 -#include <linux/sched.h>
   21.13 -#include <linux/slab.h>
   21.14 -#include <linux/string.h>
   21.15 -#include <linux/errno.h>
   21.16 -
   21.17 -#include <linux/fs.h>
   21.18 -#include <linux/hdreg.h>
   21.19 -#include <linux/blkdev.h>
   21.20 -#include <linux/major.h>
   21.21 -
   21.22 -#define MAJOR_NR XLSCSI_MAJOR   /* force defns in blk.h, must precede include */
   21.23 -static int xlscsi_major = XLSCSI_MAJOR;
   21.24 +#define MAJOR_NR XLSCSI_MAJOR
   21.25  #include <linux/blk.h>
   21.26  
   21.27 -/* Copied from linux/ide.h */
   21.28 -typedef unsigned char	byte; 
   21.29 -
   21.30 -void xlscsi_ide_register_disk(int, unsigned long);
   21.31 -
   21.32 -#define SCSI_DISKS_PER_MAJOR 16    /* max number of devices per scsi major */
   21.33 -#define XLSCSI_MAX 32              /* maximum minor devices we support */
   21.34 +/* We support up to 16 devices of up to 16 partitions each. */
   21.35 +#define XLSCSI_MAX        256
   21.36  #define XLSCSI_MAJOR_NAME "xsd"
   21.37 -
   21.38 -static int xlscsi_blk_size[XLSCSI_MAX];
   21.39 +#define SCSI_PARTN_BITS   4
   21.40  static int xlscsi_blksize_size[XLSCSI_MAX];
   21.41 -static int xlscsi_read_ahead; 
   21.42  static int xlscsi_hardsect_size[XLSCSI_MAX];
   21.43  static int xlscsi_max_sectors[XLSCSI_MAX];
   21.44  
   21.45 -#if 0
   21.46 -#define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   21.47 -#define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   21.48 -#else
   21.49 -#define DPRINTK(_f, _a...) ((void)0)
   21.50 -#define DPRINTK_IOCTL(_f, _a...) ((void)0)
   21.51 -#endif
   21.52 -
   21.53 -extern xen_disk_info_t xen_disk_info;
   21.54 -
   21.55 -extern int xenolinux_block_open(struct inode *inode, struct file *filep);
   21.56 -extern int xenolinux_block_release(struct inode *inode, struct file *filep);
   21.57 -extern int xenolinux_block_ioctl(struct inode *inode, struct file *filep,
   21.58 -				 unsigned command, unsigned long argument);
   21.59 -extern int xenolinux_block_check(kdev_t dev);
   21.60 -extern int xenolinux_block_revalidate(kdev_t dev);
   21.61 -
   21.62 -
   21.63 -extern void do_xlblk_request (request_queue_t *rq); 
   21.64 +struct gendisk *xlscsi_gendisk = NULL;
   21.65  
   21.66  static struct block_device_operations xlscsi_block_fops = 
   21.67  {
   21.68 @@ -75,137 +37,121 @@ int xlscsi_hwsect(int minor)
   21.69  } 
   21.70  
   21.71  
   21.72 -void xlscsi_register_disk(int xidx, int idx)
   21.73 +int xlscsi_init(xen_disk_info_t *xdi) 
   21.74  {
   21.75 -    int minors;
   21.76 +    int i, result, units, minors, disk;
   21.77      struct gendisk *gd;
   21.78 -    unsigned long capacity; 
   21.79 -
   21.80 -    minors    = XLSCSI_MAX; 
   21.81 -    gd        = kmalloc (sizeof(struct gendisk), GFP_KERNEL);
   21.82 -    gd->sizes = kmalloc (minors * sizeof(int), GFP_KERNEL);
   21.83 -    gd->part  = kmalloc (minors * sizeof(struct hd_struct), GFP_KERNEL);
   21.84 -    memset(gd->part, 0, minors * sizeof(struct hd_struct));
   21.85 -    
   21.86 -    if(idx > 0) 
   21.87 -	printk("xlscsi_register_disk: need fix to handle "
   21.88 -	       "multiple SCSI majors!\n"); 
   21.89 -    
   21.90 -    gd->major        = xlscsi_major;       /* XXX should be idx-specific */
   21.91 -    gd->major_name   = XLSCSI_MAJOR_NAME;  /* XXX should be idx-specific */
   21.92 -    gd->minor_shift  = 4; 
   21.93 -    gd->max_p	     = 1<<4; 
   21.94 -    gd->nr_real	     = SCSI_DISKS_PER_MAJOR; 
   21.95 -    gd->real_devices = NULL;          
   21.96 -    gd->next	     = NULL;            
   21.97 -    gd->fops         = &xlscsi_block_fops;
   21.98 -    gd->de_arr       = kmalloc (sizeof *gd->de_arr * SCSI_DISKS_PER_MAJOR, 
   21.99 -				GFP_KERNEL);
  21.100 -    gd->flags	     = kmalloc (sizeof *gd->flags * SCSI_DISKS_PER_MAJOR, 
  21.101 -				GFP_KERNEL);
  21.102 -
  21.103 -    if (gd->de_arr)  
  21.104 -	memset (gd->de_arr, 0, sizeof *gd->de_arr * SCSI_DISKS_PER_MAJOR);
  21.105 -
  21.106 -    if (gd->flags) 
  21.107 -	memset (gd->flags, 0, sizeof *gd->flags * SCSI_DISKS_PER_MAJOR);
  21.108 -
  21.109 -    add_gendisk(gd);
  21.110 -
  21.111 -    xen_disk_info.disks[xidx].gendisk = gd;
  21.112 -
  21.113 -    /* XXX major below should be idx-specific */
  21.114 -    register_disk(gd, MKDEV(xlscsi_major, 0), 1<<4, &xlscsi_block_fops, 
  21.115 -		  xen_disk_info.disks[xidx].capacity);
  21.116 -
  21.117 -    return;
  21.118 -}
  21.119 -
  21.120 -
  21.121 -/*
  21.122 -** Initialize a XenoLinux SCSI disk; the 'xidx' is the index into the 
  21.123 -** xen_disk_info array so we can grab interesting values; the 'idx' is 
  21.124 -** a count of the number of XLSCSI disks we've seen so far, starting at 0
  21.125 -** XXX SMH: this is all so ugly because the xen_disk_info() structure and 
  21.126 -** array doesn't really give us what we want. Ho hum. To be tidied someday. 
  21.127 -*/
  21.128 -int xlscsi_init(int xidx, int idx)
  21.129 -{
  21.130 -    int i, major, result;
  21.131  
  21.132      SET_MODULE_OWNER(&xlscsi_block_fops);
  21.133  
  21.134 -    major  = xlscsi_major + idx;   /* XXX asume we have linear major space */
  21.135 -    
  21.136 -    /* XXX SMH: 'name' below should vary for different major values */
  21.137 -    result = register_blkdev(major, XLSCSI_MAJOR_NAME, &xlscsi_block_fops);
  21.138 -
  21.139 -    if (result < 0) {
  21.140 -	printk (KERN_ALERT "XL SCSI: can't get major %d\n", major);
  21.141 +    result = register_blkdev(XLSCSI_MAJOR, XLSCSI_MAJOR_NAME, 
  21.142 +                             &xlscsi_block_fops);
  21.143 +    if ( result < 0 )
  21.144 +    {
  21.145 +	printk (KERN_ALERT "XL SCSI: can't get major %d\n", XLSCSI_MAJOR);
  21.146  	return result;
  21.147      }
  21.148  
  21.149 -    /* initialize global arrays in drivers/block/ll_rw_block.c */
  21.150 -    for (i = 0; i < XLSCSI_MAX; i++) {
  21.151 -	xlscsi_blk_size[i]      = xen_disk_info.disks[xidx].capacity;
  21.152 +    /* Initialize global arrays. */
  21.153 +    for ( i = 0; i < XLSCSI_MAX; i++ )
  21.154 +    {
  21.155  	xlscsi_blksize_size[i]  = 512;
  21.156  	xlscsi_hardsect_size[i] = 512;
  21.157  	xlscsi_max_sectors[i]   = 128;
  21.158      }
  21.159 -    xlscsi_read_ahead  = 8; 
  21.160  
  21.161 -    blk_size[major]      = xlscsi_blk_size;
  21.162 -    blksize_size[major]  = xlscsi_blksize_size;
  21.163 -    hardsect_size[major] = xlscsi_hardsect_size;
  21.164 -    read_ahead[major]    = xlscsi_read_ahead; 
  21.165 -    max_sectors[major]   = xlscsi_max_sectors;
  21.166 +    blk_size[XLSCSI_MAJOR]      = NULL;
  21.167 +    blksize_size[XLSCSI_MAJOR]  = xlscsi_blksize_size;
  21.168 +    hardsect_size[XLSCSI_MAJOR] = xlscsi_hardsect_size;
  21.169 +    max_sectors[XLSCSI_MAJOR]   = xlscsi_max_sectors;
  21.170 +    read_ahead[XLSCSI_MAJOR]    = 8;
  21.171  
  21.172 -    blk_init_queue(BLK_DEFAULT_QUEUE(major), do_xlblk_request);
  21.173 +    blk_init_queue(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR), do_xlblk_request);
  21.174  
  21.175      /*
  21.176       * Turn off barking 'headactive' mode. We dequeue buffer heads as
  21.177       * soon as we pass them down to Xen.
  21.178       */
  21.179 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(major), 0);
  21.180 -    
  21.181 -    xlscsi_register_disk(xidx, idx);
  21.182 +    blk_queue_headactive(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR), 0);
  21.183 +
  21.184 +    /* Count number of SCSI devices installed in the system. */
  21.185 +    units = 0;
  21.186 +    for ( i = 0; i < xdi->count; i++ )
  21.187 +        if ( xdi->disks[i].type == XEN_DISK_SCSI ) units++;
  21.188  
  21.189 +    /* Construct an appropriate gendisk structure. */
  21.190 +    minors    = units * (1<<SCSI_PARTN_BITS);
  21.191 +    gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
  21.192 +    gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
  21.193 +    gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
  21.194 +    gd->major        = XLSCSI_MAJOR;
  21.195 +    gd->major_name   = XLSCSI_MAJOR_NAME;
  21.196 +    gd->minor_shift  = SCSI_PARTN_BITS; 
  21.197 +    gd->max_p	     = 1<<SCSI_PARTN_BITS;
  21.198 +    gd->nr_real	     = units;           
  21.199 +    gd->real_devices = NULL;          
  21.200 +    gd->next	     = NULL;            
  21.201 +    gd->fops         = &xlscsi_block_fops;
  21.202 +    gd->de_arr       = kmalloc(sizeof(*gd->de_arr) * units, GFP_KERNEL);
  21.203 +    gd->flags	     = kmalloc(sizeof(*gd->flags) * units, GFP_KERNEL);
  21.204 +    memset(gd->sizes, 0, minors * sizeof(int));
  21.205 +    memset(gd->part,  0, minors * sizeof(struct hd_struct));
  21.206 +    memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
  21.207 +    memset(gd->flags, 0, sizeof(*gd->flags) * units);
  21.208 +    xlscsi_gendisk = gd;
  21.209 +    add_gendisk(gd);
  21.210 +
  21.211 +    /* Now register each disk in turn. */
  21.212 +    disk = 0;
  21.213 +    for ( i = 0; i < xdi->count; i++ )
  21.214 +    {
  21.215 +        if ( xdi->disks[i].type != XEN_DISK_SCSI ) continue;
  21.216 +        register_disk(gd,
  21.217 +                      MKDEV(XLSCSI_MAJOR, disk<<SCSI_PARTN_BITS), 
  21.218 +                      1<<SCSI_PARTN_BITS, 
  21.219 +                      &xlscsi_block_fops, 
  21.220 +                      xdi->disks[i].capacity);
  21.221 +        disk++;
  21.222 +    }
  21.223 +   
  21.224      printk(KERN_ALERT 
  21.225  	   "XenoLinux Virtual SCSI Device Driver installed [device: %d]\n",
  21.226 -	   major);
  21.227 +	   XLSCSI_MAJOR);
  21.228 +
  21.229      return 0;
  21.230  }
  21.231  
  21.232  
  21.233 -
  21.234  void xlscsi_cleanup(void)
  21.235  {
  21.236 -    /* CHANGE FOR MULTIQUEUE */
  21.237 -    blk_cleanup_queue(BLK_DEFAULT_QUEUE(xlscsi_major));
  21.238 +    blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLSCSI_MAJOR));
  21.239 +
  21.240 +    xlscsi_gendisk = NULL;
  21.241 +
  21.242 +    read_ahead[XLSCSI_MAJOR] = 0;
  21.243  
  21.244 -    /* clean up global arrays */
  21.245 -    read_ahead[xlscsi_major] = 0;
  21.246 -
  21.247 -    if (blk_size[xlscsi_major]) 
  21.248 -	kfree(blk_size[xlscsi_major]);
  21.249 -    blk_size[xlscsi_major] = NULL;
  21.250 +    if ( blksize_size[XLSCSI_MAJOR] != NULL )
  21.251 +    { 
  21.252 +	kfree(blksize_size[XLSCSI_MAJOR]);
  21.253 +        blksize_size[XLSCSI_MAJOR] = NULL;
  21.254 +    }
  21.255  
  21.256 -    if (blksize_size[xlscsi_major]) 
  21.257 -	kfree(blksize_size[xlscsi_major]);
  21.258 -    blksize_size[xlscsi_major] = NULL;
  21.259 -
  21.260 -    if (hardsect_size[xlscsi_major]) 
  21.261 -	kfree(hardsect_size[xlscsi_major]);
  21.262 -    hardsect_size[xlscsi_major] = NULL;
  21.263 +    if ( hardsect_size[XLSCSI_MAJOR] != NULL )
  21.264 +    { 
  21.265 +	kfree(hardsect_size[XLSCSI_MAJOR]);
  21.266 +        hardsect_size[XLSCSI_MAJOR] = NULL;
  21.267 +    }
  21.268      
  21.269 -    /* XXX: free each gendisk */
  21.270 -    if (unregister_blkdev(xlscsi_major, XLSCSI_MAJOR_NAME))
  21.271 +    if ( max_sectors[XLSCSI_MAJOR] != NULL )
  21.272 +    { 
  21.273 +	kfree(max_sectors[XLSCSI_MAJOR]);
  21.274 +        max_sectors[XLSCSI_MAJOR] = NULL;
  21.275 +    }
  21.276 +    
  21.277 +    if ( unregister_blkdev(XLSCSI_MAJOR, XLSCSI_MAJOR_NAME) != 0 )
  21.278 +    {
  21.279  	printk(KERN_ALERT
  21.280  	       "XenoLinux Virtual SCSI Device Driver uninstalled w/ errs\n");
  21.281 -    else
  21.282 -	printk(KERN_ALERT 
  21.283 -	       "XenoLinux Virtual SCSI Device Driver uninstalled\n");
  21.284 -
  21.285 -    return;
  21.286 +    }
  21.287  }
  21.288  
    22.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c	Thu Mar 06 16:54:15 2003 +0000
    22.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment.c	Fri Mar 07 01:38:49 2003 +0000
    22.3 @@ -5,425 +5,172 @@
    22.4   * 
    22.5   */
    22.6  
    22.7 -#include <linux/config.h>
    22.8 -#include <linux/module.h>
    22.9 -
   22.10 -#include <linux/kernel.h>
   22.11 -#include <linux/sched.h>
   22.12 -#include <linux/slab.h>
   22.13 -#include <linux/string.h>
   22.14 -#include <linux/errno.h>
   22.15 +#include "xl_block.h"
   22.16  
   22.17 -#include <linux/fs.h>
   22.18 -#include <linux/hdreg.h>
   22.19 -#include <linux/blkdev.h>
   22.20 -#include <linux/major.h>
   22.21 -
   22.22 -#include <asm/hypervisor-ifs/block.h>
   22.23 -#include <asm/hypervisor-ifs/hypervisor-if.h>
   22.24 -#include <asm/io.h>
   22.25 -#include <asm/atomic.h>
   22.26 -#include <asm/uaccess.h>
   22.27 -
   22.28 -#define MAJOR_NR XLSEG_MAJOR   /* force defns in blk.h, must precede include */
   22.29 -static int xlseg_major = XLSEG_MAJOR;
   22.30 +#define MAJOR_NR XLVIRT_MAJOR
   22.31  #include <linux/blk.h>
   22.32  
   22.33  /* Copied from linux/ide.h */
   22.34 -typedef unsigned char	byte; 
   22.35 -
   22.36 -#define XLSEG_MAX 32 /* Maximum minor devices we support */
   22.37 -#define XLSEG_MAJOR_NAME "xhd"
   22.38 -
   22.39 -static int xlseg_blk_size[XLSEG_MAX];
   22.40 -static int xlseg_blksize_size[XLSEG_MAX];
   22.41 -static int xlseg_read_ahead; 
   22.42 -static int xlseg_hardsect_size[XLSEG_MAX];
   22.43 -static int xlseg_max_sectors[XLSEG_MAX];
   22.44 -
   22.45 -extern atomic_t xlblk_control_count;                           /* xl_block.c */
   22.46 +typedef unsigned char byte; 
   22.47  
   22.48 -int hypervisor_request(void *          id,
   22.49 -                       int             operation,
   22.50 -                       char *          buffer,
   22.51 -                       unsigned long   block_number,
   22.52 -                       unsigned short  block_size,
   22.53 -                       kdev_t          device,
   22.54 -		       struct gendisk *gd);
   22.55 -void xlseg_register_disk(int idx, unsigned long capacity);
   22.56 +/* We support up to 16 devices of up to 16 partitions each. */
   22.57 +#define XLVIRT_MAX        256
   22.58 +#define XLVIRT_MAJOR_NAME "xvd"
   22.59 +#define VIRT_PARTN_BITS   4
   22.60 +static int xlseg_blksize_size[XLVIRT_MAX];
   22.61 +static int xlseg_hardsect_size[XLVIRT_MAX];
   22.62 +static int xlseg_max_sectors[XLVIRT_MAX];
   22.63  
   22.64 -#if 0
   22.65 -#define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   22.66 -#define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
   22.67 -#else
   22.68 -#define DPRINTK(_f, _a...) ((void)0)
   22.69 -#define DPRINTK_IOCTL(_f, _a...) ((void)0)
   22.70 -#endif
   22.71 +struct gendisk *xlsegment_gendisk;
   22.72  
   22.73  static xen_disk_info_t xlseg_disk_info;
   22.74  
   22.75 -/* ------------------------------------------------------------------------
   22.76 - */
   22.77 -
   22.78 -static int xenolinux_segment_open(struct inode *inode, struct file *filep)
   22.79 -{
   22.80 -    DPRINTK("xenolinux_segment_release\n");
   22.81 -    return 0;
   22.82 -}
   22.83 -
   22.84 -static int xenolinux_segment_release(struct inode *inode, struct file *filep)
   22.85 -{
   22.86 -    DPRINTK("xenolinux_segment_release\n");
   22.87 -    return 0;
   22.88 -}
   22.89 -
   22.90 -static int xenolinux_segment_ioctl(struct inode *inode, struct file *filep,
   22.91 -				   unsigned command, unsigned long argument)
   22.92 +static struct block_device_operations xlsegment_block_fops = 
   22.93  {
   22.94 -    int minor_dev;
   22.95 -    struct hd_geometry *geo = (struct hd_geometry *)argument;
   22.96 -    struct gendisk *gd = (struct gendisk *)xlseg_disk_info.disks[0].gendisk;
   22.97 -
   22.98 -    DPRINTK("xenolinux_segment_ioctl\n"); 
   22.99 -
  22.100 -    /* check permissions */
  22.101 -    if (!capable(CAP_SYS_ADMIN)) return -EPERM;
  22.102 -    if (!inode)                  return -EINVAL;
  22.103 -    minor_dev = MINOR(inode->i_rdev);
  22.104 -    if (minor_dev >= XLSEG_MAX)  return -ENODEV;
  22.105 -    
  22.106 -    DPRINTK_IOCTL("command: 0x%x, argument: 0x%lx, minor: 0x%x\n",
  22.107 -                  command, (long) argument, minor_dev); 
  22.108 -  
  22.109 -    switch (command)
  22.110 -    {
  22.111 -      case BLKGETSIZE:
  22.112 -	if (gd != NULL)
  22.113 -	{
  22.114 -	  printk(KERN_ALERT "minordev: %d\n", minor_dev);
  22.115 -	  printk(KERN_ALERT "[0] start: %lx\n", gd->part[0].start_sect);
  22.116 -	  printk(KERN_ALERT "[0] count: %lx\n", gd->part[0].nr_sects);
  22.117 -	  printk(KERN_ALERT "[1] start: %lx\n", gd->part[1].start_sect);
  22.118 -	  printk(KERN_ALERT "[1] count: %lx\n", gd->part[1].nr_sects);
  22.119 -	  printk(KERN_ALERT "[2] start: %lx\n", gd->part[2].start_sect);
  22.120 -	  printk(KERN_ALERT "[2] count: %lx\n", gd->part[2].nr_sects);
  22.121 -	  
  22.122 -	  DPRINTK_IOCTL("   BLKGETSIZE gd: %x %lx\n", BLKGETSIZE, 
  22.123 -			gd->part[minor_dev].nr_sects);
  22.124 -	  return put_user(gd->part[minor_dev].nr_sects,
  22.125 -			  (unsigned long *)argument);
  22.126 -	}
  22.127 -	else
  22.128 -	{
  22.129 -	  DPRINTK_IOCTL("   BLKGETSIZE disk: %x %lx\n", BLKGETSIZE, 
  22.130 -			xlseg_disk_info.disks[0].capacity);
  22.131 -	  return put_user(xlseg_disk_info.disks[0].capacity,
  22.132 -			  (unsigned long *) argument);
  22.133 -	}
  22.134 -		      
  22.135 -      case BLKRRPART:
  22.136 -        DPRINTK_IOCTL("   BLKRRPART: \n"); 
  22.137 -	/* we don't have re-validate drive yet...  so you need to reboot! */
  22.138 -	break;
  22.139 -
  22.140 -      case BLKSSZGET:
  22.141 -        DPRINTK_IOCTL("   BLKSSZGET: %d\n",
  22.142 -		      xlseg_hardsect_size[minor_dev]);
  22.143 -	return xlseg_hardsect_size[minor_dev]; 
  22.144 -
  22.145 -      case HDIO_GETGEO:
  22.146 -        /* note: these values are complete garbage */
  22.147 -        DPRINTK_IOCTL("   HDIO_GETGEO: \n");
  22.148 -	if (!argument) return -EINVAL;
  22.149 -	if (put_user(0x00,  (unsigned long *) &geo->start)) return -EFAULT;
  22.150 -	if (put_user(0xff,  (byte *)&geo->heads)) return -EFAULT;
  22.151 -	if (put_user(0x3f,  (byte *)&geo->sectors)) return -EFAULT;
  22.152 -	if (put_user(0x106, (unsigned short *)&geo->cylinders)) return -EFAULT;
  22.153 -	return 0;
  22.154 -
  22.155 -      case HDIO_GETGEO_BIG: 
  22.156 -        /* note: these values are complete garbage */
  22.157 -        DPRINTK_IOCTL("   HDIO_GETGEO_BIG\n");
  22.158 -	if (!argument) return -EINVAL;
  22.159 -	if (put_user(0x00,  (unsigned long *) &geo->start))  return -EFAULT;
  22.160 -	if (put_user(0xff,  (byte *)&geo->heads))   return -EFAULT;
  22.161 -	if (put_user(0x3f,  (byte *)&geo->sectors)) return -EFAULT;
  22.162 -	if (put_user(0x106, (unsigned int *) &geo->cylinders)) return -EFAULT;
  22.163 -	return 0;
  22.164 -
  22.165 -      default:
  22.166 -        DPRINTK_IOCTL("   eh? unknown ioctl\n");
  22.167 -	break;
  22.168 -    }
  22.169 -    
  22.170 -    return 0;
  22.171 -}
  22.172 -
  22.173 -static int xenolinux_segment_check(kdev_t dev)
  22.174 -{
  22.175 -    DPRINTK("xenolinux_segment_check\n");
  22.176 -    return 0;
  22.177 -}
  22.178 -
  22.179 -static int xenolinux_segment_revalidate(kdev_t dev)
  22.180 -{
  22.181 -    DPRINTK("xenolinux_segment_revalidate\n"); 
  22.182 -    return 0;
  22.183 -}
  22.184 -
  22.185 -void do_xlseg_requestX (request_queue_t *rq)
  22.186 -{
  22.187 -  /* this is a bit dumb.  do_xlseg_request is defined in blk.h
  22.188 -     and this is thus static. but we have cooperative
  22.189 -     device drivers... */
  22.190 -  do_xlseg_request(rq);
  22.191 -}
  22.192 -
  22.193 -/*
  22.194 - * do_xlseg_request
  22.195 - * read a block; request is in a request queue
  22.196 - */
  22.197 -static void do_xlseg_request (request_queue_t *rq)
  22.198 -{
  22.199 -    struct request *req;
  22.200 -    struct buffer_head *bh;
  22.201 -    int rw, nsect, full, queued = 0;
  22.202 -    
  22.203 -    /*     DPRINTK("do_xlseg_request for '%s'\n", DEVICE_NAME); */
  22.204 -
  22.205 -    while ( !rq->plugged && !QUEUE_EMPTY )
  22.206 -    {
  22.207 -	if ( (req = CURRENT) == NULL ) goto out;
  22.208 -		
  22.209 -        DPRINTK("do_xlseg_request %p: cmd %i, sec %lx, (%li/%li) bh:%p\n",
  22.210 -                req, req->cmd, req->sector,
  22.211 -                req->current_nr_sectors, req->nr_sectors, req->bh);
  22.212 -
  22.213 -        rw = req->cmd;
  22.214 -        if ( rw == READA ) rw = READ;
  22.215 -        if ((rw != READ) && (rw != WRITE))
  22.216 -            panic("XenoLinux Virtual Segment Device: bad cmd: %d\n", rw);
  22.217 -
  22.218 -	req->errors = 0;
  22.219 -
  22.220 -        bh = req->bh;
  22.221 -        while ( bh != NULL )
  22.222 -	{
  22.223 -            full = hypervisor_request(
  22.224 -                bh, (rw == READ) ? XEN_BLOCK_READ : XEN_BLOCK_WRITE, 
  22.225 -                bh->b_data, bh->b_rsector, bh->b_size, bh->b_dev,
  22.226 -		(struct gendisk *)xlseg_disk_info.disks[0].gendisk);
  22.227 -            
  22.228 -            if ( full ) 
  22.229 -	    {
  22.230 -	      goto out;
  22.231 -	    }
  22.232 -
  22.233 -            queued++;
  22.234 -
  22.235 -            /* Dequeue the buffer head from the request. */
  22.236 -            nsect = bh->b_size >> 9;
  22.237 -            req->bh = bh->b_reqnext;
  22.238 -            bh->b_reqnext = NULL;
  22.239 -            bh = req->bh;
  22.240 -            
  22.241 -            if ( bh != NULL )
  22.242 -            {
  22.243 -                /* There's another buffer head to do. Update the request. */
  22.244 -                req->hard_sector += nsect;
  22.245 -                req->hard_nr_sectors -= nsect;
  22.246 -                req->sector = req->hard_sector;
  22.247 -                req->nr_sectors = req->hard_nr_sectors;
  22.248 -                req->current_nr_sectors = bh->b_size >> 9;
  22.249 -                req->buffer = bh->b_data;
  22.250 -            }
  22.251 -            else
  22.252 -            {
  22.253 -                /* That was the last buffer head. Finalise the request. */
  22.254 -                if ( end_that_request_first(req, 1, "XenSeg") ) BUG();
  22.255 -                blkdev_dequeue_request(req);
  22.256 -                end_that_request_last(req);
  22.257 -            }
  22.258 -        }
  22.259 -    }
  22.260 -
  22.261 - out:
  22.262 -    if ( queued != 0 ) HYPERVISOR_block_io_op();
  22.263 -}
  22.264 +    open:               xenolinux_block_open,
  22.265 +    release:            xenolinux_block_release,
  22.266 +    ioctl:              xenolinux_block_ioctl,
  22.267 +    check_media_change: xenolinux_block_check,
  22.268 +    revalidate:         xenolinux_block_revalidate,
  22.269 +};
  22.270  
  22.271  
  22.272 -static struct block_device_operations xenolinux_segment_fops = 
  22.273 +int xlsegment_hwsect(int minor) 
  22.274  {
  22.275 -    open:               xenolinux_segment_open,
  22.276 -    release:            xenolinux_segment_release,
  22.277 -    ioctl:              xenolinux_segment_ioctl,
  22.278 -    check_media_change: xenolinux_segment_check,
  22.279 -    revalidate:         xenolinux_segment_revalidate,
  22.280 -};
  22.281 +    return xlseg_hardsect_size[minor]; 
  22.282 +} 
  22.283  
  22.284  
  22.285  int __init xlseg_init(void)
  22.286  {
  22.287 -    int i, result;
  22.288 -    int counter;
  22.289 +    int i, result, units, minors, disk;
  22.290 +    xen_disk_info_t *xdi = &xlseg_disk_info;
  22.291 +    struct gendisk *gd;
  22.292  
  22.293 -    /* probe for disk information */
  22.294 -    memset (&xlseg_disk_info, 0, sizeof(xlseg_disk_info));
  22.295 -    xlseg_disk_info.count = 0;
  22.296 -
  22.297 +    SET_MODULE_OWNER(&xlsegment_block_fops);
  22.298  
  22.299 -    {
  22.300 -      /* get lock xlblk_control_lock     */
  22.301 -      counter = atomic_read(&xlblk_control_count);
  22.302 -      atomic_inc(&xlblk_control_count);
  22.303 -      /* release lock xlblk_control_lock */
  22.304 -    }
  22.305 -    if ( hypervisor_request(NULL, XEN_BLOCK_PROBE_SEG, 
  22.306 -			    (char *) &xlseg_disk_info,
  22.307 -                            0, 0, (kdev_t) 0,
  22.308 -			    (struct gendisk *)NULL) )
  22.309 -        BUG();
  22.310 -    HYPERVISOR_block_io_op();
  22.311 -    while (atomic_read(&xlblk_control_count) != counter) barrier();
  22.312 +    /* Probe for disk information. */
  22.313 +    memset(xdi, 0, sizeof(*xdi));
  22.314 +    xenolinux_control_msg(XEN_BLOCK_PROBE_SEG, (char *)xdi);
  22.315  
  22.316 -    printk (KERN_ALERT "vhd block device probe:\n");
  22.317 -    for ( i = 0; i < xlseg_disk_info.count; i++ )
  22.318 +    DPRINTK("vhd block device probe:\n");
  22.319 +    for ( i = 0; i < xdi->count; i++ )
  22.320      { 
  22.321 -	printk (KERN_ALERT "  %2d: type: %d, capacity: %ld\n",
  22.322 -		i, xlseg_disk_info.disks[i].type, 
  22.323 -		xlseg_disk_info.disks[i].capacity);
  22.324 +	DPRINTK("  %2d: type: %d, capacity: %ld\n",
  22.325 +		i, xdi->disks[i].type, xdi->disks[i].capacity);
  22.326      }
  22.327  
  22.328 -    SET_MODULE_OWNER(&xenolinux_segment_fops);
  22.329 -    result = register_blkdev(xlseg_major, "segment", &xenolinux_segment_fops);
  22.330 -    if (result < 0) {
  22.331 -	printk (KERN_ALERT "xenolinux segment: can't get major %d\n",
  22.332 -		xlseg_major);
  22.333 +    result = register_blkdev(XLVIRT_MAJOR, XLVIRT_MAJOR_NAME,
  22.334 +                             &xlsegment_block_fops);
  22.335 +    if ( result < 0 )
  22.336 +    {
  22.337 +	printk(KERN_ALERT "XL Segment: can't get major %d\n", XLVIRT_MAJOR);
  22.338  	return result;
  22.339      }
  22.340  
  22.341 -    /* initialize global arrays in drivers/block/ll_rw_block.c */
  22.342 -    for (i = 0; i < XLSEG_MAX; i++) 
  22.343 +    /* Initialize global arrays. */
  22.344 +    for (i = 0; i < XLVIRT_MAX; i++) 
  22.345      {
  22.346 -      xlseg_blk_size[i]      = xlseg_disk_info.disks[0].capacity ;
  22.347 -      xlseg_blksize_size[i]  = 512;
  22.348 -      xlseg_hardsect_size[i] = 512;
  22.349 -      xlseg_max_sectors[i]   = 128;
  22.350 +        xlseg_blksize_size[i]  = 512;
  22.351 +        xlseg_hardsect_size[i] = 512;
  22.352 +        xlseg_max_sectors[i]   = 128;
  22.353      }
  22.354 -    xlseg_read_ahead  = 8; 
  22.355  
  22.356 -    blk_size[xlseg_major]      = xlseg_blk_size;
  22.357 -    blksize_size[xlseg_major]  = xlseg_blksize_size;
  22.358 -    hardsect_size[xlseg_major] = xlseg_hardsect_size;
  22.359 -    read_ahead[xlseg_major]    = xlseg_read_ahead; 
  22.360 -    max_sectors[xlseg_major]   = xlseg_max_sectors;
  22.361 +    blk_size[XLVIRT_MAJOR]      = NULL;
  22.362 +    blksize_size[XLVIRT_MAJOR]  = xlseg_blksize_size;
  22.363 +    hardsect_size[XLVIRT_MAJOR] = xlseg_hardsect_size;
  22.364 +    max_sectors[XLVIRT_MAJOR]   = xlseg_max_sectors;
  22.365 +    read_ahead[XLVIRT_MAJOR]    = 8;
  22.366  
  22.367 -    blk_init_queue(BLK_DEFAULT_QUEUE(xlseg_major), do_xlseg_request);
  22.368 +    blk_init_queue(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR), do_xlblk_request);
  22.369  
  22.370      /*
  22.371       * Turn off barking 'headactive' mode. We dequeue buffer heads as
  22.372       * soon as we pass them down to Xen.
  22.373       */
  22.374 -    blk_queue_headactive(BLK_DEFAULT_QUEUE(xlseg_major), 0);
  22.375 +    blk_queue_headactive(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR), 0);
  22.376 +
  22.377 +
  22.378 +    /* Count number of virtual devices installed in the system. */
  22.379 +    units = 0;
  22.380 +    for ( i = 0; i < xdi->count; i++ )
  22.381 +        if ( xdi->disks[i].type == XEN_DISK_VIRTUAL ) units++;
  22.382  
  22.383 -    xlseg_register_disk(0, xlseg_disk_info.disks[0].capacity);
  22.384 +    /* Construct an appropriate gendisk structure. */
  22.385 +    minors    = units * (1<<VIRT_PARTN_BITS);
  22.386 +    gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
  22.387 +    gd->sizes = kmalloc(minors * sizeof(int), GFP_KERNEL);
  22.388 +    gd->part  = kmalloc(minors * sizeof(struct hd_struct), GFP_KERNEL);
  22.389 +    gd->major        = XLVIRT_MAJOR;
  22.390 +    gd->major_name   = XLVIRT_MAJOR_NAME;
  22.391 +    gd->minor_shift  = VIRT_PARTN_BITS; 
  22.392 +    gd->max_p	     = 1<<VIRT_PARTN_BITS;
  22.393 +    gd->nr_real	     = units;           
  22.394 +    gd->real_devices = NULL;          
  22.395 +    gd->next	     = NULL;            
  22.396 +    gd->fops         = &xlsegment_block_fops;
  22.397 +    gd->de_arr       = kmalloc(sizeof(*gd->de_arr) * units, GFP_KERNEL);
  22.398 +    gd->flags	     = kmalloc(sizeof(*gd->flags) * units, GFP_KERNEL);
  22.399 +    memset(gd->sizes, 0, minors * sizeof(int));
  22.400 +    memset(gd->part,  0, minors * sizeof(struct hd_struct));
  22.401 +    memset(gd->de_arr, 0, sizeof(*gd->de_arr) * units);
  22.402 +    memset(gd->flags, 0, sizeof(*gd->flags) * units);
  22.403 +    xlsegment_gendisk = gd;
  22.404 +    add_gendisk(gd);
  22.405 +
  22.406 +    /* Now register each disk in turn. */
  22.407 +    disk = 0;
  22.408 +    for ( i = 0; i < xdi->count; i++ )
  22.409 +    {
  22.410 +        if ( xdi->disks[i].type != XEN_DISK_VIRTUAL ) continue;
  22.411 +        register_disk(gd, 
  22.412 +                      MKDEV(XLVIRT_MAJOR, disk<<VIRT_PARTN_BITS), 
  22.413 +                      1<<VIRT_PARTN_BITS, 
  22.414 +                      &xlsegment_block_fops, 
  22.415 +                      xdi->disks[i].capacity);
  22.416 +        disk++;
  22.417 +    }
  22.418  
  22.419      printk(KERN_ALERT 
  22.420  	   "XenoLinux Virtual Segment Device Driver installed [device: %d]\n",
  22.421 -	   xlseg_major);
  22.422 -    return 0;
  22.423 -}
  22.424 -
  22.425 -void xlseg_register_disk(int idx, unsigned long capacity)
  22.426 -{
  22.427 -    int units;
  22.428 -    int minors;
  22.429 -    struct gendisk *gd;
  22.430 -
  22.431 -    /* plagarized from ide-probe.c::init_gendisk */
  22.432 -    
  22.433 -    units = 2; /* from ide.h::MAX_DRIVES */
  22.434 -
  22.435 -#define IDE_PARTN_BITS 6                           /* from ide.h::PARTN_BITS */
  22.436 +	   XLVIRT_MAJOR);
  22.437  
  22.438 -    minors    = units * (1<<IDE_PARTN_BITS);
  22.439 -    gd        = kmalloc (sizeof(struct gendisk), GFP_KERNEL);
  22.440 -    gd->sizes = kmalloc (minors * sizeof(int), GFP_KERNEL);
  22.441 -    gd->part  = kmalloc (minors * sizeof(struct hd_struct), GFP_KERNEL);
  22.442 -    memset(gd->part, 0, minors * sizeof(struct hd_struct));
  22.443 -    
  22.444 -    gd->major        = xlseg_major;  
  22.445 -    gd->major_name   = XLSEG_MAJOR_NAME;
  22.446 -    gd->minor_shift  = IDE_PARTN_BITS; 
  22.447 -    gd->max_p	     = 1<<IDE_PARTN_BITS;
  22.448 -    gd->nr_real	     = units;           
  22.449 -    gd->real_devices = NULL;          
  22.450 -    gd->next	     = NULL;            
  22.451 -    gd->fops         = &xenolinux_segment_fops;
  22.452 -    gd->de_arr       = kmalloc (sizeof *gd->de_arr * units, GFP_KERNEL);
  22.453 -    gd->flags	     = kmalloc (sizeof *gd->flags * units, GFP_KERNEL);
  22.454 -
  22.455 -    if (gd->de_arr)  
  22.456 -	memset (gd->de_arr, 0, sizeof *gd->de_arr * units);
  22.457 -
  22.458 -    if (gd->flags) 
  22.459 -	memset (gd->flags, 0, sizeof *gd->flags * units);
  22.460 -
  22.461 -    add_gendisk(gd);
  22.462 -
  22.463 -    xlseg_disk_info.disks[idx].gendisk = gd;
  22.464 -
  22.465 -    register_disk(gd, MKDEV(xlseg_major, 0), 1<<IDE_PARTN_BITS,
  22.466 -		  &xenolinux_segment_fops, capacity);
  22.467 -
  22.468 -    {
  22.469 -      int loop = 0;
  22.470 -      printk (KERN_ALERT "Partition Table: (capacity: %lx)\n", capacity);
  22.471 -      for (loop = 0; loop < minors; loop++)
  22.472 -      {
  22.473 -	if (gd->part[loop].start_sect && gd->part[loop].nr_sects)
  22.474 -	{
  22.475 -	  printk (KERN_ALERT 
  22.476 -		  "  %2d: 0x%6lx %8ld    0x%6lx %7ld\n", loop,
  22.477 -		  gd->part[loop].start_sect, gd->part[loop].start_sect,
  22.478 -		  gd->part[loop].nr_sects, gd->part[loop].nr_sects);
  22.479 -	}
  22.480 -      }
  22.481 -    }
  22.482 -
  22.483 -    return;
  22.484 +    return 0;
  22.485  }
  22.486  
  22.487  
  22.488  static void __exit xlseg_cleanup(void)
  22.489  {
  22.490 -    /* CHANGE FOR MULTIQUEUE */
  22.491 -    blk_cleanup_queue(BLK_DEFAULT_QUEUE(xlseg_major));
  22.492 +    blk_cleanup_queue(BLK_DEFAULT_QUEUE(XLVIRT_MAJOR));
  22.493  
  22.494 -    /* clean up global arrays */
  22.495 -    read_ahead[xlseg_major] = 0;
  22.496 +    xlsegment_gendisk = NULL;
  22.497 +
  22.498 +    read_ahead[XLVIRT_MAJOR] = 0;
  22.499  
  22.500 -    if (blk_size[xlseg_major]) 
  22.501 -	kfree(blk_size[xlseg_major]);
  22.502 -    blk_size[xlseg_major] = NULL;
  22.503 -
  22.504 -    if (blksize_size[xlseg_major]) 
  22.505 -	kfree(blksize_size[xlseg_major]);
  22.506 -    blksize_size[xlseg_major] = NULL;
  22.507 +    if ( blksize_size[XLVIRT_MAJOR] != NULL )
  22.508 +    { 
  22.509 +	kfree(blksize_size[XLVIRT_MAJOR]);
  22.510 +        blksize_size[XLVIRT_MAJOR] = NULL;
  22.511 +    }
  22.512  
  22.513 -    if (hardsect_size[xlseg_major]) 
  22.514 -	kfree(hardsect_size[xlseg_major]);
  22.515 -    hardsect_size[xlseg_major] = NULL;
  22.516 +    if ( hardsect_size[XLVIRT_MAJOR] != NULL )
  22.517 +    { 
  22.518 +	kfree(hardsect_size[XLVIRT_MAJOR]);
  22.519 +        hardsect_size[XLVIRT_MAJOR] = NULL;
  22.520 +    }
  22.521      
  22.522 -    /* XXX: free each gendisk */
  22.523 -    if (unregister_blkdev(xlseg_major, "block"))
  22.524 +    if ( max_sectors[XLVIRT_MAJOR] != NULL )
  22.525 +    { 
  22.526 +	kfree(max_sectors[XLVIRT_MAJOR]);
  22.527 +        max_sectors[XLVIRT_MAJOR] = NULL;
  22.528 +    }
  22.529 +    
  22.530 +    if ( unregister_blkdev(XLVIRT_MAJOR, XLVIRT_MAJOR_NAME) != 0 )
  22.531 +    {
  22.532  	printk(KERN_ALERT
  22.533 -	       "XenoLinux Virtual Segment Device Driver uninstalled w/ errs\n");
  22.534 -    else
  22.535 -	printk(KERN_ALERT 
  22.536 -	       "XenoLinux Virtual Segment Device Driver uninstalled\n");
  22.537 -
  22.538 -    return;
  22.539 +	       "XenoLinux Virtual Segment Device Driver"
  22.540 +               " uninstalled w/ errs\n");
  22.541 +    }
  22.542  }
  22.543  
  22.544  
    23.1 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment_proc.c	Thu Mar 06 16:54:15 2003 +0000
    23.2 +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/block/xl_segment_proc.c	Fri Mar 07 01:38:49 2003 +0000
    23.3 @@ -4,37 +4,16 @@
    23.4   * XenoLinux virtual disk proc interface .
    23.5   */
    23.6  
    23.7 -
    23.8 -#include <linux/config.h>
    23.9 -#include <linux/module.h>
   23.10 -
   23.11 +#include "xl_block.h"
   23.12  #include <linux/proc_fs.h>
   23.13  #include <linux/delay.h>
   23.14 -#include <asm/uaccess.h>
   23.15 -#include <asm/atomic.h>
   23.16 -
   23.17 -#include <asm/hypervisor-ifs/block.h>
   23.18 -#include <asm/hypervisor-ifs/hypervisor-if.h>
   23.19  
   23.20  static struct proc_dir_entry *vhd;
   23.21 -xv_disk_t xvd;
   23.22 -
   23.23 -extern atomic_t xlblk_control_count;                           /* xl_block.c */
   23.24 -
   23.25 -int hypervisor_request(void *          id,
   23.26 -                       int             operation,
   23.27 -                       char *          buffer,
   23.28 -                       unsigned long   block_number,
   23.29 -                       unsigned short  block_size,
   23.30 -                       kdev_t          device,
   23.31 -		       struct gendisk *gd);
   23.32 -
   23.33 -/******************************************************************/
   23.34  
   23.35  static int proc_read_vhd(char *page, char **start, off_t off,
   23.36  			 int count, int *eof, void *data)
   23.37  {
   23.38 -  return 0;
   23.39 +    return 0;
   23.40  }
   23.41  
   23.42  #define isdelim(c) \
   23.43 @@ -42,236 +21,221 @@ static int proc_read_vhd(char *page, cha
   23.44  
   23.45  char *get_string(char *string)                          /* a bit like strtok */
   23.46  {
   23.47 -  static char *temp;
   23.48 -  int loop = 0;
   23.49 +    static char *temp;
   23.50 +    int loop = 0;
   23.51  
   23.52 -  if (string != NULL)	
   23.53 -    temp = string;
   23.54 -  else
   23.55 -    string = temp;
   23.56 +    if (string != NULL)	
   23.57 +        temp = string;
   23.58 +    else
   23.59 +        string = temp;
   23.60  
   23.61   try_again:
   23.62  
   23.63 -  while (!isdelim(string[loop]))
   23.64 -  {
   23.65 -    if (string[loop] == '\0')
   23.66 -      return NULL;
   23.67 -    loop++;
   23.68 -  }
   23.69 +    while (!isdelim(string[loop]))
   23.70 +    {
   23.71 +        if (string[loop] == '\0')
   23.72 +            return NULL;
   23.73 +        loop++;
   23.74 +    }
   23.75  
   23.76 -  string[loop] = '\0';	
   23.77 -  temp = (string + loop + 1);
   23.78 +    string[loop] = '\0';	
   23.79 +    temp = (string + loop + 1);
   23.80  
   23.81 -  if (loop == 0)
   23.82 -  {
   23.83 -    string = temp;
   23.84 -    goto try_again;
   23.85 -  }
   23.86 +    if (loop == 0)
   23.87 +    {
   23.88 +        string = temp;
   23.89 +        goto try_again;
   23.90 +    }
   23.91  
   23.92 -  return string;
   23.93 +    return string;
   23.94  }
   23.95  
   23.96  
   23.97  #define isdigit(c) (c >= '0' && c <= '9' ? 1 : 0)
   23.98  unsigned long to_number(char *string)                                /* atoi */
   23.99  {
  23.100 -  unsigned long value = 0;
  23.101 +    unsigned long value = 0;
  23.102  
  23.103 -  if (string == NULL) return 0;
  23.104 +    if (string == NULL) return 0;
  23.105  
  23.106 -  while (!isdigit(*string) && *string != '\0') string++;
  23.107 +    while (!isdigit(*string) && *string != '\0') string++;
  23.108  
  23.109 -  while (isdigit(*string))
  23.110 -  {
  23.111 -    value = value * 10 + (*string - '0');
  23.112 -    string++;
  23.113 -  }
  23.114 +    while (isdigit(*string))
  23.115 +    {
  23.116 +        value = value * 10 + (*string - '0');
  23.117 +        string++;
  23.118 +    }
  23.119  
  23.120 -  return value;
  23.121 +    return value;
  23.122  }
  23.123  
  23.124  static int proc_write_vhd(struct file *file, const char *buffer,
  23.125  			  unsigned long count, void *data)
  23.126  {
  23.127 -  char *local = kmalloc((count + 1) * sizeof(char), GFP_KERNEL);
  23.128 -  char *string;
  23.129 -  int loop;
  23.130 -  int counter;
  23.131 -  xv_disk_t xvd;
  23.132 +    char *local = kmalloc((count + 1) * sizeof(char), GFP_KERNEL);
  23.133 +    char *string;
  23.134 +    int loop;
  23.135 +    xv_disk_t xvd;
  23.136  
  23.137 -  memset (&xvd, 0, sizeof(xvd));
  23.138 +    memset (&xvd, 0, sizeof(xvd));
  23.139  
  23.140 -  if (copy_from_user(local, buffer, count))
  23.141 -  {
  23.142 -    return -EFAULT;
  23.143 -  }
  23.144 -  local[count] = '\0';
  23.145 +    if (copy_from_user(local, buffer, count))
  23.146 +    {
  23.147 +        return -EFAULT;
  23.148 +    }
  23.149 +    local[count] = '\0';
  23.150  
  23.151 -  string = get_string(local);                             /* look for Domain */
  23.152 -  if (string == NULL)                                        /* empty string */
  23.153 -  {
  23.154 -    return count;
  23.155 -  }
  23.156 -  if (*string != 'd' && *string != 'D')
  23.157 -  {
  23.158 -    printk (KERN_ALERT 
  23.159 -	    "error: domain specifier missing [%s]. should be \"domain\".\n",
  23.160 -	    string);
  23.161 -    return count;
  23.162 -  }
  23.163 -
  23.164 -  string = get_string(NULL);                                /* domain number */
  23.165 -  if (string == NULL)
  23.166 -  {
  23.167 -    printk (KERN_ALERT "error: domain number missing\n");
  23.168 -    return count;
  23.169 -  }
  23.170 -  xvd.domain = (int) to_number(string);
  23.171 +    string = get_string(local); /* domain specifier */
  23.172 +    if (string == NULL)
  23.173 +    {
  23.174 +        return count;
  23.175 +    }
  23.176 +    if (*string != 'd' && *string != 'D')
  23.177 +    {
  23.178 +        printk (KERN_ALERT 
  23.179 +                "error: domain specifier missing [%s]. should be \"domain\".\n",
  23.180 +                string);
  23.181 +        return count;
  23.182 +    }
  23.183  
  23.184 -  string = get_string(NULL);
  23.185 -  if (string && (strcmp(string, "RO") == 0 || strcmp(string, "ro") == 0))
  23.186 -  {
  23.187 -    xvd.mode = XEN_DISK_READ_ONLY;
  23.188 -  }
  23.189 -  else if (string && (strcmp(string, "RW") == 0 || strcmp(string, "rw") == 0))
  23.190 -  {
  23.191 -    xvd.mode = XEN_DISK_READ_WRITE;
  23.192 -  }
  23.193 -  else
  23.194 -  {
  23.195 -    printk (KERN_ALERT 
  23.196 -	    "error: bad mode [%s]. should be \"rw\" or \"ro\".\n",
  23.197 -	    string);
  23.198 -    return count;
  23.199 -  }
  23.200 -
  23.201 -  string = get_string(NULL);                             /* look for Segment */
  23.202 -  if (string == NULL || (*string != 's' && *string != 'S'))
  23.203 -  {
  23.204 -    printk (KERN_ALERT 
  23.205 -	    "error: segment specifier missing [%s]. should be \"segment\".\n",
  23.206 -	    string);
  23.207 -    return count;
  23.208 -  }
  23.209 +    string = get_string(NULL); /* domain number */
  23.210 +    if (string == NULL)
  23.211 +    {
  23.212 +        printk (KERN_ALERT "error: domain number missing\n");
  23.213 +        return count;
  23.214 +    }
  23.215 +    xvd.domain = (int) to_number(string);
  23.216  
  23.217 -  string = get_string(NULL);                               /* segment number */
  23.218 -  if (string == NULL)
  23.219 -  {
  23.220 -    printk (KERN_ALERT "error: segment number missing\n");
  23.221 -    return count;
  23.222 -  }
  23.223 -  xvd.segment = (int) to_number(string);
  23.224 -
  23.225 -  string = get_string(NULL);                             /* look for Extents */
  23.226 -  if (string == NULL || (*string != 'e' && *string != 'E'))
  23.227 -  {
  23.228 -    printk (KERN_ALERT 
  23.229 -	    "error: extents specifier missing [%s]. should be \"extents\".\n",
  23.230 -	    string);
  23.231 -    return count;
  23.232 -  }
  23.233 +    string = get_string(NULL);
  23.234 +    if (string && (strcmp(string, "RO") == 0 || strcmp(string, "ro") == 0))
  23.235 +    {
  23.236 +        xvd.mode = XEN_DISK_READ_ONLY;
  23.237 +    }
  23.238 +    else if (string && (strcmp(string, "RW") == 0 || strcmp(string, "rw") == 0))
  23.239 +    {
  23.240 +        xvd.mode = XEN_DISK_READ_WRITE;
  23.241 +    }
  23.242 +    else
  23.243 +    {
  23.244 +        printk (KERN_ALERT 
  23.245 +                "error: bad mode [%s]. should be \"rw\" or \"ro\".\n",
  23.246 +                string);
  23.247 +        return count;
  23.248 +    }
  23.249  
  23.250 -  string = get_string(NULL);                            /* number of extents */
  23.251 -  if (string == NULL)
  23.252 -  {
  23.253 -    printk (KERN_ALERT "error: number of extents missing\n");
  23.254 -    return count;
  23.255 -  }
  23.256 -  xvd.ext_count = (int) to_number(string);
  23.257 -
  23.258 -  /* ignore parenthesis */
  23.259 +    string = get_string(NULL);                             /* look for Segment */
  23.260 +    if (string == NULL || (*string != 's' && *string != 'S'))
  23.261 +    {
  23.262 +        printk (KERN_ALERT 
  23.263 +                "error: segment specifier missing [%s]. should be \"segment\".\n",
  23.264 +                string);
  23.265 +        return count;
  23.266 +    }
  23.267  
  23.268 -  for (loop = 0; loop < xvd.ext_count; loop++)
  23.269 -  {
  23.270 -    string = get_string(NULL);                              /* look for Disk */
  23.271 -    if (string == NULL || (*string != 'd' && *string != 'D'))
  23.272 -    {
  23.273 -      printk (KERN_ALERT 
  23.274 -	      "hmm, extent disk specifier missing [%s]. should be \"disk\".\n",
  23.275 -	      string);
  23.276 -      return count;
  23.277 -    }
  23.278 -    string = get_string(NULL);                                /* disk number */
  23.279 +    string = get_string(NULL);                               /* segment number */
  23.280      if (string == NULL)
  23.281      {
  23.282 -      printk (KERN_ALERT "error: disk number missing\n");
  23.283 -      return count;
  23.284 +        printk (KERN_ALERT "error: segment number missing\n");
  23.285 +        return count;
  23.286      }
  23.287 -    xvd.extents[loop].disk = (int) to_number(string);
  23.288 +    xvd.segment = (int) to_number(string);
  23.289  
  23.290 -    string = get_string(NULL);                            /* look for Offset */
  23.291 -    if (string == NULL || (*string != 'o' && *string != 'O'))
  23.292 +    string = get_string(NULL);                             /* look for Extents */
  23.293 +    if (string == NULL || (*string != 'e' && *string != 'E'))
  23.294      {
  23.295 -      printk (KERN_ALERT 
  23.296 -	      "error: disk offset missing [%s]. should be \"offset\".\n",
  23.297 -	    string);
  23.298 -      return count;
  23.299 +        printk (KERN_ALERT 
  23.300 +                "error: extents specifier missing [%s]. should be \"extents\".\n",
  23.301 +                string);
  23.302 +        return count;
  23.303      }
  23.304 -    string = get_string(NULL);                                     /* offset */
  23.305 +
  23.306 +    string = get_string(NULL);                            /* number of extents */
  23.307      if (string == NULL)
  23.308      {
  23.309 -      printk (KERN_ALERT "error: offset missing\n");
  23.310 -      return count;
  23.311 -    }
  23.312 -    xvd.extents[loop].offset =  to_number(string);
  23.313 -
  23.314 -    string = get_string(NULL);                              /* look for Size */
  23.315 -    if (string == NULL || (*string != 's' && *string != 'S'))
  23.316 -    {
  23.317 -      printk (KERN_ALERT 
  23.318 -	      "error: extent size missing [%s]. should be \"size\".\n",
  23.319 -	    string);
  23.320 -      return count;
  23.321 -    }
  23.322 -    string = get_string(NULL);                                       /* size */
  23.323 -    if (string == NULL)
  23.324 -    {
  23.325 -      printk (KERN_ALERT "error: extent size missing\n");
  23.326 -      return count;
  23.327 +        printk (KERN_ALERT "error: number of extents missing\n");
  23.328 +        return count;
  23.329      }
  23.330 -    xvd.extents[loop].size =  to_number(string);
  23.331 -  }
  23.332 +    xvd.ext_count = (int) to_number(string);
  23.333 +
  23.334 +    /* ignore parenthesis */
  23.335 +
  23.336 +    for (loop = 0; loop < xvd.ext_count; loop++)
  23.337 +    {
  23.338 +        string = get_string(NULL);                              /* look for Disk */
  23.339 +        if (string == NULL || (*string != 'd' && *string != 'D'))
  23.340 +        {
  23.341 +            printk (KERN_ALERT 
  23.342 +                    "hmm, extent disk specifier missing [%s]. should be \"disk\".\n",
  23.343 +                    string);
  23.344 +            return count;
  23.345 +        }
  23.346 +        string = get_string(NULL);                                /* disk number */
  23.347 +        if (string == NULL)
  23.348 +        {
  23.349 +            printk (KERN_ALERT "error: disk number missing\n");
  23.350 +            return count;
  23.351 +        }
  23.352 +        xvd.extents[loop].disk = (int) to_number(string);
  23.353  
  23.354 -  {
  23.355 -    /* get lock xlblk_control_lock     */
  23.356 -    counter = atomic_read(&xlblk_control_count);
  23.357 -    atomic_inc(&xlblk_control_count);
  23.358 -    /* release lock xlblk_control_lock */
  23.359 -  }
  23.360 -  if (hypervisor_request (NULL, XEN_BLOCK_SEG_CREATE, (char *)&xvd,
  23.361 -			  0, 0, (kdev_t) 0,
  23.362 -			  (struct gendisk *)NULL))
  23.363 -    BUG();
  23.364 -  HYPERVISOR_block_io_op();
  23.365 +        string = get_string(NULL);                            /* look for Offset */
  23.366 +        if (string == NULL || (*string != 'o' && *string != 'O'))
  23.367 +        {
  23.368 +            printk (KERN_ALERT 
  23.369 +                    "error: disk offset missing [%s]. should be \"offset\".\n",
  23.370 +                    string);
  23.371 +            return count;
  23.372 +        }
  23.373 +        string = get_string(NULL);                                     /* offset */
  23.374 +        if (string == NULL)
  23.375 +        {
  23.376 +            printk (KERN_ALERT "error: offset missing\n");
  23.377 +            return count;
  23.378 +        }
  23.379 +        xvd.extents[loop].offset =  to_number(string);
  23.380  
  23.381 -  while (atomic_read(&xlblk_control_count) != counter) barrier();
  23.382 +        string = get_string(NULL);                              /* look for Size */
  23.383 +        if (string == NULL || (*string != 's' && *string != 'S'))
  23.384 +        {
  23.385 +            printk (KERN_ALERT 
  23.386 +                    "error: extent size missing [%s]. should be \"size\".\n",
  23.387 +                    string);
  23.388 +            return count;
  23.389 +        }
  23.390 +        string = get_string(NULL);                                       /* size */
  23.391 +        if (string == NULL)
  23.392 +        {
  23.393 +            printk (KERN_ALERT "error: extent size missing\n");
  23.394 +            return count;
  23.395 +        }
  23.396 +        xvd.extents[loop].size =  to_number(string);
  23.397 +    }
  23.398  
  23.399 -  return count;
  23.400 +    xenolinux_control_msg(XEN_BLOCK_SEG_CREATE, (char *)&xvd);
  23.401 +
  23.402 +    return count;
  23.403  }
  23.404  
  23.405  /******************************************************************/
  23.406  
  23.407  int __init xlseg_proc_init(void)
  23.408  {
  23.409 -  vhd = create_proc_entry("xeno/dom0/vhd", 0644, NULL);
  23.410 -  if (vhd == NULL)
  23.411 -  {
  23.412 -    panic ("xlseg_init: unable to create vhd proc entry\n");
  23.413 -  }
  23.414 -  vhd->data       = NULL;
  23.415 -  vhd->read_proc  = proc_read_vhd;
  23.416 -  vhd->write_proc = proc_write_vhd;
  23.417 -  vhd->owner      = THIS_MODULE;
  23.418 +    vhd = create_proc_entry("xeno/dom0/vhd", 0644, NULL);
  23.419 +    if (vhd == NULL)
  23.420 +    {
  23.421 +        panic ("xlseg_init: unable to create vhd proc entry\n");
  23.422 +    }
  23.423 +    vhd->data       = NULL;
  23.424 +    vhd->read_proc  = proc_read_vhd;
  23.425 +    vhd->write_proc = proc_write_vhd;
  23.426 +    vhd->owner      = THIS_MODULE;
  23.427  
  23.428 -  memset(&xvd, 0, sizeof(xvd));
  23.429 -
  23.430 -  printk(KERN_ALERT "XenoLinux Virtual Disk Device Monitor installed\n");
  23.431 -  return 0;
  23.432 +    printk(KERN_ALERT "XenoLinux Virtual Disk Device Monitor installed\n");
  23.433 +    return 0;
  23.434  }
  23.435  
  23.436  static void __exit xlseg_proc_cleanup(void)
  23.437  {
  23.438 -  printk(KERN_ALERT "XenoLinux Virtual Disk Device Monitor uninstalled\n");
  23.439 +    printk(KERN_ALERT "XenoLinux Virtual Disk Device Monitor uninstalled\n");
  23.440  }
  23.441  
  23.442  #ifdef MODULE
    24.1 --- a/xenolinux-2.4.21-pre4-sparse/include/linux/blk.h	Thu Mar 06 16:54:15 2003 +0000
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,420 +0,0 @@
    24.4 -#ifndef _BLK_H
    24.5 -#define _BLK_H
    24.6 -
    24.7 -#include <linux/blkdev.h>
    24.8 -#include <linux/locks.h>
    24.9 -#include <linux/config.h>
   24.10 -#include <linux/spinlock.h>
   24.11 -
   24.12 -/*
   24.13 - * Spinlock for protecting the request queue which
   24.14 - * is mucked around with in interrupts on potentially
   24.15 - * multiple CPU's..
   24.16 - */
   24.17 -extern spinlock_t io_request_lock;
   24.18 -
   24.19 -/*
   24.20 - * Initialization functions.
   24.21 - */
   24.22 -extern int isp16_init(void);
   24.23 -extern int cdu31a_init(void);
   24.24 -extern int acsi_init(void);
   24.25 -extern int mcd_init(void);
   24.26 -extern int mcdx_init(void);
   24.27 -extern int sbpcd_init(void);
   24.28 -extern int aztcd_init(void);
   24.29 -extern int sony535_init(void);
   24.30 -extern int gscd_init(void);
   24.31 -extern int cm206_init(void);
   24.32 -extern int optcd_init(void);
   24.33 -extern int sjcd_init(void);
   24.34 -extern int cdi_init(void);
   24.35 -extern int hd_init(void);
   24.36 -extern int ide_init(void);
   24.37 -extern int xd_init(void);
   24.38 -extern int mfm_init(void);
   24.39 -extern int loop_init(void);
   24.40 -extern int md_init(void);
   24.41 -extern int ap_init(void);
   24.42 -extern int ddv_init(void);
   24.43 -extern int z2_init(void);
   24.44 -extern int swim3_init(void);
   24.45 -extern int swimiop_init(void);
   24.46 -extern int amiga_floppy_init(void);
   24.47 -extern int atari_floppy_init(void);
   24.48 -extern int ez_init(void);
   24.49 -extern int bpcd_init(void);
   24.50 -extern int ps2esdi_init(void);
   24.51 -extern int jsfd_init(void);
   24.52 -extern int viodasd_init(void);
   24.53 -extern int viocd_init(void);
   24.54 -extern int xlblk_init(void);
   24.55 -
   24.56 -#if defined(CONFIG_ARCH_S390)
   24.57 -extern int dasd_init(void);
   24.58 -extern int xpram_init(void);
   24.59 -extern int tapeblock_init(void);
   24.60 -#endif /* CONFIG_ARCH_S390 */
   24.61 -
   24.62 -extern void set_device_ro(kdev_t dev,int flag);
   24.63 -void add_blkdev_randomness(int major);
   24.64 -
   24.65 -extern int floppy_init(void);
   24.66 -extern int rd_doload;		/* 1 = load ramdisk, 0 = don't load */
   24.67 -extern int rd_prompt;		/* 1 = prompt for ramdisk, 0 = don't prompt */
   24.68 -extern int rd_image_start;	/* starting block # of image */
   24.69 -
   24.70 -#ifdef CONFIG_BLK_DEV_INITRD
   24.71 -
   24.72 -#define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
   24.73 -
   24.74 -extern unsigned long initrd_start,initrd_end;
   24.75 -extern int initrd_below_start_ok; /* 1 if it is not an error if initrd_start < memory_start */
   24.76 -void initrd_init(void);
   24.77 -
   24.78 -#endif
   24.79 -
   24.80 -		 
   24.81 -/*
   24.82 - * end_request() and friends. Must be called with the request queue spinlock
   24.83 - * acquired. All functions called within end_request() _must_be_ atomic.
   24.84 - *
   24.85 - * Several drivers define their own end_request and call
   24.86 - * end_that_request_first() and end_that_request_last()
   24.87 - * for parts of the original function. This prevents
   24.88 - * code duplication in drivers.
   24.89 - */
   24.90 -
   24.91 -static inline void blkdev_dequeue_request(struct request * req)
   24.92 -{
   24.93 -	list_del(&req->queue);
   24.94 -}
   24.95 -
   24.96 -int end_that_request_first(struct request *req, int uptodate, char *name);
   24.97 -void end_that_request_last(struct request *req);
   24.98 -
   24.99 -#if defined(MAJOR_NR) || defined(IDE_DRIVER)
  24.100 -
  24.101 -#undef DEVICE_ON
  24.102 -#undef DEVICE_OFF
  24.103 -
  24.104 -/*
  24.105 - * Add entries as needed.
  24.106 - */
  24.107 -
  24.108 -#ifdef IDE_DRIVER
  24.109 -
  24.110 -#define DEVICE_NR(device)	(MINOR(device) >> PARTN_BITS)
  24.111 -#define DEVICE_NAME "ide"
  24.112 -
  24.113 -#elif (MAJOR_NR == RAMDISK_MAJOR)
  24.114 -
  24.115 -/* ram disk */
  24.116 -#define DEVICE_NAME "ramdisk"
  24.117 -#define DEVICE_NR(device) (MINOR(device))
  24.118 -#define DEVICE_NO_RANDOM
  24.119 -
  24.120 -#elif (MAJOR_NR == Z2RAM_MAJOR)
  24.121 -
  24.122 -/* Zorro II Ram */
  24.123 -#define DEVICE_NAME "Z2RAM"
  24.124 -#define DEVICE_REQUEST do_z2_request
  24.125 -#define DEVICE_NR(device) (MINOR(device))
  24.126 -
  24.127 -#elif (MAJOR_NR == FLOPPY_MAJOR)
  24.128 -
  24.129 -static void floppy_off(unsigned int nr);
  24.130 -
  24.131 -#define DEVICE_NAME "floppy"
  24.132 -#define DEVICE_INTR do_floppy
  24.133 -#define DEVICE_REQUEST do_fd_request
  24.134 -#define DEVICE_NR(device) ( (MINOR(device) & 3) | ((MINOR(device) & 0x80 ) >> 5 ))
  24.135 -#define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
  24.136 -
  24.137 -#elif (MAJOR_NR == HD_MAJOR)
  24.138 -
  24.139 -/* Hard disk:  timeout is 6 seconds. */
  24.140 -#define DEVICE_NAME "hard disk"
  24.141 -#define DEVICE_INTR do_hd
  24.142 -#define TIMEOUT_VALUE (6*HZ)
  24.143 -#define DEVICE_REQUEST do_hd_request
  24.144 -#define DEVICE_NR(device) (MINOR(device)>>6)
  24.145 -
  24.146 -#elif (SCSI_DISK_MAJOR(MAJOR_NR))
  24.147 -
  24.148 -#define DEVICE_NAME "scsidisk"
  24.149 -#define TIMEOUT_VALUE (2*HZ)
  24.150 -#define DEVICE_NR(device) (((MAJOR(device) & SD_MAJOR_MASK) << (8 - 4)) + (MINOR(device) >> 4))
  24.151 -
  24.152 -/* Kludge to use the same number for both char and block major numbers */
  24.153 -#elif  (MAJOR_NR == MD_MAJOR) && defined(MD_DRIVER)
  24.154 -
  24.155 -#define DEVICE_NAME "Multiple devices driver"
  24.156 -#define DEVICE_REQUEST do_md_request
  24.157 -#define DEVICE_NR(device) (MINOR(device))
  24.158 -
  24.159 -#elif (MAJOR_NR == SCSI_TAPE_MAJOR)
  24.160 -
  24.161 -#define DEVICE_NAME "scsitape"
  24.162 -#define DEVICE_INTR do_st  
  24.163 -#define DEVICE_NR(device) (MINOR(device) & 0x7f)
  24.164 -
  24.165 -#elif (MAJOR_NR == OSST_MAJOR)
  24.166 -
  24.167 -#define DEVICE_NAME "onstream" 
  24.168 -#define DEVICE_INTR do_osst
  24.169 -#define DEVICE_NR(device) (MINOR(device) & 0x7f) 
  24.170 -#define DEVICE_ON(device) 
  24.171 -#define DEVICE_OFF(device) 
  24.172 -
  24.173 -#elif (MAJOR_NR == SCSI_CDROM_MAJOR)
  24.174 -
  24.175 -#define DEVICE_NAME "CD-ROM"
  24.176 -#define DEVICE_NR(device) (MINOR(device))
  24.177 -
  24.178 -#elif (MAJOR_NR == XT_DISK_MAJOR)
  24.179 -
  24.180 -#define DEVICE_NAME "xt disk"
  24.181 -#define DEVICE_REQUEST do_xd_request
  24.182 -#define DEVICE_NR(device) (MINOR(device) >> 6)
  24.183 -
  24.184 -#elif (MAJOR_NR == PS2ESDI_MAJOR)
  24.185 -
  24.186 -#define DEVICE_NAME "PS/2 ESDI"
  24.187 -#define DEVICE_REQUEST do_ps2esdi_request
  24.188 -#define DEVICE_NR(device) (MINOR(device) >> 6)
  24.189 -
  24.190 -#elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
  24.191 -
  24.192 -#define DEVICE_NAME "CDU31A"
  24.193 -#define DEVICE_REQUEST do_cdu31a_request
  24.194 -#define DEVICE_NR(device) (MINOR(device))
  24.195 -
  24.196 -#elif (MAJOR_NR == ACSI_MAJOR) && (defined(CONFIG_ATARI_ACSI) || defined(CONFIG_ATARI_ACSI_MODULE))
  24.197 -
  24.198 -#define DEVICE_NAME "ACSI"
  24.199 -#define DEVICE_INTR do_acsi
  24.200 -#define DEVICE_REQUEST do_acsi_request
  24.201 -#define DEVICE_NR(device) (MINOR(device) >> 4)
  24.202 -
  24.203 -#elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
  24.204 -
  24.205 -#define DEVICE_NAME "Mitsumi CD-ROM"
  24.206 -/* #define DEVICE_INTR do_mcd */
  24.207 -#define DEVICE_REQUEST do_mcd_request
  24.208 -#define DEVICE_NR(device) (MINOR(device))
  24.209 -
  24.210 -#elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
  24.211 -
  24.212 -#define DEVICE_NAME "Mitsumi CD-ROM"
  24.213 -/* #define DEVICE_INTR do_mcdx */
  24.214 -#define DEVICE_REQUEST do_mcdx_request
  24.215 -#define DEVICE_NR(device) (MINOR(device))
  24.216 -
  24.217 -#elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
  24.218 -
  24.219 -#define DEVICE_NAME "Matsushita CD-ROM controller #1"
  24.220 -#define DEVICE_REQUEST do_sbpcd_request
  24.221 -#define DEVICE_NR(device) (MINOR(device))
  24.222 -
  24.223 -#elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
  24.224 -
  24.225 -#define DEVICE_NAME "Matsushita CD-ROM controller #2"
  24.226 -#define DEVICE_REQUEST do_sbpcd2_request
  24.227 -#define DEVICE_NR(device) (MINOR(device))
  24.228 -
  24.229 -#elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
  24.230 -
  24.231 -#define DEVICE_NAME "Matsushita CD-ROM controller #3"
  24.232 -#define DEVICE_REQUEST do_sbpcd3_request
  24.233 -#define DEVICE_NR(device) (MINOR(device))
  24.234 -
  24.235 -#elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
  24.236 -
  24.237 -#define DEVICE_NAME "Matsushita CD-ROM controller #4"
  24.238 -#define DEVICE_REQUEST do_sbpcd4_request
  24.239 -#define DEVICE_NR(device) (MINOR(device))
  24.240 -
  24.241 -#elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
  24.242 -
  24.243 -#define DEVICE_NAME "Aztech CD-ROM"
  24.244 -#define DEVICE_REQUEST do_aztcd_request
  24.245 -#define DEVICE_NR(device) (MINOR(device))
  24.246 -
  24.247 -#elif (MAJOR_NR == CDU535_CDROM_MAJOR)
  24.248 -
  24.249 -#define DEVICE_NAME "SONY-CDU535"
  24.250 -#define DEVICE_INTR do_cdu535
  24.251 -#define DEVICE_REQUEST do_cdu535_request
  24.252 -#define DEVICE_NR(device) (MINOR(device))
  24.253 -
  24.254 -#elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
  24.255 -
  24.256 -#define DEVICE_NAME "Goldstar R420"
  24.257 -#define DEVICE_REQUEST do_gscd_request
  24.258 -#define DEVICE_NR(device) (MINOR(device))
  24.259 -
  24.260 -#elif (MAJOR_NR == CM206_CDROM_MAJOR)
  24.261 -#define DEVICE_NAME "Philips/LMS CD-ROM cm206"
  24.262 -#define DEVICE_REQUEST do_cm206_request
  24.263 -#define DEVICE_NR(device) (MINOR(device))
  24.264 -
  24.265 -#elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
  24.266 -
  24.267 -#define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
  24.268 -#define DEVICE_REQUEST do_optcd_request
  24.269 -#define DEVICE_NR(device) (MINOR(device))
  24.270 -
  24.271 -#elif (MAJOR_NR == SANYO_CDROM_MAJOR)
  24.272 -
  24.273 -#define DEVICE_NAME "Sanyo H94A CD-ROM"
  24.274 -#define DEVICE_REQUEST do_sjcd_request
  24.275 -#define DEVICE_NR(device) (MINOR(device))
  24.276 -
  24.277 -#elif (MAJOR_NR == APBLOCK_MAJOR)
  24.278 -
  24.279 -#define DEVICE_NAME "apblock"
  24.280 -#define DEVICE_REQUEST ap_request
  24.281 -#define DEVICE_NR(device) (MINOR(device))
  24.282 -
  24.283 -#elif (MAJOR_NR == DDV_MAJOR)
  24.284 -
  24.285 -#define DEVICE_NAME "ddv"
  24.286 -#define DEVICE_REQUEST ddv_request
  24.287 -#define DEVICE_NR(device) (MINOR(device)>>PARTN_BITS)
  24.288 -
  24.289 -#elif (MAJOR_NR == MFM_ACORN_MAJOR)
  24.290 -
  24.291 -#define DEVICE_NAME "mfm disk"
  24.292 -#define DEVICE_INTR do_mfm
  24.293 -#define DEVICE_REQUEST do_mfm_request
  24.294 -#define DEVICE_NR(device) (MINOR(device) >> 6)
  24.295 -
  24.296 -#elif (MAJOR_NR == NBD_MAJOR)
  24.297 -
  24.298 -#define DEVICE_NAME "nbd"
  24.299 -#define DEVICE_REQUEST do_nbd_request
  24.300 -#define DEVICE_NR(device) (MINOR(device))
  24.301 -
  24.302 -#elif (MAJOR_NR == MDISK_MAJOR)
  24.303 -
  24.304 -#define DEVICE_NAME "mdisk"
  24.305 -#define DEVICE_REQUEST mdisk_request
  24.306 -#define DEVICE_NR(device) (MINOR(device))
  24.307 -
  24.308 -#elif (MAJOR_NR == DASD_MAJOR)
  24.309 -
  24.310 -#define DEVICE_NAME "dasd"
  24.311 -#define DEVICE_REQUEST do_dasd_request
  24.312 -#define DEVICE_NR(device) (MINOR(device) >> PARTN_BITS)
  24.313 -
  24.314 -#elif (MAJOR_NR == I2O_MAJOR)
  24.315 -
  24.316 -#define DEVICE_NAME "I2O block"
  24.317 -#define DEVICE_REQUEST i2ob_request
  24.318 -#define DEVICE_NR(device) (MINOR(device)>>4)
  24.319 -
  24.320 -#elif (MAJOR_NR == COMPAQ_SMART2_MAJOR)
  24.321 -
  24.322 -#define DEVICE_NAME "ida"
  24.323 -#define TIMEOUT_VALUE (25*HZ)
  24.324 -#define DEVICE_REQUEST do_ida_request
  24.325 -#define DEVICE_NR(device) (MINOR(device) >> 4)
  24.326 -
  24.327 -#elif (MAJOR_NR == XLBLK_MAJOR)
  24.328 -
  24.329 -#define DEVICE_NAME "xeno disk"
  24.330 -#define DEVICE_REQUEST do_xlblk_request
  24.331 -/* #define DEVICE_INTR */
  24.332 -#define DEVICE_NR(device) (MINOR(device))
  24.333 -
  24.334 -#elif (MAJOR_NR == XLSEG_MAJOR)
  24.335 -
  24.336 -#define DEVICE_NAME "xeno segment"
  24.337 -#define DEVICE_REQUEST do_xlseg_request
  24.338 -/* #define DEVICE_INTR */
  24.339 -#define DEVICE_NR(device) (MINOR(device))
  24.340 -
  24.341 -#endif /* MAJOR_NR == whatever */
  24.342 -
  24.343 -/* provide DEVICE_xxx defaults, if not explicitly defined
  24.344 - * above in the MAJOR_NR==xxx if-elif tree */
  24.345 -#ifndef DEVICE_ON
  24.346 -#define DEVICE_ON(device) do {} while (0)
  24.347 -#endif
  24.348 -#ifndef DEVICE_OFF
  24.349 -#define DEVICE_OFF(device) do {} while (0)
  24.350 -#endif
  24.351 -
  24.352 -#if (MAJOR_NR != SCSI_TAPE_MAJOR) && (MAJOR_NR != OSST_MAJOR)
  24.353 -#if !defined(IDE_DRIVER)
  24.354 -
  24.355 -#ifndef CURRENT
  24.356 -#define CURRENT blkdev_entry_next_request(&blk_dev[MAJOR_NR].request_queue.queue_head)
  24.357 -#endif
  24.358 -#ifndef QUEUE_EMPTY
  24.359 -#define QUEUE_EMPTY list_empty(&blk_dev[MAJOR_NR].request_queue.queue_head)
  24.360 -#endif
  24.361 -
  24.362 -#ifndef DEVICE_NAME
  24.363 -#define DEVICE_NAME "unknown"
  24.364 -#endif
  24.365 -
  24.366 -#define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
  24.367 -
  24.368 -#ifdef DEVICE_INTR
  24.369 -static void (*DEVICE_INTR)(void) = NULL;
  24.370 -#endif
  24.371 -
  24.372 -#define SET_INTR(x) (DEVICE_INTR = (x))
  24.373 -
  24.374 -#ifdef DEVICE_REQUEST
  24.375 -static void (DEVICE_REQUEST)(request_queue_t *);
  24.376 -#endif 
  24.377 -  
  24.378 -#ifdef DEVICE_INTR
  24.379 -#define CLEAR_INTR SET_INTR(NULL)
  24.380 -#else
  24.381 -#define CLEAR_INTR
  24.382 -#endif
  24.383 -
  24.384 -#define INIT_REQUEST \
  24.385 -	if (QUEUE_EMPTY) {\
  24.386 -		CLEAR_INTR; \
  24.387 -		return; \
  24.388 -	} \
  24.389 -	if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \
  24.390 -		panic(DEVICE_NAME ": request list destroyed"); \
  24.391 -	if (CURRENT->bh) { \
  24.392 -		if (!buffer_locked(CURRENT->bh)) \
  24.393 -			panic(DEVICE_NAME ": block not locked"); \
  24.394 -	}
  24.395 -
  24.396 -#endif /* !defined(IDE_DRIVER) */
  24.397 -
  24.398 -
  24.399 -#ifndef LOCAL_END_REQUEST	/* If we have our own end_request, we do not want to include this mess */
  24.400 -
  24.401 -#if ! SCSI_BLK_MAJOR(MAJOR_NR) && (MAJOR_NR != COMPAQ_SMART2_MAJOR)
  24.402 -
  24.403 -static inline void end_request(int uptodate) {
  24.404 -	struct request *req = CURRENT;
  24.405 -
  24.406 -	if (end_that_request_first(req, uptodate, DEVICE_NAME))
  24.407 -		return;
  24.408 -
  24.409 -#ifndef DEVICE_NO_RANDOM
  24.410 -	add_blkdev_randomness(MAJOR(req->rq_dev));
  24.411 -#endif
  24.412 -	DEVICE_OFF(req->rq_dev);
  24.413 -	blkdev_dequeue_request(req);
  24.414 -	end_that_request_last(req);
  24.415 -}
  24.416 -
  24.417 -#endif /* ! SCSI_BLK_MAJOR(MAJOR_NR) */
  24.418 -#endif /* LOCAL_END_REQUEST */
  24.419 -
  24.420 -#endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) */
  24.421 -#endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
  24.422 -
  24.423 -#endif /* _BLK_H */
    25.1 --- a/xenolinux-2.4.21-pre4-sparse/include/linux/major.h	Thu Mar 06 16:54:15 2003 +0000
    25.2 +++ b/xenolinux-2.4.21-pre4-sparse/include/linux/major.h	Fri Mar 07 01:38:49 2003 +0000
    25.3 @@ -145,8 +145,15 @@
    25.4  
    25.5  #define	UMEM_MAJOR	116	/* http://www.umem.com/ Battery Backed RAM */
    25.6  
    25.7 +/*
    25.8 + * Each of these majors supports up to 16 devices of <= 16 partitions each.
    25.9 + * eg. xhda == (123, 0), xhdb == (123, 16), ...
   25.10 + *     xsda == (124, 0), xsdb == (124, 16), ...
   25.11 + *     xvda == (125, 0), xvdb == (125, 16), ...
   25.12 + */
   25.13  #define XLIDE_MAJOR	123	/* XenoLinux IDE Device */
   25.14 -#define XLSCSI_MAJOR	133	/* XenoLinux SCSI Device */
   25.15 +#define XLSCSI_MAJOR	124	/* XenoLinux SCSI Device */
   25.16 +#define XLVIRT_MAJOR    125     /* XenoLinux Virtual Device */
   25.17  
   25.18  #define RTF_MAJOR	150
   25.19  #define RAW_MAJOR	162
    26.1 --- a/xenolinux-2.4.21-pre4-sparse/init/do_mounts.c	Thu Mar 06 16:54:15 2003 +0000
    26.2 +++ b/xenolinux-2.4.21-pre4-sparse/init/do_mounts.c	Fri Mar 07 01:38:49 2003 +0000
    26.3 @@ -231,8 +231,33 @@ static struct dev_name_struct {
    26.4  	{ "ataraid/d14p",0x72E0 },
    26.5  	{ "ataraid/d15p",0x72F0 },
    26.6  #if defined(CONFIG_XENOLINUX_BLOCK)
    26.7 -        { "xhda",    0x7B00 },
    26.8 -        { "xsda",    0x8500 },
    26.9 +        /* XenoLinux IDE Devices */
   26.10 +        { "xhda", 0x7B00 }, { "xhdb", 0x7B10 },
   26.11 +        { "xhdc", 0x7B20 }, { "xhdd", 0x7B30 },
   26.12 +        { "xhde", 0x7B40 }, { "xhdf", 0x7B50 },
   26.13 +        { "xhdg", 0x7B60 }, { "xhdh", 0x7B70 },
   26.14 +        { "xhdi", 0x7B80 }, { "xhdj", 0x7B90 },
   26.15 +        { "xhdk", 0x7BA0 }, { "xhdl", 0x7BB0 },
   26.16 +        { "xhdm", 0x7BC0 }, { "xhdn", 0x7BD0 },
   26.17 +        { "xhdo", 0x7BE0 }, { "xhdp", 0x7BF0 },
   26.18 +        /* Xenolinux SCSI Devices */
   26.19 +        { "xsda", 0x7C00 }, { "xsdb", 0x7C10 },
   26.20 +        { "xsdc", 0x7C20 }, { "xsdd", 0x7C30 },
   26.21 +        { "xsde", 0x7C40 }, { "xsdf", 0x7C50 },
   26.22 +        { "xsdg", 0x7C60 }, { "xsdh", 0x7C70 },
   26.23 +        { "xsdi", 0x7C80 }, { "xsdj", 0x7C90 },
   26.24 +        { "xsdk", 0x7CA0 }, { "xsdl", 0x7CB0 },
   26.25 +        { "xsdm", 0x7CC0 }, { "xsdn", 0x7CD0 },
   26.26 +        { "xsdo", 0x7CE0 }, { "xsdp", 0x7CF0 },
   26.27 +        /* XenoLinux Virtual Devices */
   26.28 +        { "xvda", 0x7D00 }, { "xvdb", 0x7D10 },
   26.29 +        { "xvdc", 0x7D20 }, { "xvdd", 0x7D30 },
   26.30 +        { "xvde", 0x7D40 }, { "xvdf", 0x7D50 },
   26.31 +        { "xvdg", 0x7D60 }, { "xvdh", 0x7D70 },
   26.32 +        { "xvdi", 0x7D80 }, { "xvdj", 0x7D90 },
   26.33 +        { "xvdk", 0x7DA0 }, { "xvdl", 0x7DB0 },
   26.34 +        { "xvdm", 0x7DC0 }, { "xvdn", 0x7DD0 },
   26.35 +        { "xvdo", 0x7DE0 }, { "xvdp", 0x7DF0 },
   26.36  #endif
   26.37  	{ "nftla", 0x5d00 },
   26.38  	{ "nftlb", 0x5d10 },