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 dptSCSIobj_C
37
//Author: Doug Anderson
45
//***************************************************************************
48
//Include Files -------------------------------------------------------------
50
#include "allfiles.hpp" // All engine include files
52
//Function - dptSCSIobj_C::dptSCSIobj_C() - start
53
//===========================================================================
57
// This function is the constructor for the dptSCSIobj_C class.
63
//Global Variables Affected:
65
//Remarks: (Side effects, Assumptions, Warnings...)
68
//---------------------------------------------------------------------------
70
dptSCSIobj_C::dptSCSIobj_C()
73
// Initialize the pointer to this object's HBA
75
// Clear the engine object type
76
engType = DPT_SCSI_DASD;
78
memcpy(descr.vendorID,"UNKNOWN",8);
79
memcpy(descr.productID,"--UNKNOWN--",12);
80
memcpy(descr.revision,"NONE",5);
81
memset(userBuff,0,USER_BUFF_SIZE);
86
//dptSCSIobj_C::dptSCSIobj_C() - end
89
//Function - dptSCSIobj_C::updateHBAnum() - start
90
//===========================================================================
94
// This function updates this objets HBA number.
100
//Global Variables Affected:
102
//Remarks: (Side effects, Assumptions, Warnings...)
105
//---------------------------------------------------------------------------
107
void dptSCSIobj_C::updateHBAnum()
111
// Set this object's HBA number
112
addr.hba = hba_P->getHBA();
115
//dptSCSIobj_C::updateHBAnum() - end
118
//Function - dptSCSIobj_C::setInfo() - start
119
//===========================================================================
123
// This function sets SCSI object information from data in the
124
//specified input buffer.
130
//Global Variables Affected:
132
//Remarks: (Side effects, Assumptions, Warnings...)
135
//---------------------------------------------------------------------------
137
DPT_RTN_T dptSCSIobj_C::setInfo(dptBuffer_S *toEng_P,uSHORT setAll)
140
DPT_RTN_T retVal = MSG_RTN_DATA_UNDERFLOW;
141
uSHORT suggestedFlags;
144
// Skip this object's tag
145
toEng_P->skip(sizeof(DPT_TAG_T));
146
// Skip the object type (already set)
147
toEng_P->skip(sizeof(uSHORT));
148
// Set the object's flags
149
if (toEng_P->extract(suggestedFlags))
150
setObjFlags(suggestedFlags,setAll);
152
// Set the object's display status
153
toEng_P->extract(status.display);
154
if (status.display>3)
155
status.display = DSPLY_STAT_OPTIMAL;
156
// Set the object's status flags
157
toEng_P->extract(statFlags);
158
// Only allow READY, LAP, and PAP flags to be set
159
status.flags = statFlags & (FLG_STAT_READY | FLG_STAT_LAP | FLG_STAT_PAP);
160
// Set the object's main status
161
toEng_P->extract(status.main);
162
// Set the object's sub status
163
toEng_P->extract(status.sub);
166
// Set the object's SCSI address
167
toEng_P->extract(&addr,sizeof(dptAddr_S));
169
// Skip the object's origin level
170
toEng_P->skip(sizeof(uSHORT));
171
#if defined (_DPT_STRICT_ALIGN)
174
// Skip the manager that this object is attached to
175
toEng_P->skip(sizeof(DPT_TAG_T));
176
// Set the ASCII description information
177
toEng_P->extract(&descr,sizeof(dptDescr_S));
180
// Set the user buffer data
181
if (toEng_P->extract(userBuff,USER_BUFF_SIZE))
182
retVal = MSG_RTN_COMPLETED;
187
//dptSCSIobj_C::setInfo() - end
190
//Function - dptSCSIobj_C::setInfoHandler() - start
191
//===========================================================================
195
// This function sets information for artificial objects.
201
//Global Variables Affected:
203
//Remarks: (Side effects, Assumptions, Warnings...)
206
//---------------------------------------------------------------------------
208
DPT_RTN_T dptSCSIobj_C::setInfoHandler(dptBuffer_S *toEng_P)
211
DPT_RTN_T retVal = MSG_RTN_IGNORED;
213
// Insure the object was created artificially
215
// Set object information
216
retVal = setInfo(toEng_P,1);
221
//dptSCSIobj_C::setInfoHandler() - end
224
//Function - dptSCSIobj_C::rtnInfo() - start
225
//===========================================================================
229
// This function returns SCSI object information to the specified
236
//Global Variables Affected:
238
//Remarks: (Side effects, Assumptions, Warnings...)
241
//---------------------------------------------------------------------------
243
DPT_RTN_T dptSCSIobj_C::rtnInfo(dptBuffer_S *fromEng_P)
246
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
248
#if defined (_DPT_STRICT_ALIGN)
249
uSHORT shortFill = 0;
252
// Return this object's tag
253
fromEng_P->insert(tag());
254
// Return the engine object type
255
fromEng_P->insert(engType);
256
// Return the object flags
258
getObjFlags(myFlags);
259
fromEng_P->insert(myFlags);
260
// Return the object status
261
fromEng_P->insert(&status,sizeof(dptStatus_S));
262
// Update this object's HBA #
264
// Return the object's SCSI address
265
fromEng_P->insert(&addr,sizeof(dptAddr_S));
266
// Return the object's origin level
267
fromEng_P->insert(getLevel());
268
#if defined (_DPT_STRICT_ALIGN)
269
fromEng_P->insert(shortFill);
271
// Return the manager that this object is attached to
273
fromEng_P->insert((DPT_TAG_T)0);
274
else if (myMgr_P()->myMgr_P()==NULL) {
275
// If a dual level array on an I2O board...
276
if (isDevice() && myHBA_P()->isI2O())
277
fromEng_P->insert(myHBA_P()->tag());
279
fromEng_P->insert((DPT_TAG_T)0);
282
fromEng_P->insert(myMgr_P()->tag());
283
// Return the ASCII description information
284
fromEng_P->insert(&descr,sizeof(dptDescr_S));
285
// Return the user buffer data
286
if (fromEng_P->insert(userBuff,USER_BUFF_SIZE))
287
retVal = MSG_RTN_COMPLETED;
292
//dptSCSIobj_C::rtnInfo() - end
295
//Function - dptSCSIobj_C::returnID() - start
296
//===========================================================================
300
// This function returns this object's ID information in the specified
307
//Global Variables Affected:
309
//Remarks: (Side effects, Assumptions, Warnings...)
312
//---------------------------------------------------------------------------
314
DPT_RTN_T dptSCSIobj_C::returnID(dptBuffer_S *fromEng_P)
317
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
319
// Return this object's tag
320
fromEng_P->insert(tag());
321
// Return the engine object type
322
if (fromEng_P->insert(engType))
323
retVal = MSG_RTN_COMPLETED;
328
//dptSCSIobj_C::returnID() - end
331
//Function - dptSCSIobj_C::handleMessage() - start
332
//===========================================================================
336
// This routine handles DPT events for this class.
342
//Global Variables Affected:
344
//Remarks: (Side effects, Assumptions, Warnings...)
347
//---------------------------------------------------------------------------
349
DPT_RTN_T dptSCSIobj_C::handleMessage(DPT_MSG_T message,
350
dptBuffer_S *fromEng_P,
355
DPT_RTN_T retVal = MSG_RTN_IGNORED;
359
// Set absent object information
360
case MSG_ABS_SET_INFO:
361
retVal = setInfoHandler(toEng_P);
364
// Return object information
366
retVal = rtnInfo(fromEng_P);
369
// Set the user buffer with the specified input data
370
case MSG_SET_USER_BUFF:
371
if (toEng_P->extract(userBuff,USER_BUFF_SIZE))
372
retVal = MSG_RTN_COMPLETED;
374
retVal = MSG_RTN_DATA_UNDERFLOW;
377
// Return the user buffer to the specified output buffer
378
case MSG_GET_USER_BUFF:
379
if (fromEng_P->insert(userBuff,USER_BUFF_SIZE))
380
retVal = MSG_RTN_COMPLETED;
382
retVal = MSG_RTN_DATA_OVERFLOW;
386
// Call base class event handler
387
retVal = dptCoreObj_C::handleMessage(message,fromEng_P,toEng_P);
396
//dptSCSIobj_C::handleMessage() - end
399
//Function - dptSCSIobj_C::rtnConfigInfo() - start
400
//===========================================================================
404
// This function returns this object's configuration information.
405
//This information is stored in the system configuration file.
411
//Global Variables Affected:
413
//Remarks: (Side effects, Assumptions, Warnings...)
416
//---------------------------------------------------------------------------
418
DPT_RTN_T dptSCSIobj_C::rtnConfigInfo(dptBuffer_S *fromEng_P)
421
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
427
DEBUG_BEGIN(6, dptSCSIobj_C::rtnConfigInfo());
429
// Get the # of bytes remaining in the buffer
430
bytesLeft = fromEng_P->allocSize - fromEng_P->writeIndex;
431
// If there is enough space to return this object's information...
432
if (bytesLeft >= (infoSize()+sizeof(uLONG))) {
433
// Return the size of the object info
434
fromEng_P->insert(infoSize());
436
DEBUG(6, "infoSize=" << (int)infoSize() << " data addr=0x" << hex << \
437
fromEng_P->data << " writeIndex=" << dec << fromEng_P->writeIndex << \
438
" left=" << (int)bytesLeft);
440
// Get a pointer to this object's config. info
441
basic_P = (dptBasic_S *) (fromEng_P->data+fromEng_P->writeIndex);
442
if (basic_P->attachedTo!=0) {
443
// Return this object's manager SCSI ID instead of tag
444
basic_P->attachedTo = myMgr_P()->getAddrL();
445
// Reverse the SCSI address bytes
446
reverseBytes(basic_P->attachedTo);
448
DEBUG(6, PRT_SADDR(basic_P) << "new attachedTo=0x" << hex << \
449
basic_P->attachedTo << " is set");
453
oldidx = fromEng_P->writeIndex;
455
// Return this object's information
456
retVal = rtnInfo(fromEng_P);
458
DEBUG(6, PRT_SADDR(basic_P) << "rtnInfo() returned " << \
459
(int)fromEng_P->writeIndex-oldidx << "Byte Tag=" \
460
<< (int)basic_P->myTag << " attachedTo=0x" << hex \
461
<< basic_P->attachedTo);
467
//dptSCSIobj_C::rtnConfigInfo() - end