|
|
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: <USB5> 6/29/98 CJK change total length so that it's properly byte swapped.
50: <USB4> 6/5/98 CJK remove XXGetEndPointDescriptor function (not needed)
51: <USB3> 5/19/98 BG Fix some casting problems.
52: <USB2> 4/9/98 CJK change to use USB.h
53: <1> 4/7/98 CJK first checked in as USBCompositeClassDriver
54: <8> 3/17/98 CJK Replace "};" with just "}" (where required by MW). Also used
55: extractprototypes to get the function prototypes out of this
56: file and into the header file.
57: <7> 3/9/98 CJK Fix RADAR #2216609 (Duplicate sets of enums)
58: <6> 2/9/98 CJK remove get hid descriptor function
59: <5> 2/9/98 CJK remove HIDEmulation.h include
60: <4> 2/2/98 CJK Add get hid descriptor call
61: <3> 1/26/98 CJK Change to use structure field names as required by codebert
62: <2> 1/23/98 CJK Work on configuration parsing
63: */
64:
65: //#include <Types.h>
66: //#include <Devices.h>
67: //#include <processes.h>
68: #include "../driverservices.h"
69: #include "../USB.h"
70:
71: #include "CompositeClassDriver.h"
72:
73: OSErr GetInterfaceDescriptor(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc)
74: {
75: UInt32 totalLength;
76: void * pEndOfDescriptors;
77: USBInterfaceDescriptorPtr pMyIntDesc;
78: USBDescriptorHeaderPtr pCurrentDesc;
79: unsigned long anAddress, anOffset;
80:
81: totalLength = USBToHostWord(((USBConfigurationDescriptorPtr)pConfigDesc)->totalLength);
82: pEndOfDescriptors = (Ptr)pConfigDesc + totalLength; // get the total length and add it to the start of the config space
83: pCurrentDesc = (USBDescriptorHeaderPtr)pConfigDesc; // point the currentdesc to the start of the config space
84:
85: while (pCurrentDesc < pEndOfDescriptors) // as long as we haven't exhausted all the descriptors
86: {
87: if (pCurrentDesc->descriptorType == kUSBInterfaceDesc) // look at the current descriptor
88: {
89: pMyIntDesc = (USBInterfaceDescriptorPtr)pCurrentDesc; // if it's an interface descriptor
90: if (pMyIntDesc->interfaceNumber == ReqInterface) // see if it's the request descriptor
91: {
92: *hInterfaceDesc = pMyIntDesc; // if it is, then return with hInterfaceDesc set to the
93: return kUSBNoErr; // current descriptor pointer
94: }
95: }
96: anAddress = (unsigned long) pCurrentDesc; // Nope, that either wasn't an interface descriptor
97: anOffset = (unsigned long) pCurrentDesc->length;
98: anAddress += anOffset;
99: pCurrentDesc = (USBDescriptorHeaderPtr) anAddress;
100: } // or it was, but not the droid we're looking for.
101: return -1;
102: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.