Annotation of kernel/bsd/dev/ppc/drvUSBCMD/Library/uslpipestate.c, revision 1.1

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: void uslSetPipeStall(USBPipeRef ref)
        !            60: {
        !            61: pipe *thisPipe;
        !            62: OSStatus err = noErr;
        !            63:        err = findPipe(ref, &thisPipe);
        !            64:        if(thisPipe != nil)
        !            65:        {
        !            66:                if(thisPipe->state == kUSBActive)
        !            67:                {
        !            68:                        thisPipe->state = kUSBStalled;
        !            69:                }
        !            70:                else if(thisPipe->state == kUSBIdle)
        !            71:                {
        !            72:                        thisPipe->state = kUSBIdleStalled;
        !            73:                }
        !            74:        }
        !            75: 
        !            76: }
        !            77: 
        !            78: OSStatus USBAbortPipeByReference(USBReference refIn)
        !            79: {
        !            80: pipe *thisPipe;
        !            81: USBReference ref;
        !            82: OSStatus err = noErr;
        !            83: 
        !            84:        do{
        !            85:                        /* Is this a device ref ? */
        !            86:                ref = getPipeZero(refIn);
        !            87:                if(ref == 0)
        !            88:                {
        !            89:                                /* No, is it a pipe ref? */
        !            90:                        ref = refIn;
        !            91:                }
        !            92:                        /* Find the pipe struct */
        !            93:                err = findPipe(ref, &thisPipe);
        !            94:                if(thisPipe == nil)
        !            95:                {
        !            96:                        break;
        !            97:                }
        !            98:                
        !            99:                err = UIMAbortEndpoint(thisPipe->bus, thisPipe->devAddress, thisPipe->endPt, thisPipe->direction);
        !           100:        }while(0);
        !           101: 
        !           102:        return(err);
        !           103: }
        !           104: 
        !           105: OSStatus USBClearPipeStallByReference(USBPipeRef ref)
        !           106: {
        !           107: pipe *thisPipe;
        !           108: OSStatus err = noErr;
        !           109: 
        !           110:        do{
        !           111:                        /* Note this can't be a device ref, they're automatically cleared */
        !           112:                        /* Find the pipe struct */
        !           113:                err = findPipe(ref, &thisPipe);
        !           114:                if(err != kUSBPipeStalledError)
        !           115:                {
        !           116:                        break;
        !           117:                }
        !           118:                                
        !           119:                err = UIMClearEndPointStall(thisPipe->bus, thisPipe->devAddress, thisPipe->endPt, thisPipe->direction);
        !           120:                if(err == noErr)
        !           121:                {
        !           122:                        if(thisPipe->state == kUSBIdleStalled)
        !           123:                        {
        !           124:                                thisPipe->state = kUSBIdle;
        !           125:                        }
        !           126:                        else
        !           127:                        {
        !           128:                                thisPipe->state = kUSBActive;
        !           129:                        }
        !           130:                }       
        !           131:        }while(0);
        !           132: 
        !           133:        return(err);
        !           134: }
        !           135: 
        !           136: OSStatus USBSetPipeIdleByReference(USBPipeRef ref)
        !           137: {
        !           138: pipe *thisPipe;
        !           139: OSStatus err = noErr;
        !           140: 
        !           141:        do{
        !           142:                        /* Note this can't be a device ref, they're automatically cleared */
        !           143:                        /* Find the pipe struct */
        !           144:                err = findPipe(ref, &thisPipe);
        !           145:                if(thisPipe == nil)
        !           146:                {
        !           147:                        break;
        !           148:                }
        !           149:                
        !           150:                err = noErr;
        !           151:                
        !           152:                if(thisPipe->state == kUSBStalled)
        !           153:                {
        !           154:                        thisPipe->state = kUSBIdleStalled;
        !           155:                }
        !           156:                else
        !           157:                {
        !           158:                        thisPipe->state = kUSBIdle;
        !           159:                }
        !           160:        }while(0);
        !           161: 
        !           162:        return(err);
        !           163: }
        !           164: 
        !           165: OSStatus USBSetPipeActiveByReference(USBPipeRef ref)
        !           166: {
        !           167: pipe *thisPipe;
        !           168: OSStatus err = noErr;
        !           169: 
        !           170:        do{
        !           171:                        /* Note this can't be a device ref, they're automatically cleared */
        !           172:                        /* Find the pipe struct */
        !           173:                err = findPipe(ref, &thisPipe);
        !           174:                if(thisPipe == nil)
        !           175:                {
        !           176:                        break;
        !           177:                }
        !           178: 
        !           179:                if(thisPipe->state == kUSBIdleStalled)
        !           180:                {
        !           181:                        thisPipe->state = kUSBStalled;
        !           182:                        // do nothing, err is stalled err.
        !           183:                }
        !           184:                else if(thisPipe->state == kUSBStalled)
        !           185:                {
        !           186:                        // do nothing, err is stalled err.
        !           187:                }
        !           188:                else if(thisPipe->state == kUSBIdle)
        !           189:                {
        !           190:                        thisPipe->state = kUSBActive;
        !           191:                        err = noErr;
        !           192:                }
        !           193: 
        !           194:        }while(0);
        !           195: 
        !           196:        return(err);
        !           197: }
        !           198: 
        !           199: 
        !           200: 
        !           201: OSStatus USBResetPipeByReference(USBReference refIn)
        !           202: {
        !           203: pipe *thisPipe;
        !           204: USBReference ref;
        !           205: OSStatus err = noErr;
        !           206: 
        !           207:        do{
        !           208:                        /* Is this a device ref ? */
        !           209:                ref = getPipeZero(refIn);
        !           210:                if(ref == 0)
        !           211:                {
        !           212:                                /* No, is it a pipe ref? */
        !           213:                        ref = refIn;
        !           214:                }
        !           215:                        /* Find the pipe struct */
        !           216:                err = findPipe(ref, &thisPipe);
        !           217:                if(thisPipe == nil)
        !           218:                {
        !           219:                        break;
        !           220:                }
        !           221:                if(err == kUSBPipeStalledError)
        !           222:                {
        !           223:                        err = USBClearPipeStallByReference(ref);
        !           224:                }
        !           225:                else
        !           226:                {
        !           227:                        err = noErr;
        !           228:                }
        !           229:                if(err == noErr)
        !           230:                {
        !           231:                        thisPipe->state = kUSBActive;
        !           232:                }
        !           233: 
        !           234:        }while(0);
        !           235: 
        !           236:        return(err);
        !           237: }
        !           238: 
        !           239: OSStatus USBClosePipeByReference(USBPipeRef ref)
        !           240: {
        !           241: pipe *thisPipe;
        !           242: OSStatus err = noErr;
        !           243: 
        !           244:        do{
        !           245:                        /* Note this can't be a device ref, they're automatically cleared */
        !           246:                        /* Find the pipe struct */
        !           247:                err = findPipe(ref, &thisPipe);
        !           248:                if(thisPipe == nil)
        !           249:                {
        !           250:                        break;
        !           251:                }
        !           252:                
        !           253:                err = uslClosePipe(recoverPipeIdx(ref));
        !           254:        }while(0);
        !           255: 
        !           256:        return(err);
        !           257: }
        !           258: 
        !           259: 
        !           260: OSStatus USBGetPipeStatusByReference(USBReference refIn, USBPipeState *state)
        !           261: {
        !           262: pipe *thisPipe;
        !           263: USBReference ref;
        !           264: OSStatus err = noErr;
        !           265: 
        !           266:        do{
        !           267:                        /* Is this a device ref ? */
        !           268:                ref = getPipeZero(refIn);
        !           269:                if(ref == 0)
        !           270:                {
        !           271:                                /* No, is it a pipe ref? */
        !           272:                        ref = refIn;
        !           273:                }
        !           274:                        /* Find the pipe struct */
        !           275:                err = findPipe(ref, &thisPipe);
        !           276:                if(thisPipe == nil)
        !           277:                {
        !           278:                        break;
        !           279:                }
        !           280:                
        !           281:                if(thisPipe->state == kUSBIdleStalled)
        !           282:                {
        !           283:                        *state = kUSBStalled;
        !           284:                }
        !           285:                else
        !           286:                {
        !           287:                        *state = thisPipe->state;
        !           288:                }
        !           289:                
        !           290:        }while(0);
        !           291: 
        !           292:        return(err);
        !           293: }
        !           294: 
        !           295: 
        !           296: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.