1
/* Copyright (c) 1996-2004, Adaptec Corporation
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* - Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
9
* - Redistributions in binary form must reproduce the above copyright notice,
10
* this list of conditions and the following disclaimer in the documentation
11
* and/or other materials provided with the distribution.
12
* - Neither the name of the Adaptec Corporation nor the names of its
13
* contributors may be used to endorse or promote products derived from this
14
* software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
* POSSIBILITY OF SUCH DAMAGE.
30
//***************************************************************************
34
// This file contains the function definitions for the dptSCSIdev_C
37
//Author: Doug Anderson
45
//***************************************************************************
48
//Include Files -------------------------------------------------------------
49
#include "allfiles.hpp"
51
//Function - dptSCSIdev_C::dptSCSIdev_C() - start
52
//===========================================================================
56
// This function is the constructor for the dptSCSIdev_C class.
62
//Global Variables Affected:
64
//Remarks: (Side effects, Assumptions, Warnings...)
67
//---------------------------------------------------------------------------
69
dptSCSIdev_C::dptSCSIdev_C()
79
// Clear the transfer speed
81
// Clear the negotiated bus speed
85
// Default = No partition table
87
// Default = no previous max logical block
93
//dptSCSIdev_C::dptSCSIdev_C() - end
96
//Function - dptSCSIdev_C::setObjFlags() - start
97
//===========================================================================
101
// This function sets SCSI object flags.
107
//Global Variables Affected:
109
//Remarks: (Side effects, Assumptions, Warnings...)
112
//---------------------------------------------------------------------------
114
void dptSCSIdev_C::setObjFlags(uSHORT flg,uSHORT)
120
if (flg & FLG_DEV_EMULATED)
121
scsiFlags |= FLG_ENG_EMULATED;
123
// If emulated drive 1 (D:)...
124
if (flg & FLG_DEV_EMU_01)
125
scsiFlags |= FLG_ENG_EMU_01;
128
if (flg & FLG_DEV_REMOVEABLE)
129
scsiFlags |= FLG_ENG_REMOVEABLE;
131
// If a valid partition table exists...
132
if (flg & FLG_DEV_PTABLE)
133
scsiFlags |= FLG_ENG_PTABLE;
135
// If a valid DPT reserve block exists...
136
if (flg & FLG_DEV_RESERVE_BLOCK)
137
scsiFlags |= FLG_ENG_RESERVE_BLOCK;
139
// If downloaded FW exists on this drive...
140
if (flg & FLG_DEV_DFW)
141
scsiFlags |= FLG_ENG_DFW;
143
// If a valid previous SCSI address...
144
if (flg & FLG_DEV_PADDR_VALID)
145
scsiFlags |= FLG_ENG_VALID_PADDR;
147
// If ECC protected...
148
if (flg & FLG_DEV_ECC_PROTECTED)
152
//dptSCSIdev_C::setObjFlags() - end
155
//Function - dptSCSIdev_C::setInfo() - start
156
//===========================================================================
160
// This function sets SCSI device information from the specified
167
//Global Variables Affected:
169
//Remarks: (Side effects, Assumptions, Warnings...)
172
//---------------------------------------------------------------------------
174
DPT_RTN_T dptSCSIdev_C::setInfo(dptBuffer_S *toEng_P,uSHORT setAll)
177
DPT_RTN_T retVal = MSG_RTN_DATA_UNDERFLOW;
179
// Set base class information
180
dptSCSIobj_C::setInfo(toEng_P,setAll);
182
// Set the device's SCSI offset
183
toEng_P->extract(scsiOffset);
184
// Set the device's transfer speed
185
toEng_P->extract(xfrSpeed);
186
// Set the device's capacity information
187
toEng_P->extract(&capacity,sizeof(dptCapacity_S));
188
// Set the device's emulation parameters
189
toEng_P->extract(&emulation,dptEmuParam_size);
190
// If loading a configuration...
193
toEng_P->extract(dptName,DPT_NAME_SIZE+2);
194
// Skip the DPT name field
196
toEng_P->skip(DPT_NAME_SIZE+2);
197
// Set the last partition block used
198
if (toEng_P->extract(lastPartitionBlk))
199
retVal = MSG_RTN_COMPLETED;
204
//dptSCSIdev_C::setInfo() - end
207
//Function - dptSCSIdev_C::rtnInfo() - start
208
//===========================================================================
212
// This function returns SCSI device information to the specified
219
//Global Variables Affected:
221
//Remarks: (Side effects, Assumptions, Warnings...)
224
//---------------------------------------------------------------------------
226
DPT_RTN_T dptSCSIdev_C::rtnInfo(dptBuffer_S *fromEng_P)
229
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
231
// Return base class information
232
dptSCSIobj_C::rtnInfo(fromEng_P);
234
// Return the device's SCSI offset
235
fromEng_P->insert(scsiOffset);
236
// Return the device's transfer speed
237
fromEng_P->insert(xfrSpeed);
238
// Return the device's capacity information
239
fromEng_P->insert(&capacity,sizeof(dptCapacity_S));
240
// Return the device's emulation paramters
241
fromEng_P->insert(&emulation,dptEmuParam_size);
242
// Return the device's DPT specific name
243
fromEng_P->insert(dptName,DPT_NAME_SIZE+2);
244
// Return the last block used by a partition
245
if (fromEng_P->insert(lastPartitionBlk))
246
retVal = MSG_RTN_COMPLETED;
251
//dptSCSIdev_C::rtnInfo() - end
254
//Function - dptSCSIdev_C::getObjFlags() - start
255
//===========================================================================
259
// This function sets SCSI device flags.
265
//Global Variables Affected:
267
//Remarks: (Side effects, Assumptions, Warnings...)
270
//---------------------------------------------------------------------------
272
void dptSCSIdev_C::getObjFlags(uSHORT &flg)
275
// Set the appropriate flags
277
flg |= FLG_DEV_SUPPRESSED;
279
flg |= FLG_DEV_SUP_DESIRED;
281
flg |= FLG_DEV_EMULATED;
282
if (scsiFlags & FLG_ENG_EMU_01)
283
flg |= FLG_DEV_EMU_01;
285
flg |= FLG_DEV_REMOVEABLE;
287
flg |= FLG_DEV_LOGICAL;
288
if (scsiFlags & FLG_ENG_PTABLE)
289
flg |= FLG_DEV_PTABLE;
290
if (scsiFlags & FLG_ENG_RESERVE_BLOCK)
291
flg |= FLG_DEV_RESERVE_BLOCK;
292
if (myHBA_P()->is512kCache())
293
flg |= FLG_DEV_HBA_CACHE;
294
if (scsiFlags & FLG_ENG_DFW)
296
if (scsiFlags & FLG_ENG_VALID_PADDR)
297
flg |= FLG_DEV_PADDR_VALID;
298
if (isECCprotected())
299
flg |= FLG_DEV_ECC_PROTECTED;
302
//dptSCSIdev_C::getObjFlags() - end
305
//Function - dptSCSIdev_C::handleMessage() - start
306
//===========================================================================
310
// This routine handles DPT events for the dptRAIDdev_C class.
316
//Global Variables Affected:
318
//Remarks: (Side effects, Assumptions, Warnings...)
321
//---------------------------------------------------------------------------
323
DPT_RTN_T dptSCSIdev_C::handleMessage(DPT_MSG_T message,
324
dptBuffer_S *fromEng_P,
329
DPT_RTN_T retVal = MSG_RTN_IGNORED;
333
// Attempt to set the device's DPT name
334
case MSG_SET_DPT_NAME:
335
retVal = setDPTname(toEng_P);
338
// Return the device's DPT name
339
case MSG_GET_DPT_NAME:
340
if (fromEng_P->insert(dptName,DPT_NAME_SIZE+1))
341
retVal = MSG_RTN_COMPLETED;
343
retVal = MSG_RTN_DATA_OVERFLOW;
347
// Call base class event handler
348
retVal = dptObject_C::handleMessage(message,fromEng_P,toEng_P);
357
//dptSCSIdev_C::handleMessage() - end
360
//Function - dptSCSIdev_C::setDPTname() - start
361
//===========================================================================
365
// This function attempts to set the DPT name field.
371
//Global Variables Affected:
373
//Remarks: (Side effects, Assumptions, Warnings...)
376
//---------------------------------------------------------------------------
378
DPT_RTN_T dptSCSIdev_C::setDPTname(dptBuffer_S *toEng_P)
381
DPT_RTN_T retVal = MSG_RTN_IGNORED;
383
if ( (getLevel()<=1) && isLogical() ) {
384
retVal = MSG_RTN_DATA_UNDERFLOW;
385
// If any data was placed in the buffer...
386
if (toEng_P->writeIndex>0) {
387
// If the name is used by another device...
388
if ( (toEng_P->data[0]!=0) &&
389
myConn_P()->isDupName(toEng_P->data,(uSHORT)toEng_P->writeIndex)) {
390
retVal = MSG_RTN_FAILED | ERR_DUPLICATE_NAME;
393
// Indicate that a new DPT name has been specified
394
scsiFlags |= FLG_ENG_NEW_NAME;
395
// Set the new DPT name
396
if (toEng_P->extract(dptName,DPT_NAME_SIZE))
397
retVal = MSG_RTN_COMPLETED;
400
// Insure that the name is NULL terminated
401
dptName[toEng_P->readIndex] = 0;
402
// Convert to all uppercase
404
} // end if (getLevel<=1)...
410
//dptSCSIdev_C::setDPTname() - end
413
//Function - dptSCSIdev_C::~dptSCSIdev_C() - start
414
//===========================================================================
418
// This function is the destructor for the dptSCSIdev_C class.
424
//Global Variables Affected:
426
//Remarks: (Side effects, Assumptions, Warnings...)
429
//---------------------------------------------------------------------------
431
dptSCSIdev_C::~dptSCSIdev_C()
437
//dptSCSIdev_C::~dptSCSIdev_C() - end