RASCSI/cpp/hal/gpiobus.cpp

1092 lines
36 KiB
C++
Raw Normal View History

2018-05-03 13:47:57 +00:00
//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI Reloaded
2018-05-03 13:47:57 +00:00
// for Raspberry Pi
//
// Powered by XM6 TypeG Technology.
// Copyright (C) 2016-2020 GIMONS
2018-05-03 13:47:57 +00:00
//
// [ GPIO-SCSI bus ]
2018-05-03 13:47:57 +00:00
//
//---------------------------------------------------------------------------
#include "hal/gpiobus.h"
#include "config.h"
#include "hal/sbc_version.h"
#include "hal/systimer.h"
#include "log.h"
#include <array>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
#ifdef __linux__
#include <sys/epoll.h>
#endif
2018-05-03 13:47:57 +00:00
2022-10-28 02:32:23 +00:00
// #if defined CONNECT_TYPE_STANDARD
// #include "hal/gpiobus_standard.h"
// #elif defined CONNECT_TYPE_FULLSPEC
// #include "hal/gpiobus_fullspec.h"
// #elif defined CONNECT_TYPE_AIBOM
// #include "hal/gpiobus_aibom.h"
// #elif defined CONNECT_TYPE_GAMERNIUM
// #include "hal/gpiobus_gamernium.h"
// #else
// #error Invalid connection type or none specified
// #endif
2018-05-03 13:47:57 +00:00
//---------------------------------------------------------------------------
//
// Constant declarations (bus control timing)
//
//---------------------------------------------------------------------------
// SCSI Bus timings taken from:
// https://www.staff.uni-mainz.de/tacke/scsi/SCSI2-05.html
[[maybe_unused]] const static int SCSI_DELAY_ARBITRATION_DELAY_NS = 2400;
[[maybe_unused]] const static int SCSI_DELAY_ASSERTION_PERIOD_NS = 90;
[[maybe_unused]] const static int SCSI_DELAY_BUS_CLEAR_DELAY_NS = 800;
[[maybe_unused]] const static int SCSI_DELAY_BUS_FREE_DELAY_NS = 800;
[[maybe_unused]] const static int SCSI_DELAY_BUS_SET_DELAY_NS = 1800;
[[maybe_unused]] const static int SCSI_DELAY_BUS_SETTLE_DELAY_NS = 400;
[[maybe_unused]] const static int SCSI_DELAY_CABLE_SKEW_DELAY_NS = 10;
[[maybe_unused]] const static int SCSI_DELAY_DATA_RELEASE_DELAY_NS = 400;
[[maybe_unused]] const static int SCSI_DELAY_DESKEW_DELAY_NS = 45;
[[maybe_unused]] const static int SCSI_DELAY_DISCONNECTION_DELAY_US = 200;
[[maybe_unused]] const static int SCSI_DELAY_HOLD_TIME_NS = 45;
[[maybe_unused]] const static int SCSI_DELAY_NEGATION_PERIOD_NS = 90;
[[maybe_unused]] const static int SCSI_DELAY_POWER_ON_TO_SELECTION_TIME_S = 10; // (recommended)
[[maybe_unused]] const static int SCSI_DELAY_RESET_TO_SELECTION_TIME_US = 250 * 1000; // (recommended)
[[maybe_unused]] const static int SCSI_DELAY_RESET_HOLD_TIME_US = 25;
[[maybe_unused]] const static int SCSI_DELAY_SELECTION_ABORT_TIME_US = 200;
[[maybe_unused]] const static int SCSI_DELAY_SELECTION_TIMEOUT_DELAY_NS = 250 * 1000; // (recommended)
[[maybe_unused]] const static int SCSI_DELAY_FAST_ASSERTION_PERIOD_NS = 30;
[[maybe_unused]] const static int SCSI_DELAY_FAST_CABLE_SKEW_DELAY_NS = 5;
[[maybe_unused]] const static int SCSI_DELAY_FAST_DESKEW_DELAY_NS = 20;
[[maybe_unused]] const static int SCSI_DELAY_FAST_HOLD_TIME_NS = 10;
[[maybe_unused]] const static int SCSI_DELAY_FAST_NEGATION_PERIOD_NS = 30;
// The DaynaPort SCSI Link do a short delay in the middle of transfering
// a packet. This is the number of uS that will be delayed between the
// header and the actual data.
const static int SCSI_DELAY_SEND_DATA_DAYNAPORT_US = 100;
2018-05-03 13:47:57 +00:00
using namespace std;
2018-05-03 13:47:57 +00:00
// Nothing SBC hardware specific should be done in this function
bool GPIOBUS::Init(mode_e mode, board_type::rascsi_board_type_e rascsi_type)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
// Figure out what type of board is connected.
2022-11-06 01:34:09 +00:00
board = board_type::BoardType::GetRascsiBoardSettings(rascsi_type);
LOGINFO("Connection type: %s", board->connect_desc.c_str());
// Save operation mode
actmode = mode;
2022-10-29 02:13:07 +00:00
SignalTable.push_back(board->pin_dt0);
SignalTable.push_back(board->pin_dt1);
SignalTable.push_back(board->pin_dt2);
SignalTable.push_back(board->pin_dt3);
SignalTable.push_back(board->pin_dt4);
SignalTable.push_back(board->pin_dt5);
SignalTable.push_back(board->pin_dt6);
SignalTable.push_back(board->pin_dt7);
SignalTable.push_back(board->pin_dp);
SignalTable.push_back(board->pin_sel);
SignalTable.push_back(board->pin_atn);
SignalTable.push_back(board->pin_rst);
SignalTable.push_back(board->pin_ack);
SignalTable.push_back(board->pin_bsy);
SignalTable.push_back(board->pin_msg);
SignalTable.push_back(board->pin_cd);
SignalTable.push_back(board->pin_io);
SignalTable.push_back(board->pin_req);
return true;
2018-05-03 13:47:57 +00:00
}
2022-10-30 01:57:59 +00:00
// The GPIO hardware needs to be initialized before calling this function.
void GPIOBUS::InitializeGpio()
{
// Set pull up/pull down
2022-10-30 01:57:59 +00:00
LOGTRACE("%s Set pull up/down....", __PRETTY_FUNCTION__);
board_type::gpio_pull_up_down_e pullmode;
if (board->signal_control_mode == 0) {
2022-10-30 01:57:59 +00:00
// #if SIGNAL_CONTROL_MODE == 0
LOGTRACE("%s GPIO_PULLNONE", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e::GPIO_PULLNONE;
} else if (board->signal_control_mode == 1) {
2022-10-30 01:57:59 +00:00
// #elif SIGNAL_CONTROL_MODE == 1
LOGTRACE("%s GPIO_PULLUP", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLUP;
} else {
2022-10-30 01:57:59 +00:00
// #else
LOGTRACE("%s GPIO_PULLDOWN", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLDOWN;
}
// #endif
// Initialize all signals
LOGTRACE("%s Initialize all signals....", __PRETTY_FUNCTION__);
2022-11-06 01:34:09 +00:00
for (auto cur_signal : SignalTable) {
2022-10-31 20:19:59 +00:00
PinSetSignal(cur_signal, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(cur_signal, board_type::gpio_direction_e::GPIO_INPUT);
PullConfig(cur_signal, pullmode);
2022-10-30 01:57:59 +00:00
}
// Set control signals
LOGTRACE("%s Set control signals....", __PRETTY_FUNCTION__);
PinSetSignal(board->pin_act, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_tad, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_ind, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_dtd, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(board->pin_act, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_tad, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_ind, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_dtd, board_type::gpio_direction_e::GPIO_OUTPUT);
// Set the ENABLE signal
// This is used to show that the application is running
PinConfig(board->pin_enb, board_type::gpio_direction_e::GPIO_OUTPUT);
2022-11-09 20:10:43 +00:00
PinSetSignal(board->pin_enb, board->EnbOn());
2022-10-30 01:57:59 +00:00
}
void GPIOBUS::Cleanup()
2018-05-03 13:47:57 +00:00
{
#if defined(__x86_64__) || defined(__X86__)
return;
#else
// Release SEL signal interrupt
#ifdef USE_SEL_EVENT_ENABLE
close(selevreq.fd);
#endif // USE_SEL_EVENT_ENABLE
// Set control signals
2022-10-28 02:10:36 +00:00
PinSetSignal(board->pin_enb, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_act, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_tad, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_ind, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_dtd, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(board->pin_act, board_type::gpio_direction_e::GPIO_INPUT);
PinConfig(board->pin_tad, board_type::gpio_direction_e::GPIO_INPUT);
PinConfig(board->pin_ind, board_type::gpio_direction_e::GPIO_INPUT);
PinConfig(board->pin_dtd, board_type::gpio_direction_e::GPIO_INPUT);
// Initialize all signals
2022-10-29 02:13:07 +00:00
for (board_type::pi_physical_pin_e pin : SignalTable) {
if (pin != board_type::pi_physical_pin_e::PI_PHYS_PIN_NONE) {
PinSetSignal(pin, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(pin, board_type::gpio_direction_e::GPIO_INPUT);
PullConfig(pin, board_type::gpio_pull_up_down_e::GPIO_PULLNONE);
}
}
// Set drive strength back to 8mA
DrvConfig(3);
#endif // ifdef __x86_64__ || __X86__
2018-05-03 13:47:57 +00:00
}
void GPIOBUS::Reset()
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
#if defined(__x86_64__) || defined(__X86__)
return;
#else
// Turn off active signal
2022-10-28 02:10:36 +00:00
SetControl(board->pin_act, board->ActOff());
2022-10-29 02:13:07 +00:00
for (board_type::pi_physical_pin_e pin : SignalTable) {
if (pin != board_type::pi_physical_pin_e::PI_PHYS_PIN_NONE) {
SetSignal(pin, board_type::gpio_high_low_e::GPIO_STATE_LOW);
}
}
if (actmode == mode_e::TARGET) {
// Target mode
// Set target signal to input
2022-10-28 02:10:36 +00:00
SetControl(board->pin_tad, board->TadIn());
SetMode(board->pin_bsy, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_msg, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_cd, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_req, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_io, board_type::gpio_direction_e::GPIO_INPUT);
// Set the initiator signal to input
2022-10-28 02:10:36 +00:00
SetControl(board->pin_ind, board->IndIn());
SetMode(board->pin_sel, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_atn, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_ack, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_rst, board_type::gpio_direction_e::GPIO_INPUT);
// Set data bus signals to input
2022-10-28 02:10:36 +00:00
SetControl(board->pin_dtd, board->DtdIn());
SetMode(board->pin_dt0, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt1, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt2, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt3, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt4, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt5, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt6, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt7, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dp, board_type::gpio_direction_e::GPIO_INPUT);
} else {
// Initiator mode
// Set target signal to input
2022-10-28 02:10:36 +00:00
SetControl(board->pin_tad, board->TadIn());
SetMode(board->pin_bsy, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_msg, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_cd, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_req, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_io, board_type::gpio_direction_e::GPIO_INPUT);
// Set the initiator signal to output
2022-10-28 02:10:36 +00:00
SetControl(board->pin_ind, board->IndOut());
SetMode(board->pin_sel, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_atn, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_ack, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_rst, board_type::gpio_direction_e::GPIO_OUTPUT);
// Set the data bus signals to output
2022-10-28 02:10:36 +00:00
SetControl(board->pin_dtd, board->DtdOut());
SetMode(board->pin_dt0, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt1, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt2, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt3, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt4, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt5, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt6, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt7, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dp, board_type::gpio_direction_e::GPIO_OUTPUT);
}
// Re-read all signals
Acquire();
// signals = 0;
#endif // ifdef __x86_64__ || __X86__
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetENB(bool ast)
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
PinSetSignal(board->pin_enb, ast ? board->EnbOn() : board->EnbOff());
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetBSY() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_bsy);
2018-05-03 13:47:57 +00:00
}
Refactoring, device handling extensions, additional settings, improved error handling, 64 bit OS support, fixed issues (#184) * Device type unification, support of removable media * Added support for .hdr extension * Removable flag cleanup * Manpage update * Enriched PbOperation with PbDevice * Added file size to PbImageFile * Added device list support * Set image_file * Make remote interface more robust by ignoring SIGPIPE * Return status only once * Fixed typo * Error handling update * When starting rascsi parse everything before attaching devices * Added dry run mode * Comment update * Updated logging * Added Device base class, Disk class inherits from it * Renaming * Use vectors for controllers and disks, as preparation for using maps * Updated file support handling * Comment update * DaynaPort and Bridge inherit from Device instead of Disk * ProcessCmd() now works with devices instead of disks * Renaming * Added DeviceFactory * Improved factory * Comment update * protected disk_t * Code cleanup, added translations * Device name can be set for rascsi * rasctl can set device name * Manpage update * Manpage update * Formatting update * Check for missing name * Initialize fd * Initialize type * Fixed string length issue * Updated capacity formatting * Fixed typo * Split PbDevice into device and device definition * Added TODO * Renaming * Renaming * Device types can be explicitly specified with -t (no FILE:TYPE syntax anymore) * Fixed compile-time issue * Removed unused Append mode, updated read-only handling * Type handling and manpage update * Cleanup * rasctl parser cleanup * Review * Constructor update * Added .hdr (SCRM) support to web interface, tested web interface * Default folder can be set remotely * Removed deprecated operation * DETACH supports all parameters in order to detach all devices * include cleanup * Logging should not depend on NDEBUG, for RaSCSI it is not peformance-critical * INFO is default log level * Exception renaming * Updated GetPaddedName() * Inheritance update * Added BlockDevice class * Removed unused code * Updated typedefs * Revert "Updated typedefs" This reverts commit 546b46215a4d9b65067a11698e59ab1123cc6d64. * Removed unused code * Fixed warnign * Use standard C++ integer types, use streams to resolve printf data type issues * Added TODOs * Added TODO * Renaming * Added TODO * Added TODO * Improved dry-run * Code cleanup * Updated handling of unknown options, code review and cleanup * Manpage update * Added PrimaryDevice * Include cleanup * Added pure virtual methods * Comment updates * Split rasutil * Replaced some occurrences of BOOL * Removed obsolete RASCSI definition in xm6.h * Removed unused code, updated TODOs, replaced BOOL * Added capacity check (issue #192) * Fixed (most likely) https://github.com/akuker/RASCSI/issues/191 * Fixed wrong error messages * For root the default image folder is /home/pi/images, updated error handling * Dynaport code review * Improved error handling * Implemented READ CAPACITY(16) * Comment update * Commands can be 16 bytes long * Implemented READ/WRITE/VERIFY(16) * Comment update * Renamed method to reflect the name of the respective SCSI command * Do not created devices during dryRun * Fixed padding of SCSIHD_APPLE vendor and product * Initial implementation * Updated ReportLuns * Byte count update * Fixed typo * Finalized REPORT LUNS * Removed TODO * Updated TODO * TODO update * Updated device factory * Comment update * 64 bit update, tested on Ubuntu 64 bit system * Removed assertion * SCSI hard disks always have Apple specific mode pages (resolves issue #193) * Error messsage update, 64 bit cleanup * Reduced streams usage * Updated handling of device flags * MOs are protectable * Removed duplicate error code handling * Removed duplicate code * Fixed CmdReadToc buffer overflow (https://github.com/akuker/RASCSI/issues/194) * Added naive implementation of GET EVENT STATUS NOTIFICATION to avoid wranings * HD must set removable device bit if the media is removable * Removed duplicate logging * Updated daynaport additional length * Removed broken daynaport REQUEST SENSE. Successfully tested with my Mac. * EnableInterface should not always return TRUE * Updated Inquiry * Updated LUN handling * Replaced incorrect free by delete * Updated comments and write-protection handling * Made default HD name consistent * STATUS_NOERROR is default * Fixed Eject * More eject handling updates * Manpage updates * Logging update * Changed debug level * Logging update * Log capacity of all media types * Logging update * Encapsulated disk.blocks * Encapsulated sector size * Added overrides * Added more overrides * Fixed error message * Fixed typos * Fixed logging * Added logging * Use PrimaryDevice when calling Inquiry * Comment update * Changed default buffer size for testing * Reverted last change * Removed debug output * De-inlined methods because optimized code did not work with them inlined * Web interface can attach Daynaport again * Improved handling of read-only hard disks * Fixed issue with "all" semantics of DETACH * rasctl supports adding removable media devices without providing a filename * Removed unused flag in PbDeviceDefinition * Updated rasctl output for ecjected media (resolves issue #199) * Validate default folder name when changing default folder
2021-08-21 21:45:30 +00:00
void GPIOBUS::SetBSY(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
// Set BSY signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_bsy, board->bool_to_gpio_state(ast));
if (actmode == mode_e::TARGET) {
if (ast) {
// Turn on ACTIVE signal
2022-10-28 02:10:36 +00:00
SetControl(board->pin_act, board->act_on);
// Set Target signal to output
2022-10-28 02:10:36 +00:00
SetControl(board->pin_tad, board->TadOut());
2022-10-28 02:10:36 +00:00
SetMode(board->pin_bsy, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_msg, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_cd, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_req, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_io, board_type::gpio_direction_e::GPIO_OUTPUT);
} else {
// Turn off the ACTIVE signal
2022-10-28 02:10:36 +00:00
SetControl(board->pin_act, board->ActOff());
// Set the target signal to input
2022-10-28 02:10:36 +00:00
SetControl(board->pin_tad, board->TadIn());
2022-10-28 02:10:36 +00:00
SetMode(board->pin_bsy, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_msg, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_cd, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_req, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_io, board_type::gpio_direction_e::GPIO_INPUT);
}
}
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetSEL() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_sel);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetSEL(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
if (actmode == mode_e::INITIATOR && ast) {
// Turn on ACTIVE signal
2022-10-28 02:10:36 +00:00
SetControl(board->pin_act, board->act_on);
}
2018-05-03 13:47:57 +00:00
// Set SEL signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_sel, board->bool_to_gpio_state(ast));
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetATN() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_atn);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetATN(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_atn, board->bool_to_gpio_state(ast));
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetACK() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_ack);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetACK(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_ack, board->bool_to_gpio_state(ast));
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetACT() const
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_act);
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetACT(bool ast)
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_act, (ast) ? board->ActOn() : board->ActOff());
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetRST() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_rst);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetRST(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_rst, (ast) ? board->act_on : board->ActOff());
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetMSG() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_msg);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetMSG(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_msg, board->bool_to_gpio_state(ast));
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetCD() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_cd);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetCD(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_cd, board->bool_to_gpio_state(ast));
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetIO()
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
bool ast = GetSignal(board->pin_io);
if (actmode == mode_e::INITIATOR) {
// Change the data input/output direction by IO signal
if (ast) {
2022-10-28 02:10:36 +00:00
SetControl(board->pin_dtd, board->DtdIn());
SetMode(board->pin_dt0, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt1, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt2, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt3, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt4, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt5, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt6, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt7, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dp, board_type::gpio_direction_e::GPIO_INPUT);
} else {
2022-10-28 02:10:36 +00:00
SetControl(board->pin_dtd, board->DtdOut());
SetMode(board->pin_dt0, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt1, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt2, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt3, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt4, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt5, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt6, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt7, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dp, board_type::gpio_direction_e::GPIO_OUTPUT);
}
}
return ast;
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetIO(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_io, board->bool_to_gpio_state(ast));
if (actmode == mode_e::TARGET) {
// Change the data input/output direction by IO signal
if (ast) {
2022-10-28 02:10:36 +00:00
SetControl(board->pin_dtd, board->DtdOut());
SetDAT(0);
2022-10-28 02:10:36 +00:00
SetMode(board->pin_dt0, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt1, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt2, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt3, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt4, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt5, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt6, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dt7, board_type::gpio_direction_e::GPIO_OUTPUT);
SetMode(board->pin_dp, board_type::gpio_direction_e::GPIO_OUTPUT);
} else {
2022-10-28 02:10:36 +00:00
SetControl(board->pin_dtd, board->DtdIn());
SetMode(board->pin_dt0, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt1, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt2, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt3, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt4, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt5, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt6, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dt7, board_type::gpio_direction_e::GPIO_INPUT);
SetMode(board->pin_dp, board_type::gpio_direction_e::GPIO_INPUT);
}
}
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetREQ() const
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_req);
2018-05-03 13:47:57 +00:00
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
void GPIOBUS::SetREQ(bool ast)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board->bool_to_gpio_state(ast));
}
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::GetDP() const
{
GPIO_FUNCTION_TRACE
return GetSignal(board->pin_dp);
}
// Extract as specific pin field from a raw data capture
2022-10-29 02:13:07 +00:00
uint32_t GPIOBUS::GetPinRaw(uint32_t raw_data, board_type::pi_physical_pin_e pin_num)
{
// return GetSignalRaw(raw_data, pin_num);
(void)raw_data;
(void)pin_num;
LOGWARN("THIS FUNCTION ISN'T IMPLEMENTED YET");
return 0;
}
//---------------------------------------------------------------------------
//
// Receive command handshake
//
//---------------------------------------------------------------------------
int GPIOBUS::CommandHandShake(vector<uint8_t>& buf)
{
GPIO_FUNCTION_TRACE
// Only works in TARGET mode
if (actmode != mode_e::TARGET) {
return 0;
}
DisableIRQ();
// Assert REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait for ACK signal
2022-10-28 02:10:36 +00:00
bool ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait until the signal line stabilizes
SysTimer::SleepNsec(SCSI_DELAY_BUS_SETTLE_DELAY_NS);
// Get data
buf[0] = GetDAT();
// Disable REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Timeout waiting for ACK assertion
if (!ret) {
EnableIRQ();
return 0;
}
// Wait for ACK to clear
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Timeout waiting for ACK to clear
if (!ret) {
EnableIRQ();
return 0;
}
// The ICD AdSCSI ST, AdSCSI Plus ST and AdSCSI Micro ST host adapters allow SCSI devices to be connected
// to the ACSI bus of Atari ST/TT computers and some clones. ICD-aware drivers prepend a $1F byte in front
// of the CDB (effectively resulting in a custom SCSI command) in order to get access to the full SCSI
// command set. Native ACSI is limited to the low SCSI command classes with command bytes < $20.
// Most other host adapters (e.g. LINK96/97 and the one by Inventronik) and also several devices (e.g.
// UltraSatan or GigaFile) that can directly be connected to the Atari's ACSI port also support ICD
// semantics. I fact, these semantics have become a standard in the Atari world.
// RaSCSI becomes ICD compatible by ignoring the prepended $1F byte before processing the CDB.
if (buf[0] == 0x1F) {
2022-11-13 17:25:18 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
SysTimer::SleepNsec(SCSI_DELAY_BUS_SETTLE_DELAY_NS);
// Get the actual SCSI command
buf[0] = GetDAT();
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
if (!ret) {
EnableIRQ();
return 0;
}
2022-10-28 02:10:36 +00:00
WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
if (!ret) {
EnableIRQ();
return 0;
}
}
const int command_byte_count = GetCommandByteCount(buf[0]);
if (command_byte_count == 0) {
EnableIRQ();
return 0;
}
int offset = 0;
int bytes_received;
for (bytes_received = 1; bytes_received < command_byte_count; bytes_received++) {
++offset;
// Assert REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait for ACK signal
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait until the signal line stabilizes
SysTimer::SleepNsec(SCSI_DELAY_BUS_SETTLE_DELAY_NS);
// Get data
buf[offset] = GetDAT();
// Clear the REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for ACK assertion
if (!ret) {
break;
}
// Wait for ACK to clear
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for ACK to clear
if (!ret) {
break;
}
}
EnableIRQ();
return bytes_received;
2018-05-03 13:47:57 +00:00
}
//---------------------------------------------------------------------------
//
// Data reception handshake
2018-05-03 13:47:57 +00:00
//
//---------------------------------------------------------------------------
int GPIOBUS::ReceiveHandShake(uint8_t *buf, int count)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
int i;
2018-05-03 13:47:57 +00:00
// Disable IRQs
DisableIRQ();
if (actmode == mode_e::TARGET) {
for (i = 0; i < count; i++) {
// Assert the REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait for ACK
2022-10-28 02:10:36 +00:00
bool ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait until the signal line stabilizes
SysTimer::SleepNsec(SCSI_DELAY_BUS_SETTLE_DELAY_NS);
// Get data
*buf = GetDAT();
// Clear the REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for ACK signal
if (!ret) {
break;
}
// Wait for ACK to clear
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for ACK to clear
if (!ret) {
break;
}
// Advance the buffer pointer to receive the next byte
buf++;
}
} else {
// Get phase
2022-10-28 02:32:23 +00:00
// uint32_t phase = Acquire() & GPIO_MCI;
(void)Acquire();
phase_t phase = GetPhase();
for (i = 0; i < count; i++) {
// Wait for the REQ signal to be asserted
2022-10-28 02:10:36 +00:00
bool ret = WaitSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Check for timeout waiting for REQ signal
if (!ret) {
break;
}
2018-05-03 13:47:57 +00:00
// Phase error
2022-10-28 02:32:23 +00:00
(void)Acquire();
if (GetPhase() != phase) {
break;
}
// Wait until the signal line stabilizes
SysTimer::SleepNsec(SCSI_DELAY_BUS_SETTLE_DELAY_NS);
// Get data
*buf = GetDAT();
// Assert the ACK signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait for REQ to clear
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Clear the ACK signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for REQ to clear
if (!ret) {
break;
}
// Phase error
2022-10-28 02:32:23 +00:00
(void)Acquire();
if (GetPhase() != phase) {
break;
}
2018-05-03 13:47:57 +00:00
// Advance the buffer pointer to receive the next byte
buf++;
}
}
// Re-enable IRQ
EnableIRQ();
// Return the number of bytes received
return i;
2018-05-03 13:47:57 +00:00
}
//---------------------------------------------------------------------------
//
// Data transmission handshake
2018-05-03 13:47:57 +00:00
//
//---------------------------------------------------------------------------
int GPIOBUS::SendHandShake(uint8_t *buf, int count, int delay_after_bytes)
2018-05-03 13:47:57 +00:00
{
GPIO_FUNCTION_TRACE
2018-05-03 13:47:57 +00:00
int i;
// Disable IRQs
DisableIRQ();
if (actmode == mode_e::TARGET) {
for (i = 0; i < count; i++) {
if (i == delay_after_bytes) {
LOGTRACE("%s DELAYING for %dus after %d bytes", __PRETTY_FUNCTION__, SCSI_DELAY_SEND_DATA_DAYNAPORT_US,
(int)delay_after_bytes)
SysTimer::SleepUsec(SCSI_DELAY_SEND_DATA_DAYNAPORT_US);
}
// Set the DATA signals
SetDAT(*buf);
// Wait for ACK to clear
2022-10-28 02:10:36 +00:00
bool ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for ACK to clear
if (!ret) {
break;
}
// Already waiting for ACK to clear
// Assert the REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait for ACK
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Clear REQ signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for ACK to clear
if (!ret) {
break;
}
// Advance the data buffer pointer to receive the next byte
buf++;
}
// Wait for ACK to clear
2022-10-28 02:10:36 +00:00
WaitSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
} else {
// Get Phase
2022-10-28 02:32:23 +00:00
// uint32_t phase = Acquire() & GPIO_MCI;
(void)Acquire();
phase_t phase = GetPhase();
for (i = 0; i < count; i++) {
if (i == delay_after_bytes) {
LOGTRACE("%s DELAYING for %dus after %d bytes", __PRETTY_FUNCTION__, SCSI_DELAY_SEND_DATA_DAYNAPORT_US,
(int)delay_after_bytes)
SysTimer::SleepUsec(SCSI_DELAY_SEND_DATA_DAYNAPORT_US);
}
// Set the DATA signals
SetDAT(*buf);
// Wait for REQ to be asserted
2022-10-28 02:10:36 +00:00
bool ret = WaitSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
2018-05-03 13:47:57 +00:00
// Check for timeout waiting for REQ to be asserted
if (!ret) {
break;
}
// Phase error
2022-10-28 02:32:23 +00:00
Acquire();
if (GetPhase() != phase) {
break;
}
// Already waiting for REQ assertion
// Assert the ACK signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_HIGH);
// Wait for REQ to clear
2022-10-28 02:10:36 +00:00
ret = WaitSignal(board->pin_req, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Clear the ACK signal
2022-10-28 02:10:36 +00:00
SetSignal(board->pin_ack, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// Check for timeout waiting for REQ to clear
if (!ret) {
break;
}
2018-05-03 13:47:57 +00:00
// Phase error
2022-10-28 02:32:23 +00:00
Acquire();
if (GetPhase() != phase) {
break;
}
// Advance the data buffer pointer to receive the next byte
buf++;
}
}
// Re-enable IRQ
EnableIRQ();
// Return number of transmissions
return i;
}
#ifdef USE_SEL_EVENT_ENABLE
//---------------------------------------------------------------------------
//
// SEL signal event polling
//
//---------------------------------------------------------------------------
SASI code removal, error handling update, bug fixes, code cleanup (#806) Summary ov most important changes triggered by the SASI code removal: - Removed the SASI controller code - New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests. - New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests. - The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes. - The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI. - scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device - Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling. - Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers. - Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::. - Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic. - Use constructor member initialization lists (recommended for ISO C++) - Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling - Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow) - Replaced NULL by nullptr (recommended for C++), resulting in better type safety - Use more const member functions in order to avoid side effects - The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs. - Better encapsulation, updated access specifiers in many places - Removed unused methods and method arguments - Fixed a number of TODOs - Added/updated unit tests for a lot of non-legacy classes - Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
bool GPIOBUS::PollSelectEvent()
{
GPIO_FUNCTION_TRACE
errno = 0;
if (epoll_event epev; epoll_wait(epfd, &epev, 1, -1) <= 0) {
LOGWARN("%s epoll_wait failed", __PRETTY_FUNCTION__)
LOGWARN("[%08X] %s", errno, strerror(errno))
return false;
}
if (gpioevent_data gpev; read(selevreq.fd, &gpev, sizeof(gpev)) < 0) {
LOGWARN("%s read failed", __PRETTY_FUNCTION__)
LOGWARN("[%08X] %s", errno, strerror(errno))
return false;
}
return true;
}
//---------------------------------------------------------------------------
//
// Cancel SEL signal event
//
//---------------------------------------------------------------------------
void GPIOBUS::ClearSelectEvent()
{
GPIO_FUNCTION_TRACE
2018-05-03 13:47:57 +00:00
}
#endif // USE_SEL_EVENT_ENABLE
2018-05-03 13:47:57 +00:00
//---------------------------------------------------------------------------
//
// Signal table
2018-05-03 13:47:57 +00:00
//
//---------------------------------------------------------------------------
2022-10-29 02:13:07 +00:00
vector<board_type::pi_physical_pin_e> GPIOBUS::SignalTable;
//---------------------------------------------------------------------------
//
// Create work table
//
//---------------------------------------------------------------------------
void GPIOBUS::MakeTable(void)
{
GPIO_FUNCTION_TRACE
2022-10-29 02:13:07 +00:00
[[maybe_unused]] const array<board_type::pi_physical_pin_e, 9> pintbl = {
board->pin_dt0, board->pin_dt1, board->pin_dt2, board->pin_dt3, board->pin_dt4,
board->pin_dt5, board->pin_dt6, board->pin_dt7, board->pin_dp};
array<bool, 256> tblParity;
// Create parity table
for (uint32_t i = 0; i < 0x100; i++) {
uint32_t bits = i;
uint32_t parity = 0;
for (int j = 0; j < 8; j++) {
parity ^= bits & 1;
bits >>= 1;
}
parity = ~parity;
tblParity[i] = parity & 1;
}
#if SIGNAL_CONTROL_MODE == 0
// Mask and setting data generation
for (auto &tbl : tblDatMsk) {
tbl.fill(-1);
}
for (auto &tbl : tblDatSet) {
tbl.fill(0);
}
for (uint32_t i = 0; i < 0x100; i++) {
// Bit string for inspection
uint32_t bits = i;
2022-10-29 01:56:10 +00:00
// TODO: temporary to make clang++ happy.....
(void)bits;
// Get parity
if (tblParity[i]) {
bits |= (1 << 8);
}
// TODO: THIS NEEDS TO BE MOVED DOWN TO THE BOARD_SPECIFIC REGION
// // Bit check
// for (int j = 0; j < 9; j++) {
// // Index and shift amount calculation
// int index = pintbl[j] / 10;
// int shift = (pintbl[j] % 10) * 3;
// // Mask data
// tblDatMsk[index][i] &= ~(0x7 << shift);
// // Setting data
// if (bits & 1) {
// tblDatSet[index][i] |= (1 << shift);
// }
// bits >>= 1;
// }
}
#else
for (uint32_t i = 0; i < 0x100; i++) {
// Bit string for inspection
uint32_t bits = i;
// Get parity
if (tblParity[i]) {
bits |= (1 << 8);
}
#if SIGNAL_CONTROL_MODE == 1
// Negative logic is inverted
bits = ~bits;
#endif
// Create GPIO register information
uint32_t gpclr = 0;
uint32_t gpset = 0;
for (int j = 0; j < 9; j++) {
if (bits & 1) {
gpset |= (1 << pintbl[j]);
} else {
gpclr |= (1 << pintbl[j]);
}
bits >>= 1;
}
tblDatMsk[i] = gpclr;
tblDatSet[i] = gpset;
}
#endif
}
//---------------------------------------------------------------------------
//
// Wait for signal change
//
//---------------------------------------------------------------------------
2022-10-28 02:10:36 +00:00
bool GPIOBUS::WaitSignal(board_type::pi_physical_pin_e pin, board_type::gpio_high_low_e ast)
{
GPIO_FUNCTION_TRACE
// Get current time
uint32_t now = SysTimer::GetTimerLow();
// Calculate timeout (3000ms)
uint32_t timeout = 3000 * 1000;
// end immediately if the signal has changed
do {
// Immediately upon receiving a reset
Acquire();
if (GetRST()) {
return false;
}
// Check for the signal edge
LOGWARN("THIS WONT WORK. NEEDS TO BE UPDATED");
2022-10-29 02:13:07 +00:00
2022-10-28 02:10:36 +00:00
if ((GetSignal(pin) ^ ~((int)(board->gpio_state_to_bool(ast)))) & 1) {
return true;
}
// if (((signals >> pin) ^ ~ast) & 1) {
// return true;
// }
} while ((SysTimer::GetTimerLow() - now) < timeout);
// We timed out waiting for the signal
return false;
}
//---------------------------------------------------------------------------
//
// Generic Phase Acquisition (Doesn't read GPIO)
//
//---------------------------------------------------------------------------
BUS::phase_t GPIOBUS::GetPhaseRaw(uint32_t raw_data)
{
2022-10-29 02:13:07 +00:00
GPIO_FUNCTION_TRACE(void) raw_data;
// // Selection Phase
// if (GetPinRaw(raw_data, board->pin_sel)) {
// if (GetPinRaw(raw_data, board->pin_io)) {
// return BUS::phase_t::reselection;
// } else {
// return BUS::phase_t::selection;
// }
// }
// // Bus busy phase
// if (!GetPinRaw(raw_data, board->pin_bsy)) {
// return BUS::phase_t::busfree;
// }
LOGWARN("NOT IMPLEMENTED YET");
return BUS::phase_t::busfree;
2022-10-29 02:13:07 +00:00
// // Selection Phase
// if (GetSignal(board->pin_sel)) {
// if (GetSignal(board->pin_io)) {
// return BUS::phase_t::reselection;
// } else {
// return BUS::phase_t::selection;
// }
// }
// // Bus busy phase
// if (!GetPinRaw(raw_data, board->pin_bsy)) {
// return BUS::phase_t::busfree;
// }
// // Get target phase from bus signal line
// int mci = GetPinRaw(raw_data, board->pin_msg) ? 0x04 : 0x00;
// mci |= GetPinRaw(raw_data, board->pin_cd) ? 0x02 : 0x00;
// mci |= GetPinRaw(raw_data, board->pin_io) ? 0x01 : 0x00;
// return GetPhase(mci);
}
const string GPIOBUS::GetConnectDesc()
{
if (board == nullptr) {
return "unknown";
}
return board->connect_desc;
}