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

@ -17,7 +17,7 @@ void dev_info( int id );
void show_spares( int id );
void main() {
SIOUXSettings.autocloseonquit = TRUE;
SIOUXSettings.autocloseonquit = TRUE;
SIOUXSettings.asktosaveonclose = FALSE;
SIOUXSettings.standalone = FALSE;
@ -29,18 +29,18 @@ void main() {
print_help();
do {
EventRecord event;
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), NULL))
SIOUXHandleOneEvent(&event);
do {
EventRecord event;
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), NULL))
SIOUXHandleOneEvent(&event);
} while (process_command());
} while (process_command());
printf( "Goodbye.\n" );
}
bool process_command() {
short int arg_val = 0;
short int arg_val = 0;
char cmd[80];
printf( "\n> " );
gets( cmd );
@ -58,32 +58,32 @@ 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;
}
void print_help() {
printf(
"\nGeneral commands:\n"
" help : print this help\n"
" quit : quit the program\n"
printf(
"\nGeneral commands:\n"
" help : print this help\n"
" quit : quit the program\n"
"\nMacintosh commands (please unmount Zip prior to testing):\n"
" volumes : list Mac volumes\n"
" unmount [n] : unmount a volume\n"
"\nMacintosh commands (please unmount Zip prior to testing):\n"
" volumes : list Mac volumes\n"
" unmount [n] : unmount a volume\n"
"\nGeneral SCSI operations:\n"
" reset : reset the SCSI bus\n"
" list : list devices on the SCSI bus\n"
" info [n] : display SCSI inquiry\n"
"\nGeneral SCSI operations:\n"
" reset : reset the SCSI bus\n"
" list : list devices on the SCSI bus\n"
" info [n] : display SCSI inquiry\n"
"\nIomega device operations on SCSI device:\n"
" spin [n] : spin up a cartridge\n"
" eject [n] : eject cartridge\n"
" tip [n] : run Steve Gibson's TIP 2.1\n"
);
"\nIomega device operations on SCSI device:\n"
" spin [n] : spin up a cartridge\n"
" eject [n] : eject cartridge\n"
" tip [n] : run Steve Gibson's TIP 2.1\n"
);
}
void scan_bus() {

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

View File

@ -11,28 +11,28 @@ void mac_list_volumes() {
paramBlock.volumeParam.ioVRefNum = 0;
paramBlock.volumeParam.ioVolIndex = 0;
for (;;) {
OSErr err = PBHGetVInfo(&paramBlock, false);
if (err == nsvErr) break;
printf(" %d: %#s\n", paramBlock.volumeParam.ioVolIndex, paramBlock.volumeParam.ioNamePtr);
paramBlock.volumeParam.ioVolIndex++;
}
OSErr err = PBHGetVInfo(&paramBlock, false);
if (err == nsvErr) break;
printf(" %d: %#s\n", paramBlock.volumeParam.ioVolIndex, paramBlock.volumeParam.ioNamePtr);
paramBlock.volumeParam.ioVolIndex++;
}
}
void mac_unmount(int id) {
HParamBlockRec paramBlock;
HParamBlockRec paramBlock;
paramBlock.volumeParam.ioCompletion = 0;
paramBlock.volumeParam.ioNamePtr = 0;
paramBlock.volumeParam.ioVRefNum = 0;
paramBlock.volumeParam.ioVolIndex = id;
OSErr err = PBHGetVInfo(&paramBlock, false);
if (err == nsvErr) {
printf("No such volume\n");
return;
}
err = UnmountVol(0, paramBlock.volumeParam.ioVRefNum);
switch (err) {
case noErr: printf("Okay\n"); break;
case fBsyErr: printf("One or more files are open\n"); break;
default: printf("Failed %d\n", err);
}
if (err == nsvErr) {
printf("No such volume\n");
return;
}
err = UnmountVol(0, paramBlock.volumeParam.ioVRefNum);
switch (err) {
case noErr: printf("Okay\n"); break;
case fBsyErr: printf("One or more files are open\n"); break;
default: printf("Failed %d\n", err);
}
}

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

@ -43,7 +43,7 @@ OSErr iomega_set_prevent_removal( int id, bool lock) {
}
OSErr iomega_eject_cartridge( int id ) {
OSErr err;
OSErr err;
err = iomega_set_prevent_removal(id, false);
if (err != noErr) return err;
return iomega_spin_down_and_eject(id);

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);
}

View File

@ -4,7 +4,7 @@ typedef Boolean bool;
enum {
SCSI_Cmd_RequestSense = 0x03,
SCSI_Cmd_FormatUnit = 0x04,
SCSI_Cmd_FormatUnit = 0x04,
SCSI_Cmd_NonSenseData = 0x06,
SCSI_Cmd_Read = 0x08,
SCSI_Cmd_Write = 0x0a,

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

@ -8,7 +8,7 @@
#include "tip.h"
// ----------------------- Test Monitor Panel Definitions -------------------
// ----------------------- Test Monitor Panel Definitions -------------------
#define SET_RECT(LEFT, TOP, RIGHT, BOTTOM) {TOP, LEFT, BOTTOM, RIGHT}
Rect CS_Stat = SET_RECT(114, 8, 242, 28);
@ -25,72 +25,72 @@ Rect SE_Rect = SET_RECT(222, 154, 255, 221);
* This is the system's main window procedure
*/
void WndProc(long iMessage, long wParam) {
// -------------------------------------------------------------------------
// WM_PAINT
// -------------------------------------------------------------------------
if (iMessage == WM_PAINT) {
// Draw the Lower Horz Button Divider
// -------------------------------------------------------------------------
// WM_PAINT
// -------------------------------------------------------------------------
if (iMessage == WM_PAINT) {
// Draw the Lower Horz Button Divider
SetColor(GRAY_COLOR);
MoveTo(15, 289);
LineTo(446, 289);
SetColor(WHITE_COLOR);
LineTo(446, 290);
LineTo(14, 290);
SetColor(GRAY_COLOR);
MoveTo(15, 289);
LineTo(446, 289);
SetColor(WHITE_COLOR);
LineTo(446, 290);
LineTo(14, 290);
// Paint the Copyright Notice
SetColor(GRAY_COLOR);
TextOut(15, 298, szCopyright_1);
TextOut(15, 311, szCopyright_2);
// Paint the Copyright Notice
SetColor(GRAY_COLOR);
TextOut(15, 298, szCopyright_1);
TextOut(15, 311, szCopyright_2);
}
// -------------------------------------------------------------------------
// WM_COMMAND : a button was pressed
// -------------------------------------------------------------------------
else if (iMessage == WM_COMMAND) {
switch(wParam) {
case IDB_QUIT:
if (TestingPhase < TESTING_STARTUP) {
PostQuitMessage();
}
break;
case IDB_TEST:
switch(CartridgeStatus) {
case DISK_SPUN_DOWN:
SpinUpIomegaCartridge(CurrentDevice);
break;
case DISK_AT_SPEED:
printf("Testing the disk\n");
if(TestingPhase != READY_TO_TEST) {
PrepareToBeginTesting();
}
TestTheDisk();
printf("Test finished\n");
break;
case DISK_TEST_UNDERWAY:
UserInterrupt = 1;
break;
case DISK_Z_TRACK_FAILURE:
case DISK_TEST_FAILURE:
case DISK_PROTECTED:
//EjectIomegaCartridge();
break;
case DISK_LOW_SPARES:
PrepareToBeginTesting();
break;
}
break;
// -------------------------------------------------------------------------
// WM_COMMAND : a button was pressed
// -------------------------------------------------------------------------
else if (iMessage == WM_COMMAND) {
switch(wParam) {
case IDB_QUIT:
if (TestingPhase < TESTING_STARTUP) {
PostQuitMessage();
}
break;
case IDB_TEST:
switch(CartridgeStatus) {
case DISK_SPUN_DOWN:
SpinUpIomegaCartridge(CurrentDevice);
break;
case DISK_AT_SPEED:
printf("Testing the disk\n");
if(TestingPhase != READY_TO_TEST) {
PrepareToBeginTesting();
}
TestTheDisk();
printf("Test finished\n");
break;
case DISK_TEST_UNDERWAY:
UserInterrupt = 1;
break;
case DISK_Z_TRACK_FAILURE:
case DISK_TEST_FAILURE:
case DISK_PROTECTED:
//EjectIomegaCartridge();
break;
case DISK_LOW_SPARES:
PrepareToBeginTesting();
break;
}
break;
default:
break;
}
}
break;
}
}
}
BtnList tipBtns[] = {
{IDB_TEST, szPressToStart, 200, 301, 160, 24, true}, // Added by MLT
{IDB_BACK, szBack, 185-28, 301, 80, 24, false},
{IDB_NEXT, szNext, 264-28, 301, 80, 24, false},
{IDB_QUIT, szQuit, 367+35, 301, 45, 24, true},
{0, 0, 0, 0, 0, 0, 0}
{IDB_TEST, szPressToStart, 200, 301, 160, 24, true}, // Added by MLT
{IDB_BACK, szBack, 185-28, 301, 80, 24, false},
{IDB_NEXT, szNext, 264-28, 301, 80, 24, false},
{IDB_QUIT, szQuit, 367+35, 301, 45, 24, true},
{0, 0, 0, 0, 0, 0, 0}
};
/*******************************************************************************
@ -155,7 +155,7 @@ void PaintCartStatus() {
* PAINT BAR GRAPH
*******************************************************************************/
void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor, long BarValue, char *pRightText, bool Active) {
// fill the entire rectangle with background gray
// fill the entire rectangle with background gray
SetColor(BACK_COLOR);
Rectangle(Xleft, Ytop, Xleft + XWidth, Ytop + YHeight);
if (Active) { // now fleshout the bar ONLY IF we're active
@ -170,10 +170,10 @@ void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor,
Rectangle(Xleft, Ytop, Xleft + AbsoluteBarWidth, Ytop + YHeight);
// now place the floating percentage into the middle (if it fits there)
if(BarValue) {
char PercentString[8];
sprintf(PercentString, szBarChartPercent, BarValue);
SetColor(WHITE_COLOR);
TextOutCentered(Xleft, Ytop, AbsoluteBarWidth, YHeight, PercentString);
char PercentString[8];
sprintf(PercentString, szBarChartPercent, BarValue);
SetColor(WHITE_COLOR);
TextOutCentered(Xleft, Ytop, AbsoluteBarWidth, YHeight, PercentString);
}
}
@ -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;
}
@ -262,8 +266,8 @@ void PaintTestStatistics(bool Active) {
// show the LastError
char *errStr = 0;
for (int i = 0; errorTypeList[i].str; i++) {
errStr = errorTypeList[i].str;
if (errorTypeList[i].code == LastError) break;
errStr = errorTypeList[i].str;
if (errorTypeList[i].code == LastError) break;
}
PaintCenteredString(76, 172, 126, 14, errStr, Active);
@ -345,12 +349,12 @@ void TestMonitorWndProc() {
*******************************************************************************/
void UpdateRunTimeDisplay() {
GetDC(hTestMonitor);
PaintTestPhase();
PaintTheBarGraphs(true);
PaintTestStatistics(true);
PaintCartStatus();// Added by MLT
ReleaseDC(hTestMonitor);
GetDC(hTestMonitor);
PaintTestPhase();
PaintTheBarGraphs(true);
PaintTestStatistics(true);
PaintCartStatus();// Added by MLT
ReleaseDC(hTestMonitor);
}
/*******************************************************************************
@ -358,11 +362,11 @@ void UpdateRunTimeDisplay() {
*******************************************************************************/
void UpdateCurrentSector() {
GetDC(hTestMonitor);
char szString[40];
sprintf(szString, szCenteredDecimal, SingleTransferLBA);
PaintCenteredString(76, 155, 126, 14, szString, true);
ReleaseDC(hTestMonitor);
GetDC(hTestMonitor);
char szString[40];
sprintf(szString, szCenteredDecimal, SingleTransferLBA);
PaintCenteredString(76, 155, 126, 14, szString, true);
ReleaseDC(hTestMonitor);
}
/*******************************************************************************
@ -370,9 +374,9 @@ void UpdateCurrentSector() {
*******************************************************************************/
void UpdateRunPhaseDisplay() {
GetDC(hTestMonitor);
PaintTestPhase();
ReleaseDC(hTestMonitor);
GetDC(hTestMonitor);
PaintTestPhase();
ReleaseDC(hTestMonitor);
}
/*******************************************************************************
@ -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
@ -70,9 +70,9 @@ unsigned long GetSystemTime();
#define hMainWnd 0, 40
#define GetDC(h) {GrafPtr oldPort; \
GetPort(&oldPort); \
SetPort(tipWindow); \
SetOrigin(h);
GetPort(&oldPort); \
SetPort(tipWindow); \
SetOrigin(h);
#define ReleaseDC(h) SetOrigin(0,0); \
SetPort(oldPort);}
@ -162,9 +162,9 @@ extern const char *szBack;
extern const char *szNext;
extern const char *szQuit;
#define IDB_BACK 0xFF00
#define IDB_NEXT 0xFF01
#define IDB_QUIT 0xFF02
#define IDB_BACK 0xFF00
#define IDB_NEXT 0xFF01
#define IDB_QUIT 0xFF02
#define IDB_TEST 0xFF03
typedef struct {long id; const char *name; int x; int y; int w; int h; bool visible;} BtnList;
@ -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))
@ -25,9 +26,9 @@
#define JAZ_2GB_BOOT 0x0E00
struct DEFECT_LIST_HEADER {
char DLH_reserved; // (00h)
char DLH_BitFlags; // [000] [P] [G] [xxx - defect list format]
char DLH_DefectListLength;
char DLH_reserved; // (00h)
char DLH_BitFlags; // [000] [P] [G] [xxx - defect list format]
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
@ -170,23 +171,22 @@ long SCSICommand(short Device, char *lpCmdBlk, void *lpIoBuf, short IoBufLen) {
// call the SCSI interface to forward the command to the device
OSErr err = scsi_cmd(Device, lpCmdBlk, cmd_length, lpIoBuf, IoBufLen, 0, cmd_flags, &cmd_status);
if(err != noErr) {
return SS_ERR;
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];
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff));
#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];
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat));
if (!eax) /*goto ListChk;*/ return;
#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
}
@ -423,16 +440,16 @@ void PrepareToBeginTesting() {
HardErrors = 0;
UserInterrupt = 0;
LastError = 0;
#ifdef DEMO
LastLBAOnCartridge = 99999;
SoftErrors = 6;
FirmErrors = 2;
HardErrors = 1;
UserInterrupt = 0;
LastError = 0x0C8001;
Side_0_SparesCount = 12;
Side_1_SparesCount = 20;
#endif
#ifdef DEMO
LastLBAOnCartridge = 99999;
SoftErrors = 6;
FirmErrors = 2;
HardErrors = 1;
UserInterrupt = 0;
LastError = 0x0C8001;
Side_0_SparesCount = 12;
Side_1_SparesCount = 20;
#endif
}
/*******************************************************************************
@ -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) {
@ -489,11 +505,11 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
char *LocalBuffer = (char*) pBuffer;
ErrorSound();
SingleTransferLBA = FirstLBASector;
SingleTransferLBA = FirstLBASector;
// Perform transfer LBA block at a time
for(long i = 0; i < NumberOfLBAs; ++i) {
UpdateCurrentSector();
UpdateCurrentSector();
// setup for our series of transfer tests ...
@ -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;
if(UserInterrupt) break;
}
LocalBuffer += BYTES_PER_SECTOR;
SingleTransferLBA++;
ProcessPendingMessages();
}
@ -582,10 +598,10 @@ long TestTheDisk() {
void *pPatternBuffer = malloc(MAX_SECTORS_PER_TEST * BYTES_PER_SECTOR);
void *pUserDataBuffer = malloc(MAX_SECTORS_PER_TEST * BYTES_PER_SECTOR);
if(pPatternBuffer == NULL || pUserDataBuffer == NULL) {
printf("Allocation error\n");
return -1;
}
if(pPatternBuffer == NULL || pUserDataBuffer == NULL) {
printf("Allocation error\n");
return -1;
}
CartridgeStatus = DISK_TEST_UNDERWAY;
TestingPhase = TESTING_STARTUP; // inhibit stopping now
@ -593,23 +609,26 @@ long TestTheDisk() {
LockCurrentDrive(); // prevent media removal
GetSpareSectorCounts(false); // update the Cart's Condition
UpdateRunTimeDisplay();
// Standard Testing Operation
StartingInstant = GetSystemTime();
do {
ProcessPendingMessages();
ProcessPendingMessages();
NumberOfLBAs = MAX_SECTORS_PER_TEST;
NumberOfLBAs = MAX_SECTORS_PER_TEST;
if(LastLBAOnCartridge) {
if (FirstLBASector + NumberOfLBAs > LastLBAOnCartridge + 1) {
NumberOfLBAs = LastLBAOnCartridge - FirstLBASector + 1;
}
// compute the percentage complete
PercentComplete = FirstLBASector * 100 / LastLBAOnCartridge;
}
if(LastLBAOnCartridge) {
if (FirstLBASector + NumberOfLBAs > LastLBAOnCartridge + 1) {
NumberOfLBAs = LastLBAOnCartridge - FirstLBASector + 1;
}
// compute the percentage complete
PercentComplete = FirstLBASector * 100 / LastLBAOnCartridge;
}
if(NumberOfLBAs == 0) break;
if(NumberOfLBAs == 0) break;
// uppdate the elapsed time
SecondsElapsed = GetElapsedTimeInSeconds();
@ -627,7 +646,7 @@ long TestTheDisk() {
long eax = PerformRegionTransfer(SCSI_Cmd_ReadMany, pUserDataBuffer);
if(eax == 0) {
/*if(eax == 0) {
// -------------------------------
TestingPhase = WRITING_PATT;
UpdateRunPhaseDisplay();
@ -646,16 +665,16 @@ long TestTheDisk() {
goto GetOut;
}
if (CartridgeStatus != DISK_TEST_UNDERWAY) {
break;
}
break;
}*/
// bump the FirstLBASector up for the next transfer
FirstLBASector += NumberOfLBAs;
} while(!UserInterrupt);
// show that we're post-test
GetOut:
free(pPatternBuffer);
free(pUserDataBuffer);
free(pPatternBuffer);
free(pUserDataBuffer);
TestingPhase = UNTESTED;
UnlockCurrentDrive();

View File

@ -22,16 +22,17 @@ void DoUpdate(WindowPtr window);
void DoMouseDown(EventRecord &event);
void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion);
void run_tip(void) {
RgnHandle cursorRgn = NewRgn();
void run_tip(int id) {
CurrentDevice = id;
RgnHandle cursorRgn = NewRgn();
NewTipWindow();
gDone = false;
do {
EventRecord event;
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), cursorRgn)) {
DoEvent(event, &cursorRgn);
}
EventRecord event;
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), cursorRgn)) {
DoEvent(event, &cursorRgn);
}
} while (!gDone);
DestroyTipWindow();
@ -50,13 +51,13 @@ void NewTipWindow() {
rect.bottom = rect.top + 336 - 35;
rect.right = rect.left + 467;
Str255 title;
StrToPascal(title, szWindowTitle);
Str255 title;
StrToPascal(title, szWindowTitle);
tipWindow = AllowColor ?
NewCWindow(NULL,&rect, title, true, 0, 0, true, 0) :
NewWindow(NULL,&rect, title, true, 0, 0, true, 0);
GetDC(hMainWnd);
GetDC(hMainWnd);
if (AllowColor) {
SetColor(BACK_COLOR);
@ -66,23 +67,29 @@ void NewTipWindow() {
}
TextSize(10);
for(int i = 0; tipBtns[i].name; i++) {
if (!tipBtns[i].visible) continue;
SetRect(&rect,
tipBtns[i].x,
tipBtns[i].y,
tipBtns[i].x + tipBtns[i].w,
tipBtns[i].y + tipBtns[i].h
);
for(int i = 0; tipBtns[i].name; i++) {
if (!tipBtns[i].visible) continue;
SetRect(&rect,
tipBtns[i].x,
tipBtns[i].y,
tipBtns[i].x + tipBtns[i].w,
tipBtns[i].y + tipBtns[i].h
);
StrToPascal(title, tipBtns[i].name);
ControlHandle h = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
if(tipBtns[i].id == IDB_TEST) {
actionBtn = h;
}
StrToPascal(title, tipBtns[i].name);
ControlHandle h = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
if(tipBtns[i].id == IDB_TEST) {
actionBtn = h;
}
}
ReleaseDC(hMainWnd);
// Initialize tip
PrepareToBeginTesting();
GetSpareSectorCounts(false);
FirmErrors = 0;
UpdateRunTimeDisplay();
}
void DestroyTipWindow() {
@ -91,9 +98,9 @@ void DestroyTipWindow() {
void DoEvent(EventRecord &event, RgnHandle *cursorRgn) {
if(!SIOUXHandleOneEvent(&event)) {
// If SIOUX didn't handle the event, then handle it ourselves
// If SIOUX didn't handle the event, then handle it ourselves
switch(event.what) {
case mouseDown: DoMouseDown(event); break;
case mouseDown: DoMouseDown(event); break;
case updateEvt: DoUpdate((WindowPtr)event.message); break;
case osEvt: DoMouseMove(event, cursorRgn); break;
}
@ -106,7 +113,7 @@ void DoUpdate(WindowPtr window) {
SetPort(window);
EraseRect(&window->portRect);
GetDC(hMainWnd);
GetDC(hMainWnd);
WndProc(WM_PAINT, 0);
DrawControls(window);
ReleaseDC(hMainWnd);
@ -131,19 +138,19 @@ void DoMouseDown(EventRecord &event) {
SelectWindow(thisWindow);
}
else if(thisWindow == tipWindow) {
long id = 0;
Point mouse = event.where;
GetDC(hMainWnd);
GlobalToLocal(&mouse);
if(FindControl(mouse, thisWindow, &thisControl) == inButton) {
if(TrackControl(thisControl, mouse, 0) == inButton) {
id = GetControlReference(thisControl);
}
}
ReleaseDC(hMainWnd);
if(id) {
WndProc(WM_COMMAND, id);
}
long id = 0;
Point mouse = event.where;
GetDC(hMainWnd);
GlobalToLocal(&mouse);
if(FindControl(mouse, thisWindow, &thisControl) == inButton) {
if(TrackControl(thisControl, mouse, 0) == inButton) {
id = GetControlReference(thisControl);
}
}
ReleaseDC(hMainWnd);
if(id) {
WndProc(WM_COMMAND, id);
}
}
break;
case inDrag:
@ -163,13 +170,13 @@ void DoMouseDown(EventRecord &event) {
void DoMouseMove(EventRecord &event, RgnHandle *cursorRgn) {
WindowPtr thisWindow;
int part = FindWindow(event.where, &thisWindow);
if (thisWindow == tipWindow) {
InitCursor();
// Set the cursorRegion to everything inside our window
if(cursorRgn) {
CopyRgn(((WindowPeek)tipWindow)->contRgn, *cursorRgn);
}
}
if (thisWindow == tipWindow) {
InitCursor();
// Set the cursorRegion to everything inside our window
if(cursorRgn) {
CopyRgn(((WindowPeek)tipWindow)->contRgn, *cursorRgn);
}
}
}
void StrToPascal(Str255 pStr, const char *str) {
@ -202,8 +209,8 @@ void SetColor(long color) {
break;
case BLACK_COLOR:
case GRAY_COLOR:
PenPat(&qd.black);
break;
PenPat(&qd.black);
break;
case RED_COLOR:
case BLUE_COLOR:
PenPat(&qd.ltGray);
@ -211,17 +218,17 @@ void SetColor(long color) {
case LTGRAY_COLOR:
case GREEN_COLOR:
PenPat(&qd.gray);
break;
break;
}
}
}
void SetColor(long color, long monoColor) {
if (AllowColor) {
SetColor(color);
} else {
SetColor(monoColor);
}
if (AllowColor) {
SetColor(color);
} else {
SetColor(monoColor);
}
}
/*******************************************************************************
@ -264,7 +271,7 @@ void DrawLed(int x, int y, long color) {
*******************************************************************************/
void DrawEdge(Rect *qrc, int edge, int grfFlags) {
if(edge == BDR_SUNKENOUTER && AllowColor) {
if(edge == BDR_SUNKENOUTER && AllowColor) {
// Draw a sunken rectangle
SetColor(GRAY_COLOR);
MoveTo(qrc->left,qrc->bottom-1);
@ -343,28 +350,28 @@ unsigned long GetSystemTime() {
* SET BUTTON TEXT
*******************************************************************************/
void SetButtonText(const char *str) {
Str255 pStr;
StrToPascal(pStr, str);
if(actionBtn) {
GetDC(hMainWnd);
SetCTitle(actionBtn, pStr);
ReleaseDC(hMainWnd);
}
Str255 pStr;
StrToPascal(pStr, str);
if(actionBtn) {
GetDC(hMainWnd);
SetCTitle(actionBtn, pStr);
ReleaseDC(hMainWnd);
}
}
/*******************************************************************************
* POST QUIT MESSAGE
*******************************************************************************/
void PostQuitMessage() {
gDone = true;
gDone = true;
}
/*******************************************************************************
* PROCESS PENDING MESSAGES
*******************************************************************************/
void ProcessPendingMessages() {
EventRecord event;
if (GetNextEvent(everyEvent, &event)) {
DoEvent(event,NULL);
}
EventRecord event;
if (GetNextEvent(everyEvent, &event)) {
DoEvent(event,NULL);
}
}

View File

@ -1,7 +1,7 @@
#include "tip.h"
const char *szWindowTitle = "TIP 2.1b -- Zip & Jaz Drive and Cartridge Testing System";
const char *szCopyright_1 = "Copyright (c) 2006 by";
const char *szCopyright_1 = "Copyright (c) 2006 by";
const char *szCopyright_2 = "Gibson Research Corp.";
const char *szSide0 = "Side 0";
@ -10,7 +10,7 @@ const char *szSpaceDashSpace = " - ";
const char *szBarChartPercent = " %ld%% ";
const char *szCenteredDecimal = "%ld";
const char *szCenteredHex = "ErrorCode: %06lX";
const char *szCenteredHex = "ErrorCode: %06lX";
const char *szHoursMinsSecs = "%ld:%02ld:%02ld";
const char *szCartStatus = "Cartridge Status:";