|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * ! 24: * queueHelpers.cpp ! 25: * ! 26: */ ! 27: #include <IOKit/scsi/IOSCSIParallelInterface.h> ! 28: ! 29: void IOSCSIParallelDevice::addCommand( queue_head_t *list, IOSCSIParallelCommand *scsiCmd ) ! 30: { ! 31: scsiCmd->list = list; ! 32: ! 33: queue_enter( list, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 34: } ! 35: ! 36: void IOSCSIParallelDevice::deleteCommand( queue_head_t *list, IOSCSIParallelCommand *scsiCmd, IOReturn rc = kIOReturnSuccess ) ! 37: { ! 38: scsiCmd->list = 0; ! 39: ! 40: if ( rc != kIOReturnSuccess ) ! 41: { ! 42: if ( scsiCmd->results.returnCode == kIOReturnSuccess ) ! 43: { ! 44: scsiCmd->results.returnCode = (IOReturn) rc; ! 45: } ! 46: } ! 47: ! 48: queue_remove( list, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 49: } ! 50: ! 51: IOSCSIParallelCommand *IOSCSIParallelDevice::checkCommand( queue_head_t *list ) ! 52: { ! 53: if ( queue_empty( list ) == true ) ! 54: { ! 55: return 0; ! 56: } ! 57: ! 58: return (IOSCSIParallelCommand *)queue_first( list ); ! 59: } ! 60: ! 61: ! 62: IOSCSIParallelCommand *IOSCSIParallelDevice::getCommand( queue_head_t *list ) ! 63: { ! 64: IOSCSIParallelCommand *scsiCmd = 0; ! 65: ! 66: if ( queue_empty( list ) == false ) ! 67: { ! 68: queue_remove_first( list, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 69: scsiCmd->list = 0; ! 70: } ! 71: ! 72: return scsiCmd; ! 73: } ! 74: ! 75: void IOSCSIParallelDevice::stackCommand( queue_head_t *list, IOSCSIParallelCommand *scsiCmd ) ! 76: { ! 77: scsiCmd->list = list; ! 78: ! 79: queue_enter_first( list, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 80: } ! 81: ! 82: void IOSCSIParallelDevice::moveCommand( queue_head_t *fromList, queue_head_t *toList, IOSCSIParallelCommand *scsiCmd, IOReturn rc = kIOReturnSuccess ) ! 83: { ! 84: if ( rc != kIOReturnSuccess ) ! 85: { ! 86: if ( scsiCmd->results.returnCode == kIOReturnSuccess ) ! 87: { ! 88: scsiCmd->results.returnCode = (IOReturn) rc; ! 89: } ! 90: } ! 91: ! 92: scsiCmd->list = toList; ! 93: ! 94: queue_remove( fromList, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 95: queue_enter( toList, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 96: } ! 97: ! 98: void IOSCSIParallelDevice::moveAllCommands( queue_head_t *fromList, queue_head_t *toList, IOReturn rc = kIOReturnSuccess ) ! 99: { ! 100: IOSCSIParallelCommand *scsiCmd; ! 101: ! 102: if ( queue_empty( fromList ) == true ) return; ! 103: ! 104: do ! 105: { ! 106: scsiCmd = (IOSCSIParallelCommand *)queue_first( fromList ); ! 107: ! 108: if ( rc != kIOReturnSuccess ) ! 109: { ! 110: if ( scsiCmd->results.returnCode == kIOReturnSuccess ) ! 111: { ! 112: scsiCmd->results.returnCode = (IOReturn) rc; ! 113: } ! 114: } ! 115: ! 116: scsiCmd->list = toList; ! 117: ! 118: queue_remove( fromList, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 119: queue_enter( toList, scsiCmd, IOSCSIParallelCommand *, nextCommand ); ! 120: ! 121: } while( queue_empty( fromList ) == false ); ! 122: } ! 123: ! 124: bool IOSCSIParallelDevice::findCommand( queue_head_t *list, IOSCSIParallelCommand *findSCSICmd ) ! 125: { ! 126: IOSCSIParallelCommand *scsiCmd; ! 127: ! 128: queue_iterate( list, scsiCmd, IOSCSIParallelCommand *, nextCommand ) ! 129: { ! 130: if ( scsiCmd == findSCSICmd ) ! 131: { ! 132: return true; ! 133: } ! 134: } ! 135: return false; ! 136: } ! 137: ! 138: void IOSCSIParallelDevice::purgeAllCommands( queue_head_t *list, IOReturn rc ) ! 139: { ! 140: IOSCSIParallelCommand *scsiCmd; ! 141: ! 142: if ( queue_empty( list ) == true ) return; ! 143: ! 144: do ! 145: { ! 146: scsiCmd = (IOSCSIParallelCommand *)queue_first( list ); ! 147: ! 148: deleteCommand( list, scsiCmd, rc ); ! 149: finishCommand( scsiCmd ); ! 150: ! 151: } while( queue_empty( list ) == false ); ! 152: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.