summaryrefslogtreecommitdiff
path: root/scsi_sgi.c
diff options
context:
space:
mode:
authorCarsten Leonhardt <leo@debian.org>2019-02-27 23:12:38 +0100
committerCarsten Leonhardt <leo@debian.org>2019-02-27 23:12:38 +0100
commitd94bd19c05a1b654a7851821f7c4b7cdd70e1515 (patch)
treebe7cb2ff99167e6dbc12c2c99acad4b386f92bf5 /scsi_sgi.c
parentb695062f151fdfa5cd19cd20918bdf2dc6fd6332 (diff)
Import Upstream version 1.2.16rel
Diffstat (limited to 'scsi_sgi.c')
-rw-r--r--scsi_sgi.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/scsi_sgi.c b/scsi_sgi.c
new file mode 100644
index 0000000..c215de9
--- /dev/null
+++ b/scsi_sgi.c
@@ -0,0 +1,75 @@
+/* Copyright 1997, 1998 Leonard Zubkoff <lnz@dandelion.com>
+ Changes copyright 2000 Eric Green <eric@estinc.com>
+
+$Date: 2001/06/05 17:10:26 $
+$Revision: 1.1.1.1 $
+
+ This program is free software; you may redistribute and/or modify it under
+ the terms of the GNU General Public License Version 2 as published by the
+ Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for complete details.
+
+*/
+
+/* This is the SCSI commands for SGI Iris */
+DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
+{
+ dsreq_t *DeviceFD = dsopen(DeviceName, O_RDWR | O_EXCL);
+ if (DeviceFD == 0)
+ FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+ return (DEVICE_TYPE) DeviceFD;
+}
+
+
+void SCSI_CloseDevice(char *DeviceName,
+ DEVICE_TYPE DeviceFD)
+{
+ dsclose((dsreq_t *) DeviceFD);
+}
+
+#define MTX_HZ 1000
+#define MTX_DEFAULT_SCSI_TIMEOUT 60*5*MTX_HZ /* 5 minutes! */
+
+static int mtx_default_timeout = MTX_DEFAULT_SCSI_TIMEOUT ;
+void SCSI_Set_Timeout(int sec) {
+ mtx_default_timeout=sec*MTX_HZ;
+}
+
+void SCSI_Default_Timeout() {
+ mtx_default_timeout=MTX_DEFAULT_SCSI_TIMEOUT;
+}
+
+int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
+ Direction_T Direction,
+ CDB_T *CDB,
+ int CDB_Length,
+ void *DataBuffer,
+ int DataBufferLength,
+ RequestSense_T *RequestSense)
+{
+ dsreq_t *dsp = (dsreq_t *) DeviceFD;
+ int Result;
+ memset(RequestSense, 0, sizeof(RequestSense_T));
+ memcpy(CMDBUF(dsp), CDB, CDB_Length);
+ if (Direction == Input)
+ {
+ memset(DataBuffer, 0, DataBufferLength);
+ filldsreq(dsp, (unsigned char *) DataBuffer, DataBufferLength,
+ DSRQ_READ | DSRQ_SENSE);
+ }
+ else filldsreq(dsp, (unsigned char *) DataBuffer, DataBufferLength,
+ DSRQ_WRITE | DSRQ_SENSE);
+ /* Set 5 minute timeout. */
+ /* TIME(dsp) = 300 * 1000; */
+ TIME(dsp) = mtx_default_timeout;
+ Result = doscsireq(getfd((dsp)), dsp);
+ if (SENSESENT(dsp) > 0)
+ memcpy(RequestSense, SENSEBUF(dsp),
+ min(sizeof(RequestSense_T), SENSESENT(dsp)));
+ SCSI_Default_Timeout(); /* reset the mtx default timeout */
+ return Result;
+}