1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
|
/* Copyright (c) 1996-2004, Adaptec Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the Adaptec Corporation nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
//File - SCSI_OBJ.CPP
//***************************************************************************
//
//Description:
//
// This file contains the function definitions for the dptSCSIobj_C
//class.
//
//Author: Doug Anderson
//Date: 3/9/93
//
//Editors:
//
//Remarks:
//
//
//***************************************************************************
//Include Files -------------------------------------------------------------
#include "allfiles.hpp" // All engine include files
//Function - dptSCSIobj_C::dptSCSIobj_C() - start
//===========================================================================
//
//Description:
//
// This function is the constructor for the dptSCSIobj_C class.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
dptSCSIobj_C::dptSCSIobj_C()
{
// Initialize the pointer to this object's HBA
hba_P = NULL;
// Clear the engine object type
engType = DPT_SCSI_DASD;
memcpy(descr.vendorID,"UNKNOWN",8);
memcpy(descr.productID,"--UNKNOWN--",12);
memcpy(descr.revision,"NONE",5);
memset(userBuff,0,USER_BUFF_SIZE);
magicNum = 0;
}
//dptSCSIobj_C::dptSCSIobj_C() - end
//Function - dptSCSIobj_C::updateHBAnum() - start
//===========================================================================
//
//Description:
//
// This function updates this objets HBA number.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
void dptSCSIobj_C::updateHBAnum()
{
if (hba_P!=NULL)
// Set this object's HBA number
addr.hba = hba_P->getHBA();
}
//dptSCSIobj_C::updateHBAnum() - end
//Function - dptSCSIobj_C::setInfo() - start
//===========================================================================
//
//Description:
//
// This function sets SCSI object information from data in the
//specified input buffer.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
DPT_RTN_T dptSCSIobj_C::setInfo(dptBuffer_S *toEng_P,uSHORT setAll)
{
DPT_RTN_T retVal = MSG_RTN_DATA_UNDERFLOW;
uSHORT suggestedFlags;
uCHAR statFlags;
// Skip this object's tag
toEng_P->skip(sizeof(DPT_TAG_T));
// Skip the object type (already set)
toEng_P->skip(sizeof(uSHORT));
// Set the object's flags
if (toEng_P->extract(suggestedFlags))
setObjFlags(suggestedFlags,setAll);
// Set the object's display status
toEng_P->extract(status.display);
if (status.display>3)
status.display = DSPLY_STAT_OPTIMAL;
// Set the object's status flags
toEng_P->extract(statFlags);
// Only allow READY, LAP, and PAP flags to be set
status.flags = statFlags & (FLG_STAT_READY | FLG_STAT_LAP | FLG_STAT_PAP);
// Set the object's main status
toEng_P->extract(status.main);
// Set the object's sub status
toEng_P->extract(status.sub);
if (setAll)
// Set the object's SCSI address
toEng_P->extract(&addr,sizeof(dptAddr_S));
// Skip the object's origin level
toEng_P->skip(sizeof(uSHORT));
#if defined (_DPT_STRICT_ALIGN)
toEng_P->skip(2);
#endif
// Skip the manager that this object is attached to
toEng_P->skip(sizeof(DPT_TAG_T));
// Set the ASCII description information
toEng_P->extract(&descr,sizeof(dptDescr_S));
descr.terminate();
descr.toUpper();
// Set the user buffer data
if (toEng_P->extract(userBuff,USER_BUFF_SIZE))
retVal = MSG_RTN_COMPLETED;
return (retVal);
}
//dptSCSIobj_C::setInfo() - end
//Function - dptSCSIobj_C::setInfoHandler() - start
//===========================================================================
//
//Description:
//
// This function sets information for artificial objects.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
DPT_RTN_T dptSCSIobj_C::setInfoHandler(dptBuffer_S *toEng_P)
{
DPT_RTN_T retVal = MSG_RTN_IGNORED;
// Insure the object was created artificially
if (isArtificial())
// Set object information
retVal = setInfo(toEng_P,1);
return (retVal);
}
//dptSCSIobj_C::setInfoHandler() - end
//Function - dptSCSIobj_C::rtnInfo() - start
//===========================================================================
//
//Description:
//
// This function returns SCSI object information to the specified
//output buffer.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
DPT_RTN_T dptSCSIobj_C::rtnInfo(dptBuffer_S *fromEng_P)
{
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
uSHORT myFlags;
#if defined (_DPT_STRICT_ALIGN)
uSHORT shortFill = 0;
#endif
// Return this object's tag
fromEng_P->insert(tag());
// Return the engine object type
fromEng_P->insert(engType);
// Return the object flags
myFlags = 0;
getObjFlags(myFlags);
fromEng_P->insert(myFlags);
// Return the object status
fromEng_P->insert(&status,sizeof(dptStatus_S));
// Update this object's HBA #
updateHBAnum();
// Return the object's SCSI address
fromEng_P->insert(&addr,sizeof(dptAddr_S));
// Return the object's origin level
fromEng_P->insert(getLevel());
#if defined (_DPT_STRICT_ALIGN)
fromEng_P->insert(shortFill);
#endif
// Return the manager that this object is attached to
if (myMgr_P()==NULL)
fromEng_P->insert((DPT_TAG_T)0);
else if (myMgr_P()->myMgr_P()==NULL) {
// If a dual level array on an I2O board...
if (isDevice() && myHBA_P()->isI2O())
fromEng_P->insert(myHBA_P()->tag());
else
fromEng_P->insert((DPT_TAG_T)0);
}
else
fromEng_P->insert(myMgr_P()->tag());
// Return the ASCII description information
fromEng_P->insert(&descr,sizeof(dptDescr_S));
// Return the user buffer data
if (fromEng_P->insert(userBuff,USER_BUFF_SIZE))
retVal = MSG_RTN_COMPLETED;
return (retVal);
}
//dptSCSIobj_C::rtnInfo() - end
//Function - dptSCSIobj_C::returnID() - start
//===========================================================================
//
//Description:
//
// This function returns this object's ID information in the specified
//output buffer.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
DPT_RTN_T dptSCSIobj_C::returnID(dptBuffer_S *fromEng_P)
{
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
// Return this object's tag
fromEng_P->insert(tag());
// Return the engine object type
if (fromEng_P->insert(engType))
retVal = MSG_RTN_COMPLETED;
return (retVal);
}
//dptSCSIobj_C::returnID() - end
//Function - dptSCSIobj_C::handleMessage() - start
//===========================================================================
//
//Description:
//
// This routine handles DPT events for this class.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
DPT_RTN_T dptSCSIobj_C::handleMessage(DPT_MSG_T message,
dptBuffer_S *fromEng_P,
dptBuffer_S *toEng_P
)
{
DPT_RTN_T retVal = MSG_RTN_IGNORED;
switch (message) {
// Set absent object information
case MSG_ABS_SET_INFO:
retVal = setInfoHandler(toEng_P);
break;
// Return object information
case MSG_GET_INFO:
retVal = rtnInfo(fromEng_P);
break;
// Set the user buffer with the specified input data
case MSG_SET_USER_BUFF:
if (toEng_P->extract(userBuff,USER_BUFF_SIZE))
retVal = MSG_RTN_COMPLETED;
else
retVal = MSG_RTN_DATA_UNDERFLOW;
break;
// Return the user buffer to the specified output buffer
case MSG_GET_USER_BUFF:
if (fromEng_P->insert(userBuff,USER_BUFF_SIZE))
retVal = MSG_RTN_COMPLETED;
else
retVal = MSG_RTN_DATA_OVERFLOW;
break;
default:
// Call base class event handler
retVal = dptCoreObj_C::handleMessage(message,fromEng_P,toEng_P);
break;
} // end switch
return (retVal);
}
//dptSCSIobj_C::handleMessage() - end
//Function - dptSCSIobj_C::rtnConfigInfo() - start
//===========================================================================
//
//Description:
//
// This function returns this object's configuration information.
//This information is stored in the system configuration file.
//
//Parameters:
//
//Return Value:
//
//Global Variables Affected:
//
//Remarks: (Side effects, Assumptions, Warnings...)
//
//
//---------------------------------------------------------------------------
DPT_RTN_T dptSCSIobj_C::rtnConfigInfo(dptBuffer_S *fromEng_P)
{
DPT_RTN_T retVal = MSG_RTN_DATA_OVERFLOW;
uLONG bytesLeft;
dptBasic_S *basic_P;
int oldidx;
DEBUG_BEGIN(6, dptSCSIobj_C::rtnConfigInfo());
// Get the # of bytes remaining in the buffer
bytesLeft = fromEng_P->allocSize - fromEng_P->writeIndex;
// If there is enough space to return this object's information...
if (bytesLeft >= (infoSize()+sizeof(uLONG))) {
// Return the size of the object info
fromEng_P->insert(infoSize());
DEBUG(6, "infoSize=" << (int)infoSize() << " data addr=0x" << hex << \
fromEng_P->data << " writeIndex=" << dec << fromEng_P->writeIndex << \
" left=" << (int)bytesLeft);
// Get a pointer to this object's config. info
basic_P = (dptBasic_S *) (fromEng_P->data+fromEng_P->writeIndex);
if (basic_P->attachedTo!=0) {
// Return this object's manager SCSI ID instead of tag
basic_P->attachedTo = myMgr_P()->getAddrL();
// Reverse the SCSI address bytes
reverseBytes((uLONG &)basic_P->attachedTo);
DEBUG(6, PRT_SADDR(basic_P) << "new attachedTo=0x" << hex << \
basic_P->attachedTo << " is set");
}
oldidx = fromEng_P->writeIndex;
// Return this object's information
retVal = rtnInfo(fromEng_P);
DEBUG(6, PRT_SADDR(basic_P) << "rtnInfo() returned " << \
(int)fromEng_P->writeIndex-oldidx << "Byte Tag=" \
<< (int)basic_P->myTag << " attachedTo=0x" << hex \
<< basic_P->attachedTo);
}
return (retVal);
}
//dptSCSIobj_C::rtnConfigInfo() - end
|