home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 3
/
Meeting_Pearls_III.iso
/
Pearls
/
disk
/
Misc
/
TestGeometry
/
TestGeometry.mod
< prev
Wrap
Text File
|
1995-08-25
|
9KB
|
239 lines
(*
(****** TestGeometry/--AMOK-Header-- ****************************************
:Program. TestGeometry.mod
:Contents. TD_GETGEOMETRY test/demo for Exec device drivers
:Author. Oliver Knorr
:Copyright. Public Domain
:Language. Oberon-2
:Translator. Amiga Oberon v3.11
:History. v1.0 [olk] 25-Aug-95
:Version. $VER: TestGeometry.mod 1.0 (25.8.95)
*****************************************************************************
*
*)
*)
MODULE TestGeometry;
(****** TestGeometry/--background-- *****************************************
*
* This is a test and demonstration program for the TD_GETGEOMETRY
* and TD_PROTSTATUS commands that may be implemented in
* trackdisk.device-compatible Exec devices.
*
*****************************************************************************
*
*)
IMPORT
Exec, Dos, TrackDisk, SCSIDisk, io;
TYPE
Args = STRUCT (as: Dos.ArgsStruct)
device : Dos.ArgString;
unit : Dos.ArgLong;
END;
CONST
template = "DEVICE/A,UNIT/N/A";
verString = "$VER: TestGeometry 1.0 (25.8.95) by Oliver Knorr";
VAR
rdArgs : Dos.RDArgsPtr;
args : Args;
msgPort : Exec.MsgPortPtr;
ioReq : Exec.IOStdReqPtr;
driveGeo : TrackDisk.DriveGeometryPtr;
(****** TestGeometry/IOError ************************************************
*
* NAME
* IOError -- print scsi device driver error message
*
* SYNOPSIS
* IOError(code: SHORTINT)
*
* FUNCTION
* Writes the given error code and an appropriate error message
* to standard output. Knows messages for Exec, Trackdisk and
* SCSIDisk error codes.
*
* INPUTS
* code - the error code returned in the "error" field
* of your Exec.IOStdReq
*
* RESULT
*
* EXAMPLE
* IF Exec.DoIO (ioReq) = 0 THEN
* (* handle success case *)
* ELSE
* IOError(ioReq.error)
* END
*
* NOTES
*
* BUGS
*
* SEE ALSO
*
*****************************************************************************
*
*)
PROCEDURE IOError(code: SHORTINT);
BEGIN
io.WriteString("error "); io.WriteInt(code, 0);
CASE code OF
Exec.openFail : io.WriteString(" (device/unit failed to open)")
| Exec.aborted : io.WriteString(" (request terminated early)")
| Exec.noCmd : io.WriteString(" (command not supported by device)")
| Exec.badLength : io.WriteString(" (not a valid length)")
| Exec.badAddress : io.WriteString(" (invalid address)")
| Exec.unitBusy : io.WriteString(" (requested unit is busy)")
| Exec.selfTest : io.WriteString(" (hardware failed self-test)")
| TrackDisk.notSpecified : io.WriteString(" (not specified)")
| TrackDisk.noSecHdr : io.WriteString(" (no sector header)")
| TrackDisk.badSecPreamble : io.WriteString(" (bad sector preamble)")
| TrackDisk.badSecID : io.WriteString(" (bad secotor ID)")
| TrackDisk.badHdrSum : io.WriteString(" (bad header checksum)")
| TrackDisk.badSecSum : io.WriteString(" (bad data checksum)")
| TrackDisk.tooFewSecs : io.WriteString(" (too few sectors)")
| TrackDisk.badSecHdr : io.WriteString(" (bad sector header)")
| TrackDisk.writeProt : io.WriteString(" (disk is write protected)")
| TrackDisk.diskChanged : io.WriteString(" (no disk in the drive)")
| TrackDisk.seekError : io.WriteString(" (seek error)")
| TrackDisk.noMem : io.WriteString(" (out of memory)")
| TrackDisk.badUnitNum : io.WriteString(" (bad unit number)")
| TrackDisk.badDriveType : io.WriteString(" (bad drive type)")
| TrackDisk.driveInUse : io.WriteString(" (drive in use)")
| TrackDisk.postReset : io.WriteString(" (post reset)")
| SCSIDisk.selfUnit : io.WriteString(" (cannot issue SCSI command to self)")
| SCSIDisk.dma : io.WriteString(" (DMA error)")
| SCSIDisk.phase : io.WriteString(" (illegal or unexpected SCSI phase)")
| SCSIDisk.parity : io.WriteString(" (SCSI parity error)")
| SCSIDisk.selTimeout : io.WriteString(" (select timed out)")
| SCSIDisk.badStatus : io.WriteString(" (status and/or sense error)")
| SCSIDisk.noBoard : io.WriteString(" (open failed for non-existant board)")
ELSE
END
END IOError;
BEGIN
IF verString[0]="$" THEN END; (* the version string shouldn't be optimized away *)
IF Exec.SysBase.libNode.version >= 37 THEN
rdArgs := Dos.ReadArgs (template, args, NIL);
IF rdArgs # NIL THEN
msgPort := Exec.CreateMsgPort();
IF msgPort # NIL THEN
ioReq := Exec.CreateIORequest(msgPort, SIZE(Exec.IOStdReq));
IF ioReq # NIL THEN
IF Exec.OpenDevice(args.device^, args.unit[0], ioReq, LONGSET{}) = 0 THEN
io.WriteString("TD_GETGEOMETRY:"); io.WriteLn;
io.WriteString("==============="); io.WriteLn;
NEW(driveGeo);
ioReq.command := TrackDisk.getGeometry;
ioReq.length := SIZE(TrackDisk.DriveGeometry);
ioReq.data := driveGeo;
IF Exec.DoIO (ioReq) = 0 THEN
io.WriteString("sector size : "); io.WriteInt(driveGeo.sectorSize, 0); io.WriteLn;
io.WriteString("total sectors : "); io.WriteInt(driveGeo.totalSectors, 0); io.WriteLn;
io.WriteString("cylinders : "); io.WriteInt(driveGeo.cylinders, 0); io.WriteLn;
io.WriteString("sectors/cylinder : "); io.WriteInt(driveGeo.cylSectors, 0); io.WriteLn;
io.WriteString("heads : "); io.WriteInt(driveGeo.heads, 0); io.WriteLn;
io.WriteString("sectors/track : "); io.WriteInt(driveGeo.trackSectors, 0); io.WriteLn;
io.WriteString("buffer mem type : "); io.WriteInt(driveGeo.bufMemType, 0); io.WriteLn;
io.WriteString("device type : "); io.WriteInt(driveGeo.deviceType, 0); io.Write(" ");
CASE driveGeo.deviceType OF
TrackDisk.directAccess : io.WriteString("direct access")
| TrackDisk.sequentialAccess : io.WriteString("sequentiall access")
| TrackDisk.printer : io.WriteString("printer")
| TrackDisk.processor : io.WriteString("processor")
| TrackDisk.worm : io.WriteString("WORM")
| TrackDisk.cdRom : io.WriteString("CD-ROM")
| TrackDisk.scanner : io.WriteString("scanner")
| TrackDisk.opticalDisk : io.WriteString("optical disk")
| TrackDisk.mediumChanger : io.WriteString("medium changer")
| TrackDisk.communication : io.WriteString("communication")
| TrackDisk.unknown : io.WriteString("unknown")
ELSE
END;
io.WriteLn;
io.WriteString("flags :");
IF TrackDisk.removable IN driveGeo.flags THEN io.WriteString(" removable") END;
IF 1 IN driveGeo.flags THEN io.WriteString(" 1") END;
IF 2 IN driveGeo.flags THEN io.WriteString(" 2") END;
IF 3 IN driveGeo.flags THEN io.WriteString(" 3") END;
IF 4 IN driveGeo.flags THEN io.WriteString(" 4") END;
IF 5 IN driveGeo.flags THEN io.WriteString(" 5") END;
IF 6 IN driveGeo.flags THEN io.WriteString(" 6") END;
IF 7 IN driveGeo.flags THEN io.WriteString(" 7") END;
io.WriteLn
ELSE
IOError(ioReq.error);
io.WriteString(" reading drive geometry"); io.WriteLn
END;
io.WriteLn;
io.WriteString("TD_PROTSTATUS:"); io.WriteLn;
io.WriteString("=============="); io.WriteLn;
ioReq.command := TrackDisk.protStatus;
IF Exec.DoIO (ioReq) = 0 THEN
io.WriteString("write-protect status: ");
io.WriteInt(ioReq.actual, 0);
IF ioReq.actual = 0 THEN
io.WriteString(" read/write")
ELSE
io.WriteString(" read only")
END;
io.WriteLn
ELSE
IOError(ioReq.error);
io.WriteString(" reading write-protect status"); io.WriteLn
END;
io.WriteLn;
Exec.CloseDevice(ioReq)
ELSE
IOError(ioReq.error);
io.WriteString(" opening ");
io.WriteString(args.device^);
io.WriteString(" unit ");
io.WriteInt(args.unit[0], 0); io.WriteLn
END;
Exec.DeleteIORequest(ioReq)
ELSE
io.WriteString("could not create IORequest"); io.WriteLn
END;
Exec.DeleteMsgPort(msgPort)
ELSE
io.WriteString("could not create message port"); io.WriteLn
END;
Dos.FreeArgs(rdArgs)
ELSE
io.WriteString("wrong arguments"); io.WriteLn
END
ELSE
io.WriteString("requires exec.library V37"); io.WriteLn
END
END TestGeometry.