Changeset 435 for trunk/kernel/fs/fatfs.c
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/fatfs.c
r407 r435 262 262 "no FAT access required for first page\n"); 263 263 264 fatfs_dmsg("\n[DBG] %s : core[%x,%d] enters / first_cluster_id = %d / searched_index = %d\n", 265 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first_cluster_id, searched_page_index ); 264 #if CONFIG_DEBUG_FATFS_GET_CLUSTER 265 uint32_t cycle = (uint32_t)hal_get_cycles(); 266 if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle ) 267 printk("\n[DBG] %s : thread %x enter / first_cluster_id %d / searched_index / cycle %d\n", 268 __FUNCTION__, CURRENT_THREAD, first_cluster_id, searched_page_index, cycle ); 269 #endif 266 270 267 271 // get number of FAT slots per page … … 289 293 next_cluster_id = current_page_buffer[current_page_offset]; 290 294 291 fatfs_dmsg("\n[DBG] %s : core[%x,%d] traverse FAT / current_page_index = %d\n" 295 #if (CONFIG_DEBUG_FATFS_GET_CLUSTER & 1) 296 if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle ) 297 printk("\n[DBG] %s : traverse FAT / current_page_index = %d\n" 292 298 "current_page_offset = %d / next_cluster_id = %d\n", 293 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, current_page_index,294 current_page_offset , next_cluster_id ); 299 __FUNCTION__, current_page_index, current_page_offset , next_cluster_id ); 300 #endif 295 301 296 302 // update loop variables … … 302 308 if( next_cluster_id == 0xFFFFFFFF ) return EIO; 303 309 304 fatfs_dmsg("\n[DBG] %s : core[%x;%d] exit / cluster_id = %d\n", 305 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, next_cluster_id ); 310 #if CONFIG_DEBUG_FATFS_GET_CLUSTER 311 cycle = (uint32_t)hal_get_cycles(); 312 if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle ) 313 printk("\n[DBG] %s : thread %x exit / searched_cluster_id = %d / cycle %d\n", 314 __FUNCTION__, CURRENT_THREAD, next_cluster_id / cycle ); 315 #endif 306 316 307 317 *searched_cluster_id = next_cluster_id; … … 335 345 uint8_t * buffer; 336 346 337 fatfs_dmsg("\n[DBG] %s : enter for fatfs_ctx = %x\n", 338 __FUNCTION__ , fatfs_ctx ); 347 #if CONFIG_DEBUG_FATFS_INIT 348 uint32_t cycle = (uint32_t)hal_get_cycles(); 349 if( CONFIG_DEBUG_FATFS_INIT < cycle ) 350 printk("\n[DBG] %s : thread %x enter for fatfs_ctx = %x / cycle %d\n", 351 __FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle ); 352 #endif 339 353 340 354 assert( (fatfs_ctx != NULL) , __FUNCTION__ , 341 355 "cannot allocate memory for FATFS context\n" ); 342 356 343 357 // allocate a 512 bytes buffer to store the boot record … … 347 361 348 362 assert( (buffer != NULL) , __FUNCTION__ , 349 363 "cannot allocate memory for 512 bytes buffer\n" ); 350 364 351 fatfs_dmsg("\n[DBG] %s : allocated 512 bytes buffer\n", __FUNCTION__ );352 353 365 // load the boot record from device 354 366 // using a synchronous access to IOC device 355 367 error = dev_ioc_sync_read( buffer , 0 , 1 ); 356 368 357 fatfs_dmsg("\n[DBG] %s : buffer loaded\n", __FUNCTION__ ); 358 359 assert( (error == 0) , __FUNCTION__ , "cannot access boot record\n" ); 360 361 #if (CONFIG_FATFS_DEBUG & 0x1) 362 if( hal_time_stamp() > CONFIG_FATFS_DEBUG ) 369 assert( (error == 0) , __FUNCTION__ , 370 "cannot access boot record\n" ); 371 372 #if (CONFIG_DEBUG_FATFS_INIT & 0x1) 373 if( CONFIG_DEBUG_FATFS_INIT < cycle ) 363 374 { 364 375 uint32_t line; … … 389 400 390 401 assert( (nb_sectors == 8) , __FUNCTION__ , 391 402 "cluster size must be 8 sectors\n" ); 392 403 393 404 // check number of FAT copies from boot record … … 395 406 396 407 assert( (nb_fats == 1) , __FUNCTION__ , 397 408 "number of FAT copies must be 1\n" ); 398 409 399 410 // get & check number of sectors in FAT from boot record … … 401 412 402 413 assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ , 403 414 "FAT not multiple of 16 sectors\n"); 404 415 405 416 // get and check root cluster from boot record … … 407 418 408 419 assert( (root_cluster == 2) , __FUNCTION__ , 409 420 "root cluster index must be 2\n"); 410 421 411 422 // get FAT lba from boot record … … 417 428 kmem_free( &req ); 418 429 419 fatfs_dmsg("\n[DBG] %s : boot record read & released\n",420 __FUNCTION__ );421 422 430 // allocate a mapper for the FAT itself 423 431 mapper_t * fat_mapper = mapper_create( FS_TYPE_FATFS ); 424 432 425 assert( (fat_mapper != NULL) , __FUNCTION__ , "no memory for FAT mapper" ); 433 assert( (fat_mapper != NULL) , __FUNCTION__ , 434 "no memory for FAT mapper" ); 426 435 427 436 // WARNING : the inode field MUST be NULL for the FAT mapper … … 439 448 fatfs_ctx->fat_mapper_xp = XPTR( local_cxy , fat_mapper ); 440 449 441 fatfs_dmsg("\n[DBG] %s : exit for fatfs_ctx = %x\n", __FUNCTION__ , fatfs_ctx ); 450 #if CONFIG_DEBUG_FATFS_INIT 451 cycle = (uint32_t)hal_get_cycles(); 452 if( CONFIG_DEBUG_FATFS_INIT < cycle ) 453 printk("\n[DBG] %s : thread %x exit for fatfs_ctx = %x / cycle %d\n", 454 __FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle ); 455 #endif 442 456 443 457 } // end fatfs_ctx_init() … … 472 486 inode = mapper->inode; 473 487 474 fatfs_dmsg("\n[DBG] %s : core[%x,%d] enter for page %d / inode %x / mapper %x\n", 475 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper ); 488 #if CONFIG_DEBUG_FATFS_MOVE 489 uint32_t cycle = (uint32_t)hal_get_cycles(); 490 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 491 printk("\n[DBG] %s : thread %x enter / page %d / inode %x / mapper %x / cycle %d\n", 492 __FUNCTION__ , CURRENT_THREAD , index , inode , mapper , cycle ); 493 #endif 476 494 477 495 // get page base address … … 489 507 lba = fatfs_ctx->fat_begin_lba + (count * index); 490 508 491 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access FAT on device / lba = %d\n", 492 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba ); 509 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 510 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 511 printk("\n[DBG] %s : access FAT on device / lba = %d\n", __FUNCTION__ , lba ); 512 #endif 493 513 494 514 // access device … … 521 541 { 522 542 523 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access local FAT mapper\n" 543 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 544 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 545 print("\n[DBG] %s : access local FAT mapper\n" 524 546 "fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n", 525 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , 526 fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 527 547 __FUNCTION__ , fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 548 #endif 528 549 error = fatfs_get_cluster( fat_mapper_ptr, 529 550 first_cluster_id, … … 534 555 { 535 556 536 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access remote FAT mapper\n" 557 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 558 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 559 printk("\n[DBG] %s : access remote FAT mapper\n" 537 560 "fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n", 538 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , 539 fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 540 561 __FUNCTION__ , fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 562 #endif 541 563 rpc_fatfs_get_cluster_client( fat_mapper_cxy, 542 564 fat_mapper_ptr, … … 550 572 } 551 573 552 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access device for inode %x / cluster_id %d\n", 553 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , searched_cluster_id ); 574 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 575 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 576 printk("\n[DBG] %s : access device for inode %x / cluster_id %d\n", 577 __FUNCTION__ , inode , searched_cluster_id ); 578 #endif 554 579 555 580 // get lba from cluster_id … … 563 588 } 564 589 565 fatfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / inode %x / mapper %x\n", 566 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper ); 567 568 #if (CONFIG_FATFS_DEBUG & 0x1) 569 if( hal_time_stamp() > CONFIG_FATFS_DEBUG ) 590 #if CONFIG_DEBUG_FATFS_MOVE 591 cycle = (uint32_t)hal_get_cycles(); 592 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 593 printk("\n[DBG] %s : thread %x exit / page %d / inode %x / mapper %x / cycle %d\n", 594 __FUNCTION__ , CURRENT_THREAD , index , inode , mapper , cycle ); 595 #endif 596 597 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 598 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 570 599 { 571 600 uint32_t * tab = (uint32_t *)buffer; … … 594 623 // - scan the directory entries in each 4 Kbytes page 595 624 596 fatfs_dmsg("\n[DBG] %s : enter for child <%s> in parent inode %l\n", 597 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) ); 625 #if CONFIG_DEBUG_FATFS_LOAD 626 uint32_t cycle = (uint32_t)hal_get_cycles(); 627 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 628 printk("\n[DBG] %s : thread %x enter for child <%s> in parent inode %x / cycle %d\n", 629 __FUNCTION__ , CURRENT_THREAD , name , parent_inode , cycle ); 630 #endif 598 631 599 632 mapper_t * mapper = parent_inode->mapper; … … 632 665 base = (uint8_t *)GET_PTR( base_xp ); 633 666 634 #if (CONFIG_ FATFS_DEBUG& 0x1)635 if( hal_time_stamp() > CONFIG_FATFS_DEBUG)667 #if (CONFIG_DEBUG_FATFS_LOAD & 0x1) 668 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 636 669 { 637 670 uint32_t * buf = (uint32_t *)base; … … 716 749 { 717 750 718 fatfs_dmsg("\n[DBG] %s : exit / child <%s> not found in parent inode %l\n", 719 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) ); 751 #if CONFIG_DEBUG_FATFS_LOAD 752 cycle = (uint32_t)hal_get_cycles(); 753 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 754 printk("\n[DBG] %s : thread %x exit / child <%s> not found / cycle %d\n", 755 __FUNCTION__ , CURRENT_THREAD, name, cycle ); 756 #endif 720 757 721 758 return ENOENT; … … 734 771 hal_remote_sw( XPTR( child_cxy , &child_ptr->extend ) , cluster ); 735 772 736 fatfs_dmsg("\n[DBG] %s : exit / child <%s> found in parent inode %l\n", 737 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) ); 773 #if CONFIG_DEBUG_FATFS_LOAD 774 cycle = (uint32_t)hal_get_cycles(); 775 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 776 printk("\n[DBG] %s : thread %x exit / child <%s> loaded / cycle %d\n", 777 __FUNCTION__ , CURRENT_THREAD, name, cycle ); 778 #endif 738 779 739 780 return 0;
Note: See TracChangeset
for help on using the changeset viewer.