mirror of
https://github.com/thewesker/RASCSI.git
synced 2025-12-21 12:51:13 -05:00
Additional updates
This commit is contained in:
@@ -285,8 +285,10 @@ void *Command_Thread::MonThread(void *param)
|
|||||||
|
|
||||||
// Scheduler Settings
|
// Scheduler Settings
|
||||||
schedparam.sched_priority = 0;
|
schedparam.sched_priority = 0;
|
||||||
|
#if defined(__linux__)
|
||||||
|
// sched_setscheduler is only available on Linux
|
||||||
sched_setscheduler(0, SCHED_IDLE, &schedparam);
|
sched_setscheduler(0, SCHED_IDLE, &schedparam);
|
||||||
|
#endif
|
||||||
// Set the affinity to a specific processor core
|
// Set the affinity to a specific processor core
|
||||||
FixCpu(2);
|
FixCpu(2);
|
||||||
|
|
||||||
@@ -311,31 +313,27 @@ void *Command_Thread::MonThread(void *param)
|
|||||||
fp = fdopen(fd, "r+");
|
fp = fdopen(fd, "r+");
|
||||||
p = fgets(buf, BUFSIZ, fp);
|
p = fgets(buf, BUFSIZ, fp);
|
||||||
|
|
||||||
// Failed to get the command
|
// If we received a command....
|
||||||
if (!p) {
|
if (p) {
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the newline character
|
// // Remove the newline character
|
||||||
p[strlen(p) - 1] = 0;
|
// p[strlen(p) - 1] = 0;
|
||||||
|
|
||||||
// List all of the devices
|
// // List all of the devices
|
||||||
if (xstrncasecmp(p, "list", 4) == 0) {
|
// if (xstrncasecmp(p, "list", 4) == 0) {
|
||||||
Rascsi_Manager::GetInstance()->ListDevice(fp);
|
// Rascsi_Manager::GetInstance()->ListDevice(fp);
|
||||||
goto next;
|
// goto next;
|
||||||
}
|
// }
|
||||||
|
|
||||||
new_command = Rasctl_Command::DeSerialize((BYTE*)p,BUFSIZ);
|
new_command = Rasctl_Command::DeSerialize((BYTE*)p,BUFSIZ);
|
||||||
|
|
||||||
// // Wait until we becom idle
|
if(new_command != nullptr){
|
||||||
// while (m_running) {
|
|
||||||
// usleep(500 * 1000);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Execute the command
|
// Execute the command
|
||||||
ExecuteCommand(fp, new_command);
|
ExecuteCommand(fp, new_command);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
next:
|
|
||||||
// Release the connection
|
// Release the connection
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
close(fd);
|
close(fd);
|
||||||
@@ -539,17 +537,16 @@ BOOL Command_Thread::ExecuteCommand(FILE *fp, Rasctl_Command *incoming_command)
|
|||||||
|
|
||||||
|
|
||||||
BOOL Command_Thread::DoShutdown(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
BOOL Command_Thread::DoShutdown(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
||||||
BOOL Command_Thread::DoList(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
|
||||||
BOOL Command_Thread::DoAttach(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
|
||||||
BOOL Command_Thread::DoDetach(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
|
||||||
BOOL Command_Thread::DoInsert(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
|
||||||
BOOL Command_Thread::DoEject(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
|
||||||
BOOL Command_Thread::DoProtect(FILE *fp, Rasctl_Command *incoming_command){return FALSE;}
|
|
||||||
|
|
||||||
|
BOOL Command_Thread::DoList(FILE *fp, Rasctl_Command *incoming_command){
|
||||||
|
Rascsi_Manager::GetInstance()->ListDevice(fp);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
BOOL Command_Thread::DoAttach(FILE *fp, Rasctl_Command *incoming_command){
|
||||||
|
Filepath filepath;
|
||||||
|
Disk *pUnit = nullptr;
|
||||||
|
|
||||||
// BOOL Command_Thread::DoAttach(File *fp, Rasctl_Command *incoming_command){
|
// Connect Command
|
||||||
|
|
||||||
// // Connect Command
|
|
||||||
// if (cmd == rasctl_cmd_attach) { // ATTACH
|
// if (cmd == rasctl_cmd_attach) { // ATTACH
|
||||||
// // Distinguish between SASI and SCSI
|
// // Distinguish between SASI and SCSI
|
||||||
// ext = NULL;
|
// ext = NULL;
|
||||||
@@ -557,67 +554,72 @@ BOOL Command_Thread::DoProtect(FILE *fp, Rasctl_Command *incoming_command){retur
|
|||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Create a new drive, based upon type
|
// Create a new drive, based upon type
|
||||||
// switch (type) {
|
switch (incoming_command->type) {
|
||||||
// case 0: // HDF
|
case rasctl_dev_sasi_hd: // HDF
|
||||||
// pUnit = new SASIHD();
|
pUnit = new SASIHD();
|
||||||
// break;
|
break;
|
||||||
// case 1: // HDS/HDN/HDI/NHD/HDA
|
case rasctl_dev_scsi_hd: // HDS/HDN/HDI/NHD/HDA
|
||||||
// if (ext == NULL) {
|
pUnit = new SCSIHD();
|
||||||
// break;
|
break;
|
||||||
// }
|
case rasctl_dev_scsi_hd_appl:
|
||||||
// if (xstrcasecmp(ext, "hdn") == 0 ||
|
pUnit = new SCSIHD_APPLE();
|
||||||
// xstrcasecmp(ext, "hdi") == 0 || xstrcasecmp(ext, "nhd") == 0) {
|
break;
|
||||||
// pUnit = new SCSIHD_NEC();
|
case rasctl_dev_scsi_hd_nec:
|
||||||
// } else if (xstrcasecmp(ext, "hda") == 0) {
|
pUnit = new SCSIHD_NEC();
|
||||||
// pUnit = new SCSIHD_APPLE();
|
break;
|
||||||
// } else {
|
case rasctl_dev_mo:
|
||||||
// pUnit = new SCSIHD();
|
pUnit = new SCSIMO();
|
||||||
// }
|
break;
|
||||||
// break;
|
case rasctl_dev_cd:
|
||||||
// case 2: // MO
|
pUnit = new SCSICD();
|
||||||
// pUnit = new SCSIMO();
|
break;
|
||||||
// break;
|
case rasctl_dev_br:
|
||||||
// case 3: // CD
|
pUnit = new SCSIBR();
|
||||||
// pUnit = new SCSICD();
|
break;
|
||||||
// break;
|
default:
|
||||||
// case 4: // BRIDGE
|
FPRT(fp, "Error : Invalid device type\n");
|
||||||
// pUnit = new SCSIBR();
|
return FALSE;
|
||||||
// break;
|
}
|
||||||
// default:
|
|
||||||
// FPRT(fp, "Error : Invalid device type\n");
|
|
||||||
// return FALSE;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // drive checks files
|
// drive checks files
|
||||||
// if (type <= 1 || (type <= 3 && xstrcasecmp(file, "-") != 0)) {
|
switch(incoming_command->type){
|
||||||
// // Set the Path
|
case rasctl_dev_mo:
|
||||||
// filepath.SetPath(file);
|
case rasctl_dev_scsi_hd_nec:
|
||||||
|
case rasctl_dev_sasi_hd:
|
||||||
|
case rasctl_dev_scsi_hd:
|
||||||
|
case rasctl_dev_cd:
|
||||||
|
case rasctl_dev_scsi_hd_appl:
|
||||||
|
// Set the Path
|
||||||
|
filepath.SetPath(incoming_command->file);
|
||||||
|
|
||||||
// // Open the file path
|
// Open the file path
|
||||||
// if (!pUnit->Open(filepath)) {
|
if (!pUnit->Open(filepath)) {
|
||||||
// FPRT(fp, "Error : File open error [%s]\n", file);
|
FPRT(fp, "Error : File open error [%s]\n", incoming_command->file);
|
||||||
// delete pUnit;
|
delete pUnit;
|
||||||
// return FALSE;
|
return FALSE;
|
||||||
// }
|
}
|
||||||
// }
|
break;
|
||||||
|
case rasctl_dev_br:
|
||||||
|
case rasctl_dev_invalid:
|
||||||
|
// Do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// // Set the cache to write-through
|
|
||||||
// pUnit->SetCacheWB(FALSE);
|
// Set the cache to write-through
|
||||||
|
pUnit->SetCacheWB(FALSE);
|
||||||
|
|
||||||
// // Replace with the newly created unit
|
// // Replace with the newly created unit
|
||||||
// map[id * Rascsi_Manager::GetInstance()->UnitNum + un] = pUnit;
|
// map[id * Rascsi_Manager::GetInstance()->UnitNum + un] = pUnit;
|
||||||
|
|
||||||
// // Re-map the controller
|
// Map the controller
|
||||||
// Rascsi_Manager::GetInstance()->MapControler(fp, map);
|
Rascsi_Manager::GetInstance()->MapControler(fp, map);
|
||||||
// return TRUE;
|
return TRUE;
|
||||||
// }
|
|
||||||
|
|
||||||
// // Is this a valid command?
|
|
||||||
// if (cmd > 4) {
|
return FALSE;}
|
||||||
// FPRT(fp, "Error : Invalid command\n");
|
BOOL Command_Thread::DoDetach(FILE *fp, Rasctl_Command *incoming_command){
|
||||||
// return FALSE;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Does the controller exist?
|
// // Does the controller exist?
|
||||||
// if (Rascsi_Manager::GetInstance()->m_ctrl[id] == NULL) {
|
// if (Rascsi_Manager::GetInstance()->m_ctrl[id] == NULL) {
|
||||||
@@ -632,7 +634,7 @@ BOOL Command_Thread::DoProtect(FILE *fp, Rasctl_Command *incoming_command){retur
|
|||||||
// return FALSE;
|
// return FALSE;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Disconnect Command
|
// // Disconnect Command
|
||||||
// if (cmd == 1) { // DETACH
|
// if (cmd == 1) { // DETACH
|
||||||
// // Free the existing unit
|
// // Free the existing unit
|
||||||
// map[id * Rascsi_Manager::GetInstance()->UnitNum + un] = NULL;
|
// map[id * Rascsi_Manager::GetInstance()->UnitNum + un] = NULL;
|
||||||
@@ -642,43 +644,91 @@ BOOL Command_Thread::DoProtect(FILE *fp, Rasctl_Command *incoming_command){retur
|
|||||||
// return TRUE;
|
// return TRUE;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Valid only for MO or CD
|
return FALSE;}
|
||||||
|
BOOL Command_Thread::DoInsert(FILE *fp, Rasctl_Command *incoming_command){
|
||||||
|
|
||||||
|
|
||||||
|
// // Does the controller exist?
|
||||||
|
// if (Rascsi_Manager::GetInstance()->m_ctrl[id] == NULL) {
|
||||||
|
// FPRT(fp, "Error : No such device\n");
|
||||||
|
// return FALSE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Does the unit exist?
|
||||||
|
// pUnit = Rascsi_Manager::GetInstance()->m_disk[id * Rascsi_Manager::GetInstance()->UnitNum + un];
|
||||||
|
// if (pUnit == NULL) {
|
||||||
|
// FPRT(fp, "Error : No such device\n");
|
||||||
|
// return FALSE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Valid only for MO or CD
|
||||||
|
// if (pUnit->GetID() != MAKEID('S', 'C', 'M', 'O') &&
|
||||||
|
// pUnit->GetID() != MAKEID('S', 'C', 'C', 'D')) {
|
||||||
|
// FPRT(fp, "Error : Operation denied(Deveice isn't removable)\n");
|
||||||
|
// return FALSE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// case 2: // INSERT
|
||||||
|
// // Set the file path
|
||||||
|
// filepath.SetPath(file);
|
||||||
|
|
||||||
|
// // Open the file
|
||||||
|
// if (!pUnit->Open(filepath)) {
|
||||||
|
// FPRT(fp, "Error : File open error [%s]\n", file);
|
||||||
|
// return FALSE;
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
BOOL Command_Thread::DoEject(FILE *fp, Rasctl_Command *incoming_command){
|
||||||
|
|
||||||
|
// // Does the controller exist?
|
||||||
|
// if (Rascsi_Manager::GetInstance()->m_ctrl[id] == NULL) {
|
||||||
|
// FPRT(fp, "Error : No such device\n");
|
||||||
|
// return FALSE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Does the unit exist?
|
||||||
|
// pUnit = Rascsi_Manager::GetInstance()->m_disk[id * Rascsi_Manager::GetInstance()->UnitNum + un];
|
||||||
|
// if (pUnit == NULL) {
|
||||||
|
// FPRT(fp, "Error : No such device\n");
|
||||||
|
// return FALSE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Valid only for MO or CD
|
||||||
// if (pUnit->GetID() != MAKEID('S', 'C', 'M', 'O') &&
|
// if (pUnit->GetID() != MAKEID('S', 'C', 'M', 'O') &&
|
||||||
// pUnit->GetID() != MAKEID('S', 'C', 'C', 'D')) {
|
// pUnit->GetID() != MAKEID('S', 'C', 'C', 'D')) {
|
||||||
// FPRT(fp, "Error : Operation denied(Deveice isn't removable)\n");
|
// FPRT(fp, "Error : Operation denied(Deveice isn't removable)\n");
|
||||||
// return FALSE;
|
// return FALSE;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// switch (cmd) {
|
|
||||||
// case 2: // INSERT
|
|
||||||
// // Set the file path
|
|
||||||
// filepath.SetPath(file);
|
|
||||||
|
|
||||||
// // Open the file
|
|
||||||
// if (!pUnit->Open(filepath)) {
|
|
||||||
// FPRT(fp, "Error : File open error [%s]\n", file);
|
|
||||||
// return FALSE;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 3: // EJECT
|
// case 3: // EJECT
|
||||||
// pUnit->Eject(TRUE);
|
// pUnit->Eject(TRUE);
|
||||||
// break;
|
// break;
|
||||||
|
return FALSE;}
|
||||||
|
BOOL Command_Thread::DoProtect(FILE *fp, Rasctl_Command *incoming_command){
|
||||||
|
|
||||||
// case 4: // PROTECT
|
// case 4: // PROTECT
|
||||||
// if (pUnit->GetID() != MAKEID('S', 'C', 'M', 'O')) {
|
// if (pUnit->GetID() != MAKEID('S', 'C', 'M', 'O')) {
|
||||||
// FPRT(fp, "Error : Operation denied(Deveice isn't MO)\n");
|
// FPRT(fp, "Error : Operation denied(Deveice isn't MO)\n");
|
||||||
// return FALSE;
|
// return FALSE;
|
||||||
// }
|
// }
|
||||||
// pUnit->WriteP(!pUnit->IsWriteP());
|
// pUnit->WriteP(!pUnit->IsWriteP());
|
||||||
// break;
|
// break;
|
||||||
// default:
|
|
||||||
// ASSERT(FALSE);
|
|
||||||
// return FALSE;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return TRUE;
|
return FALSE;}
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL Command_Thread::HasSuffix(const char* string, const char* suffix) {
|
BOOL Command_Thread::HasSuffix(const char* string, const char* suffix) {
|
||||||
int string_len = strlen(string);
|
int string_len = strlen(string);
|
||||||
|
|||||||
@@ -121,8 +121,10 @@ BOOL FASTCALL Fileio::Open(LPCTSTR fname, OpenMode mode, BOOL directIO)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __APPLE__
|
||||||
// デフォルトモード
|
// デフォルトモード
|
||||||
omode = directIO ? O_DIRECT : 0;
|
omode = directIO ? O_DIRECT : 0;
|
||||||
|
#endif // ifndef __APPLE__
|
||||||
|
|
||||||
// モード別
|
// モード別
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|||||||
@@ -1215,7 +1215,7 @@ int FASTCALL GPIOBUS::PollSelectEvent()
|
|||||||
{
|
{
|
||||||
// clear errno
|
// clear errno
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
#if !defined(__x86_64__) && !defined(__X86__)
|
||||||
#ifdef BAREMETAL
|
#ifdef BAREMETAL
|
||||||
// Enable interrupts
|
// Enable interrupts
|
||||||
EnableInterrupts();
|
EnableInterrupts();
|
||||||
@@ -1235,6 +1235,7 @@ int FASTCALL GPIOBUS::PollSelectEvent()
|
|||||||
|
|
||||||
read(selevreq.fd, &gpev, sizeof(gpev));
|
read(selevreq.fd, &gpev, sizeof(gpev));
|
||||||
#endif // BAREMETAL
|
#endif // BAREMETAL
|
||||||
|
#endif // !__x86_64
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1506,6 +1507,9 @@ BOOL FASTCALL GPIOBUS::WaitSignal(int pin, BOOL ast)
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void FASTCALL GPIOBUS::DisableIRQ()
|
void FASTCALL GPIOBUS::DisableIRQ()
|
||||||
{
|
{
|
||||||
|
#if defined(__x86_64__) || defined(__X86__)
|
||||||
|
return;
|
||||||
|
#else
|
||||||
#ifndef BAREMETAL
|
#ifndef BAREMETAL
|
||||||
if (rpitype == 4) {
|
if (rpitype == 4) {
|
||||||
// RPI4 is disabled by GICC
|
// RPI4 is disabled by GICC
|
||||||
@@ -1522,6 +1526,7 @@ void FASTCALL GPIOBUS::DisableIRQ()
|
|||||||
irpctl[IRPT_DIS_IRQ_1] = irptenb & 0xf;
|
irpctl[IRPT_DIS_IRQ_1] = irptenb & 0xf;
|
||||||
}
|
}
|
||||||
#endif // BAREMETAL
|
#endif // BAREMETAL
|
||||||
|
#endif // ifdef __x86_64__ || __X86__
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void FixCpu(int cpu)
|
void FixCpu(int cpu)
|
||||||
{
|
{
|
||||||
#ifndef BAREMETAL
|
#if !defined BAREMETAL && defined(__linux__)
|
||||||
cpu_set_t cpuset;
|
cpu_set_t cpuset;
|
||||||
int cpus;
|
int cpus;
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ int main(int argc, char* argv[])
|
|||||||
// Set the affinity to a specific processor core
|
// Set the affinity to a specific processor core
|
||||||
FixCpu(3);
|
FixCpu(3);
|
||||||
|
|
||||||
#ifdef USE_SEL_EVENT_ENABLE
|
#if defined(USE_SEL_EVENT_ENABLE) && defined(__linux__)
|
||||||
// Scheduling policy setting (highest priority)
|
// Scheduling policy setting (highest priority)
|
||||||
schparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
schparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||||
sched_setscheduler(0, SCHED_FIFO, &schparam);
|
sched_setscheduler(0, SCHED_FIFO, &schparam);
|
||||||
|
|||||||
@@ -25,6 +25,123 @@ Rascsi_Manager* Rascsi_Manager::GetInstance(){
|
|||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Rascsi_Manager::AttachDevice(FILE *fp, Disk *disk, int id, int unit_num){
|
||||||
|
int unitno = (id * UnitNum) + unit_num;
|
||||||
|
|
||||||
|
// Get the lock
|
||||||
|
m_locked.lock();
|
||||||
|
|
||||||
|
// Check if something already exists at that SCSI ID / Unit Number
|
||||||
|
if (m_disk[unitno]) {
|
||||||
|
// Disconnect it from the controller
|
||||||
|
if (m_ctrl[i]) {
|
||||||
|
m_ctrl[i]->SetUnit(j, NULL);
|
||||||
|
}else{
|
||||||
|
printf("Warning: A controller was not connected to the drive at id %d un %d\n",id, unit_num);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free the Unit
|
||||||
|
delete m_disk[unitno];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new unit
|
||||||
|
m_disk[unitno] = disk;
|
||||||
|
|
||||||
|
// Reconfigure all of the controllers
|
||||||
|
for (i = 0; i < CtrlMax; i++) {
|
||||||
|
// Examine the unit configuration
|
||||||
|
sasi_num = 0;
|
||||||
|
scsi_num = 0;
|
||||||
|
for (j = 0; j < UnitNum; j++) {
|
||||||
|
unitno = i * UnitNum + j;
|
||||||
|
// branch by unit type
|
||||||
|
if (m_disk[unitno]) {
|
||||||
|
if (m_disk[unitno]->IsSASI()) {
|
||||||
|
// Drive is SASI, so increment SASI count
|
||||||
|
sasi_num++;
|
||||||
|
} else {
|
||||||
|
// Drive is SCSI, so increment SCSI count
|
||||||
|
scsi_num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the unit
|
||||||
|
if (m_ctrl[i]) {
|
||||||
|
m_ctrl[i]->SetUnit(j, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are no units connected
|
||||||
|
if (sasi_num == 0 && scsi_num == 0) {
|
||||||
|
if (m_ctrl[i]) {
|
||||||
|
delete m_ctrl[i];
|
||||||
|
m_ctrl[i] = NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mixture of SCSI and SASI
|
||||||
|
if (sasi_num > 0 && scsi_num > 0) {
|
||||||
|
FPRT(fp, "Error : SASI and SCSI can't be mixed\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sasi_num > 0) {
|
||||||
|
// Only SASI Unit(s)
|
||||||
|
|
||||||
|
// Release the controller if it is not SASI
|
||||||
|
if (m_ctrl[i] && !m_ctrl[i]->IsSASI()) {
|
||||||
|
delete m_ctrl[i];
|
||||||
|
m_ctrl[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new SASI controller
|
||||||
|
if (!m_ctrl[i]) {
|
||||||
|
m_ctrl[i] = new SASIDEV();
|
||||||
|
m_ctrl[i]->Connect(i, m_bus);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Only SCSI Unit(s)
|
||||||
|
|
||||||
|
// Release the controller if it is not SCSI
|
||||||
|
if (m_ctrl[i] && !m_ctrl[i]->IsSCSI()) {
|
||||||
|
delete m_ctrl[i];
|
||||||
|
m_ctrl[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new SCSI controller
|
||||||
|
if (!m_ctrl[i]) {
|
||||||
|
m_ctrl[i] = new SCSIDEV();
|
||||||
|
m_ctrl[i]->Connect(i, m_bus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// connect all units
|
||||||
|
for (j = 0; j < UnitNum; j++) {
|
||||||
|
unitno = i * UnitNum + j;
|
||||||
|
if (m_disk[unitno]) {
|
||||||
|
// Add the unit connection
|
||||||
|
m_ctrl[i]->SetUnit(j, m_disk[unitno]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void Rascsi_Manager::DetachDevice(FILE *fp, Disk *map, int id, int ui)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Disk* Rascsi_Manager::GetDevice(FILE *fp, int id, int ui)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Controller Mapping
|
// Controller Mapping
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "rasctl_command.h"
|
#include "rasctl_command.h"
|
||||||
|
|
||||||
//const char* Rasctl_Command::m_delimiter = "\x1E"; // Record separator charater
|
const char* Rasctl_Command::m_delimiter = "\x1E"; // Record separator charater
|
||||||
const char* Rasctl_Command::m_delimiter = " "; // Record separator charater
|
//const char* Rasctl_Command::m_delimiter = " "; // Record separator charater
|
||||||
|
|
||||||
void Rasctl_Command::Serialize(BYTE *buff, int max_buff_size){
|
void Rasctl_Command::Serialize(BYTE *buff, int max_buff_size){
|
||||||
snprintf((char*)buff, max_buff_size, "%d%s%d%s%d%s%d%s%s%s",
|
snprintf((char*)buff, max_buff_size, "%d%s%d%s%d%s%d%s%s%s\n",
|
||||||
this->id, this->m_delimiter,
|
this->id, this->m_delimiter,
|
||||||
this->un, this->m_delimiter,
|
this->un, this->m_delimiter,
|
||||||
this->cmd, this->m_delimiter,
|
this->cmd, this->m_delimiter,
|
||||||
@@ -39,7 +39,7 @@ Rasctl_Command* Rasctl_Command::DeSerialize(BYTE* buff, int size){
|
|||||||
return_command->un = atoi(cur_token);
|
return_command->un = atoi(cur_token);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
for(int i=0; i<size; i++)
|
for(int i=0; i<strlen((char*)buff); i++)
|
||||||
{
|
{
|
||||||
snprintf(&err_message[i*2], sizeof(err_message), "%02X", buff[i]);
|
snprintf(&err_message[i*2], sizeof(err_message), "%02X", buff[i]);
|
||||||
}
|
}
|
||||||
@@ -49,16 +49,18 @@ Rasctl_Command* Rasctl_Command::DeSerialize(BYTE* buff, int size){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cur_token_idx = (serial_token_order)((int)cur_token_idx + 1);
|
cur_token_idx = (serial_token_order)((int)cur_token_idx + 1);
|
||||||
|
cur_token = strtok(NULL, m_delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cur_token_idx != serial_token_last_token)
|
if(cur_token_idx != serial_token_last_token)
|
||||||
{
|
{
|
||||||
for(int i=0; i<size; i++)
|
for(int i=0; i<strlen((char*)buff); i++)
|
||||||
{
|
{
|
||||||
snprintf(&err_message[i*2], sizeof(err_message), "%02X", buff[i]);
|
snprintf(&err_message[i*2], sizeof(err_message), "%02X", buff[i]);
|
||||||
}
|
}
|
||||||
printf("Received too few tokens: %s", err_message);
|
printf("Received too few tokens: %s", err_message);
|
||||||
free(return_command);
|
free(return_command);
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_command;
|
return return_command;
|
||||||
|
|||||||
Reference in New Issue
Block a user