mirror of https://github.com/acidanthera/audk.git
OvmfPkg/XenPvBlkDxe: Update disk size calculation
The specification wasn't clear and even contradict itself regarding the calculation of the disk size. This have been clarified by Xen commit 221f2748e8da ("blkif: reconcile protocol specification with in-use implementations"). https://xenbits.xenproject.org/gitweb/?p=xen.git;a=commit;h=221f2748e8dabe8361b8cdfcffbeab9102c4c899 The value from the xenstore node "sectors" must be multiplied by 512 to have the size of the disk. Calculation of LastBlock is now the same for both CD-ROM case and generic case. Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
This commit is contained in:
parent
3cf7a644eb
commit
8c1e786e50
|
@ -356,7 +356,7 @@ Again:
|
||||||
|
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"XenPvBlk: New disk with %ld sectors of %d bytes\n",
|
"XenPvBlk: New disk with %ld 512B-sectors and logical sector size of %d bytes\n",
|
||||||
Dev->MediaInfo.Sectors,
|
Dev->MediaInfo.Sectors,
|
||||||
Dev->MediaInfo.SectorSize
|
Dev->MediaInfo.SectorSize
|
||||||
));
|
));
|
||||||
|
|
|
@ -295,15 +295,19 @@ XenPvBlkDxeDriverBindingStart (
|
||||||
// MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
|
// MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
|
||||||
//
|
//
|
||||||
Media->BlockSize = 2048;
|
Media->BlockSize = 2048;
|
||||||
Media->LastBlock = DivU64x32 (
|
|
||||||
Dev->MediaInfo.Sectors,
|
|
||||||
Media->BlockSize / Dev->MediaInfo.SectorSize
|
|
||||||
) - 1;
|
|
||||||
} else {
|
} else {
|
||||||
Media->BlockSize = Dev->MediaInfo.SectorSize;
|
Media->BlockSize = Dev->MediaInfo.SectorSize;
|
||||||
Media->LastBlock = Dev->MediaInfo.Sectors - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Sectors is express as 512B unit, size of disk is "Sectors * 512",
|
||||||
|
// independently from SectorSize.
|
||||||
|
//
|
||||||
|
Media->LastBlock = DivU64x32 (
|
||||||
|
Dev->MediaInfo.Sectors,
|
||||||
|
Media->BlockSize / 512
|
||||||
|
) - 1;
|
||||||
|
|
||||||
ASSERT (Media->BlockSize % 512 == 0);
|
ASSERT (Media->BlockSize % 512 == 0);
|
||||||
Dev->BlockIo.Media = Media;
|
Dev->BlockIo.Media = Media;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue