mirror of
https://github.com/akuker/RASCSI.git
synced 2026-10-26 04:02:17 +00:00
Restore the SCBR device as an X68000 Host Bridge, including the Human68k-compatible host file-system service and the bridge-specific SCSI message handlers. Back its Ethernet path with the TAP driver, derive a stable locally administered MAC address, preserve the driver minimum-frame/FCS expectations, and restrict received traffic to its own unicast frames and broadcasts. Match the RASCTL/RASETHER/RASDRV bridge protocol that originated in the parent RaSCSI project: dispatch its non-standard message format on READ(10)/WRITE(10) (0x28/0x2a), with type, function, phase, and a three-byte byte count carried in the CDB. Advertise the legacy control channel required by RASCTL, translate its list and device-management commands to PiSCSI operations, and defer stop or system-shutdown requests until after the response is sent, while gating this insecure interface behind a new '-c disabled|media|full' runtime option. Preserve the type-1 Ethernet exchange used by RASETHER and the type-2, phased filesystem exchange used by RASDRV. Register the device in the factory, protobuf API, controller transfer path, command-line tooling, device listings, and web UI. Share the explicit bridge and proxy-ARP topology workflow with DaynaPort so both adapters validate and use the same mode/interface pair. Add build support for iconv where needed, extend unit coverage for device creation, RAS* protocol handling, CLI parsing, web attachment, and topology selection, and update the man pages and network-profile documentation for Host Bridge operation and its networking limits.
122 lines
3.0 KiB
C++
122 lines
3.0 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021-2023 Uwe Seimet
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include "shared/piscsi_util.h"
|
|
#include "scsihd.h"
|
|
#include "scsihd_nec.h"
|
|
#include "sasi_hd.h"
|
|
#include "scsimo.h"
|
|
#include "scsicd.h"
|
|
#include "scsi_printer.h"
|
|
#include "scsi_host_bridge.h"
|
|
#include "scsi_daynaport.h"
|
|
#include "host_services.h"
|
|
#include "device_factory.h"
|
|
#include "scsi_streamer.h"
|
|
|
|
using namespace std;
|
|
using namespace piscsi_util;
|
|
|
|
PbDeviceType DeviceFactory::GetTypeForFile(const string& filename) const
|
|
{
|
|
if (const auto& it = EXTENSION_MAPPING.find(GetExtensionLowerCase(filename)); it != EXTENSION_MAPPING.end()) {
|
|
return it->second;
|
|
}
|
|
|
|
if (const auto& it = DEVICE_MAPPING.find(filename); it != DEVICE_MAPPING.end()) {
|
|
return it->second;
|
|
}
|
|
|
|
return UNDEFINED;
|
|
}
|
|
|
|
shared_ptr<PrimaryDevice> DeviceFactory::CreateDevice(PbDeviceType type, int lun, const string& filename) const
|
|
{
|
|
// If no type was specified try to derive the device type from the filename
|
|
if (type == UNDEFINED) {
|
|
type = GetTypeForFile(filename);
|
|
if (type == UNDEFINED) {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
shared_ptr<PrimaryDevice> device;
|
|
switch (type) {
|
|
case SAHD:
|
|
device = make_shared<SasiHd>(lun);
|
|
break;
|
|
|
|
case SCHD: {
|
|
if (const string ext = GetExtensionLowerCase(filename); ext == "hdn" || ext == "hdi" || ext == "nhd") {
|
|
device = make_shared<SCSIHD_NEC>(lun);
|
|
} else {
|
|
device = make_shared<SCSIHD>(lun, false, ext == "hd1" ? scsi_level::scsi_1_ccs : scsi_level::scsi_2);
|
|
|
|
// Some Apple tools require a particular drive identification
|
|
if (ext == "hda") {
|
|
device->SetVendor("QUANTUM");
|
|
device->SetProduct("FIREBALL");
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case SCRM:
|
|
device = make_shared<SCSIHD>(lun, true, scsi_level::scsi_2);
|
|
device->SetProduct("SCSI HD (REM.)");
|
|
break;
|
|
|
|
case SCMO:
|
|
device = make_shared<SCSIMO>(lun);
|
|
device->SetProduct("SCSI MO");
|
|
break;
|
|
|
|
case SCCD:
|
|
device = make_shared<SCSICD>(lun,
|
|
GetExtensionLowerCase(filename) == "is1" ? scsi_level::scsi_1_ccs : scsi_level::scsi_2);
|
|
device->SetProduct("SCSI CD-ROM");
|
|
break;
|
|
|
|
case SCBR:
|
|
device = make_shared<SCSIBR>(lun);
|
|
device->SetProduct("RASCSI BRIDGE");
|
|
break;
|
|
|
|
case SCDP:
|
|
device = make_shared<SCSIDaynaPort>(lun);
|
|
// Since this is an emulation for a specific device the full INQUIRY data have to be set accordingly
|
|
device->SetVendor("Dayna");
|
|
device->SetProduct("SCSI/Link");
|
|
device->SetRevision("1.4a");
|
|
break;
|
|
|
|
case SCHS:
|
|
device = make_shared<HostServices>(lun);
|
|
// Since this is an emulation for a specific device the full INQUIRY data have to be set accordingly
|
|
device->SetVendor("PiSCSI");
|
|
device->SetProduct("Host Services");
|
|
break;
|
|
|
|
case SCLP:
|
|
device = make_shared<SCSIPrinter>(lun);
|
|
device->SetProduct("SCSI PRINTER");
|
|
break;
|
|
|
|
case SCTP:
|
|
device = make_shared<SCSIST>(lun);
|
|
device->SetProduct("SCSI TAPE");
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return device;
|
|
}
|