Changeset 276
- Timestamp:
- 06/27/06 14:46:41 (17 years ago)
- Files:
-
- branches/libfreebob-downloader/ChangeLog (modified) (1 diff)
- branches/libfreebob-downloader/configure.ac (modified) (1 diff)
- branches/libfreebob-downloader/src/bebob/bebob_avdevice.cpp (modified) (3 diffs)
- branches/libfreebob-downloader/src/bebob/bebob_avdevice.h (modified) (2 diffs)
- branches/libfreebob-downloader/src/bebob/bebob_dl_bcd.cpp (modified) (3 diffs)
- branches/libfreebob-downloader/src/bebob/bebob_dl_bcd.h (modified) (2 diffs)
- branches/libfreebob-downloader/src/bebob/bebob_dl_codes.cpp (modified) (2 diffs)
- branches/libfreebob-downloader/src/bebob/bebob_dl_codes.h (modified) (1 diff)
- branches/libfreebob-downloader/src/bebob/bebob_dl_mgr.cpp (modified) (23 diffs)
- branches/libfreebob-downloader/src/bebob_light/bebob_light_avdevice.cpp (deleted)
- branches/libfreebob-downloader/src/bebob_light/bebob_light_avdevice.h (deleted)
- branches/libfreebob-downloader/src/bebob_light/bebob_light_avdevicesubunit.cpp (deleted)
- branches/libfreebob-downloader/src/bebob_light/bebob_light_avdevicesubunit.h (deleted)
- branches/libfreebob-downloader/src/bebob_light/bebob_light_avplug.cpp (deleted)
- branches/libfreebob-downloader/src/bebob_light/bebob_light_avplug.h (deleted)
- branches/libfreebob-downloader/src/bounce/bounce_avdevice.cpp (modified) (1 diff)
- branches/libfreebob-downloader/src/configrom.cpp (modified) (6 diffs)
- branches/libfreebob-downloader/src/configrom.h (modified) (3 diffs)
- branches/libfreebob-downloader/src/devicemanager.cpp (modified) (6 diffs)
- branches/libfreebob-downloader/src/devicemanager.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-downloader/ChangeLog
r271 r276 1 2006-06-27 Daniel Wagner <wagi@monom.org> 2 3 * configure.ac: Version bump to 1.1.0 4 * remove bebob_light code 5 * downloader various improvements 6 * ConfigRom::isAvcDevice() removed. Device probe code added. 7 Each device driver class can check if it supports a device. 8 1 9 2006-06-21 Daniel Wagner <wagi@monom.org> 2 10 branches/libfreebob-downloader/configure.ac
r259 r276 23 23 24 24 m4_define(freebob_major_version, 1) 25 m4_define(freebob_minor_version, 0)25 m4_define(freebob_minor_version, 1) 26 26 m4_define(freebob_micro_version, 0) 27 27 branches/libfreebob-downloader/src/bebob/bebob_avdevice.cpp
r241 r276 39 39 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_NORMAL ); 40 40 41 AvDevice::AvDevice( Ieee1394Service& ieee1394service, 42 int nodeId, 43 int verboseLevel ) 44 : m_1394Service( &ieee1394service ) 41 AvDevice::AvDevice( std::auto_ptr< ConfigRom >( configRom ), 42 Ieee1394Service& ieee1394service, 43 int nodeId, 44 int verboseLevel ) 45 : m_configRom( configRom ) 46 , m_1394Service( &ieee1394service ) 45 47 , m_nodeId( nodeId ) 46 48 , m_verboseLevel( verboseLevel ) … … 52 54 debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", 53 55 nodeId ); 54 55 m_configRom = new ConfigRom( m_1394Service, m_nodeId );56 m_configRom->initialize();57 56 } 58 57 59 58 AvDevice::~AvDevice() 60 59 { 61 delete m_configRom;62 60 for ( AvDeviceSubunitVector::iterator it = m_subunits.begin(); 63 61 it != m_subunits.end(); … … 90 88 { 91 89 return *m_configRom; 90 } 91 92 struct VendorModelEntry { 93 unsigned int vendor_id; 94 unsigned int model_id; 95 }; 96 97 static VendorModelEntry supportedDeviceList[] = 98 { 99 {0x000d6c, 0x00010060}, // M-Audio, Audiophile 100 {0x0007f5, 0x00010048}, // BridgeCo, RD Audio1 101 }; 102 103 bool 104 AvDevice::probe( ConfigRom& configRom ) 105 { 106 unsigned int vendorId = configRom.getNodeVendorId(); 107 unsigned int modelId = configRom.getModelId(); 108 109 for ( unsigned int i = 0; 110 i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 111 ++i ) 112 { 113 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 114 && ( supportedDeviceList[i].model_id == modelId ) ) 115 { 116 return true; 117 } 118 } 119 120 return false; 92 121 } 93 122 branches/libfreebob-downloader/src/bebob/bebob_avdevice.h
r241 r276 42 42 class AvDevice : public IAvDevice { 43 43 public: 44 AvDevice( Ieee1394Service& ieee1394Service, 44 AvDevice( std::auto_ptr<ConfigRom>( configRom ), 45 Ieee1394Service& ieee1394Service, 45 46 int nodeId, 46 47 int verboseLevel ); 47 48 virtual ~AvDevice(); 48 49 50 static bool probe( ConfigRom& configRom ); 49 51 virtual bool discover(); 50 52 virtual ConfigRom& getConfigRom() const; … … 95 97 bool checkSyncConnections( AvPlugVector& plhs, AvPlugVector& prhs ); 96 98 protected: 99 std::auto_ptr<ConfigRom>( m_configRom ); 97 100 Ieee1394Service* m_1394Service; 98 ConfigRom* m_configRom;99 101 int m_nodeId; 100 102 int m_verboseLevel; branches/libfreebob-downloader/src/bebob/bebob_dl_bcd.cpp
r271 r276 99 99 , m_softwareId( 0 ) 100 100 , m_softwareVersion( 0 ) 101 , m_hardwareId( 0 ) 102 , m_vendorOUI( 0 ) 101 103 , m_imageBaseAddress( 0 ) 102 104 , m_imageLength( 0 ) … … 200 202 return false; 201 203 } 204 if ( !read( 0x20, &m_hardwareId ) ) { 205 return false; 206 } 207 if ( !read( 0x24, &m_vendorOUI ) ) { 208 return false; 209 } 202 210 if ( !read( 0x30, &m_imageOffset ) ) { 203 211 return false; … … 360 368 printf( "\tBCD File Version\t%d\n", m_bcd_version ); 361 369 printf( "\tSoftware Date:\t\t%s, %s\n", 362 makeDate( m_softwareDate ).c_str(),370 makeDate( m_softwareDate ).c_str(), 363 371 makeTime( m_softwareTime ).c_str() ); 364 372 printf( "\tSoftware Version:\t0x%08x\n", m_softwareVersion ); 365 373 printf( "\tSoftware Id:\t\t0x%08x\n", m_softwareId ); 374 printf( "\tHardware ID:\t\t0x%08x\n", m_hardwareId ); 375 printf( "\tVendor OUI:\t\t0x%08x\n", m_vendorOUI ); 366 376 printf( "\tImage Offset:\t\t0x%08x\n", m_imageOffset ); 367 377 printf( "\tImage Base Address:\t0x%08x\n", m_imageBaseAddress ); branches/libfreebob-downloader/src/bebob/bebob_dl_bcd.h
r271 r276 46 46 fb_quadlet_t getSoftwareVersion() const 47 47 { return m_softwareVersion; } 48 48 fb_quadlet_t getHardwareId() const 49 { return m_hardwareId; } 50 fb_quadlet_t getVendorOUI() const 51 { return m_vendorOUI; } 52 49 53 fb_quadlet_t getImageBaseAddress() const 50 54 { return m_imageBaseAddress; } … … 86 90 fb_quadlet_t m_softwareId; 87 91 fb_quadlet_t m_softwareVersion; 92 fb_quadlet_t m_hardwareId; 93 fb_quadlet_t m_vendorOUI; 94 88 95 89 96 fb_quadlet_t m_imageBaseAddress; branches/libfreebob-downloader/src/bebob/bebob_dl_codes.cpp
r271 r276 170 170 bool result = CommandCodes::serialize( se ); 171 171 172 fb_quadlet_t tmp;173 172 result &= se.write( m_object, "CommandCodesDownloadStart: object" ); 174 tmp = m_date >> 32;175 result &= se.write( tmp, "CommandCodesDownloadStart: date high");176 tmp = m_date & 0xffffffff;177 result &= se.write( tmp, "CommandCodesDownloadStart: date low" );178 tmp = m_time >> 32;179 result &= se.write( tmp , "CommandCodesDownloadStart: time high");180 tmp = m_time & 0xffffffff;181 result &= se.write( tmp, "CommandCodesDownloadStart: time low" );173 for ( unsigned int i = 0; i < sizeof( m_date ); ++i ) { 174 fb_byte_t* tmp = ( fb_byte_t* )( &m_date ); 175 result &= se.write( tmp[i], "CommandCodesDownloadStart: date" ); 176 } 177 for ( unsigned int i = 0; i < sizeof( m_date ); ++i ) { 178 fb_byte_t* tmp = ( fb_byte_t* )( &m_time ); 179 result &= se.write( tmp[i], "CommandCodesDownloadStart: time" ); 180 } 182 181 result &= se.write( m_id, "CommandCodesDownloadStart: id" ); 183 182 result &= se.write( m_version, "CommandCodesDownloadStart: version" ); … … 315 314 } 316 315 316 //////////////////////////////// 317 318 BeBoB::CommandCodesGo::CommandCodesGo( fb_quadlet_t protocolVersion, 319 EStartMode startMode ) 320 : CommandCodes( protocolVersion, eCmdC_Go, sizeof( m_startMode ), 1, 1 ) 321 , m_startMode( startMode ) 322 { 323 } 324 325 BeBoB::CommandCodesGo::~CommandCodesGo() 326 { 327 } 328 329 bool 330 BeBoB::CommandCodesGo::serialize( IOSSerialize& se ) 331 { 332 bool result = CommandCodes::serialize( se ); 333 result &= se.write( m_startMode, "CommandCodesGo: start mode" ); 334 335 return result; 336 } 337 338 bool 339 BeBoB::CommandCodesGo::deserialize( IISDeserialize& de ) 340 { 341 bool result = CommandCodes::deserialize( de ); 342 result &= de.read( &m_resp_validCRC ); 343 344 return result; 345 } branches/libfreebob-downloader/src/bebob/bebob_dl_codes.h
r271 r276 279 279 }; 280 280 281 ///////////////////////// 282 283 class CommandCodesGo : public CommandCodes { 284 public: 285 enum EStartMode { 286 eSM_Application = 0, 287 eSM_Debugger = 2, 288 }; 289 290 CommandCodesGo( fb_quadlet_t protocolVersion, EStartMode startMode ); 291 virtual ~CommandCodesGo(); 292 293 virtual bool serialize( IOSSerialize& se ); 294 virtual bool deserialize( IISDeserialize& de ); 295 296 EStartMode getStartMode() const 297 { return static_cast<EStartMode>( m_startMode ); } 298 bool setStartMode( EStartMode startMode ) 299 { m_startMode = startMode; return true; } 300 301 fb_quadlet_t getRespIsValidCRC() const 302 { return m_resp_validCRC; } 303 304 private: 305 fb_quadlet_t m_startMode; 306 fb_quadlet_t m_resp_validCRC; 307 }; 308 309 310 281 311 }; 282 312 #endif branches/libfreebob-downloader/src/bebob/bebob_dl_mgr.cpp
r271 r276 76 76 memset( &m_cachedInfoRegs, 0, sizeof( m_cachedInfoRegs ) ); 77 77 78 m_configRom = new ConfigRom( m_ieee1394service, nodeId );78 m_configRom = new ConfigRom( *m_ieee1394service, nodeId ); 79 79 // XXX throw exception if initialize fails! 80 80 m_configRom->initialize(); … … 214 214 using namespace std; 215 215 216 printf( "parse BCD file\n" ); 216 217 std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) ); 217 218 if ( !bcd.get() ) { … … 220 221 return false; 221 222 } 222 223 223 if ( !bcd->parse() ) { 224 224 debugError( "downloadFirmware: BCD parsing failed\n" ); … … 226 226 } 227 227 228 printf( "prepare for download (start bootloader)\n" ); 228 229 if ( !startBootloaderCmd() ) { 229 230 debugError( "downloadFirmware: Could not start bootloader\n" ); 230 231 return false; 231 232 } 232 waitForBusReset(); 233 if ( !cacheInfoRegisters( MaxRetries ) ) { 234 debugError( "downloadFirmware: Could not read info registers\n" ); 235 return false; 236 } 237 238 // wait for bootloader finish startup sequence 239 // there is no way to find out when it has finished 240 sleep( 10 ); 241 233 234 printf( "start downloading protocol for application image\n" ); 242 235 if ( !downloadObject( *bcd, eOT_Application ) ) { 243 236 debugError( "downloadFirmware: Firmware download failed\n" ); … … 245 238 } 246 239 240 printf( "start downloading protocol for CnE\n" ); 247 241 if ( !downloadObject( *bcd, eOT_CnE ) ) { 248 242 debugError( "downloadFirmware: CnE download failed\n" ); … … 250 244 } 251 245 252 sleep( 5 ); 253 254 // Let's try to start the image in any case... 246 printf( "setting CnE to factory default settings\n" ); 247 if ( !initializeConfigToFactorySettingCmd() ) { 248 debugError( "downloadFirmware: Could not reinitalize CnE\n" ); 249 return false; 250 } 251 252 printf( "start application\n" ); 255 253 if ( !startApplicationCmd() ) { 256 254 debugError( "downloadFirmware: Could not restart application\n" ); … … 266 264 using namespace std; 267 265 266 printf( "parse BCD file\n" ); 268 267 std::auto_ptr<BCD> bcd = std::auto_ptr<BCD>( new BCD( filename ) ); 269 268 if ( !bcd.get() ) { … … 272 271 return false; 273 272 } 274 275 273 if ( !bcd->parse() ) { 276 274 debugError( "downloadCnE: BCD parsing failed\n" ); … … 278 276 } 279 277 278 printf( "prepare for download (start bootloader)\n" ); 280 279 if ( !startBootloaderCmd() ) { 281 280 debugError( "downloadCnE: Could not start bootloader\n" ); 282 281 return false; 283 282 } 284 waitForBusReset(); 285 if ( !cacheInfoRegisters( MaxRetries ) ) { 286 debugError( "downloadCnE: Could not read info registers\n" ); 287 return false; 288 } 289 290 // wait for bootloader finish startup sequence 291 // there is no way to find out when it has finished 292 sleep( 10 ); 293 294 get1394Serivce()->setVerbose( true ); 295 283 284 printf( "start downloading protocol for CnE\n" ); 296 285 if ( !downloadObject( *bcd, eOT_CnE ) ) { 297 286 debugError( "downloadCnE: CnE download failed\n" ); … … 299 288 } 300 289 290 printf( "setting CnE to factory default settings\n" ); 301 291 if ( !initializeConfigToFactorySettingCmd() ) { 302 debugError( "downloadCnE: Setting default config " 303 "settings failed\n" ); 304 return false; 305 } 306 307 sleep( 5 ); 308 309 // Let's try to start the image in any case... 292 debugError( "downloadFirmware: Could not reinitalize CnE\n" ); 293 return false; 294 } 295 296 printf( "start application\n" ); 310 297 if ( !startApplicationCmd() ) { 311 298 debugError( "downloadCnE: Could not restart application\n" ); … … 363 350 // bootloader erases the flash, have to wait until is ready 364 351 // to answer our next request 352 printf( "wait unitl flash ereasing has terminated\n" ); 365 353 sleep( 20 ); 366 354 … … 380 368 fb_quadlet_t address = 0; 381 369 bool result = true; 382 int nrBlocks = ( imageLength + maxBlockSize - 1 ) / maxBlockSize; 370 int totalBytes = imageLength; 371 int downloadedBytes = 0; 383 372 while ( imageLength > 0 ) { 384 373 unsigned int blockSize = imageLength > maxBlockSize ? … … 412 401 break; 413 402 } 414 usleep( 100 0);403 usleep( 100 ); 415 404 416 405 if ( !readResponse( ccBlock ) ) { … … 434 423 } 435 424 436 if ( ( i % 1000 ) == 0 ) { 437 printf( "[%04d/%04d] packets downloaded\n", i, nrBlocks ); 425 downloadedBytes += blockSize; 426 if ( ( i % 100 ) == 0 ) { 427 printf( "%10d/%d bytes downloaded\n", 428 downloadedBytes, totalBytes ); 438 429 } 439 430 … … 443 434 i++; 444 435 } 436 printf( "%10d/%d bytes downloaded\n", 437 downloadedBytes, totalBytes ); 445 438 446 439 if ( !result ) { … … 456 449 } 457 450 451 printf( "wait for transaction completion\n" ); 458 452 sleep( 10 ); 459 453 … … 478 472 } 479 473 } 474 printf( "download protocol successfuly completed\n" ); 480 475 return result; 481 476 } … … 488 483 return false; 489 484 } 490 491 waitForBusReset();492 if ( !cacheInfoRegisters( MaxRetries ) ) {493 debugError( "programGUID: Could not read info registers\n" );494 return false;495 }496 497 // wait for bootloader finish startup sequence498 // there is no way to find out when it has finished499 sleep( 10 );500 485 501 486 if ( !programGUIDCmd( guid ) ) { … … 609 594 } 610 595 596 waitForBusReset(); 597 if ( !cacheInfoRegisters( MaxRetries ) ) { 598 debugError( "startBootloaderCmd: Could not read info registers\n" ); 599 return false; 600 } 601 602 // wait for bootloader finish startup sequence 603 // there is no way to find out when it has finished 604 sleep( 10 ); 605 611 606 return true; 612 607 } … … 615 610 BeBoB::BootloaderManager::startApplicationCmd() 616 611 { 617 CommandCodes Resetcmd( m_protocolVersion,618 CommandCodes Reset::eSM_Application ) ;612 CommandCodesGo cmd( m_protocolVersion, 613 CommandCodesGo::eSM_Application ) ; 619 614 if ( !writeRequest( cmd ) ) { 620 615 debugError( "startApplicationCmd: writeRequest failed\n" ); … … 634 629 } 635 630 631 sleep( 1 ); 632 636 633 return true; 637 634 } … … 646 643 } 647 644 645 sleep( 1 ); 646 648 647 return true; 649 648 } … … 658 657 } 659 658 660 return true; 661 } 659 sleep( 5 ); 660 661 return true; 662 } branches/libfreebob-downloader/src/bounce/bounce_avdevice.cpp
r241 r276 47 47 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce::BounceDevice (NodeID %d)\n", 48 48 nodeId ); 49 m_configRom = new ConfigRom( m_1394Service, m_nodeId );49 m_configRom = new ConfigRom( *m_1394Service, m_nodeId ); 50 50 m_configRom->initialize(); 51 51 } branches/libfreebob-downloader/src/configrom.cpp
r271 r276 30 30 using namespace std; 31 31 32 IMPL_DEBUG_MODULE( ConfigRom, ConfigRom, DEBUG_LEVEL_ NORMAL);32 IMPL_DEBUG_MODULE( ConfigRom, ConfigRom, DEBUG_LEVEL_VERBOSE ); 33 33 34 34 static int busRead( struct csr1212_csr* csr, … … 55 55 //------------------------------------------------------------- 56 56 57 ConfigRom::ConfigRom( Ieee1394Service *ieee1394service, fb_nodeid_t nodeId )58 : m_1394Service( ieee1394service )57 ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ) 58 : m_1394Service( &ieee1394service ) 59 59 , m_nodeId( nodeId ) 60 60 , m_avcDevice( false ) … … 103 103 104 104 // Process Bus_Info_Block 105 m_isIsoResourceManager = m_csr->bus_info_data[2]>> 31;106 m_isCycleMasterCapable = ( m_csr->bus_info_data[2]>> 30 ) & 0x1;107 m_isSupportIsoOperations = ( m_csr->bus_info_data[2]>> 29 ) & 0x1;108 m_isBusManagerCapable = ( m_csr->bus_info_data[2]>> 28 ) & 0x1;109 m_cycleClkAcc = ( m_csr->bus_info_data[2]>> 16 ) & 0xff;110 m_maxRec = ( m_csr->bus_info_data[2]>> 12 ) & 0xf;111 m_nodeVendorId = ( m_csr->bus_info_data[3]>> 8 );112 m_chipIdHi = ( m_csr->bus_info_data[3]) & 0xff;113 m_chipIdLow = m_csr->bus_info_data[4];105 m_isIsoResourceManager = CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 31; 106 m_isCycleMasterCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 30 ) & 0x1; 107 m_isSupportIsoOperations = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 29 ) & 0x1; 108 m_isBusManagerCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 28 ) & 0x1; 109 m_cycleClkAcc = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 16 ) & 0xff; 110 m_maxRec = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[2] ) >> 12 ) & 0xf; 111 m_nodeVendorId = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) >> 8 ); 112 m_chipIdHi = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) ) & 0xff; 113 m_chipIdLow = CSR1212_BE32_TO_CPU( m_csr->bus_info_data[4] ); 114 114 115 115 // Process Root Directory … … 173 173 } 174 174 175 const bool176 ConfigRom::isAvcDevice() const177 {178 return m_avcDevice;179 }180 181 // XXX This might work only for the M-Audio Audiophile182 // but can easily extended.183 #define VENDOR_ID_MAUDIO 0x00000d6c184 #define MODEL_ID_MAUDIO_BOOTLOADER 0x00010060185 186 const bool187 ConfigRom::isBootloader() const188 {189 if ( ( m_vendorId == VENDOR_ID_MAUDIO )190 && ( m_modelId == MODEL_ID_MAUDIO_BOOTLOADER ) )191 {192 return true;193 }194 return false;195 }196 197 175 static int 198 176 busRead( struct csr1212_csr* csr, … … 434 412 { 435 413 using namespace std; 436 cout << "Config ROM" << endl; 437 cout << "\tCurrent Node Id:\t" << getNodeId() << endl; 438 cout << "\tGUID:\t\t\t0x" << setfill( '0' ) << setw( 16 ) << hex << getGuid() << endl; 439 cout << "\tVendor Name:\t\t" << getVendorName() << endl; 440 cout << "\tModel Name:\t\t" << getModelName() << endl; 414 printf( "Config ROM\n" ); 415 printf( "\tCurrent Node Id:\t%d\n", getNodeId() ); 416 printf( "\tGUID:\t\t\t0x%08x%08x\n", 417 ( unsigned int )( getGuid() >> 32 ), 418 ( unsigned int ) ( getGuid() & 0xffffffff ) ); 419 printf( "\tVendor Name:\t\t%s\n", getVendorName().c_str() ); 420 printf( "\tModel Name:\t\t%s\n", getModelName().c_str() ); 421 printf( "\tNode Vendor ID:\t\t0x%06x\n", getNodeVendorId() ); 422 printf( "\tModel Id:\t\t0x%08x\n", getModelId() ); 423 printf( "\tISO resource manager:\t%d\n", isIsoResourseManager() ); 424 printf( "\tCycle master capable:\t%d\n", isSupportsIsoOperations() ); 425 printf( "\tBus manager capable:\t%d\n", isBusManagerCapable() ); 426 printf( "\tCycle clock accurancy:\t%d\n", getCycleClockAccurancy() ); 427 printf( "\tMax rec:\t\t%d (max asy payload: %d bytes)\n", 428 getMaxRec(), getAsyMaxPayload() ); 441 429 } 442 430 … … 444 432 ConfigRom::getAsyMaxPayload() const 445 433 { 446 // XXX use pow instead 434 // XXX use pow instead? 447 435 return 1 << ( m_maxRec + 1 ); 448 436 } branches/libfreebob-downloader/src/configrom.h
r271 r276 33 33 class ConfigRom { 34 34 public: 35 ConfigRom( Ieee1394Service *ieee1394service, fb_nodeid_t nodeId );35 ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ); 36 36 virtual ~ConfigRom(); 37 37 38 38 bool initialize(); 39 39 40 const bool isAvcDevice() const;41 const bool isBootloader() const;42 40 const fb_nodeid_t getNodeId() const; 43 41 const fb_octlet_t getGuid() const; … … 57 55 { return m_maxRec; } 58 56 unsigned short getAsyMaxPayload() const; 57 58 fb_quadlet_t getNodeVendorId() const 59 { return m_nodeVendorId; } 60 unsigned int getModelId() const 61 { return m_modelId; } 59 62 60 63 bool updatedNodeId(); … … 83 86 fb_byte_t m_cycleClkAcc; 84 87 fb_byte_t m_maxRec; 85 unsigned shortm_nodeVendorId;88 fb_quadlet_t m_nodeVendorId; 86 89 fb_byte_t m_chipIdHi; 87 90 fb_quadlet_t m_chipIdLow; branches/libfreebob-downloader/src/devicemanager.cpp
r241 r276 1 /* devicemanager.cpp1 /* devicemanager.cpp 2 2 * Copyright (C) 2005,06 by Daniel Wagner 3 3 * … … 28 28 #include "debugmodule/debugmodule.h" 29 29 #include "bebob/bebob_avdevice.h" 30 #include "bebob_light/bebob_light_avdevice.h"31 30 #include "bounce/bounce_avdevice.h" 32 31 … … 40 39 : m_1394Service( 0 ) 41 40 { 42 m_probeList.push_back( probeBeBoB );43 // m_probeList.push_back( probeBounce );44 41 } 45 42 … … 93 90 ++nodeId ) 94 91 { 95 ConfigRom configRom( m_1394Service, nodeId ); 96 if ( !configRom.initialize() ) { 97 // \todo If a PHY on the bus in power safe mode than 92 std::auto_ptr<ConfigRom> configRom = 93 std::auto_ptr<ConfigRom>( new ConfigRom( *m_1394Service, 94 nodeId ) ); 95 if ( !configRom->initialize() ) { 96 // \todo If a PHY on the bus is in power safe mode then 98 97 // the config rom is missing. So this might be just 99 // such acase and we can safely skip it. But it might98 // such this case and we can safely skip it. But it might 100 99 // be there is a real software problem on our side. 101 100 // This should be handled more carefuly. … … 107 106 } 108 107 109 if ( !configRom.isAvcDevice() ) { 110 continue; 111 } 112 113 for ( ProbeFunctionVector::iterator it = m_probeList.begin(); 114 it != m_probeList.end(); 115 ++it ) 116 { 117 ProbeFunction func = *it; 118 IAvDevice* avDevice = func(*m_1394Service, nodeId, verboseLevel); 119 if ( avDevice ) { 120 m_avDevices.push_back( avDevice ); 121 122 if ( !avDevice->setId( m_avDevices.size() ) ) { 123 debugError( "setting Id failed\n" ); 124 } 125 if ( verboseLevel ) { 126 avDevice->showDevice(); 127 } 128 break; 108 configRom->printConfigRom(); 109 IAvDevice* avDevice = getDriverForDevice( configRom, 110 nodeId, 111 verboseLevel ); 112 if ( avDevice ) { 113 debugOutput( DEBUG_LEVEL_NORMAL, 114 "discover: driver found for device %d\n", 115 nodeId ); 116 117 if ( !avDevice->discover() ) { 118 debugError( "discover: could not discover device\n" ); 119 delete avDevice; 120 continue; 129 121 } 130 } 131 122 123 if ( !avDevice->setId( m_avDevices.size() ) ) { 124 debugError( "setting Id failed\n" ); 125 } 126 if ( verboseLevel ) { 127 avDevice->showDevice(); 128 } 129 130 m_avDevices.push_back( avDevice ); 131 } 132 132 } 133 133 … … 137 137 138 138 IAvDevice* 139 DeviceManager::probeBeBoB(Ieee1394Service& service, int id, int level) 140 { 141 IAvDevice* avDevice = new BeBoB_Light::AvDevice( service, id, level ); 142 if ( !avDevice ) { 143 return 0; 144 } 145 146 if ( !avDevice->discover() ) { 147 delete avDevice; 148 return 0; 149 } 150 return avDevice; 151 } 152 153 IAvDevice* 154 DeviceManager::probeBounce(Ieee1394Service& service, int id, int level) 155 { 156 IAvDevice* avDevice = new Bounce::BounceDevice( service, id, level ); 157 if ( !avDevice ) { 158 return 0; 159 } 160 161 if ( !avDevice->discover() ) { 162 delete avDevice; 163 return 0; 164 } 165 return avDevice; 139 DeviceManager::getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 140 int id, int level ) 141 { 142 if ( BeBoB::AvDevice::probe( *configRom.get() ) ) { 143 return new BeBoB::AvDevice( configRom, *m_1394Service, id, level ); 144 } 145 146 return 0; 166 147 } 167 148 branches/libfreebob-downloader/src/devicemanager.h
r241 r276 34 34 typedef std::vector< IAvDevice* >::iterator IAvDeviceVectorIterator; 35 35 36 typedef IAvDevice* (*ProbeFunction)(Ieee1394Service&, int, int); 37 typedef std::vector<ProbeFunction> ProbeFunctionVector; 38 typedef std::vector<ProbeFunction>::iterator ProbeFunctionVectorIterator; 36 class ConfigRom; 39 37 40 38 class DeviceManager{ … … 57 55 58 56 protected: 59 static IAvDevice* probeBeBoB(Ieee1394Service& service, int id, int level); 60 static IAvDevice* probeBounce(Ieee1394Service& service, int id, int level); 57 IAvDevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 58 int id, 59 int level ); 61 60 62 61 protected: 63 62 Ieee1394Service* m_1394Service; 64 63 IAvDeviceVector m_avDevices; 65 ProbeFunctionVector m_probeList;66 64 67 65 DECLARE_DEBUG_MODULE;