static NTSTATUS
PdoSendReadCapacity16Synchronous(
- IN PXENDISK_PDO Pdo,
- OUT PULONG SectorSize,
- OUT PULONG PhysSectorSize
+ IN PXENDISK_PDO Pdo,
+ OUT PULONG SectorSize,
+ OUT PULONG PhysSectorSize,
+ OUT PULONG64 SectorCount
)
{
- SCSI_REQUEST_BLOCK Srb;
- PCDB Cdb;
- PREAD_CAPACITY16_DATA Capacity;
- ULONG Length;
- NTSTATUS status;
+ SCSI_REQUEST_BLOCK Srb;
+ PCDB Cdb;
+ PREAD_CAPACITY16_DATA Capacity;
+ ULONG Length;
+ NTSTATUS status;
Trace("====>\n");
*SectorSize = _byteswap_ulong(Capacity->BytesPerBlock);
*PhysSectorSize = *SectorSize << Capacity->LogicalPerPhysicalExponent;
+ *SectorCount = _byteswap_uint64(Capacity->LogicalBlockAddress.QuadPart) + 1;
__PdoFree(Capacity);
{
ULONG SectorSize;
ULONG PhysSectorSize;
+ ULONG64 SectorCount;
+ ULONG64 Size;
POWER_STATE PowerState;
NTSTATUS status;
if (!NT_SUCCESS(status))
goto fail2;
- status = PdoSendReadCapacity16Synchronous(Pdo, &SectorSize, &PhysSectorSize);
+ status = PdoSendReadCapacity16Synchronous(Pdo,
+ &SectorSize,
+ &PhysSectorSize,
+ &SectorCount);
if (!NT_SUCCESS(status))
goto fail3;
- Trace("SectorSize = %u PhysSectorSize = %u\n", SectorSize, PhysSectorSize);
-
Pdo->SectorSize = SectorSize;
Pdo->PhysSectorSize = PhysSectorSize;
+ Size = SectorSize * SectorCount;
+ Size >>= 20; // Scale to megabytes
+
+ Verbose("%s: %luMB (%uB sectors)\n",
+ __PdoGetName(Pdo), Size, SectorSize);
+
__PdoSetSystemPowerState(Pdo, PowerSystemWorking);
__PdoSetDevicePowerState(Pdo, PowerDeviceD0);
}
// dump actual values
- Verbose("Target[%d] : %lld sectors of %d bytes (%d)\n", Frontend->TargetId,
- Frontend->DiskInfo.SectorCount, Frontend->DiskInfo.SectorSize,
- Frontend->DiskInfo.PhysSectorSize);
- Verbose("Target[%d] : %d %s (%08x) %s\n", Frontend->TargetId,
- __Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
- Frontend->DiskInfo.DiskInfo,
- Frontend->Caps.SurpriseRemovable ? "SURPRISE_REMOVABLE" : "");
+ Trace("Target[%d] : %lld sectors of %d bytes (%d)\n", Frontend->TargetId,
+ Frontend->DiskInfo.SectorCount, Frontend->DiskInfo.SectorSize,
+ Frontend->DiskInfo.PhysSectorSize);
+ Trace("Target[%d] : %d %s (%08x) %s\n", Frontend->TargetId,
+ __Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
+ Frontend->DiskInfo.DiskInfo,
+ Frontend->Caps.SurpriseRemovable ? "SURPRISE_REMOVABLE" : "");
}
static FORCEINLINE VOID