]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOSCSIParallel/queueHelpers.cpp
569418feb540887f178da0f8d9256280083155ab
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
27 #include <IOKit/scsi/IOSCSIParallelInterface.h>
29 void IOSCSIParallelDevice::addCommand( queue_head_t
*list
, IOSCSIParallelCommand
*scsiCmd
)
33 queue_enter( list
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
36 void IOSCSIParallelDevice::deleteCommand( queue_head_t
*list
, IOSCSIParallelCommand
*scsiCmd
, IOReturn rc
= kIOReturnSuccess
)
40 if ( rc
!= kIOReturnSuccess
)
42 if ( scsiCmd
->results
.returnCode
== kIOReturnSuccess
)
44 scsiCmd
->results
.returnCode
= (IOReturn
) rc
;
48 queue_remove( list
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
51 IOSCSIParallelCommand
*IOSCSIParallelDevice::checkCommand( queue_head_t
*list
)
53 if ( queue_empty( list
) == true )
58 return (IOSCSIParallelCommand
*)queue_first( list
);
62 IOSCSIParallelCommand
*IOSCSIParallelDevice::getCommand( queue_head_t
*list
)
64 IOSCSIParallelCommand
*scsiCmd
= 0;
66 if ( queue_empty( list
) == false )
68 queue_remove_first( list
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
75 void IOSCSIParallelDevice::stackCommand( queue_head_t
*list
, IOSCSIParallelCommand
*scsiCmd
)
79 queue_enter_first( list
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
82 void IOSCSIParallelDevice::moveCommand( queue_head_t
*fromList
, queue_head_t
*toList
, IOSCSIParallelCommand
*scsiCmd
, IOReturn rc
= kIOReturnSuccess
)
84 if ( rc
!= kIOReturnSuccess
)
86 if ( scsiCmd
->results
.returnCode
== kIOReturnSuccess
)
88 scsiCmd
->results
.returnCode
= (IOReturn
) rc
;
92 scsiCmd
->list
= toList
;
94 queue_remove( fromList
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
95 queue_enter( toList
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
98 void IOSCSIParallelDevice::moveAllCommands( queue_head_t
*fromList
, queue_head_t
*toList
, IOReturn rc
= kIOReturnSuccess
)
100 IOSCSIParallelCommand
*scsiCmd
;
102 if ( queue_empty( fromList
) == true ) return;
106 scsiCmd
= (IOSCSIParallelCommand
*)queue_first( fromList
);
108 if ( rc
!= kIOReturnSuccess
)
110 if ( scsiCmd
->results
.returnCode
== kIOReturnSuccess
)
112 scsiCmd
->results
.returnCode
= (IOReturn
) rc
;
116 scsiCmd
->list
= toList
;
118 queue_remove( fromList
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
119 queue_enter( toList
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
);
121 } while( queue_empty( fromList
) == false );
124 bool IOSCSIParallelDevice::findCommand( queue_head_t
*list
, IOSCSIParallelCommand
*findSCSICmd
)
126 IOSCSIParallelCommand
*scsiCmd
;
128 queue_iterate( list
, scsiCmd
, IOSCSIParallelCommand
*, nextCommand
)
130 if ( scsiCmd
== findSCSICmd
)
138 void IOSCSIParallelDevice::purgeAllCommands( queue_head_t
*list
, IOReturn rc
)
140 IOSCSIParallelCommand
*scsiCmd
;
142 if ( queue_empty( list
) == true ) return;
146 scsiCmd
= (IOSCSIParallelCommand
*)queue_first( list
);
148 deleteCommand( list
, scsiCmd
, rc
);
149 finishCommand( scsiCmd
);
151 } while( queue_empty( list
) == false );