|
|
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_IOUSBINTERFACE_H
31: #define _IOKIT_IOUSBINTERFACE_H
32:
33: #include <IOKit/IOService.h>
34: #include <libkern/c++/OSData.h>
35:
36: #include <IOKit/usb/USB.h>
37: #include <IOKit/usb/IOUSBNub.h>
38:
39: class IOUSBDevice;
40:
41: /*!
42: @class IOUSBInterface
43: @abstract The object representing an interface of a device on the USB bus.
44: @discussion This class provides functionality to find the pipes of an interface and
45: to read the descriptors associated with an interface. When an interface is open()ed,
46: all its pipes are created
47: */
48: class IOUSBInterface : public IOUSBNub
49: {
50: OSDeclareDefaultStructors(IOUSBInterface)
51:
52: protected:
53: IOUSBPipe * _pipeList[kUSBMaxPipes];
54: const IOUSBConfigurationDescriptor *_configDesc;
55: const IOUSBInterfaceDescriptor * _interfaceDesc;
56: IOUSBDevice * _device;
57: UInt8 _currentAlt;
58:
59: virtual void cleanPipes(void); // close all pipes (except pipe zero)
60: // Create an IOUserClient object to handle communication with User task
61: virtual IOReturn newUserClient( task_t owningTask,
62: void * security_id,
63: UInt32 type,
64: IOUserClient ** handler );
65:
66:
67: public:
68:
69: virtual bool init(OSDictionary * propTable,
70: const IOUSBConfigurationDescriptor *cfDesc,
71: const IOUSBInterfaceDescriptor *ifDesc);
72: virtual bool attach(IOService *provider);
73: virtual bool finalize(IOOptionBits options);
74:
75: /*!
76: @function findNextAltInterface
77: return alternate interface descriptor satisfying the requirements specified in request, or NULL if there aren't any.
78: request is updated with the properties of the returned interface.
79: @param current interface descriptor to start searching from, NULL to start at alternate interface 0.
80: @param request specifies what properties an interface must have to match.
81: @result Pointer to a matching interface descriptor, or NULL if none match.
82: */
83: virtual const IOUSBInterfaceDescriptor *findNextAltInterface(const IOUSBInterfaceDescriptor *current,
84: FindInterfaceRequest *request);
85:
86: /*!
87: @function findNextPipe
88: Find a pipe of the interface that matches the requirements, either
89: starting from the beginning of the interface's pipe list or from a specified
90: pipe.
91: @param current Pipe to start searching from, NULL to start from beginning of list.
92: @param request Requirements for pipe to match, updated with the found pipe's
93: properties.
94: @result Pointer to the pipe, or NULL if no pipe matches the request.
95: */
96: virtual IOUSBPipe *findNextPipe(IOUSBPipe *current,
97: IOUSBFindEndpointRequest *request);
98:
99: /*!
100: @function findNextAssociatedDescriptor
101: Find the next descriptor of the requested type associated with the interface.
102: @param current Descriptor to start searching from, NULL to start from beginning of list.
103: @param type Descriptor type to search for, or kUSBAnyDesc to return any descriptor type.
104: @result Pointer to the descriptor, or NULL if no matching descriptors found.
105: */
106: virtual const IOUSBDescriptorHeader *
107: findNextAssociatedDescriptor(const void *current, UInt8 type);
108:
109: /*!
110: @function setAlternateInterface
111: Select the specified alternate interface.
112: @param alternateSetting Alternate setting (from the alternate interface's interface descriptor).
113: */
114: virtual IOReturn setAlternateInterface(UInt8 alternateSetting);
115:
116: /* Open / Close, overriden to open/close all the pipes */
117: virtual bool open( IOService * forClient,
118: IOOptionBits options = 0,
119: void * arg = 0 );
120: virtual void close( IOService * forClient,
121: IOOptionBits options = 0 );
122:
123: // Lowlevel requests for non-standard device requests
124: virtual IOReturn deviceRequest(IOUSBDevRequest *request,
125: IOUSBCompletion *completion = 0);
126:
127: /*!
128: @function getConfigValue
129: returns the device configuration value for the interface
130: @result The device configuration value.
131: */
132: UInt8 getConfigValue();
133: /*!
134: @function interfaceDescriptor
135: returns the interface descriptor for the interface
136: @result Pointer to the interface descriptor.
137: */
138: const IOUSBInterfaceDescriptor * interfaceDescriptor();
139: /*!
140: @function device
141: returns the device the interface is part of.
142: @result Pointer to the device.
143: */
144: IOUSBDevice * device();
145: };
146:
147: #endif /* _IOKIT_IOUSBINTERFACE_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.