ia64/xen-unstable

view xen/drivers/ide/ide-xeno.c @ 926:0a901de56d7c

bitkeeper revision 1.588 (3fafd2ccYgSbWe9z2kLiH-DeviUaIA)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/local/scratch/smh22/xeno.bk
author smh22@labyrinth.cl.cam.ac.uk
date Mon Nov 10 18:02:52 2003 +0000 (2003-11-10)
parents db4b686bbf64 4aba3a48d64f
children a822251cfa9b
line source
1 #include <xeno/config.h>
2 #include <xeno/types.h>
3 #include <xeno/lib.h>
4 #include <xeno/ide.h>
5 #include <xeno/vbd.h>
6 #include <asm/domain_page.h>
7 #include <asm/io.h>
9 #define NR_IDE_DEVS 20
11 static kdev_t ide_devs[NR_IDE_DEVS] = {
12 MKDEV(IDE0_MAJOR, 0), MKDEV(IDE0_MAJOR, 64), /* hda, hdb */
13 MKDEV(IDE1_MAJOR, 0), MKDEV(IDE1_MAJOR, 64), /* hdc, hdd */
14 MKDEV(IDE2_MAJOR, 0), MKDEV(IDE2_MAJOR, 64), /* hde, hdf */
15 MKDEV(IDE3_MAJOR, 0), MKDEV(IDE3_MAJOR, 64), /* hdg, hdh */
16 MKDEV(IDE4_MAJOR, 0), MKDEV(IDE4_MAJOR, 64), /* hdi, hdj */
17 MKDEV(IDE5_MAJOR, 0), MKDEV(IDE5_MAJOR, 64), /* hdk, hdl */
18 MKDEV(IDE6_MAJOR, 0), MKDEV(IDE6_MAJOR, 64), /* hdm, hdn */
19 MKDEV(IDE7_MAJOR, 0), MKDEV(IDE7_MAJOR, 64), /* hdo, hdp */
20 MKDEV(IDE8_MAJOR, 0), MKDEV(IDE8_MAJOR, 64), /* hdq, hdr */
21 MKDEV(IDE9_MAJOR, 0), MKDEV(IDE9_MAJOR, 64) /* hds, hdt */
22 };
27 int ide_probe_devices(xen_disk_info_t* xdi)
28 {
29 int loop, ret = 0;
30 unsigned int unit;
31 unsigned short type;
32 ide_drive_t *drive;
33 xen_disk_t cur_disk;
35 for ( loop = 0; loop < MAX_HWIFS; loop++ )
36 {
37 ide_hwif_t *hwif = &ide_hwifs[loop];
38 if ( !hwif->present ) continue;
40 for ( unit = 0; unit < MAX_DRIVES; unit++ )
41 {
42 drive = &hwif->drives[unit];
44 if ( !drive->present ) continue;
47 /* SMH: don't ever expect this to happen, hence verbose printk */
48 if ( xdi->count == xdi->max ) {
49 printk("ide_probe_devices: out of space for probe.\n");
50 return -ENOMEM;
51 }
55 /* SMH: we export 'raw' linux device numbers to domain 0 */
56 cur_disk.device = ide_devs[(loop * MAX_DRIVES) + unit];
58 /*
59 ** NB: we use the ide 'media' field (ide_disk, ide_cdrom, etc)
60 ** as our 'type' field (XD_TYPE_DISK, XD_TYPE_CDROM, etc).
61 ** Hence must ensure these are kept in sync.
62 */
63 cur_disk.info = (type = drive->media);
64 if(type == XD_TYPE_CDROM)
65 cur_disk.info |= XD_FLAG_RO;
67 cur_disk.capacity = current_capacity(drive);
68 cur_disk.domain = 0; /* 'physical' disks belong to domain 0
70 /* Now copy into relevant part of user-space buffer */
71 if((ret = copy_to_user(xdi->disks + xdi->count, &cur_disk,
72 sizeof(xen_disk_t))) < 0) {
73 printk("ide_probe_devices: copy_to_user failed [rc=%d]\n",
74 ret);
75 return ret;
76 }
78 xdi->count++;
79 }
80 }
82 return ret;
83 }