Files
RASCSI/cpp/controllers/controller_manager.h
T
Daniel Markstedt e57893893c restore support for SASI disk drive device
Introduce a SASI controller and SAHD disk implementation alongside the existing SCSI path. Select the appropriate controller when attaching a device, prevent SASI and SCSI devices from sharing a target ID, and implement SASI-specific selection, message, status, timing, and LUN handling.

Restore SAHD in the protocol and expose it consistently through the device factory, command-line client, configuration validation, web interface, drive profiles, and manual. Enforce the two-LUN limit for SASI targets wherever device definitions are created or parsed.

Bring back handling of the hdf image format and map it to the SAHD device type. The hdf file ending is the established one for SASI raw disk images used in the X68000 emulation community, however it is a raw data format without any special header.

Add focused C++ and Go coverage for SASI devices, controller selection, LUN validation, and web-facing behavior.
2026-08-30 08:27:35 +02:00

58 lines
1.7 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator PiSCSI
// for Raspberry Pi
//
// Copyright (C) 2022-2023 Uwe Seimet
//
// Keeps track of and manages the controllers
//
//---------------------------------------------------------------------------
#pragma once
#include "generated/piscsi_interface.pb.h"
#include "hal/bus.h"
#include "controllers/abstract_controller.h"
#include <unordered_map>
#include <unordered_set>
#include <memory>
using namespace std;
class ScsiController;
class SasiController;
class PrimaryDevice;
class ControllerManager
{
public:
ControllerManager() = default;
~ControllerManager() = default;
bool AttachToController(BUS&, int, shared_ptr<PrimaryDevice>);
bool DeleteController(const AbstractController&);
void DeleteAllControllers();
AbstractController::piscsi_shutdown_mode ProcessOnController(int) const;
shared_ptr<AbstractController> FindController(int) const;
bool HasController(int) const;
unordered_set<shared_ptr<PrimaryDevice>> GetAllDevices() const;
bool HasDeviceForIdAndLun(int, int) const;
shared_ptr<PrimaryDevice> GetDeviceForIdAndLun(int, int) const;
static int GetScsiIdMax() { return 8; }
static int GetScsiLunMax() { return 32; }
static int GetSasiLunMax() { return 2; }
static int GetLunMax(piscsi_interface::PbDeviceType type)
{ return type == piscsi_interface::SAHD ? GetSasiLunMax() : GetScsiLunMax(); }
private:
shared_ptr<ScsiController> CreateScsiController(BUS&, int) const;
shared_ptr<SasiController> CreateSasiController(BUS&, int) const;
// Controllers mapped to their device IDs
unordered_map<int, shared_ptr<AbstractController>> controllers;
};