MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / ReadCapacity10

Method ReadCapacity10

cpp/devices/disk.cpp:550–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548}
549
550void Disk::ReadCapacity10()
551{
552 CheckReady();
553
554 if (GetBlockCount() == 0) {
555 throw scsi_exception(sense_key::illegal_request, asc::medium_not_present);
556 }
557
558 vector<uint8_t>& buf = GetController()->GetBuffer();
559
560 // Create end of logical block address (blocks-1)
561 uint64_t capacity = GetBlockCount() - 1;
562
563 // If the capacity exceeds 32 bit, -1 must be returned and the client has to use READ CAPACITY(16)
564 if (capacity > 4294967295) {
565 capacity = -1;
566 }
567 SetInt32(buf, 0, static_cast<uint32_t>(capacity));
568
569 // Create block length (1 << size)
570 SetInt32(buf, 4, 1 << size_shift_count);
571
572 GetController()->SetLength(8);
573
574 EnterDataInPhase();
575}
576
577void Disk::ReadCapacity16()
578{

Callers

nothing calls this directly

Calls 3

scsi_exceptionClass · 0.85
SetInt32Function · 0.85
SetLengthMethod · 0.80

Tested by

no test coverage detected