Annotation of kernel/bsd/dev/ppc/drvUSBCMD/mouse/MouseConfigParse.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:           ConfigParse.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:                            Craig Keithley
        !            37: 
        !            38:                Other Contact:          xxx put other contact here xxx
        !            39: 
        !            40:                Technology:                     xxx put technology here xxx
        !            41: 
        !            42:        Writers:
        !            43: 
        !            44:                (BG)    Bill Galcher
        !            45:                (CJK)   Craig Keithley
        !            46: 
        !            47:        Change History (most recent first):
        !            48: 
        !            49:         <USB12>         6/29/98        CJK             change total length so that it's properly byte swapped
        !            50:         <USB11>         6/16/98        CJK             change FindHIDInterfaceByProtocol to FindHIDInterfaceByNumber
        !            51:         <USB10>          6/8/98        CJK             remove unneeded XXGetEndPointDescriptor function
        !            52:          <USB9>         5/19/98        BG              Fix some casting problems.
        !            53:          <USB8>         4/23/98        CJK             added FindHIDInterfaceByProtocol, so that the reworked mouse
        !            54:                                                                        code can find the interface within the configuration descriptor.
        !            55:          <USB7>          4/9/98        CJK             remove include of USBClassDrivers.h, USBHIDModules.h, and
        !            56:                                                                        USBDeviceDefines.h
        !            57:                 <6>     3/17/98        CJK             Replace some "};" with just "}" (metrowerks has a problem with
        !            58:                                                                        it).
        !            59:                 <5>      3/9/98        CJK             Fix RADAR #2216609 (Duplicate sets of enums)
        !            60:                 <4>      3/2/98        CJK             Fix change history (had some old entries from before being
        !            61:                                                                        cloned).
        !            62:                 <3>      3/2/98        CJK             Correct semi-colon problem.
        !            63:                 <2>      3/2/98        CJK             Add include of USBHIDModules.h. Remove include of HIDEmulation.h
        !            64: */
        !            65: 
        !            66: //#include <Types.h>
        !            67: //#include <Devices.h>
        !            68: //#include <processes.h>
        !            69: #include "../driverservices.h"
        !            70: #include "../USB.h"
        !            71: 
        !            72: 
        !            73: #include "MouseModule.h"
        !            74: 
        !            75: OSErr FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc)
        !            76: {
        !            77: UInt32 totalLength;
        !            78: void * pEndOfDescriptors;
        !            79: USBInterfaceDescriptorPtr      pMyIntDesc;
        !            80: USBDescriptorHeaderPtr         pCurrentDesc;
        !            81: unsigned long                          anAddress, anOffset;
        !            82: 
        !            83:        totalLength = USBToHostWord(((USBConfigurationDescriptorPtr)pConfigDesc)->totalLength);
        !            84:        pEndOfDescriptors = (Ptr)pConfigDesc + totalLength;                                     // get the total length and add it to the start of the config space
        !            85:        pCurrentDesc = (USBDescriptorHeaderPtr)pConfigDesc;                                     // point the currentdesc to the start of the config space
        !            86:        
        !            87:        while (pCurrentDesc < pEndOfDescriptors)                                                        // as long as we haven't exhausted all the descriptors
        !            88:        {
        !            89:                if (pCurrentDesc->descriptorType == kUSBInterfaceDesc)                  // look at the current descriptor
        !            90:                {
        !            91:                        pMyIntDesc = (USBInterfaceDescriptorPtr)pCurrentDesc;           // if it's an interface descriptor
        !            92:                        if ((pMyIntDesc->interfaceClass == kUSBHIDInterfaceClass) &&
        !            93:                            (pMyIntDesc->interfaceNumber == ReqInterface))                      // and if it's the interface we want...
        !            94:                        {
        !            95:                                *hInterfaceDesc = pMyIntDesc;                                                   // if it is, then return with hInterfaceDesc set to the
        !            96:                                return noErr;                                                                                   // current descriptor pointer
        !            97:                        }
        !            98:                }
        !            99:                // (Ptr)pCurrentDesc += pCurrentDesc->length;                                   // Nope, that either wasn't an interface descriptor
        !           100:                anAddress = (unsigned long) pCurrentDesc;                                               // Nope, that either wasn't an interface descriptor
        !           101:                anOffset  = (unsigned long) pCurrentDesc->length;
        !           102:                anAddress += anOffset;
        !           103:                pCurrentDesc = (USBDescriptorHeaderPtr) anAddress;
        !           104:                if (pCurrentDesc->length == 0)
        !           105:                        break;
        !           106:        }                                                                                                                                       // or it was, but not the droid we're looking for.
        !           107:        *hInterfaceDesc = NULL;
        !           108:        return kUSBInternalErr;
        !           109: }
        !           110: 
        !           111: 
        !           112: 
        !           113: 

unix.superglobalmegacorp.com

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