Annotation of XNU/iokit/IOKit/usb/IOUSBPipe.h, revision 1.1.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:  *
                     27:  */
                     28: 
                     29: 
                     30: #ifndef _IOKIT_IOUSBPIPE_H
                     31: #define _IOKIT_IOUSBPIPE_H
                     32: 
                     33: #include <IOKit/IOService.h>
                     34: #include <IOKit/IOMemoryDescriptor.h>
                     35: 
                     36: #include <IOKit/usb/USB.h>
                     37: 
                     38: #include <IOKit/usb/IOUSBController.h>
                     39: 
                     40: /*!
                     41:     @class IOUSBPipe
                     42:     @abstract The object representing an open pipe for a device.
                     43: */
                     44: class IOUSBPipe : public OSObject
                     45: {
                     46:     OSDeclareDefaultStructors(IOUSBPipe)
                     47: 
                     48: protected:
                     49: 
                     50:     const IOUSBEndpointDescriptor *    _descriptor;
                     51:     IOUSBController::Endpoint          _endpoint;      // tidied up version of descriptor
                     52:     IOUSBController *                  _controller;
                     53:     USBDeviceAddress                   _address;
                     54:     UInt8                              _status;        // stalled, active
                     55: 
                     56:     virtual void free();
                     57: 
                     58: public:
                     59: 
                     60:     virtual bool initToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed,
                     61:                                 USBDeviceAddress address, IOUSBController * controller);
                     62:     static IOUSBPipe *toEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed,
                     63:                                  USBDeviceAddress address, IOUSBController * controller);
                     64: 
                     65:     // Controlling pipe state
                     66:     /*!
                     67:         @function status
                     68:        Get the current state of the pipe (kIOUSBPipeStalled if stalled or 0 if active).
                     69:        We clear a pipe stall as soon as it is detected, so in practice this routine
                     70:        always returns zero
                     71:     */
                     72:     virtual UInt8 status(void);
                     73:     /*!
                     74:         @function abort
                     75:        abort a pipe, causing all outstanding I/O to complete
                     76:        with return code kIOReturnAborted
                     77:     */
                     78:     virtual IOReturn abort(void);
                     79:     /*!
                     80:         @function reset
                     81:         reset a pipe, causing all outstanding I/O to complete
                     82:         with return code kIOReturnAborted, and clear any stall.
                     83:     */
                     84:     virtual IOReturn reset(void);
                     85:     /*!
                     86:         @function clearStall
                     87:         clear any stall.
                     88:     */
                     89:     virtual IOReturn clearStall(void);
                     90: 
                     91:     //
                     92:     // Transferring Data
                     93:     //
                     94:     
                     95:     // Transfer data over Bulk or Interrupt pipes.
                     96:     /*!
                     97:         @function read
                     98:         Read from an interrupt or bulk endpoint
                     99:         @param buffer place to put the transferred data
                    100:         @param completion describes action to take when buffer has been filled
                    101:         @param bytesRead returns total bytes read for synchronous reads
                    102:     */
                    103:     virtual IOReturn read(IOMemoryDescriptor * buffer,
                    104:                           IOUSBCompletion *    completion = 0,
                    105:                          IOByteCount *         bytesRead = 0);
                    106: 
                    107:     /*!
                    108:         @function write
                    109:         Write to an interrupt or bulk endpoint
                    110:         @param buffer place to get the transferred data
                    111:         @param completion describes action to take when buffer has been emptied
                    112:     */
                    113:     virtual IOReturn write(IOMemoryDescriptor *        buffer,
                    114:                            IOUSBCompletion *   completion = 0);
                    115: 
                    116:     // Transfer data over Isochronous pipes
                    117:     /*!
                    118:         @function read
                    119:         Read from an isochronous endpoint
                    120:         @param buffer place to put the transferred data
                    121:         @param frameStart USB frame number of the frame to start transfer
                    122:        @param numFrames Number of frames to transfer
                    123:        @param frameList Bytes to transfer and result for each frame
                    124:         @param completion describes action to take when buffer has been filled
                    125:     */
                    126:     virtual IOReturn read(IOMemoryDescriptor * buffer,
                    127:                           UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList,
                    128:                           IOUSBIsocCompletion *        completion = 0);
                    129:     /*!
                    130:         @function write
                    131:         Write to an interrupt or bulk endpoint
                    132:         @param buffer place to get the transferred data
                    133:         @param frameStart USB frame number of the frame to start transfer
                    134:         @param numFrames Number of frames to transfer
                    135:         @param frameList Bytes to transfer and result for each frame
                    136:         @param completion describes action to take when buffer has been emptied
                    137:     */
                    138:     virtual IOReturn write(IOMemoryDescriptor *        buffer,
                    139:                            UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList,
                    140:                            IOUSBIsocCompletion * completion = 0);
                    141: 
                    142:     /*!
                    143:         @function controlRequest
                    144:         Make a control request
                    145:         There are two versions of this method, one uses a simple void *
                    146:         to point to the data portion of the transfer, the other uses an
                    147:         IOMemoryDescriptor to point to the data.
                    148:         @param request parameter block for the control request
                    149:         @param completion describes action to take when the request has been executed
                    150:     */
                    151:     // Do a control request over a Control pipe, using a memory descriptor
                    152:     virtual IOReturn controlRequest(IOUSBDevRequestDesc        *request,
                    153:                                    IOUSBCompletion     *completion = 0);
                    154: 
                    155:     // Do a control request over a Control pipe, using a simple buffer
                    156:     virtual IOReturn controlRequest(IOUSBDevRequest    *request,
                    157:                                 IOUSBCompletion        *completion = 0);
                    158: 
                    159:     /*!
                    160:         @function GetBandwidthAvailable
                    161:         Returns the available bandwidth (in bytes) per frame for
                    162:         isochronous transfers.
                    163:         @result maximum number of bytes that a new iso pipe could transfer
                    164:         per frame given current allocations.
                    165:     */
                    166:     virtual UInt32 GetBandwidthAvailable();
                    167: 
                    168:     /*!
                    169:         @function GetFrameNumber
                    170:         Returns the full current frame number of the bus the device is
                    171:         attached to
                    172:         @result The frame number.
                    173:     */
                    174:     virtual UInt64 GetFrameNumber();
                    175: 
                    176:     // Return cached pointer to an associated descriptor.
                    177:     // Don't free returned pointer.
                    178:     /*!
                    179:         @function findNextAssociatedDescriptor
                    180:         Find the next descriptor of the requested type associated with the endpoint.
                    181:         @param current Descriptor to start searching from, NULL to start from beginning of list.
                    182:         @param type Descriptor type to search for, or kUSBAnyDesc to return any descriptor type.
                    183:     */
                    184:     virtual const IOUSBDescriptorHeader *
                    185:     findNextAssociatedDescriptor(const void *current, UInt8 type);
                    186: 
                    187:     /*!
                    188:         @function endpoint
                    189:         returns a pointer to the Endpoint structure for the pipe.
                    190:     */
                    191:     const IOUSBController::Endpoint *  endpoint();
                    192:     /*!
                    193:         @function endpointDescriptor
                    194:         returns the endpoint descriptor for the pipe.
                    195:     */
                    196:     const IOUSBEndpointDescriptor *    endpointDescriptor();
                    197:     /*!
                    198:         @function direction
                    199:         returns the direction of the pipe:kUSBOut/kUSBIn for a bulk or interrupt pipe,
                    200:        kUSBAnyDirn for a control pipe.
                    201:     */
                    202:     UInt8                              direction();
                    203:     /*!
                    204:         @function type
                    205:         returns the pipe type: kUSBControl, kUSBBulk or kUSBInterrupt.
                    206:     */
                    207:     UInt8                              type();
                    208:     /*!
                    209:         @function endpointNumber
                    210:         returns the endpoint number in the device that the pipe is connected to.
                    211:     */
                    212:     UInt8                              endpointNumber();
                    213:     /*!
                    214:         @function address
                    215:         returns the bus address of the pipe's device
                    216:     */
                    217:     virtual USBDeviceAddress           address(void);
                    218: };
                    219: 
                    220: #endif /* _IOKIT_IOUSBPIPE_H */

unix.superglobalmegacorp.com

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