Commit 92cb0557 authored by Eugene (jno) Dvurechenski's avatar Eugene (jno) Dvurechenski Committed by Christian Borntraeger

pc-bios/s390-ccw: support all virtio block size

The block size value may be given "as is" OR as a base value and
a shift count (exponent). So, we have to use calculation to get
the proper number in the code.

The main expression reads as
        (blk_cfg.blk_size << blk_cfg.physical_block_exp)

E.g., various combinations between blk_size=1/physical_block_exp=12
and blk_size=4096/physical_block_exp=0 are valid for 4K blocks.
Signed-off-by: default avatarEugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
Acked-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: default avatarJens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
parent 159855f0
......@@ -275,12 +275,14 @@ void virtio_assume_scsi(void)
{
guessed_disk_nature = true;
blk_cfg.blk_size = 512;
blk_cfg.physical_block_exp = 0;
}
void virtio_assume_eckd(void)
{
guessed_disk_nature = true;
blk_cfg.blk_size = 4096;
blk_cfg.physical_block_exp = 0;
/* this must be here to calculate code segment position */
blk_cfg.geometry.heads = 15;
......@@ -290,31 +292,31 @@ void virtio_assume_eckd(void)
bool virtio_disk_is_scsi(void)
{
if (guessed_disk_nature) {
return (blk_cfg.blk_size == 512);
return (virtio_get_block_size() == 512);
}
return (blk_cfg.geometry.heads == 255)
&& (blk_cfg.geometry.sectors == 63)
&& (blk_cfg.blk_size == 512);
&& (virtio_get_block_size() == 512);
}
bool virtio_disk_is_eckd(void)
{
if (guessed_disk_nature) {
return (blk_cfg.blk_size == 4096);
return (virtio_get_block_size() == 4096);
}
return (blk_cfg.geometry.heads == 15)
&& (blk_cfg.geometry.sectors == 12)
&& (blk_cfg.blk_size == 4096);
&& (virtio_get_block_size() == 4096);
}
bool virtio_ipl_disk_is_valid(void)
{
return blk_cfg.blk_size && (virtio_disk_is_scsi() || virtio_disk_is_eckd());
return virtio_disk_is_scsi() || virtio_disk_is_eckd();
}
int virtio_get_block_size(void)
{
return blk_cfg.blk_size;
return blk_cfg.blk_size << blk_cfg.physical_block_exp;
}
uint16_t virtio_get_cylinders(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment