Annotation of XNU/iokit/Families/IOUSBBus/IOUSBController_Pipes.cpp, revision 1.1

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:  * Copyright (c) 1998 Apple Computer, Inc.  All rights reserved.
        !            24:  *
        !            25:  * HISTORY
        !            26:  * 08 Dec 98 ehewitt created.
        !            27:  *
        !            28:  */
        !            29: 
        !            30: #include <IOKit/system.h>
        !            31: 
        !            32: #define DEBUGGING_LEVEL 0      // 1 = low; 2 = high; 3 = extreme
        !            33: #define DEBUGLOG kprintf
        !            34: 
        !            35: #include <IOKit/usb/IOUSBController.h>
        !            36: #include <IOKit/IOMemoryDescriptor.h>
        !            37: 
        !            38: #define super IOUSBBus
        !            39: #define self this
        !            40: 
        !            41: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
        !            42: IOReturn IOUSBController::openPipe(USBDeviceAddress address, UInt8 speed,
        !            43:                                                Endpoint *endpoint)
        !            44: {
        !            45:     return _commandGate->runAction(doCreateEP, (void *)address,
        !            46:                        (void *)speed, endpoint);
        !            47: }
        !            48: 
        !            49: IOReturn IOUSBController::closePipe(USBDeviceAddress address,
        !            50:                                                Endpoint * endpoint)
        !            51: {
        !            52:     return _commandGate->runAction(doDeleteEP, (void *)address,
        !            53:                        (void *)endpoint->number, (void *)endpoint->direction);
        !            54: }
        !            55: 
        !            56: IOReturn IOUSBController::abortPipe(USBDeviceAddress address,
        !            57:                                     Endpoint * endpoint)
        !            58: {
        !            59:     return UIMAbortEndpoint(address,
        !            60:                 endpoint->number, endpoint->direction);
        !            61: }
        !            62: 
        !            63: IOReturn IOUSBController::resetPipe(USBDeviceAddress address,
        !            64:                                     Endpoint * endpoint)
        !            65: {
        !            66:     return UIMClearEndpointStall(address,
        !            67:                 endpoint->number, endpoint->direction);
        !            68: }
        !            69: 
        !            70: IOReturn IOUSBController::clearPipeStall(USBDeviceAddress address,
        !            71:                                          Endpoint * endpoint)
        !            72: {
        !            73:     return UIMClearEndpointStall(address,
        !            74:                 endpoint->number, endpoint->direction);
        !            75: }
        !            76: 
        !            77: 
        !            78: // Transferring Data
        !            79: IOReturn IOUSBController::read(IOMemoryDescriptor *    buffer,
        !            80:                                USBDeviceAddress        address,
        !            81:                                Endpoint *              endpoint,
        !            82:                                IOUSBCompletion *               completion)
        !            83: {
        !            84:     IOReturn    err = kIOReturnSuccess;
        !            85:     IOUSBCommand *command = (IOUSBCommand *)IOMalloc(sizeof(IOUSBCommand));
        !            86: 
        !            87:     do
        !            88:     {
        !            89:         /* Validate its a inny pipe */
        !            90:         if (endpoint->direction != kUSBIn)
        !            91:         {
        !            92:             err = kIOReturnBadArgument;
        !            93:             break;
        !            94:         }
        !            95: 
        !            96:         /* Validate the completion */
        !            97:         if (completion == 0)
        !            98:         {
        !            99:             err = kIOReturnNoCompletion;
        !           100:             break;
        !           101:         }
        !           102:         
        !           103:         command->selector      = READ;
        !           104:         command->request       = 0;            // Not a device request
        !           105:         command->address       = address;
        !           106:         command->endpoint      = endpoint->number;
        !           107:        command->direction      = kUSBIn;
        !           108:         command->type          = endpoint->transferType;
        !           109:         command->buffer                = buffer;
        !           110:         command->completion    = *completion;
        !           111: 
        !           112:         if (_commandGate == 0)
        !           113:         {
        !           114:             err = kIOReturnInternalError;
        !           115:             break;
        !           116:         }
        !           117: 
        !           118:         if ((err = _commandGate->runAction(doIOTransfer, command)))
        !           119:             break;
        !           120:             
        !           121:         return(err);
        !           122: 
        !           123:     } while (0);
        !           124: 
        !           125:     /* Free/give back the command */
        !           126:     IOFree(command, sizeof(IOUSBCommand));
        !           127: 
        !           128:     return (err);
        !           129: }
        !           130: 
        !           131: IOReturn IOUSBController::write(IOMemoryDescriptor *           buffer,
        !           132:                                 USBDeviceAddress       address,
        !           133:                                 Endpoint *             endpoint,
        !           134:                                 IOUSBCompletion *      completion)
        !           135: {
        !           136:     IOReturn    err = kIOReturnSuccess;
        !           137:     IOUSBCommand *command = (IOUSBCommand *)IOMalloc(sizeof(IOUSBCommand));
        !           138: 
        !           139:     do
        !           140:     {
        !           141:         /* Validate its a outty pipe */
        !           142:         if(endpoint->direction != kUSBOut)
        !           143:         {
        !           144:             err = kIOReturnBadArgument;
        !           145:             break;
        !           146:         }
        !           147: 
        !           148:         command->selector      = WRITE;
        !           149:         command->request       = 0;            // Not a device request
        !           150:         command->address       = address;
        !           151:         command->endpoint      = endpoint->number;
        !           152:         command->direction     = kUSBOut;
        !           153:         command->type          = endpoint->transferType;
        !           154:         command->buffer                = buffer;
        !           155:         command->completion    = *completion;
        !           156: 
        !           157:         if (_commandGate == 0)
        !           158:         {
        !           159:             err = kIOReturnInternalError;
        !           160:             break;
        !           161:         }
        !           162: 
        !           163:         if ((err = _commandGate->runAction(doIOTransfer, command)))
        !           164:             break;
        !           165:             
        !           166:         return(err);
        !           167: 
        !           168:     } while (0);
        !           169: 
        !           170:     /* Free/give back the command */
        !           171:     IOFree(command, sizeof(IOUSBCommand));
        !           172:     
        !           173:     return (err);
        !           174: }
        !           175: 
        !           176: IOReturn IOUSBController::isocIO(IOMemoryDescriptor * buffer,
        !           177:                                UInt64 frameStart,
        !           178:                                UInt32 numFrames,
        !           179:                                IOUSBIsocFrame *frameList,
        !           180:                                USBDeviceAddress address,
        !           181:                                Endpoint * endpoint,
        !           182:                                IOUSBIsocCompletion * completion)
        !           183: {
        !           184:     IOReturn    err = kIOReturnSuccess;
        !           185:     IOUSBIsocCommand *command = (IOUSBIsocCommand *)IOMalloc(sizeof(IOUSBIsocCommand));
        !           186: 
        !           187:     do
        !           188:     {
        !           189:         /* Validate the completion */
        !           190:         if (completion == 0)
        !           191:         {
        !           192:             err = kIOReturnNoCompletion;
        !           193:             break;
        !           194:         }
        !           195: 
        !           196:         /* Set up direction */
        !           197:         if (endpoint->direction == kUSBOut) {
        !           198:             command->selector  = WRITE;
        !           199:             command->direction = kUSBOut;
        !           200:        }
        !           201:         else if (endpoint->direction == kUSBIn) {
        !           202:             command->selector  = READ;
        !           203:             command->direction = kUSBIn;
        !           204:        }
        !           205:        else {
        !           206:             err = kIOReturnBadArgument;
        !           207:             break;
        !           208:         }
        !           209: 
        !           210:         command->address       = address;
        !           211:         command->endpoint      = endpoint->number;
        !           212:         command->buffer                = buffer;
        !           213:         command->completion    = *completion;
        !           214:         command->startFrame    = frameStart;
        !           215:         command->numFrames     = numFrames;
        !           216:         command->frameList     = frameList;
        !           217:         command->status                = kIOReturnInvalid;
        !           218: 
        !           219:         if (_commandGate == 0)
        !           220:         {
        !           221:             err = kIOReturnInternalError;
        !           222:             break;
        !           223:         }
        !           224: 
        !           225:         if ((err = _commandGate->runAction(doIsocTransfer, command)))
        !           226:             break;
        !           227: 
        !           228:         return(err);
        !           229: 
        !           230:     } while (0);
        !           231: 
        !           232:     /* Free/give back the command */
        !           233:     IOFree(command, sizeof(IOUSBIsocCommand));
        !           234: 
        !           235:     return (err);
        !           236: }

unix.superglobalmegacorp.com

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