From b90396f7c43312711b91da4d3785a750033d81c4 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Wed, 22 Jan 2025 14:26:23 +0100 Subject: [PATCH] Further reduce Pi dependencies --- cpp/Makefile | 5 ++++- cpp/buses/bus_factory.cpp | 4 ++++ cpp/buses/rpi_bus.cpp | 12 ------------ cpp/buses/rpi_bus.h | 6 +----- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/cpp/Makefile b/cpp/Makefile index efe373a5..6f99a9c0 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -171,7 +171,10 @@ SRC_SHARED_PROTOBUF := $(wildcard $(DIR_SHARED_PROTOBUF)/*.cpp) SRC_SHARED_COMMAND := $(wildcard $(DIR_SHARED_COMMAND)/*.cpp) SRC_SHARED_INITIATOR := $(wildcard $(DIR_SHARED_INITIATOR)/*.cpp) SRC_BASE = $(wildcard $(DIR_BASE)/*.cpp) -SRC_BUSES = $(wildcard $(DIR_BUSES)/*.cpp) +SRC_BUSES = $(shell ls -1 $(DIR_BUSES)/*.cpp | grep -v rpi_bus.cpp) +ifdef IS_LINUX +SRC_BUSES += $(DIR_BUSES)/rpi_bus.cpp +endif SRC_CONTROLLERS = $(wildcard $(DIR_CONTROLLERS)/*.cpp) SRC_DISK = \ diff --git a/cpp/buses/bus_factory.cpp b/cpp/buses/bus_factory.cpp index e033929f..083676d7 100644 --- a/cpp/buses/bus_factory.cpp +++ b/cpp/buses/bus_factory.cpp @@ -8,7 +8,9 @@ #include "bus_factory.h" #include "in_process_bus.h" +#ifdef __linux__ #include "rpi_bus.h" +#endif using namespace spdlog; @@ -19,9 +21,11 @@ unique_ptr BusFactory::CreateBus(bool target, bool in_process, const string if (in_process) { bus = make_unique(InProcessBus::Instance(), identifier, log_signals); } +#ifdef __linux__ else if (const auto pi_type = RpiBus::CheckForPi(); pi_type != RpiBus::PiType::UNKNOWN) { bus = make_unique(pi_type); } +#endif else { bus = make_unique(InProcessBus::Instance(), identifier, false); } diff --git a/cpp/buses/rpi_bus.cpp b/cpp/buses/rpi_bus.cpp index 6da01e57..c38760cf 100644 --- a/cpp/buses/rpi_bus.cpp +++ b/cpp/buses/rpi_bus.cpp @@ -150,7 +150,6 @@ bool RpiBus::Init(bool target) return false; } -#ifdef __linux__ // Event request setting strcpy(selevreq.consumer_label, "SCSI2Pi"); // NOSONAR Using strcpy is safe selevreq.lineoffset = PIN_SEL; @@ -169,7 +168,6 @@ bool RpiBus::Init(bool target) ev.events = EPOLLIN | EPOLLPRI; ev.data.fd = selevreq.fd; epoll_ctl(epoll_fd, EPOLL_CTL_ADD, selevreq.fd, &ev); -#endif CreateWorkTable(); @@ -182,9 +180,7 @@ bool RpiBus::Init(bool target) void RpiBus::CleanUp() { // Release SEL signal interrupt -#ifdef __linux__ close(selevreq.fd); -#endif // Set control signals PinSetSignal(PIN_ENB, false); @@ -238,9 +234,6 @@ void RpiBus::Reset() bool RpiBus::WaitForSelection() { -#ifndef __linux__ - return false; -#else if (epoll_event epev; epoll_wait(epoll_fd, &epev, 1, -1) == -1) { if (errno != EINTR) { warn("epoll_wait failed: {}", strerror(errno)); @@ -254,7 +247,6 @@ bool RpiBus::WaitForSelection() } return false; } -#endif Acquire(); @@ -449,7 +441,6 @@ void RpiBus::SetSignal(int pin, bool state) void RpiBus::DisableIRQ() { -#ifdef __linux__ switch (pi_type) { case PiType::PI_1: // Stop system timer interrupt with interrupt controller @@ -474,12 +465,10 @@ void RpiBus::DisableIRQ() // Currently do nothing break; } -#endif } void RpiBus::EnableIRQ() { -#ifdef __linux__ switch (pi_type) { case PiType::PI_1: // Restart the system timer interrupt with the interrupt controller @@ -501,7 +490,6 @@ void RpiBus::EnableIRQ() // Currently do nothing break; } -#endif } //--------------------------------------------------------------------------- diff --git a/cpp/buses/rpi_bus.h b/cpp/buses/rpi_bus.h index feef910a..2dc71273 100644 --- a/cpp/buses/rpi_bus.h +++ b/cpp/buses/rpi_bus.h @@ -3,16 +3,14 @@ // SCSI2Pi, SCSI device emulator and SCSI tools for the Raspberry Pi // // Copyright (C) 2016-2020 GIMONS -// Copyright (C) 2023-2024 Uwe Seimet +// Copyright (C) 2023-2025 Uwe Seimet // //--------------------------------------------------------------------------- #pragma once -#ifdef __linux__ #include #include -#endif #include "bus.h" class RpiBus final : public Bus @@ -110,7 +108,6 @@ class RpiBus final : public Bus // QA7 register volatile uint32_t *qa7_regs = nullptr; -#ifdef __linux__ // Interrupt enabled state uint32_t irpt_enb; @@ -126,7 +123,6 @@ class RpiBus final : public Bus struct gpioevent_request selevreq = { }; int epoll_fd = 0; -#endif // GIC CPU interface register volatile uint32_t *gicc_mpr = nullptr;