1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2003, 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 <module.h> 23 #include <util/kernel_cpp.h> 24 25 #include "usb_p.h" 26 27 Stack::Stack() 28 { 29 //Init the master lock 30 m_master = create_sem( 0 , "usb master lock" ); 31 set_sem_owner( m_master , B_SYSTEM_TEAM ); 32 33 //Create the data lock 34 m_datalock = create_sem( 0 , "usb data lock" ); 35 set_sem_owner( m_datalock , B_SYSTEM_TEAM ); 36 37 //Check for host controller modules 38 void *list = open_module_list( "busses/usb" ); 39 char modulename[B_PATH_NAME_LENGTH]; 40 size_t buffersize = sizeof(modulename); 41 dprintf( "USB: Looking for host controller modules\n" ); 42 while( read_next_module_name( list , modulename , &buffersize ) == B_OK ) 43 { 44 dprintf( "USB: Found module %s\n" , modulename ); 45 host_controller_info *module = 0; 46 if ( get_module( modulename , (module_info **)&module ) != B_OK ) 47 continue; 48 m_busmodules.Insert( new BusManager( module ) , 0 ); 49 dprintf( "USB: module %s successfully loaded\n" , modulename ); 50 } 51 52 if( m_busmodules.Count() == 0 ) 53 return; 54 } 55 56 Stack::~Stack() 57 { 58 //Release the bus modules 59 for( Vector<BusManager *>::Iterator i = m_busmodules.Begin() ; i != m_busmodules.End() ; i++ ) 60 delete (*i); 61 } 62 63 64 status_t Stack::InitCheck() 65 { 66 if ( m_busmodules.Count() == 0 ) 67 return ENODEV; 68 return B_OK; 69 } 70 71 Stack *data = 0; 72