mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-20 12:21:10 -05:00
Additional updates
This commit is contained in:
2
src/raspberrypi/.vscode/tasks.json
vendored
2
src/raspberrypi/.vscode/tasks.json
vendored
@@ -5,7 +5,7 @@
|
||||
"type": "shell",
|
||||
"label": "g++ build active file",
|
||||
"command": "make",
|
||||
"args": ["all", "DEBUG=1"],
|
||||
"args": ["all", "DEBUG=1", "ARCH=", "CROSS_COMPILE="],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/"
|
||||
},
|
||||
|
||||
@@ -21,17 +21,27 @@
|
||||
|
||||
#include "os.h"
|
||||
#include "rasctl_command.h"
|
||||
#include "sasihd.h"
|
||||
#include "scsihd.h"
|
||||
#include "scsihd_nec.h"
|
||||
#include "scsihd_apple.h"
|
||||
#include "scsicd.h"
|
||||
#include "scsimo.h"
|
||||
#include "scsi_host_bridge.h"
|
||||
#include "devices/sasihd.h"
|
||||
#include "devices/scsihd.h"
|
||||
#include "devices/scsihd_nec.h"
|
||||
#include "devices/scsihd_apple.h"
|
||||
#include "devices/scsicd.h"
|
||||
#include "devices/scsimo.h"
|
||||
#include "devices/scsi_host_bridge.h"
|
||||
|
||||
int Command_Thread::m_monsocket = -1; // Monitor Socket
|
||||
pthread_t Command_Thread::m_monthread; // Monitor Thread
|
||||
|
||||
// These objects are currently in rascsi.cpp. They should eventually be
|
||||
// broken out.
|
||||
extern volatile BOOL running; // Running flag
|
||||
extern volatile BOOL active; // Processing flag
|
||||
void ListDevice(FILE *fp);
|
||||
Disk* GetDevice(FILE *fp, int id, int un);
|
||||
BOOL AttachDevice(FILE *fp, Disk *pUnit, int id, int un);
|
||||
BOOL DetachDevice(FILE *fp, int id, int un);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Initialization
|
||||
@@ -304,7 +314,7 @@ void *Command_Thread::MonThread(void *param)
|
||||
// Setup the monitor socket to receive commands
|
||||
listen(m_monsocket, 1);
|
||||
|
||||
while (Rascsi_Manager::IsRunning()) {
|
||||
while (running) {
|
||||
// Wait for connection
|
||||
memset(&client, 0, sizeof(client));
|
||||
len = sizeof(client);
|
||||
@@ -319,14 +329,14 @@ void *Command_Thread::MonThread(void *param)
|
||||
|
||||
// If we received a command....
|
||||
if (p) {
|
||||
|
||||
// Decode the received buffer into a Command object
|
||||
new_command = Rasctl_Command::DeSerialize(p,BUFSIZ);
|
||||
|
||||
// If the command was successfully parsed
|
||||
if(new_command != nullptr){
|
||||
// Execute the command
|
||||
ExecuteCommand(fp, new_command);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Release the connection
|
||||
@@ -380,12 +390,12 @@ BOOL Command_Thread::ExecuteCommand(FILE *fp, Rasctl_Command *incoming_command)
|
||||
|
||||
BOOL Command_Thread::DoShutdown(FILE *fp, Rasctl_Command *incoming_command){
|
||||
fprintf(fp, "Stopping the RaSCSI application\n");
|
||||
Rascsi_Manager::Stop();
|
||||
running = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Command_Thread::DoList(FILE *fp, Rasctl_Command *incoming_command){
|
||||
Rascsi_Manager::ListDevice(fp);
|
||||
ListDevice(fp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -453,17 +463,17 @@ BOOL Command_Thread::DoAttach(FILE *fp, Rasctl_Command *incoming_command){
|
||||
pUnit->SetCacheWB(FALSE);
|
||||
|
||||
// Map the controller
|
||||
return Rascsi_Manager::AttachDevice(fp, pUnit, incoming_command->id, incoming_command->un);
|
||||
return AttachDevice(fp, pUnit, incoming_command->id, incoming_command->un);
|
||||
}
|
||||
|
||||
BOOL Command_Thread::DoDetach(FILE *fp, Rasctl_Command *incoming_command){
|
||||
return Rascsi_Manager::DetachDevice(fp, incoming_command->id, incoming_command->un);
|
||||
return DetachDevice(fp, incoming_command->id, incoming_command->un);
|
||||
}
|
||||
|
||||
BOOL Command_Thread::DoInsert(FILE *fp, Rasctl_Command *incoming_command){
|
||||
|
||||
Filepath filepath;
|
||||
Disk *pUnit = Rascsi_Manager::GetDevice(fp, incoming_command->id, incoming_command->un);
|
||||
Disk *pUnit = GetDevice(fp, incoming_command->id, incoming_command->un);
|
||||
|
||||
|
||||
// Does the device exist?
|
||||
@@ -491,7 +501,7 @@ BOOL Command_Thread::DoInsert(FILE *fp, Rasctl_Command *incoming_command){
|
||||
return TRUE;
|
||||
}
|
||||
BOOL Command_Thread::DoEject(FILE *fp, Rasctl_Command *incoming_command){
|
||||
Disk *pUnit = Rascsi_Manager::GetDevice(fp, incoming_command->id, incoming_command->un);
|
||||
Disk *pUnit = GetDevice(fp, incoming_command->id, incoming_command->un);
|
||||
|
||||
// Does the device exist?
|
||||
if (pUnit == nullptr) {
|
||||
@@ -511,7 +521,7 @@ BOOL Command_Thread::DoEject(FILE *fp, Rasctl_Command *incoming_command){
|
||||
|
||||
BOOL Command_Thread::DoProtect(FILE *fp, Rasctl_Command *incoming_command){
|
||||
|
||||
Disk *pUnit = Rascsi_Manager::GetDevice(fp, incoming_command->id, incoming_command->un);
|
||||
Disk *pUnit = GetDevice(fp, incoming_command->id, incoming_command->un);
|
||||
|
||||
// Does the device exist?
|
||||
if (pUnit == nullptr) {
|
||||
|
||||
@@ -117,6 +117,12 @@
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/(sizeof(x[0])))
|
||||
|
||||
#ifdef BAREMETAL
|
||||
#define FPRT(fp, ...) printf( __VA_ARGS__ )
|
||||
#else
|
||||
#define FPRT(fp, ...) fprintf(fp, __VA_ARGS__ )
|
||||
#endif // BAREMETAL
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Basic Type Definitions
|
||||
|
||||
@@ -33,19 +33,17 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#define CtrlMax 8 // Maximum number of SCSI controllers
|
||||
#define UnitNum 2 // Number of units around controller
|
||||
#ifdef BAREMETAL
|
||||
#define FPRT(fp, ...) printf( __VA_ARGS__ )
|
||||
#else
|
||||
#define FPRT(fp, ...) fprintf(fp, __VA_ARGS__ )
|
||||
#endif // BAREMETAL
|
||||
|
||||
#ifndef CONNECT_DESC
|
||||
#define CONNECT_DESC "Unknown"
|
||||
#endif
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Variable declarations
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
static volatile BOOL running; // Running flag
|
||||
static volatile BOOL active; // Processing flag
|
||||
volatile BOOL running; // Running flag
|
||||
volatile BOOL active; // Processing flag
|
||||
SASIDEV *ctrl[CtrlMax]; // Controller
|
||||
Disk *disk[CtrlMax * UnitNum]; // Disk
|
||||
GPIOBUS *bus; // GPIO Bus
|
||||
@@ -297,6 +295,9 @@ void ListDevice(FILE *fp)
|
||||
FPRT(fp, "+----+----+------+-------------------------------------\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Mapping
|
||||
@@ -412,6 +413,80 @@ void MapControler(FILE *fp, Disk **map)
|
||||
}
|
||||
}
|
||||
|
||||
Disk* GetDevice(FILE *fp, int id, int un){
|
||||
|
||||
// Check the Controller Number
|
||||
if (id < 0 || id >= CtrlMax) {
|
||||
FPRT(fp, "Error : Invalid ID\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check the Unit Number
|
||||
if (un < 0 || un >= UnitNum) {
|
||||
FPRT(fp, "Error : Invalid unit number\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Replace with the newly created unit
|
||||
return disk[id * UnitNum + un];
|
||||
}
|
||||
|
||||
BOOL AttachDevice(FILE *fp, Disk *pUnit, int id, int un){
|
||||
Disk *map[CtrlMax * UnitNum];
|
||||
Filepath filepath;
|
||||
|
||||
// Copy the Unit List
|
||||
memcpy(map, disk, sizeof(disk));
|
||||
|
||||
// Check the Controller Number
|
||||
if (id < 0 || id >= CtrlMax) {
|
||||
FPRT(fp, "Error : Invalid ID\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check the Unit Number
|
||||
if (un < 0 || un >= UnitNum) {
|
||||
FPRT(fp, "Error : Invalid unit number\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Replace with the newly created unit
|
||||
map[id * UnitNum + un] = pUnit;
|
||||
|
||||
// Re-map the controller
|
||||
MapControler(fp, map);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL DetachDevice(FILE *fp, int id, int un){
|
||||
Disk *map[CtrlMax * UnitNum];
|
||||
Filepath filepath;
|
||||
|
||||
// Copy the Unit List
|
||||
memcpy(map, disk, sizeof(disk));
|
||||
|
||||
// Check the Controller Number
|
||||
if (id < 0 || id >= CtrlMax) {
|
||||
FPRT(fp, "Error : Invalid ID\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check the Unit Number
|
||||
if (un < 0 || un >= UnitNum) {
|
||||
FPRT(fp, "Error : Invalid unit number\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Free the existing unit
|
||||
map[id * UnitNum + un] = NULL;
|
||||
|
||||
// Re-map the controller
|
||||
MapControler(fp, map);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Main processing
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "rasctl_command.h"
|
||||
#include "rascsi_mgr.h"
|
||||
#include <string.h>
|
||||
|
||||
// In the serialized string from rasctl
|
||||
@@ -100,7 +99,6 @@ BOOL Rasctl_Command::rasctl_dev_is_hd(rasctl_dev_type type)
|
||||
|
||||
BOOL Rasctl_Command::IsValid(FILE *fp){
|
||||
struct stat stat_buffer;
|
||||
rasctl_dev_type expected_type = rasctl_dev_invalid;
|
||||
|
||||
// If the command is "invalid" we can just return FALSE
|
||||
if(cmd == rasctl_cmd_invalid){
|
||||
@@ -113,14 +111,14 @@ BOOL Rasctl_Command::IsValid(FILE *fp){
|
||||
}
|
||||
|
||||
// Check that the ID is in range
|
||||
if((id < 0) || (id >= Rascsi_Manager::CtrlMax)){
|
||||
FPRT(fp, "Invalid ID. Must be between 0 and %d",Rascsi_Manager::CtrlMax-1);
|
||||
if((id < 0) || (id >= CtrlMax)){
|
||||
FPRT(fp, "Invalid ID. Must be between 0 and %d",CtrlMax-1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check that unit number is in range
|
||||
if((un < 0) || (un >= Rascsi_Manager::UnitNum)){
|
||||
FPRT(fp, "Invalid unit number. Must be between 0 and %d",Rascsi_Manager::UnitNum-1);
|
||||
if((un < 0) || (un >= UnitNum)){
|
||||
FPRT(fp, "Invalid unit number. Must be between 0 and %d",UnitNum-1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
|
||||
#include "os.h"
|
||||
|
||||
// Todo - this is a clone of the declaration in rascsi.cpp. This is sloppy!!! Fix this!!
|
||||
#ifndef CtrlMax
|
||||
#define CtrlMax 8 // Maximum number of SCSI controllers
|
||||
#define UnitNum 2 // Number of units around controller
|
||||
#endif
|
||||
|
||||
enum rasctl_command : int {
|
||||
rasctl_cmd_invalid = -1,
|
||||
rasctl_cmd_attach = 0,
|
||||
|
||||
Reference in New Issue
Block a user