Changeset 503 for soft


Ignore:
Timestamp:
Feb 8, 2015, 9:22:56 PM (9 years ago)
Author:
alain
Message:

Cosmetic.

Location:
soft/giet_vm/giet_fat32
Files:
2 edited

Legend:

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

    r474 r503  
    3636// This function displays the content of the FAT cache
    3737//////////////////////////////////////////////////////////////////////////////////
    38 void display_fat_cache()
     38void _display_fat_cache()
    3939{
    4040    unsigned int line;
     
    7878    _puts("***************************************************************************\n");
    7979
    80 } // end display_fat_cache() 
     80} // end _display_fat_cache() 
    8181
    8282//////////////////////////////////////////////////////////////////////////////////
     
    191191unsigned int p       = procid & ((1<<P_WIDTH)-1);
    192192
    193 _puts("\n[FAT DEBUG] _get_next_cluster() : P[");
    194 _putd( x );
    195 _puts(",");
    196 _putd( y );
    197 _puts(",");
    198 _putd( p );
    199 _puts("] enters for cluster ");
    200 _putx( cluster );
    201 _puts("\n");
     193_printf("\n[FAT DEBUG] _get_next_cluster() : P[%d,%d,%d] enters for cluster %x\n",
     194      x , y , p , cluster );
    202195#endif
    203196
     
    214207                       1 ) )              // one sector
    215208        {
    216             _puts("[FAT_ERROR] in get_next cluster_id() : cannot read block ");
    217             _putx( lba );
    218             _puts("\n");
     209            _printf("[FAT_ERROR] in get_next cluster_id() : cannot read block %x", lba );
    219210            return 1;
    220211        }
     
    222213   
    223214#if (GIET_DEBUG_FAT > 1)
    224 display_fat_cache();
     215_display_fat_cache();
    225216#endif
    226217
     
    232223
    233224#if GIET_DEBUG_FAT
    234 _puts("\n[FAT DEBUG] _get_next_cluster() : P[");
    235 _putd( x );
    236 _puts(",");
    237 _putd( y );
    238 _puts(",");
    239 _putd( p );
    240 _puts("] next cluster = ");
    241 _putx( next );
    242 _puts("\n");
     225_printf("\n[FAT DEBUG] _get_next_cluster() : P[%d,%d,%d] next cluster = %x\n", next );
    243226#endif
    244227
     
    512495                    1 ) )            // one sector
    513496    {
    514         _puts("[FAT ERROR] in update_entry() cannot read sector ");
    515         _putx( lba );
    516         _puts("\n");
     497        _printf("\n[FAT ERROR] in update_entry() cannot read sector %x\n", lba );
    517498        return 1;
    518499    }
     
    543524            else if (ord == NO_MORE_ENTRY )            // end of directory : return
    544525            {
    545                 _puts("[FAT ERROR] in update_entry() : reaches end of directory\n");
     526                _printf("\n[FAT ERROR] in update_entry() : reaches end of directory\n");
    546527                return 1;
    547528            }
     
    569550            else if (ord == NO_MORE_ENTRY )                        // end of directory : return
    570551            {
    571                 _puts("[FAT ERROR] in update_entry() reaches end of directory\n");
     552                _printf("\n[FAT ERROR] in update_entry() reaches end of directory\n");
    572553                return 1;
    573554            }
     
    634615
    635616#if GIET_DEBUG_FAT
    636 _puts("\n[FAT DEBUG] _update_fs_info() : enters\n");
     617_printf("\n[FAT DEBUG] _update_fs_info() : enters\n");
    637618#endif
    638619
     
    650631                        1 ) )              // one sector
    651632        {
    652             _puts("[FAT_ERROR] in _update_fat() cannot read block ");
    653             _putx( lba );
    654             _puts("\n");
     633            _printf("\n[FAT_ERROR] in _update_fat() cannot read block %x\n", lba );
    655634            return 1;
    656635        }
     
    677656
    678657#if GIET_DEBUG_FAT
    679 _puts("\n[FAT DEBUG] _update_fat() : cluster = ");
    680 _putx( cluster );
    681 _puts(" / value = ");
    682 _putx( value );
    683 _puts("\n");
     658_printf("\n[FAT DEBUG] _update_fat() : cluster = %x / value = %x\n", cluster, value );
    684659#endif
    685660
     
    696671                        1 ) )              // one sector
    697672        {
    698             _puts("[FAT_ERROR] in _update_fat() cannot read block %x\n");
     673            _printf("\n[FAT_ERROR] in _update_fat() cannot read block %x\n", lba );
    699674            return 1;
    700675        }
     
    717692                                 unsigned int count )
    718693{
    719     unsigned int next_cluster = fat.fd[fd_id].first_cluster;    // Get the first cluster of file
    720     unsigned int cluster_to_allocate = count;                   // Number of cluster to allocate
    721     unsigned int last_cluster_file;                             // Last cluster of the file (EOC)
     694    unsigned int next_cluster = fat.fd[fd_id].first_cluster;    // get first cluster
     695    unsigned int cluster_to_allocate = count;                   // clusters to allocate
     696    unsigned int last_cluster_file;                             // Last cluster (EOC)
    722697    unsigned int free_cluster = fat.last_cluster_allocated + 1; // First free cluster
    723698
     
    725700    if ( _get_next_cluster( IOC_KERNEL_MODE, free_cluster ) != FREE_CLUSTER)
    726701    {
    727         _puts("\n[FAT ERROR] in _fat_allocate() : first free cluster not free\n");
     702        _printf("\n[FAT ERROR] in _fat_allocate() : first free cluster not free\n");
    728703        return -1;
    729704    }
     
    731706    if ( count > fat.number_free_cluster )
    732707    {
    733         _puts("\n[FAT ERROR] in _fat_allocate() : Not enough free cluster(s)\n");
     708        _printf("\n[FAT ERROR] in _fat_allocate() : Not enough free cluster(s)\n");
    734709        return -1;
    735710    }
    736711
    737712#if GIET_DEBUG_FAT
    738 _puts("\n[FAT DEBUG] _fat_allocate() for fd = ");
    739 _putd( fd_id );
    740 _puts("\n");
     713_printf("\n[FAT DEBUG] _fat_allocate() for fd = %d\n" fd_id );
    741714#endif
    742715
    743716    // Get the last cluster allocated for the file (seek END_OF_CHAIN_CLUSTER).
    744     do{
     717    do
     718    {
    745719        last_cluster_file = next_cluster;
    746720        next_cluster      = _get_next_cluster( IOC_KERNEL_MODE, next_cluster );
    747     }while ( next_cluster < END_OF_CHAIN_CLUSTER );
     721    }
     722    while ( next_cluster < END_OF_CHAIN_CLUSTER );
    748723
    749724    // Loop on the number of clusters to be allocated
     
    752727
    753728#if GIET_DEBUG_FAT
    754 _puts("\n[FAT DEBUG] cluster to update = ");
    755 _putx( last_cluster_file );
    756 _puts(" / free cluster = ");
    757 _putx( free_cluster );
    758 _puts(" / clusters required = ");
    759 _putx( cluster_to_allocate );
    760 _puts("\n");
     729_printf("\n[FAT DEBUG] cluster to update = %x / free cluster = %x / nb_clusters %d\n",
     730        last_cluster_file , free_cluster , cluster_to_allocate );
    761731#endif
    762732
     
    765735        if ( _update_fat( last_cluster_file, free_cluster ) )
    766736        {
    767             _puts("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");
     737            _printf("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");
    768738            return -1;
    769739        }
     
    780750            if ( _update_fat( last_cluster_file, END_OF_CHAIN_CLUSTER ) )
    781751            {
    782                 _puts("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");
     752                _printf("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");
    783753                return -1;
    784754            }
     
    790760        if ( _get_next_cluster( IOC_KERNEL_MODE, free_cluster ) != FREE_CLUSTER)
    791761        {
    792             _puts("\n[FAT ERROR] in _fat_allocate() : free_cluster not free\n");
     762            _printf("\n[FAT ERROR] in _fat_allocate() : free_cluster not free\n");
    793763            return -1;
    794764        }
     
    802772    if ( _update_fs_info() )
    803773    {
    804         _puts("\n[FAT ERROR] in _fat_allocate() : update fs_info failed\n");
     774        _printf("\n[FAT ERROR] in _fat_allocate() : update fs_info failed\n");
    805775        return -1;
    806776    }
     
    847817unsigned int p       = procid & ((1<<P_WIDTH)-1);
    848818
    849 _puts("\n[FAT DEBUG] _scan_directory() : P[");
    850 _putd( x );
    851 _puts(",");
    852 _putd( y );
    853 _puts(",");
    854 _putd( p );
    855 _puts("] enters for ");
    856 _puts( file_name );
    857 _puts(" / is_sfn = ");
    858 _putd( is_sfn );
    859 _puts("\n");
     819_printf("\n[FAT DEBUG] _scan_directory() : P[%d,%d,%d] enters for %s\n",
     820      x, y, p, file_name );
    860821#endif
    861822
     
    872833                   1 ) )            // one sector
    873834    {
    874         _puts("[FAT ERROR] in _scan_directory() : cannot read sector ");
    875         _putx( lba );
    876         _puts("\n");
     835        _printf("[\nFAT ERROR] in _scan_directory() : cannot read sector %x\n", lba );
    877836        return -1;
    878837    }
     
    881840
    882841#if ( GIET_DEBUG_FAT > 1 )
    883 display_fat_cache();
     842_display_fat_cache();
    884843#endif
    885844
     
    912871                           1 ) )            // one sector
    913872            {
    914                 _puts("[FAT ERROR] in _scan_directory() : cannot read sector ");
    915                 _putx( lba );
    916                 _puts("\n");
     873                _printf("\n[FAT ERROR] in _scan_directory() : cannot read sector %x\n", lba);
    917874                return -1;
    918875            }
     
    1008965
    1009966#if GIET_DEBUG_FAT
    1010 _puts("\n[FAT DEBUG] _scan_directory() : P[");
    1011 _putd( x );
    1012 _puts(",");
    1013 _putd( y );
    1014 _puts(",");
    1015 _putd( p );
    1016 _puts("] found ");
    1017 _puts( file_name );
    1018 _puts(" / cluster = ");
    1019 _putx( searched_cluster );
    1020 _puts("\n");
     967_printf("\n[FAT DEBUG] _scan_directory() : P[%d,%d,%d] found %s"
     968        " : cluster = %x\n", x, y, p, file_name, searched_cluster );
    1021969#endif
    1022970
     
    1035983                        unsigned int    dir_cluster )
    1036984{
    1037     _puts("\n[FAT ERROR] _fat_create() not implemented\n");
     985    _printf("\n[FAT ERROR] _fat_create() not implemented\n");
    1038986    return 0;
    1039987}  //end _fat_create()
     
    1049997// This should be done only once.
    1050998//////////////////////////////////////////////////////////////////////////
    1051 // Return 0 if success, Return -1 if failure
     999// Return 0 if success, exit if failure
    10521000//////////////////////////////////////////////////////////////////////////
    10531001int _fat_init( unsigned int mode )   // mode for IOC driver
     
    10611009unsigned int p       = procid & ((1<<P_WIDTH)-1);
    10621010
    1063 _puts("\n[FAT DEBUG] _fat_init() : P[");
    1064 _putd( x );
    1065 _puts(",");
    1066 _putd( y );
    1067 _puts(",");
    1068 _putd( p );
    1069 _puts("] enters _fat_init()");
    1070 if ( mode == IOC_BOOT_MODE   ) _puts(" in BOOT_MODE\n");
    1071 if ( mode == IOC_KERNEL_MODE ) _puts(" in KERNEL_MODE\n");
    1072 if ( mode == IOC_USER_MODE   ) _puts(" in USER_MODE\n");
     1011if ( mode == IOC_BOOT_MODE )
     1012_printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters in BOOT_MODE\n",x,y,p);
     1013if ( mode == IOC_KERNEL_MODE )
     1014_printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters in KERNEL_MODE\n",x,y,p);
     1015if ( mode == IOC_USER_MODE )
     1016_printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters in USER_MODE\n",x,y,p);
    10731017#endif
    10741018
     
    10761020    if ( fat.initialised == FAT_INITIALISED )
    10771021    {
    1078         _puts("\n[FAT WARNING] Strange initialisation  of a FAT already initialised...\n");
    1079         return 0;
     1022        _printf("\n[FAT WARNING] Strange, FAT already initialised...\n");
     1023        _exit();
    10801024    }
    10811025
     
    10871031                    1 ) )                // one sector
    10881032    {
    1089         _puts("\n[FAT ERROR] in _fat_init() cannot load VBR\n");
    1090         return -1;
     1033        _printf("\n[FAT ERROR] in _fat_init() cannot load VBR\n");
     1034        _exit();
    10911035    }
    10921036    fat.cache_lba = 0;
    10931037
    1094 #if GIET_DEBUG_FAT
    1095 _puts("\n[FAT DEBUG] _fat_init() : Boot Sector Loaded\n");
     1038#if GIET_DEBUG_FAT > 1
     1039_printf("\n[FAT DEBUG] _fat_init() : Boot Sector Loaded\n");
     1040_display_fat_cache();
    10961041#endif
    10971042
     
    10991044    if( _read_entry( BPB_BYTSPERSEC, fat.fat_cache, 1 ) != 512 )
    11001045    {
    1101         _puts("\n[FAT ERROR] The sector size must be 512 bytes\n");
    1102         return -1; 
     1046        _printf("\n[FAT ERROR] The sector size must be 512 bytes\n");
     1047        _exit();
    11031048    }
    11041049    if( _read_entry( BPB_NUMFATS, fat.fat_cache, 1 ) != 1 )
    11051050    {
    1106         _puts("\n[FAT ERROR] The number of FAT copies in FAT region must be 1\n");
    1107         return -1; 
     1051        _printf("\n[FAT ERROR] The number of FAT copies in FAT region must be 1\n");
     1052        _exit();
    11081053    }
    11091054    if( (_read_entry( BPB_FAT32_FATSZ32, fat.fat_cache, 1 ) & 0xF) != 0 )
    11101055    {
    1111         _puts("\n[FAT ERROR] The FAT region in FAT32 must be multiple of 32 sectors\n");
    1112         return -1; 
     1056        _printf("\n[FAT ERROR] The FAT region in FAT32 must be multiple of 32 sectors\n");
     1057        _exit();
    11131058    }
    11141059    if( _read_entry( BPB_FAT32_ROOTCLUS, fat.fat_cache, 1 ) != 2 )
    11151060    {
    1116         _puts("\n[FAT ERROR] The first cluster index must be 2\n");
    1117         return -1; 
     1061        _printf("\n[FAT ERROR] The first cluster index must be 2\n");
     1062        _exit();
    11181063    }
    11191064    // FS Info always in sector 1
     
    11361081
    11371082#if GIET_DEBUG_FAT
    1138 _puts("\n[FAT DEBUG] _fat_init() : FS_INFO Sector = ");
    1139 _putx( fat.fs_info_lba );
    1140 _puts("\n");
     1083_printf("\n[FAT DEBUG] _fat_init() : FS_INFO Sector = %x\n", fat.fs_info_lba );
    11411084#endif
    11421085
     
    11481091                    1 ) )               // one sector
    11491092    {
    1150         _puts("\n[FAT ERROR] in _fat_init() cannot load FS_INFO Sector\n");
    1151         return -1;
     1093        _printf("\n[FAT ERROR] in _fat_init() cannot load FS_INFO Sector\n");
     1094        _exit();
    11521095    }
    11531096    fat.cache_lba = fat.fs_info_lba;
     
    11591102#if GIET_DEBUG_FAT
    11601103_fat_print();
    1161 _puts("\n[FAT DEBUG] P[");
    1162 _putd( x );
    1163 _puts(",");
    1164 _putd( y );
    1165 _puts(",");
    1166 _putd( p );
    1167 _puts("] exit _fat_init()\n");
     1104_printf("\n[FAT DEBUG] P[%d,%d,%d] exit _fat_init()\n" );
    11681105#endif
    11691106
     
    11741111void _fat_print()
    11751112{
    1176     _puts("\n########################## FAT32 ################################"); 
    1177     _puts("\nFAT initialised                  "); _putx( fat.initialised );
    1178     _puts("\nSector Size  (bytes)             "); _putx( fat.sector_size );
    1179     _puts("\nSectors per cluster              "); _putx( fat.sectors_per_cluster );
    1180     _puts("\nFAT region first lba             "); _putx( fat.fat_lba );
    1181     _puts("\nData region first lba            "); _putx( fat.data_lba );
    1182     _puts("\nNumber of sectors for one FAT    "); _putx( fat.fat_sectors );
    1183     _puts("\nNumber of free clusters          "); _putx( fat.number_free_cluster );
    1184     _puts("\nLast allocated cluster           "); _putx( fat.last_cluster_allocated );
    1185     _puts("\n#################################################################\n");
     1113    _printf("\n########################## FAT32 ################################" 
     1114            "\nFAT initialised                  %x"
     1115            "\nSector Size  (bytes)             %x"
     1116            "\nSectors per cluster              %x"
     1117            "\nFAT region first lba             %x"
     1118            "\nData region first lba            %x"
     1119            "\nNumber of sectors for one FAT    %x"
     1120            "\nNumber of free clusters          %x"
     1121            "\nLast allocated cluster           %x"
     1122            "\n#################################################################\n",
     1123            fat.initialised,
     1124            fat.sector_size,
     1125            fat.sectors_per_cluster,
     1126            fat.fat_lba,
     1127            fat.data_lba,
     1128            fat.fat_sectors,
     1129            fat.number_free_cluster,
     1130            fat.last_cluster_allocated );
    11861131}
    11871132
     
    12161161unsigned int p       = procid & ((1<<P_WIDTH)-1);
    12171162
    1218 _puts("\n[FAT DEBUG] P[");
    1219 _putd( x );
    1220 _puts(",");
    1221 _putd( y );
    1222 _puts(",");
    1223 _putd( p );
    1224 _puts("] enters _fat_open() for path ");
    1225 _puts( pathname );
    1226 _puts("\n");
     1163_printf("\n[FAT DEBUG] P[%d,%d,%d] enters _fat_open() for path %s\n",
     1164        x, y, p, pathname );
    12271165#endif
    12281166
     
    12301168    if ( creat )
    12311169    {
    1232         _puts("[FAT ERROR] in _fat_open() : create not supported yet\n");
     1170        _printf("\n[FAT ERROR] in _fat_open() : create not supported yet\n");
    12331171        return -1;
    12341172    }
     
    12371175    if( fat.initialised != FAT_INITIALISED )
    12381176    {
    1239         _puts("[FAT ERROR] in _fat_open() : FAT not initialised\n");
     1177        _printf("\n[FAT ERROR] in _fat_open() : FAT not initialised\n");
    12401178        return -1;
    12411179    }
     
    12441182
    12451183#if GIET_DEBUG_FAT
    1246 _puts("\n[FAT DEBUG] _fat_open() : P[");
    1247 _putd( x );
    1248 _puts(",");
    1249 _putd( y );
    1250 _puts(",");
    1251 _putd( p );
    1252 _puts("] takes the FAT lock\n");
     1184_printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] takes the FAT lock\n",
     1185        x, y, p );
    12531186#endif
    12541187 
     
    12661199
    12671200#if GIET_DEBUG_FAT
    1268 _puts("\n[FAT DEBUG] _fat_open() : P[");
    1269 _putd( x );
    1270 _puts(",");
    1271 _putd( y );
    1272 _puts(",");
    1273 _putd( p );
    1274 _puts("] search dir/file ");
    1275 _puts( name );
    1276 _puts("\n");
     1201_printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] search file/dir %s\n",
     1202        x, y, p, name );
    12771203#endif
    12781204
     
    12931219        else if ( cluster == END_OF_CHAIN_CLUSTER )
    12941220        {
    1295             _puts("\n[FAT ERROR] in _fat_open() cannot found ");
    1296             _puts( name );
    1297             _puts("\n");
     1221            _printf("\n[FAT ERROR] in _fat_open() cannot found %s\n", name );
    12981222            _spin_lock_release( &fat.fat_lock );
    12991223            return -1;
     
    13021226
    13031227#if GIET_DEBUG_FAT
    1304 _puts("\n[FAT DEBUG] _fat_open() : P[");
    1305 _putd( x );
    1306 _puts(",");
    1307 _putd( y );
    1308 _puts(",");
    1309 _putd( p );
    1310 _puts("] cluster index for file ");
    1311 _puts( pathname );
    1312 _puts(" = ");
    1313 _putx( cluster );
    1314 _puts("\n");
     1228_printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] cluster for %s = %x\n",
     1229       x, y, p, pathname, cluster );
    13151230#endif
    13161231
     
    13371252
    13381253#if GIET_DEBUG_FAT
    1339 _puts("\n[FAT DEBUG] _fat_open() : P[");
    1340 _putd( x );
    1341 _puts(",");
    1342 _putd( y );
    1343 _puts(",");
    1344 _putd( p );
    1345 _puts("] exit : fd = ");
    1346 _putd( fd_id );
    1347 _puts(" for file ");
    1348 _puts( pathname );
    1349 _puts("\n");
     1254_printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] exit : fd = %d for file %s\n",
     1255        x, y, p, fd_id, pathname );
    13501256#endif
    13511257
     
    13571263        else
    13581264        {
    1359             _puts("\n[FAT ERROR] in _fat_open() for file ");
    1360             _puts( pathname );
    1361             _puts(" : fd array full\n");
     1265            _printf("\n[FAT ERROR] in _fat_open() for file %s : fd array full\n",
     1266                    pathname );
    13621267            _spin_lock_release( &fat.fat_lock );
    13631268            return -1;
     
    13661271    else
    13671272    {
    1368         _puts("\n[FAT ERROR] in _fat_open() for file ");
    1369         _puts( pathname );
    1370         _puts(" : bad cluster\n");
     1273        _printf("\n[FAT ERROR] in _fat_open() for file %s : bad cluster\n",
     1274                pathname );
    13711275        _spin_lock_release( &fat.fat_lock );
    13721276        return -1;
     
    13991303    if ( fd_id >= GIET_OPEN_FILES_MAX )
    14001304    {
    1401         _puts("\n[FAT ERROR] in _fat_read() : illegal file descriptor index\n");
     1305        _printf("\n[FAT ERROR] in _fat_read() : illegal file descriptor index\n");
    14021306        return -1;
    14031307    }
    14041308    if ( fat.fd[fd_id].used != 1 )
    14051309    {
    1406         _puts("\n[FAT ERROR] in _fat_read() : file not open\n");
     1310        _printf("\n[FAT ERROR] in _fat_read() : file not open\n");
    14071311        return -1;
    14081312    }
    14091313    if ( ((unsigned int)buffer & 0x1FF) != 0 )
    14101314    {
    1411         _puts("\n[FAT ERROR] in _fat_read() : memory buffer not sector aligned\n");
     1315        _printf("\n[FAT ERROR] in _fat_read() : memory buffer not sector aligned\n");
    14121316        return -1;
    14131317    }
     
    14201324    if ( offset >= file_sectors )
    14211325    {
    1422         _puts("\n[FAT ERROR] offset larger than number of sectors\n");
     1326        _printf("\n[FAT ERROR] offset larger than number of sectors\n");
    14231327        return -1;
    14241328    }
     
    14401344unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    14411345unsigned int p       = procid & ((1<<P_WIDTH)-1);
    1442 _puts("\n[FAT DEBUG] _fat_read() : P[");
    1443 _putd( x );
    1444 _puts(",");
    1445 _putd( y );
    1446 _puts(",");
    1447 _putd( p );
    1448 _puts("] enters for file ");
    1449 _puts( fat.fd[fd_id].name );
    1450 _puts("\n - buffer vbase    = ");
    1451 _putx( (unsigned int)buffer );
    1452 _puts("\n - skipped sectors = ");
    1453 _putx( offset );
    1454 _puts("\n - read sectors    = ");
    1455 _putx( count );
    1456 _puts("\n - first cluster   = ");
    1457 _putx( cluster );
    1458 _puts("\n - skiped clusters = ");
    1459 _putx( clusters_to_skip );   
    1460 _puts("\n");
     1346_printf("\n[FAT DEBUG] _fat_read() : P[%d,%d,%d] enters for file %s\n"
     1347        " - buffer vbase     = %x\n"
     1348        " - skipped sectors  = %x\n"
     1349        " - read sectors     = %x\n"
     1350        " - first cluster    = %x\n"
     1351        " - skipped clusters = %x\n",
     1352        x, y, p,
     1353        fat.fd[fd_id].name,
     1354        (unsigned int)buffer,
     1355        offset,
     1356        count,
     1357        cluster,
     1358        clusters_to_skip );
    14611359#endif
    14621360
     
    14871385
    14881386#if GIET_DEBUG_FAT
    1489 _puts("\n[FAT DEBUG] _fat_read() : P[");
    1490 _putd( x );
    1491 _puts(",");
    1492 _putd( y );
    1493 _puts(",");
    1494 _putd( p );
    1495 _puts("] makes an IOC read");
    1496 _puts("\n - cluster = ");
    1497 _putx( cluster );
    1498 _puts("\n - buf     = ");
    1499 _putx( (unsigned int)dst );
    1500 _puts("\n - lba     = ");
    1501 _putx( lba );
    1502 _puts("\n - sectors = ");
    1503 _putd( iter_sectors );
    1504 _puts("\n");
     1387_printf("\n[FAT DEBUG] _fat_read() : P[%d,%d,%d] makes an IOC read\n"
     1388        " - cluster = %x\n"
     1389        " - buffer  = %x\n"
     1390        " - lba     = %x\n"
     1391        " - sectors = %x\n",
     1392        x, y, p,
     1393        cluster,
     1394        (unsigned int)dst,
     1395        lba,
     1396        iter_sectors );
    15051397#endif
    15061398
     
    15111403                       iter_sectors ) )   // number of sectors
    15121404        {
    1513             _puts("\n[FAT ERROR] in _fat_read() cannot load block ");
    1514             _putx( lba );
    1515             _puts("\n");
     1405            _printf("\n[FAT ERROR] in _fat_read() cannot load block %x", lba );
    15161406            return -1;
    15171407        }
     
    15821472unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    15831473unsigned int p       = procid & ((1<<P_WIDTH)-1);
    1584 _puts("\n[FAT DEBUG] _fat_write() : P[");
    1585 _putd( x );
    1586 _puts(",");
    1587 _putd( y );
    1588 _puts(",");
    1589 _putd( p );
    1590 _puts("] enters for file ");
    1591 _puts( fat.fd[fd_id].name );
    1592 _puts("\n - buffer vbase    = ");
    1593 _putx( (unsigned int)buffer );
    1594 _puts("\n - skipped sectors = ");
    1595 _putx( offset );
    1596 _puts("\n - write sectors   = ");
    1597 _putx( count );
    1598 _puts("\n - file sectors    = ");
    1599 _putx( file_sectors );
    1600 _puts("\n - need_allocate   = ");
    1601 _putd( allocate );   
     1474
     1475_printf("\n[FAT DEBUG] _fat_write() : P[%d,%d,%d] enters for file %s\n"
     1476        " - buffer vbase    = %x\n"
     1477        " - skipped sectors = %x\n"
     1478        " - write sectors   = %x\n"
     1479        " - file sectors    = %x\n"
     1480        " - need_allocate   = %d\n",
     1481        x, y, p,
     1482        fat.fd[fd_id].name
     1483        (unsigned int)buffer,
     1484        offset,
     1485        count,
     1486        file_sectors,
     1487        allocate );
    16021488#endif
    16031489
     
    16051491    if ( fd_id >= GIET_OPEN_FILES_MAX )
    16061492    {
    1607         _puts("\n[FAT ERROR] in _fat_write() : illegal file descriptor index\n");
     1493        _printf("\n[FAT ERROR] in _fat_write() : illegal file descriptor index\n");
    16081494        return -1;
    16091495    }
    16101496    if ( fat.fd[fd_id].used != 1 )
    16111497    {
    1612         _puts("\n[FAT ERROR] in _fat_write() : file not open\n");
     1498        _printf("\n[FAT ERROR] in _fat_write() : file not open\n");
    16131499        return -1;
    16141500    }
    16151501    if ( ((unsigned int)buffer & 0x1FF) != 0 )
    16161502    {
    1617         _puts("\n[FAT ERROR] in _fat_write() : memory buffer not sector aligned\n");
     1503        _printf("\n[FAT ERROR] in _fat_write() : memory buffer not sector aligned\n");
    16181504        return -1;
    16191505    }
     
    16231509        if ( _fat_allocate( fd_id, (required_cluster - current_cluster) ) < 0 )
    16241510        {
    1625             _puts("\n[FAT ERROR] in _fat_write() : fat_allocate failed\n");
     1511            _printf("\n[FAT ERROR] in _fat_write() : fat_allocate failed\n");
    16261512            return -1;
    16271513        }
     
    16361522
    16371523#if GIET_DEBUG_FAT
    1638 _puts("\n - first cluster   = ");
    1639 _putx( cluster );
    1640 _puts("\n - skiped clusters = ");
    1641 _putx( clusters_to_skip );   
    1642 _puts("\n");
     1524_printf("\n[FAT DEBUG] _fat_write() : P[%d,%d,%d] get cluster %x\n",
     1525        x, y, p, cluster );
    16431526#endif
    16441527
     
    16691552
    16701553#if GIET_DEBUG_FAT
    1671 _puts("\n[FAT DEBUG] _fat_write() : P[");
    1672 _putd( x );
    1673 _puts(",");
    1674 _putd( y );
    1675 _puts(",");
    1676 _putd( p );
    1677 _puts("] makes an IOC write");
    1678 _puts("\n - cluster = ");
    1679 _putx( cluster );
    1680 _puts("\n - buf     = ");
    1681 _putx( (unsigned int)src );
    1682 _puts("\n - lba     = ");
    1683 _putx( lba );
    1684 _puts("\n - sectors = ");
    1685 _putd( iter_sectors );
    1686 _puts("\n");
     1554_printf("\n[FAT DEBUG] _fat_write() : P[%d,%d,%d] makes an IOC write"
     1555        " - cluster  = %x\n"
     1556        " - buffer   = %x\n"
     1557        " - lba      = %x\n"
     1558        " - sectors  = %x\n",
     1559        x, y, p,
     1560        cluster,
     1561        (unsigned int) src,
     1562        lba,
     1563        iter_sectors );
    16871564#endif
    16881565
     
    16931570                        iter_sectors ) )   // number of sectors
    16941571        {
    1695             _puts("\n[FAT ERROR] in _fat_write() cannot write block ");
    1696             _putx( lba );
    1697             _puts("\n");
     1572            _printf("\n[FAT ERROR] in _fat_write() cannot write block %x\n", lba );
    16981573            return -1;
    16991574        }
     
    17191594    if ( update_entry(fd_id, DIR_FILE_SIZE, fat.fd[fd_id].file_size) )
    17201595    {
    1721             _puts("\n[FAT ERROR] in _fat_write() update entry failed\n");
     1596            _printf("\n[FAT ERROR] in _fat_write() update entry failed\n");
    17221597            return -1;
    17231598    }
     
    17491624    else
    17501625    {
    1751         _puts("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n");
     1626        _printf("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n");
    17521627        return -1;
    17531628    }
     
    17681643    else
    17691644    {
    1770         _puts("\n[FAT ERROR] in _fat_close() : illegal file descriptor index\n");
     1645        _printf("\n[FAT ERROR] in _fat_close() : illegal file descriptor index\n");
    17711646        return -1;
    17721647    }
     
    18281703                     unsigned int whence )
    18291704{
    1830     _puts("[GIET ERROR] _fat_user_lseek() not implemented\n");
     1705    _printf("\n[GIET ERROR] _fat_user_lseek() not implemented\n");
    18311706    _exit();
    18321707    return 0;
  • soft/giet_vm/giet_fat32/fat32.h

    r458 r503  
    1010
    1111#include "giet_config.h"
    12 #include "locks.h"
     12#include "kernel_locks.h"
    1313
    1414/*************** Partition Boot Sector Format ******************************************/
Note: See TracChangeset for help on using the changeset viewer.