]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOATAStandard/ATAQueueHelpers.cpp
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/ata/IOATAStandardInterface.h>
29 void IOATAStandardDevice::addCommand( queue_head_t
*list
, IOATAStandardCommand
*ataCmd
)
33 queue_enter( list
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
36 void IOATAStandardDevice::deleteCommand( queue_head_t
*list
, IOATAStandardCommand
*ataCmd
, IOReturn rc
= kIOReturnSuccess
)
40 if ( rc
!= kIOReturnSuccess
)
42 if ( ataCmd
->results
.returnCode
== kIOReturnSuccess
)
44 ataCmd
->results
.returnCode
= (IOReturn
) rc
;
48 queue_remove( list
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
51 IOATAStandardCommand
*IOATAStandardDevice::checkCommand( queue_head_t
*list
)
53 if ( queue_empty( list
) == true )
58 return (IOATAStandardCommand
*)queue_first( list
);
62 IOATAStandardCommand
*IOATAStandardDevice::getCommand( queue_head_t
*list
)
64 IOATAStandardCommand
*ataCmd
= 0;
66 if ( queue_empty( list
) == false )
68 queue_remove_first( list
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
75 void IOATAStandardDevice::stackCommand( queue_head_t
*list
, IOATAStandardCommand
*ataCmd
)
79 queue_enter_first( list
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
82 void IOATAStandardDevice::moveCommand( queue_head_t
*fromList
, queue_head_t
*toList
, IOATAStandardCommand
*ataCmd
, IOReturn rc
= kIOReturnSuccess
)
84 if ( rc
!= kIOReturnSuccess
)
86 if ( ataCmd
->results
.returnCode
== kIOReturnSuccess
)
88 ataCmd
->results
.returnCode
= (IOReturn
) rc
;
92 ataCmd
->list
= toList
;
94 queue_remove( fromList
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
95 queue_enter( toList
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
98 void IOATAStandardDevice::moveAllCommands( queue_head_t
*fromList
, queue_head_t
*toList
, IOReturn rc
= kIOReturnSuccess
)
100 IOATAStandardCommand
*ataCmd
;
102 if ( queue_empty( fromList
) == true ) return;
106 ataCmd
= (IOATAStandardCommand
*)queue_first( fromList
);
108 if ( rc
!= kIOReturnSuccess
)
110 if ( ataCmd
->results
.returnCode
== kIOReturnSuccess
)
112 ataCmd
->results
.returnCode
= (IOReturn
) rc
;
116 ataCmd
->list
= toList
;
118 queue_remove( fromList
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
119 queue_enter( toList
, ataCmd
, IOATAStandardCommand
*, nextCommand
);
121 } while( queue_empty( fromList
) == false );
124 bool IOATAStandardDevice::findCommand( queue_head_t
*list
, IOATAStandardCommand
*findATACmd
)
126 IOATAStandardCommand
*ataCmd
;
128 queue_iterate( list
, ataCmd
, IOATAStandardCommand
*, nextCommand
)
130 if ( ataCmd
== findATACmd
)
138 void IOATAStandardDevice::purgeAllCommands( queue_head_t
*list
, IOReturn rc
)
140 IOATAStandardCommand
*ataCmd
;
142 if ( queue_empty( list
) == true ) return;
146 ataCmd
= (IOATAStandardCommand
*)queue_first( list
);
148 deleteCommand( list
, ataCmd
, rc
);
149 finishCommand( ataCmd
);
151 } while( queue_empty( list
) == false );