RASCSI/src/raspberrypi/devices/scsi_host_bridge.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

108 lines
3.9 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 Host Bridge for the Sharp X68000 ]
//
// Note: This requires a special driver on the host system and will only
// work with the Sharp X68000 operating system.
//---------------------------------------------------------------------------
#pragma once
#include "os.h"
#include "disk.h"
#include <string>
//===========================================================================
//
// SCSI Host Bridge
//
//===========================================================================
class CTapDriver;
class CFileSys;
class SCSIBR : public Disk
{
public:
SCSIBR();
~SCSIBR();
bool Init(const unordered_map<string, string>&) override;
bool Dispatch(SCSIDEV *) override;
// Commands
vector<BYTE> Inquiry() const override;
int GetMessage10(const DWORD *cdb, BYTE *buf);
bool SendMessage10(const DWORD *cdb, BYTE *buf);
void TestUnitReady(SASIDEV *) override;
void GetMessage10(SASIDEV *);
void SendMessage10(SASIDEV *);
private:
typedef Disk super;
Dispatcher<SCSIBR, SASIDEV> dispatcher;
int GetMacAddr(BYTE *buf); // Get MAC address
void SetMacAddr(BYTE *buf); // Set MAC address
void ReceivePacket(); // Receive a packet
void GetPacketBuf(BYTE *buf); // Get a packet
void SendPacket(BYTE *buf, int len); // Send a packet
CTapDriver *tap; // TAP driver
bool m_bTapEnable; // TAP valid flag
BYTE mac_addr[6]; // MAC Addres
int packet_len; // Receive packet size
BYTE packet_buf[0x1000]; // Receive packet buffer
bool packet_enable; // Received packet valid
int ReadFsResult(BYTE *buf); // Read filesystem (result code)
int ReadFsOut(BYTE *buf); // Read filesystem (return data)
int ReadFsOpt(BYTE *buf); // Read file system (optional data)
void WriteFs(int func, BYTE *buf); // File system write (execute)
void WriteFsOpt(BYTE *buf, int len); // File system write (optional data)
// Command handlers
void FS_InitDevice(BYTE *buf); // $40 - boot
void FS_CheckDir(BYTE *buf); // $41 - directory check
void FS_MakeDir(BYTE *buf); // $42 - create directory
void FS_RemoveDir(BYTE *buf); // $43 - delete directory
void FS_Rename(BYTE *buf); // $44 - change filename
void FS_Delete(BYTE *buf); // $45 - delete file
void FS_Attribute(BYTE *buf); // $46 - get/set file attributes
void FS_Files(BYTE *buf); // $47 - file search
void FS_NFiles(BYTE *buf); // $48 - find next file
void FS_Create(BYTE *buf); // $49 - create file
void FS_Open(BYTE *buf); // $4A - open file
void FS_Close(BYTE *buf); // $4B - close file
void FS_Read(BYTE *buf); // $4C - read file
void FS_Write(BYTE *buf); // $4D - write file
void FS_Seek(BYTE *buf); // $4E - seek file
void FS_TimeStamp(BYTE *buf); // $4F - get/set file time
void FS_GetCapacity(BYTE *buf); // $50 - get capacity
void FS_CtrlDrive(BYTE *buf); // $51 - drive status check/control
void FS_GetDPB(BYTE *buf); // $52 - get DPB
void FS_DiskRead(BYTE *buf); // $53 - read sector
void FS_DiskWrite(BYTE *buf); // $54 - write sector
void FS_Ioctrl(BYTE *buf); // $55 - IOCTRL
void FS_Flush(BYTE *buf); // $56 - flush cache
void FS_CheckMedia(BYTE *buf); // $57 - check media
void FS_Lock(BYTE *buf); // $58 - get exclusive control
CFileSys *fs; // File system accessor
DWORD fsresult; // File system access result code
BYTE fsout[0x800]; // File system access result buffer
DWORD fsoutlen; // File system access result buffer size
BYTE fsopt[0x1000000]; // File system access buffer
DWORD fsoptlen; // File system access buffer size
};