xref: /haiku/src/add-ons/kernel/bus_managers/usb/usb.cpp (revision 1501c2bf3ec93a4548eba2168d29c0bb68d31589)
1*1501c2bfSNiels Sascha Reedijk //------------------------------------------------------------------------------
2*1501c2bfSNiels Sascha Reedijk //	Copyright (c) 2003, Niels S. Reedijk
3*1501c2bfSNiels Sascha Reedijk //
4*1501c2bfSNiels Sascha Reedijk //	Permission is hereby granted, free of charge, to any person obtaining a
5*1501c2bfSNiels Sascha Reedijk //	copy of this software and associated documentation files (the "Software"),
6*1501c2bfSNiels Sascha Reedijk //	to deal in the Software without restriction, including without limitation
7*1501c2bfSNiels Sascha Reedijk //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*1501c2bfSNiels Sascha Reedijk //	and/or sell copies of the Software, and to permit persons to whom the
9*1501c2bfSNiels Sascha Reedijk //	Software is furnished to do so, subject to the following conditions:
10*1501c2bfSNiels Sascha Reedijk //
11*1501c2bfSNiels Sascha Reedijk //	The above copyright notice and this permission notice shall be included in
12*1501c2bfSNiels Sascha Reedijk //	all copies or substantial portions of the Software.
13*1501c2bfSNiels Sascha Reedijk //
14*1501c2bfSNiels Sascha Reedijk //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*1501c2bfSNiels Sascha Reedijk //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*1501c2bfSNiels Sascha Reedijk //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17*1501c2bfSNiels Sascha Reedijk //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18*1501c2bfSNiels Sascha Reedijk //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19*1501c2bfSNiels Sascha Reedijk //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20*1501c2bfSNiels Sascha Reedijk //	DEALINGS IN THE SOFTWARE.
21*1501c2bfSNiels Sascha Reedijk 
22*1501c2bfSNiels Sascha Reedijk #include <USB.h>
23*1501c2bfSNiels Sascha Reedijk #include <util/kernel_cpp.h>
24*1501c2bfSNiels Sascha Reedijk 
25*1501c2bfSNiels Sascha Reedijk #include "usb_p.h"
26*1501c2bfSNiels Sascha Reedijk 
27*1501c2bfSNiels Sascha Reedijk #define USB_DEBUG
28*1501c2bfSNiels Sascha Reedijk #ifdef USB_DEBUG
29*1501c2bfSNiels Sascha Reedijk #define TRACE dprintf
30*1501c2bfSNiels Sascha Reedijk #else
31*1501c2bfSNiels Sascha Reedijk #define TRACE silent
32*1501c2bfSNiels Sascha Reedijk void silent( const char * , ... ) {}
33*1501c2bfSNiels Sascha Reedijk #endif
34*1501c2bfSNiels Sascha Reedijk 
35*1501c2bfSNiels Sascha Reedijk /* ++++++++++
36*1501c2bfSNiels Sascha Reedijk Loading/unloading the module
37*1501c2bfSNiels Sascha Reedijk ++++++++++ */
38*1501c2bfSNiels Sascha Reedijk 
39*1501c2bfSNiels Sascha Reedijk static int32
40*1501c2bfSNiels Sascha Reedijk bus_std_ops(int32 op, ...)
41*1501c2bfSNiels Sascha Reedijk {
42*1501c2bfSNiels Sascha Reedijk 	switch(op) {
43*1501c2bfSNiels Sascha Reedijk 		case B_MODULE_INIT:
44*1501c2bfSNiels Sascha Reedijk 			TRACE(("usb_nielx: bus module: init\n"));
45*1501c2bfSNiels Sascha Reedijk 			data = new Stack();
46*1501c2bfSNiels Sascha Reedijk 			if( data->InitCheck() != B_OK )
47*1501c2bfSNiels Sascha Reedijk 			{
48*1501c2bfSNiels Sascha Reedijk 				delete data;
49*1501c2bfSNiels Sascha Reedijk 				return ENODEV;
50*1501c2bfSNiels Sascha Reedijk 			}
51*1501c2bfSNiels Sascha Reedijk 			break;
52*1501c2bfSNiels Sascha Reedijk 		case B_MODULE_UNINIT:
53*1501c2bfSNiels Sascha Reedijk 			TRACE(("usb_nielx: bus module: uninit\n"));
54*1501c2bfSNiels Sascha Reedijk 			delete data;
55*1501c2bfSNiels Sascha Reedijk 			break;
56*1501c2bfSNiels Sascha Reedijk 		default:
57*1501c2bfSNiels Sascha Reedijk 			return EINVAL;
58*1501c2bfSNiels Sascha Reedijk 	}
59*1501c2bfSNiels Sascha Reedijk 	return B_OK;
60*1501c2bfSNiels Sascha Reedijk }
61*1501c2bfSNiels Sascha Reedijk 
62*1501c2bfSNiels Sascha Reedijk 
63*1501c2bfSNiels Sascha Reedijk /* ++++++++++
64*1501c2bfSNiels Sascha Reedijk This module exports the USB API
65*1501c2bfSNiels Sascha Reedijk ++++++++++ */
66*1501c2bfSNiels Sascha Reedijk 
67*1501c2bfSNiels Sascha Reedijk struct usb_module_info m_module_info =
68*1501c2bfSNiels Sascha Reedijk {
69*1501c2bfSNiels Sascha Reedijk 	// First the bus_manager_info:
70*1501c2bfSNiels Sascha Reedijk 	{
71*1501c2bfSNiels Sascha Reedijk 		//module_info
72*1501c2bfSNiels Sascha Reedijk 		{
73*1501c2bfSNiels Sascha Reedijk 			"bus_managers/usb/nielx" ,
74*1501c2bfSNiels Sascha Reedijk 			B_KEEP_LOADED ,				// Keep loaded, even if no driver requires it
75*1501c2bfSNiels Sascha Reedijk 			bus_std_ops
76*1501c2bfSNiels Sascha Reedijk 		} ,
77*1501c2bfSNiels Sascha Reedijk 		NULL 							// the rescan function
78*1501c2bfSNiels Sascha Reedijk 	} ,
79*1501c2bfSNiels Sascha Reedijk 	NULL ,								// register_driver
80*1501c2bfSNiels Sascha Reedijk 	NULL ,								// install_notify
81*1501c2bfSNiels Sascha Reedijk 	NULL ,								// uninstall_notify
82*1501c2bfSNiels Sascha Reedijk 	NULL ,								// get_device_descriptor
83*1501c2bfSNiels Sascha Reedijk 	NULL ,								// get_nth_configuration_info
84*1501c2bfSNiels Sascha Reedijk 	NULL ,								// get_configuration
85*1501c2bfSNiels Sascha Reedijk 	NULL ,								// set_configuration
86*1501c2bfSNiels Sascha Reedijk 	NULL ,								// set_alt_interface
87*1501c2bfSNiels Sascha Reedijk 	NULL , 								// set_feature
88*1501c2bfSNiels Sascha Reedijk 	NULL , 								// clear_feature
89*1501c2bfSNiels Sascha Reedijk 	NULL , 								// get_status
90*1501c2bfSNiels Sascha Reedijk 	NULL ,								// get_descriptor
91*1501c2bfSNiels Sascha Reedijk 	NULL ,								// send_request
92*1501c2bfSNiels Sascha Reedijk 	NULL ,								// queue_interrupt
93*1501c2bfSNiels Sascha Reedijk 	NULL ,								// queue_bulk
94*1501c2bfSNiels Sascha Reedijk 	NULL ,								// queue_isochronous
95*1501c2bfSNiels Sascha Reedijk 	NULL ,								// queue_request
96*1501c2bfSNiels Sascha Reedijk 	NULL ,								// set_pipe_policy
97*1501c2bfSNiels Sascha Reedijk 	NULL ,								// cancel_queued_transfers
98*1501c2bfSNiels Sascha Reedijk 	NULL 								// usb_ioctl
99*1501c2bfSNiels Sascha Reedijk };
100*1501c2bfSNiels Sascha Reedijk 
101*1501c2bfSNiels Sascha Reedijk module_info *modules[] = {
102*1501c2bfSNiels Sascha Reedijk 	(module_info *)&m_module_info ,
103*1501c2bfSNiels Sascha Reedijk 	NULL
104*1501c2bfSNiels Sascha Reedijk };
105