|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* ! 26: File: uslPipeState.c ! 27: ! 28: Contains: xxx put contents here xxx ! 29: ! 30: Version: xxx put version here xxx ! 31: ! 32: Copyright: � 1998 by Apple Computer, Inc., all rights reserved. ! 33: ! 34: File Ownership: ! 35: ! 36: DRI: xxx put dri here xxx ! 37: ! 38: Other Contact: xxx put other contact here xxx ! 39: ! 40: Technology: xxx put technology here xxx ! 41: ! 42: Writers: ! 43: ! 44: (BT) Barry Twycross ! 45: ! 46: Change History (most recent first): ! 47: ! 48: <USB3> 8/13/98 BT Add multibus support ! 49: <USB2> 7/28/98 BT Fix spurious errors ! 50: <USB1> 4/26/98 BT first checked in ! 51: */ ! 52: ! 53: #include "../USB.h" ! 54: #include "../USBpriv.h" ! 55: ! 56: #include "uslpriv.h" ! 57: #include "../uimpriv.h" ! 58: ! 59: ! 60: void uslSetPipeStall(USBPipeRef ref) ! 61: { ! 62: pipe *thisPipe; ! 63: OSStatus err = noErr; ! 64: err = findPipe(ref, &thisPipe); ! 65: if(thisPipe != nil) ! 66: { ! 67: if(thisPipe->state == kUSBActive) ! 68: { ! 69: thisPipe->state = kUSBStalled; ! 70: } ! 71: else if(thisPipe->state == kUSBIdle) ! 72: { ! 73: thisPipe->state = kUSBIdleStalled; ! 74: } ! 75: } ! 76: ! 77: } ! 78: ! 79: OSStatus USBAbortPipeByReference(USBReference refIn) ! 80: { ! 81: pipe *thisPipe; ! 82: USBReference ref; ! 83: OSStatus err = noErr; ! 84: ! 85: do{ ! 86: /* Is this a device ref ? */ ! 87: ref = getPipeZero(refIn); ! 88: if(ref == 0) ! 89: { ! 90: /* No, is it a pipe ref? */ ! 91: ref = refIn; ! 92: } ! 93: /* Find the pipe struct */ ! 94: err = findPipe(ref, &thisPipe); ! 95: if(thisPipe == nil) ! 96: { ! 97: break; ! 98: } ! 99: ! 100: err = UIMAbortEndpoint(thisPipe->bus, thisPipe->devAddress, thisPipe->endPt, thisPipe->direction); ! 101: }while(0); ! 102: ! 103: return(err); ! 104: } ! 105: ! 106: OSStatus USBClearPipeStallByReference(USBPipeRef ref) ! 107: { ! 108: pipe *thisPipe; ! 109: OSStatus err = noErr; ! 110: ! 111: do{ ! 112: /* Note this can't be a device ref, they're automatically cleared */ ! 113: /* Find the pipe struct */ ! 114: err = findPipe(ref, &thisPipe); ! 115: if(err != kUSBPipeStalledError) ! 116: { ! 117: break; ! 118: } ! 119: ! 120: err = UIMClearEndPointStall(thisPipe->bus, thisPipe->devAddress, thisPipe->endPt, thisPipe->direction); ! 121: if(err == noErr) ! 122: { ! 123: if(thisPipe->state == kUSBIdleStalled) ! 124: { ! 125: thisPipe->state = kUSBIdle; ! 126: } ! 127: else ! 128: { ! 129: thisPipe->state = kUSBActive; ! 130: } ! 131: } ! 132: }while(0); ! 133: ! 134: return(err); ! 135: } ! 136: ! 137: OSStatus USBSetPipeIdleByReference(USBPipeRef ref) ! 138: { ! 139: pipe *thisPipe; ! 140: OSStatus err = noErr; ! 141: ! 142: do{ ! 143: /* Note this can't be a device ref, they're automatically cleared */ ! 144: /* Find the pipe struct */ ! 145: err = findPipe(ref, &thisPipe); ! 146: if(thisPipe == nil) ! 147: { ! 148: break; ! 149: } ! 150: ! 151: err = noErr; ! 152: ! 153: if(thisPipe->state == kUSBStalled) ! 154: { ! 155: thisPipe->state = kUSBIdleStalled; ! 156: } ! 157: else ! 158: { ! 159: thisPipe->state = kUSBIdle; ! 160: } ! 161: }while(0); ! 162: ! 163: return(err); ! 164: } ! 165: ! 166: OSStatus USBSetPipeActiveByReference(USBPipeRef ref) ! 167: { ! 168: pipe *thisPipe; ! 169: OSStatus err = noErr; ! 170: ! 171: do{ ! 172: /* Note this can't be a device ref, they're automatically cleared */ ! 173: /* Find the pipe struct */ ! 174: err = findPipe(ref, &thisPipe); ! 175: if(thisPipe == nil) ! 176: { ! 177: break; ! 178: } ! 179: ! 180: if(thisPipe->state == kUSBIdleStalled) ! 181: { ! 182: thisPipe->state = kUSBStalled; ! 183: // do nothing, err is stalled err. ! 184: } ! 185: else if(thisPipe->state == kUSBStalled) ! 186: { ! 187: // do nothing, err is stalled err. ! 188: } ! 189: else if(thisPipe->state == kUSBIdle) ! 190: { ! 191: thisPipe->state = kUSBActive; ! 192: err = noErr; ! 193: } ! 194: ! 195: }while(0); ! 196: ! 197: return(err); ! 198: } ! 199: ! 200: ! 201: ! 202: OSStatus USBResetPipeByReference(USBReference refIn) ! 203: { ! 204: pipe *thisPipe; ! 205: USBReference ref; ! 206: OSStatus err = noErr; ! 207: ! 208: do{ ! 209: /* Is this a device ref ? */ ! 210: ref = getPipeZero(refIn); ! 211: if(ref == 0) ! 212: { ! 213: /* No, is it a pipe ref? */ ! 214: ref = refIn; ! 215: } ! 216: /* Find the pipe struct */ ! 217: err = findPipe(ref, &thisPipe); ! 218: if(thisPipe == nil) ! 219: { ! 220: break; ! 221: } ! 222: if(err == kUSBPipeStalledError) ! 223: { ! 224: err = USBClearPipeStallByReference(ref); ! 225: } ! 226: else ! 227: { ! 228: err = noErr; ! 229: } ! 230: if(err == noErr) ! 231: { ! 232: thisPipe->state = kUSBActive; ! 233: } ! 234: ! 235: }while(0); ! 236: ! 237: return(err); ! 238: } ! 239: ! 240: OSStatus USBClosePipeByReference(USBPipeRef ref) ! 241: { ! 242: pipe *thisPipe; ! 243: OSStatus err = noErr; ! 244: ! 245: do{ ! 246: /* Note this can't be a device ref, they're automatically cleared */ ! 247: /* Find the pipe struct */ ! 248: err = findPipe(ref, &thisPipe); ! 249: if(thisPipe == nil) ! 250: { ! 251: break; ! 252: } ! 253: ! 254: err = uslClosePipe(recoverPipeIdx(ref)); ! 255: }while(0); ! 256: ! 257: return(err); ! 258: } ! 259: ! 260: ! 261: OSStatus USBGetPipeStatusByReference(USBReference refIn, USBPipeState *state) ! 262: { ! 263: pipe *thisPipe; ! 264: USBReference ref; ! 265: OSStatus err = noErr; ! 266: ! 267: do{ ! 268: /* Is this a device ref ? */ ! 269: ref = getPipeZero(refIn); ! 270: if(ref == 0) ! 271: { ! 272: /* No, is it a pipe ref? */ ! 273: ref = refIn; ! 274: } ! 275: /* Find the pipe struct */ ! 276: err = findPipe(ref, &thisPipe); ! 277: if(thisPipe == nil) ! 278: { ! 279: break; ! 280: } ! 281: ! 282: if(thisPipe->state == kUSBIdleStalled) ! 283: { ! 284: *state = kUSBStalled; ! 285: } ! 286: else ! 287: { ! 288: *state = thisPipe->state; ! 289: } ! 290: ! 291: }while(0); ! 292: ! 293: return(err); ! 294: } ! 295: ! 296: ! 297:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.