Skip to content

Commit

Permalink
Logging update, improved locality of code
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Aug 23, 2021
1 parent a2c2362 commit b40c6b1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/raspberrypi/devices/disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ bool Disk::Dispatch(SCSIDEV *controller)
if (commands.count(static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0]))) {
command_t *command = commands[static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0])];

LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);
LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);

(this->*command->execute)(controller);

Expand Down
2 changes: 1 addition & 1 deletion src/raspberrypi/devices/scsi_daynaport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void SCSIDaynaPort::Open(const Filepath& path)
if (commands.count(static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0]))) {
command_t *command = commands[static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0])];

LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);
LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);

(this->*command->execute)(controller);

Expand Down
9 changes: 3 additions & 6 deletions src/raspberrypi/devices/scsi_host_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool SCSIBR::Dispatch(SCSIDEV *controller)
if (commands.count(static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0]))) {
command_t *command = commands[static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0])];

LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);
LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);

(this->*command->execute)(controller);

Expand Down Expand Up @@ -180,7 +180,6 @@ void SCSIBR::TestUnitReady(SASIDEV *controller)
{
// TEST UNIT READY Success

// status phase
controller->Status();}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -264,7 +263,7 @@ int SCSIBR::GetMessage10(const DWORD *cdb, BYTE *buf)
}

// Error
ASSERT(FALSE);
ASSERT(false);
return 0;
}

Expand Down Expand Up @@ -326,7 +325,7 @@ bool SCSIBR::SendMessage10(const DWORD *cdb, BYTE *buf)
}

// Error
ASSERT(FALSE);
ASSERT(false);
return false;
}

Expand Down Expand Up @@ -355,7 +354,6 @@ void SCSIBR::GetMessage10(SASIDEV *controller)
ctrl->blocks = 1;
ctrl->next = 1;

// Data in phase
controller->DataIn();
}

Expand Down Expand Up @@ -392,7 +390,6 @@ void SCSIBR::SendMessage10(SASIDEV *controller)
ctrl->blocks = 1;
ctrl->next = 1;

// Data out phase
controller->DataOut();
}

Expand Down
17 changes: 6 additions & 11 deletions src/raspberrypi/devices/scsicd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ bool SCSICD::Dispatch(SCSIDEV *controller)
if (commands.count(static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0]))) {
command_t *command = commands[static_cast<SCSIDEV::scsi_command>(ctrl->cmd[0])];

LOGDEBUG("%s received %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);
LOGDEBUG("%s Executing %s ($%02X)", __PRETTY_FUNCTION__, command->name, (unsigned int)ctrl->cmd[0]);

(this->*command->execute)(controller);

Expand All @@ -299,9 +299,7 @@ bool SCSICD::Dispatch(SCSIDEV *controller)
//---------------------------------------------------------------------------
void SCSICD::Open(const Filepath& path)
{
Fileio fio;
off_t size;
TCHAR file[5];

ASSERT(!IsReady());

Expand All @@ -311,6 +309,7 @@ void SCSICD::Open(const Filepath& path)
ClearTrack();

// Open as read-only
Fileio fio;
if (!fio.Open(path, Fileio::ReadOnly)) {
throw io_exception("Can't open CD-ROM file read-only");
}
Expand All @@ -331,12 +330,13 @@ void SCSICD::Open(const Filepath& path)
}

// Judge whether it is a CUE sheet or an ISO file
TCHAR file[5];
fio.Read(file, 4);
file[4] = '\0';
fio.Close();

// If it starts with FILE, consider it as a CUE sheet
if (strncasecmp(file, _T("FILE"), 4) == 0) {
if (!strncasecmp(file, _T("FILE"), 4)) {
// Open as CUE
OpenCue(path);
} else {
Expand Down Expand Up @@ -381,9 +381,6 @@ void SCSICD::OpenCue(const Filepath& /*path*/)
//---------------------------------------------------------------------------
void SCSICD::OpenIso(const Filepath& path)
{
BYTE header[12];
BYTE sync[12];

// Open as read-only
Fileio fio;
if (!fio.Open(path, Fileio::ReadOnly)) {
Expand All @@ -398,12 +395,14 @@ void SCSICD::OpenIso(const Filepath& path)
}

// Read the first 12 bytes and close
BYTE header[12];
if (!fio.Read(header, sizeof(header))) {
fio.Close();
throw io_exception("Can't read header of ISO CD-ROM file");
}

// Check if it is RAW format
BYTE sync[12];
memset(sync, 0xff, sizeof(sync));
sync[0] = 0x00;
sync[11] = 0x00;
Expand Down Expand Up @@ -514,7 +513,6 @@ void SCSICD::CmdReadToc(SASIDEV *controller)
return;
}

// Data-in Phase
controller->DataIn();
}

Expand All @@ -528,7 +526,6 @@ void SCSICD::CmdPlayAudio10(SASIDEV *controller)
return;
}

// Status phase
controller->Status();
}

Expand All @@ -542,7 +539,6 @@ void SCSICD::CmdPlayAudioMSF(SASIDEV *controller)
return;
}

// Status phase
controller->Status();
}

Expand All @@ -556,7 +552,6 @@ void SCSICD::CmdPlayAudioTrack(SASIDEV *controller)
return;
}

// Status phase
controller->Status();
}

Expand Down
3 changes: 1 addition & 2 deletions src/raspberrypi/devices/scsihd_nec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ static inline WORD getWordLE(const BYTE *b)
//---------------------------------------------------------------------------
static inline DWORD getDwordLE(const BYTE *b)
{
return ((DWORD)(b[3]) << 24) | ((DWORD)(b[2]) << 16) |
((DWORD)(b[1]) << 8) | b[0];
return ((DWORD)(b[3]) << 24) | ((DWORD)(b[2]) << 16) | ((DWORD)(b[1]) << 8) | b[0];
}

//---------------------------------------------------------------------------
Expand Down

0 comments on commit b40c6b1

Please sign in to comment.