RASCSI/src/raspberrypi/controllers/scsidev_ctrl.h
Uwe Seimet 1df7cdb1f3
Use vector for INQUIRY data, LUN list can have gaps, made methods const (#713)
* Use vector for INQUIRY data, Inquiry() is const, moved EVPD check

* Moved code

* Fixed warning

* Updated memcpy

* Set length

* Limit result vector size

* Limit result buffer size

* Inquiry() result buffer handling update

* Logging update

* Inquiry cleanup

* NEC drive can also use PrimaryDevice::Inquiry()

* NEC drive is never removable

* Comment update

* Bridge can also use PrimaryDevice::Inquiry()

* Removed unused method argument

* Comment update

* Updated comment

* Updated REQUEST SENSE buffer handling

* Fixed typo

* Fixed typo

* Re-added comment

* Updated additional length handling

* Check for INQUIRY command support first

* Added assertion

* Size handling update

* Renaming

* Renaming

* Removed obsolete casts

* Cleanup

* Moved error codes to scsi_defs namespace

* Fixed ReadDefectData10

* Comment update

* Updated buffer handling

* Data type update

* SendDiagnostic is now const

* Removed obsolete forward declaration

* removed unused enum

* Reduced method visibility

* Renaming

* GetSendDelay() can be const

* Made method const

* Made method const

* Added TODO

* Use iterator

* Made method const

* Revert "Made method const"

This reverts commit 38412b8ddd.

* No need to sort all set/maps

* Do not sort all sets

* Removed more unnecessary sorting

* Cleaned up includes

* More include cleanups

* Updated REPORT LUNS

* LUNs must not be consecutive anymore

* Updated detaching of LUN

* Improvements for devices without LUN 0

* Assume LUN 0 is always present

* Enforce presence of LUN 0

* Updated error handling
2022-03-01 20:25:22 -06:00

100 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI (*^..^*)
// for Raspberry Pi
//
// Copyright (C) 2001-2006 (ytanaka@ipc-tokai.or.jp)
// Copyright (C) 2014-2020 GIMONS
// Copyright (C) akuker
//
// Licensed under the BSD 3-Clause License.
// See LICENSE file in the project root folder.
//
// [ SCSI device controller ]
//
//---------------------------------------------------------------------------
#pragma once
#include "controllers/sasidev_ctrl.h"
//===========================================================================
//
// SCSI Device (Interits SASI device)
//
//===========================================================================
class SCSIDEV : public SASIDEV
{
public:
enum rascsi_shutdown_mode {
NONE,
STOP_RASCSI,
STOP_PI,
RESTART_PI
};
// Internal data definition
typedef struct {
// Synchronous transfer
BOOL syncenable; // Synchronous transfer possible
int syncperiod; // Synchronous transfer period
int syncoffset; // Synchronous transfer offset
int syncack; // Number of synchronous transfer ACKs
// ATN message
bool atnmsg;
int msc;
BYTE msb[256];
// -1 means that the initiator ID is unknown, e.g. with Atari ACSI and old host adapters
int initiator_id;
bool is_byte_transfer;
uint32_t bytes_to_transfer;
} scsi_t;
SCSIDEV();
~SCSIDEV();
void Reset() override;
BUS::phase_t Process(int) override;
void Receive() override;
bool IsSASI() const override { return false; }
bool IsSCSI() const override { return true; }
// Common error handling
void Error(scsi_defs::sense_key sense_key = scsi_defs::sense_key::NO_SENSE,
scsi_defs::asc asc = scsi_defs::asc::NO_ADDITIONAL_SENSE_INFORMATION,
scsi_defs::status status = scsi_defs::status::CHECK_CONDITION) override;
void ScheduleShutDown(rascsi_shutdown_mode shutdown_mode) { this->shutdown_mode = shutdown_mode; }
int GetInitiatorId() const { return scsi.initiator_id; }
bool IsByteTransfer() const { return scsi.is_byte_transfer; }
void SetByteTransfer(bool is_byte_transfer) { scsi.is_byte_transfer = is_byte_transfer; }
private:
typedef SASIDEV super;
// Phases
void BusFree() override;
void Selection() override;
void Execute() override;
void MsgOut();
// Data transfer
void Send() override;
bool XferMsg(int);
bool XferOut(bool);
void ReceiveBytes();
// Internal data
scsi_t scsi;
rascsi_shutdown_mode shutdown_mode;
};