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 //Check for host controller modules 34 void *list = open_module_list( "busses/usb" ); 35 char modulename[B_PATH_NAME_LENGTH]; 36 size_t buffersize = sizeof(modulename); 37 dprintf( "USB: Looking for host controller modules\n" ); 38 while( read_next_module_name( list , modulename , &buffersize ) == B_OK ) 39 { 40 dprintf( "USB: Found module %s\n" , modulename ); 41 module_info *module = 0; 42 if ( get_module( modulename , &module ) != B_OK ) 43 continue; 44 m_busmodules.Insert( module , 0 ); 45 dprintf( "USB: module %s successfully loaded\n" , modulename ); 46 } 47 48 if( m_busmodules.Count() == 0 ) 49 return; 50 } 51 52 Stack::~Stack() 53 { 54 //Release the bus modules 55 for( Vector<module_info *>::Iterator i = m_busmodules.Begin() ; i != m_busmodules.End() ; i++ ) 56 put_module( (*i)->name ); 57 } 58 59 60 status_t Stack::InitCheck() 61 { 62 if ( m_busmodules.Count() == 0 ) 63 return ENODEV; 64 return B_OK; 65 } 66 67 Stack *data = 0; 68