aboutsummaryrefslogtreecommitdiffstats
path: root/xen/drivers/ide/ide-xeno.c
blob: 351e2cbcf5062aee9fe00fdb7b01cce082c18428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <xeno/config.h>
#include <xeno/types.h>
#include <xeno/lib.h>
#include <xeno/ide.h>
#include <xeno/segment.h>
#include <hypervisor-ifs/block.h>
#include <asm/domain_page.h>
#include <asm/io.h>

void ide_probe_devices(xen_disk_info_t* xdi)
{
    int loop;
    unsigned int unit;
    xen_disk_info_t *xen_xdi = map_domain_mem(virt_to_phys(xdi));
    unsigned long capacity, device;
    ide_drive_t *drive;
    
    for ( loop = 0; loop < MAX_HWIFS; loop++ )
    {
	ide_hwif_t *hwif = &ide_hwifs[loop];
	if ( !hwif->present ) continue;

        for ( unit = 0; unit < MAX_DRIVES; unit++ )
        {
            drive = &hwif->drives[unit];
            if ( !drive->present ) continue;
            
            device   = MK_IDE_XENDEV((loop * MAX_DRIVES) + unit);
            capacity = current_capacity(drive);

            xen_xdi->disks[xen_xdi->count].device   = device;
            xen_xdi->disks[xen_xdi->count].capacity = capacity;
            xen_xdi->count++;

            printk("Disk %d: IDE-XENO capacity %ldkB (%ldMB)\n",
                   xen_xdi->count, capacity>>1, capacity>>11);
        }
    }

    unmap_domain_mem(xen_xdi);
}