Commit Graph
146 Commits
Author SHA1 Message Date
Daniel Markstedt 825a33872d place the NOSONAR comment in the right place 2026-09-03 06:55:44 +02:00
Daniel Markstedt 6c1aa8eaaf overhaul the SonarCube coverage CI job
the SonarCube Cloud scan actions were using outdated and conflicting configurations, while omitting the Go codebase

now we also build all the binaries with the Makefile
2026-09-01 21:14:49 +02:00
Daniel Markstedt 1bd0c06bc6 meson: fix protobuf race condition and track build targets
two fixes: make sure the generated protobuf sources are available before proceeding with compilation, and track the actual build targets that get flagged in the configure summary
2026-09-01 20:25:51 +02:00
Daniel Markstedt 485298ffe5 restore X68000 Host Bridge support
Restore the SCBR device as an X68000 Host Bridge, including the Human68k-compatible host file-system service and the bridge-specific SCSI message handlers. Back its Ethernet path with the TAP driver, derive a stable locally administered MAC address, preserve the driver minimum-frame/FCS expectations, and restrict received traffic to its own unicast frames and broadcasts.

Match the RASCTL/RASETHER/RASDRV bridge protocol that originated in the parent RaSCSI project: dispatch its non-standard message format on READ(10)/WRITE(10) (0x28/0x2a), with type, function, phase, and a three-byte byte count carried in the CDB. Advertise the legacy control channel required by RASCTL, translate its list and device-management commands to PiSCSI operations, and defer stop or system-shutdown requests until after the response is sent, while gating this insecure interface behind a new '-c disabled|media|full' runtime option. Preserve the type-1 Ethernet exchange used by RASETHER and the type-2, phased filesystem exchange used by RASDRV.

Register the device in the factory, protobuf API, controller transfer path, command-line tooling, device listings, and web UI. Share the explicit bridge and proxy-ARP topology workflow with DaynaPort so both adapters validate and use the same mode/interface pair.

Add build support for iconv where needed, extend unit coverage for device creation, RAS* protocol handling, CLI parsing, web attachment, and topology selection, and update the man pages and network-profile documentation for Host Bridge operation and its networking limits.
2026-09-01 00:52:00 +02:00
Daniel Markstedt 1ee4a320b8 replace compile-time board types with runtime profiles
Move GPIO mappings into a single module and select a board profile at process startup instead of at compile time: Build every GPIO-facing utility for every supported profile. At the same time, we remove support for the historical AIBOM board type since it's the only one using positive logic, the other three variants share the same electrical behavior.

Run piscsi, scsimon, scsiloop, scsidump, or sasidump with -C=STANDARD, FULLSPEC, or GAMERNIUM. FULLSPEC remains the default. To select a profile for the systemd service, set PISCSI_CONNECTION_TYPE and restart the service.
2026-08-31 21:55:50 +02:00
Daniel Markstedt 69535c772b fix NEC image sector size handling
Use the validated image sector size to derive SCSIHD_NEC's sector shift count, instead of the complete image size. This restores correct capacity and MODE SENSE geometry for PC-98 HDN images.
2026-08-30 09:13:03 +02:00
Daniel Markstedt a0c3c41f2c the Sleep() function now takes a parameter
common bus wait times are now defined in a central place, and passed to the Sleep() function
2026-08-30 08:27:35 +02:00
Daniel Markstedt bbf50d504a restore the sasidump utility
Restore the sasidump tool for dumping physical SASI hard disks to local file through piscsi GPIO. It has been slightly refactored to align with the current C++ coding standards.
2026-08-30 08:27:35 +02:00
Daniel Markstedt e972b3c31a explicitly wait for protobuf source to be generated 2026-08-30 08:27:35 +02:00
Daniel Markstedt 1b9f279e61 introduce X68000 SASI compatibility quirks
Port the X68000 SASI probe handling and completion-message behavior from the older RaSCSI SASI implementation.

Borrow BlueSCSI v2-compatible Assign Disk Parameters (0xC2) handling: accept its six-byte CDB and consume the ten-byte parameter payload.
2026-08-30 08:27:35 +02:00
Daniel Markstedt e57893893c restore support for SASI disk drive device
Introduce a SASI controller and SAHD disk implementation alongside the existing SCSI path. Select the appropriate controller when attaching a device, prevent SASI and SCSI devices from sharing a target ID, and implement SASI-specific selection, message, status, timing, and LUN handling.

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

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

Add focused C++ and Go coverage for SASI devices, controller selection, LUN validation, and web-facing behavior.
2026-08-30 08:27:35 +02:00
Daniel Markstedt e9e48b7fca remove plain text man page generation 2026-08-23 17:40:58 +02:00
Daniel Markstedt 57dfca91c8 meson: rename build targets option to 'targets' 2026-08-23 14:45:47 +02:00
Daniel Markstedt f103292867 fix error in ReadProxyArpUplinkFile unit test 2026-08-23 14:45:47 +02:00
Daniel Markstedt cbf399cc30 bump release version to 26.8.1 2026-08-23 14:45:47 +02:00
Daniel Markstedt e2735813a3 parprouted bridge for SCDP adapter
Refactor the DaynaPort TAP driver around explicit bridge and proxy-ARP profiles. Validate the selected interface and profile before creating piscsi0, attach it only to the preconfigured bridge when appropriate, derive a stable DaynaPort MAC address from the uplink, and make TAP setup and cleanup robust.

Add managed host networking profiles for wired bridging and Wi-Fi proxy ARP. Install the PiSCSI NetworkManager templates, profile-management command, parprouted and DHCP relay system services, udev/sysctl hooks, and configuration file so a selected Wi-Fi uplink can provide proxy-ARP networking without altering connectivity during package installation.

Expose DaynaPort profiles consistently through the protocol, daemon, scsictl, and web UI. Report interface type, state, and supported modes; require or default explicit mode/interface pairs on attach; present eligible wired-bridge and Wi-Fi proxy-ARP choices; and validate selections before attaching an SCDP device.

Package and document the new networking workflow. Add the profile utility and required runtime assets to Debian packages, expand the manual-page set and web manual index, update DaynaPort command help, and extend unit and handler tests for the profile-aware behavior.
2026-08-23 12:15:13 +02:00
Daniel Markstedt 420d4eea21 remove compile time stamps to enable reproducible builds
while the timestamp when the binary was built can be handy for
knowing when a development build was created, it breaks reproducible
builds which is a fatal error when doing Debian deb packaging

also strips away the redundant trailing version string from the banner
2026-08-21 07:09:06 +02:00
Daniel Markstedt fa878e3133 create Debian packaging files
Debian deb packaging files for all four targets: piscsi, piscsi-web,
piscsi-oled, piscsi-ctrlboard

build instructions for Trixie specifically in README.Debian

consolidate all systemd unit files and standardize on /usr/bin
for all binaries
2026-08-21 07:09:06 +02:00
Daniel Markstedt 51ac8cb42d properly initialize piscsi controller before running test
also, add assertions to the GetInitiatorId calls right afterwards
2026-08-17 19:57:05 +02:00
Daniel Markstedt 353bb48878 bump copyright years to 2026 2026-08-17 19:56:46 +02:00
Daniel Markstedt a4b64fc1eb scsiloop: gate hardware diagnostics by platform
Replace getopt() and usleep() dependencies with portable C++ parsing and sleeps. Refuse to execute the GPIO loopback diagnostic off Linux/Raspberry Pi hardware, and omit the hardware-only target from non-Linux Meson builds.
2026-08-15 16:33:15 +02:00
Daniel Markstedt fec28e6795 bound CD-ROM READ TOC allocation length to the transfer buffer
READ TOC receives its allocation length from the initiator’s CDB and accepts values up to 65535 bytes. The controller’s transfer buffer is normally only 4096 bytes, so using that value directly could overrun the buffer and report more data than can be transferred.

Clamp the response length to the available buffer size and clear only that bounded range before constructing the response. Also bound the start-track scan before dereferencing the track vector, allowing a lead-out (0xAA) request to safely produce its descriptor when no matching track exists.

Add regression tests for the maximum allocation length and for READ TOC lead-out handling.
2026-08-11 07:05:54 +02:00
Daniel Markstedt 4e9d0de1f8 image: resolve default-folder symlinks canonically
Resolve symlinked default image folders with canonical() so relative link targets are evaluated from their link location. Replace the tautological default-folder assertion with coverage for missing folders, relative paths, and relative symlink targets.
2026-08-02 23:18:40 +02:00
Daniel Markstedt 6593547c69 scsi: validate Format Device page length
Reject MODE SELECT Format Device pages whose length differs from the 24-byte page returned by MODE SENSE. Use a complete valid page in the truncation regression and cover both invalid page lengths and transfer lengths exceeding the buffer.
2026-08-02 23:18:40 +02:00
Daniel Markstedt 4ac28cff38 tests: make Meson unit runs diagnosable
Forward command-line arguments to GoogleTest and mark the Meson target as gtest protocol so filtering, seeds, and individual results are available. Harden the service tests against unavailable socket capabilities and environment-dependent privileged ports, and skip the Linux-only interface assertion elsewhere.
2026-08-02 23:18:40 +02:00
Daniel Markstedt 3fab138bf5 Make Meson unit tests portable to macOS 2026-08-02 23:18:40 +02:00
Daniel Markstedt beea830a12 use a fixture to clean up between tests 2026-08-02 23:18:40 +02:00
Daniel Markstedt 42f48ade04 validate MODE SELECT parameter lists
Validate that the declared MODE SELECT parameter list fits in the transfer buffer and contains a complete command header. Validate the block-descriptor list against the remaining parameter-list length before skipping it.

Reject truncated mode-page headers and page bodies before reading them. Report ILLEGAL REQUEST / PARAMETER LIST LENGTH ERROR for truncated headers, block descriptors, and mode pages, as required by SCSI-2 8.2.8; retain INVALID FIELD IN PARAMETER LIST for complete but invalid fields.

Update the hard-disk and magneto-optical fixtures to send complete Format Device pages with their actual MODE SELECT parameter-list lengths. Add regression coverage for truncated headers, descriptors, page headers, and page bodies.
2026-08-02 23:18:40 +02:00
Daniel Markstedt bb9e3b4a78 update hd and mo test with valid page data 2026-08-02 23:18:40 +02:00
Daniel Markstedt f8e35314cb protect against empty operation 2026-08-02 23:18:40 +02:00
Daniel Markstedt dba5f9be3d executor: validate existing devices without blocking ATTACH 2026-08-02 23:18:40 +02:00
Daniel Markstedt 4564e427ef create meson build scripts
Adds a suite of meson scripts for building the C++ project
2026-08-02 23:18:40 +02:00
Eric Helgeson 7bef2d72ae rewrite Web UI in Go
Introduce a server-rendered Go control panel for managing PiSCSI devices, disk images, saved configurations, archives, uploads, system settings, embedded themes and translations, PWA assets, a mock daemon, installation and systemd support, generated protobuf bindings, tests, and CI builds for supported Raspberry Pi targets.

This is built for feature parity with the Python Web UI, with a few notable differences: piscsi-web runs as a non-privileged user, there is no user authentication, the upload form uses a plain stream with no Javascript, the ability to set 'pretty hostname' is removed, and reserved ID memos are removed too.

Update piscsi core to use /var/lib/piscsi/images as its default and resolve relative image folders from the server working directory. Allow valid folders outside the user's home directory, and align the tests, protocol comments, service example, and man pages with the new behavior.

Ship a script and makefile target for migrating user data from old to new file system locations.
2026-08-01 12:30:27 +02:00
Jan-Benedict Glaw 13af059d95 Fix logging for unknown commands
I'm currently debugging why NetBSD cannot access a simulated
DEC RRD42 drive. The log shows this command is received:

Mar  6 09:31:55 piscsi PISCSI[479]: [2026-03-06 09:31:55.710] [trace] (ID 5) - Received unknown command: $0Q

This is actually 0x51 (= ASCII 'Q')
2026-03-07 08:35:55 +01:00
Jan-Benedict Glaw 1bab197cae scsidump: Allow to start at a specific offset
I'm using `scsidump` to dump old SCSI drives and from time to time, I run into
errors. With this patch, I can resume a transfer (and will only lose 64 KB.)
2026-01-07 04:39:42 +09:00
Daniel Markstedt 00743d1126 force man page to plain text output to 80 char width 2026-01-02 07:09:22 +09:00
Daniel Markstedt 363760f2cc Update version numbers for release 25.12.1 2025-12-30 15:39:07 +01:00
Daniel Markstedt 6b7d140351 Reintroduce clang-format rules and remove IDE specific configuration
This reverts a previous change where configurations for the Eclipse IDE specifically was introduced.

I think it's more important to have an IDE agnostic formatting framework, which clang-format provides

Example command for formatting all C++ source code, as run from within the cpp dir:

find . -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i
2025-12-24 09:53:51 +01:00
Daniel Markstedt 7dc49d2311 Reduce overly detailed usage help text and refer to the man pages
This will reduce the recurring maintenance overhead of keeping the same information up to date in multiple places

Only the most common use cases are covered in the usage help text now
2025-12-24 01:03:47 +01:00
Daniel Markstedt a99e1c51b9 Move the protobuf source into its own dir in the repo root
The protobuf source file is used by more than just the C++ code,
so let's move it into its own location for consistency and discoverability
2025-12-03 23:20:46 +01:00
Daniel Markstedt db31ba291f have all objects depend on generated protobuf code (#1437)
Protect against compiler errors due to the protobuf header not existing yet when you compile multi threaded
2025-11-28 09:00:07 +01:00
Daniel Markstedt f26fd6567a Override Eject function for Streamer device (#1538)
In order for the Eject command to properly release the image and reset the status,
we need to override the Eject function with the appropriate logic

The other removable disk drive devices inherit the Disk class,
and hence do not need this
2025-11-23 09:05:18 +01:00
Chris Hooper 25718e0887 Add support for drives larger than 2 TB (Closes: #1551)
Mode Sense (6) supports a 32-bit number for the maximum block count, where Mode Sense (10) supports a 64-bit number for the count. The Seagate SCSI Commands Reference Manual from 2016, has this to say about a "Short LBA mode parameter block descriptor" as returned by Mode Sense (6):

>  On a MODE SENSE command, if the number of logical blocks on the
>  medium exceeds the maximum value that is able to be specified in
>  the NUMBER OF LOGICAL BLOCKS field, the device server shall return
>  a value of FFFFFFFh.

Similarly, the Read Capacity (10) command should return FFFFFFFFh if the capacity of the drive exceeds 2^32 sectors, and that a driver should then know to use Read Capacity (16) if it supports that command.

There may be an unexpected side-effect if presenting a drive of more than 2^32 sectors to a legacy host that does not support devices that large. The Read Capacity commands specify the value returned as the last addressable sector on the device. This means that typically, an application which uses the value returned by that command is going to add 1 to it to get the actual number of blocks on a given device. If the program is not aware of Read Capacity (16), and is not using greater than 32-bit math, then it might report to the user that the total number of sectors on the drive as 0. I don't view this as a huge problem, however. In that case, the legacy driver wouldn't correctly support the capacity of the drive anyway, so providing that driver with a device that is 2 ^ 32 sectors or larger wouldn't make sense from the user perspective.
2025-11-18 21:03:26 +01:00
Daniel Markstedt c642592551 Use generic SCSI TAPE product name and add more SCTP profiles 2025-11-10 19:51:57 +01:00
Daniel Markstedt 567dca9cc3 Add device type shorthand 't' for Tape, and change printer to 'p'
The scsictl command parser looks for single letter shorthands for each device type;
this adds 't' for SCTP and changes SCLP to 'p'

Now you can do '-t tape' and '-t printer' for an easy to remember command

Also moves the SCTP default product/vendor into the device factory,
updates the unit tests, and an overhauls the man pages
2025-11-10 19:51:57 +01:00
Daniel Markstedt 7f57c9e28d Introduce option to set the minimum execution time of SCSI commands (#741)
For the Status, DataIn, and DataOut phases, piscsi has a 50 microsecond
sleep implemented, which has proven a stabilizing factor for the bus
on most SCSI initiators

However, Akai S1100 and other samplers of a similar vintage need a longer
sleep time for reliable operation, so a -s option for piscsi has been
introduced to set the value to an artbitrary number at runtime
2025-11-09 09:37:33 +01:00
Daniel Markstedt b7e7c4e529 Remove bitrotted X68000 host bridge device
The X68000 host bridge and associated host file system module
has not been functional for many years, as reported by multiple users

Removing the code will reduce complexity for users -
the SCBR device has caused some misunderstandings in the past -
while eliminating code that has been flagged as insecure by SonarQube
2025-11-09 08:45:56 +01:00
BogDan Vatra 18bb9548a7 Use same notation as scsi2pi 2025-11-07 18:20:31 +01:00
BogDan Vatra a985fc83e4 Say hello to Streamer (tape) device support
Implements the mandatory and a few optional commands for tandberd see
https://bitsavers.org/pdf/tandbergData/TDC4100/6047-1_TDC-4100_SCSI-2_Interface_Functional_Specification_Aug1991.pdf
for more info.

Fixed #480
2025-11-07 07:43:21 +01:00
Daniel Markstedt 847c46e3c7 Update copyright year to 2025 in piscsi_util.cpp 2025-11-06 21:28:04 +01:00