Changeset 569


Ignore:
Timestamp:
May 18, 2015, 7:07:43 PM (9 years ago)
Author:
alain
Message:

Improving debug: debug activated only if _get_proctime() > GIET_DEBUG_FAT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_fat32/fat32.c

    r551 r569  
    55// Copyright (c) UPMC-LIP6
    66//////////////////////////////////////////////////////////////////////////////////
    7 // The fat.h and fat_common.c files define a library of access functions
     7// The fat32.h and fat32.c files define a library of access functions
    88// to a FAT32 disk on a block device. It is intended to be used
    99// by the GIET_VM nano-kernel for both the boot code and the kernel code.
     
    1414// 2. the "cluster" variable is actually a cluster index. A cluster contains
    1515//    typically 8 sectors (4K bytes) and the cluster index is a 32 bits word.
    16 // 3. This FAT32 library uses a FAT cache whose storage capacity is one
    17 //    sector (512 bytes = 128 cluster indexes in FAT)
     16// 3. This FAT32 library uses a FAT cache whose storage capacity is one sector.
    1817//////////////////////////////////////////////////////////////////////////////////
    1918
     
    3837extern unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE];
    3938 
    40 //////////////////////////////////////////////////////////////////////////////
     39/////////////////////////////////////////////////////////////////////////////////
    4140// This function computes the memory buffer physical address, and calls
    42 // the proper IOC driver depending on the subtype (BDV / HBA / SDC /RDK).
     41// the proper IOC driver depending on the subtype (BDV / HBA / SDC / SPI / RDK).
    4342// The use_irq argument allows to activate the descheduling mode, if it
    4443// supported by the IOC driver subtype
    45 //////////////////////////////////////////////////////////////////////////////
     44/////////////////////////////////////////////////////////////////////////////////
    4645// Return 0 in case of success, return -1 in case of error
    47 //////////////////////////////////////////////////////////////////////////////
     46/////////////////////////////////////////////////////////////////////////////////
    4847static
    4948int _fat_ioc_access( unsigned int use_irq,
     
    6665    }
    6766
    68 #if (GIET_DEBUG_FAT > 1)
     67#if GIET_DEBUG_FAT
    6968unsigned int procid  = _get_procid();
    7069unsigned int x       = procid >> (Y_WIDTH + P_WIDTH);
    7170unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    7271unsigned int p       = procid & ((1<<P_WIDTH)-1);
     72if ( _get_proctime() > GIET_DEBUG_FAT )
    7373_printf("\n[DEBUG FAT] P[%d,%d,%d] enters _fat_ioc_access() at cycle %d\n"
    7474        "  to_mem = %d / vaddr = %x / paddr = %l / sectors = %d / lba = %x\n",
     
    8686#elif ( USE_IOC_HBA )
    8787    return( _hba_access( use_irq , to_mem , lba , buf_paddr , count ) );
     88#elif ( USE_IOC_SDC )
     89    return( _sdc_access( use_irq , to_mem , lba , buf_paddr , count ) );
    8890#elif ( USE_IOC_SPI )
    89     return( _sdc_access( use_irq , to_mem , lba , buf_paddr , count ) );
     91    return( _spi_access( use_irq , to_mem , lba , buf_paddr , count ) );
    9092#elif ( USE_IOC_RDK )
    9193    return( _rdk_access( use_irq , to_mem , lba , buf_paddr , count ) );
     
    101103// This function displays the content of the FAT cache
    102104//////////////////////////////////////////////////////////////////////////////////
    103 #if (GIET_DEBUG_FAT > 1)
     105#if GIET_DEBUG_FAT
    104106static
    105107void _display_fat_cache()
     
    307309                                     _fat.fat_cache,
    308310                                     1 );
    309 #if (GIET_DEBUG_FAT > 1)
     311#if GIET_DEBUG_FAT
    310312unsigned int procid  = _get_procid();
    311313unsigned int x       = procid >> (Y_WIDTH + P_WIDTH);
    312314unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    313315unsigned int p       = procid & ((1<<P_WIDTH)-1);
     316if ( _get_proctime() > GIET_DEBUG_FAT )
    314317_printf("\n[DEBUG FAT] P[%d,%d,%d] in _get_next_cluster() :  next = %x\n",
    315318        x , y , p , next );
     319if ( (_get_proctime() > GIET_DEBUG_FAT) && (GIET_DEBUG_FAT & 0x1) )
    316320_display_fat_cache();
    317321#endif
     
    725729
    726730#if GIET_DEBUG_FAT
     731if ( _get_proctime() > GIET_DEBUG_FAT )
    727732_printf("\n[DEBUG FAT] _update_fs_info()\n");
    728733#endif
     
    773778
    774779#if GIET_DEBUG_FAT
     780if ( _get_proctime() > GIET_DEBUG_FAT )
    775781_printf("\n[DEBUG FAT] _update_fat() : cluster = %x / value = %x\n",
    776782        cluster, value );
     
    839845
    840846#if GIET_DEBUG_FAT
     847if ( _get_proctime() > GIET_DEBUG_FAT )
    841848_printf("\n[DEBUG FAT] _fat_allocate() for fd = %d\n", fd_id );
    842849#endif
     
    855862
    856863#if GIET_DEBUG_FAT
     864if ( _get_proctime() > GIET_DEBUG_FAT )
    857865_printf("\n[DEBUG FAT] cluster to update = %x / free cluster = %x / count = %d\n",
    858866        last_cluster_file , free_cluster , cluster_to_allocate );
     
    926934                     unsigned int*  lba_dir_entry )  // lba of dir_entry
    927935{
    928     char dir_entry[32];   // buffer to store a full directory_entry
    929     char name_entry[14];  // buffer to store a 13 characters (partial) name
     936    char dir_entry[32];       // buffer to store a full directory_entry
     937    char name_entry[14];      // buffer to store a 13 characters (partial) name
    930938
    931939    char sfn_string[12]    = {[0 ... 10] = ' ', '\0'};  // buffer Short File Name
    932940    unsigned int  is_sfn   = is_short(file_name, sfn_string); // file_name is short
    933941    unsigned int  offset   = 0;                         // byte offset in block
    934     unsigned int  block_id = _fat.sectors_per_cluster;   // sector index
     942    unsigned int  block_id = _fat.sectors_per_cluster;  // sector index
    935943    unsigned int  lba      = cluster_to_lba(cluster);   // lba of cluster
    936944    unsigned int  attr     = 0;                         // dir entry attribute
     
    945953unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    946954unsigned int p       = procid & ((1<<P_WIDTH)-1);
    947 
     955if ( _get_proctime() > GIET_DEBUG_FAT )
    948956_printf("\n[DEBUG FAT] _scan_directory() : P[%d,%d,%d] enters for %s\n",
    949957      x, y, p, file_name );
     
    968976    _fat.cache_lba = lba;
    969977
    970 #if ( GIET_DEBUG_FAT > 1 )
     978#if GIET_DEBUG_FAT
     979if ( (_get_proctime() > GIET_DEBUG_FAT) && (GIET_DEBUG_FAT & 0x1) )
    971980_display_fat_cache();
    972981#endif
     
    10951104
    10961105#if GIET_DEBUG_FAT
     1106if ( _get_proctime() > GIET_DEBUG_FAT )
    10971107_printf("\n[DEBUG FAT] _scan_directory() : P[%d,%d,%d] found %s"
    10981108        " : cluster = %x\n", x, y, p, file_name, searched_cluster );
     
    11371147unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    11381148unsigned int p       = procid & ((1<<P_WIDTH)-1);
     1149if ( _get_proctime() > GIET_DEBUG_FAT )
    11391150_printf("\n[DEBUG FAT] P[%d,%d,%d] enters _fat_init\n",x,y,p);
    11401151#endif
     
    11601171
    11611172#if GIET_DEBUG_FAT > 1
     1173if ( _get_proctime() > GIET_DEBUG_FAT )
    11621174_printf("\n[DEBUG FAT] _fat_init() : Boot Sector Loaded\n");
     1175if ( (_get_proctime() > GIET_DEBUG_FAT) && (GIET_DEBUG_FAT & 0x1) )
    11631176_display_fat_cache();
    11641177#endif
     
    12051218
    12061219#if GIET_DEBUG_FAT
     1220if ( _get_proctime() > GIET_DEBUG_FAT )
    12071221_printf("\n[DEBUG FAT] _fat_init() : FS_INFO Sector = %x\n", _fat.fs_info_lba );
    12081222#endif
     
    12241238
    12251239#if GIET_DEBUG_FAT
     1240if ( _get_proctime() > GIET_DEBUG_FAT )
    12261241_fat_print();
    12271242_printf("\n[DEBUG FAT] P[%d,%d,%d] exit _fat_init()\n", x,y,p );
     
    12601275unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    12611276unsigned int p       = procid & ((1<<P_WIDTH)-1);
     1277if ( _get_proctime() > GIET_DEBUG_FAT )
    12621278_printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] enters for path %s\n",
    12631279        x, y, p, pathname );
     
    12811297
    12821298#if GIET_DEBUG_FAT
     1299if ( _get_proctime() > GIET_DEBUG_FAT )
    12831300_printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] takes the FAT lock\n",
    12841301        x, y, p );
     
    12981315
    12991316#if GIET_DEBUG_FAT
     1317if ( _get_proctime() > GIET_DEBUG_FAT )
    13001318_printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] search file/dir %s\n",
    13011319        x, y, p, name );
     
    13061324        {
    13071325            last_name   = 1;
    1308             dir_cluster = cluster;
     1326            dir_cluster = cluster;   // this is the lowest directory
    13091327        }
    13101328
     
    13251343
    13261344#if GIET_DEBUG_FAT
     1345if ( _get_proctime() > GIET_DEBUG_FAT )
    13271346_printf("\n[DEBUG FAT] P[%d,%d,%d] in _fat_open() : cluster for %s = %x\n",
    13281347       x, y, p, pathname, cluster );
     
    13511370
    13521371#if GIET_DEBUG_FAT
     1372if ( _get_proctime() > GIET_DEBUG_FAT )
    13531373_printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] exit : fd = %d for file %s\n",
    13541374        x, y, p, fd_id, pathname );
     
    14431463unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    14441464unsigned int p       = procid & ((1<<P_WIDTH)-1);
     1465if ( _get_proctime() > GIET_DEBUG_FAT )
    14451466_printf("\n[DEBUG FAT] _fat_read() : P[%d,%d,%d] enters for file %s\n"
    14461467        " - buffer vbase     = %x\n"
     
    14781499
    14791500#if GIET_DEBUG_FAT
     1501if ( _get_proctime() > GIET_DEBUG_FAT )
    14801502_printf("\n[DEBUG FAT] _fat_read() : P[%d,%d,%d] makes an IOC read\n"
    14811503        "  cluster = %x / buffer = %x / lba = %x / sectors = %d\n",
     
    15521574unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    15531575unsigned int p       = procid & ((1<<P_WIDTH)-1);
    1554 
     1576if ( _get_proctime() > GIET_DEBUG_FAT )
    15551577_printf("\n[DEBUG FAT] _fat_write() : P[%d,%d,%d] enters for file %s\n"
    15561578        " - buffer vbase    = %x\n"
     
    15971619
    15981620#if GIET_DEBUG_FAT
     1621if ( _get_proctime() > GIET_DEBUG_FAT )
    15991622_printf("\n[DEBUG FAT] _fat_write() : P[%d,%d,%d] get cluster %x\n",
    16001623        x, y, p, cluster );
     
    16261649
    16271650#if GIET_DEBUG_FAT
     1651if ( _get_proctime() > GIET_DEBUG_FAT )
    16281652_printf("\n[DEBUG FAT] _fat_write() : P[%d,%d,%d] makes an IOC write"
    16291653        "  cluster = %x / buffer = %x / lba = %x / sectors = %d\n",
Note: See TracChangeset for help on using the changeset viewer.