Changeset 354 for soft/giet_vm
- Timestamp:
- Jun 29, 2014, 1:25:59 PM (10 years ago)
- Location:
- soft/giet_vm/giet_fat32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r345 r354 37 37 // This function displays the content of the FAT cache 38 38 ////////////////////////////////////////////////////////////////////////////////// 39 #if GIET_DEBUG_FAT40 39 void display_fat_cache() 41 40 { … … 77 76 _printf("**************************************************************************\n"); 78 77 } // end display_fat_cache() 79 #endif80 78 81 79 ////////////////////////////////////////////////////////////////////////////////// … … 263 261 char ch; 264 262 265 #if GIET_DEBUG_FAT266 _printf("\n[FAT DEBUG] filename %s", string );267 #endif268 269 263 if(string[0] == '.' && string[1] == '\0') 270 264 { 271 265 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; 346 318 } 347 319 … … 850 822 851 823 fat.cache_lba = lba; 852 853 #if GIET_DEBUG_FAT854 display_fat_cache();855 #endif856 824 857 825 // in this loop we scan all names in directory identified by cluster: … … 1045 1013 #if GIET_DEBUG_FAT 1046 1014 _printf("\n[FAT DEBUG] Boot Sector Loaded\n"); 1047 display_fat_cache();1048 1015 #endif 1049 1016 … … 1079 1046 fat.fat_lba = read_entry( BPB_RSVDSECCNT, fat.fat_cache, 1 ); 1080 1047 fat.data_lba = fat.fat_lba + fat.fat_sectors; 1048 fat.fat_lock.value = 0; 1081 1049 fat.initialised = FAT_INITIALISED; 1082 1050 … … 1106 1074 _printf("\n[FAT DEBUG] Processor[%d,%d,%d] exit _fat_init() / " 1107 1075 "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 ); 1109 1077 #endif 1110 1078 … … 1126 1094 1127 1095 /////////////////////////////////////////////////////////////////////////////// 1128 // This function checks that the kernel FAT structure has been initialised ,1129 // and makes the FAT initialisation if it is the first useropen 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. 1130 1098 // This function searches a file identified by the "pathname" argument. 1131 1099 // It starts from root (cluster 2) to scan successively each subdirectory. … … 1133 1101 // a new file is created and introduced in the directory. 1134 1102 // Finally, it sets a new open file in the file descriptors array. 1135 // The same file can be open several times by differents ta ks.1103 // The same file can be open several times by differents tasks. 1136 1104 /////////////////////////////////////////////////////////////////////////////// 1137 1105 // Returns file descriptor index if success, returns -1 if error. … … 1141 1109 unsigned int creat ) 1142 1110 { 1143 char name[256]; // buffer for one name in pathname1144 unsigned int nb_read; // number of characters written in name[]1145 unsigned int cluster; // current cluster index when scanning FAT1146 unsigned int dir_cluster; // previous cluster index when scanning FAT1147 unsigned int fd_id; // index when scanning file descriptors array1148 unsigned int file_size ; // number of bytes1149 unsigned int last_name ; // directory containing file name is reached1150 unsigned int lba ;// lba of dir_entry for this file1111 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 1151 1119 1152 1120 #if GIET_DEBUG_FAT … … 1169 1137 1170 1138 // takes the FAT lock for exclusive access 1171 _get_lock( &fat. lock );1139 _get_lock( &fat.fat_lock ); 1172 1140 1173 1141 #if GIET_DEBUG_FAT … … 1184 1152 1185 1153 // release FAT lock 1186 _release_lock( &fat. lock );1154 _release_lock( &fat.fat_lock ); 1187 1155 1188 1156 return -1; … … 1233 1201 1234 1202 // release FAT lock 1235 _release_lock( &fat. lock );1203 _release_lock( &fat.fat_lock ); 1236 1204 1237 1205 return -1; … … 1266 1234 1267 1235 // release FAT lock 1268 _release_lock( &fat. lock );1236 _release_lock( &fat.fat_lock ); 1269 1237 1270 1238 return fd_id; … … 1276 1244 1277 1245 // release FAT lock 1278 _release_lock( &fat. lock );1246 _release_lock( &fat.fat_lock ); 1279 1247 1280 1248 return -1; … … 1287 1255 1288 1256 // release FAT lock 1289 _release_lock( &fat. lock );1257 _release_lock( &fat.fat_lock ); 1290 1258 1291 1259 return -1; … … 1306 1274 unsigned int offset ) // nuber of sectors to skip in file 1307 1275 { 1308 1309 #if GIET_DEBUG_FAT1310 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 #endif1322 1323 1276 unsigned int spc = fat.sectors_per_cluster; 1324 1277 … … 1369 1322 1370 1323 #if GIET_DEBUG_FAT 1371 _printf(" - first cluster = %x\n" 1324 unsigned int procid = _get_procid(); 1325 unsigned int cid = procid / NB_PROCS_MAX; 1326 unsigned int lpid = procid % NB_PROCS_MAX; 1327 unsigned int x = cid >> Y_WIDTH; 1328 unsigned 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" 1372 1335 " - 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 ); 1374 1338 #endif 1375 1339 -
soft/giet_vm/giet_fat32/fat32.h
r300 r354 10 10 11 11 #include "giet_config.h" 12 #include "utils.h" 12 13 13 14 /*************** Partition Boot Sector Format ******************************************/ … … 137 138 { 138 139 char fat_cache[512]; // FAT cache: 1 sector = 128 cluster indexes 140 giet_lock_t fat_lock; // lock protecting exclusive access 139 141 file_desc_t fd[GIET_OPEN_FILES_MAX]; // file descriptors array 140 142 unsigned int initialised; // contains 0xBABEF00D when FAT initialised … … 149 151 unsigned int number_free_cluster; // number of free clusters 150 152 unsigned int fs_info_lba; // lba of fs_info 151 unsigned int lock; // lock protecting exclusive access152 153 } fat32_fs_t; 153 154 /***************************************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.