Ignore:
Timestamp:
Jun 29, 2014, 1:25:59 PM (10 years ago)
Author:
alain
Message:

Cosmetic: reducing debug verbosity.

File:
1 edited

Legend:

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

    r345 r354  
    3737// This function displays the content of the FAT cache
    3838//////////////////////////////////////////////////////////////////////////////////
    39 #if GIET_DEBUG_FAT
    4039void display_fat_cache()
    4140{
     
    7776    _printf("**************************************************************************\n");
    7877} // end display_fat_cache() 
    79 #endif
    8078
    8179//////////////////////////////////////////////////////////////////////////////////
     
    263261    char ch;
    264262
    265 #if GIET_DEBUG_FAT
    266 _printf("\n[FAT DEBUG] filename %s", string );
    267 #endif
    268 
    269263    if(string[0] == '.' && string[1] == '\0')
    270264    {
    271265        sfn_string[0] = '.';
    272 
    273 #if GIET_DEBUG_FAT
    274 _printf(" converted to 8.3 SFN format : %s\n", sfn_string );
    275 #endif
    276 
    277       return 1;
    278    }
    279 
    280    if(string[0] == '.' && string[1] == '.' && string[2] == '\0')
    281    {
    282       sfn_string[0] = '.';
    283       sfn_string[1] = '.';
    284 
    285 #if GIET_DEBUG_FAT
    286 _printf(" converted to 8.3 SFN format : %s\n", sfn_string );
    287 #endif
    288 
    289       return 1;
    290    }
    291 
    292    sfn_string[11] = '\0';
    293 
    294    while (string[s_size] != '\0')
    295    {
    296       if (string[s_size] == '.')
    297       {
    298          dot_ext = s_size;
    299          ext_len = -1;
    300       }
    301       ext_len++;
    302       s_size++;
    303    }
    304 
    305    if (dot_ext != 0)
    306    {
    307       name_len = s_size - ext_len - 1;
    308    }
    309    else
    310    {
    311       name_len = s_size;
    312       ext_len = 0;
    313    }
    314 
    315    if ( ext_len > 3 || ( name_len > 8))
    316    {
    317       return 0;
    318    }
    319 
    320    if (dot_ext != 0)
    321    {
    322       while (i != ext_len)
    323       {
    324          ch = to_upper(string[dot_ext + 1 + i]);
    325          ch = illegal_short(ch);
    326          sfn_string[8+i] = ch;
    327          i++;
    328       }
    329    }
    330    i = 0;
    331    sc_i = 0;
    332    while (i!= name_len)
    333    {
    334       ch = to_upper(string[i]);
    335       ch = illegal_short(ch);
    336       if (ch != '.')
    337          sfn_string[sc_i++] = ch;
    338       i++;
    339    }
    340 
    341 #if GIET_DEBUG_FAT
    342 _printf(" converted to 8.3 SFN format : %s\n", sfn_string );
    343 #endif
    344 
    345    return 1;
     266        return 1;
     267    }
     268    if(string[0] == '.' && string[1] == '.' && string[2] == '\0')
     269    {
     270        sfn_string[0] = '.';
     271        sfn_string[1] = '.';
     272        return 1;
     273    }
     274    sfn_string[11] = '\0';
     275    while (string[s_size] != '\0')
     276    {
     277        if (string[s_size] == '.')
     278        {
     279            dot_ext = s_size;
     280            ext_len = -1;
     281        }
     282        ext_len++;
     283        s_size++;
     284    }
     285    if (dot_ext != 0)
     286    {
     287        name_len = s_size - ext_len - 1;
     288    }
     289    else
     290    {
     291        name_len = s_size;
     292        ext_len = 0;
     293    }
     294    if ( ext_len > 3 || ( name_len > 8))
     295    {
     296        return 0;
     297    }
     298    if (dot_ext != 0)
     299    {
     300        while (i != ext_len)
     301        {
     302            ch = to_upper(string[dot_ext + 1 + i]);
     303            ch = illegal_short(ch);
     304            sfn_string[8+i] = ch;
     305            i++;
     306        }
     307    }
     308    i = 0;
     309    sc_i = 0;
     310    while (i!= name_len)
     311    {
     312        ch = to_upper(string[i]);
     313        ch = illegal_short(ch);
     314        if (ch != '.') sfn_string[sc_i++] = ch;
     315        i++;
     316    }
     317    return 1;
    346318}
    347319
     
    850822
    851823    fat.cache_lba = lba;
    852 
    853 #if GIET_DEBUG_FAT
    854 display_fat_cache();
    855 #endif
    856824
    857825    // in this loop we scan all names in directory identified by cluster:
     
    10451013#if GIET_DEBUG_FAT
    10461014_printf("\n[FAT DEBUG] Boot Sector Loaded\n");
    1047 display_fat_cache();
    10481015#endif
    10491016
     
    10791046    fat.fat_lba             = read_entry( BPB_RSVDSECCNT, fat.fat_cache, 1 );
    10801047    fat.data_lba            = fat.fat_lba + fat.fat_sectors;
     1048    fat.fat_lock.value      = 0;
    10811049    fat.initialised         = FAT_INITIALISED;
    10821050
     
    11061074_printf("\n[FAT DEBUG] Processor[%d,%d,%d] exit _fat_init() / "
    11071075        "free clusters = %x / last allocated cluster = %x\n",
    1108         fat.number_free_cluster, fat.last_cluster_allocated );
     1076        x, y, lpid, fat.number_free_cluster, fat.last_cluster_allocated );
    11091077#endif
    11101078
     
    11261094
    11271095///////////////////////////////////////////////////////////////////////////////
    1128 // This function checks that the kernel FAT structure has been initialised,
    1129 // and makes the FAT initialisation if it is the first user open request.
     1096// This function checks that the kernel FAT structure has been initialised.
     1097// It makes the FAT initialisation if it is the first open request.
    11301098// This function searches a file identified by the "pathname" argument.
    11311099// It starts from root (cluster 2) to scan successively each subdirectory.
     
    11331101// a new file is created and introduced in the directory.
    11341102// Finally, it sets a new open file in the file descriptors array.
    1135 // The same file can be open several times by differents taks.
     1103// The same file can be open several times by differents tasks.
    11361104///////////////////////////////////////////////////////////////////////////////
    11371105// Returns file descriptor index if success, returns -1 if error.
     
    11411109               unsigned int creat )
    11421110{
    1143     char                 name[256];    // buffer for one name in pathname
    1144     unsigned int         nb_read;          // number of characters written in name[]
    1145     unsigned int         cluster;      // current cluster index when scanning FAT
    1146     unsigned int         dir_cluster;  // previous cluster index when scanning FAT
    1147     unsigned int         fd_id;        // index when scanning file descriptors array
    1148     unsigned int         file_size;    // number of bytes
    1149     unsigned int         last_name;    // directory containing file name is reached
    1150     unsigned int         lba;          // lba of dir_entry for this file
     1111    char                 name[256];        // buffer for one name in pathname
     1112    unsigned int         nb_read;              // number of characters written in name[]
     1113    unsigned int         cluster;          // current cluster index when scanning FAT
     1114    unsigned int         dir_cluster;      // previous cluster index when scanning FAT
     1115    unsigned int         fd_id;            // index when scanning file descriptors array
     1116    unsigned int         file_size = 0;    // number of bytes
     1117    unsigned int         last_name = 0;    // directory containing file name is reached
     1118    unsigned int         lba       = 0;    // lba of dir_entry for this file
    11511119   
    11521120#if GIET_DEBUG_FAT
     
    11691137
    11701138    // takes the FAT lock for exclusive access
    1171     _get_lock( &fat.lock );
     1139    _get_lock( &fat.fat_lock );
    11721140
    11731141#if GIET_DEBUG_FAT
     
    11841152
    11851153            // release FAT lock
    1186             _release_lock( &fat.lock );
     1154            _release_lock( &fat.fat_lock );
    11871155
    11881156            return -1;
     
    12331201
    12341202            // release FAT lock
    1235             _release_lock( &fat.lock );
     1203            _release_lock( &fat.fat_lock );
    12361204
    12371205            return -1;
     
    12661234
    12671235            // release FAT lock
    1268             _release_lock( &fat.lock );
     1236            _release_lock( &fat.fat_lock );
    12691237
    12701238            return fd_id;
     
    12761244
    12771245            // release FAT lock
    1278             _release_lock( &fat.lock );
     1246            _release_lock( &fat.fat_lock );
    12791247
    12801248            return -1;
     
    12871255
    12881256        // release FAT lock
    1289         _release_lock( &fat.lock );
     1257        _release_lock( &fat.fat_lock );
    12901258
    12911259        return -1;
     
    13061274               unsigned int offset )    // nuber of sectors to skip in file
    13071275{
    1308 
    1309 #if GIET_DEBUG_FAT
    1310 unsigned int procid  = _get_procid();
    1311 unsigned int cid     = procid / NB_PROCS_MAX;
    1312 unsigned int lpid    = procid % NB_PROCS_MAX;
    1313 unsigned int x       = cid >> Y_WIDTH;
    1314 unsigned int y       = cid & ((1<<Y_WIDTH) - 1);
    1315 
    1316 _printf("\n[FAT DEBUG] Processor[%d,%d,%d] enters _fat_read() for file %s\n"
    1317         " - buffer vbase    = %x\n"
    1318         " - skipped sectors = %x\n"
    1319         " - read sectors    = %x\n",
    1320         x, y, lpid, fat.fd[fd_id].name, (unsigned int)buffer, offset, count );
    1321 #endif
    1322 
    13231276    unsigned int spc = fat.sectors_per_cluster;
    13241277
     
    13691322
    13701323#if GIET_DEBUG_FAT
    1371 _printf(" - first cluster   = %x\n"
     1324unsigned int procid  = _get_procid();
     1325unsigned int cid     = procid / NB_PROCS_MAX;
     1326unsigned int lpid    = procid % NB_PROCS_MAX;
     1327unsigned int x       = cid >> Y_WIDTH;
     1328unsigned int y       = cid & ((1<<Y_WIDTH) - 1);
     1329
     1330_printf("\n[FAT DEBUG] Processor[%d,%d,%d] enters _fat_read() for file %s\n"
     1331        " - buffer vbase    = %x\n"
     1332        " - skipped sectors = %x\n"
     1333        " - read sectors    = %x\n"
     1334        " - first cluster   = %x\n"
    13721335        " - skiped clusters = %x\n",
    1373         cluster, clusters_to_skip );   
     1336        x, y, lpid, fat.fd[fd_id].name,
     1337        (unsigned int)buffer, offset, count, cluster, clusters_to_skip );   
    13741338#endif
    13751339
Note: See TracChangeset for help on using the changeset viewer.