Skip to content

Commit

Permalink
Issue PiSCSI#7 - implement a scsi monitor function for RaSCSI to log …
Browse files Browse the repository at this point in the history
…SCSI traffic (PiSCSI#46)

* PiSCSI#7 Re-merge scsimon functionality with latest master. The old scsimon branch was waaaaay too out of date

* PiSCSI#7 Re-merge scsimon functionality with latest master. The old scsimon branch was waaaaay too out of date

* Added libspdlog-dev as a required package

* Cleanup from master re-base

* Updated to use GCC version 8, to match the raspberry pi

Co-authored-by: akuker <akuker@gmail.com>
  • Loading branch information
akuker and akuker authored Oct 19, 2020
1 parent 3ddeac6 commit 1118c34
Show file tree
Hide file tree
Showing 18 changed files with 739 additions and 88 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ jobs:

steps:
- name: Install cross compile toolchain
run: sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
run: sudo apt-get install gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libspdlog-dev
- uses: actions/checkout@v2

- name: dump arm gcc version
run: arm-linux-gnueabihf-gcc -v
working-directory: ./src/raspberrypi

- name: dump native gcc version
run: gcc -v
working-directory: ./src/raspberrypi


- name: make standard
run: make all DEBUG=1 CONNECT_TYPE=STANDARD
working-directory: ./src/raspberrypi
Expand Down
2 changes: 1 addition & 1 deletion doc/rascsi.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ To create an empty, 100MB HD image, use the following command:
dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800

.SH SEE ALSO
rasctl(1), scsidump(1)
rasctl(1), scsimon(1)

Full documentation is available at: <https://www.github.com/akuker/RASCSI/wiki/>
18 changes: 8 additions & 10 deletions doc/rascsi_man_page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
!! ------ The native file is rascsi.1. Re-run 'make docs' after updating


rascsi(1) General Commands Manual rascsi(1)
rascsi(1) General Commands Manual rascsi(1)

NAME
rascsi - Emulates SCSI devices using the Raspberry Pi GPIO pins
Expand All @@ -13,10 +13,9 @@ SYNOPSIS
DESCRIPTION
rascsi Emulates SCSI devices using the Raspberry Pi GPIO pins.

In the arguments to RaSCSI, one or more SCSI (-IDn) or SASI (-HDn) devices can be specified. The number (n)
after the ID or HD idnetifier specifies the ID number for that device. For SCSI: The ID is limited from 0-7.
However, typically SCSI ID 7 is reserved for the "initiator" (the host computer).Note that SASI is considered
rare and only used on very early Sharp X68000 computers.
In the arguments to RaSCSI, one or more SCSI (-IDn) or SASI (-HDn) devices can be specified. The number (n) after the ID or HD idnetifier specifies the ID number for that device. For SCSI:
The ID is limited from 0-7. However, typically SCSI ID 7 is reserved for the "initiator" (the host computer).Note that SASI is considered rare and only used on very early Sharp X68000 com‐
puters.

RaSCSI will determin the type of device based upon the file extension of the FILE argument.
hdf: SASI Hard Disk image (XM6 SASI HD image - typically only used with X68000)
Expand All @@ -31,9 +30,8 @@ DESCRIPTION
For example, if you want to specify an Apple-compatible HD image on ID 0, you can use the following command:
sudo rascsi -ID0 /path/to/drive/hdimage.hda

Once RaSCSI starts, it will open a socket (port 6868) to allow external management commands. If another
process is using port 6868, RaSCSI will terminate, since it is likely another instance of RaSCSI. Once
RaSCSI has initialized, the rasctl utility can be used to send commands.
Once RaSCSI starts, it will open a socket (port 6868) to allow external management commands. If another process is using port 6868, RaSCSI will terminate, since it is likely another in‐
stance of RaSCSI. Once RaSCSI has initialized, the rasctl utility can be used to send commands.

To quit RaSCSI, press Control + C. If it is running in the background, you can kill it using an INT signal.

Expand Down Expand Up @@ -61,8 +59,8 @@ EXAMPLES
dd if=/dev/zero of=/path/to/newimage.hda bs=512 count=204800

SEE ALSO
rasctl(1), scsidump(1)
rasctl(1), scsimon(1)

Full documentation is available at: <https://www.github.com/akuker/RASCSI/wiki/>

rascsi(1)
rascsi(1)
2 changes: 1 addition & 1 deletion doc/rasctl.1
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ Request the RaSCSI process to attach a disk (assumed) to SCSI ID 0 with the cont
rasctl -i 0 -f HDIIMAGE0.HDS

.SH SEE ALSO
rascsi(1)
rascsi(1) scsimon(1)

Full documentation is available at: <https://www.github.com/akuker/RASCSI/wiki/>
21 changes: 8 additions & 13 deletions doc/rasctl_man_page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
!! ------ The native file is rasctl.1. Re-run 'make docs' after updating


rascsi(1) General Commands Manual rascsi(1)
rascsi(1) General Commands Manual rascsi(1)

NAME
rasctl - Sends management commands to the rascsi process
Expand All @@ -11,24 +11,21 @@ SYNOPSIS
rasctl -l | -i ID [-u UNIT] [-c CMD] [-t TYPE] [-f FILE]

DESCRIPTION
rasctl Sends commands to the rascsi process to make configuration adjustments at runtime or to check the sta‐
tus of the devices.
rasctl Sends commands to the rascsi process to make configuration adjustments at runtime or to check the status of the devices.

Either the -i or -l option should be specified at one time. Not both.

You do NOT need root privileges to use rasctl.

Note: The command and type arguments are case insensitive. Only the first letter of the command/type are
evaluated by the tool.
Note: The command and type arguments are case insensitive. Only the first letter of the command/type are evaluated by the tool.

OPTIONS
-l List all of the devices that are currently being emulated by RaSCSI, as well as their current status.

-i ID ID is the SCSI ID that you want to control. (0-7)

-u UNIT
Unit number (0 or 1). This will default to 0. This option is only used when there are multiple SCSI
devices on a shared SCSI controller. (This is not common)
Unit number (0 or 1). This will default to 0. This option is only used when there are multiple SCSI devices on a shared SCSI controller. (This is not common)

-c CMD Command is the operation being requested. options are:
attach: attach disk
Expand All @@ -40,8 +37,7 @@ OPTIONS
When the command is omited, rasctl will default to the 'attach' command

-t TYPE
Specifies the type of disk. If this disagrees with the file extension of the specified image, the TYPE
argument is ignored. Available drive types are:
Specifies the type of disk. If this disagrees with the file extension of the specified image, the TYPE argument is ignored. Available drive types are:
hd: Hard disk (SCSI or SASI)
mo: Magneto-Optical disk)
cd: CD-ROM
Expand All @@ -61,13 +57,12 @@ EXAMPLES
| 0 | 1 | SCHD | /home/pi/harddisk.hda
+----+----+------+-------------------------------------

Request the RaSCSI process to attach a disk (assumed) to SCSI ID 0 with the contents of the file system image
"HDIIMAGE0.HDS".
Request the RaSCSI process to attach a disk (assumed) to SCSI ID 0 with the contents of the file system image "HDIIMAGE0.HDS".
rasctl -i 0 -f HDIIMAGE0.HDS

SEE ALSO
rascsi(1)
rascsi(1) scsimon(1)

Full documentation is available at: <https://www.github.com/akuker/RASCSI/wiki/>

rascsi(1)
rascsi(1)
27 changes: 27 additions & 0 deletions doc/scsimon.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.TH scsimon 1
.SH NAME
scsimon \- Acts as a data capture tool for all traffic on the SCSI bus. Data is stored in a Value Change Dump (VCD) file.
.SH SYNOPSIS
.B scsimon
.SH DESCRIPTION
.B scsimon
Monitors all of the traffic on the SCSI bus, using a RaSCSI device. The data is cached in memory while the tool is running. A circular buffer is used so that only the most recent 1,000,000 transactions are stored. The tool will continue to run until the user presses CTRL-C, or the process receives a SIGINT signal.
.PP
The logged data is stored in a file called "log.vcd" in the current working directory from where scsimon was launched.

Currently, scsimon doesn't accept any agruments.

To quit scsimon, press Control + C.

.SH OPTIONS
.TP
None

.SH EXAMPLES
Launch scsimon to capture all SCSI traffic available to the RaSCSI hardware:
scsimon

.SH SEE ALSO
rasctl(1), rascsi(1)

Full documentation is available at: <https://www.github.com/akuker/RASCSI/wiki/>
35 changes: 35 additions & 0 deletions doc/scsimon_man_page.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
!! ------ THIS FILE IS AUTO_GENERATED! DO NOT MANUALLY UPDATE!!!
!! ------ The native file is scsimon.1. Re-run 'make docs' after updating


scsimon(1) General Commands Manual scsimon(1)

NAME
scsimon - Acts as a data capture tool for all traffic on the SCSI bus. Data is stored in a Value Change Dump (VCD) file.

SYNOPSIS
scsimon

DESCRIPTION
scsimon Monitors all of the traffic on the SCSI bus, using a RaSCSI device. The data is cached in memory while the tool is running. A circular buffer is used so that only the most recent 1,000,000
transactions are stored. The tool will continue to run until the user presses CTRL-C, or the process receives a SIGINT signal.

The logged data is stored in a file called "log.vcd" in the current working directory from where scsimon was launched.

Currently, scsimon doesn't accept any agruments.

To quit scsimon, press Control + C.

OPTIONS
None

EXAMPLES
Launch scsimon to capture all SCSI traffic available to the RaSCSI hardware:
scsimon

SEE ALSO
rasctl(1), rascsi(1)

Full documentation is available at: <https://www.github.com/akuker/RASCSI/wiki/>

scsimon(1)
1 change: 1 addition & 0 deletions src/raspberrypi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.cbp
*.layout
*.log
*.vcd
rascsi
scsimon
rasctl
Expand Down
41 changes: 25 additions & 16 deletions src/raspberrypi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ CXXFLAGS += -std=c++14 -iquote . -MD -MP
## STANDARD or FULLSPEC. The default is STANDARD
## * THIS IS TYPICALLY THE ONLY COMPILE OPTION YOU
## * NEED TO SPECIFY
# If its not specified, build for STANDARD configuration
CONNECT_TYPE ?= STANDARD
# If its not specified, build for FULLSPEC configuration
CONNECT_TYPE ?= FULLSPEC

ifdef CONNECT_TYPE
CFLAGS += -DCONNECT_TYPE_$(CONNECT_TYPE)
Expand Down Expand Up @@ -67,8 +67,7 @@ BINDIR := ./bin/$(shell echo $(CONNECT_TYPE) | tr '[:upper:]' '[:lower:]')
#BIN_ALL = $(RASCSI) $(RASCTL) $(RASDUMP) $(SASIDUMP) $(SCSIMON)
# Temporarily remove the RASDUMP and RASDUMP tools, since they're not needed
# for my specific use case. If you need them - add them back in!
BIN_ALL = $(BINDIR)/$(RASCSI) $(BINDIR)/$(RASCTL)

BIN_ALL = $(BINDIR)/$(RASCSI) $(BINDIR)/$(RASCTL) $(BINDIR)/$(SCSIMON)

SRC_RASCSI = \
rascsi.cpp \
Expand All @@ -83,6 +82,16 @@ SRC_RASCSI = \
SRC_RASCSI += $(shell find ./controllers -name '*.cpp')
SRC_RASCSI += $(shell find ./devices -name '*.cpp')

SRC_SCSIMON = \
scsimon.cpp \
scsi.cpp \
gpiobus.cpp \
filepath.cpp \
fileio.cpp
SRC_SCSIMON += $(shell find ./controllers -name '*.cpp')
SRC_SCSIMON += $(shell find ./devices -name '*.cpp')


SRC_RASCTL = \
rasctl.cpp
# rasctl_command.cpp
Expand Down Expand Up @@ -113,12 +122,12 @@ OBJ_RASDUMP := $(addprefix $(OBJDIR)/,$(notdir $(SRC_RASDUMP:%.cpp=%.o)))
OBJ_SASIDUMP := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SASIDUMP:%.cpp=%.o)))
OBJ_SCSIMON := $(addprefix $(OBJDIR)/,$(notdir $(SRC_SCSIMON:%.cpp=%.o)))
#OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP)
OBJ_ALL := $(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_RASDUMP) $(OBJ_SASIDUMP) $(OBJ_SCSIMON)


# The following will include all of the auto-generated dependency files (*.d)
# if they exist. This will trigger a rebuild of a source file if a header changes
ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_RASCSI) $(OBJ_RASCTL))
ALL_DEPS := $(patsubst %.o,%.d,$(OBJ_RASCSI) $(OBJ_RASCTL) $(OBJ_SCSIMON))
-include $(ALL_DEPS)

$(OBJDIR) $(BINDIR):
Expand All @@ -137,21 +146,21 @@ $(OBJDIR)/%.o: %.cpp | $(OBJDIR)
all: $(BIN_ALL) docs
ALL: all

docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt
docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt $(DOC_DIR)/scsimon_man_page.txt

$(BINDIR)/$(RASCSI): $(OBJ_RASCSI) | $(BINDIR)
$(CXX) -o $@ $(OBJ_RASCSI) -lpthread
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_RASCSI) -lpthread

$(BINDIR)/$(RASCTL): $(OBJ_RASCTL) $(BINDIR)
$(CXX) -o $@ $(OBJ_RASCTL)
$(BINDIR)/$(RASCTL): $(OBJ_RASCTL) | $(BINDIR)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_RASCTL)

$(RASDUMP): $(OBJ_RASDUMP) $(BINDIR)
$(CXX) -o $@ $(OBJ_RASDUMP)
$(BINDIR)/$(RASDUMP): $(OBJ_RASDUMP) | $(BINDIR)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_RASDUMP)

$(SASIDUMP): $(OBJ_SASIDUMP) $(BINDIR)
$(CXX) -o $@ $(OBJ_SASIDUMP)
$(BINDIR)/$(SASIDUMP): $(OBJ_SASIDUMP) | $(BINDIR)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SASIDUMP)

$(SCSIMON): $(OBJ_SCSIMON) $(BINDIR)
$(BINDIR)/$(SCSIMON): $(OBJ_SCSIMON) | $(BINDIR)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ_SCSIMON) -lpthread

## clean : Remove all of the object files, intermediate
Expand Down Expand Up @@ -180,7 +189,7 @@ run:
## * sudo systemctl enable rascsi
## * sudo systemctl start rascsi
.PHONY: install
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1 $(USR_LOCAL_BIN)/$(RASCTL) $(USR_LOCAL_BIN)/$(RASCSI) $(SYSTEMD_CONF) $(RSYSLOG_CONF) $(RSYSLOG_LOG)
install: $(MAN_PAGE_DIR)/rascsi.1 $(MAN_PAGE_DIR)/rasctl.1 $(MAN_PAGE_DIR)/scsimon.1 $(USR_LOCAL_BIN)/$(RASCTL) $(USR_LOCAL_BIN)/$(RASCSI) $(USR_LOCAL_BIN)/$(SCSIMON) $(SYSTEMD_CONF) $(RSYSLOG_CONF) $(RSYSLOG_LOG)
@echo "-- Done installing!"

$(USR_LOCAL_BIN)% : $(BINDIR)/%
Expand Down
4 changes: 2 additions & 2 deletions src/raspberrypi/controllers/sasidev_ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ BUS::phase_t FASTCALL SASIDEV::Process()
}

// Get bus information
ctrl.bus->Aquire();
((GPIOBUS*)ctrl.bus)->Aquire();

// For the monitor tool, we shouldn't need to reset. We're just logging information
// Reset
Expand Down Expand Up @@ -927,7 +927,7 @@ void FASTCALL SASIDEV::Error()
ASSERT(this);

// Get bus information
ctrl.bus->Aquire();
((GPIOBUS*)ctrl.bus)->Aquire();

// Reset check
if (ctrl.bus->GetRST()) {
Expand Down
4 changes: 2 additions & 2 deletions src/raspberrypi/controllers/scsidev_ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BUS::phase_t FASTCALL SCSIDEV::Process()
}

// Get bus information
ctrl.bus->Aquire();
((GPIOBUS*)ctrl.bus)->Aquire();

// Reset
if (ctrl.bus->GetRST()) {
Expand Down Expand Up @@ -488,7 +488,7 @@ void FASTCALL SCSIDEV::Error()
ASSERT(this);

// Get bus information
ctrl.bus->Aquire();
((GPIOBUS*)ctrl.bus)->Aquire();

// Reset check
if (ctrl.bus->GetRST()) {
Expand Down
Loading

0 comments on commit 1118c34

Please sign in to comment.