Skip to content

Commit

Permalink
Merge SASI controller into SCSI controller
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Mar 4, 2024
1 parent 5d20e8d commit 646e6ea
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
//---------------------------------------------------------------------------

#include "base/primary_device.h"
#include "scsi_controller.h"
#include "controller.h"

void ScsiController::Reset()
void Controller::Reset()
{
GenericController::Reset();

Expand All @@ -20,7 +20,7 @@ void ScsiController::Reset()
atn_msg = false;
}

void ScsiController::BusFree()
void Controller::BusFree()
{
if (!IsBusFree()) {
identified_lun = -1;
Expand All @@ -31,7 +31,7 @@ void ScsiController::BusFree()
GenericController::BusFree();
}

void ScsiController::MsgOut()
void Controller::MsgOut()
{
if (!IsMsgOut()) {
LogTrace("MESSAGE OUT phase");
Expand All @@ -58,7 +58,7 @@ void ScsiController::MsgOut()
Receive();
}

void ScsiController::XferMsg(uint8_t msg)
void Controller::XferMsg(uint8_t msg)
{
assert(IsMsgOut());

Expand All @@ -67,7 +67,7 @@ void ScsiController::XferMsg(uint8_t msg)
}
}

void ScsiController::ParseMessage()
void Controller::ParseMessage()
{
for (const uint8_t message : msg_bytes) {
switch (message) {
Expand Down Expand Up @@ -106,7 +106,7 @@ void ScsiController::ParseMessage()
}
}

void ScsiController::ProcessMessage()
void Controller::ProcessMessage()
{
// MESSAGE OUT phase as long as ATN is asserted
if (GetBus().GetATN()) {
Expand All @@ -124,7 +124,7 @@ void ScsiController::ProcessMessage()
Command();
}

void ScsiController::ProcessExtendedMessage()
void Controller::ProcessExtendedMessage()
{
// Completed sending response to extended message of IDENTIFY message
if (atn_msg) {
Expand All @@ -135,7 +135,7 @@ void ScsiController::ProcessExtendedMessage()
}
}

int ScsiController::GetEffectiveLun() const
int Controller::GetEffectiveLun() const
{
// Return LUN from IDENTIFY message, or return the LUN from the CDB as fallback
return identified_lun != -1 ? identified_lun : GetLun();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

using namespace std;

class ScsiController : public GenericController
class Controller : public GenericController
{

public:

using GenericController::GenericController;
~ScsiController() override = default;
~Controller() override = default;

void Reset() override;

Expand Down
13 changes: 3 additions & 10 deletions cpp/controllers/controller_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
//
//---------------------------------------------------------------------------

#include "scsi_controller.h"
#include "sasi_controller.h"
#include "controller.h"
#include "controller_factory.h"

using namespace std;

shared_ptr<AbstractController> ControllerFactory::CreateController(Bus &bus, int id) const
{
shared_ptr<AbstractController> controller;
if (is_sasi) {
controller = make_shared<SasiController>(bus, id, GetSasiLunMax());
}
else {
controller = make_shared<ScsiController>(bus, id, GetScsiLunMax());
}

shared_ptr<AbstractController> controller = make_shared<Controller>(bus, id,
is_sasi ? GetSasiLunMax() : GetScsiLunMax());
controller->Init();

return controller;
Expand Down
40 changes: 0 additions & 40 deletions cpp/controllers/sasi_controller.cpp

This file was deleted.

32 changes: 0 additions & 32 deletions cpp/controllers/sasi_controller.h

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/devices/host_services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#include <google/protobuf/text_format.h>
#include "shared/shared_exceptions.h"
#include "protobuf/protobuf_util.h"
#include "controllers/scsi_controller.h"
#include "controllers/controller.h"
#include "base/memory_util.h"
#include "host_services.h"

Expand Down
10 changes: 5 additions & 5 deletions cpp/test/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <gmock/gmock.h>
#include "command/command_executor.h"
#include "buses/in_process_bus.h"
#include "controllers/scsi_controller.h"
#include "controllers/controller.h"
#include "devices/sasi_hd.h"
#include "devices/scsi_hd.h"
#include "devices/scsi_cd.h"
Expand Down Expand Up @@ -187,7 +187,7 @@ class MockAbstractController : public AbstractController // NOSONAR Having many
~MockAbstractController() override = default;
};

class MockScsiController : public ScsiController
class MockScsiController : public Controller
{
FRIEND_TEST(ScsiControllerTest, Process);
FRIEND_TEST(ScsiControllerTest, BusFree);
Expand All @@ -207,11 +207,11 @@ class MockScsiController : public ScsiController
MOCK_METHOD(void, Status, (), (override));
MOCK_METHOD(void, Execute, (), ());

using ScsiController::ScsiController;
MockScsiController(shared_ptr<Bus> bus, int target_id) : ScsiController(*bus, target_id, 32)
using Controller::Controller;
MockScsiController(shared_ptr<Bus> bus, int target_id) : Controller(*bus, target_id, 32)
{
}
explicit MockScsiController(shared_ptr<Bus> bus) : ScsiController(*bus, 0, 32)
explicit MockScsiController(shared_ptr<Bus> bus) : Controller(*bus, 0, 32)
{
}
~MockScsiController() override = default;
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/scsi_controller_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST(ScsiControllerTest, Reset)
const int ID = 5;

NiceMock<MockBus> bus;
auto controller = make_shared<ScsiController>(bus, ID, 32);
auto controller = make_shared<Controller>(bus, ID, 32);
auto device = make_shared<MockPrimaryDevice>(0);

controller->Init();
Expand Down

0 comments on commit 646e6ea

Please sign in to comment.