Skip to content

Commit

Permalink
Initial codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 9, 2023
0 parents commit a4a41ef
Show file tree
Hide file tree
Showing 172 changed files with 26,414 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# When creating a new ticket please provide information on your environment.

- The Pi type:


- The Pi OS version (output of 'lsb_release -a'):


- The SCSI2Pi release or git revision:


- The computer/sampler connected to the RaSCSI/PiSCSI board:


# Describe the issue
67 changes: 67 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Run Sonar analysis

on:
workflow_dispatch:
inputs:
branch:
required: true
type: string
description: Branch to analyze

jobs:
code_analysis:
runs-on: ubuntu-latest

defaults:
run:
working-directory: cpp

env:
PACKAGES: protobuf-compiler libspdlog-dev libpcap-dev libgmock-dev
BUILD_WRAPPER_OUT_DIR: ".build_wrapper_out"
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_PROJECT_KEY: "uweseimet_scsi2pi"
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Install additional packages
run: sudo apt install --yes $PACKAGES

- name: Set up Python for gcovr
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install gcovr
run: pip install gcovr==5.0 # 5.1 is not supported

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2

- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR \
make -j $(nproc) coverage DEBUG=1
- name: Generate coverage data
run: gcovr --sonarqube > coverage.xml

- name: Run sonar-scanner
run: |
sonar-scanner \
--define sonar.host.url=$SONAR_SERVER_URL \
--define sonar.projectKey=$SONAR_PROJECT_KEY \
--define sonar.organization=$SONAR_ORGANIZATION \
--define sonar.cfamily.build-wrapper-output=$BUILD_WRAPPER_OUT_DIR \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.exclusions="obj/**,lib/**,bin/**,generated/**" \
--define sonar.coverage.exclusions="test/**" \
--define sonar.cpd.exclusions="test/**"
53 changes: 53 additions & 0 deletions .github/workflows/analyze_k8s.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run Sonar analysis (k8s)

on:
workflow_dispatch:
inputs:
branch:
required: true
type: string
description: Branch to analyze

jobs:
code_analysis:
runs-on: [k8s]

defaults:
run:
working-directory: cpp

env:
BUILD_WRAPPER_OUT_DIR: ".build_wrapper_out"
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_PROJECT_KEY: "uweseimet_scsi2pi"
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR \
make -j2 coverage DEBUG=1
- name: Generate coverage data
run: gcovr --sonarqube > coverage.xml

- name: Run sonar-scanner
run: |
sonar-scanner \
--define sonar.host.url=$SONAR_SERVER_URL \
--define sonar.projectKey=$SONAR_PROJECT_KEY \
--define sonar.organization=$SONAR_ORGANIZATION \
--define sonar.cfamily.build-wrapper-output=$BUILD_WRAPPER_OUT_DIR \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.branch.name=${{ inputs.branch }} \
--define sonar.exclusions="obj/**,lib/**,bin/**,generated/**" \
--define sonar.coverage.exclusions="test/**" \
--define sonar.cpd.exclusions="test/**"
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and test on code change

on:
workflow_call:
push:
paths:
- 'cpp/**'
- 'proto/**'
- '.github/workflows/build.yml'
pull_request:
paths:
- 'cpp/**'
- 'proto/**'
- '.github/workflows/build.yml'
types:
- assigned
- opened
- synchronize
- reopened
branches:
- 'develop'
- 'main'

jobs:
fullspec:
uses: ./.github/workflows/build_and_test_aarch64.yml
with:
board: "FULLSPEC"

# standard:
# uses: ./.github/workflows/build_and_test_aarch64.yml
# with:
# board: "STANDARD"
55 changes: 55 additions & 0 deletions .github/workflows/build_and_test_aarch64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and test on aarch64

on:
workflow_dispatch:
inputs:
debug:
required: false
type: boolean
description: Debug build
default: true
board:
required: false
type: choice
description: Board type
options:
- FULLSPEC
- STANDARD
default: FULLSPEC
branch:
required: true
type: string
description: Branch to build

workflow_call:
inputs:
debug:
required: false
type: boolean
default: true
board:
required: false
type: string
branch:
required: false
type: string

jobs:
build:
runs-on: [ora, ARM64]

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Compile
run: |
debug=${{ inputs.debug && 'DEBUG=1' || '' }} &&
make -j $(nproc) BOARD=${{ inputs.board }} $debug CXX=clang++
- name: Run unit tests
run: |
debug=${{ inputs.debug && 'DEBUG=1' || '' }} &&
make -C cpp test -j $(nproc) BOARD=${{ inputs.board }} $debug CXX=clang++
60 changes: 60 additions & 0 deletions .github/workflows/build_and_test_amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and test on amd64

on:
workflow_dispatch:
inputs:
debug:
required: true
type: boolean
description: Debug build
default: true
board:
required: true
type: choice
description: Board type
options:
- FULLSPEC
- STANDARD
default: FULLSPEC
branch:
required: true
type: string
description: Branch to build

workflow_call:
inputs:
debug:
required: true
type: boolean
default: true
board:
required: true
type: string
branch:
required: true
type: string

jobs:
build:
runs-on: [ora, X64]

env:
PACKAGES: "libspdlog-dev libpcap-dev libgmock-dev protobuf-compiler"

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Install additional packages
run: sudo apt install --yes $PACKAGES

- name: Compile
run: |
debug=${{ inputs.debug && 'DEBUG=1' || '' }} &&
make -j $(nproc) BOARD=${{ inputs.board }} $debug
- name: Run unit tests
run: |
debug=${{ inputs.debug && 'DEBUG=1' || '' }} &&
make -C cpp test -j $(nproc) BOARD=${{ inputs.board }} $debug CXX=clang++
33 changes: 33 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
BSD 3-Clause License

Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
Copyright (C) 2014-2020 GIMONS
Copyright (C) 2020-2021 akuker
Copyright (C) PiSCSI project contributors (github.com/PiSCSI/piscsi)
Copyright (C) 2021-2023 Uwe Seimet
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DEFAULT_GOAL: all

TARGETS := all clean install

SUBDIRS := cpp doc

$(TARGETS): $(SUBDIRS)

$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)

.PHONY: $(TARGETS) $(SUBDIRS)
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# What is SCSI2Pi?

SCSI2Pi (or simply just S2P) is an alternative to the <a href="https://github.com/PiSCSI/piscsi">PiSCSI software</a> for the PiSCSI/RaSCSI board. SCSI2Pi focuses on improving the SCSI emulation, i.e. the C++ backend, and is compatible with the PiSCSI web UI and the <a href="https://www.scsi2pi.net/en/app.html">SCSI Control app</a>.<br />
You can switch from PiSCSI to SCSI2Pi (or back, if needed) in seconds, by installing/de-installing a Debian package with the binaries. No time-consuming compilation is required.<br />
SCSI2Pi emulates several SCSI or SASI devices like hard disks, CD-ROM drives, printers or network adapters at the same time. This way you can easily add a range of devices to computers like 68k Macs, Atari ST/TT/Falcon, Amigas, old PCs, Unix workstations or samplers. Compared to PiSCSI the SCSI2Pi backend offers <a href="https://www.scsi2pi.net/en/scsi2pi.html">numerous extensions</a>, new device emulations, performance improvements and additional bug fixes. These add to the extensive changes I contributed to the PiSCSI project in the past. I have re-implemented almost the complete original codebase in modern C++.<br />
SCSI2Pi was chosen as the name for this project because there are not that many choices anymore when looking for a name that contains both "SCSI" and "Pi" ;-).<br />
<a href="https://www.scsi2pi.net">The SCSI2Pi project</a> is currently in the process of being set up, which will still take a while. Note that the current sources on GitHub are only temporary, and the repository will be re-initialized with fresh sources when SCSI2Pi is ready to start.

# How is SCSI2Pi related to PiSCSI and the former RaSCSI?

Over time, within the PiSCSI project the interest in replacing the old, often buggy or unnecessary code became rather low. In addition, code reviewers were missing, and features, which led to long delays before changes could be committed. Furhter, long promised features on the roadmap and in tickets have not been addressed. This is why I decided to further improve the software in a separate project. The major part of the current (23.11.01) PiSCSI codebase has been contributed by me anyway.<br />
There was also no interest in further exploiting the initiator mode feature of the FULLSPEC board. This mode, together with new SCSI2Pi command line tools, offers solutions for use cases that have never been addressed before.<br />
From my perspective the overall situation was not satisfying, and this is why I set up SCSI2Pi as an alternative project that is compatible with the RaSCSI/PiSCSI board and the PiSCSI web interface.

# Who am I?

In the past I was the main C++ code contributor for PiSCSI. I revised the backend architecture and re-engineered most of the legacy C++ code. The code was updated to C++-20, which is the latest C++ standard you can currently use on the Pi. All in all this resulted in more modular code and drastically improved SonarQube code metrics. Besides adding numerous <a href="https://www.scsi2pi.net/en/scsi2pi.html">new features</a> and improving the compatibility with many platforms, I also fixed numerous bugs in the legacy codebase and added an extensive set of unit tests.<br />
I am also the author of the <a href="https://www.scsi2pi.net/en/app.html">SCSI Control app</a> for Android, which is the remote control for your RaSCSI/PiSCSI boards.

# SCSI2Pi goals

The intention of SCSI2Pi is not to completely replace the PiSCSI software, where great work is still being done on the web interface, and on supporting users in social media.
The goal of SCSI2Pi is to improve the actual SCSI emulation, i.e. the C++ core, and to address compatibility issues, mainly (but not only) with usually rather exotic platforms. SCSI2Pi focuses on vintage computers like Macs, Ataris, Amigas, workstations and on samplers. There is no support for the X68000, in particular not for the host bridge (SCBR) device. In PiSCSI the related code has always been in a bad shape, and nobody has been willing to test it. It might not even be working. The other PiSCSI features are supported by SCSI2Pi - many of these I implemented anyway ;-). There is already a <a href="https://www.scsi2pi.net/en/scsi2pi.html">list of upcoming new SCSI2Pi features</a>.<br />
In general, the <a href="https://www.scsi2pi.net">SCSI2Pi website</a> tries to address users and developers, whereas the information on GitHub is developer-centric.

# Contributing to SCSI2Pi

If you are interested in the Pi and/or SCSI, in modern C++ and platform-independent programming, you are very welcome as a developer or a code reviewer.<br />
Did I just say "platform independent programming", even though SCSI2Pi is about the Pi? I did indeed, because I have ensured that the PiSCSI code also compiles and partially runs on regular Linux PCs, on BSD and even on macos. This is important for developers and for testing, because the faster your development machine, the better. In general, a C provides a much better development environment than a Pi. I am using Eclipse CDT on a Linux PC as my primary development platform, by the way.
Loading

0 comments on commit a4a41ef

Please sign in to comment.