Bug fixes, whitespace cleanup, deleted binaries.

This commit is contained in:
Marcio T 2021-11-24 08:55:06 -07:00
parent 4db47b680f
commit 5e33fa482c
40 changed files with 360 additions and 338 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@ -58,7 +58,7 @@ bool process_command() {
case 'i': dev_info(arg_val); break;
case 'v': mac_list_volumes(); break;
case 'u': mac_unmount(arg_val); break;
case 't': run_tip(); break;
case 't': run_tip(arg_val); break;
case 'q': return false;
}
return true;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

View File

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>
#define READ_TIMEOUT 300 /* 300 ticks = 5 seconds */
#define READ_TIMEOUT 60 /* 300 ticks = 5 seconds */
OSErr scsi_reset() {
return SCSIReset();
@ -34,7 +34,7 @@ OSErr scsi_cmd(int id, void *cmd, size_t clen, void *buff, size_t siz, size_t cn
TIB[2].scParam2 = 0;
} else {
/* Transfer siz bytes in one fell swoop. */
//printf("CMD: %x SCSI Siz %ld\n", int(*((char*)cmd)), siz);
TIB[0].scOpcode = scInc;
TIB[0].scParam1 = (long) buff;
TIB[0].scParam2 = siz;
@ -48,30 +48,31 @@ OSErr scsi_cmd(int id, void *cmd, size_t clen, void *buff, size_t siz, size_t cn
if (err != noErr) {printf("SCSIGet Error: %d\n", err); return err;}
err = SCSISelect(id);
if (err != noErr) {/*printf("SCSISelect Error: %d\n", err);*/ return err;}
if (err != noErr) {printf("SCSISelect Error: %d\n", err); return err;}
/* Send the command to the SCSI device and perform the requested I/O */
err = SCSICmd( (Ptr) cmd, clen );
if (err == noErr) {
OSErr io_err;
switch(flags) {
case SCSI_WRITE | SCSI_BLIND: err = SCSIWBlind( (Ptr) TIB ); break;
case SCSI_READ | SCSI_BLIND: err = SCSIRBlind( (Ptr) TIB ); break;
case SCSI_WRITE: err = SCSIWrite( (Ptr) TIB ); break;
case SCSI_READ: err = SCSIRead( (Ptr) TIB ); break;
case SCSI_WRITE | SCSI_BLIND: io_err = SCSIWBlind( (Ptr) TIB ); break;
case SCSI_READ | SCSI_BLIND: io_err = SCSIRBlind( (Ptr) TIB ); break;
case SCSI_WRITE: io_err = SCSIWrite( (Ptr) TIB ); break;
case SCSI_READ: io_err = SCSIRead( (Ptr) TIB ); break;
default: break;
}
if (err != noErr) {
printf("SCSI Read/Write Error: %d\n", err);
if (io_err != noErr) {
printf("SCSI Read/Write Error: %d\n", io_err);
}
} else {
printf("SCSICmd Error: %d", err);
printf("SCSICmd Error: %d\n", err);
}
/* Complete the transaction and release the bus */
short cstat, cmsg;
OSErr comperr = SCSIComplete( &cstat, &cmsg, READ_TIMEOUT );
if (comperr != noErr) {printf("SCSIComplete Error: %d\n", err); return err;}
if(status) *status = cstat;
if (comperr != noErr) {printf("SCSIComplete Error: %d (status: %d)\n", err, cstat); return err;}
return err;
}
@ -93,18 +94,7 @@ OSErr scsi_inquiry(int id, int lun, scsi_inq_reply *reply) {
}
OSErr scsi_request_sense_data(int id, scsi_sense_reply *reply) {
short err;
unsigned char cmd[6] = { SCSI_Cmd_RequestSense, 0x00, 0x00, 0x00, 0x08, 0x00 };
memset(reply, 0, sizeof(scsi_sense_reply));
/* First we issue a dummy command to get the additional data field, then */
/* we use that number to issue a second command with the corrected length. */
if( (err = scsi_cmd(id, cmd, sizeof(cmd), reply, cmd[4], 0, SCSI_READ)) != noErr) {
return err;
}
cmd[4] += reply->alen;
unsigned char cmd[6] = {SCSI_Cmd_RequestSense, 0x00, 0x00, 0x00, sizeof(scsi_sense_reply), 0x00};
return scsi_cmd(id, cmd, sizeof(cmd), reply, cmd[4], 0, SCSI_READ);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

View File

@ -193,17 +193,21 @@ void PaintTheBarGraphs(bool Active) {
if(ebx > ecx) { // if Spares > MAXIMUM
ebx = ecx; // clip Spares down to MAX
}
PaintBarGraph(13, 95, 395, 30, RED_COLOR, ebx*100/ecx, NULL, Active);
PaintBarGraph(13, 95, 395, 30, RED_COLOR, CvrtIntoPrcnt(ebx, ecx), NULL, Active);
} else {
ebx = Side_0_SparesCount;
ecx = MAXIMUM_ZIP_SPARES;
PaintBarGraph(13, 95, 395, 14, RED_COLOR, ebx*100/ecx, "Side 0", Active);
PaintBarGraph(13, 95, 395, 14, RED_COLOR, CvrtIntoPrcnt(ebx, ecx), "Side 0", Active);
ebx = Side_1_SparesCount;
ecx = MAXIMUM_ZIP_SPARES;
PaintBarGraph(13, 111, 395, 14, RED_COLOR, ebx*100/ecx, "Side 1", Active);
PaintBarGraph(13, 111, 395, 14, RED_COLOR, CvrtIntoPrcnt(ebx, ecx), "Side 1", Active);
}
}
int CvrtIntoPrcnt(long val, long max) {
return 100 - val*100/max;
}
/*******************************************************************************
* PAINT CENTERED STRING
*
@ -251,7 +255,7 @@ void PaintTestStatistics(bool Active) {
}
sprintf(szString, szCenteredDecimal, eax);
strcat(szString, szSpaceDashSpace);
eax = FirstLBASector + NumberOfLBAs;
eax = FirstLBASector + NumberOfLBAs - 1;
if (TestingPhase == READY_TO_TEST) {
eax = LastLBAOnCartridge;
}
@ -380,4 +384,5 @@ void UpdateRunPhaseDisplay() {
*******************************************************************************/
void ErrorSound() {
SysBeep(10);
}

View File

@ -3,7 +3,7 @@ typedef Boolean bool;
extern WindowPtr tipWindow;
void run_tip();
void run_tip(int id);
#define MINIMUM_JAZ_SPARES 500
#define MAXIMUM_JAZ_SPARES 2557
@ -180,6 +180,7 @@ void SunkenFields(Rect *pFirstRect, long count, long yspacing);
void PaintCartStatus();
void PaintTextArray(TextList *list, long color);
void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor, long BarValue, char *pRightText, bool Active);
int CvrtIntoPrcnt(long val, long max);
void PaintTestPhase();
void PaintTheBarGraphs(bool Active);
void PaintTestStatistics(bool Active);

View File

@ -5,6 +5,7 @@
#include "tip.h"
//#define DEMO
#define NO_EXCESS_READS
#define BYTE_AT(a) *((char*)&(a))
#define WORD_AT(a) *((short*)&(a))
@ -27,7 +28,7 @@
struct DEFECT_LIST_HEADER {
char DLH_reserved; // (00h)
char DLH_BitFlags; // [000] [P] [G] [xxx - defect list format]
char DLH_DefectListLength;
short DLH_DefectListLength;
};
//-------------------------- Drive Array Status Flags ---------------------------
@ -60,7 +61,7 @@ struct DEFECT_LIST_HEADER {
#define DRIVE_A_SUPPORT_BIAS 32 // reduce total by 32 for DRIVE A support
#define BYTES_PER_SECTOR 512
#define MAX_SECTORS_PER_TEST 20
#define MAX_SECTORS_PER_TEST 50
#define BADNESS_THRESHOLD 10
@ -173,20 +174,19 @@ long SCSICommand(short Device, char *lpCmdBlk, void *lpIoBuf, short IoBufLen) {
return SS_ERR;
}
if(cmd_status == 0) {
printf("SCSI OK\n");
// if the command did not generate any Sense Data, just return NULL
return 0;
}
else if(cmd_status == 2) { // Check Condition
printf("SCSI CHK CONDITION\n");
// Request sense data
scsi_sense_reply sense_data;
scsi_request_sense_data(Device, &sense_data);
printf("SCSI CHECK CONDITION (KEY %x, ASC %x, ASCQ %x)\n", sense_data.key, sense_data.asc, sense_data.ascq);
// okay, we have an SS_ERR condition, let's check the SENSE DATA
// assemble [00 ASC ASCQ SenseKey]
return (sense_data.asc << 16) ||
(sense_data.ascq << 8) ||
sense_data.key;
return (long(sense_data.asc) << 16) |
(long(sense_data.ascq) << 8) |
(long(sense_data.key) );
}
else {
// else, if it's *NOT* a "Sense Data" error (SS_ERR)
@ -209,9 +209,13 @@ long GetModePage(short Device, short PageToGet, void *pBuffer, short BufLen) {
* SET MODE PAGE
*******************************************************************************/
long SetModePage(short Device, void *pBuffer) {
char Scsi[6] = {0}; // init the SCSI parameter block
char* ebx = (char*) pBuffer; // get a pointer to the top of buffer
char ecx = ebx[0] + 1; // adjust it up by one
ebx[0] = 0; // now clear the two reserved bytes
ebx[2] = 0;
char Scsi[6] = {0}; // init the SCSI parameter block
Scsi[0] = SCSI_Cmd_ModeSelect; // set the command
Scsi[1] = 0x10; // set the Page Format bit
Scsi[4] = ecx; // set the parameter list length
@ -237,7 +241,13 @@ void ModifyModePage(char *PageBuff, char ecc, char retries) {
void SetErrorRecovery(bool Retries, bool ECC, bool Testing) {
char PageBuff[40];
#ifdef NO_EXCESS_READS
// Limit reads to 20 bytes to prevent controller errors
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, 20);
#else
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff));
#endif
#define EARLY_RECOVERY 0x08
#define PER 0x04
@ -260,7 +270,7 @@ void SetErrorRecovery(bool Retries, bool ECC, bool Testing) {
retries = 0;
ModifyModePage(PageBuff, ecc, retries);
long eax = SetModePage(CurrentDevice, PageBuff);
const long eax = SetModePage(CurrentDevice, PageBuff);
// if we had an invalid field in the CDB (the EER bit was on)
if (eax == 0x00260005) {
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff));
@ -339,8 +349,13 @@ void GetSpareSectorCounts(bool) {
// rather than 72; it looks like this code is causing a SCSI transfer error
// here... might be better to conditionally check for Jaz drive
char DiskStat[72];
#ifdef NO_EXCESS_READS
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, 63);
if (eax) return;
#else
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat));
if (!eax) /*goto ListChk;*/ return;
#endif
// --------------------------------------------------------------------------
ch = 0; // clear the DRIVE_A_SUPPORT
if (JazDrive) {
@ -378,6 +393,7 @@ void GetSpareSectorCounts(bool) {
Side_0_SparesCount = eax;
MAKE_LITTLE_ENDIAN(ebx); // make it little endian
Side_1_SparesCount = ebx;
// compute the number of troubles we encountered during the testing
FirmErrors = Initial_Side_0_Spares - Side_0_SparesCount;
FirmErrors += Initial_Side_1_Spares - Side_1_SparesCount;
@ -386,6 +402,7 @@ void GetSpareSectorCounts(bool) {
CartridgeStatus = DISK_TEST_FAILURE;
return;
}
// MLT: The code for removing the ZIP protection has been omitted
return; // return zero since no error
}
@ -462,7 +479,6 @@ void BumpErrorCounts(long ErrorCode) {
* PERFORM REGION TRANSFER
*******************************************************************************/
long PerformRegionTransfer(short XferCmd, void *pBuffer) {
return -1;
char Scsi[10] = {0}; // clear out the SCSI CDB
const long InitialHardErrors = HardErrors;
@ -472,10 +488,10 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
DWORD_AT(Scsi[2]) = MAKE_BIG_ENDIAN(FirstLBASector); // WHICH LBA's to read, BIG endian
WORD_AT(Scsi[7]) = MAKE_BIG_ENDIAN(NumberOfLBAs); // HOW MANY to read, BIG endian
long eax = SCSICommand(CurrentDevice, Scsi, pBuffer, NumberOfLBAs * BYTES_PER_SECTOR);
return 1;
// if we failed somewhere during our transfer ... let's zero in on it
if (eax) {
printf("Error during transfer %lx (lba: %ld)\n", eax, FirstLBASector);
if ( eax == SS_ERR || // if it's a CONTROLLER ERROR, skip!
eax == BUFFER_TOO_BIG ||
eax == LBA_TOO_LARGE) {
@ -540,10 +556,10 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
GetSpareSectorCounts(false); // update the Cart's Condition
UpdateRunTimeDisplay();
LocalBuffer += BYTES_PER_SECTOR;
SingleTransferLBA++;
if(UserInterrupt) break;
}
LocalBuffer += BYTES_PER_SECTOR;
SingleTransferLBA++;
ProcessPendingMessages();
}
@ -593,6 +609,9 @@ long TestTheDisk() {
LockCurrentDrive(); // prevent media removal
GetSpareSectorCounts(false); // update the Cart's Condition
UpdateRunTimeDisplay();
// Standard Testing Operation
StartingInstant = GetSystemTime();
@ -627,7 +646,7 @@ long TestTheDisk() {
long eax = PerformRegionTransfer(SCSI_Cmd_ReadMany, pUserDataBuffer);
if(eax == 0) {
/*if(eax == 0) {
// -------------------------------
TestingPhase = WRITING_PATT;
UpdateRunPhaseDisplay();
@ -647,7 +666,7 @@ long TestTheDisk() {
}
if (CartridgeStatus != DISK_TEST_UNDERWAY) {
break;
}
}*/
// bump the FirstLBASector up for the next transfer
FirstLBASector += NumberOfLBAs;
} while(!UserInterrupt);

View File

@ -22,7 +22,8 @@ void DoUpdate(WindowPtr window);
void DoMouseDown(EventRecord &event);
void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion);
void run_tip(void) {
void run_tip(int id) {
CurrentDevice = id;
RgnHandle cursorRgn = NewRgn();
NewTipWindow();
@ -83,6 +84,12 @@ void NewTipWindow() {
}
ReleaseDC(hMainWnd);
// Initialize tip
PrepareToBeginTesting();
GetSpareSectorCounts(false);
FirmErrors = 0;
UpdateRunTimeDisplay();
}
void DestroyTipWindow() {