diff --git a/.github/workflows/build_code.yml b/.github/workflows/build_code.yml index b57bb592..5ed9acd7 100644 --- a/.github/workflows/build_code.yml +++ b/.github/workflows/build_code.yml @@ -32,11 +32,11 @@ jobs: - name: make standard run: make all -j6 CONNECT_TYPE=STANDARD CROSS_COMPILE=arm-linux-gnueabihf- - working-directory: ./src/raspberrypi + working-directory: ./cpp - name: make fullspec run: make all -j6 CONNECT_TYPE=FULLSPEC CROSS_COMPILE=arm-linux-gnueabihf- - working-directory: ./src/raspberrypi + working-directory: ./cpp # We need to tar the binary outputs to retain the executable # file permission. Currently, actions/upload-artifact only @@ -44,11 +44,11 @@ jobs: # This is workaround for https://github.com/actions/upload-artifact/issues/38 - name: tar binary outputs run: tar -czvf rascsi.tar.gz ./bin - working-directory: ./src/raspberrypi + working-directory: ./cpp - name: upload artifacts uses: actions/upload-artifact@v2 with: name: arm-binaries - path: ./src/raspberrypi/rascsi.tar.gz + path: ./cpp/rascsi.tar.gz diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 00b3718f..d690aa22 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-22.04 env: MAKEFLAGS: -j2 # Number of available processors - SOURCES: src/raspberrypi + SOURCES: cpp SONAR_SCANNER_VERSION: 4.7.0.2747 SONAR_SERVER_URL: "https://sonarcloud.io" BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed diff --git a/src/raspberrypi/.clang-format b/cpp/.clang-format similarity index 100% rename from src/raspberrypi/.clang-format rename to cpp/.clang-format diff --git a/src/raspberrypi/.gitignore b/cpp/.gitignore similarity index 100% rename from src/raspberrypi/.gitignore rename to cpp/.gitignore diff --git a/src/raspberrypi/.vscode/launch.json b/cpp/.vscode/launch.json similarity index 100% rename from src/raspberrypi/.vscode/launch.json rename to cpp/.vscode/launch.json diff --git a/src/raspberrypi/.vscode/settings.json b/cpp/.vscode/settings.json similarity index 100% rename from src/raspberrypi/.vscode/settings.json rename to cpp/.vscode/settings.json diff --git a/src/raspberrypi/.vscode/tasks.json b/cpp/.vscode/tasks.json similarity index 100% rename from src/raspberrypi/.vscode/tasks.json rename to cpp/.vscode/tasks.json diff --git a/src/raspberrypi/Makefile b/cpp/Makefile similarity index 98% rename from src/raspberrypi/Makefile rename to cpp/Makefile index fd90e8aa..77da468f 100644 --- a/src/raspberrypi/Makefile +++ b/cpp/Makefile @@ -65,7 +65,7 @@ RSYSLOG_LOG = /var/log/rascsi.log USR_LOCAL_BIN = /usr/local/bin MAN_PAGE_DIR = /usr/local/man/man1 -DOC_DIR = ../../doc +DOC_DIR = ../doc COVERAGE_DIR = ./coverage COVERAGE_FILE = rascsi.dat OS_FILES = ./os_integration @@ -178,7 +178,7 @@ coverage: test lcov: CXXFLAGS += --coverage lcov: test - lcov -q -c -d . --include '*/raspberrypi/*' -o $(COVERAGE_FILE) --exclude '*/test/*' --exclude '*/interfaces/*' --exclude '*/rascsi_interface.pb*' + lcov -q -c -d . --include '*/cpp/*' -o $(COVERAGE_FILE) --exclude '*/test/*' --exclude '*/interfaces/*' --exclude '*/rascsi_interface.pb*' genhtml -q -o $(COVERAGE_DIR) --legend $(COVERAGE_FILE) docs: $(DOC_DIR)/rascsi_man_page.txt $(DOC_DIR)/rasctl_man_page.txt $(DOC_DIR)/scsimon_man_page.txt diff --git a/src/raspberrypi/bus.cpp b/cpp/bus.cpp similarity index 100% rename from src/raspberrypi/bus.cpp rename to cpp/bus.cpp diff --git a/src/raspberrypi/bus.h b/cpp/bus.h similarity index 100% rename from src/raspberrypi/bus.h rename to cpp/bus.h diff --git a/src/raspberrypi/config.h b/cpp/config.h similarity index 100% rename from src/raspberrypi/config.h rename to cpp/config.h diff --git a/src/raspberrypi/controllers/abstract_controller.cpp b/cpp/controllers/abstract_controller.cpp similarity index 100% rename from src/raspberrypi/controllers/abstract_controller.cpp rename to cpp/controllers/abstract_controller.cpp diff --git a/src/raspberrypi/controllers/abstract_controller.h b/cpp/controllers/abstract_controller.h similarity index 100% rename from src/raspberrypi/controllers/abstract_controller.h rename to cpp/controllers/abstract_controller.h diff --git a/src/raspberrypi/controllers/controller_manager.cpp b/cpp/controllers/controller_manager.cpp similarity index 100% rename from src/raspberrypi/controllers/controller_manager.cpp rename to cpp/controllers/controller_manager.cpp diff --git a/src/raspberrypi/controllers/controller_manager.h b/cpp/controllers/controller_manager.h similarity index 100% rename from src/raspberrypi/controllers/controller_manager.h rename to cpp/controllers/controller_manager.h diff --git a/src/raspberrypi/controllers/phase_handler.h b/cpp/controllers/phase_handler.h similarity index 100% rename from src/raspberrypi/controllers/phase_handler.h rename to cpp/controllers/phase_handler.h diff --git a/src/raspberrypi/controllers/scsi_controller.cpp b/cpp/controllers/scsi_controller.cpp similarity index 100% rename from src/raspberrypi/controllers/scsi_controller.cpp rename to cpp/controllers/scsi_controller.cpp diff --git a/src/raspberrypi/controllers/scsi_controller.h b/cpp/controllers/scsi_controller.h similarity index 100% rename from src/raspberrypi/controllers/scsi_controller.h rename to cpp/controllers/scsi_controller.h diff --git a/src/raspberrypi/devices/cd_track.cpp b/cpp/devices/cd_track.cpp similarity index 100% rename from src/raspberrypi/devices/cd_track.cpp rename to cpp/devices/cd_track.cpp diff --git a/src/raspberrypi/devices/cd_track.h b/cpp/devices/cd_track.h similarity index 100% rename from src/raspberrypi/devices/cd_track.h rename to cpp/devices/cd_track.h diff --git a/src/raspberrypi/devices/cfilesystem.cpp b/cpp/devices/cfilesystem.cpp similarity index 100% rename from src/raspberrypi/devices/cfilesystem.cpp rename to cpp/devices/cfilesystem.cpp diff --git a/src/raspberrypi/devices/cfilesystem.h b/cpp/devices/cfilesystem.h similarity index 100% rename from src/raspberrypi/devices/cfilesystem.h rename to cpp/devices/cfilesystem.h diff --git a/src/raspberrypi/devices/ctapdriver.cpp b/cpp/devices/ctapdriver.cpp similarity index 100% rename from src/raspberrypi/devices/ctapdriver.cpp rename to cpp/devices/ctapdriver.cpp diff --git a/src/raspberrypi/devices/ctapdriver.h b/cpp/devices/ctapdriver.h similarity index 100% rename from src/raspberrypi/devices/ctapdriver.h rename to cpp/devices/ctapdriver.h diff --git a/src/raspberrypi/devices/device.cpp b/cpp/devices/device.cpp similarity index 100% rename from src/raspberrypi/devices/device.cpp rename to cpp/devices/device.cpp diff --git a/src/raspberrypi/devices/device.h b/cpp/devices/device.h similarity index 100% rename from src/raspberrypi/devices/device.h rename to cpp/devices/device.h diff --git a/src/raspberrypi/devices/device_factory.cpp b/cpp/devices/device_factory.cpp similarity index 100% rename from src/raspberrypi/devices/device_factory.cpp rename to cpp/devices/device_factory.cpp diff --git a/src/raspberrypi/devices/device_factory.h b/cpp/devices/device_factory.h similarity index 100% rename from src/raspberrypi/devices/device_factory.h rename to cpp/devices/device_factory.h diff --git a/src/raspberrypi/devices/disk.cpp b/cpp/devices/disk.cpp similarity index 100% rename from src/raspberrypi/devices/disk.cpp rename to cpp/devices/disk.cpp diff --git a/src/raspberrypi/devices/disk.h b/cpp/devices/disk.h similarity index 100% rename from src/raspberrypi/devices/disk.h rename to cpp/devices/disk.h diff --git a/src/raspberrypi/devices/disk_cache.cpp b/cpp/devices/disk_cache.cpp similarity index 100% rename from src/raspberrypi/devices/disk_cache.cpp rename to cpp/devices/disk_cache.cpp diff --git a/src/raspberrypi/devices/disk_cache.h b/cpp/devices/disk_cache.h similarity index 100% rename from src/raspberrypi/devices/disk_cache.h rename to cpp/devices/disk_cache.h diff --git a/src/raspberrypi/devices/disk_track.cpp b/cpp/devices/disk_track.cpp similarity index 100% rename from src/raspberrypi/devices/disk_track.cpp rename to cpp/devices/disk_track.cpp diff --git a/src/raspberrypi/devices/disk_track.h b/cpp/devices/disk_track.h similarity index 100% rename from src/raspberrypi/devices/disk_track.h rename to cpp/devices/disk_track.h diff --git a/src/raspberrypi/devices/dispatcher.h b/cpp/devices/dispatcher.h similarity index 100% rename from src/raspberrypi/devices/dispatcher.h rename to cpp/devices/dispatcher.h diff --git a/src/raspberrypi/devices/host_services.cpp b/cpp/devices/host_services.cpp similarity index 100% rename from src/raspberrypi/devices/host_services.cpp rename to cpp/devices/host_services.cpp diff --git a/src/raspberrypi/devices/host_services.h b/cpp/devices/host_services.h similarity index 100% rename from src/raspberrypi/devices/host_services.h rename to cpp/devices/host_services.h diff --git a/src/raspberrypi/devices/interfaces/scsi_block_commands.h b/cpp/devices/interfaces/scsi_block_commands.h similarity index 100% rename from src/raspberrypi/devices/interfaces/scsi_block_commands.h rename to cpp/devices/interfaces/scsi_block_commands.h diff --git a/src/raspberrypi/devices/interfaces/scsi_mmc_commands.h b/cpp/devices/interfaces/scsi_mmc_commands.h similarity index 100% rename from src/raspberrypi/devices/interfaces/scsi_mmc_commands.h rename to cpp/devices/interfaces/scsi_mmc_commands.h diff --git a/src/raspberrypi/devices/interfaces/scsi_primary_commands.h b/cpp/devices/interfaces/scsi_primary_commands.h similarity index 100% rename from src/raspberrypi/devices/interfaces/scsi_primary_commands.h rename to cpp/devices/interfaces/scsi_primary_commands.h diff --git a/src/raspberrypi/devices/interfaces/scsi_printer_commands.h b/cpp/devices/interfaces/scsi_printer_commands.h similarity index 100% rename from src/raspberrypi/devices/interfaces/scsi_printer_commands.h rename to cpp/devices/interfaces/scsi_printer_commands.h diff --git a/src/raspberrypi/devices/mode_page_device.cpp b/cpp/devices/mode_page_device.cpp similarity index 100% rename from src/raspberrypi/devices/mode_page_device.cpp rename to cpp/devices/mode_page_device.cpp diff --git a/src/raspberrypi/devices/mode_page_device.h b/cpp/devices/mode_page_device.h similarity index 100% rename from src/raspberrypi/devices/mode_page_device.h rename to cpp/devices/mode_page_device.h diff --git a/src/raspberrypi/devices/primary_device.cpp b/cpp/devices/primary_device.cpp similarity index 100% rename from src/raspberrypi/devices/primary_device.cpp rename to cpp/devices/primary_device.cpp diff --git a/src/raspberrypi/devices/primary_device.h b/cpp/devices/primary_device.h similarity index 100% rename from src/raspberrypi/devices/primary_device.h rename to cpp/devices/primary_device.h diff --git a/src/raspberrypi/devices/scsi_command_util.cpp b/cpp/devices/scsi_command_util.cpp similarity index 100% rename from src/raspberrypi/devices/scsi_command_util.cpp rename to cpp/devices/scsi_command_util.cpp diff --git a/src/raspberrypi/devices/scsi_command_util.h b/cpp/devices/scsi_command_util.h similarity index 100% rename from src/raspberrypi/devices/scsi_command_util.h rename to cpp/devices/scsi_command_util.h diff --git a/src/raspberrypi/devices/scsi_daynaport.cpp b/cpp/devices/scsi_daynaport.cpp similarity index 100% rename from src/raspberrypi/devices/scsi_daynaport.cpp rename to cpp/devices/scsi_daynaport.cpp diff --git a/src/raspberrypi/devices/scsi_daynaport.h b/cpp/devices/scsi_daynaport.h similarity index 100% rename from src/raspberrypi/devices/scsi_daynaport.h rename to cpp/devices/scsi_daynaport.h diff --git a/src/raspberrypi/devices/scsi_host_bridge.cpp b/cpp/devices/scsi_host_bridge.cpp similarity index 100% rename from src/raspberrypi/devices/scsi_host_bridge.cpp rename to cpp/devices/scsi_host_bridge.cpp diff --git a/src/raspberrypi/devices/scsi_host_bridge.h b/cpp/devices/scsi_host_bridge.h similarity index 100% rename from src/raspberrypi/devices/scsi_host_bridge.h rename to cpp/devices/scsi_host_bridge.h diff --git a/src/raspberrypi/devices/scsi_printer.cpp b/cpp/devices/scsi_printer.cpp similarity index 100% rename from src/raspberrypi/devices/scsi_printer.cpp rename to cpp/devices/scsi_printer.cpp diff --git a/src/raspberrypi/devices/scsi_printer.h b/cpp/devices/scsi_printer.h similarity index 100% rename from src/raspberrypi/devices/scsi_printer.h rename to cpp/devices/scsi_printer.h diff --git a/src/raspberrypi/devices/scsicd.cpp b/cpp/devices/scsicd.cpp similarity index 100% rename from src/raspberrypi/devices/scsicd.cpp rename to cpp/devices/scsicd.cpp diff --git a/src/raspberrypi/devices/scsicd.h b/cpp/devices/scsicd.h similarity index 100% rename from src/raspberrypi/devices/scsicd.h rename to cpp/devices/scsicd.h diff --git a/src/raspberrypi/devices/scsihd.cpp b/cpp/devices/scsihd.cpp similarity index 100% rename from src/raspberrypi/devices/scsihd.cpp rename to cpp/devices/scsihd.cpp diff --git a/src/raspberrypi/devices/scsihd.h b/cpp/devices/scsihd.h similarity index 100% rename from src/raspberrypi/devices/scsihd.h rename to cpp/devices/scsihd.h diff --git a/src/raspberrypi/devices/scsihd_nec.cpp b/cpp/devices/scsihd_nec.cpp similarity index 100% rename from src/raspberrypi/devices/scsihd_nec.cpp rename to cpp/devices/scsihd_nec.cpp diff --git a/src/raspberrypi/devices/scsihd_nec.h b/cpp/devices/scsihd_nec.h similarity index 100% rename from src/raspberrypi/devices/scsihd_nec.h rename to cpp/devices/scsihd_nec.h diff --git a/src/raspberrypi/devices/scsimo.cpp b/cpp/devices/scsimo.cpp similarity index 100% rename from src/raspberrypi/devices/scsimo.cpp rename to cpp/devices/scsimo.cpp diff --git a/src/raspberrypi/devices/scsimo.h b/cpp/devices/scsimo.h similarity index 100% rename from src/raspberrypi/devices/scsimo.h rename to cpp/devices/scsimo.h diff --git a/src/raspberrypi/devices/storage_device.cpp b/cpp/devices/storage_device.cpp similarity index 100% rename from src/raspberrypi/devices/storage_device.cpp rename to cpp/devices/storage_device.cpp diff --git a/src/raspberrypi/devices/storage_device.h b/cpp/devices/storage_device.h similarity index 100% rename from src/raspberrypi/devices/storage_device.h rename to cpp/devices/storage_device.h diff --git a/src/raspberrypi/hal/gpiobus.cpp b/cpp/hal/gpiobus.cpp similarity index 100% rename from src/raspberrypi/hal/gpiobus.cpp rename to cpp/hal/gpiobus.cpp diff --git a/src/raspberrypi/hal/gpiobus.h b/cpp/hal/gpiobus.h similarity index 100% rename from src/raspberrypi/hal/gpiobus.h rename to cpp/hal/gpiobus.h diff --git a/src/raspberrypi/hal/gpiobus_aibom.h b/cpp/hal/gpiobus_aibom.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_aibom.h rename to cpp/hal/gpiobus_aibom.h diff --git a/src/raspberrypi/hal/gpiobus_allwinner.cpp b/cpp/hal/gpiobus_allwinner.cpp similarity index 100% rename from src/raspberrypi/hal/gpiobus_allwinner.cpp rename to cpp/hal/gpiobus_allwinner.cpp diff --git a/src/raspberrypi/hal/gpiobus_allwinner.h b/cpp/hal/gpiobus_allwinner.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_allwinner.h rename to cpp/hal/gpiobus_allwinner.h diff --git a/src/raspberrypi/hal/gpiobus_factory.cpp b/cpp/hal/gpiobus_factory.cpp similarity index 100% rename from src/raspberrypi/hal/gpiobus_factory.cpp rename to cpp/hal/gpiobus_factory.cpp diff --git a/src/raspberrypi/hal/gpiobus_factory.h b/cpp/hal/gpiobus_factory.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_factory.h rename to cpp/hal/gpiobus_factory.h diff --git a/src/raspberrypi/hal/gpiobus_fullspec.h b/cpp/hal/gpiobus_fullspec.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_fullspec.h rename to cpp/hal/gpiobus_fullspec.h diff --git a/src/raspberrypi/hal/gpiobus_gamernium.h b/cpp/hal/gpiobus_gamernium.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_gamernium.h rename to cpp/hal/gpiobus_gamernium.h diff --git a/src/raspberrypi/hal/gpiobus_raspberry.cpp b/cpp/hal/gpiobus_raspberry.cpp similarity index 100% rename from src/raspberrypi/hal/gpiobus_raspberry.cpp rename to cpp/hal/gpiobus_raspberry.cpp diff --git a/src/raspberrypi/hal/gpiobus_raspberry.h b/cpp/hal/gpiobus_raspberry.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_raspberry.h rename to cpp/hal/gpiobus_raspberry.h diff --git a/src/raspberrypi/hal/gpiobus_standard.h b/cpp/hal/gpiobus_standard.h similarity index 100% rename from src/raspberrypi/hal/gpiobus_standard.h rename to cpp/hal/gpiobus_standard.h diff --git a/src/raspberrypi/hal/sbc_version.cpp b/cpp/hal/sbc_version.cpp similarity index 100% rename from src/raspberrypi/hal/sbc_version.cpp rename to cpp/hal/sbc_version.cpp diff --git a/src/raspberrypi/hal/sbc_version.h b/cpp/hal/sbc_version.h similarity index 100% rename from src/raspberrypi/hal/sbc_version.h rename to cpp/hal/sbc_version.h diff --git a/src/raspberrypi/hal/systimer.cpp b/cpp/hal/systimer.cpp similarity index 100% rename from src/raspberrypi/hal/systimer.cpp rename to cpp/hal/systimer.cpp diff --git a/src/raspberrypi/hal/systimer.h b/cpp/hal/systimer.h similarity index 100% rename from src/raspberrypi/hal/systimer.h rename to cpp/hal/systimer.h diff --git a/src/raspberrypi/hal/systimer_allwinner.cpp b/cpp/hal/systimer_allwinner.cpp similarity index 100% rename from src/raspberrypi/hal/systimer_allwinner.cpp rename to cpp/hal/systimer_allwinner.cpp diff --git a/src/raspberrypi/hal/systimer_allwinner.h b/cpp/hal/systimer_allwinner.h similarity index 100% rename from src/raspberrypi/hal/systimer_allwinner.h rename to cpp/hal/systimer_allwinner.h diff --git a/src/raspberrypi/hal/systimer_raspberry.cpp b/cpp/hal/systimer_raspberry.cpp similarity index 100% rename from src/raspberrypi/hal/systimer_raspberry.cpp rename to cpp/hal/systimer_raspberry.cpp diff --git a/src/raspberrypi/hal/systimer_raspberry.h b/cpp/hal/systimer_raspberry.h similarity index 100% rename from src/raspberrypi/hal/systimer_raspberry.h rename to cpp/hal/systimer_raspberry.h diff --git a/src/raspberrypi/launch_sudo.sh b/cpp/launch_sudo.sh similarity index 100% rename from src/raspberrypi/launch_sudo.sh rename to cpp/launch_sudo.sh diff --git a/src/raspberrypi/log.h b/cpp/log.h similarity index 100% rename from src/raspberrypi/log.h rename to cpp/log.h diff --git a/src/raspberrypi/monitor/data_sample.cpp b/cpp/monitor/data_sample.cpp similarity index 100% rename from src/raspberrypi/monitor/data_sample.cpp rename to cpp/monitor/data_sample.cpp diff --git a/src/raspberrypi/monitor/data_sample.h b/cpp/monitor/data_sample.h similarity index 100% rename from src/raspberrypi/monitor/data_sample.h rename to cpp/monitor/data_sample.h diff --git a/src/raspberrypi/monitor/sm_html_report.cpp b/cpp/monitor/sm_html_report.cpp similarity index 100% rename from src/raspberrypi/monitor/sm_html_report.cpp rename to cpp/monitor/sm_html_report.cpp diff --git a/src/raspberrypi/monitor/sm_json_report.cpp b/cpp/monitor/sm_json_report.cpp similarity index 100% rename from src/raspberrypi/monitor/sm_json_report.cpp rename to cpp/monitor/sm_json_report.cpp diff --git a/src/raspberrypi/monitor/sm_reports.h b/cpp/monitor/sm_reports.h similarity index 100% rename from src/raspberrypi/monitor/sm_reports.h rename to cpp/monitor/sm_reports.h diff --git a/src/raspberrypi/monitor/sm_vcd_report.cpp b/cpp/monitor/sm_vcd_report.cpp similarity index 100% rename from src/raspberrypi/monitor/sm_vcd_report.cpp rename to cpp/monitor/sm_vcd_report.cpp diff --git a/src/raspberrypi/os.h b/cpp/os.h similarity index 100% rename from src/raspberrypi/os.h rename to cpp/os.h diff --git a/src/raspberrypi/os_integration/dhcpcd.conf.patch b/cpp/os_integration/dhcpcd.conf.patch similarity index 100% rename from src/raspberrypi/os_integration/dhcpcd.conf.patch rename to cpp/os_integration/dhcpcd.conf.patch diff --git a/src/raspberrypi/os_integration/rascsi.conf b/cpp/os_integration/rascsi.conf similarity index 100% rename from src/raspberrypi/os_integration/rascsi.conf rename to cpp/os_integration/rascsi.conf diff --git a/src/raspberrypi/os_integration/rascsi.service b/cpp/os_integration/rascsi.service similarity index 100% rename from src/raspberrypi/os_integration/rascsi.service rename to cpp/os_integration/rascsi.service diff --git a/src/raspberrypi/os_integration/rascsi_bridge b/cpp/os_integration/rascsi_bridge similarity index 100% rename from src/raspberrypi/os_integration/rascsi_bridge rename to cpp/os_integration/rascsi_bridge diff --git a/src/raspberrypi/protobuf_serializer.cpp b/cpp/protobuf_serializer.cpp similarity index 100% rename from src/raspberrypi/protobuf_serializer.cpp rename to cpp/protobuf_serializer.cpp diff --git a/src/raspberrypi/protobuf_serializer.h b/cpp/protobuf_serializer.h similarity index 100% rename from src/raspberrypi/protobuf_serializer.h rename to cpp/protobuf_serializer.h diff --git a/src/raspberrypi/protobuf_util.cpp b/cpp/protobuf_util.cpp similarity index 100% rename from src/raspberrypi/protobuf_util.cpp rename to cpp/protobuf_util.cpp diff --git a/src/raspberrypi/protobuf_util.h b/cpp/protobuf_util.h similarity index 100% rename from src/raspberrypi/protobuf_util.h rename to cpp/protobuf_util.h diff --git a/src/raspberrypi/rascsi.cpp b/cpp/rascsi.cpp similarity index 100% rename from src/raspberrypi/rascsi.cpp rename to cpp/rascsi.cpp diff --git a/src/raspberrypi/rascsi/command_context.cpp b/cpp/rascsi/command_context.cpp similarity index 100% rename from src/raspberrypi/rascsi/command_context.cpp rename to cpp/rascsi/command_context.cpp diff --git a/src/raspberrypi/rascsi/command_context.h b/cpp/rascsi/command_context.h similarity index 100% rename from src/raspberrypi/rascsi/command_context.h rename to cpp/rascsi/command_context.h diff --git a/src/raspberrypi/rascsi/localizer.cpp b/cpp/rascsi/localizer.cpp similarity index 100% rename from src/raspberrypi/rascsi/localizer.cpp rename to cpp/rascsi/localizer.cpp diff --git a/src/raspberrypi/rascsi/localizer.h b/cpp/rascsi/localizer.h similarity index 100% rename from src/raspberrypi/rascsi/localizer.h rename to cpp/rascsi/localizer.h diff --git a/src/raspberrypi/rascsi/rascsi_executor.cpp b/cpp/rascsi/rascsi_executor.cpp similarity index 100% rename from src/raspberrypi/rascsi/rascsi_executor.cpp rename to cpp/rascsi/rascsi_executor.cpp diff --git a/src/raspberrypi/rascsi/rascsi_executor.h b/cpp/rascsi/rascsi_executor.h similarity index 100% rename from src/raspberrypi/rascsi/rascsi_executor.h rename to cpp/rascsi/rascsi_executor.h diff --git a/src/raspberrypi/rascsi/rascsi_image.cpp b/cpp/rascsi/rascsi_image.cpp similarity index 100% rename from src/raspberrypi/rascsi/rascsi_image.cpp rename to cpp/rascsi/rascsi_image.cpp diff --git a/src/raspberrypi/rascsi/rascsi_image.h b/cpp/rascsi/rascsi_image.h similarity index 100% rename from src/raspberrypi/rascsi/rascsi_image.h rename to cpp/rascsi/rascsi_image.h diff --git a/src/raspberrypi/rascsi/rascsi_response.cpp b/cpp/rascsi/rascsi_response.cpp similarity index 100% rename from src/raspberrypi/rascsi/rascsi_response.cpp rename to cpp/rascsi/rascsi_response.cpp diff --git a/src/raspberrypi/rascsi/rascsi_response.h b/cpp/rascsi/rascsi_response.h similarity index 100% rename from src/raspberrypi/rascsi/rascsi_response.h rename to cpp/rascsi/rascsi_response.h diff --git a/src/raspberrypi/rascsi/rascsi_service.cpp b/cpp/rascsi/rascsi_service.cpp similarity index 100% rename from src/raspberrypi/rascsi/rascsi_service.cpp rename to cpp/rascsi/rascsi_service.cpp diff --git a/src/raspberrypi/rascsi/rascsi_service.h b/cpp/rascsi/rascsi_service.h similarity index 100% rename from src/raspberrypi/rascsi/rascsi_service.h rename to cpp/rascsi/rascsi_service.h diff --git a/src/raspberrypi/rascsi_exceptions.h b/cpp/rascsi_exceptions.h similarity index 100% rename from src/raspberrypi/rascsi_exceptions.h rename to cpp/rascsi_exceptions.h diff --git a/src/raspberrypi/rascsi_interface.proto b/cpp/rascsi_interface.proto similarity index 100% rename from src/raspberrypi/rascsi_interface.proto rename to cpp/rascsi_interface.proto diff --git a/src/raspberrypi/rascsi_version.cpp b/cpp/rascsi_version.cpp similarity index 100% rename from src/raspberrypi/rascsi_version.cpp rename to cpp/rascsi_version.cpp diff --git a/src/raspberrypi/rascsi_version.h b/cpp/rascsi_version.h similarity index 100% rename from src/raspberrypi/rascsi_version.h rename to cpp/rascsi_version.h diff --git a/src/raspberrypi/rasctl.cpp b/cpp/rasctl.cpp similarity index 100% rename from src/raspberrypi/rasctl.cpp rename to cpp/rasctl.cpp diff --git a/src/raspberrypi/rasctl/rasctl_commands.cpp b/cpp/rasctl/rasctl_commands.cpp similarity index 100% rename from src/raspberrypi/rasctl/rasctl_commands.cpp rename to cpp/rasctl/rasctl_commands.cpp diff --git a/src/raspberrypi/rasctl/rasctl_commands.h b/cpp/rasctl/rasctl_commands.h similarity index 100% rename from src/raspberrypi/rasctl/rasctl_commands.h rename to cpp/rasctl/rasctl_commands.h diff --git a/src/raspberrypi/rasctl/rasctl_display.cpp b/cpp/rasctl/rasctl_display.cpp similarity index 100% rename from src/raspberrypi/rasctl/rasctl_display.cpp rename to cpp/rasctl/rasctl_display.cpp diff --git a/src/raspberrypi/rasctl/rasctl_display.h b/cpp/rasctl/rasctl_display.h similarity index 100% rename from src/raspberrypi/rasctl/rasctl_display.h rename to cpp/rasctl/rasctl_display.h diff --git a/src/raspberrypi/rasctl/rasctl_parser.cpp b/cpp/rasctl/rasctl_parser.cpp similarity index 100% rename from src/raspberrypi/rasctl/rasctl_parser.cpp rename to cpp/rasctl/rasctl_parser.cpp diff --git a/src/raspberrypi/rasctl/rasctl_parser.h b/cpp/rasctl/rasctl_parser.h similarity index 100% rename from src/raspberrypi/rasctl/rasctl_parser.h rename to cpp/rasctl/rasctl_parser.h diff --git a/src/raspberrypi/rasdump.cpp b/cpp/rasdump.cpp similarity index 100% rename from src/raspberrypi/rasdump.cpp rename to cpp/rasdump.cpp diff --git a/src/raspberrypi/rasdump_fileio.cpp b/cpp/rasdump_fileio.cpp similarity index 100% rename from src/raspberrypi/rasdump_fileio.cpp rename to cpp/rasdump_fileio.cpp diff --git a/src/raspberrypi/rasdump_fileio.h b/cpp/rasdump_fileio.h similarity index 100% rename from src/raspberrypi/rasdump_fileio.h rename to cpp/rasdump_fileio.h diff --git a/src/raspberrypi/rasutil.cpp b/cpp/rasutil.cpp similarity index 100% rename from src/raspberrypi/rasutil.cpp rename to cpp/rasutil.cpp diff --git a/src/raspberrypi/rasutil.h b/cpp/rasutil.h similarity index 100% rename from src/raspberrypi/rasutil.h rename to cpp/rasutil.h diff --git a/src/raspberrypi/scsi.h b/cpp/scsi.h similarity index 100% rename from src/raspberrypi/scsi.h rename to cpp/scsi.h diff --git a/src/raspberrypi/scsimon.cpp b/cpp/scsimon.cpp similarity index 100% rename from src/raspberrypi/scsimon.cpp rename to cpp/scsimon.cpp diff --git a/src/raspberrypi/test/abstract_controller_test.cpp b/cpp/test/abstract_controller_test.cpp similarity index 100% rename from src/raspberrypi/test/abstract_controller_test.cpp rename to cpp/test/abstract_controller_test.cpp diff --git a/src/raspberrypi/test/bus_test.cpp b/cpp/test/bus_test.cpp similarity index 100% rename from src/raspberrypi/test/bus_test.cpp rename to cpp/test/bus_test.cpp diff --git a/src/raspberrypi/test/command_context_test.cpp b/cpp/test/command_context_test.cpp similarity index 100% rename from src/raspberrypi/test/command_context_test.cpp rename to cpp/test/command_context_test.cpp diff --git a/src/raspberrypi/test/controller_manager_test.cpp b/cpp/test/controller_manager_test.cpp similarity index 100% rename from src/raspberrypi/test/controller_manager_test.cpp rename to cpp/test/controller_manager_test.cpp diff --git a/src/raspberrypi/test/ctapdriver_test.cpp b/cpp/test/ctapdriver_test.cpp similarity index 100% rename from src/raspberrypi/test/ctapdriver_test.cpp rename to cpp/test/ctapdriver_test.cpp diff --git a/src/raspberrypi/test/device_factory_test.cpp b/cpp/test/device_factory_test.cpp similarity index 100% rename from src/raspberrypi/test/device_factory_test.cpp rename to cpp/test/device_factory_test.cpp diff --git a/src/raspberrypi/test/device_test.cpp b/cpp/test/device_test.cpp similarity index 100% rename from src/raspberrypi/test/device_test.cpp rename to cpp/test/device_test.cpp diff --git a/src/raspberrypi/test/disk_test.cpp b/cpp/test/disk_test.cpp similarity index 100% rename from src/raspberrypi/test/disk_test.cpp rename to cpp/test/disk_test.cpp diff --git a/src/raspberrypi/test/gpiobus_test.cpp b/cpp/test/gpiobus_test.cpp similarity index 100% rename from src/raspberrypi/test/gpiobus_test.cpp rename to cpp/test/gpiobus_test.cpp diff --git a/src/raspberrypi/test/host_services_test.cpp b/cpp/test/host_services_test.cpp similarity index 100% rename from src/raspberrypi/test/host_services_test.cpp rename to cpp/test/host_services_test.cpp diff --git a/src/raspberrypi/test/localizer_test.cpp b/cpp/test/localizer_test.cpp similarity index 100% rename from src/raspberrypi/test/localizer_test.cpp rename to cpp/test/localizer_test.cpp diff --git a/src/raspberrypi/test/mocks.h b/cpp/test/mocks.h similarity index 100% rename from src/raspberrypi/test/mocks.h rename to cpp/test/mocks.h diff --git a/src/raspberrypi/test/mode_page_device_test.cpp b/cpp/test/mode_page_device_test.cpp similarity index 100% rename from src/raspberrypi/test/mode_page_device_test.cpp rename to cpp/test/mode_page_device_test.cpp diff --git a/src/raspberrypi/test/phase_handler_test.cpp b/cpp/test/phase_handler_test.cpp similarity index 100% rename from src/raspberrypi/test/phase_handler_test.cpp rename to cpp/test/phase_handler_test.cpp diff --git a/src/raspberrypi/test/primary_device_test.cpp b/cpp/test/primary_device_test.cpp similarity index 100% rename from src/raspberrypi/test/primary_device_test.cpp rename to cpp/test/primary_device_test.cpp diff --git a/src/raspberrypi/test/protobuf_serializer_test.cpp b/cpp/test/protobuf_serializer_test.cpp similarity index 100% rename from src/raspberrypi/test/protobuf_serializer_test.cpp rename to cpp/test/protobuf_serializer_test.cpp diff --git a/src/raspberrypi/test/protobuf_util_test.cpp b/cpp/test/protobuf_util_test.cpp similarity index 100% rename from src/raspberrypi/test/protobuf_util_test.cpp rename to cpp/test/protobuf_util_test.cpp diff --git a/src/raspberrypi/test/rascsi_exceptions_test.cpp b/cpp/test/rascsi_exceptions_test.cpp similarity index 100% rename from src/raspberrypi/test/rascsi_exceptions_test.cpp rename to cpp/test/rascsi_exceptions_test.cpp diff --git a/src/raspberrypi/test/rascsi_executor_test.cpp b/cpp/test/rascsi_executor_test.cpp similarity index 100% rename from src/raspberrypi/test/rascsi_executor_test.cpp rename to cpp/test/rascsi_executor_test.cpp diff --git a/src/raspberrypi/test/rascsi_image_test.cpp b/cpp/test/rascsi_image_test.cpp similarity index 100% rename from src/raspberrypi/test/rascsi_image_test.cpp rename to cpp/test/rascsi_image_test.cpp diff --git a/src/raspberrypi/test/rascsi_response_test.cpp b/cpp/test/rascsi_response_test.cpp similarity index 100% rename from src/raspberrypi/test/rascsi_response_test.cpp rename to cpp/test/rascsi_response_test.cpp diff --git a/src/raspberrypi/test/rascsi_service_test.cpp b/cpp/test/rascsi_service_test.cpp similarity index 100% rename from src/raspberrypi/test/rascsi_service_test.cpp rename to cpp/test/rascsi_service_test.cpp diff --git a/src/raspberrypi/test/rasctl_commands_test.cpp b/cpp/test/rasctl_commands_test.cpp similarity index 100% rename from src/raspberrypi/test/rasctl_commands_test.cpp rename to cpp/test/rasctl_commands_test.cpp diff --git a/src/raspberrypi/test/rasctl_display_test.cpp b/cpp/test/rasctl_display_test.cpp similarity index 100% rename from src/raspberrypi/test/rasctl_display_test.cpp rename to cpp/test/rasctl_display_test.cpp diff --git a/src/raspberrypi/test/rasctl_parser_test.cpp b/cpp/test/rasctl_parser_test.cpp similarity index 100% rename from src/raspberrypi/test/rasctl_parser_test.cpp rename to cpp/test/rasctl_parser_test.cpp diff --git a/src/raspberrypi/test/rasutil_test.cpp b/cpp/test/rasutil_test.cpp similarity index 100% rename from src/raspberrypi/test/rasutil_test.cpp rename to cpp/test/rasutil_test.cpp diff --git a/src/raspberrypi/test/scsi_command_util_test.cpp b/cpp/test/scsi_command_util_test.cpp similarity index 100% rename from src/raspberrypi/test/scsi_command_util_test.cpp rename to cpp/test/scsi_command_util_test.cpp diff --git a/src/raspberrypi/test/scsi_controller_test.cpp b/cpp/test/scsi_controller_test.cpp similarity index 100% rename from src/raspberrypi/test/scsi_controller_test.cpp rename to cpp/test/scsi_controller_test.cpp diff --git a/src/raspberrypi/test/scsi_daynaport_test.cpp b/cpp/test/scsi_daynaport_test.cpp similarity index 100% rename from src/raspberrypi/test/scsi_daynaport_test.cpp rename to cpp/test/scsi_daynaport_test.cpp diff --git a/src/raspberrypi/test/scsi_host_bridge_test.cpp b/cpp/test/scsi_host_bridge_test.cpp similarity index 100% rename from src/raspberrypi/test/scsi_host_bridge_test.cpp rename to cpp/test/scsi_host_bridge_test.cpp diff --git a/src/raspberrypi/test/scsi_printer_test.cpp b/cpp/test/scsi_printer_test.cpp similarity index 100% rename from src/raspberrypi/test/scsi_printer_test.cpp rename to cpp/test/scsi_printer_test.cpp diff --git a/src/raspberrypi/test/scsicd_test.cpp b/cpp/test/scsicd_test.cpp similarity index 100% rename from src/raspberrypi/test/scsicd_test.cpp rename to cpp/test/scsicd_test.cpp diff --git a/src/raspberrypi/test/scsihd_nec_test.cpp b/cpp/test/scsihd_nec_test.cpp similarity index 100% rename from src/raspberrypi/test/scsihd_nec_test.cpp rename to cpp/test/scsihd_nec_test.cpp diff --git a/src/raspberrypi/test/scsihd_test.cpp b/cpp/test/scsihd_test.cpp similarity index 100% rename from src/raspberrypi/test/scsihd_test.cpp rename to cpp/test/scsihd_test.cpp diff --git a/src/raspberrypi/test/scsimo_test.cpp b/cpp/test/scsimo_test.cpp similarity index 100% rename from src/raspberrypi/test/scsimo_test.cpp rename to cpp/test/scsimo_test.cpp diff --git a/src/raspberrypi/test/storage_device_test.cpp b/cpp/test/storage_device_test.cpp similarity index 100% rename from src/raspberrypi/test/storage_device_test.cpp rename to cpp/test/storage_device_test.cpp diff --git a/src/raspberrypi/test/test_setup.cpp b/cpp/test/test_setup.cpp similarity index 100% rename from src/raspberrypi/test/test_setup.cpp rename to cpp/test/test_setup.cpp diff --git a/src/raspberrypi/test/test_shared.cpp b/cpp/test/test_shared.cpp similarity index 100% rename from src/raspberrypi/test/test_shared.cpp rename to cpp/test/test_shared.cpp diff --git a/src/raspberrypi/test/test_shared.h b/cpp/test/test_shared.h similarity index 100% rename from src/raspberrypi/test/test_shared.h rename to cpp/test/test_shared.h diff --git a/easyinstall.sh b/easyinstall.sh index e12324d9..b352ccbb 100755 --- a/easyinstall.sh +++ b/easyinstall.sh @@ -48,6 +48,7 @@ echo -e $logo USER=$(whoami) BASE=$(dirname "$(readlink -f "${0}")") +CPP_PATH="$BASE/cpp" VIRTUAL_DRIVER_PATH="$HOME/images" CFG_PATH="$HOME/.config/rascsi" WEB_INSTALL_PATH="$BASE/python/web" @@ -132,7 +133,7 @@ function cachePipPackages(){ # compile the RaSCSI binaries function compileRaScsi() { - cd "$BASE/src/raspberrypi" || exit 1 + cd "$CPP_PATH" || exit 1 echo "Compiling with ${CORES:-1} simultaneous cores..." make clean /etc/network/interfaces.d/rascsi_bridge' + sudo bash -c 'sed s/eth0/'"$LAN_INTERFACE"'/g '"$CPP_PATH"'/os_integration/rascsi_bridge > /etc/network/interfaces.d/rascsi_bridge' echo "Modified /etc/network/interfaces.d/rascsi_bridge" echo "Configuration completed!" diff --git a/src/x68k/RASCTL/Makefile b/src/x68k/RASCTL/Makefile deleted file mode 100644 index b10bd182..00000000 --- a/src/x68k/RASCTL/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# -# Makefile for RASCTL.X -# - -CC = gcc -O2 -Wall -LK = hlk -l -x - -RASCTL.X : RASCTL.o - $(LK) -o $@ $^ libc.a libiocs.a libscsi.a libgnu.a - -RASCTL.o : RASCTL.C - $(CC) -c -o $@ $^ - \ No newline at end of file diff --git a/src/x68k/RASCTL/RASCTL.C b/src/x68k/RASCTL/RASCTL.C deleted file mode 100644 index c711683f..00000000 --- a/src/x68k/RASCTL/RASCTL.C +++ /dev/null @@ -1,433 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// Powered by XM6 TypeG Technology. -// -// Copyright (C) 2016-2021 GIMONS(Twitter:@kugimoto0715) -// -// [ Sending commands ] -// -//--------------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------------- -// -// Primitive definitions -// -//--------------------------------------------------------------------------- -typedef unsigned int UINT; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef unsigned long long UL64; -typedef int BOOL; -typedef char TCHAR; -typedef char *LPTSTR; -typedef const char *LPCTSTR; -typedef const char *LPCSTR; - -#if !defined(FALSE) -#define FALSE 0 -#endif - -#if !defined(TRUE) -#define TRUE 1 -#endif - -//--------------------------------------------------------------------------- -// -// Constant definitions -// -//--------------------------------------------------------------------------- -#define ENOTCONN 107 - -//--------------------------------------------------------------------------- -// -// Struct definitions -// -//--------------------------------------------------------------------------- -typedef struct -{ - char DeviceType; - char RMB; - char ANSI_Ver; - char RDF; - char AddLen; - char RESV0; - char RESV1; - char OptFunc; - char VendorID[8]; - char ProductID[16]; - char FirmRev[4]; -} INQUIRY_T; - -typedef struct -{ - INQUIRY_T info; - char options[8]; -} INQUIRYOPT_T; - -//--------------------------------------------------------------------------- -// -// Global variables -// -//--------------------------------------------------------------------------- -int scsiid = -1; - -//--------------------------------------------------------------------------- -// -// Search for bridge device -// -//--------------------------------------------------------------------------- -BOOL SearchRaSCSI() -{ - int i; - INQUIRYOPT_T inq; - - for (i = 7; i >= 0; i--) { - // Search for bridge device - if (S_INQUIRY(sizeof(INQUIRY_T) , i, (struct INQUIRY*)&inq) < 0) { - continue; - } - - if (memcmp(&(inq.info.ProductID), "RASCSI BRIDGE", 13) != 0) { - continue; - } - - // Check if option functions are initialized - if (S_INQUIRY(sizeof(INQUIRYOPT_T) , i, (struct INQUIRY*)&inq) < 0) { - continue; - } - - if (inq.options[0] != '1') { - continue; - } - - // Confirm SCSI ID - scsiid = i; - return TRUE; - } - - return FALSE; -} - -//--------------------------------------------------------------------------- -// -// Get messages -// -//--------------------------------------------------------------------------- -BOOL ScsiGetMessage(BYTE *buf) -{ - unsigned char cmd[10]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return FALSE; - } - - cmd[0] = 0x28; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = 0; - cmd[7] = 0x04; - cmd[8] = 0; - cmd[9] = 0; - if (S_CMDOUT(10, cmd) != 0) { - return FALSE; - } - - if (S_DATAIN_P(1024, buf) != 0) { - return FALSE; - } - - S_STSIN(&sts); - S_MSGIN(&msg); - - return TRUE; -} - -//--------------------------------------------------------------------------- -// -// Send messages -// -//--------------------------------------------------------------------------- -BOOL ScsiSendMessage(BYTE *buf) -{ - unsigned char cmd[10]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return FALSE; - } - - cmd[0] = 0x2a; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = 0; - cmd[7] = 0x04; - cmd[8] = 0; - cmd[9] = 0; - if (S_CMDOUT(10, cmd) != 0) { - return FALSE; - } - - S_DATAOUT_P(1024, buf); - - S_STSIN(&sts); - S_MSGIN(&msg); - - return TRUE; -} - -//--------------------------------------------------------------------------- -// -// Send commands -// -//--------------------------------------------------------------------------- -BOOL SendCommand(char *buf) -{ - BYTE message[1024]; - - memset(message, 0x00, 1024); - memcpy(message, buf, strlen(buf)); - - if (ScsiSendMessage(message)) { - memset(message, 0x00, 1024); - if (ScsiGetMessage(message)) { - printf("%s", (char*)message); - return TRUE; - } - } - - return FALSE; -} - -//--------------------------------------------------------------------------- -// -// Main process -// -//--------------------------------------------------------------------------- -void main(int argc, char* argv[]) -{ - int opt; - int id; - int un; - int cmd; - int type; - char *file; - int len; - char *ext; - char buf[BUFSIZ]; - - id = -1; - un = 0; - cmd = -1; - type = -1; - file = NULL; - - // Display help - if (argc < 2) { - fprintf(stderr, "SCSI Target Emulator RaSCSI Controller\n"); - fprintf(stderr, - "Usage: %s -i ID [-u UNIT] [-c CMD] [-t TYPE] [-f FILE]\n", - argv[0]); - fprintf(stderr, " where ID := {0|1|2|3|4|5|6|7}\n"); - fprintf(stderr, " UNIT := {0|1} default setting is 0.\n"); - fprintf(stderr, " CMD := {attach|detach|insert|eject|protect}\n"); - fprintf(stderr, " TYPE := {hd|mo|cd|bridge}\n"); - fprintf(stderr, " FILE := image file path\n"); - fprintf(stderr, " CMD is 'attach' or 'insert' and FILE parameter is required.\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: %s -l\n\n", argv[0]); - fprintf(stderr, " Print device list.\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: %s --stop\n\n", argv[0]); - fprintf(stderr, " Stop rascsi prosess.\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Usage: %s --shutdown\n\n", argv[0]); - fprintf(stderr, " Shutdown raspberry pi.\n"); - exit(0); - } - - // Look for bridge device - if (!SearchRaSCSI()) { - fprintf(stderr, "Error: bridge not found\n"); - exit(ENOTCONN); - } - - // Argument parsing - opterr = 0; - while ((opt = getopt(argc, argv, "i:u:c:t:f:l-:")) != -1) { - switch (opt) { - case 'i': - id = optarg[0] - '0'; - break; - - case 'u': - un = optarg[0] - '0'; - break; - - case 'c': - switch (optarg[0]) { - case 'a': // ATTACH - case 'A': - cmd = 0; - break; - case 'd': // DETACH - case 'D': - cmd = 1; - break; - case 'i': // INSERT - case 'I': - cmd = 2; - break; - case 'e': // EJECT - case 'E': - cmd = 3; - break; - case 'p': // PROTECT - case 'P': - cmd = 4; - break; - } - break; - - case 't': - switch (optarg[0]) { - case 's': // HD(SASI) - case 'S': - case 'h': // HD(SCSI) - case 'H': - type = 0; - break; - case 'm': // MO - case 'M': - type = 2; - break; - case 'c': // CD - case 'C': - type = 3; - break; - case 'b': // BRIDGE - case 'B': - type = 4; - break; - } - break; - - case 'f': - file = optarg; - break; - - case 'l': - sprintf(buf, "list\n"); - SendCommand(buf); - exit(0); - - case '-': - if (strcmp(optarg, "shutdown") == 0) { - sprintf(buf, "shutdown\n"); - SendCommand(buf); - exit(0); - } else if (strcmp(optarg, "stop") == 0) { - sprintf(buf, "stop\n"); - SendCommand(buf); - exit(0); - } - break; - } - } - - // ID check - if (id < 0 || id > 7) { - fprintf(stderr, "Error : Invalid ID\n"); - exit(EINVAL); - } - - // Unit check - if (un < 0 || un > 1) { - fprintf(stderr, "Error : Invalid UNIT\n"); - exit(EINVAL); - } - - // Command check - if (cmd < 0) { - cmd = 0; // The default is 'attach' - } - - // Type check - if (cmd == 0 && type < 0) { - - // Attempt type detection from extension - len = file ? strlen(file) : 0; - if (len > 4 && file[len - 4] == '.') { - ext = &file[len - 3]; - if (strcasecmp(ext, "hdf") == 0 || - strcasecmp(ext, "hds") == 0 || - strcasecmp(ext, "hdn") == 0 || - strcasecmp(ext, "hdi") == 0 || - strcasecmp(ext, "nhd") == 0 || - strcasecmp(ext, "hda") == 0) { - // HD(SASI/SCSI) - type = 0; - } else if (strcasecmp(ext, "mos") == 0) { - // MO - type = 2; - } else if (strcasecmp(ext, "iso") == 0) { - // CD - type = 3; - } - } - - if (type < 0) { - fprintf(stderr, "Error : Invalid type\n"); - exit(EINVAL); - } - } - - // File check (the command is 'attach' with type HD) - if (cmd == 0 && type >= 0 && type <= 1) { - if (!file) { - fprintf(stderr, "Error : Invalid file path\n"); - exit(EINVAL); - } - } - - // File check (the command is 'insert') - if (cmd == 2) { - if (!file) { - fprintf(stderr, "Error : Invalid file path\n"); - exit(EINVAL); - } - } - - // Useless types are set to 0 - if (type < 0) { - type = 0; - } - - // Create command to send - sprintf(buf, "%d %d %d %d %s\n", id, un, cmd, type, file ? file : "-"); - if (!SendCommand(buf)) { - exit(ENOTCONN); - } - - // Quit - exit(0); -} diff --git a/src/x68k/RASDRV/BRIDGE.C b/src/x68k/RASDRV/BRIDGE.C deleted file mode 100644 index c9c85e71..00000000 --- a/src/x68k/RASDRV/BRIDGE.C +++ /dev/null @@ -1,2430 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// -// Powered by XM6 TypeG Technology. -// Copyright (C) 2016-2017 GIMONS -// [ Host Filesystem Bridge Driver ] -// -//--------------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include "bridge.h" - -//--------------------------------------------------------------------------- -// -// Variable definitions -// -//--------------------------------------------------------------------------- -volatile BYTE *request; // Request header address -DWORD command; // Command number -DWORD unit; // Unit number - -//=========================================================================== -// -/// File system (SCSI integration) -// -//=========================================================================== -typedef struct -{ - char DeviceType; - char RMB; - char ANSI_Ver; - char RDF; - char AddLen; - char RESV0; - char RESV1; - char OptFunc; - char VendorID[8]; - char ProductID[16]; - char FirmRev[4]; -} INQUIRY_T; - -int scsiid; // SCSI ID - -//--------------------------------------------------------------------------- -// -// Initialize -// -//--------------------------------------------------------------------------- -BOOL SCSI_Init(void) -{ - int i; - INQUIRY_T inq; - - // SCSI ID not set - scsiid = -1; - - for (i = 0; i <= 7; i++) { - if (S_INQUIRY(sizeof(INQUIRY_T) , i, (struct INQUIRY*)&inq) < 0) { - continue; - } - - if (memcmp(&(inq.ProductID), "RASCSI BRIDGE", 13) != 0) { - continue; - } - - // SCSI ID set - scsiid = i; - return TRUE; - } - - return FALSE; -} - -//--------------------------------------------------------------------------- -// -// Send commands -// -//--------------------------------------------------------------------------- -int SCSI_SendCmd(BYTE *buf, int len) -{ - int ret; - BYTE cmdbuf[10]; - BYTE sts; - BYTE msg; - BYTE retbuf[4]; - - ret = FS_FATAL_MEDIAOFFLINE; - - cmdbuf[0] = 0x2a; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = (BYTE)(len >> 16); - cmdbuf[7] = (BYTE)(len >> 8); - cmdbuf[8] = (BYTE)len; - cmdbuf[9] = 0; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return ret; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return ret; - } - - if (S_DATAOUT_P(len, buf) != 0) { - return ret; - } - - if (S_STSIN(&sts) != 0) { - return ret; - } - - if (S_MSGIN(&msg) != 0) { - return ret; - } - - cmdbuf[0] = 0x28; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = 0; - cmdbuf[7] = 0; - cmdbuf[8] = 4; - cmdbuf[9] = 0; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return ret; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return ret; - } - - if (S_DATAIN_P(4, retbuf) != 0) { - return ret; - } - - if (S_STSIN(&sts) != 0) { - return ret; - } - - if (S_MSGIN(&msg) != 0) { - return ret; - } - - ret = *(int*)retbuf; - return ret; -} - -//--------------------------------------------------------------------------- -// -// Call commands -// -//--------------------------------------------------------------------------- -int SCSI_CalCmd(BYTE *buf, int len, BYTE *outbuf, int outlen) -{ - int ret; - BYTE cmdbuf[10]; - BYTE sts; - BYTE msg; - BYTE retbuf[4]; - - ret = FS_FATAL_MEDIAOFFLINE; - - cmdbuf[0] = 0x2a; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = (BYTE)(len >> 16); - cmdbuf[7] = (BYTE)(len >> 8); - cmdbuf[8] = (BYTE)len; - cmdbuf[9] = 0; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return ret; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return ret; - } - - if (S_DATAOUT_P(len, buf) != 0) { - return ret; - } - - if (S_STSIN(&sts) != 0) { - return ret; - } - - if (S_MSGIN(&msg) != 0) { - return ret; - } - - cmdbuf[0] = 0x28; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = 0; - cmdbuf[7] = 0; - cmdbuf[8] = 4; - cmdbuf[9] = 0; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return ret; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return ret; - } - - if (S_DATAIN_P(4, retbuf) != 0) { - return ret; - } - - if (S_STSIN(&sts) != 0) { - return ret; - } - - if (S_MSGIN(&msg) != 0) { - return ret; - } - - // Stop receiving return data on error - ret = *(int*)retbuf; - if (ret < 0) { - return ret; - } - - cmdbuf[0] = 0x28; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = (BYTE)(outlen >> 16); - cmdbuf[7] = (BYTE)(outlen >> 8); - cmdbuf[8] = (BYTE)outlen; - cmdbuf[9] = 1; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return ret; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return ret; - } - - if (S_DATAIN_P(outlen, outbuf) != 0) { - return ret; - } - - if (S_STSIN(&sts) != 0) { - return ret; - } - - if (S_MSGIN(&msg) != 0) { - return ret; - } - - ret = *(int*)retbuf; - return ret; -} - -//--------------------------------------------------------------------------- -// -// Get option data -// -//--------------------------------------------------------------------------- -BOOL SCSI_ReadOpt(BYTE *buf, int len) -{ - BYTE cmdbuf[10]; - BYTE sts; - BYTE msg; - - cmdbuf[0] = 0x28; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = (BYTE)(len >> 16); - cmdbuf[7] = (BYTE)(len >> 8); - cmdbuf[8] = (BYTE)len; - cmdbuf[9] = 2; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return FALSE; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return FALSE; - } - - if (S_DATAIN_P(len, buf) != 0) { - return FALSE; - } - - if (S_STSIN(&sts) != 0) { - return FALSE; - } - - if (S_MSGIN(&msg) != 0) { - return FALSE; - } - - return TRUE; -} - -//--------------------------------------------------------------------------- -// -// Write option data -// -//--------------------------------------------------------------------------- -BOOL SCSI_WriteOpt(BYTE *buf, int len) -{ - BYTE cmdbuf[10]; - BYTE sts; - BYTE msg; - - cmdbuf[0] = 0x2a; - cmdbuf[1] = 0; - cmdbuf[2] = 2; - cmdbuf[3] = command; - cmdbuf[4] = 0; - cmdbuf[5] = 0; - cmdbuf[6] = (BYTE)(len >> 16); - cmdbuf[7] = (BYTE)(len >> 8); - cmdbuf[8] = (BYTE)len; - cmdbuf[9] = 1; - - // Retry when select times out - if (S_SELECT(scsiid) != 0) { - S_RESET(); - if (S_SELECT(scsiid) != 0) { - return FALSE; - } - } - - if (S_CMDOUT(10, cmdbuf) != 0) { - return FALSE; - } - - if (S_DATAOUT_P(len, buf) != 0) { - return FALSE; - } - - if (S_STSIN(&sts) != 0) { - return FALSE; - } - - if (S_MSGIN(&msg) != 0) { - return FALSE; - } - - return TRUE; -} - -//=========================================================================== -// -/// File System -// -//=========================================================================== - -//--------------------------------------------------------------------------- -// -// $40 - Device startup -// -//--------------------------------------------------------------------------- -DWORD FS_InitDevice(const argument_t* pArgument) -{ - return (DWORD)SCSI_SendCmd((BYTE*)pArgument, sizeof(argument_t)); -} - -//--------------------------------------------------------------------------- -// -// $41 - Directory check -// -//--------------------------------------------------------------------------- -int FS_CheckDir(const namests_t* pNamests) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $42 - Create directory -// -//--------------------------------------------------------------------------- -int FS_MakeDir(const namests_t* pNamests) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $43 - Delete directory -// -//--------------------------------------------------------------------------- -int FS_RemoveDir(const namests_t* pNamests) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $44 - Change file name -// -//--------------------------------------------------------------------------- -int FS_Rename(const namests_t* pNamests, const namests_t* pNamestsNew) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - memcpy(&buf[i], pNamestsNew, sizeof(namests_t)); - i += sizeof(namests_t); - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $45 - Delete file -// -//--------------------------------------------------------------------------- -int FS_Delete(const namests_t* pNamests) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $46 - Get/set file attribute -// -//--------------------------------------------------------------------------- -int FS_Attribute(const namests_t* pNamests, DWORD nHumanAttribute) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - dp = (DWORD*)&buf[i]; - *dp = nHumanAttribute; - i += sizeof(DWORD); - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $47 - File search -// -//--------------------------------------------------------------------------- -int FS_Files(DWORD nKey, - const namests_t* pNamests, files_t* info) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - memcpy(&buf[i], info, sizeof(files_t)); - i += sizeof(files_t); - - return SCSI_CalCmd(buf, i, (BYTE*)info, sizeof(files_t)); -} - -//--------------------------------------------------------------------------- -// -// $48 - Search next file -// -//--------------------------------------------------------------------------- -int FS_NFiles(DWORD nKey, files_t* info) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], info, sizeof(files_t)); - i += sizeof(files_t); - - return SCSI_CalCmd(buf, i, (BYTE*)info, sizeof(files_t)); -} - -//--------------------------------------------------------------------------- -// -// $49 - Create new file -// -//--------------------------------------------------------------------------- -int FS_Create(DWORD nKey, - const namests_t* pNamests, fcb_t* pFcb, DWORD nAttribute, BOOL bForce) -{ - BYTE buf[256]; - DWORD *dp; - BOOL *bp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - dp = (DWORD*)&buf[i]; - *dp = nAttribute; - i += sizeof(DWORD); - - bp = (BOOL*)&buf[i]; - *bp = bForce; - i += sizeof(BOOL); - - return SCSI_CalCmd(buf, i, (BYTE*)pFcb, sizeof(fcb_t)); -} - -//--------------------------------------------------------------------------- -// -// $4A - File open -// -//--------------------------------------------------------------------------- -int FS_Open(DWORD nKey, - const namests_t* pNamests, fcb_t* pFcb) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pNamests, sizeof(namests_t)); - i += sizeof(namests_t); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - return SCSI_CalCmd(buf, i, (BYTE*)pFcb, sizeof(fcb_t)); -} - -//--------------------------------------------------------------------------- -// -// $4B - File close -// -//--------------------------------------------------------------------------- -int FS_Close(DWORD nKey, fcb_t* pFcb) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - return SCSI_CalCmd(buf, i, (BYTE*)pFcb, sizeof(fcb_t)); -} - -//--------------------------------------------------------------------------- -// -// $4C - Read file -// -//--------------------------------------------------------------------------- -int FS_Read(DWORD nKey, fcb_t* pFcb, BYTE* pAddress, DWORD nSize) -{ - BYTE buf[256]; - DWORD *dp; - int i; - int nResult; - - i = 0; - dp = (DWORD*)buf; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - dp = (DWORD*)&buf[i]; - *dp = nSize; - i += sizeof(DWORD); - - nResult = SCSI_CalCmd(buf, i, (BYTE*)pFcb, sizeof(fcb_t)); - - if (nResult > 0) { - SCSI_ReadOpt(pAddress, nResult); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4D - Write file -// -//--------------------------------------------------------------------------- -int FS_Write(DWORD nKey, fcb_t* pFcb, BYTE* pAddress, DWORD nSize) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - dp = (DWORD*)&buf[i]; - *dp = nSize; - i += sizeof(DWORD); - - if (nSize != 0) { - if (!SCSI_WriteOpt(pAddress, nSize)) { - return FS_FATAL_MEDIAOFFLINE; - } - } - - return SCSI_SendCmd(buf, i); -} - -//--------------------------------------------------------------------------- -// -// $4E - File seek -// -//--------------------------------------------------------------------------- -int FS_Seek(DWORD nKey, fcb_t* pFcb, DWORD nMode, int nOffset) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - dp = (DWORD*)&buf[i]; - *dp = nMode; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nOffset; - i += sizeof(int); - - return SCSI_CalCmd(buf, i, (BYTE*)pFcb, sizeof(fcb_t)); -} - -//--------------------------------------------------------------------------- -// -// $4F - Get/set file time stamp -// -//--------------------------------------------------------------------------- -DWORD FS_TimeStamp(DWORD nKey, - fcb_t* pFcb, DWORD nHumanTime) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nKey; - i += sizeof(DWORD); - - memcpy(&buf[i], pFcb, sizeof(fcb_t)); - i += sizeof(fcb_t); - - dp = (DWORD*)&buf[i]; - *dp = nHumanTime; - i += sizeof(DWORD); - - return (DWORD)SCSI_CalCmd(buf, i, (BYTE*)pFcb, sizeof(fcb_t)); -} - -//--------------------------------------------------------------------------- -// -// $50 - Get capacity -// -//--------------------------------------------------------------------------- -int FS_GetCapacity(capacity_t* cap) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - return SCSI_CalCmd(buf, i, (BYTE*)cap, sizeof(capacity_t)); -} - -//--------------------------------------------------------------------------- -// -// $51 - Inspect/control drive status -// -//--------------------------------------------------------------------------- -int FS_CtrlDrive(ctrldrive_t* pCtrlDrive) -{ -#if 1 - // Do tentative processing here due to high load - switch (pCtrlDrive->status) { - case 0: // Inspect status - case 9: // Inspect status 2 - pCtrlDrive->status = 0x42; - return pCtrlDrive->status; - case 1: // Eject - case 2: // Eject forbidden 1 (not implemented) - case 3: // Eject allowed 1 (not implemented) - case 4: // Flash LED when media is not inserted (not implemented) - case 5: // Turn off LED when media is not inserted (not implemented) - case 6: // Eject forbidden 2 (not implemented) - case 7: // Eject allowed 2 (not implemented) - return 0; - - case 8: // Eject inspection - return 1; - } - - return -1; -#else - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - memcpy(&buf[i], pCtrlDrive, sizeof(ctrldrive_t)); - i += sizeof(ctrldrive_t); - - return SCSI_CalCmd(buf, i, (BYTE*)pCtrlDrive, sizeof(ctrldrive_t)); -#endif -} - -//--------------------------------------------------------------------------- -// -// $52 - Get DPB -// -//--------------------------------------------------------------------------- -int FS_GetDPB(dpb_t* pDpb) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - return SCSI_CalCmd(buf, i, (BYTE*)pDpb, sizeof(dpb_t)); -} - -//--------------------------------------------------------------------------- -// -// $53 - Read sector -// -//--------------------------------------------------------------------------- -int FS_DiskRead(BYTE* pBuffer, DWORD nSector, DWORD nSize) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nSector; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nSize; - i += sizeof(DWORD); - - return SCSI_CalCmd(buf, i, (BYTE*)pBuffer, 0x200); -} - -//--------------------------------------------------------------------------- -// -// $54 - Write sector -// -//--------------------------------------------------------------------------- -int FS_DiskWrite() -{ - BYTE buf[256]; - DWORD *dp; - - dp = (DWORD*)buf; - *dp = unit; - - return SCSI_SendCmd(buf, 4); -} - -//--------------------------------------------------------------------------- -// -// $55 - IOCTRL -// -//--------------------------------------------------------------------------- -int FS_Ioctrl(DWORD nFunction, ioctrl_t* pIoctrl) -{ - BYTE buf[256]; - DWORD *dp; - int i; - - i = 0; - dp = (DWORD*)buf; - *dp = unit; - i += sizeof(DWORD); - - dp = (DWORD*)&buf[i]; - *dp = nFunction; - i += sizeof(DWORD); - - memcpy(&buf[i], pIoctrl, sizeof(ioctrl_t)); - i += sizeof(ioctrl_t); - - return SCSI_CalCmd(buf, i, (BYTE*)pIoctrl, sizeof(ioctrl_t)); -} - -//--------------------------------------------------------------------------- -// -// $56 - Flush -// -//--------------------------------------------------------------------------- -int FS_Flush() -{ -#if 1 - // Not supported - return 0; -#else - BYTE buf[256]; - DWORD *dp; - - dp = (DWORD*)buf; - *dp = unit; - - return SCSI_SendCmd(buf, 4); -#endif -} - -//--------------------------------------------------------------------------- -// -// $57 - Media change check -// -//--------------------------------------------------------------------------- -int FS_CheckMedia() -{ -#if 1 - // Do tentative processing due to high load - return 0; -#else - BYTE buf[256]; - DWORD *dp; - - dp = (DWORD*)buf; - *dp = unit; - - return SCSI_SendCmd(buf, 4); -#endif -} - -//--------------------------------------------------------------------------- -// -// $58 - Lock -// -//--------------------------------------------------------------------------- -int FS_Lock() -{ -#if 1 - // Not supported - return 0; -#else - BYTE buf[256]; - DWORD *dp; - - dp = (DWORD*)buf; - *dp = unit; - - return SCSI_SendCmd(buf, 4); -#endif -} - -//=========================================================================== -// -// Command handlers -// -//=========================================================================== -#define GetReqByte(a) (request[a]) -#define SetReqByte(a,d) (request[a] = (d)) -#define GetReqWord(a) (*((WORD*)&request[a])) -#define SetReqWord(a,d) (*((WORD*)&request[a]) = (d)) -#define GetReqLong(a) (*((DWORD*)&request[a])) -#define SetReqLong(a,d) (*((DWORD*)&request[a]) = (d)) -#define GetReqAddr(a) ((BYTE*)((*((DWORD*)&request[a])) & 0x00ffffff)) - -//--------------------------------------------------------------------------- -// -// Read NAMESTS -// -//--------------------------------------------------------------------------- -void GetNameStsPath(BYTE *addr, namests_t* pNamests) -{ - DWORD i; - - ASSERT(this); - ASSERT(pNamests); - - // Wildcard data - pNamests->wildcard = *addr; - - // Drive number - pNamests->drive = addr[1]; - - // Pathname - for (i = 0; i < sizeof(pNamests->path); i++) { - pNamests->path[i] = addr[2 + i]; - } - - // Filename 1 - memset(pNamests->name, 0x20, sizeof(pNamests->name)); - - // File ending - memset(pNamests->ext, 0x20, sizeof(pNamests->ext)); - - // Filename 2 - memset(pNamests->add, 0, sizeof(pNamests->add)); -} - -//--------------------------------------------------------------------------- -// -// Read NAMESTS -// -//--------------------------------------------------------------------------- -void GetNameSts(BYTE *addr, namests_t* pNamests) -{ - DWORD i; - - ASSERT(this); - ASSERT(pNamests); - ASSERT(addr <= 0xFFFFFF); - - // Wildcard data - pNamests->wildcard = *addr; - - // Drive number - pNamests->drive = addr[1]; - - // Pathname - for (i = 0; i < sizeof(pNamests->path); i++) { - pNamests->path[i] = addr[2 + i]; - } - - // Filename 1 - for (i = 0; i < sizeof(pNamests->name); i++) { - pNamests->name[i] = addr[67 + i]; - } - - // File ending - for (i = 0; i < sizeof(pNamests->ext); i++) { - pNamests->ext[i] = addr[75 + i]; - } - - // Filename 2 - for (i = 0; i < sizeof(pNamests->add); i++) { - pNamests->add[i] = addr[78 + i]; - } -} - -//--------------------------------------------------------------------------- -// -// Read FILES -// -//--------------------------------------------------------------------------- -void GetFiles(BYTE *addr, files_t* pFiles) -{ - ASSERT(this); - ASSERT(pFiles); - ASSERT(addr <= 0xFFFFFF); - - // Search data - pFiles->fatr = *addr; - pFiles->sector = *((DWORD*)&addr[2]); - pFiles->offset = *((WORD*)&addr[8]);; - - pFiles->attr = 0; - pFiles->time = 0; - pFiles->date = 0; - pFiles->size = 0; - memset(pFiles->full, 0, sizeof(pFiles->full)); -} - -//--------------------------------------------------------------------------- -// -// Write FILES -// -//--------------------------------------------------------------------------- -void SetFiles(BYTE *addr, const files_t* pFiles) -{ - DWORD i; - - ASSERT(this); - ASSERT(pFiles); - - *((DWORD*)&addr[2]) = pFiles->sector; - *((WORD*)&addr[8]) = pFiles->offset; - - // File data - addr[21] = pFiles->attr; - *((WORD*)&addr[22]) = pFiles->time; - *((WORD*)&addr[24]) = pFiles->date; - *((DWORD*)&addr[26]) = pFiles->size; - - // Full filename - addr += 30; - for (i = 0; i < sizeof(pFiles->full); i++) { - *addr = pFiles->full[i]; - addr++; - } -} - -//--------------------------------------------------------------------------- -// -// Read FCB -// -//--------------------------------------------------------------------------- -void GetFcb(BYTE *addr, fcb_t* pFcb) -{ - ASSERT(this); - ASSERT(pFcb); - - // FCB data - pFcb->fileptr = *((DWORD*)&addr[6]); - pFcb->mode = *((WORD*)&addr[14]); - - // Attribute - pFcb->attr = addr[47]; - - // FCB data - pFcb->time = *((WORD*)&addr[58]); - pFcb->date = *((WORD*)&addr[60]); - pFcb->size = *((DWORD*)&addr[64]); -} - -//--------------------------------------------------------------------------- -// -// Write FCB -// -//--------------------------------------------------------------------------- -void SetFcb(BYTE *addr, const fcb_t* pFcb) -{ - ASSERT(this); - ASSERT(pFcb); - - // FCB data - *((DWORD*)&addr[6]) = pFcb->fileptr; - *((WORD*)&addr[14]) = pFcb->mode; - - // Attribute - addr[47] = pFcb->attr; - - // FCB data - *((WORD*)&addr[58]) = pFcb->time; - *((WORD*)&addr[60]) = pFcb->date; - *((DWORD*)&addr[64]) = pFcb->size; -} - -//--------------------------------------------------------------------------- -// -// Write CAPACITY -// -//--------------------------------------------------------------------------- -void SetCapacity(BYTE *addr, const capacity_t* pCapacity) -{ - ASSERT(this); - ASSERT(pCapacity); - - *((WORD*)&addr[0]) = pCapacity->freearea; - *((WORD*)&addr[2]) = pCapacity->clusters; - *((WORD*)&addr[4]) = pCapacity->sectors; - *((WORD*)&addr[6]) = pCapacity->bytes; -} - -//--------------------------------------------------------------------------- -// -// Write DPB -// -//--------------------------------------------------------------------------- -void SetDpb(BYTE *addr, const dpb_t* pDpb) -{ - ASSERT(this); - ASSERT(pDpb); - - // DPB data - *((WORD*)&addr[0]) = pDpb->sector_size; - addr[2] = pDpb->cluster_size; - addr[3] = pDpb->shift; - *((WORD*)&addr[4]) = pDpb->fat_sector; - addr[6] = pDpb->fat_max; - addr[7] = pDpb->fat_size; - *((WORD*)&addr[8]) = pDpb->file_max; - *((WORD*)&addr[10]) = pDpb->data_sector; - *((WORD*)&addr[12]) = pDpb->cluster_max; - *((WORD*)&addr[14]) = pDpb->root_sector; - addr[20] = pDpb->media; -} - -//--------------------------------------------------------------------------- -// -// Read IOCTRL -// -//--------------------------------------------------------------------------- -void GetIoctrl(DWORD param, DWORD func, ioctrl_t* pIoctrl) -{ - DWORD *lp; - - ASSERT(this); - ASSERT(pIoctrl); - - switch (func) { - case 2: - // Re-identify media - pIoctrl->param = param; - return; - - case -2: - // Configure options - lp = (DWORD*)param; - pIoctrl->param = *lp; - return; - } -} - -//--------------------------------------------------------------------------- -// -// Write IOCTRL -// -//--------------------------------------------------------------------------- -void SetIoctrl(DWORD param, DWORD func, ioctrl_t* pIoctrl) -{ - DWORD i; - BYTE *bp; - WORD *wp; - DWORD *lp; - - ASSERT(this); - ASSERT(pIoctrl); - - switch (func) { - case 0: - // Acquire media ID - wp = (WORD*)param; - *wp = pIoctrl->media; - return; - - case 1: - // Dummy for Human68k compatibility - lp = (DWORD*)param; - *lp = pIoctrl->param; - return; - - case -1: - // Resident evaluation - bp = (BYTE*)param; - for (i = 0; i < 8; i++) { - *bp = pIoctrl->buffer[i]; - bp++; - } - return; - - case -3: - // Acquire options - lp = (DWORD*)param; - *lp = pIoctrl->param; - return; - } -} - -//--------------------------------------------------------------------------- -// -// Read ARGUMENT -// -// When this exceeds the buffer size, interrupt transfer and exit. -// -//--------------------------------------------------------------------------- -void GetArgument(BYTE *addr, argument_t* pArgument) -{ - BOOL bMode; - BYTE *p; - DWORD i; - BYTE c; - - ASSERT(this); - ASSERT(pArgument); - - bMode = FALSE; - p = pArgument->buf; - for (i = 0; i < sizeof(pArgument->buf) - 2; i++) { - c = addr[i]; - *p++ = c; - if (bMode == 0) { - if (c == '\0') - return; - bMode = TRUE; - } else { - if (c == '\0') - bMode = FALSE; - } - } - - *p++ = '\0'; - *p = '\0'; -} - -//--------------------------------------------------------------------------- -// -// Write return value -// -//--------------------------------------------------------------------------- -void SetResult(DWORD nResult) -{ - DWORD code; - - ASSERT(this); - - // Handle fatal errors - switch (nResult) { - case FS_FATAL_INVALIDUNIT: - code = 0x5001; - goto fatal; - case FS_FATAL_INVALIDCOMMAND: - code = 0x5003; - goto fatal; - case FS_FATAL_WRITEPROTECT: - code = 0x700D; - goto fatal; - case FS_FATAL_MEDIAOFFLINE: - code = 0x7002; - fatal: - SetReqByte(3, (BYTE)code); - SetReqByte(4, code >> 8); - // @note When returning retryability, never overwrite with (a5 + 18). - // If you do that, the system will start behaving erratically if you hit Retry at the system error screen. - if (code & 0x2000) - break; - nResult = FS_INVALIDFUNC; - default: - SetReqLong(18, nResult); - break; - } -} - -//--------------------------------------------------------------------------- -// -// $40 - Device startup -// -// in (offset size) -// 0 1.b constant (22) -// 2 1.b command ($40/$c0) -// 18 1.l parameter address -// 22 1.b drive number -// out (offset size) -// 3 1.b error code (lower) -// 4 1.b '' (upper) -// 13 1.b number of units -// 14 1.l device driver exit address + 1 -// -// This is called command 0 when the driver is loaded similarly to a local drive, -// but there is no need to prepare BPB or its pointer array. -// Unlike other commands, only this command does not include a valid a5 + 1, -// since it doesn't expect 0 initialization etc., so be careful. -// -//--------------------------------------------------------------------------- -DWORD InitDevice(void) -{ - argument_t arg; - DWORD units; - - ASSERT(this); - ASSERT(fs); - - // Get option contents - GetArgument(GetReqAddr(18), &arg); - - // Contstruct the filesystem to the extent Human68k can support number of drivers etc. - units = FS_InitDevice(&arg); - - // Return number of drives - SetReqByte(13, units); - - return 0; -} - -//--------------------------------------------------------------------------- -// -// $41 - Directory check -// -// in (offset size) -// 14 1.L NAMESTS struct address -// -//--------------------------------------------------------------------------- -DWORD CheckDir(void) -{ - namests_t ns; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get filename to search - GetNameStsPath(GetReqAddr(14), &ns); - - // Call filesystem - nResult = FS_CheckDir(&ns); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $42 - Create directory -// -// in (offset size) -// 14 1.L NAMESTS struct address -// -//--------------------------------------------------------------------------- -DWORD MakeDir(void) -{ - namests_t ns; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get filename to search - GetNameSts(GetReqAddr(14), &ns); - - // Call filesystem - nResult = FS_MakeDir(&ns); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $43 - Delete directory -// -// in (offset size) -// 14 1.L NAMESTS struct address -// -//--------------------------------------------------------------------------- -DWORD RemoveDir(void) -{ - namests_t ns; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get filename to search - GetNameSts(GetReqAddr(14), &ns); - - // Call filesystem - nResult = FS_RemoveDir(&ns); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $44 - Change filename -// -// in (offset size) -// 14 1.L NAMESTS struct address old filename -// 18 1.L NAMESTS struct address new filename -// -//--------------------------------------------------------------------------- -DWORD Rename(void) -{ - namests_t ns; - namests_t ns_new; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get filename to search - GetNameSts(GetReqAddr(14), &ns); - GetNameSts(GetReqAddr(18), &ns_new); - - // Call filesystem - nResult = FS_Rename(&ns, &ns_new); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $45 - Delete file -// -// in (offset size) -// 14 1.L NAMESTS struct address -// -//--------------------------------------------------------------------------- -DWORD Delete(void) -{ - namests_t ns; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get filename to search - GetNameSts(GetReqAddr(14), &ns); - - // Call filesystem - nResult = FS_Delete(&ns); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $46 - Get/set file attribute -// -// in (offset size) -// 12 1.B Note that this becomes 0x01 when read from memory -// 13 1.B attribute; read from memory when $FF -// 14 1.L NAMESTS struct address -// -//--------------------------------------------------------------------------- -DWORD Attribute(void) -{ - namests_t ns; - DWORD attr; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get filename to search - GetNameSts(GetReqAddr(14), &ns); - - // Target attribute - attr = GetReqByte(13); - - // Call filesystem - nResult = FS_Attribute(&ns, attr); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $47 - File search -// -// in (offset size) -// 0 1.b constant (26) -// 1 1.b unit number -// 2 1.b command ($47/$c7) -// 13 1.b search attribute (Unused in WindrvXM. Written directly to search buffer.) -// 14 1.l Filename buffer (namests format) -// 18 1.l Search buffer (files format) Search data in progress and search results are written to this buffer. -// out (offset size) -// 3 1.b error code (lower) -// 4 1.b '' (upper) -// 18 1.l result status -// -// Search files from specified directory. Called from DOS _FILES. -// When a search fails, or succeeds but not using wildcards, -// we write -1 to the search buffer offset to make the next search fail. -// When a file is found, we set its data as well as the following data -// for the next search: sector number, offset, and in the case of the -// root directory, also the remaining sectors. The search drive, attribute, -// and path name are set in the DOS call processing, so writing is not needed. -// -// -// (offset size) -// 0 1.b NAMWLD 0: no wildcard -1:no specified file -// (number of chars of wildcard) -// 1 1.b NAMDRV drive number (A=0,B=1,...,Z=25) -// 2 65.b NAMPTH path ('\' + optional subdirectory + '\') -// 67 8.b NAMNM1 filename (first 8 chars) -// 75 3.b NAMEXT file ending -// 78 10.b NAMNM2 filename (remaining 10 chars) -// -// Note that 0x09 (TAB) is used for path separator, rather than 0x2F (/) or 0x5C (\) -// -//--------------------------------------------------------------------------- -DWORD Files(void) -{ - BYTE *files; - files_t info; - namests_t ns; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Memory for storing search in progress - files = GetReqAddr(18); - GetFiles(files, &info); - - // Get filename to search - GetNameSts(GetReqAddr(14), &ns); - - // Call filesystem - nResult = FS_Files((DWORD)files, &ns, &info); - - // Apply search results - if (nResult >= 0) { - SetFiles(files, &info); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $48 - Search next file -// -// in (offset size) -// 18 1.L FILES struct address -// -//--------------------------------------------------------------------------- -DWORD NFiles(void) -{ - BYTE *files; - files_t info; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Read work memory - files = GetReqAddr(18); - GetFiles(files, &info); - - // Call filesystem - nResult = FS_NFiles((DWORD)files, &info); - - // Apply search results - if (nResult >= 0) { - SetFiles(files, &info); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $49 - Create file (Create) -// -// in (offset size) -// 1 1.B unit number -// 13 1.B attribute -// 14 1.L NAMESTS struct address -// 18 1.L mode (0:_NEWFILE 1:_CREATE) -// 22 1.L FCB struct address -// -//--------------------------------------------------------------------------- -DWORD Create(void) -{ - namests_t ns; - BYTE *pFcb; - fcb_t fcb; - DWORD attr; - BOOL force; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get target filename - GetNameSts(GetReqAddr(14), &ns); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Attribute - attr = GetReqByte(13); - - // Forced overwrite mode - force = (BOOL)GetReqLong(18); - - // Call filesystem - nResult = FS_Create((DWORD)pFcb, &ns, &fcb, attr, force); - - // Apply results - if (nResult >= 0) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4A - File open -// -// in (offset size) -// 1 1.B unit number -// 14 1.L NAMESTS struct address -// 22 1.L FCB struct address -// Most parameters are already set in FCB. -// Overwrite time and date at the moment of opening. -// Overwrite if size is 0. -// -//--------------------------------------------------------------------------- -DWORD Open(void) -{ - namests_t ns; - BYTE *pFcb; - fcb_t fcb; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get target filename - GetNameSts(GetReqAddr(14), &ns); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Call filesystem - nResult = FS_Open((DWORD)pFcb, &ns, &fcb); - - // Apply results - if (nResult >= 0) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4B - File close -// -// in (offset size) -// 22 1.L FCB struct address -// -//--------------------------------------------------------------------------- -DWORD Close(void) -{ - BYTE *pFcb; - fcb_t fcb; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Call filesystem - nResult = FS_Close((DWORD)pFcb, &fcb); - - // Apply results - if (nResult >= 0) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4C - Read file -// -// in (offset size) -// 14 1.L Reading buffer; Read the file contents here. -// 18 1.L Size; It may be set to values exceeding 16MB -// 22 1.L FCB struct address -// -// No guarantee for behavior when passing address where bus error occurs. -// -// In the 20th century, a small number of apps used a trick where reading a -// negative value meant "read all the files!" Wh, what? This file is over 16MB! -// -// Back then, anything over 4~12MB was treated as "inifity" and often truncated -// out of helpfulness, which is not needed in this day and age. -// On the other hand, it might be a good idea to truncate at 12MB or 16MB. -// -//--------------------------------------------------------------------------- -DWORD Read(void) -{ - BYTE *pFcb; - fcb_t fcb; - BYTE *pAddress; - DWORD nSize; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Read buffer - pAddress = GetReqAddr(14); - - // Read size - nSize = GetReqLong(18); - - // Clipping - if (nSize >= WINDRV_CLIPSIZE_MAX) { - nSize = WINDRV_CLIPSIZE_MAX; - } - - // Call filesystem - nResult = FS_Read((DWORD)pFcb, &fcb, pAddress, nSize); - - // Apply results - if (nResult >= 0) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4D - Write file -// -// in (offset size) -// 14 1.L Write buffer; Write file contents here -// 18 1.L Size; If a negative number, treated the same as specifying file size -// 22 1.L FCB struct address -// -// No guarantee for behavior when passing address where bus error occurs. -// -//--------------------------------------------------------------------------- -DWORD Write(void) -{ - BYTE *pFcb; - fcb_t fcb; - BYTE *pAddress; - DWORD nSize; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Write buffer - pAddress = GetReqAddr(14); - - // Write size - nSize = GetReqLong(18); - - // Clipping - if (nSize >= WINDRV_CLIPSIZE_MAX) { - nSize = WINDRV_CLIPSIZE_MAX; - } - - // Call filesystem - nResult = FS_Write((DWORD)pFcb, &fcb, pAddress, nSize); - - // Apply results - if (nResult >= 0) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4E - File seek -// -// in (offset size) -// 12 1.B This becomes 0x2B sometimes, and 0 other times -// 13 1.B mode -// 18 1.L offset -// 22 1.L FCB struct address -// -//--------------------------------------------------------------------------- -DWORD Seek(void) -{ - BYTE *pFcb; - fcb_t fcb; - DWORD nMode; - DWORD nOffset; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Seek mode - nMode = GetReqByte(13); - - // Seek offset - nOffset = GetReqLong(18); - - // Call filesystem - nResult = FS_Seek((DWORD)pFcb, &fcb, nMode, nOffset); - - // Apply results - if (nResult >= 0) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $4F - Get/set file timestamp -// -// in (offset size) -// 18 1.W DATE -// 20 1.W TIME -// 22 1.L FCB struct address -// -// Possible to change settings when FCB is opened in read mode too. -// Note: Cannot make the judgement of read-only with only FCB -// -//--------------------------------------------------------------------------- -DWORD TimeStamp(void) -{ - BYTE *pFcb; - fcb_t fcb; - DWORD nTime; - DWORD nResult; - - ASSERT(this); - ASSERT(fs); - - // Get FCB - pFcb = GetReqAddr(22); - GetFcb(pFcb, &fcb); - - // Get timestamp - nTime = GetReqLong(18); - - // Call filesystem - nResult = FS_TimeStamp((DWORD)pFcb, &fcb, nTime); - - // Apply results - if (nResult < 0xFFFF0000) { - SetFcb(pFcb, &fcb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $50 - Get capacity -// -// in (offset size) -// 0 1.b constant (26) -// 1 1.b unit number -// 2 1.b command ($50/$d0) -// 14 1.l buffer address -// out (offset size) -// 3 1.b error code (lower) -// 4 1.b '' (upper) -// 18 1.l result status -// -// Get the total and available media capacity, as well as cluster / sector size. -// The contents to write to buffer follows. Returns number of bytes that can be -// used for result status. -// -// (offset size) -// 0 1.w available number of clusters -// 2 1.w total number of clusters -// 4 1.w number of sectors per 1 cluster -// 6 1.w number of bytes per 1 sector -// -//--------------------------------------------------------------------------- -DWORD GetCapacity(void) -{ - BYTE *pCapacity; - capacity_t cap; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get buffer - pCapacity = GetReqAddr(14); - -#if 0 - // Call filesystem - nResult = FS_GetCapacity(&cap); -#else - // Try skipping since the contents are always returned - cap.freearea = 0xFFFF; - cap.clusters = 0xFFFF; - cap.sectors = 64; - cap.bytes = 512; - nResult = 0x7FFF8000; -#endif - - // Apply results - if (nResult >= 0) { - SetCapacity(pCapacity, &cap); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $51 - Inspect/control drive status -// -// in (offset size) -// 1 1.B unit number -// 13 1.B status 0: status inspection 1: eject -// -//--------------------------------------------------------------------------- -DWORD CtrlDrive(void) -{ - ctrldrive_t ctrl; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get drive status - ctrl.status = GetReqByte(13); - - // Call filesystem - nResult = FS_CtrlDrive(&ctrl); - - // Apply results - if (nResult >= 0) { - SetReqByte(13, ctrl.status); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $52 - Get DPB -// -// in (offset size) -// 0 1.b constant (26) -// 1 1.b unit number -// 2 1.b command ($52/$d2) -// 14 1.l buffer address (points at starting address + 2) -// out (offset size) -// 3 1.b error code (lower) -// 4 1.b '' (upper) -// 18 1.l result status -// -// Specified media data is returned as DPB v1. Data needed to be set -// for this command are as follows (parantheses indicate what's set by DOS calls.) -// Note that the buffer adress is what's pointed at by offset 2. -// -// (offset size) -// 0 1.b (drive number) -// 1 1.b (unit number) -// 2 1.w number of bytes per 1 sector -// 4 1.b number of sectors - 1 per 1 cluster -// 5 1.b Number of cluster -> sector -// bit 7 = 1 in MS-DOS format FAT (16bit Intel array) -// 6 1.w FAT first sector number -// 8 1.b Number of FAT allocations -// 9 1.b Number of FAT controlled sectors (excluding duplicates) -// 10 1.w Number of files in the root directory -// 12 1.w First sector number of data memory -// 14 1.w Total number of clusters + 1 -// 16 1.w First sector number of root directory -// 18 1.l (Driver head address) -// 22 1.b (Physical drive name in lower-case) -// 23 1.b (DPB usage flag: normally 0) -// 24 1.l (Next DPB address) -// 28 1.w (Cluster number of current directory: normally 0) -// 30 64.b (Current directory name) -// -//--------------------------------------------------------------------------- -DWORD GetDPB(void) -{ - BYTE *pDpb; - dpb_t dpb; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get DPB - pDpb = GetReqAddr(14); - - // Call filesystem - nResult = FS_GetDPB(&dpb); - - // Apply results - if (nResult >= 0) { - SetDpb(pDpb, &dpb); - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $53 - Read sector -// -// in (offset size) -// 1 1.B unit number -// 14 1.L buffer address -// 18 1.L number of sectors -// 22 1.L sector number -// -//--------------------------------------------------------------------------- -DWORD DiskRead(void) -{ - BYTE *pAddress; - DWORD nSize; - DWORD nSector; - BYTE buffer[0x200]; - int nResult; - int i; - - ASSERT(this); - ASSERT(fs); - - pAddress = GetReqAddr(14); // Address (upper bit is extension flag) - nSize = GetReqLong(18); // Number of sectors - nSector = GetReqLong(22); // Sector number - - // Call filesystem - nResult = FS_DiskRead(buffer, nSector, nSize); - - // Apply results - if (nResult >= 0) { - for (i = 0; i < sizeof(buffer); i++) { - *pAddress = buffer[i]; - pAddress++; - } - } - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $54 - Write sector -// -// in (offset size) -// 1 1.B unit number -// 14 1.L buffer address -// 18 1.L number of sectors -// 22 1.L sector number -// -//--------------------------------------------------------------------------- -DWORD DiskWrite(void) -{ - BYTE *pAddress; - DWORD nSize; - DWORD nSector; - int nResult; - - ASSERT(this); - ASSERT(fs); - - pAddress = GetReqAddr(14); // Address (upper bit is extension flag) - nSize = GetReqLong(18); // Number of sectors - nSector = GetReqLong(22); // Sector number - - // Call filesystem - nResult = FS_DiskWrite(); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $55 - IOCTRL -// -// in (offset size) -// 1 1.B unit number -// 14 1.L parameter -// 18 1.W feature number -// -//--------------------------------------------------------------------------- -DWORD Ioctrl(void) -{ - DWORD param; - DWORD func; - ioctrl_t ioctrl; - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Get IOCTRL - param = GetReqLong(14); // Parameter - func = GetReqWord(18); // Feature number - GetIoctrl(param, func, &ioctrl); - - // Call filesystem - nResult = FS_Ioctrl(func, &ioctrl); - - // Apply results - if (nResult >= 0) - SetIoctrl(param, func, &ioctrl); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $56 - Flush -// -// in (offset size) -// 1 1.b unit number -// -//--------------------------------------------------------------------------- -DWORD Flush(void) -{ - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Call filesystem - nResult = FS_Flush(); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $57 - Media change check -// -// in (offset size) -// 0 1.b constant (26) -// 1 1.b unit number -// 2 1.b Command ($57/$d7) -// out (offset size) -// 3 1.b error code (lower) -// 4 1.b '' (upper) -// 18 1.l result status -// -// Checks if the media has been changed or not. Format if it has changed. -// The verification is done within this command. -// -//--------------------------------------------------------------------------- -DWORD CheckMedia(void) -{ - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Call filesystem - nResult = FS_CheckMedia(); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// $58 - Lock -// -// in (offset size) -// 1 1.b unit number -// -//--------------------------------------------------------------------------- -DWORD Lock(void) -{ - int nResult; - - ASSERT(this); - ASSERT(fs); - - // Call filesystem - nResult = FS_Lock(); - - return nResult; -} - -//--------------------------------------------------------------------------- -// -// Execute command -// -//--------------------------------------------------------------------------- -DWORD ExecuteCommand() -{ - ASSERT(this); - - // Clear error data - SetReqByte(3, 0); - SetReqByte(4, 0); - - // Command number - command = (DWORD)GetReqByte(2); // Bit 7 is verify flag - - // Unit number - unit = GetReqByte(1); - - // Command branching - switch (command & 0x7F) { - case 0x40: return InitDevice(); // $40 - Device startup - case 0x41: return CheckDir(); // $41 - Directory check - case 0x42: return MakeDir(); // $42 - Create directory - case 0x43: return RemoveDir(); // $43 - Delete directory - case 0x44: return Rename(); // $44 - Change file name - case 0x45: return Delete(); // $45 - Delete file - case 0x46: return Attribute(); // $46 - Get / set file attribute - case 0x47: return Files(); // $47 - Find file - case 0x48: return NFiles(); // $48 - Find next file - case 0x49: return Create(); // $49 - Create file - case 0x4A: return Open(); // $4A - Open file - case 0x4B: return Close(); // $4B - Close file - case 0x4C: return Read(); // $4C - Read file - case 0x4D: return Write(); // $4D - Write file - case 0x4E: return Seek(); // $4E - Seek file - case 0x4F: return TimeStamp(); // $4F - Get / set file timestamp - case 0x50: return GetCapacity();// $50 - Get capacity - case 0x51: return CtrlDrive(); // $51 - Inspect / control drive status - case 0x52: return GetDPB(); // $52 - Get DPB - case 0x53: return DiskRead(); // $53 - Read sectors - case 0x54: return DiskWrite(); // $54 - Write sectors - case 0x55: return Ioctrl(); // $55 - IOCTRL - case 0x56: return Flush(); // $56 - Flush - case 0x57: return CheckMedia(); // $57 - Media change check - case 0x58: return Lock(); // $58 - Lock - } - - return FS_FATAL_INVALIDCOMMAND; -} - -//--------------------------------------------------------------------------- -// -// Initialization -// -//--------------------------------------------------------------------------- -BOOL Init() -{ - ASSERT(this); - - return SCSI_Init(); -} - -//--------------------------------------------------------------------------- -// -// Execution -// -//--------------------------------------------------------------------------- -void Process(DWORD nA5) -{ - ASSERT(this); - ASSERT(nA5 <= 0xFFFFFF); - ASSERT(m_bAlloc); - ASSERT(m_bFree); - - // Request header address - request = (BYTE*)nA5; - - // Command execution - SetResult(ExecuteCommand()); -} diff --git a/src/x68k/RASDRV/BRIDGE.H b/src/x68k/RASDRV/BRIDGE.H deleted file mode 100644 index 1d531583..00000000 --- a/src/x68k/RASDRV/BRIDGE.H +++ /dev/null @@ -1,255 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// -// Powered by XM6 TypeG Technology. -// Copyright (C) 2016-2017 GIMONS -// [ Host Filesystem Bridge Driver ] -// -//--------------------------------------------------------------------------- - -#ifndef bridge_h -#define bridge_h - -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef int BOOL; - -#if !defined(FALSE) -#define FALSE 0 -#endif - -#if !defined(TRUE) -#define TRUE 1 -#endif - -#define FASTCALL -#define ASSERT(x) - -//--------------------------------------------------------------------------- -// -// Constant definitions -// -//--------------------------------------------------------------------------- -#define FILEPATH_MAX _MAX_PATH -#define WINDRV_CLIPSIZE_MAX 0xC00000 - -//--------------------------------------------------------------------------- -// -// Status code definitions -// -//--------------------------------------------------------------------------- -#define FS_INVALIDFUNC 0xFFFFFFFF // Executed an invalid function -#define FS_FILENOTFND 0xFFFFFFFE // The selected file can not be found -#define FS_DIRNOTFND 0xFFFFFFFD // The selected directory can not be found -#define FS_OVEROPENED 0xFFFFFFFC // There are too many files open -#define FS_CANTACCESS 0xFFFFFFFB // Can not access the direcory or volume -#define FS_NOTOPENED 0xFFFFFFFA // The selected handle is not opened -#define FS_INVALIDMEM 0xFFFFFFF9 // Memory management has been destroyed -#define FS_OUTOFMEM 0xFFFFFFF8 // Insufficient memory for execution -#define FS_INVALIDPTR 0xFFFFFFF7 // Selected an invalid memory management pointer -#define FS_INVALIDENV 0xFFFFFFF6 // Selected an invalid environment -#define FS_ILLEGALFMT 0xFFFFFFF5 // The exeucted file is in an invalid format -#define FS_ILLEGALMOD 0xFFFFFFF4 // Invalid open access mode -#define FS_INVALIDPATH 0xFFFFFFF3 // Mistake in selected file name -#define FS_INVALIDPRM 0xFFFFFFF2 // Called with an invalid parameter -#define FS_INVALIDDRV 0xFFFFFFF1 // Mistake in selected drive -#define FS_DELCURDIR 0xFFFFFFF0 // Unable to delete the current directory -#define FS_NOTIOCTRL 0xFFFFFFEF // Unable to use IOCTRL with the device -#define FS_LASTFILE 0xFFFFFFEE // Can not find any more files -#define FS_CANTWRITE 0xFFFFFFED // Selected file can not be written -#define FS_DIRALREADY 0xFFFFFFEC // Selected directory is already registered -#define FS_CANTDELETE 0xFFFFFFEB // Can not delete because of a file -#define FS_CANTRENAME 0xFFFFFFEA // Can not rename because of a file -#define FS_DISKFULL 0xFFFFFFE9 // Can not create a file because the disk is full -#define FS_DIRFULL 0xFFFFFFE8 // Can not create a file because the directory is full -#define FS_CANTSEEK 0xFFFFFFE7 // Can not seek in the selected location -#define FS_SUPERVISOR 0xFFFFFFE6 // Selected supervisor in supervisor mode -#define FS_THREADNAME 0xFFFFFFE5 // A thread with this name already exists -#define FS_BUFWRITE 0xFFFFFFE4 // Writing to inter-process communication buffers is disallowed -#define FS_BACKGROUND 0xFFFFFFE3 // Unable to start a background process -#define FS_OUTOFLOCK 0xFFFFFFE0 // Insufficient lock space -#define FS_LOCKED 0xFFFFFFDF // Can not access because it is locked -#define FS_DRIVEOPENED 0xFFFFFFDE // Selected drive has an open handler -#define FS_LINKOVER 0xFFFFFFDD // The symbolic link is nested over 16 times -#define FS_FILEEXIST 0xFFFFFFB0 // The file exists - -#define FS_FATAL_MEDIAOFFLINE 0xFFFFFFA3 // No media inserted -#define FS_FATAL_WRITEPROTECT 0xFFFFFFA2 // Write protected -#define FS_FATAL_INVALIDCOMMAND 0xFFFFFFA1 // Invalid command number -#define FS_FATAL_INVALIDUNIT 0xFFFFFFA0 // Invalid unit number - -#define HUMAN68K_PATH_MAX 96 // Longest path allowed in Human68k - -//=========================================================================== -// -/// Human68k name space -// -//=========================================================================== -/// File attribute bit -enum attribute_t { - AT_READONLY = 0x01, // Read only attribute - AT_HIDDEN = 0x02, // Hidden attribute - AT_SYSTEM = 0x04, // System attribute - AT_VOLUME = 0x08, // Volume label attribute - AT_DIRECTORY = 0x10, // Directory attribute - AT_ARCHIVE = 0x20, // Archive attribute - AT_ALL = 0xFF, // All attribute bits are 1 -}; - -/// File open modes -enum open_t { - OP_READ = 0, // Read - OP_WRITE = 1, // Write - OP_FULL = 2, // Read/Write - OP_MASK = 0x0F, // Decision mask - OP_SHARE_NONE = 0x10, // Sharing forbidden - OP_SHARE_READ = 0x20, // Read sharing - OP_SHARE_WRITE = 0x30, // Write sharing - OP_SHARE_FULL = 0x40, // Read/Write sharing - OP_SHARE_MASK = 0x70, // Sharing decision mask - OP_SPECIAL = 0x100, // Dictionary access -}; - -/// Seek types -enum seek_t { - SK_BEGIN = 0, // From the beginning of a file - SK_CURRENT = 1, // From the current location - SK_END = 2, // From the end of the file -}; - -/// Media byte -enum media_t { - MEDIA_2DD_10 = 0xE0, // 2DD/10 sector - MEDIA_1D_9 = 0xE5, // 1D/9 sector - MEDIA_2D_9 = 0xE6, // 2D/9 sector - MEDIA_1D_8 = 0xE7, // 1D/8 sector - MEDIA_2D_8 = 0xE8, // 2D/8 sector - MEDIA_2HT = 0xEA, // 2HT - MEDIA_2HS = 0xEB, // 2HS - MEDIA_2HDE = 0xEC, // 2DDE - MEDIA_1DD_9 = 0xEE, // 1DD/9 sector - MEDIA_1DD_8 = 0xEF, // 1DD/8 sector - MEDIA_MANUAL = 0xF1, // Remote drive (manual eject) - MEDIA_REMOVABLE = 0xF2, // Remote drive (removable) - MEDIA_REMOTE = 0xF3, // Remote drive - MEDIA_DAT = 0xF4, // SCSI-DAT - MEDIA_CDROM = 0xF5, // SCSI-CDROM - MEDIA_MO = 0xF6, // SCSI-MO - MEDIA_SCSI_HD = 0xF7, // SCSI-HD - MEDIA_SASI_HD = 0xF8, // SASI-HD - MEDIA_RAMDISK = 0xF9, // RAM disk - MEDIA_2HQ = 0xFA, // 2HQ - MEDIA_2DD_8 = 0xFB, // 2DD/8 sector - MEDIA_2DD_9 = 0xFC, // 2DD/9 sector - MEDIA_2HC = 0xFD, // 2HC - MEDIA_2HD = 0xFE, // 2HD -}; - -/// namests struct -typedef struct { - BYTE wildcard; // Wildcard character length - BYTE drive; // Drive number - BYTE path[65]; // Path (subdirectory +/) - BYTE name[8]; // File name (PADDING 0x20) - BYTE ext[3]; // Extension (PADDING 0x20) - BYTE add[10]; // File name addition (PADDING 0x00) -} namests_t; - -/// files struct -typedef struct { - BYTE fatr; // + 0 search attribute; read-only - BYTE pad1[3]; // padding -// BYTE drive; // + 1 drive number; read-only - DWORD sector; // + 2 directory sector; DOS _FILES first address substitute -// WORD cluster; // + 6 directory cluster; details unknown (unused) - WORD offset; // + 8 directory entry; write-only -// BYTE name[8]; // +10 working file name; write-only (unused) -// BYTE ext[3]; // +18 working extension; write-only (unused) - BYTE attr; // +21 file attribute; write-only - BYTE pad2; // padding - WORD time; // +22 last change time of day; write-only - WORD date; // +24 last change date; write-only - DWORD size; // +26 file size; write-only - BYTE full[23]; // +30 full name; write-only - BYTE pad3; // padding -} files_t; - -/// FCB\‘¢‘Ì -typedef struct { -// BYTE pad00[6]; // + 0~+ 5 (unused) - DWORD fileptr; // + 6~+ 9 file pointer -// BYTE pad01[4]; // +10~+13 (unused) - WORD mode; // +14~+15 open mode -// BYTE pad02[16]; // +16~+31 (unused) -// DWORD zero; // +32~+35 zeros are written when opened (unused) -// BYTE name[8]; // +36~+43 file name (PADDING 0x20) (unused) -// BYTE ext[3]; // +44~+46 extension (PADDING 0x20) (unused) - BYTE attr; // +47 file attribute -// BYTE add[10]; // +48~+57 file name addition (PADDING 0x00) (unused) - WORD time; // +58~+59 last change time of day - WORD date; // +60~+61 last change date -// WORD cluster; // +62~+63 cluster number (unused) - DWORD size; // +64~+67 file size -// BYTE pad03[28]; // +68~+95 FAT cache (unused) -} fcb_t; - -/// capacity struct -typedef struct { - WORD freearea; // + 0 Number of available clusters - WORD clusters; // + 2 Total number of clusters - WORD sectors; // + 4 Number of sectors per cluster - WORD bytes; // + 6 Number of bytes per sector -} capacity_t; - -/// ctrldrive struct -typedef struct { - BYTE status; // +13 status - BYTE pad[3]; // padding -} ctrldrive_t; - -/// DPB struct -typedef struct { - WORD sector_size; // + 0 Number of bytes in one sector - BYTE cluster_size; // + 2 Number sectors in one cluster -1 - BYTE shift; // + 3 Number of cluster¨sector shifts - WORD fat_sector; // + 4 FAT first sector number - BYTE fat_max; // + 6 FAT storage quantity - BYTE fat_size; // + 7 FAT controlled sector number (excluding duplicates) - WORD file_max; // + 8 Number of files in the root directory - WORD data_sector; // +10 First sector number of data storage - WORD cluster_max; // +12 Total number of clusters +1 - WORD root_sector; // +14 First sector number of root directory -// DWORD driverentry; // +16 Device driver pointer (unused) - BYTE media; // +20 Media identifier -// BYTE flag; // +21 Flag used by DPB (unused) - BYTE pad; // padding -} dpb_t; - -/// Directory entry struct -typedef struct { - BYTE name[8]; // + 0 File name (PADDING 0x20) - BYTE ext[3]; // + 8 Extension (PADDING 0x20) - BYTE attr; // +11 File attribute - BYTE add[10]; // +12 File name addition (PADDING 0x00) - WORD time; // +22 Last change time of day - WORD date; // +24 Last change date - WORD cluster; // +26 Cluster number - DWORD size; // +28 File size -} dirent_t; - -/// IOCTRL parameter union -typedef union { - BYTE buffer[8]; // Access in byte units - DWORD param; // Parameter (First 4 bytes) - WORD media; // Media byte (First 2 bytes) -} ioctrl_t; - -/// Command line parameter struct -typedef struct { - BYTE buf[256]; // Command line argument -} argument_t; - -#endif // bridge_h diff --git a/src/x68k/RASDRV/Makefile b/src/x68k/RASDRV/Makefile deleted file mode 100644 index 4a449de3..00000000 --- a/src/x68k/RASDRV/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# Makefile for RASDRV.SYS -# - -CC = gcc -O2 -Wall -fomit-frame-pointer -AS = has -LK = hlk -l -x - -RASDRV.SYS : RASDRV.o BRIDGE.o - $(LK) -o $@ $^ libc.a libiocs.a libscsi.a - -RASDRV.o : RASDRV.S - $(AS) $^ - -BRIDGE.o : BRIDGE.C - $(CC) -c -o $@ $^ - \ No newline at end of file diff --git a/src/x68k/RASDRV/RASDRV.S b/src/x68k/RASDRV/RASDRV.S deleted file mode 100644 index 6eb0a848..00000000 --- a/src/x68k/RASDRV/RASDRV.S +++ /dev/null @@ -1,193 +0,0 @@ -*--------------------------------------------------------------------------- -* -* SCSI Target Emulator RaSCSI (*^..^*) -* for Raspberry Pi -* -* Powered by XM6 TypeG Technology. -* Copyright (C) 2016-2019 GIMONS -* [ Host Filesystem Bridge Driver ] -* -* Based on -* X68k Emulator Host Filesystem Driver version 0.27 -* Programmed By co -* -*--------------------------------------------------------------------------- - - CPU 68010 - - INCLUDE DOSCALL.MAC - INCLUDE IOCSCALL.MAC - -.XREF _Init, _Process ;bridge.c - -COMMAND EQU 2 Command number -ERRLOW EQU 3 Error code lower 8 bits -ERRHIGH EQU 4 Error code upper 8 bits -MXUNIT EQU 13 Number of units -DEVEND EQU 14 Driver exit address -BDEVNO EQU 22 Base drive number - -DDHEADER: - DC.L -1 +$00 Link pointer - DC.W $2040 +$04 Device attribute - DC.L DDSTRATEGY +$06 - DC.L DDENTRY_FIRST +$0A - DC.B '*EMUHOST' +$0E Device name - -DDREQUEST: - DC.L 0 - -DDSTRATEGY: - MOVE.L A5,DDREQUEST - RTS - -*Device driver entry -DDENTRY: - MOVE.L SP,(STACK_BUFF) - LEA (DEF_STACK),SP - MOVEM.L D1-D3/A0-A2,-(SP) - MOVEM.L DDREQUEST(PC),D0 D0.L: Request header address - MOVE.L D0,-(SP) - BSR _Process - ADDQ.L #4,SP - MOVEM.L (SP)+,D1-D3/A0-A2 - MOVEA.L (STACK_BUFF),SP - RTS - -KEEP_HERE: - -*First time only device driver entry -DDENTRY_FIRST: - MOVEM.L D1-D3/A0-A2/A5,-(SP) - MOVEA.L DDREQUEST(PC),A5 A5.L: Request header address -* CMPI.B #$40,COMMAND(A5) No need to check when Human68k is running -* BNE UNSUPPORTED Error: Not supported - -*Show title - PEA MESSAGE_TITLE(PC) - DOS _PRINT - ADDQ.L #4,SP - -*Device check -DEVICE_CHECK: - BSR _Init - - TST.L D0 - BEQ NOTFOUND Error: Device not found - -*Resident program start - LEA DDENTRY(PC),A1 - - LEA DDHEADER+$0A(PC),A0 - MOVE.L A1,(A0) Configure driver entry - MOVE.L #PROG_END,DEVEND(A5) Configure resident exit address - - ST.B MXUNIT(A5) Set negative number since port is considered unimplemented - JSR (A1) Execute driver entry - - TST.B MXUNIT(A5) Verify number of units - BLE NODRIVE Error: No drive - - MOVE.B BDEVNO(A5),D0 - MOVE.B MXUNIT(A5),D1 - LEA FIRSTDRIVE(PC),A0 - ADD.B D0,(A0) Overwrite start drive name - ADD.B D1,D0 Overwrite stop drive name - ADD.B D0,LASTDRIVE-FIRSTDRIVE(A0) - - PEA MESSAGE_DRIVENAME(PC) Normal: Drive A: - DOS _PRINT - - PEA MESSAGE_DRIVENAME2(PC) Normal: to Z: - SUBQ.B #2,D1 - BCS @F - DOS _PRINT -@@ ADDQ.L #8,SP - - PEA MESSAGE_DRIVENAME3(PC) Normal: was registered - BRA QUIT - -NOTFOUND: - PEA MESSAGE_NOTFOUND(PC) Error: Device not found - BRA ABORT - -UNSUPPORTED: - PEA MESSAGE_UNSUPPORTED(PC) Error: Not supported - BRA ABORT - -NODRIVE: - PEA MESSAGE_NODRIVE(PC) Error: No drive - -ABORT: - MOVE.B #$0D,ERRLOW(A5) - MOVE.B #$70,ERRHIGH(A5) - -QUIT: - DOS _PRINT - ADDQ.L #4,SP - - MOVEM.L (SP)+,D1-D3/A0-A2/A5 - RTS - -SECRET: - PEA MESSAGE_TITLE2(PC) - DOS _PRINT - PEA CREDIT(PC) - DOS _PRINT - ADDQ.L #8,SP - DOS _EXIT - - DATA - -*Error messages -MESSAGE_NOTFOUND: - DC.B 'Device not found',$0D,$0A,0 - -MESSAGE_UNSUPPORTED: - DC.B 'Not supported',$0D,$0A,0 - -MESSAGE_NODRIVE: - DC.B 'No drive',$0D,$0A,0 - -*Registration messages -MESSAGE_DRIVENAME: - DC.B 'Drive' -FIRSTDRIVE: - DC.B 'A:',0 -MESSAGE_DRIVENAME2: - DC.B ' to ' -LASTDRIVE: - DC.B '@:',0 -MESSAGE_DRIVENAME3: - DC.B ' was registered',$0D,$0A,0 - -*Title -MESSAGE_TITLE: - DC.B $0D,$0A -MESSAGE_TITLE2: - DC.B 'RaSCSI FileSystem Driver version 1.42',$0D,$0A,0 - -*Thanks! -CREDIT: - DC.B 'Coded by GIMONS',$0D,$0A - DC.B 'Special thanks to',$0D,$0A - DC.B 9,'co',$0D,$0A - DC.B 9,'PI.',$0D,$0A - DC.B 9,'Tachibana@Kuwashima Giken',$0D,$0A - DC.B 0 - - BSS - QUAD - -STACK_BUFF: - .DS.L 1 - - STACK - QUAD - - .DS.B 1024*2 -DEF_STACK: - - -PROG_END: - END SECRET diff --git a/src/x68k/RASETHER/Makefile b/src/x68k/RASETHER/Makefile deleted file mode 100644 index 92557b33..00000000 --- a/src/x68k/RASETHER/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# Makefile for RASETHER.SYS -# - -TARGET = RASETHER.SYS - -OBJS = re.o asmsub.o main.o scsictl.o -LIBS = libc.a libgnu.a libscsi.a - -CC = gcc -O2 -Wall -fomit-frame-pointer -CFLAGS = -D__DOS_INLINE__ -D__IOCS_INLINE__ -#CFLAGS = -D__DOS_INLINE__ -D__IOCS_INLINE__ -DUSE_DMA - -AS = has -ASFLAGS = -LD = hlk -LDFLAGS = -l -x - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) - -scsictl.o: scsictl.c scsictl.h - $(COMPILE.c) $< - -main.o: main.c main.h scsictl.h - $(COMPILE.c) $< - -asmsub.o: asmsub.s - -# EOF - \ No newline at end of file diff --git a/src/x68k/RASETHER/asmsub.s b/src/x68k/RASETHER/asmsub.s deleted file mode 100644 index 87d85957..00000000 --- a/src/x68k/RASETHER/asmsub.s +++ /dev/null @@ -1,22 +0,0 @@ -* asmsub.s - - .xdef _DI, _EI * ne2000.c nagai. - - .text - .even - - - -_DI: - move.w sr,sendp_sr - ori.w #$700,sr - rts -_EI: - move.w sendp_sr,sr - rts - -sendp_sr: - .ds.w 1 - - - .even diff --git a/src/x68k/RASETHER/main.c b/src/x68k/RASETHER/main.c deleted file mode 100644 index 17cf4bce..00000000 --- a/src/x68k/RASETHER/main.c +++ /dev/null @@ -1,282 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// -// Powered by XM6 TypeG Technology. -// Copyright (C) 2016-2017 GIMONS -// [ RaSCSI Ethernet Main ] -// -// Based on -// Neptune-X board driver for Human-68k(ESP-X) version 0.03 -// Programed 1996-7 by Shi-MAD. -// Special thanks to Niggle, FIRST, yamapu ... -// -//--------------------------------------------------------------------------- - -#include -#include -#include -#include "main.h" -#include "scsictl.h" - -unsigned int scsiid; -int trap_no; -int num_of_prt; -struct prt PRT_LIST[NPRT]; - -// Multicast (not supported) -#ifdef MULTICAST -int num_of_multicast; -struct eaddr multicast_array[NMULTICAST]; -#endif - -/************************************************ - * * - ************************************************/ -static int sprint_eaddr(unsigned char* dst, void* e) -{ - unsigned char* p = e; - - return sprintf( - dst, - "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", - p[0], p[1], p[2], p[3], p[4], p[5]); -} - -/************************************************ - * Check if TRAP n can be used * - ************************************************/ -static int is_valid_trap(int trap_no) -{ - unsigned int addr; - - if (trap_no < 0 || 7 < trap_no) { - return 0; - } - - // Check if in use - addr = (unsigned int)_dos_intvcg(TRAP_VECNO(trap_no)); - - // Unused if the uppermost byte of the process address contains the vector number - if (addr & 0xff000000) { - return -1; - } - - return 0; -} - -/************************************************ - * Search for unused TRAP n * - ************************************************/ -static int search_trap_no(int def) -{ - int i; - - // If def is usable, choose that - if (is_valid_trap(def)) { - return def; - } - - for (i = 0; i <= 6; i++) { - if (is_valid_trap(i)) { - return i; - } - } - - return -1; -} - -/************************************************ - * vector set * - ************************************************/ -static void* trap_vector(int trap_no, void *func) -{ - return _dos_intvcs(TRAP_VECNO(trap_no), func); -} - -/************************************************ - * Init Function (call with ne.s initialize) * - ************************************************/ -int Initialize(void) -{ - unsigned char buff[128]; - unsigned char buff2[32]; - struct eaddr ether_addr; - - if (SearchRaSCSI()) - { - Print("Could not locate the RaSCSI Ethernet Adapter\r\n"); - return -1; - } - - if (InitList(NPRT) - || InitRaSCSI()) - { - Print("Failed to initialize the RaSCSI Ethernet Adapter Driver\r\n"); - return -1; - } - - memset(ðer_addr, 0x00, sizeof(ether_addr)); - GetMacAddr(ðer_addr); - - // Inspect unused trap number (prioritize specified number) - if (trap_no >= 0) { - trap_no = search_trap_no(trap_no); - } - - if (trap_no >= 0) { - // Hook the trap - trap_vector(trap_no, (void*)trap_entry); - sprintf(buff, " API trap number:%d ", trap_no); - } else { - sprintf(buff, " API trap number:n/a "); - } - Print(buff); - - sprintf(buff, "SCSI ID:%d ", scsiid); - Print(buff); - - sprint_eaddr(buff2, ether_addr.eaddr); - sprintf(buff, "MAC Addr:%s\r\n", buff2); - Print(buff); - - // Start polling - RegisterIntProcess(poll_interval); - - return 0; -} - -/************************************************ - * Initialize Protocol List * - ************************************************/ -int InitList(int n) -{ - struct prt* p; - int i; - - p = &PRT_LIST[0]; - for (i = 0; i < NPRT; i++, p++) { - p->type = -1; - p->func = 0; - p->malloc = (malloc_func)-1; - } - num_of_prt = 0; - -#ifdef MULTICAST - num_of_multicast = 0; -#endif - - return 0; -} - -/************************************************ - * Add Receive Handler (protocol) * - ************************************************/ -int AddList(int type, int_handler handler) -{ - struct prt* p; - int i, result; - - if (type == -1) { - return -1; - } - - result = -1; - - // overwrite if already exist - p = &PRT_LIST[0]; - for (i = 0; i < NPRT; i++, p++) { - if ((p->type == type && p->malloc != (malloc_func)-1) - || p->type == -1) - { - if (p->type == -1) - num_of_prt++; - - p->type = type; - p->func = handler; - p->malloc = (malloc_func)-1; - i++; - p++; - result = 0; - break; - } - } - - // clear if exist more - for (; i < NPRT; i++, p++) { - if (p->type == type && p->malloc != (malloc_func)-1) { - p->type = -1; - } - } - - return result; -} - -/************************************************ - * Delete Receive Handler (protocol) * - ************************************************/ -int DeleteList(int type) -{ - struct prt* p; - int i, result; - - if (type == -1) { - return -1; - } - - result = -1; - for (i = 0, p = &PRT_LIST[0]; i < NPRT; i++, p++) { - if (p->type == type && p->malloc != (malloc_func)-1) { - p->type = -1; - result = 0; - num_of_prt--; - } - } - - return result; -} - -/************************************************ - * Search Receive Handler (protocol) * - ************************************************/ -int_handler SearchList(int type) -{ - struct prt* p; - int i; - - if (type == -1) { - return 0; - } - - for (i = 0, p = &PRT_LIST[0]; i < NPRT; i++, p++) { - if (p->type == type) { - return p->func; - } - } - - return 0; -} - - -/************************************************ - * Search Receive Handler (protocol) * - ************************************************/ -int_handler SearchList2(int type, int n) -{ - struct prt *p; - int i, cur; - - if (type == -1) { - return NULL; - } - - cur = 0; - for (i = 0, p = &PRT_LIST[0]; i < NPRT; i++, p++) { - if (p->type == type && cur++ == n) { - return p->func; - } - } - - return NULL; -} diff --git a/src/x68k/RASETHER/main.h b/src/x68k/RASETHER/main.h deleted file mode 100644 index 68a41cee..00000000 --- a/src/x68k/RASETHER/main.h +++ /dev/null @@ -1,81 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// -// Powered by XM6 TypeG Technology. -// Copyright (C) 2016-2017 GIMONS -// [ RaSCSI Ethernet Main ] -// -// Based on -// Neptune-X board driver for Human-68k(ESP-X) version 0.03 -// Programed 1996-7 by Shi-MAD. -// Special thanks to Niggle, FIRST, yamapu ... -// -//--------------------------------------------------------------------------- - -#ifndef main_h -#define main_h - -#define ID_EN0 (('e'<<24)+('n'<<16)+('0'<<8)) -#undef MULTICAST - -// number of protocol type we can handle **EDIT this** -#define NPRT (16) - -// number of multicast address we can handle **EDIT this** -#define NMULTICAST (64) -/* However, multicast is not yet supported */ - -struct eaddr { - unsigned char eaddr [6]; -}; - -typedef void (*int_handler) (int, void*, int); -typedef void (*malloc_func) (unsigned int*); - -struct prt { - int type; - int_handler func; - malloc_func malloc; -}; - - -// Global variables -extern unsigned int scsiid; -extern int trap_no; -extern int num_of_prt; -extern struct prt PRT_LIST [NPRT]; - -#ifdef MULTICAST -extern int num_of_multicast; -extern struct eaddr multicast_array [NMULTICAST]; -#endif - - -// Prototype declarations -extern int Initialize (void); -extern int InitList (int); -extern int AddList (int, int_handler); -extern int DeleteList (int); -extern int_handler SearchList (int); -extern int_handler SearchList2 (int, int); -extern malloc_func GetMallocFunc (int, int); - -#ifdef MULTICAST -extern int AddMulticastArray (struct eaddr*); -extern void DelMulticastArray (struct eaddr*); -extern void MakeMulticastTable (unsigned char*); -#endif - - -// Function within ne.s -extern void trap_entry (void); - - -#include -#define Print _iocs_b_print - -#define TRAP_VECNO(n) (0x20 + n) - -#endif // main_h diff --git a/src/x68k/RASETHER/re.s b/src/x68k/RASETHER/re.s deleted file mode 100644 index 1ff0c65b..00000000 --- a/src/x68k/RASETHER/re.s +++ /dev/null @@ -1,574 +0,0 @@ -**--------------------------------------------------------------------------- -** -** SCSI Target Emulator RaSCSI (*^..^*) -** for Raspberry Pi -** -** Powered by XM6 TypeG Technology. -** Copyright (C) 2016-2017 GIMONS -** [ RaSCSI Ethernet Driver ] -** -** Based on -** Neptune-X board driver for Human-68k(ESP-X) version 0.03 -** Programed 1996-7 by Shi-MAD. -** Special thanks to Niggle, FIRST, yamapu ... -** -**--------------------------------------------------------------------------- - -* Include Files ----------------------- * - - .include doscall.mac - .include iocscall.mac - - -* Global Symbols ---------------------- * - -* -* For C language: external declarations -* - .xref _Initialize, _AddList, _SearchList, _DeleteList ;main.c - .xref _GetMacAddr, _SetMacAddr ;scsictl.c - .xref _SendPacket, _SetPacketReception ;scsictl.c -* .xref _AddMulticastAddr, _DelMulticastAddr ;not implemented - -* -* For C language: external functions -* - .xref _num_of_prt ;main.c Number of registered protocols - .xref _trap_no ;Used trap number - .xref _trans_counter ;scsictl.c Number of send/receive bytes - .xref _intr_type ;scsictl.c Type of interrupt - .xref _poll_interval ;scsictl.c Polling interval - - -* Text Section -------------------------------- * - - .cpu 68000 - .text - - -* -* Device Header -* -device_header: - .dc.l -1 ;link pointer - .dc $8000 ;device att. - .dc.l strategy_entry ;strategy entry - .dc.l interupt_entry ;interrupt entry - .dc.b '/dev/en0' ;device name - .dc.b 'EthD' ;for etherlib.a - .dc.b 'RASC' ;driver name (put in entry later) - -* Don not put anything between 'RASC' and superjsr_entry - -* -* Ether Driver Function Entry ( for DOS _SUPERJSR ) -* in: d0: command number -* a0: args -* -superjsr_entry: - movem.l d1-d7/a1-a7,-(sp) - -* move.l d0,-(sp) -* pea (mes11,pc) -* DOS _PRINT -* addq.l #4,sp -* move.l (sp)+,d0 -* .data -*mes11: .dc.b 'en0:spjEntry',13,10,0 -* .text - - bsr do_command - movem.l (sp)+,d1-d7/a1-a7 - rts ;normal return - - -* -* Ether Driver Function Entry ( for trap #n ) -* in: d0: command number -* a0: args -* -_trap_entry:: - movem.l d1-d7/a1-a7,-(sp) - -* move.l d0,-(sp) -* pea (mes10,pc) -* DOS _PRINT -* addq.l #4,sp -* move.l (sp)+,d0 -* .data -*mes10: .dc.b 'en0:trapEntry',13,10,0 -* .text - - bsr do_command - movem.l (sp)+,d1-d7/a1-a7 - rte ;interrupt return - - -* -* Assign each command -* -do_command: - moveq #FUNC_MIN,d1 - cmp.l d0,d1 - bgt error ;d0<-2 is an unsupported command number - moveq #FUNC_MAX,d1 - cmp.l d1,d0 - bgt error ;9) - .dc get_statistics-jumptable ;09 ... (Read out statistics ) -FUNC_MAX: .equ ($-jumptable)/2-1 - - -* -* Command -2: Return transfer counter address -* return: address -* -get_cnt_addr: - pea (_trans_counter,pc) - move.l (sp)+,d0 - rts - - -* -* Command -1: Return used trap number -* return: trap number to use (-1:use SUPERJSR) -* -driver_entry: -* pea (mesff,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mesff: .dc.b 'DriverEntry',13,10,0 -* .text - - move.l (_trap_no,pc),d0 ;trap_no ... main.c variable - rts - - -* -* Command 00: Return driver version -* return: version number (Ex... for ver1.00 return 100) -* -get_driver_version: -* pea (mes00,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes00: .dc.b 'GetDriverVersion',13,10,0 -* .text - - moveq #3,d0 ;ver 0.03 - rts - - -* -* Command 01: Get current MAC address -* return: same as *dst -* -get_mac_addr: -* pea (mes01,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes01: .dc.b 'GetMacAddr',13,10,0 -* .text - - pea (a0) - pea (a0) - bsr _GetMacAddr ;scsictl.c function - addq.l #4,sp - move.l (sp)+,d0 ;Return d0 for parameter a0 - rts - -* -* Command 02: Get MAC address written to EEPROM -* return: same as *dst -* -get_prom_addr: -* pea (mes02,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes02: .dc.b 'GePromAddr',13,10,0 -* .text - - pea (a0) - pea (a0) - bsr _GetMacAddr ;scsictl.c function - addq.l #4,sp - move.l (sp)+,d0 ;Return d0 for parameter a0 - rts - -* -* Command 03: Set MAC address -* return: 0 (if no errors) -* -set_mac_addr: -* pea (mes03,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes03: .dc.b 'SetMacAddr',13,10,0 -* .text - - pea (a0) - bsr _SetMacAddr ;scsictl.c function - addq.l #4,sp - rts - - -* -* Command 04: Send packet -* packet contents: -* Distination MAC: 6 bytes -* Source(own) MAC: 6 bytes -* Protcol type: 2 bytes -* Data: ? bytes -* return: 0 (if no errors) -* -send_packet: -* pea (mes04,pc) -* DOS _PRINT -* addq.l #4,sp - - move.l (a0)+,d0 ;packet size - move.l (a0),-(sp) ;packet address - move.l d0,-(sp) - bsr _SendPacket ;scsictl.c function - addq.l #8,sp - -* move.l d0,-(sp) -* pea (mes04e,pc) -* DOS _PRINT -* addq.l #4,sp -* move.l (sp)+,d0 -* .data -*mes04: .dc.b 13,10,'SendPacket,13,10',0 -*mes04e:.dc.b 13,10,'SendPacket finished',13,10,0 -* .text - - rts - - -* -* Command 05: Set / add receive interrupt handler -* type: 0x00000800 IP packet -* 0x00000806 ARP packet -* return: 0 (if no errors) -* -set_int_addr: -* pea (mes05,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes05: .dc.b 'SetIntAddr',13,10,0 -* .text - - move.l (a0)+,d0 ;protocol number - move.l (a0),-(sp) ;address to handler function - move.l d0,-(sp) - bsr _AddList ;main.c function - addq.l #8,sp - tst.l d0 - bmi set_int_addr_rts ;Registration failed - - cmpi.l #1,(_num_of_prt) ;Permit interrupt if number of handlers is 1 - bne set_int_addr_rts - - pea (1) ;1= - bsr _SetPacketReception ;interrupt permitted ... scsictl.c - addq.l #4,sp - -* moveq #0,d0 ;SetPacketReception() always returns 0 so bypass -set_int_addr_rts: - rts - - -* -* Command 06: Get interrupt handler and address -* return: interupt address -* -get_int_addr: -* pea (mes07,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes07: .dc.b 'GetIntAddr',13,10,0 -* .text - - pea (a0) - bsr _SearchList - addq.l #4,sp - rts - - -* -* Command 07: Delete interrupt handler -* return: 0 (if no errors) -* -del_int_addr: -* pea (mes06,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes06: .dc.b 'DelIntAddr',13,10,0 -* .text - - pea (a0) - bsr _DeleteList ;main.c function - move.l d0,(sp)+ - bmi del_int_addr_ret ;Delete failed - - tst.l (_num_of_prt) ;Forbid interrupts if handlers are gone - bne del_int_addr_ret - - clr.l -(sp) ;0= - bsr _SetPacketReception ;Interrupt forbitten ... scsictl.c - addq.l #4,sp - -* moveq #0,d0 ;SetPacketReception() always returns 0 so bypass -del_int_addr_ret: - rts - - -* -* Command 08: Set multicast address -* -set_multicast_addr: -* pea (mes08,pc) -* .data -* DOS _PRINT -* addq.l #4,sp -*mes08: .dc.b 'SetMulticastAddr',13,10,0 -* .text - - moveq #0,d0 - rts - - -* -* Command 09: Read out statistics -* -get_statistics: -* pea (mes09,pc) -* DOS _PRINT -* addq.l #4,sp -* .data -*mes09: .dc.b 'GetStatistics',13,10,0 -* .text - - moveq #0,d0 - rts - -* -* Device Driver Entry -* -strategy_entry: - move.l a5,(request_buffer) - rts - - -interupt_entry: - move.l sp,(stack_buff) ;Use own stack area - lea (def_stack),sp ; - - movem.l d1-d7/a0-a5,-(sp) - movea.l (request_buffer,pc),a5 - tst.b (2,a5) - bne errorret - - pea (mestitle,pc) - DOS _PRINT - addq.l #4,sp - movea.l (18,a5),a4 -@@: - tst.b (a4)+ - bne @b - - moveq #0,d0 - move.l d0,(_trap_no) - move.l d0,(_intr_type) - moveq #1,d0 - move.l d0,(_poll_interval) - -arg_loop: - move.b (a4)+,d0 - beq arg_end - cmpi.b #'-',d0 - beq @f - cmpi.b #'/',d0 - bne param_errret -@@: - move.b (a4)+,d0 - beq param_errret -opt_loop: - andi.b #$df,d0 - cmpi.b #'I',d0 - beq opt_i - cmpi.b #'P',d0 - beq opt_p - cmpi.b #'T',d0 - beq opt_t - cmpi.b #'N',d0 - beq opt_n - bra param_errret - -opt_n: - moveq #-1,d0 - move.l d0,(_trap_no) - move.b (a4)+,d0 - beq arg_loop - bra opt_loop - -opt_t: - bsr get_num - tst.b d0 - bne param_errret - cmpi #6,d2 - bgt param_errret - move.l d2,(_trap_no) - move.b (a4)+,d0 - beq arg_loop - bra opt_loop - -opt_p: - bsr get_num - tst.b d0 - bne param_errret - cmpi #1,d2 - blt param_errret - cmpi #8,d2 - bgt param_errret - move.l d2,(_poll_interval) - move.b (a4)+,d0 - beq arg_loop - bra opt_loop - -opt_i: - bsr get_num - tst.b d0 - bne param_errret - cmpi #1,d2 - bgt param_errret - move.l d2,(_intr_type) - move.b (a4)+,d0 - beq arg_loop - bra opt_loop - -arg_end: - bsr _Initialize ;main.c function - ;Set I/O address - ;Get MAC address - ;Init protocol list - ;Init SCSICTL - ;Interrupt handler (set vector) - ;trap service (set vector) - tst.l d0 - bne errorret - -* moveq #0,d0 - move.l #prog_end,(14,a5) - bra intret - - -param_errret: - pea (mesparam_err,pc) - DOS _PRINT - addq.l #4,sp -errorret: - move #$5003,d0 -intret: - move.b d0,(4,a5) - lsr #8,d0 - move.b d0,(3,a5) - movem.l (sp)+,d1-d7/a0-a5 - - movea.l (stack_buff,pc),sp ;Restore stack pointer - rts - -get_num: - moveq #1,d0 - moveq #0,d1 - moveq #0,d2 -@@: - move.b (a4),d1 - subi.b #'0',d1 - bcs @f - cmpi.b #9,d1 - bgt @f - move.b #0,d0 - andi #$f,d1 - mulu #10,d2 - add d1,d2 - addq.l #1,a4 - bra @b -@@: - rts - - -* Data Section ------------------------ * - - .data -mestitle: - .dc.b 13,10 - .dc.b 'RaSCSI Ethernet Driver version 1.20 / Based on ether_ne.sys+M01L12',13,10 - .dc.b 0 -mesparam_err: - .dc.b 'Invalid parameter',13,10,0 - .even - - -* BSS --------------------------------- * - - .bss - .quad - -stack_buff: - .ds.l 1 -request_buffer: - .ds.l 1 -stack_buff_i: - .ds.l 1 - - -* Stack Section ----------------------- * - - .stack - .quad - -* -* Stack area -* - .ds.b 1024*8 -def_stack: - -prog_end: - .end - - -* EOF --------------------------------- * diff --git a/src/x68k/RASETHER/scsictl.c b/src/x68k/RASETHER/scsictl.c deleted file mode 100644 index 9051710b..00000000 --- a/src/x68k/RASETHER/scsictl.c +++ /dev/null @@ -1,537 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// -// Powered by XM6 TypeG Technology. -// Copyright (C) 2016-2017 GIMONS -// [ RaSCSI Ethernet SCSI Control Department ] -// -// Based on -// Neptune-X board driver for Human-68k(ESP-X) version 0.03 -// Programed 1996-7 by Shi-MAD. -// Special thanks to Niggle, FIRST, yamapu ... -// -//--------------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include "main.h" -#include "scsictl.h" - -typedef struct -{ - char DeviceType; - char RMB; - char ANSI_Ver; - char RDF; - char AddLen; - char RESV0; - char RESV1; - char OptFunc; - char VendorID[8]; - char ProductID[16]; - char FirmRev[4]; -} INQUIRY_T; - -typedef struct -{ - INQUIRY_T info; - char options[8]; -} INQUIRYOPT_T; - -#define MFP_AEB 0xe88003 -#define MFP_IERB 0xe88009 -#define MFP_IMRB 0xe88015 - -// Subroutine in asmsub.s -extern void DI(); -extern void EI(); - -volatile short* iocsexec = (short*)0xa0e; // Work when executin IOCS -struct trans_counter trans_counter; // Transfer counter -unsigned char rx_buff[2048]; // Receive buffer -int imr; // Interrupt permission flag -int scsistop; // SCSI stopped flag -int intr_type; // Interrupt type (0:V-DISP 1:TimerA) -int poll_interval; // Polling interval (configure) -int poll_current; // Polling interval (current) -int idle; // Idle counter - -#define POLLING_SLEEP 255 // 4-5s - -/************************************************ - * Execute command to get MAC address * - ************************************************/ -int SCSI_GETMACADDR(unsigned char *mac) -{ - unsigned char cmd[10]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return 0; - } - - cmd[0] = 0x28; - cmd[1] = 0; - cmd[2] = 1; - cmd[3] = 0; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = 0; - cmd[7] = 0; - cmd[8] = 6; - cmd[9] = 0; - if (S_CMDOUT(10, cmd) != 0) { - return 0; - } - -#ifdef USE_DMA - if (S_DATAIN(6, mac) != 0) { -#else - if (S_DATAIN_P(6, mac) != 0) { -#endif - return 0; - } - - S_STSIN(&sts); - S_MSGIN(&msg); - - return 1; -} - -/************************************************ - * Execute command to configure MAC address * - ************************************************/ -int SCSI_SETMACADDR(const unsigned char *mac) -{ - unsigned char cmd[10]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return 0; - } - - cmd[0] = 0x2a; - cmd[1] = 0; - cmd[2] = 1; - cmd[3] = 0; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = 0; - cmd[7] = 0; - cmd[8] = 6; - cmd[9] = 0; - if (S_CMDOUT(10, cmd) != 0) { - return 0; - } - -#ifdef USE_DMA - S_DATAOUT(6, mac); -#else - S_DATAOUT_P(6, mac); -#endif - - S_STSIN(&sts); - S_MSGIN(&msg); - - return 1; -} - -/************************************************ - * Execute command to get received packet size* - ************************************************/ -int SCSI_GETPACKETLEN(int *len) -{ - unsigned char cmd[10]; - unsigned char buf[2]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return 0; - } - - cmd[0] = 0x28; - cmd[1] = 0; - cmd[2] = 1; - cmd[3] = 1; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = 0; - cmd[7] = 0; - cmd[8] = 2; - cmd[9] = 0; - if (S_CMDOUT(10, cmd) != 0) { - return 0; - } - -#ifdef USE_DMA - if (S_DATAIN(2, buf) != 0) { -#else - if (S_DATAIN_P(2, buf) != 0) { -#endif - return 0; - } - - S_STSIN(&sts); - S_MSGIN(&msg); - - *len = (int)(buf[0] << 8) + (int)(buf[1]); - - return 1; -} - -/************************************************ - * Execute receive packet command * - ************************************************/ -int SCSI_GETPACKETBUF(unsigned char *buf, int len) -{ - unsigned char cmd[10]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return 0; - } - - cmd[0] = 0x28; - cmd[1] = 0; - cmd[2] = 1; - cmd[3] = 1; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = (unsigned char)(len >> 16); - cmd[7] = (unsigned char)(len >> 8); - cmd[8] = (unsigned char)len; - cmd[9] = 1; - if (S_CMDOUT(10, cmd) != 0) { - return 0; - } - -#ifdef USE_DMA - if (S_DATAIN(len, buf) != 0) { -#else - if (S_DATAIN_P(len, buf) != 0) { -#endif - return 0; - } - - S_STSIN(&sts); - S_MSGIN(&msg); - - return 1; -} - -/************************************************ - * Execute packet send command * - ************************************************/ -int SCSI_SENDPACKET(const unsigned char *buf, int len) -{ - unsigned char cmd[10]; - unsigned char sts; - unsigned char msg; - - if (S_SELECT(scsiid) != 0) { - return 0; - } - - cmd[0] = 0x2a; - cmd[1] = 0; - cmd[2] = 1; - cmd[3] = 1; - cmd[4] = 0; - cmd[5] = 0; - cmd[6] = (unsigned char)(len >> 16); - cmd[7] = (unsigned char)(len >> 8); - cmd[8] = (unsigned char)len; - cmd[9] = 0; - if (S_CMDOUT(10, cmd) != 0) { - return 0; - } - -#ifdef USE_DMA - S_DATAOUT(len, buf); -#else - S_DATAOUT_P(len, buf); -#endif - S_STSIN(&sts); - S_MSGIN(&msg); - - return 1; -} - -/************************************************ - * Get MAC address * - ************************************************/ -int GetMacAddr(struct eaddr* buf) -{ - if (SCSI_GETMACADDR(buf->eaddr) != 0) { - return 0; - } else { - return -1; - } -} - -/************************************************ - * Set MAC address * - ************************************************/ -int SetMacAddr(const struct eaddr* data) -{ - if (SCSI_SETMACADDR(data->eaddr) != 0) { - return 0; - } else { - return -1; - } -} - -/************************************************ - * Search RaSCSI * - ************************************************/ -int SearchRaSCSI() -{ - int i; - INQUIRYOPT_T inq; - - for (i = 0; i <= 7; i++) { - // Search for BRIDGE device - if (S_INQUIRY(sizeof(INQUIRY_T) , i, (struct INQUIRY*)&inq) < 0) { - continue; - } - - if (memcmp(&(inq.info.ProductID), "RASCSI BRIDGE", 13) != 0) { - continue; - } - - // Get TAP initialization status - if (S_INQUIRY(sizeof(INQUIRYOPT_T) , i, (struct INQUIRY*)&inq) < 0) { - continue; - } - - if (inq.options[1] != '1') { - continue; - } - - // Configure SCSI ID - scsiid = i; - return 0; - } - - return -1; -} - -/************************************************ - * Init RaSCSI method * - ************************************************/ -int InitRaSCSI(void) -{ -#ifdef MULTICAST - unsigned char multicast_table[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; -#endif - - imr = 0; - scsistop = 0; - poll_current = -1; - idle = 0; - - return 0; -} - -/************************************************ - * RaSCSI interrupt handler function (polling) * - ************************************************/ -void interrupt IntProcess(void) -{ - unsigned char phase; - unsigned int len; - int type; - int_handler func; - int i; - - // V-DISP GPIP interrupt idle count control - if (intr_type == 0) { - // Increment idle - idle++; - - // Skip if not yet next scheduled processing - if (idle < poll_current) { - return; - } - - // Clear idle counter - idle = 0; - } - - // Start interrupt - - // Only when interrupt is permitted - if (imr == 0) { - return; - } - - // Skip if executing IOCS - if (*iocsexec != -1) { - return; - } - - // Interrupt forbidden if receiving data - DI (); - - // Only in bus free phase - phase = S_PHASE(); - if (phase != 0) { - // Exit - goto ei_exit; - } - - // Receive data - if (SCSI_GETPACKETLEN(&len) == 0) { - // RaSCSI is stopped - scsistop = 1; - - // Reset polling interval (sleep) - UpdateIntProcess(POLLING_SLEEP); - - // Exit - goto ei_exit; - } - - // RaSCSI is stopped - if (scsistop) { - scsistop = 0; - - // Reset polling interval (hurry) - UpdateIntProcess(poll_interval); - } - - // Packets did not arrive - if (len == 0) { - // Exit - goto ei_exit; - } - - // Tranfer packets to receive buffer memory - if (SCSI_GETPACKETBUF(rx_buff, len) == 0) { - // Fail - goto ei_exit; - } - - // Interrupt permitted - EI (); - - // Split data by packet type - type = rx_buff[12] * 256 + rx_buff[13]; - i = 0; - while ((func = SearchList2(type, i))) { - i++; - func(len, (void*)&rx_buff, ID_EN0); - } - trans_counter.recv_byte += len; - return; - -ei_exit: - // Interrupt permitted - EI (); -} - -/************************************************ - * RaSCSI Send Packets Function (from ne.s) * - ************************************************/ -int SendPacket(int len, const unsigned char* data) -{ - if (len < 1) { - return 0; - } - - if (len > 1514) { // 6 + 6 + 2 + 1500 - return -1; // Error - } - - // If RaSCSI seems to be stopped, throw an error - if (scsistop) { - return -1; - } - - // Interrupt is not permitted during sending - DI (); - - // Send processing and raise send flag - if (SCSI_SENDPACKET(data, len) == 0) { - // Interrupt permitted - EI (); - return -1; - } - - // Interrupt permitted - EI (); - - // Finished requesting send - trans_counter.send_byte += len; - - return 0; -} - -/************************************************ - * RaSCSI Interrupt Permission Setting Function* - ************************************************/ -int SetPacketReception(int i) -{ - imr = i; - return 0; -} - -/************************************************ - * RaSCSI Interrupt Processing Registration * - ************************************************/ -void RegisterIntProcess(int n) -{ - volatile unsigned char *p; - - // Update polling interval (current) and clear idle counter - poll_current = n; - idle = 0; - - if (intr_type == 0) { - // Overwrite V-DISP GPIP interrupt vectors - // and enable interrupt - B_INTVCS(0x46, (int)IntProcess); - p = (unsigned char *)MFP_AEB; - *p = *p | 0x10; - p = (unsigned char *)MFP_IERB; - *p = *p | 0x40; - p = (unsigned char *)MFP_IMRB; - *p = *p | 0x40; - } else if (intr_type == 1) { - // Set TimerA counter mode - VDISPST(NULL, 0, 0); - VDISPST(IntProcess, 0, poll_current); - } -} - -/************************************************ - * RaSCSI Interrupt Processing Update * - ************************************************/ -void UpdateIntProcess(int n) -{ - // Do not update if polling interval (current) is the same - if (n == poll_current) { - return; - } - - // Update polling interval (current) and clear idle counter - poll_current = n; - idle = 0; - - if (intr_type == 1) { - // TimerA requires re-registering - VDISPST(NULL, 0, 0); - VDISPST(IntProcess, 0, poll_current); - } -} - -// EOF diff --git a/src/x68k/RASETHER/scsictl.h b/src/x68k/RASETHER/scsictl.h deleted file mode 100644 index a13ea178..00000000 --- a/src/x68k/RASETHER/scsictl.h +++ /dev/null @@ -1,40 +0,0 @@ -//--------------------------------------------------------------------------- -// -// SCSI Target Emulator RaSCSI (*^..^*) -// for Raspberry Pi -// -// Powered by XM6 TypeG Technology. -// Copyright (C) 2016-2017 GIMONS -// [ RaSCSI Ethernet SCSI Control Department ] -// -// Based on -// Neptune-X board driver for Human-68k(ESP-X) version 0.03 -// Programed 1996-7 by Shi-MAD. -// Special thanks to Niggle, FIRST, yamapu ... -// -//--------------------------------------------------------------------------- - -#ifndef scsictl_h -#define scsictl_h - -// Global variables -extern int intr_type; -extern int poll_interval; - -// Transfer counter -struct trans_counter { - unsigned int send_byte; - unsigned int recv_byte; -}; -extern struct trans_counter trans_counter; - -extern int SearchRaSCSI(); -extern int InitRaSCSI(void); -extern int GetMacAddr(struct eaddr* buf); -extern int SetMacAddr(const struct eaddr* data); -extern int SetPacketReception(int i); -extern int SendPacket(int len, const unsigned char* data); -extern void RegisterIntProcess(int n); -extern void UpdateIntProcess(int n); - -#endif // scsictl_h