Changeset 503 for soft/giet_vm
- Timestamp:
- Feb 8, 2015, 9:22:56 PM (10 years ago)
- Location:
- soft/giet_vm/giet_fat32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r474 r503 36 36 // This function displays the content of the FAT cache 37 37 ////////////////////////////////////////////////////////////////////////////////// 38 void display_fat_cache()38 void _display_fat_cache() 39 39 { 40 40 unsigned int line; … … 78 78 _puts("***************************************************************************\n"); 79 79 80 } // end display_fat_cache()80 } // end _display_fat_cache() 81 81 82 82 ////////////////////////////////////////////////////////////////////////////////// … … 191 191 unsigned int p = procid & ((1<<P_WIDTH)-1); 192 192 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 ); 202 195 #endif 203 196 … … 214 207 1 ) ) // one sector 215 208 { 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 ); 219 210 return 1; 220 211 } … … 222 213 223 214 #if (GIET_DEBUG_FAT > 1) 224 display_fat_cache();215 _display_fat_cache(); 225 216 #endif 226 217 … … 232 223 233 224 #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 ); 243 226 #endif 244 227 … … 512 495 1 ) ) // one sector 513 496 { 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 ); 517 498 return 1; 518 499 } … … 543 524 else if (ord == NO_MORE_ENTRY ) // end of directory : return 544 525 { 545 _p uts("[FAT ERROR] in update_entry() : reaches end of directory\n");526 _printf("\n[FAT ERROR] in update_entry() : reaches end of directory\n"); 546 527 return 1; 547 528 } … … 569 550 else if (ord == NO_MORE_ENTRY ) // end of directory : return 570 551 { 571 _p uts("[FAT ERROR] in update_entry() reaches end of directory\n");552 _printf("\n[FAT ERROR] in update_entry() reaches end of directory\n"); 572 553 return 1; 573 554 } … … 634 615 635 616 #if GIET_DEBUG_FAT 636 _p uts("\n[FAT DEBUG] _update_fs_info() : enters\n");617 _printf("\n[FAT DEBUG] _update_fs_info() : enters\n"); 637 618 #endif 638 619 … … 650 631 1 ) ) // one sector 651 632 { 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 ); 655 634 return 1; 656 635 } … … 677 656 678 657 #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 ); 684 659 #endif 685 660 … … 696 671 1 ) ) // one sector 697 672 { 698 _p uts("[FAT_ERROR] in _update_fat() cannot read block %x\n");673 _printf("\n[FAT_ERROR] in _update_fat() cannot read block %x\n", lba ); 699 674 return 1; 700 675 } … … 717 692 unsigned int count ) 718 693 { 719 unsigned int next_cluster = fat.fd[fd_id].first_cluster; // Get the first cluster of file720 unsigned int cluster_to_allocate = count; // Number of clusterto allocate721 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) 722 697 unsigned int free_cluster = fat.last_cluster_allocated + 1; // First free cluster 723 698 … … 725 700 if ( _get_next_cluster( IOC_KERNEL_MODE, free_cluster ) != FREE_CLUSTER) 726 701 { 727 _p uts("\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"); 728 703 return -1; 729 704 } … … 731 706 if ( count > fat.number_free_cluster ) 732 707 { 733 _p uts("\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"); 734 709 return -1; 735 710 } 736 711 737 712 #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 ); 741 714 #endif 742 715 743 716 // Get the last cluster allocated for the file (seek END_OF_CHAIN_CLUSTER). 744 do{ 717 do 718 { 745 719 last_cluster_file = next_cluster; 746 720 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 ); 748 723 749 724 // Loop on the number of clusters to be allocated … … 752 727 753 728 #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 ); 761 731 #endif 762 732 … … 765 735 if ( _update_fat( last_cluster_file, free_cluster ) ) 766 736 { 767 _p uts("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");737 _printf("\n[FAT ERROR] in _fat_allocate() : update fat failed\n"); 768 738 return -1; 769 739 } … … 780 750 if ( _update_fat( last_cluster_file, END_OF_CHAIN_CLUSTER ) ) 781 751 { 782 _p uts("\n[FAT ERROR] in _fat_allocate() : update fat failed\n");752 _printf("\n[FAT ERROR] in _fat_allocate() : update fat failed\n"); 783 753 return -1; 784 754 } … … 790 760 if ( _get_next_cluster( IOC_KERNEL_MODE, free_cluster ) != FREE_CLUSTER) 791 761 { 792 _p uts("\n[FAT ERROR] in _fat_allocate() : free_cluster not free\n");762 _printf("\n[FAT ERROR] in _fat_allocate() : free_cluster not free\n"); 793 763 return -1; 794 764 } … … 802 772 if ( _update_fs_info() ) 803 773 { 804 _p uts("\n[FAT ERROR] in _fat_allocate() : update fs_info failed\n");774 _printf("\n[FAT ERROR] in _fat_allocate() : update fs_info failed\n"); 805 775 return -1; 806 776 } … … 847 817 unsigned int p = procid & ((1<<P_WIDTH)-1); 848 818 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 ); 860 821 #endif 861 822 … … 872 833 1 ) ) // one sector 873 834 { 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 ); 877 836 return -1; 878 837 } … … 881 840 882 841 #if ( GIET_DEBUG_FAT > 1 ) 883 display_fat_cache();842 _display_fat_cache(); 884 843 #endif 885 844 … … 912 871 1 ) ) // one sector 913 872 { 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); 917 874 return -1; 918 875 } … … 1008 965 1009 966 #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 ); 1021 969 #endif 1022 970 … … 1035 983 unsigned int dir_cluster ) 1036 984 { 1037 _p uts("\n[FAT ERROR] _fat_create() not implemented\n");985 _printf("\n[FAT ERROR] _fat_create() not implemented\n"); 1038 986 return 0; 1039 987 } //end _fat_create() … … 1049 997 // This should be done only once. 1050 998 ////////////////////////////////////////////////////////////////////////// 1051 // Return 0 if success, Return -1if failure999 // Return 0 if success, exit if failure 1052 1000 ////////////////////////////////////////////////////////////////////////// 1053 1001 int _fat_init( unsigned int mode ) // mode for IOC driver … … 1061 1009 unsigned int p = procid & ((1<<P_WIDTH)-1); 1062 1010 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"); 1011 if ( mode == IOC_BOOT_MODE ) 1012 _printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters in BOOT_MODE\n",x,y,p); 1013 if ( mode == IOC_KERNEL_MODE ) 1014 _printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters in KERNEL_MODE\n",x,y,p); 1015 if ( mode == IOC_USER_MODE ) 1016 _printf("\n[FAT DEBUG] _fat_init() : P[%d,%d,%d] enters in USER_MODE\n",x,y,p); 1073 1017 #endif 1074 1018 … … 1076 1020 if ( fat.initialised == FAT_INITIALISED ) 1077 1021 { 1078 _p uts("\n[FAT WARNING] Strange initialisation of aFAT already initialised...\n");1079 return 0;1022 _printf("\n[FAT WARNING] Strange, FAT already initialised...\n"); 1023 _exit(); 1080 1024 } 1081 1025 … … 1087 1031 1 ) ) // one sector 1088 1032 { 1089 _p uts("\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(); 1091 1035 } 1092 1036 fat.cache_lba = 0; 1093 1037 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(); 1096 1041 #endif 1097 1042 … … 1099 1044 if( _read_entry( BPB_BYTSPERSEC, fat.fat_cache, 1 ) != 512 ) 1100 1045 { 1101 _p uts("\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(); 1103 1048 } 1104 1049 if( _read_entry( BPB_NUMFATS, fat.fat_cache, 1 ) != 1 ) 1105 1050 { 1106 _p uts("\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(); 1108 1053 } 1109 1054 if( (_read_entry( BPB_FAT32_FATSZ32, fat.fat_cache, 1 ) & 0xF) != 0 ) 1110 1055 { 1111 _p uts("\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(); 1113 1058 } 1114 1059 if( _read_entry( BPB_FAT32_ROOTCLUS, fat.fat_cache, 1 ) != 2 ) 1115 1060 { 1116 _p uts("\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(); 1118 1063 } 1119 1064 // FS Info always in sector 1 … … 1136 1081 1137 1082 #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 ); 1141 1084 #endif 1142 1085 … … 1148 1091 1 ) ) // one sector 1149 1092 { 1150 _p uts("\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(); 1152 1095 } 1153 1096 fat.cache_lba = fat.fs_info_lba; … … 1159 1102 #if GIET_DEBUG_FAT 1160 1103 _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" ); 1168 1105 #endif 1169 1106 … … 1174 1111 void _fat_print() 1175 1112 { 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 ); 1186 1131 } 1187 1132 … … 1216 1161 unsigned int p = procid & ((1<<P_WIDTH)-1); 1217 1162 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 ); 1227 1165 #endif 1228 1166 … … 1230 1168 if ( creat ) 1231 1169 { 1232 _p uts("[FAT ERROR] in _fat_open() : create not supported yet\n");1170 _printf("\n[FAT ERROR] in _fat_open() : create not supported yet\n"); 1233 1171 return -1; 1234 1172 } … … 1237 1175 if( fat.initialised != FAT_INITIALISED ) 1238 1176 { 1239 _p uts("[FAT ERROR] in _fat_open() : FAT not initialised\n");1177 _printf("\n[FAT ERROR] in _fat_open() : FAT not initialised\n"); 1240 1178 return -1; 1241 1179 } … … 1244 1182 1245 1183 #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 ); 1253 1186 #endif 1254 1187 … … 1266 1199 1267 1200 #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 ); 1277 1203 #endif 1278 1204 … … 1293 1219 else if ( cluster == END_OF_CHAIN_CLUSTER ) 1294 1220 { 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 ); 1298 1222 _spin_lock_release( &fat.fat_lock ); 1299 1223 return -1; … … 1302 1226 1303 1227 #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 ); 1315 1230 #endif 1316 1231 … … 1337 1252 1338 1253 #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 ); 1350 1256 #endif 1351 1257 … … 1357 1263 else 1358 1264 { 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 ); 1362 1267 _spin_lock_release( &fat.fat_lock ); 1363 1268 return -1; … … 1366 1271 else 1367 1272 { 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 ); 1371 1275 _spin_lock_release( &fat.fat_lock ); 1372 1276 return -1; … … 1399 1303 if ( fd_id >= GIET_OPEN_FILES_MAX ) 1400 1304 { 1401 _p uts("\n[FAT ERROR] in _fat_read() : illegal file descriptor index\n");1305 _printf("\n[FAT ERROR] in _fat_read() : illegal file descriptor index\n"); 1402 1306 return -1; 1403 1307 } 1404 1308 if ( fat.fd[fd_id].used != 1 ) 1405 1309 { 1406 _p uts("\n[FAT ERROR] in _fat_read() : file not open\n");1310 _printf("\n[FAT ERROR] in _fat_read() : file not open\n"); 1407 1311 return -1; 1408 1312 } 1409 1313 if ( ((unsigned int)buffer & 0x1FF) != 0 ) 1410 1314 { 1411 _p uts("\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"); 1412 1316 return -1; 1413 1317 } … … 1420 1324 if ( offset >= file_sectors ) 1421 1325 { 1422 _p uts("\n[FAT ERROR] offset larger than number of sectors\n");1326 _printf("\n[FAT ERROR] offset larger than number of sectors\n"); 1423 1327 return -1; 1424 1328 } … … 1440 1344 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1441 1345 unsigned 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 ); 1461 1359 #endif 1462 1360 … … 1487 1385 1488 1386 #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 ); 1505 1397 #endif 1506 1398 … … 1511 1403 iter_sectors ) ) // number of sectors 1512 1404 { 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 ); 1516 1406 return -1; 1517 1407 } … … 1582 1472 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1583 1473 unsigned 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 ); 1602 1488 #endif 1603 1489 … … 1605 1491 if ( fd_id >= GIET_OPEN_FILES_MAX ) 1606 1492 { 1607 _p uts("\n[FAT ERROR] in _fat_write() : illegal file descriptor index\n");1493 _printf("\n[FAT ERROR] in _fat_write() : illegal file descriptor index\n"); 1608 1494 return -1; 1609 1495 } 1610 1496 if ( fat.fd[fd_id].used != 1 ) 1611 1497 { 1612 _p uts("\n[FAT ERROR] in _fat_write() : file not open\n");1498 _printf("\n[FAT ERROR] in _fat_write() : file not open\n"); 1613 1499 return -1; 1614 1500 } 1615 1501 if ( ((unsigned int)buffer & 0x1FF) != 0 ) 1616 1502 { 1617 _p uts("\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"); 1618 1504 return -1; 1619 1505 } … … 1623 1509 if ( _fat_allocate( fd_id, (required_cluster - current_cluster) ) < 0 ) 1624 1510 { 1625 _p uts("\n[FAT ERROR] in _fat_write() : fat_allocate failed\n");1511 _printf("\n[FAT ERROR] in _fat_write() : fat_allocate failed\n"); 1626 1512 return -1; 1627 1513 } … … 1636 1522 1637 1523 #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 ); 1643 1526 #endif 1644 1527 … … 1669 1552 1670 1553 #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 ); 1687 1564 #endif 1688 1565 … … 1693 1570 iter_sectors ) ) // number of sectors 1694 1571 { 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 ); 1698 1573 return -1; 1699 1574 } … … 1719 1594 if ( update_entry(fd_id, DIR_FILE_SIZE, fat.fd[fd_id].file_size) ) 1720 1595 { 1721 _p uts("\n[FAT ERROR] in _fat_write() update entry failed\n");1596 _printf("\n[FAT ERROR] in _fat_write() update entry failed\n"); 1722 1597 return -1; 1723 1598 } … … 1749 1624 else 1750 1625 { 1751 _p uts("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n");1626 _printf("\n[FAT ERROR] in _fat_fstat() : illegal file descriptor index\n"); 1752 1627 return -1; 1753 1628 } … … 1768 1643 else 1769 1644 { 1770 _p uts("\n[FAT ERROR] in _fat_close() : illegal file descriptor index\n");1645 _printf("\n[FAT ERROR] in _fat_close() : illegal file descriptor index\n"); 1771 1646 return -1; 1772 1647 } … … 1828 1703 unsigned int whence ) 1829 1704 { 1830 _p uts("[GIET ERROR] _fat_user_lseek() not implemented\n");1705 _printf("\n[GIET ERROR] _fat_user_lseek() not implemented\n"); 1831 1706 _exit(); 1832 1707 return 0; -
soft/giet_vm/giet_fat32/fat32.h
r458 r503 10 10 11 11 #include "giet_config.h" 12 #include " locks.h"12 #include "kernel_locks.h" 13 13 14 14 /*************** Partition Boot Sector Format ******************************************/
Note: See TracChangeset
for help on using the changeset viewer.