mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-10 17:29:35 +00:00
5622694701
* Initial RTC skeleton * Added device info * Added TEST UNIT READY * Fixed command dispatcher * First untested naive implementation * Comment update * Code cleanup * More code cleanup * Updated date/time encoding * Updated versioning * Use standard RaSCSI INQUIRY version for SCRT device * Manpage update * Added shortcut for SCRT type * Added support for rtc "filename" * RTC supports LUNs > 0 * Fixed LUN count * Renaming * Renaming * Manpage update * Initial naive implementation * SCRA is removable * Updated command list * Added controller field * Shut down works, bus free phase is not yet entered * Clear caches on shutdown * Expose BusFree() * Moved code * Logging update * Moved code * Moved code * Added comment * Logging update * Code cleanup * Service device is not removable anymore (was only needed for testing) * Manpage update * Added comment * Comment update * Version update * Renaming * Comment update * Comment update * Renaming * Fixed typo * Added convenience method * Property handling optimization * Code cleanup * Code cleanup * Code cleanup, introduced base class * Added TODO * More code cleanup * Removed unnecessary assignments * Moved code * Removed forward declaration * Added base class * INclude cleanup * Moved scsi_command enum * Fixed warnings * Addressing circular dependencies * Removed duplicate enum * include file cleanup * Include cleanup * Reduced dependencies to Disk class (replaced by Device), fixed TODO * Include cleanup * PrimaryDevice implements ReportLuns * Inheritance update * Removed duplicate code * Moved code to base class * Cleanup * Removed duplicate field * Updated command dispatchign * Comment update * Moved code * Updated method visibilities * Moved MODE SENSE/MODE SELECT base code
117 lines
4.3 KiB
C++
117 lines
4.3 KiB
C++
//---------------------------------------------------------------------------
|
||
//
|
||
// SCSI Target Emulator RaSCSI (*^..^*)
|
||
// for Raspberry Pi
|
||
//
|
||
// Copyright (C) 2001-2006 PI.(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
|
||
{
|
||
|
||
private:
|
||
typedef struct _command_t {
|
||
const char* name;
|
||
void (SCSIBR::*execute)(SASIDEV *);
|
||
|
||
_command_t(const char* _name, void (SCSIBR::*_execute)(SASIDEV *)) : name(_name), execute(_execute) { };
|
||
} command_t;
|
||
std::map<ScsiDefs::scsi_command, command_t*> commands;
|
||
|
||
SASIDEV::ctrl_t *ctrl;
|
||
|
||
void AddCommand(ScsiDefs::scsi_command, const char*, void (SCSIBR::*)(SASIDEV *));
|
||
|
||
public:
|
||
SCSIBR();
|
||
~SCSIBR();
|
||
|
||
bool Init(const map<string, string>&) override;
|
||
bool Dispatch(SCSIDEV *) override;
|
||
|
||
// Commands
|
||
int Inquiry(const DWORD *cdb, BYTE *buf) override; // INQUIRY command
|
||
int GetMessage10(const DWORD *cdb, BYTE *buf); // GET MESSAGE10 command
|
||
bool SendMessage10(const DWORD *cdb, BYTE *buf); // SEND MESSAGE10 command
|
||
void TestUnitReady(SASIDEV *) override;
|
||
void GetMessage10(SASIDEV *);
|
||
void SendMessage10(SASIDEV *);
|
||
|
||
private:
|
||
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
|
||
};
|