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

Method StartStopUnit

cpp/devices/disk.cpp:199–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void Disk::StartStopUnit()
200{
201 const bool start = GetController()->GetCmdByte(4) & 0x01;
202 const bool load = GetController()->GetCmdByte(4) & 0x02;
203
204 if (load) {
205 LogTrace(start ? "Loading medium" : "Ejecting medium");
206 }
207 else {
208 LogTrace(start ? "Starting unit" : "Stopping unit");
209
210 SetStopped(!start);
211 }
212
213 if (!start) {
214 // Look at the eject bit and eject if necessary
215 if (load) {
216 if (IsLocked()) {
217 // Cannot be ejected because it is locked
218 throw scsi_exception(sense_key::illegal_request, asc::load_or_eject_failed);
219 }
220
221 // Eject
222 if (!Eject(false)) {
223 throw scsi_exception(sense_key::illegal_request, asc::load_or_eject_failed);
224 }
225 }
226 else {
227 FlushCache();
228 }
229 }
230
231 EnterStatusPhase();
232}
233
234
235

Callers

nothing calls this directly

Calls 2

scsi_exceptionClass · 0.85
GetCmdByteMethod · 0.80

Tested by

no test coverage detected