mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 01:31:42 +00:00
Factors out command termination, adds a default implementation of test unit ready.
This commit is contained in:
parent
a4ab0afce3
commit
cbd1a8cf78
@ -19,11 +19,7 @@ bool DirectAccessDevice::read(const Target::CommandState &state, Target::Respond
|
||||
if(!device_) return false;
|
||||
|
||||
responder.send_data(device_->get_block(state.address()), [] (const Target::CommandState &state, Target::Responder &responder) {
|
||||
responder.send_message(Target::Responder::Message::CommandComplete, [] (const Target::CommandState &state, Target::Responder &responder) {
|
||||
responder.send_status(Target::Responder::Status::Good, [] (const Target::CommandState &state, Target::Responder &responder) {
|
||||
responder.end_command();
|
||||
});
|
||||
});
|
||||
responder.terminate_command(Target::Responder::Status::Good);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -79,6 +79,16 @@ struct Responder {
|
||||
Ends the SCSI command.
|
||||
*/
|
||||
virtual void end_command() = 0;
|
||||
/*!
|
||||
Terminates a SCSI command, sending the proper sequence of status and message phases.
|
||||
*/
|
||||
void terminate_command(Status status) {
|
||||
send_message(Target::Responder::Message::CommandComplete, [status] (const Target::CommandState &state, Target::Responder &responder) {
|
||||
responder.send_status(status, [] (const Target::CommandState &state, Target::Responder &responder) {
|
||||
responder.end_command();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -92,7 +102,11 @@ struct Responder {
|
||||
*/
|
||||
struct Executor {
|
||||
/* Group 0 commands. */
|
||||
bool test_unit_ready(const CommandState &, Responder &) { return false; }
|
||||
bool test_unit_ready(const CommandState &, Responder &responder) {
|
||||
/* "Returns zero status if addressed unit is powered on and ready. */
|
||||
responder.terminate_command(Target::Responder::Status::Good);
|
||||
return true;
|
||||
}
|
||||
bool rezero_unit(const CommandState &, Responder &) { return false; }
|
||||
bool request_sense(const CommandState &, Responder &) { return false; }
|
||||
bool format_unit(const CommandState &, Responder &) { return false; }
|
||||
|
Loading…
Reference in New Issue
Block a user