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