diff --git a/src/raspberrypi/controllers/scsidev_ctrl.cpp b/src/raspberrypi/controllers/scsidev_ctrl.cpp index b8699d55..e8360532 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.cpp +++ b/src/raspberrypi/controllers/scsidev_ctrl.cpp @@ -164,18 +164,25 @@ void SCSIDEV::BusFree() // When the bus is free RaSCSI or the Pi may be shut down switch(shutdown_mode) { - case RASCSI: + case STOP_RASCSI: LOGINFO("RaSCSI shutdown requested"); exit(0); break; - case PI: + case STOP_PI: LOGINFO("Raspberry Pi shutdown requested"); if (system("init 0") == -1) { LOGERROR("Raspberry Pi shutdown failed: %s", strerror(errno)); } break; + case RESTART_PI: + LOGINFO("Raspberry Pi restart requested"); + if (system("init 6") == -1) { + LOGERROR("Raspberry Pi restart failed: %s", strerror(errno)); + } + break; + default: break; } diff --git a/src/raspberrypi/controllers/scsidev_ctrl.h b/src/raspberrypi/controllers/scsidev_ctrl.h index 9a3621cd..68fc3772 100644 --- a/src/raspberrypi/controllers/scsidev_ctrl.h +++ b/src/raspberrypi/controllers/scsidev_ctrl.h @@ -29,8 +29,9 @@ public: enum rascsi_shutdown_mode { NONE, - RASCSI, - PI + STOP_RASCSI, + STOP_PI, + RESTART_PI }; // Internal data definition diff --git a/src/raspberrypi/devices/host_services.cpp b/src/raspberrypi/devices/host_services.cpp index 6a141399..c2272e8c 100644 --- a/src/raspberrypi/devices/host_services.cpp +++ b/src/raspberrypi/devices/host_services.cpp @@ -27,9 +27,10 @@ // uint8_t second; // 0-59 // } mode_page_datetime; // -// 2. STOP UNIT shuts down RaSCSI or the Raspberry Pi +// 2. START/STOP UNIT shuts down RaSCSI or shuts down/reboots the Raspberry Pi // a) !start && !load (STOP): Shut down RaSCSI // b) !start && load (EJECT): Shut down the Raspberry Pi +// c) start && load (LOAD): Reboot the Raspberry Pi // #include "controllers/scsidev_ctrl.h" @@ -77,15 +78,23 @@ void HostServices::StartStopUnit(SCSIDEV *controller) } if (load) { - controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::PI); + controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::STOP_PI); } else { - controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::RASCSI); + controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::STOP_RASCSI); } controller->Status(); return; } + else { + if (load) { + controller->ScheduleShutDown(SCSIDEV::rascsi_shutdown_mode::RESTART_PI); + + controller->Status(); + return; + } + } controller->Error(ERROR_CODES::sense_key::ILLEGAL_REQUEST, ERROR_CODES::asc::INVALID_FIELD_IN_CDB); }