Changeset 435 for trunk/kernel/fs


Ignore:
Timestamp:
Feb 20, 2018, 5:32:17 PM (6 years ago)
Author:
alain
Message:

Fix a bad bug in scheduler...

Location:
trunk/kernel/fs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/devfs.c

    r433 r435  
    4242extern chdev_directory_t    chdev_dir;      // allocated in kernel_init.c
    4343
    44 #if CONFIG_READ_DEBUG
    45 extern uint32_t  enter_devfs_move;
    46 extern uint32_t  exit_devfs_move;
     44#if (CONFIG_DEBUG_SYS_READ & 1)
     45extern uint32_t  enter_devfs_read;
     46extern uint32_t  exit_devfs_read;
     47#endif
     48
     49#if (CONFIG_DEBUG_SYS_WRITE & 1)
     50extern uint32_t  enter_devfs_write;
     51extern uint32_t  exit_devfs_write;
    4752#endif
    4853
     
    375380    char               k_buf[CONFIG_TXT_KBUF_SIZE];  // local kernel buffer
    376381
     382#if (CONFIG_DEBUG_SYS_READ & 1)
     383enter_devfs_read = hal_time_stamp();
     384#endif
     385
     386#if (CONFIG_DEBUG_SYS_WRITE & 1)
     387enter_devfs_write = hal_time_stamp();
     388#endif
     389
    377390#if CONFIG_DEBUG_DEVFS_MOVE
    378391uint32_t cycle = (uint32_t)hal_get_cycles();
     
    380393printk("\n[DBG] %s : thread %x enter / to_mem %d / cycle %d\n",
    381394__FUNCTION__ , CURRENT_THREAD , to_buffer , cycle );
    382 #endif
    383 
    384 #if CONFIG_READ_DEBUG
    385 enter_devfs_move = hal_time_stamp();
    386395#endif
    387396
     
    424433#endif
    425434
    426 #if CONFIG_READ_DEBUG
    427 exit_devfs_move = hal_time_stamp();
     435#if (CONFIG_DEBUG_SYS_READ & 1)
     436exit_devfs_read = hal_time_stamp();
    428437#endif
    429438            return size;
     
    448457#endif
    449458
     459#if (CONFIG_DEBUG_SYS_WRITE & 1)
     460exit_devfs_write = hal_time_stamp();
     461#endif
    450462                return size;
    451463            }
  • trunk/kernel/fs/fatfs.c

    r407 r435  
    262262    "no FAT access required for first page\n");
    263263
    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
     265uint32_t cycle = (uint32_t)hal_get_cycles();
     266if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle )
     267printk("\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
    266270
    267271    // get number of FAT slots per page
     
    289293        next_cluster_id = current_page_buffer[current_page_offset];
    290294
    291 fatfs_dmsg("\n[DBG] %s : core[%x,%d] traverse FAT / current_page_index = %d\n"
     295#if (CONFIG_DEBUG_FATFS_GET_CLUSTER & 1)
     296if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle )
     297printk("\n[DBG] %s : traverse FAT / current_page_index = %d\n"
    292298"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
    295301
    296302        // update loop variables
     
    302308    if( next_cluster_id == 0xFFFFFFFF ) return EIO;
    303309   
    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
     311cycle = (uint32_t)hal_get_cycles();
     312if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle )
     313printk("\n[DBG] %s : thread %x exit / searched_cluster_id = %d / cycle %d\n",
     314__FUNCTION__, CURRENT_THREAD, next_cluster_id / cycle );
     315#endif
    306316
    307317    *searched_cluster_id = next_cluster_id;
     
    335345    uint8_t     * buffer;
    336346
    337     fatfs_dmsg("\n[DBG] %s : enter for fatfs_ctx = %x\n",
    338                __FUNCTION__ , fatfs_ctx );
     347#if CONFIG_DEBUG_FATFS_INIT
     348uint32_t cycle = (uint32_t)hal_get_cycles();
     349if( CONFIG_DEBUG_FATFS_INIT < cycle )
     350printk("\n[DBG] %s : thread %x enter for fatfs_ctx = %x / cycle %d\n",
     351__FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle );
     352#endif
    339353
    340354    assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
    341                    "cannot allocate memory for FATFS context\n" );
     355    "cannot allocate memory for FATFS context\n" );
    342356
    343357    // allocate a 512 bytes buffer to store the boot record
     
    347361
    348362    assert( (buffer != NULL) , __FUNCTION__ ,
    349                    "cannot allocate memory for 512 bytes buffer\n" );
     363    "cannot allocate memory for 512 bytes buffer\n" );
    350364     
    351     fatfs_dmsg("\n[DBG] %s : allocated 512 bytes buffer\n", __FUNCTION__ );
    352 
    353365    // load the boot record from device
    354366    // using a synchronous access to IOC device 
    355367    error = dev_ioc_sync_read( buffer , 0 , 1 );
    356368
    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)
     373if( CONFIG_DEBUG_FATFS_INIT < cycle )
    363374{
    364375    uint32_t   line;
     
    389400
    390401    assert( (nb_sectors == 8) , __FUNCTION__ ,
    391             "cluster size must be 8 sectors\n" );
     402    "cluster size must be 8 sectors\n" );
    392403
    393404    // check number of FAT copies from boot record
     
    395406
    396407    assert( (nb_fats == 1) , __FUNCTION__ ,
    397             "number of FAT copies must be 1\n" );
     408    "number of FAT copies must be 1\n" );
    398409
    399410    // get & check number of sectors in FAT from boot record
     
    401412
    402413    assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ ,
    403             "FAT not multiple of 16 sectors\n");
     414    "FAT not multiple of 16 sectors\n");
    404415
    405416    // get and check root cluster from boot record
     
    407418
    408419    assert( (root_cluster == 2) , __FUNCTION__ ,
    409             "root cluster index must be  2\n");
     420    "root cluster index must be  2\n");
    410421
    411422    // get FAT lba from boot record
     
    417428    kmem_free( &req );
    418429
    419     fatfs_dmsg("\n[DBG] %s : boot record read & released\n",
    420                __FUNCTION__ );
    421 
    422430    // allocate a mapper for the FAT itself
    423431    mapper_t * fat_mapper = mapper_create( FS_TYPE_FATFS );
    424432
    425     assert( (fat_mapper != NULL) , __FUNCTION__ , "no memory for FAT mapper" );
     433    assert( (fat_mapper != NULL) , __FUNCTION__ ,
     434    "no memory for FAT mapper" );
    426435
    427436    // WARNING : the inode field MUST be NULL for the FAT mapper
     
    439448    fatfs_ctx->fat_mapper_xp         = XPTR( local_cxy , fat_mapper );
    440449
    441 fatfs_dmsg("\n[DBG] %s : exit for fatfs_ctx = %x\n", __FUNCTION__ , fatfs_ctx );
     450#if CONFIG_DEBUG_FATFS_INIT
     451cycle = (uint32_t)hal_get_cycles();
     452if( CONFIG_DEBUG_FATFS_INIT < cycle )
     453printk("\n[DBG] %s : thread %x exit for fatfs_ctx = %x / cycle %d\n",
     454__FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle );
     455#endif
    442456
    443457}  // end fatfs_ctx_init()
     
    472486    inode = mapper->inode;
    473487
    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
     489uint32_t cycle = (uint32_t)hal_get_cycles();
     490if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     491printk("\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
    476494
    477495    // get page base address
     
    489507        lba = fatfs_ctx->fat_begin_lba + (count * index);
    490508 
    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)
     510if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     511printk("\n[DBG] %s : access FAT on device / lba = %d\n", __FUNCTION__ , lba );
     512#endif
    493513
    494514        // access device
     
    521541            {
    522542
    523 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access local FAT mapper\n"
     543#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     544if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     545print("\n[DBG] %s : access local FAT mapper\n"
    524546"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
    528549                error = fatfs_get_cluster( fat_mapper_ptr,
    529550                                           first_cluster_id,
     
    534555            {
    535556
    536 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access remote FAT mapper\n"
     557#if (CONFIG_DEBUG_FATFS_MOVE & 0x1)
     558if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     559printk("\n[DBG] %s : access remote FAT mapper\n"
    537560"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
    541563                rpc_fatfs_get_cluster_client( fat_mapper_cxy,
    542564                                              fat_mapper_ptr,
     
    550572        }
    551573
    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)
     575if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     576printk("\n[DBG] %s : access device for inode %x / cluster_id %d\n",
     577__FUNCTION__ , inode , searched_cluster_id );
     578#endif
    554579
    555580        // get lba from cluster_id
     
    563588    }
    564589
    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
     591cycle = (uint32_t)hal_get_cycles();
     592if( CONFIG_DEBUG_FATFS_MOVE < cycle )
     593printk("\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)
     598if( CONFIG_DEBUG_FATFS_MOVE < cycle )
    570599{
    571600    uint32_t * tab = (uint32_t *)buffer;
     
    594623    // - scan the directory entries in each 4 Kbytes page
    595624
    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
     626uint32_t cycle = (uint32_t)hal_get_cycles();
     627if( CONFIG_DEBUG_FATFS_LOAD < cycle )
     628printk("\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
    598631
    599632    mapper_t * mapper = parent_inode->mapper;
     
    632665        base = (uint8_t *)GET_PTR( base_xp );
    633666
    634 #if (CONFIG_FATFS_DEBUG & 0x1)
    635 if( hal_time_stamp() > CONFIG_FATFS_DEBUG )
     667#if (CONFIG_DEBUG_FATFS_LOAD & 0x1)
     668if( CONFIG_DEBUG_FATFS_LOAD < cycle )
    636669{
    637670    uint32_t * buf = (uint32_t *)base;
     
    716749    {
    717750
    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
     752cycle = (uint32_t)hal_get_cycles();
     753if( CONFIG_DEBUG_FATFS_LOAD < cycle )
     754printk("\n[DBG] %s : thread %x exit / child <%s> not found / cycle %d\n",
     755__FUNCTION__ , CURRENT_THREAD, name, cycle );
     756#endif
    720757
    721758        return ENOENT;
     
    734771        hal_remote_sw( XPTR( child_cxy , &child_ptr->extend ) , cluster );
    735772
    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
     774cycle = (uint32_t)hal_get_cycles();
     775if( CONFIG_DEBUG_FATFS_LOAD < cycle )
     776printk("\n[DBG] %s : thread %x exit / child <%s> loaded / cycle %d\n",
     777__FUNCTION__ , CURRENT_THREAD, name, cycle );
     778#endif
    738779
    739780        return 0;
Note: See TracChangeset for help on using the changeset viewer.