Changeset 443
- Timestamp:
- Nov 3, 2014, 11:30:32 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r429 r443 41 41 unsigned int word; 42 42 unsigned int temp[9]; 43 unsigned int save_sr; // for tty_get_lock()44 45 43 46 44 temp[8] = 0; 47 48 _tty_get_lock( 0, &save_sr );49 45 50 46 _puts("\n*********************** fat_cache_lba = "); … … 81 77 } 82 78 _puts("***************************************************************************\n"); 83 84 _tty_release_lock( 0, &save_sr );85 79 86 80 } // end display_fat_cache() … … 197 191 unsigned int p = procid & ((1<<P_WIDTH)-1); 198 192 199 _printf("\n[FAT DEBUG] _get_next_cluster() : P[%d,%d,%d] enters for cluster %x\n", 200 x, y, p, cluster ); 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"); 201 202 #endif 202 203 … … 213 214 1 ) ) // one sector 214 215 { 215 _printf("[FAT_ERROR] in get_next cluster_id() " 216 "cannot read block %x\n", lba ); 216 _puts("[FAT_ERROR] in get_next cluster_id() : cannot read block "); 217 _putx( lba ); 218 _puts("\n"); 217 219 return 1; 218 220 } … … 230 232 231 233 #if GIET_DEBUG_FAT 232 _printf("\n[FAT DEBUG] _get_next_cluster() : P[%d,%d,%d] next cluster = %x\n", 233 x, y, p, next ); 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"); 234 243 #endif 235 244 … … 503 512 1 ) ) // one sector 504 513 { 505 _printf("[FAT ERROR] in update_entry() cannot read sector %x\n", lba ); 514 _puts("[FAT ERROR] in update_entry() cannot read sector "); 515 _putx( lba ); 516 _puts("\n"); 506 517 return 1; 507 518 } … … 532 543 else if (ord == NO_MORE_ENTRY ) // end of directory : return 533 544 { 534 _p rintf("[FAT ERROR] in update_entry() : reaches end of directory\n");545 _puts("[FAT ERROR] in update_entry() : reaches end of directory\n"); 535 546 return 1; 536 547 } … … 558 569 else if (ord == NO_MORE_ENTRY ) // end of directory : return 559 570 { 560 _p rintf("[FAT ERROR] in update_entry() reaches end of directory\n");571 _puts("[FAT ERROR] in update_entry() reaches end of directory\n"); 561 572 return 1; 562 573 } … … 623 634 624 635 #if GIET_DEBUG_FAT 625 _p rintf("\n[FAT DEBUG] _update_fs_info() : enters\n");636 _puts("\n[FAT DEBUG] _update_fs_info() : enters\n"); 626 637 #endif 627 638 … … 639 650 1 ) ) // one sector 640 651 { 641 _printf("[FAT_ERROR] in _update_fat() cannot read block %x\n", lba ); 652 _puts("[FAT_ERROR] in _update_fat() cannot read block "); 653 _putx( lba ); 654 _puts("\n"); 642 655 return 1; 643 656 } … … 664 677 665 678 #if GIET_DEBUG_FAT 666 _printf("\n[FAT DEBUG] _update_fat() : cluster = %x / value = %x\n", 667 cluster, value ); 679 _puts("\n[FAT DEBUG] _update_fat() : cluster = "); 680 _putx( cluster ); 681 _puts(" / value = "); 682 _putx( value ); 683 _puts("\n"); 668 684 #endif 669 685 … … 680 696 1 ) ) // one sector 681 697 { 682 _p rintf("[FAT_ERROR] in _update_fat() cannot read block %x\n");698 _puts("[FAT_ERROR] in _update_fat() cannot read block %x\n"); 683 699 return 1; 684 700 } … … 694 710 695 711 ////////////////////////////////////////////////////////////////////////////////// 696 // This function allocate a count number of clusterto a file by calling the712 // This function allocate count clusters to a file by calling the 697 713 // _update_fat function that takes care to update the chaining of clusters. 698 714 // return 0 if success, -1 if failure … … 709 725 if ( _get_next_cluster( IOC_KERNEL_MODE, free_cluster ) != FREE_CLUSTER) 710 726 { 711 _p rintf("\n[FAT ERROR] in _fat_allocate() : first free_cluster not free\n");727 _puts("\n[FAT ERROR] in _fat_allocate() : first free_cluster not free\n"); 712 728 return -1; 713 729 } … … 715 731 if ( count > fat.number_free_cluster ) 716 732 { 717 _p rintf("\n[FAT ERROR] in _fat_allocate() : Not enough free cluster(s)\n");733 _puts("\n[FAT ERROR] in _fat_allocate() : Not enough free cluster(s)\n"); 718 734 return -1; 719 735 } 720 736 721 737 #if GIET_DEBUG_FAT 722 _printf("\n[FAT DEBUG] _fat_allocate() for file %d\n", fd_id ); 738 _puts("\n[FAT DEBUG] _fat_allocate() for fd = "); 739 _putd( fd_id ); 740 _puts("\n"); 723 741 #endif 724 742 … … 729 747 }while ( next_cluster < END_OF_CHAIN_CLUSTER ); 730 748 731 // Loop on the number of cluster neededto be allocated749 // Loop on the number of clusters to be allocated 732 750 while ( cluster_to_allocate > 0 ) 733 751 { 734 752 735 753 #if GIET_DEBUG_FAT 736 _printf("\n[FAT DEBUG] cluster to update = %x / free cluster = %x / clusters required = %d\n", 737 last_cluster_file, free_cluster, cluster_to_allocate ); 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"); 738 761 #endif 739 762 … … 742 765 if ( _update_fat( last_cluster_file, free_cluster ) ) 743 766 { 744 _p rintf("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");767 _puts("\n[FAT ERROR] in _fat_allocate() : update fat failed\n"); 745 768 return -1; 746 769 } … … 757 780 if ( _update_fat( last_cluster_file, END_OF_CHAIN_CLUSTER ) ) 758 781 { 759 _p rintf("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");782 _puts("\n[FAT ERROR] in _fat_allocate() : update fat failed\n"); 760 783 return -1; 761 784 } … … 767 790 if ( _get_next_cluster( IOC_KERNEL_MODE, free_cluster ) != FREE_CLUSTER) 768 791 { 769 _p rintf("\n[FAT ERROR] in _fat_allocate() : free_cluster not free\n");792 _puts("\n[FAT ERROR] in _fat_allocate() : free_cluster not free\n"); 770 793 return -1; 771 794 } … … 779 802 if ( _update_fs_info() ) 780 803 { 781 _p rintf("\n[FAT ERROR] in _fat_allocate() : update fs_info failed\n");804 _puts("\n[FAT ERROR] in _fat_allocate() : update fs_info failed\n"); 782 805 return -1; 783 806 } … … 824 847 unsigned int p = procid & ((1<<P_WIDTH)-1); 825 848 826 _printf("\n[FAT DEBUG] _scan_directory() : P[%d,%d,%d] enters for %s / is_sfn = %d\n", 827 x, y, p, file_name, is_sfn ); 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"); 828 860 #endif 829 861 … … 840 872 1 ) ) // one sector 841 873 { 842 _printf("[FAT ERROR] in _scan_directory() : cannot read sector %x\n", lba ); 874 _puts("[FAT ERROR] in _scan_directory() : cannot read sector "); 875 _putx( lba ); 876 _puts("\n"); 843 877 return -1; 844 878 } … … 878 912 1 ) ) // one sector 879 913 { 880 _printf("[FAT ERROR] in _scan_directory() : cannot read sector %x\n", lba ); 914 _puts("[FAT ERROR] in _scan_directory() : cannot read sector "); 915 _putx( lba ); 916 _puts("\n"); 881 917 return -1; 882 918 } … … 972 1008 973 1009 #if GIET_DEBUG_FAT 974 _printf("\n[FAT DEBUG] _scan_directory() : P[%d,%d,%d] found %s / cluster = %x\n", 975 x, y, p, file_name, searched_cluster ); 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") 976 1021 #endif 977 1022 … … 990 1035 unsigned int dir_cluster ) 991 1036 { 992 _p rintf("\n[FAT ERROR] _fat_create() not implemented\n");1037 _puts("\n[FAT ERROR] _fat_create() not implemented\n"); 993 1038 return 0; 994 1039 } //end _fat_create() … … 1014 1059 unsigned int p = procid & ((1<<P_WIDTH)-1); 1015 1060 1016 _printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters", x, y, p ); 1017 if ( mode == IOC_BOOT_MODE ) _printf(" / IOC_BOOT_MODE\n"); 1018 if ( mode == IOC_KERNEL_MODE ) _printf(" / IOC_KERNEL_MODE\n"); 1019 if ( mode == IOC_USER_MODE ) _printf(" / IOC_USER_MODE\n"); 1061 _puts("\n[FAT DEBUG] _fat_init() : P["); 1062 _putd( x ); 1063 _puts(","); 1064 _putd( y ); 1065 _puts(","); 1066 _putd( p ); 1067 _puts("] enters"); 1068 if ( mode == IOC_BOOT_MODE ) _puts(" / IOC_BOOT_MODE\n"); 1069 if ( mode == IOC_KERNEL_MODE ) _puts(" / IOC_KERNEL_MODE\n"); 1070 if ( mode == IOC_USER_MODE ) _puts(" / IOC_USER_MODE\n"); 1020 1071 #endif 1021 1072 … … 1027 1078 1 ) ) // one sector 1028 1079 { 1029 _p rintf("\n[FAT ERROR] in _fat_init() cannot load VBR\n");1080 _puts("\n[FAT ERROR] in _fat_init() cannot load VBR\n"); 1030 1081 return -1; 1031 1082 } … … 1033 1084 1034 1085 #if GIET_DEBUG_FAT 1035 _p rintf("\n[FAT DEBUG] _fat_init() : Boot Sector Loaded\n");1086 _puts("\n[FAT DEBUG] _fat_init() : Boot Sector Loaded\n"); 1036 1087 #endif 1037 1088 … … 1039 1090 if( _read_entry( BPB_BYTSPERSEC, fat.fat_cache, 1 ) != 512 ) 1040 1091 { 1041 _p rintf("\n[FAT ERROR] The sector size must be 512 bytes\n");1092 _puts("\n[FAT ERROR] The sector size must be 512 bytes\n"); 1042 1093 return -1; 1043 1094 } 1044 1095 if( _read_entry( BPB_NUMFATS, fat.fat_cache, 1 ) != 1 ) 1045 1096 { 1046 _p rintf("\n[FAT ERROR] The number of FAT copies in FAT region must be 1\n");1097 _puts("\n[FAT ERROR] The number of FAT copies in FAT region must be 1\n"); 1047 1098 return -1; 1048 1099 } 1049 1100 if( (_read_entry( BPB_FAT32_FATSZ32, fat.fat_cache, 1 ) & 0xF) != 0 ) 1050 1101 { 1051 _p rintf("\n[FAT ERROR] The FAT region in FAT32 must be multiple of 32 sectors\n");1102 _puts("\n[FAT ERROR] The FAT region in FAT32 must be multiple of 32 sectors\n"); 1052 1103 return -1; 1053 1104 } 1054 1105 if( _read_entry( BPB_FAT32_ROOTCLUS, fat.fat_cache, 1 ) != 2 ) 1055 1106 { 1056 _p rintf("\n[FAT ERROR] The first cluster index must be 2\n");1107 _puts("\n[FAT ERROR] The first cluster index must be 2\n"); 1057 1108 return -1; 1058 1109 } … … 1074 1125 1075 1126 #if GIET_DEBUG_FAT 1076 _printf("\n[FAT DEBUG] _fat_init() : FS_INFO Sector = %x\n", fat.fs_info_lba ); 1127 _puts("\n[FAT DEBUG] _fat_init() : FS_INFO Sector = "); 1128 _putx( fat.fs_info_lba ); 1129 _puts("\n"); 1077 1130 #endif 1078 1131 … … 1084 1137 1 ) ) // one sector 1085 1138 { 1086 _p rintf("\n[FAT ERROR] in _fat_init() cannot load FS_INFO Sector\n");1139 _puts("\n[FAT ERROR] in _fat_init() cannot load FS_INFO Sector\n"); 1087 1140 return -1; 1088 1141 } … … 1094 1147 1095 1148 #if GIET_DEBUG_FAT 1096 _printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] initialises FAT descriptor\n", x, y, p );1097 1149 _fat_print(); 1098 _printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] exit\n", x, y, p ); 1150 _puts("\n[FAT DEBUG] _fat_init() : P["); 1151 _putd( x ); 1152 _puts(","); 1153 _putd( y ); 1154 _puts(","); 1155 _putd( p ); 1156 _puts("] exit\n"); 1099 1157 #endif 1100 1158 … … 1105 1163 void _fat_print() 1106 1164 { 1107 _p rintf("\n########################## FAT32 ################################");1108 _p rintf("\nFAT initialised %x",fat.initialised );1109 _p rintf("\nSector Size (bytes) %x",fat.sector_size );1110 _p rintf("\nSectors per cluster %x",fat.sectors_per_cluster );1111 _p rintf("\nFAT region first lba %x",fat.fat_lba );1112 _p rintf("\nData region first lba %x",fat.data_lba );1113 _p rintf("\nNumber of sectors for one FAT %x",fat.fat_sectors );1114 _p rintf("\nNumber of free clusters %x",fat.number_free_cluster );1115 _p rintf("\nLast allocated cluster %x",fat.last_cluster_allocated );1116 _p rintf("\n#################################################################\n");1165 _puts("\n########################## FAT32 ################################"); 1166 _puts("\nFAT initialised "); _putx( fat.initialised ); 1167 _puts("\nSector Size (bytes) "); _putx( fat.sector_size ); 1168 _puts("\nSectors per cluster "); _putx( fat.sectors_per_cluster ); 1169 _puts("\nFAT region first lba "); _putx( fat.fat_lba ); 1170 _puts("\nData region first lba "); _putx( fat.data_lba ); 1171 _puts("\nNumber of sectors for one FAT "); _putx( fat.fat_sectors ); 1172 _puts("\nNumber of free clusters "); _putx( fat.number_free_cluster ); 1173 _puts("\nLast allocated cluster "); _putx( fat.last_cluster_allocated ); 1174 _puts("\n#################################################################\n"); 1117 1175 } 1118 1176 … … 1148 1206 unsigned int p = procid & ((1<<P_WIDTH)-1); 1149 1207 1150 _printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] enters for path %s\n", 1151 x, y, p, pathname ); 1208 _puts("\n[FAT DEBUG] _fat_open() : P["); 1209 _putd( x ); 1210 _puts(","); 1211 _putd( y ); 1212 _puts(","); 1213 _putd( p ); 1214 _puts("] enters for path "); 1215 _puts( pathname ); 1216 _puts("\n"); 1152 1217 #endif 1153 1218 … … 1155 1220 if ( creat ) 1156 1221 { 1157 _p rintf("[FAT ERROR] in _fat_open() : create not supported yet\n");1222 _puts("[FAT ERROR] in _fat_open() : create not supported yet\n"); 1158 1223 return -1; 1159 1224 } … … 1163 1228 1164 1229 #if GIET_DEBUG_FAT 1165 _printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] takes the FAT lock\n", 1166 x, y, p ); 1230 _puts("\n[FAT DEBUG] _fat_open() : P["); 1231 _putd( x ); 1232 _puts(","); 1233 _putd( y ); 1234 _puts(","); 1235 _putd( p ); 1236 _puts("] takes the FAT lock\n"); 1167 1237 #endif 1168 1238 … … 1172 1242 if ( _fat_init( mode ) ) 1173 1243 { 1174 _p rintf("[FAT ERROR] in _fat_open() : Cannot initialize FAT descriptor\n");1244 _puts("[FAT ERROR] in _fat_open() : Cannot initialize FAT descriptor\n"); 1175 1245 _release_lock( &fat.fat_lock ); 1176 1246 return -1; … … 1191 1261 1192 1262 #if GIET_DEBUG_FAT 1193 _printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] search dir/file : %s\n", 1194 x, y, p, name ); 1263 _puts("\n[FAT DEBUG] _fat_open() : P["); 1264 _putd( x ); 1265 _puts(","); 1266 _putd( y ); 1267 _puts(","); 1268 _putd( p ); 1269 _puts("] search dir/file "); 1270 _puts( name ); 1271 _puts("\n"); 1195 1272 #endif 1196 1273 … … 1211 1288 else if ( cluster == END_OF_CHAIN_CLUSTER ) 1212 1289 { 1213 _p rintf("\n[FAT ERROR] in _fat_open() cannot found %s\n", name);1214 1215 // release FAT lock1290 _puts("\n[FAT ERROR] in _fat_open() cannot found "); 1291 _puts( name ); 1292 _puts("\n"); 1216 1293 _release_lock( &fat.fat_lock ); 1217 1218 1294 return -1; 1219 1295 } … … 1221 1297 1222 1298 #if GIET_DEBUG_FAT 1223 _printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] found cluster index for file %s : %x\n", 1224 x, y, p, pathname, cluster ); 1299 _puts("\n[FAT DEBUG] _fat_open() : P["); 1300 _putd( x ); 1301 _puts(","); 1302 _putd( y ); 1303 _puts(","); 1304 _putd( p ); 1305 _puts("] cluster index for file "); 1306 _puts( pathname ); 1307 _puts(" = "); 1308 _putx( cluster ); 1309 _puts("\n"); 1225 1310 #endif 1226 1311 … … 1247 1332 1248 1333 #if GIET_DEBUG_FAT 1249 _printf("\n[FAT DEBUG] _fat_open() : P[%d,%d,%d] exit : fd = %d for file %s\n", 1250 x, y, p, fd_id, pathname ); 1334 _puts("\n[FAT DEBUG] _fat_open() : P["); 1335 _putd( x ); 1336 _puts(","); 1337 _putd( y ); 1338 _puts(","); 1339 _putd( p ); 1340 _puts("] exit : fd = "); 1341 _putd( fd_id ); 1342 _puts(" for file "); 1343 _puts( pathname ); 1344 _puts("\n"); 1251 1345 #endif 1252 1346 … … 1258 1352 else 1259 1353 { 1260 _printf("\n[FAT ERROR] in _fat_open() for file %s : fd array full\n", 1261 pathname ); 1262 1263 // release FAT lock 1354 _puts("\n[FAT ERROR] in _fat_open() for file "); 1355 _puts( pathname ); 1356 _puts(" : fd array full\n"); 1264 1357 _release_lock( &fat.fat_lock ); 1265 1266 1358 return -1; 1267 1359 } … … 1269 1361 else 1270 1362 { 1271 _printf("\n[FAT ERROR] in _fat_open() for file %s : bad cluster\n", 1272 pathname ); 1273 1274 // release FAT lock 1363 _puts("\n[FAT ERROR] in _fat_open() for file "); 1364 _puts( pathname ); 1365 _puts(" : bad cluster\n"); 1275 1366 _release_lock( &fat.fat_lock ); 1276 1277 1367 return -1; 1278 1368 } … … 1304 1394 if ( fd_id >= GIET_OPEN_FILES_MAX ) 1305 1395 { 1306 _p rintf("\n[FAT ERROR] in _fat_read() : illegal file descriptor index\n");1396 _puts("\n[FAT ERROR] in _fat_read() : illegal file descriptor index\n"); 1307 1397 return -1; 1308 1398 } 1309 1399 if ( fat.fd[fd_id].used != 1 ) 1310 1400 { 1311 _p rintf("\n[FAT ERROR] in _fat_read() : file not open\n");1401 _puts("\n[FAT ERROR] in _fat_read() : file not open\n"); 1312 1402 return -1; 1313 1403 } 1314 1404 if ( ((unsigned int)buffer & 0x1FF) != 0 ) 1315 1405 { 1316 _p rintf("\n[FAT ERROR] in _fat_read() : memory buffer not sector aligned\n");1406 _puts("\n[FAT ERROR] in _fat_read() : memory buffer not sector aligned\n"); 1317 1407 return -1; 1318 1408 } … … 1325 1415 if ( offset >= file_sectors ) 1326 1416 { 1327 _p rintf("\n[FAT ERROR] offset larger than number of sectors\n");1417 _puts("\n[FAT ERROR] offset larger than number of sectors\n"); 1328 1418 return -1; 1329 1419 } … … 1345 1435 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1346 1436 unsigned int p = procid & ((1<<P_WIDTH)-1); 1347 _printf("\n[FAT DEBUG] _fat_read() : P[%d,%d,%d] enters for file %s\n" 1348 " - buffer vbase = %x\n" 1349 " - skipped sectors = %x\n" 1350 " - read sectors = %x\n" 1351 " - first cluster = %x\n" 1352 " - skiped clusters = %x\n", 1353 x, y, p, fat.fd[fd_id].name, 1354 (unsigned int)buffer, offset, count, cluster, clusters_to_skip ); 1437 _puts("\n[FAT DEBUG] _fat_read() : P["); 1438 _putd( x ); 1439 _puts(","); 1440 _putd( y ); 1441 _puts(","); 1442 _putd( p ); 1443 _puts("] enters for file "); 1444 _puts( fat.fd[fd_id].name ); 1445 _puts("\n - buffer vbase = "); 1446 _putx( (unsigned int)buffer ); 1447 _puts("\n - skipped sectors = "); 1448 _putx( offset ); 1449 _puts("\n - read sectors = "); 1450 _putx( count ); 1451 _puts("\n - first cluster = "); 1452 _putx( cluster ); 1453 _puts("\n - skiped clusters = "); 1454 _putx( clusters_to_skip ); 1455 _puts("\n"); 1355 1456 #endif 1356 1457 … … 1381 1482 1382 1483 #if GIET_DEBUG_FAT 1383 _printf("\n[FAT DEBUG] _fat_read() : P[%d,%d,%d] makes an IOC read\n" 1384 " - cluster = %x\n" 1385 " - buf = %x\n" 1386 " - lba = %x\n" 1387 " - sectors = %d\n", 1388 x, y, p, cluster, (unsigned int)dst, lba, iter_sectors ); 1484 _puts("\n[FAT DEBUG] _fat_read() : P["); 1485 _putd( x ); 1486 _puts(","); 1487 _putd( y ); 1488 _puts(","); 1489 _putd( p ); 1490 _puts("] makes an IOC read"); 1491 _puts("\n - cluster = "); 1492 _putx( cluster ); 1493 _puts("\n - buf = "); 1494 _putx( (unsigned int)dst ); 1495 _puts("\n - lba = "); 1496 _putx( lba ); 1497 _puts("\n - sectors = "); 1498 _putd( iter_sectors ); 1499 _puts("\n"); 1389 1500 #endif 1390 1501 … … 1395 1506 iter_sectors ) ) // number of sectors 1396 1507 { 1397 _printf("\n[FAT ERROR] in _fat_read() cannot load block %x\n", lba ); 1508 _puts("\n[FAT ERROR] in _fat_read() cannot load block "); 1509 _putx( lba ); 1510 _puts("\n"); 1398 1511 return -1; 1399 1512 } … … 1464 1577 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1465 1578 unsigned int p = procid & ((1<<P_WIDTH)-1); 1466 1467 _printf("\n[FAT DEBUG] _fat_write() : P[%d,%d,%d] enters for file %s\n", 1468 " - buffer vbase = %x\n" 1469 " - skipped sectors = %x\n" 1470 " - write sectors = %x\n" 1471 " - file sectors = %x\n" 1472 " - need allocate = %d\n", 1473 x, y, p, fat.fd[fd_id].name, (unsigned int)buffer, 1474 offset, count, file_sectors, allocate ); 1579 _puts("\n[FAT DEBUG] _fat_write() : P["); 1580 _putd( x ); 1581 _puts(","); 1582 _putd( y ); 1583 _puts(","); 1584 _putd( p ); 1585 _puts("] enters for file "); 1586 _puts( fat.fd[fd_id].name ); 1587 _puts("\n - buffer vbase = "); 1588 _putx( (unsigned int)buffer ); 1589 _puts("\n - skipped sectors = "); 1590 _putx( offset ); 1591 _puts("\n - write sectors = "); 1592 _putx( count ); 1593 _puts("\n - file sectors = "); 1594 _putx( file_sectors ); 1595 _puts("\n - need_allocate = "); 1596 _putd( allocate ); 1475 1597 #endif 1476 1598 … … 1478 1600 if ( fd_id >= GIET_OPEN_FILES_MAX ) 1479 1601 { 1480 _p rintf("\n[FAT ERROR] in _fat_write() : illegal file descriptor index\n");1602 _puts("\n[FAT ERROR] in _fat_write() : illegal file descriptor index\n"); 1481 1603 return -1; 1482 1604 } 1483 1605 if ( fat.fd[fd_id].used != 1 ) 1484 1606 { 1485 _p rintf("\n[FAT ERROR] in _fat_write() : file not open\n");1607 _puts("\n[FAT ERROR] in _fat_write() : file not open\n"); 1486 1608 return -1; 1487 1609 } 1488 1610 if ( ((unsigned int)buffer & 0x1FF) != 0 ) 1489 1611 { 1490 _p rintf("\n[FAT ERROR] in _fat_write() : memory buffer not sector aligned\n");1612 _puts("\n[FAT ERROR] in _fat_write() : memory buffer not sector aligned\n"); 1491 1613 return -1; 1492 1614 } … … 1496 1618 if ( _fat_allocate( fd_id, (required_cluster - current_cluster) ) < 0 ) 1497 1619 { 1498 _p rintf("\n[FAT ERROR] in _fat_write() : fat_allocate failed\n");1620 _puts("\n[FAT ERROR] in _fat_write() : fat_allocate failed\n"); 1499 1621 return -1; 1500 1622 } … … 1509 1631 1510 1632 #if GIET_DEBUG_FAT 1511 _printf(" - first cluster = %x\n" 1512 " - skiped clusters = %x\n", 1513 cluster, clusters_to_skip ); 1633 _puts("\n - first cluster = "); 1634 _putx( cluster ); 1635 _puts("\n - skiped clusters = "); 1636 _putx( clusters_to_skip ); 1637 _puts("\n"); 1514 1638 #endif 1515 1639 … … 1540 1664 1541 1665 #if GIET_DEBUG_FAT 1542 _printf("\n[FAT DEBUG] _fat_write() : P[%d,%d,%d] makes an IOC write : " 1543 "buf = %x / lba = %x / sectors = %x\n", 1544 x, y, p, (unsigned int)src, lba, iter_sectors ); 1666 _puts("\n[FAT DEBUG] _fat_write() : P["); 1667 _putd( x ); 1668 _puts(","); 1669 _putd( y ); 1670 _puts(","); 1671 _putd( p ); 1672 _puts("] makes an IOC write"); 1673 _puts("\n - cluster = "); 1674 _putx( cluster ); 1675 _puts("\n - buf = "); 1676 _putx( (unsigned int)src ); 1677 _puts("\n - lba = "); 1678 _putx( lba ); 1679 _puts("\n - sectors = "); 1680 _putd( iter_sectors ); 1681 _puts("\n"); 1545 1682 #endif 1546 1683 … … 1551 1688 iter_sectors ) ) // number of sectors 1552 1689 { 1553 _printf("\n[FAT ERROR] in _fat_write() cannot write block %x\n", lba ); 1690 _puts("\n[FAT ERROR] in _fat_write() cannot write block "); 1691 _putx( lba ); 1692 _puts("\n"); 1554 1693 return -1; 1555 1694 } … … 1575 1714 if ( update_entry(fd_id, DIR_FILE_SIZE, fat.fd[fd_id].file_size) ) 1576 1715 { 1577 _p rintf("\n[FAT ERROR] in _fat_write() update entry failed\n");1716 _puts("\n[FAT ERROR] in _fat_write() update entry failed\n"); 1578 1717 return -1; 1579 1718 } … … 1605 1744 else 1606 1745 { 1607 _p rintf("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n");1746 _puts("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n"); 1608 1747 return -1; 1609 1748 } … … 1624 1763 else 1625 1764 { 1626 _p rintf("\n[FAT ERROR] in _fat_close() : illegal file descriptor index\n");1765 _puts("\n[FAT ERROR] in _fat_close() : illegal file descriptor index\n"); 1627 1766 return -1; 1628 1767 } … … 1684 1823 unsigned int whence ) 1685 1824 { 1686 _p rintf("[GIET ERROR] _fat_user_lseek() not implemented\n");1825 _puts("[GIET ERROR] _fat_user_lseek() not implemented\n"); 1687 1826 _exit(); 1688 1827 return 0;
Note: See TracChangeset
for help on using the changeset viewer.