- Timestamp:
- 02/22/07 10:55:06 (16 years ago)
- Files:
-
- branches/streaming-rework/configure.ac (modified) (1 diff)
- branches/streaming-rework/src/libieee1394/ARMHandler.cpp (added)
- branches/streaming-rework/src/libieee1394/ARMHandler.h (added)
- branches/streaming-rework/src/libieee1394/ieee1394service.cpp (modified) (10 diffs)
- branches/streaming-rework/src/libieee1394/ieee1394service.h (modified) (5 diffs)
- branches/streaming-rework/src/Makefile.am (modified) (2 diffs)
- branches/streaming-rework/tests/test-ieee1394service.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/configure.ac
r407 r414 25 25 m4_define(freebob_major_version, 1) 26 26 m4_define(freebob_minor_version, 999) 27 m4_define(freebob_micro_version, 2)27 m4_define(freebob_micro_version, 3) 28 28 29 29 m4_define(freebob_version, freebob_major_version.freebob_minor_version.freebob_micro_version) branches/streaming-rework/src/libieee1394/ieee1394service.cpp
r413 r414 20 20 */ 21 21 #include "ieee1394service.h" 22 #include "ARMHandler.h" 22 23 23 24 #include <libavc1394/avc1394.h> … … 57 58 stopRHThread(); 58 59 59 for ( arm_ mapping_vec_t::iterator it = m_arm_mappings.begin();60 it != m_arm _mappings.end();60 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); 61 it != m_armHandlers.end(); 61 62 ++it ) 62 63 { 63 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler for 0x%016llX\n", (*it)-> start);64 int err=raw1394_arm_unregister(m_resetHandle, (*it)-> start);64 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler for 0x%016llX\n", (*it)->getStart()); 65 int err=raw1394_arm_unregister(m_resetHandle, (*it)->getStart()); 65 66 if (err) { 66 debugError(" Failed to unregister ARM handler for 0x%016llX\n", (*it)-> start);67 debugError(" Failed to unregister ARM handler for 0x%016llX\n", (*it)->getStart()); 67 68 debugError(" Error: %s\n", strerror(errno)); 68 } else {69 delete *it;70 69 } 71 70 } … … 146 145 "read: node 0x%X, addr = 0x%016llX, length = %u\n", 147 146 nodeId, addr, length); 148 printBuffer( length, buffer );147 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, length, buffer ); 149 148 #endif 150 149 … … 190 189 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"write: node 0x%X, addr = 0x%016X, length = %d\n", 191 190 nodeId, addr, length); 192 printBuffer( length, data );191 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, length, data ); 193 192 #endif 194 193 … … 226 225 #ifdef DEBUG 227 226 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " pre avc1394_transaction_block2\n" ); 228 printBuffer( len, buf );227 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, len, buf ); 229 228 #endif 230 229 … … 239 238 #ifdef DEBUG 240 239 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " post avc1394_transaction_block2\n" ); 241 printBuffer( *resp_len, result );240 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, *resp_len, result ); 242 241 #endif 243 242 … … 271 270 272 271 void 273 Ieee1394Service::printBuffer( size_t length, fb_quadlet_t* buffer ) const272 Ieee1394Service::printBuffer( unsigned int level, size_t length, fb_quadlet_t* buffer ) const 274 273 { 275 274 … … 277 276 if ( ( i % 4 ) == 0 ) { 278 277 if ( i > 0 ) { 279 debugOutputShort( DEBUG_LEVEL_VERY_VERBOSE,"\n");278 debugOutputShort(level,"\n"); 280 279 } 281 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE," %4d: ",i*4); 282 } 283 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE,"%08X ",buffer[i]); 284 } 285 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE,"\n"); 280 debugOutputShort(level," %4d: ",i*4); 281 } 282 debugOutputShort(level,"%08X ",buffer[i]); 283 } 284 debugOutputShort(level,"\n"); 285 } 286 void 287 Ieee1394Service::printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const 288 { 289 290 for ( unsigned int i=0; i < length; ++i ) { 291 if ( ( i % 16 ) == 0 ) { 292 if ( i > 0 ) { 293 debugOutputShort(level,"\n"); 294 } 295 debugOutputShort(level," %4d: ",i*16); 296 } 297 debugOutputShort(level,"%02X ",buffer[i]); 298 } 299 debugOutputShort(level,"\n"); 286 300 } 287 301 … … 314 328 } 315 329 316 bool Ieee1394Service::registerARMrange(nodeaddr_t start, 317 size_t length, byte_t *initial_value, 318 arm_options_t access_rights, 319 arm_options_t notification_options, 320 arm_options_t client_transactions, 321 Functor* functor) { 322 debugOutput(DEBUG_LEVEL_VERBOSE, "Registering ARM handler for 0x%016llX, length %u\n", start,length); 323 324 arm_mapping_t *new_mapping=NULL; 325 new_mapping = new arm_mapping_t; 326 327 new_mapping->start=start; 328 new_mapping->length=length; 329 new_mapping->access_rights=access_rights; 330 new_mapping->notification_options=notification_options; 331 new_mapping->client_transactions=client_transactions; 332 new_mapping->functor=functor; 333 334 int err=raw1394_arm_register(m_resetHandle, start, 335 length, initial_value, (octlet_t)new_mapping, 336 access_rights, 337 notification_options, 338 client_transactions); 330 bool Ieee1394Service::registerARMhandler(ARMHandler *h) { 331 debugOutput(DEBUG_LEVEL_VERBOSE, "Registering ARM handler (%p) for 0x%016llX, length %u\n", 332 h, h->getStart(), h->getLength()); 333 334 int err=raw1394_arm_register(m_resetHandle, h->getStart(), 335 h->getLength(), h->getBuffer(), (octlet_t)h, 336 h->getAccessRights(), 337 h->getNotificationOptions(), 338 h->getClientTransactions()); 339 339 if (err) { 340 debugError("Failed to register ARM handler for 0x%016llX\n", start);340 debugError("Failed to register ARM handler for 0x%016llX\n", h->getStart()); 341 341 debugError(" Error: %s\n", strerror(errno)); 342 delete new_mapping;343 342 return false; 344 343 } 345 344 346 m_arm_mappings.push_back( new_mapping ); 347 348 return true; 349 } 350 351 bool Ieee1394Service::unregisterARMrange( nodeaddr_t start ) { 352 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler for 0x%016llX\n", start); 353 354 for ( arm_mapping_vec_t::iterator it = m_arm_mappings.begin(); 355 it != m_arm_mappings.end(); 345 m_armHandlers.push_back( h ); 346 347 return true; 348 } 349 350 bool Ieee1394Service::unregisterARMhandler( ARMHandler *h ) { 351 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016llX\n", 352 h, h->getStart()); 353 354 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); 355 it != m_armHandlers.end(); 356 356 ++it ) 357 357 { 358 if((*it) ->start == start) {359 int err=raw1394_arm_unregister(m_resetHandle, start);358 if((*it) == h) { 359 int err=raw1394_arm_unregister(m_resetHandle, h->getStart()); 360 360 if (err) { 361 debugError("Failed to unregister ARM handler for 0x%016llX\n", start);361 debugError("Failed to unregister ARM handler (%p)\n", h); 362 362 debugError(" Error: %s\n", strerror(errno)); 363 363 } else { 364 m_arm_mappings.erase(it); 365 delete *it; 364 m_armHandlers.erase(it); 366 365 return true; 367 366 } 368 367 } 369 368 } 370 debugOutput(DEBUG_LEVEL_VERBOSE, " no handlerfound!\n");371 369 debugOutput(DEBUG_LEVEL_VERBOSE, " handler not found!\n"); 370 372 371 return false; 373 372 } 374 373 /** 374 * @brief Tries to find a free ARM address range 375 * 376 * @param start address to start with 377 * @param length length of the block needed (bytes) 378 * @param step step to use when searching (bytes) 379 * @return The base address that is free, and 0xFFFFFFFFFFFFFFFF when failed 380 */ 381 nodeaddr_t Ieee1394Service::findFreeARMBlock( nodeaddr_t start, size_t length, size_t step ) { 382 debugOutput(DEBUG_LEVEL_VERBOSE, "Finding free ARM block of %d bytes, from 0x%016llX in steps of %d bytes\n", 383 length, start, step); 384 385 int cnt=0; 386 const int maxcnt=10; 387 int err=1; 388 while(err && cnt++ < maxcnt) { 389 // try to register 390 err=raw1394_arm_register(m_resetHandle, start, length, 0, 0, 0, 0, 0); 391 392 if (err) { 393 debugOutput(DEBUG_LEVEL_VERBOSE, " -> cannot use 0x%016llX\n", start); 394 debugError(" Error: %s\n", strerror(errno)); 395 start += step; 396 } else { 397 debugOutput(DEBUG_LEVEL_VERBOSE, " -> use 0x%016llX\n", start); 398 err=raw1394_arm_unregister(m_resetHandle, start); 399 if (err) { 400 debugOutput(DEBUG_LEVEL_VERBOSE, " error unregistering test handler\n"); 401 debugError(" Error: %s\n", strerror(errno)); 402 return 0xFFFFFFFFFFFFFFFFLLU; 403 } 404 return start; 405 } 406 } 407 debugOutput(DEBUG_LEVEL_VERBOSE, " Could not find free block in %d tries\n",cnt); 408 return 0xFFFFFFFFFFFFFFFFLLU; 409 410 } 411 375 412 int 376 413 Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle, … … 391 428 void *data) 392 429 { 393 for ( arm_ mapping_vec_t::iterator it = m_arm_mappings.begin();394 it != m_arm _mappings.end();430 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); 431 it != m_armHandlers.end(); 395 432 ++it ) 396 433 { 397 if((*it) == (arm_mapping_t *)arm_tag) { 398 debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016llX called\n", (*it)->start); 399 Functor* func = (*it)->functor; 400 ( *func )(); 434 if((*it) == (ARMHandler *)arm_tag) { 435 struct raw1394_arm_request_response *arm_req_resp; 436 arm_req_resp = (struct raw1394_arm_request_response *) data; 437 raw1394_arm_request_t arm_req=arm_req_resp->request; 438 raw1394_arm_response_t arm_resp=arm_req_resp->response; 439 440 debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016llX called\n", 441 (*it)->getStart()); 442 debugOutput(DEBUG_LEVEL_VERBOSE," request type : 0x%02X\n",request_type); 443 debugOutput(DEBUG_LEVEL_VERBOSE," request length : %04d\n",requested_length); 444 445 switch(request_type) { 446 case RAW1394_ARM_READ: 447 (*it)->handleRead(arm_req); 448 *arm_resp=*((*it)->getResponse()); 449 break; 450 case RAW1394_ARM_WRITE: 451 (*it)->handleWrite(arm_req); 452 *arm_resp=*((*it)->getResponse()); 453 break; 454 case RAW1394_ARM_LOCK: 455 (*it)->handleLock(arm_req); 456 *arm_resp=*((*it)->getResponse()); 457 break; 458 default: 459 debugWarning("Unknown request type received, ignoring...\n"); 460 } 461 401 462 return true; 402 463 } branches/streaming-rework/src/libieee1394/ieee1394service.h
r413 r414 1 1 /* Ieee1394Service.cpp 2 2 * Copyright (C) 2005,06 by Daniel Wagner 3 * Copyright (C) 2007 by Pieter Palmers 3 4 * 4 5 * This file is part of FreeBoB. … … 32 33 #include <vector> 33 34 35 class ARMHandler; 36 34 37 class Ieee1394Service{ 35 38 public: … … 127 130 128 131 /** 129 * @brief register an AddressRangeMapping 130 * 131 * @param start identifies addressrange 132 * @param length identifies addressrange length 133 * @param initial_value pointer to buffer containing (if necessary) initial value 134 * NULL means undefined 135 * @param access_rights access-rights for registered addressrange handled 136 * by kernel-part. Value is one or more binary or of the 137 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 138 * @param notification_options identifies for which type of request you want 139 * to be notified. Value is one or more binary or of the 140 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 141 * @param client_transactions identifies for which type of request you want 142 * to handle the request by the client application. 143 * for those requests no response will be generated, but 144 * has to be generated by the application. 145 * Value is one or more binary or of the 146 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 147 * For each bit set here, notification_options and 148 * access_rights will be ignored. 149 * @param functor the function to call when this range is written to 132 * @brief register an AddressRangeMapping Handler 133 * @param h pointer to the handler to register 150 134 * 151 135 * @return true on success or false on failure 152 136 **/ 153 137 154 bool registerARMrange(nodeaddr_t start, 155 size_t length, byte_t *initial_value, 156 arm_options_t access_rights, 157 arm_options_t notification_options, 158 arm_options_t client_transactions, 159 Functor* functor); 138 bool registerARMhandler( ARMHandler *h ); 160 139 161 140 /** 162 141 * @brief unregister ARM range 163 * @param start identifies addressrange142 * @param h pointer to the handler to unregister 164 143 * @return true if successful, false otherwise 165 144 */ 166 bool unregisterARMrange( nodeaddr_t start ); 145 bool unregisterARMhandler( ARMHandler *h ); 146 147 nodeaddr_t findFreeARMBlock( nodeaddr_t start, size_t length, size_t step ); 167 148 168 149 // ISO channel stuff … … 203 184 static void* rHThread( void* arg ); 204 185 205 void printBuffer( size_t length, fb_quadlet_t* buffer ) const; 206 186 void printBuffer( unsigned int level, size_t length, fb_quadlet_t* buffer ) const; 187 void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 188 207 189 static int resetHandlerLowLevel( raw1394handle_t handle, 208 190 unsigned int generation ); … … 231 213 arm_tag_handler_t m_default_arm_handler; 232 214 233 typedef struct arm_mapping { 234 nodeaddr_t start; 235 size_t length; 236 arm_options_t access_rights; 237 arm_options_t notification_options; 238 arm_options_t client_transactions; 239 Functor* functor; 240 } arm_mapping_t; 241 242 typedef std::vector< arm_mapping_t* > arm_mapping_vec_t; 243 arm_mapping_vec_t m_arm_mappings; 215 typedef std::vector< ARMHandler * > arm_handler_vec_t; 216 arm_handler_vec_t m_armHandlers; 244 217 245 218 DECLARE_DEBUG_MODULE; branches/streaming-rework/src/Makefile.am
r413 r414 32 32 libfreebob_la_LIBADD = -lrt 33 33 34 noinst_HEADERS = libieee1394/configrom.h libieee1394/csr1212.h \ 35 libieee1394/ieee1394service.h debugmodule/debugmodule.h \ 34 noinst_HEADERS = \ 35 libieee1394/configrom.h libieee1394/csr1212.h \ 36 libieee1394/ieee1394service.h libieee1394/ARMHandler.h \ 37 debugmodule/debugmodule.h \ 36 38 devicemanager.h fbtypes.h iavdevice.h threads.h bebob/bebob_avdevice.h \ 37 39 bebob/bebob_avdevice_subunit.h bebob/bebob_avplug.h bebob/bebob_dl_bcd.h bebob/bebob_dl_codes.h \ … … 76 78 libfreebobavc/avc_subunit_info.cpp \ 77 79 libfreebobavc/avc_unit_info.cpp \ 80 libieee1394/ARMHandler.cpp \ 78 81 libieee1394/configrom.cpp \ 79 82 libieee1394/csr1212.c \ branches/streaming-rework/tests/test-ieee1394service.cpp
r413 r414 36 36 #include "src/libieee1394/configrom.h" 37 37 #include "src/libieee1394/ieee1394service.h" 38 #include "src/libieee1394/ARMHandler.h" 38 39 39 40 #include <libraw1394/raw1394.h> … … 64 65 65 66 printf("Freebob Ieee1394Service test application\n"); 66 67 MyFunctor *test_busreset=new MyFunctor(); 68 MyFunctor *test_arm=new MyFunctor(); 69 67 70 68 Ieee1394Service *m_service=NULL; 71 69 … … 73 71 m_service->initialize(2); 74 72 73 MyFunctor *test_busreset=new MyFunctor(); 74 75 75 printf(" adding (%p) as busreset handler\n", test_busreset); 76 76 77 m_service->addBusResetHandler(test_busreset); 77 m_service->addBusResetHandler(test_busreset); 78 79 nodeaddr_t addr = m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 ); 80 81 ARMHandler *test_arm=new ARMHandler(addr, 82 4, 83 RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 84 RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 85 0); 78 86 79 87 printf(" adding (%p) as arm handler\n", test_arm); 80 88 81 m_service->registerARMrange(0x0000FFFFE0000000ULL, 82 8, NULL, 89 if (!m_service->registerARMhandler(test_arm)) { 90 printf(" failed\n"); 91 } 92 93 addr = m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 ); 94 95 ARMHandler *test_arm2=new ARMHandler(addr, 96 4, 83 97 RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 84 98 RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 85 0, 86 test_arm); 99 0); 100 101 printf(" adding (%p) as arm handler\n", test_arm2); 102 103 if (!m_service->registerARMhandler(test_arm2)) { 104 printf(" failed\n"); 105 } 87 106 88 107 while(run) { … … 91 110 sleep(1); 92 111 } 93 112 94 113 delete m_service; 95 114 delete test_busreset; 96 115 delete test_arm; 116 delete test_arm2; 97 117 98 118 printf("Bye...\n");