diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c index a6cd7e0..b9c31aa 100644 --- a/arch/x86/boards/x86_generic/generic_pc.c +++ b/arch/x86/boards/x86_generic/generic_pc.c @@ -46,7 +46,7 @@ static struct device_d bios_disk_dev = { .id = -1, .name = "biosdrive", - .size = 1, + .size = 0, /* auto guess */ }; /* diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c index 15ef5f4..a54429a 100644 --- a/drivers/ata/disk_drive.c +++ b/drivers/ata/disk_drive.c @@ -23,6 +23,7 @@ * @brief Generic disk drive support * * @todo Support for disks larger than 4 GiB + * @todo Reliable size detection for BIOS based disks (on x86 only) */ #include @@ -299,11 +300,16 @@ else #endif disk_cdev->name = asprintf("disk%d", dev->id); - /** - * @todo we need the size of the drive, else its nearly impossible - * to do anything with it (at least with the generic routines) - */ - disk_cdev->size = 32; /* FIXME */ + + /* On x86, BIOS based disks are coming without a valid .size field */ + if (dev->size == 0) { + /* + * We need always the size of the drive, else its nearly impossible + * to do anything with it (at least with the generic routines) + */ + disk_cdev->size = 32; + } else + disk_cdev->size = dev->size; disk_cdev->ops = &disk_ops; disk_cdev->dev = dev; devfs_create(disk_cdev); @@ -314,10 +320,13 @@ goto on_error; } - /* guess the size of this drive */ - dev->size = disk_guess_size(dev, (struct partition_entry*)§or[446]) * SECTOR_SIZE; - dev_info(dev, "Drive size guessed to %u kiB\n", dev->size / 1024); - disk_cdev->size = dev->size; + if (dev->size == 0) { + /* guess the size of this drive if not otherwise given */ + dev->size = disk_guess_size(dev, + (struct partition_entry*)§or[446]) * SECTOR_SIZE; + dev_info(dev, "Drive size guessed to %u kiB\n", dev->size / 1024); + disk_cdev->size = dev->size; + } rc = disk_register_partitions(dev, (struct partition_entry*)§or[446]);