|
|
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: uslExpert.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: xxx put dri here xxx
37:
38: Other Contact: xxx put other contact here xxx
39:
40: Technology: xxx put technology here xxx
41:
42: Writers:
43:
44: (CJK) Craig Keithley
45: (DF) David Ferguson
46: (BT) Barry Twycross
47:
48: Change History (most recent first):
49:
50: <USB7> 9/28/98 BT Add device reset function
51: <USB6> 6/11/98 CJK add reserved params to USBExpertSetDevicePowerStatus. Wanted to
52: get it into the USB.i before freezing C1
53: <USB5> 6/11/98 BT Add power state notification message
54: <USB4> 6/8/98 CJK add USBExpertSetDevicePowerStatus
55: <USB3> 6/6/98 DF Change parameter for USBExpertInstallInterfaceDriver from hubRef
56: to deviceRef
57: <USB2> 5/12/98 BT New interface handling
58: <USB1> 4/26/98 BT first checked in
59: */
60:
61: //#include <errors.h>
62: #include "../USB.h"
63: #include "../USBpriv.h"
64: #include "../driverservices.h"
65: #include "uslpriv.h"
66: #include "../uimpriv.h"
67:
68: //two globals needed to support international keyboards for Rhapsody
69: unsigned int usb_kbd_vendor_id = 0, usb_kbd_product_id = 0;
70:
71:
72: static ExpertNotificationProcPtr expert;
73:
74: void SetExpertFunction(void *exProc)
75: {
76: expert = exProc;
77: }
78:
79: OSStatus USBExpertNotify(void *note)
80: {
81: if(expert == nil)
82: {
83: return(kUSBInternalErr); // make up a not inited err
84: }
85: return(*expert)(note);
86: }
87:
88: OSStatus USBExpertStatus(USBDeviceRef ref, void *pointer, UInt32 value)
89: {
90: ExpertNotificationData note;
91: note.notification = kNotifyStatus;
92: note.deviceRef = &ref;
93: note.data = pointer;
94: note.info2 = value;
95: kprintf("USBExpertStatus:%s: value=%d,ref=%d\n",pointer,value,ref);
96: return(USBExpertNotify(¬e));
97: }
98:
99: OSStatus USBExpertStatusLevel(UInt32 level, USBDeviceRef ref, char *status, UInt32 value)
100: {
101: ExpertNotificationData note;
102: note.notification = kNotifyStatus;
103: note.deviceRef = &ref;
104: note.data = status;
105: note.info1 = level;
106: note.info2 = value;
107: return(USBExpertNotify(¬e));
108: }
109:
110:
111: OSStatus USBExpertFatalError(USBDeviceRef ref, OSStatus status, void *pointer, UInt32 value)
112: {
113: ExpertNotificationData note;
114: note.notification = kNotifyFatalError;
115: note.deviceRef = &ref;
116: note.data = pointer;
117: note.info1 = status;
118: note.info2 = value;
119: kprintf("USBFatalError:%s: Status=%d value=%d,ref=%d\n",pointer,status,value,ref);
120: return(USBExpertNotify(¬e));
121: }
122:
123:
124: OSStatus USBExpertInstallInterfaceDriver(USBDeviceRef ref, USBDeviceDescriptor *desc,
125: USBInterfaceDescriptor *interface,
126: USBReference deviceRef, UInt32 busPowerAvailable)
127: {
128: ExpertNotificationData note;
129:
130:
131: kprintf("USB: in USBExpertInstallInterfaceDriver interface class=%d subclass=%d protocol = %d device vendor = %d product=%d \n", interface->interfaceClass,
132: interface->interfaceSubClass, interface->interfaceProtocol, EndianSwap16Bit(desc->vendor), EndianSwap16Bit(desc->product));
133:
134: //A.W. 11/30/98
135: if (interface->interfaceProtocol == 2)
136: {
137: //Call mouse now... mouse uses InterfaceEntry(), keyboard uses kbd_InterfaceEntry()
138: // NOTE: the "2" is interfacenum, which is unused in InterfaceEntry()
139: InterfaceEntry(2, interface, desc, deviceRef);
140: }
141: else if(interface->interfaceProtocol == 1 )
142: {
143: kbd_InterfaceEntry(2, interface, desc, deviceRef); //naga
144: //A.W. I need two global variables to support international keyboards in Rhapsody
145: usb_kbd_vendor_id = EndianSwap16Bit(desc->vendor);
146: usb_kbd_product_id = EndianSwap16Bit(desc->product);
147: }
148:
149:
150:
151: note.notification = kNotifyAddInterface;
152: note.deviceRef = &ref;
153: note.data = interface;
154: note.info1 = deviceRef;
155: note.info2 = (UInt32) desc;
156: note.busPowerAvailable = busPowerAvailable;
157: return(USBExpertNotify(¬e));
158: }
159:
160: OSStatus USBExpertInstallDeviceDriver(USBDeviceRef ref, USBDeviceDescriptor *desc,
161: USBReference hubRef, UInt32 port,
162: UInt32 busPowerAvailable)
163: {
164: ExpertNotificationData note;
165: kprintf("USB Install Driver:ref=0x%x,class=%d,subclass=%d,protocol=%d,vendor=0x%x,product=0x%x\n",ref,desc->deviceClass,desc->deviceSubClass,desc->protocol,EndianSwap16Bit(desc->vendor),EndianSwap16Bit(desc->product));
166:
167: note.notification = kNotifyAddDevice;
168: note.deviceRef = &ref;
169: note.data = desc;
170: note.info1 = hubRef;
171: note.info2 = port;
172: note.busPowerAvailable = busPowerAvailable;
173: if(desc->deviceClass == 0)
174: DeviceInitialize(ref,desc,busPowerAvailable);
175: if(desc->deviceClass == 9)
176: {
177:
178: if (desc->deviceSubClass == 0)
179: {
180: HubDriverEntry(ref,desc,busPowerAvailable);
181: }
182: else if (desc->deviceSubClass == 1)
183: {
184: Hub2DriverEntry(ref,desc,busPowerAvailable);
185: }
186: else kprintf("USB: Hub SubClass error in uslExpert.c\n");
187:
188: }
189: // return(USBExpertNotify(¬e));
190: }
191:
192: OSStatus USBExpertRemoveDeviceDriver(USBDeviceRef ref)
193: {
194: ExpertNotificationData note;
195: note.notification = kNotifyRemoveDevice;
196: note.deviceRef = &ref;
197: return(USBExpertNotify(¬e));
198: }
199:
200: OSStatus USBExpertRemoveInterfaceDriver(USBDeviceRef ref)
201: {
202: ExpertNotificationData note;
203: note.notification = kNotifyRemoveInterface;
204: note.deviceRef = &ref;
205: return(USBExpertNotify(¬e));
206: }
207:
208: OSStatus USBExpertSetDevicePowerStatus(USBDeviceRef ref, UInt32 reserved1, UInt32 reserved2, UInt32 powerStatus, UInt32 busPowerAvailable, UInt32 busPowerNeeded )
209: {
210: #pragma unused (reserved1)
211: #pragma unused (reserved2)
212:
213: ExpertNotificationData note;
214: note.notification = kNotifyPowerState;
215: note.deviceRef = &ref;
216: note.info1 = powerStatus;
217: note.busPowerAvailable = busPowerAvailable;
218: note.info2 = busPowerNeeded;
219: USBExpertStatus(0,"USL - sending power note to expert", powerStatus);
220:
221: return(USBExpertNotify(¬e));
222: }
223:
224: OSStatus USBExpertNotifyParentMsg(USBReference reference, void *pointer)
225: {
226: ExpertNotificationData note;
227:
228: note.notification = kNotifyParentNotify;
229: note.deviceRef = &reference;
230: note.data = pointer;
231: return(USBExpertNotify(¬e));
232: }
233:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.