|
|
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_IOUSBDEVICE_H
31: #define _IOKIT_IOUSBDEVICE_H
32:
33: #include <IOKit/usb/IOUSBNub.h>
34:
35: class IOUSBController;
36: class IOUSBHubPort;
37: class IOUSBInterface;
38:
39: /*!
40: @class IOUSBDevice
41: @abstract The object representing a device on the USB bus.
42: @discussion This class provides functionality to configure a device and to create
43: IOUSBInterface objects to represent the interfaces of the device
44: */
45:
46: class IOUSBDevice : public IOUSBNub
47: {
48: OSDeclareDefaultStructors(IOUSBDevice)
49:
50: protected:
51:
52:
53: IOUSBEndpointDescriptor _endpointZero; // Fake ep for control pipe
54: IOUSBHubPort * _port;
55: UInt8 ** _configList;
56:
57: virtual void free();
58:
59: // Create an IOUserClient object to handle communication with User task
60: virtual IOReturn newUserClient( task_t owningTask,
61: void * security_id,
62: UInt32 type,
63: IOUserClient ** handler );
64:
65: const IOUSBConfigurationDescriptor *findConfig(UInt8 configValue, int *configIndex=0);
66:
67: virtual IOUSBInterface * GetInterface(const IOUSBInterfaceDescriptor *interface,
68: const IOUSBConfigurationDescriptor *config);
69:
70: virtual IOReturn GetConfigDescriptor(UInt8 configIndex, void *data, int len);
71:
72: virtual IOUSBInterface *createInterface(OSDictionary *table,
73: const IOUSBConfigurationDescriptor *config,
74: const IOUSBInterfaceDescriptor *interface);
75:
76: public:
77:
78: virtual bool init(OSDictionary * propTable);
79: virtual bool attach(IOService *provider);
80: virtual void setPort(IOUSBHubPort *);
81:
82: /*!
83: @function findNextInterface
84: return an interface satisfying the requirements specified in request, or NULL if there aren't any.
85: request is updated with the properties of the returned interface.
86: @param current interface to start searching from, NULL to start at the beginning of the device's interface
87: list.
88: @param request specifies what properties an interface must have to match.
89: @result Pointer to a matching interface, or NULL if none match
90: */
91: virtual IOUSBInterface *findNextInterface(IOUSBInterface *current,
92: FindInterfaceRequest *request);
93:
94: // Get pointer to full config info (cached in device, don't free returned pointer)
95: /*!
96: @function getFullConfigurationDescriptor
97: return a pointer to all the descriptors for the requested configuration.
98: @param configIndex The configuration index (not the configuration value)
99: @result Pointer to the descriptors, which are cached in the device object.
100: */
101: virtual const IOUSBConfigurationDescriptor *getFullConfigurationDescriptor(UInt8 configIndex);
102:
103: // Copy data into supplied buffer, up to 'len' bytes.
104: /*!
105: @function getConfigurationDescriptor
106: Copy the specified amount of data for a configuration into the suppled buffer.
107: @param configValue The configuration value
108: @param data Buffer to copy data into
109: @param len number of bytes to copy
110: */
111: virtual IOReturn getConfigurationDescriptor(UInt8 configValue, void *data, UInt32 len);
112:
113: // Reset the device
114: // an extreme measure, almost equivalent to unplugging it and plugging in again
115: /*!
116: @function resetDevice
117: Reset the device, returning it to the addressed, unconfigured state.
118: This is useful if a device has got badly confused
119: */
120: virtual IOReturn resetDevice();
121:
122: virtual IOReturn SetConfiguration(UInt8 configValue);
123: };
124:
125: #endif /* _IOKIT_IOUSBDEVICE_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.