Changeset 653 for soft/giet_vm/giet_fat32/fat32.c
- Timestamp:
- Jul 22, 2015, 2:31:34 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r652 r653 1017 1017 if ( pdesc == NULL ) // miss 1018 1018 { 1019 // allocate one cluster descriptor and one 4K buffer1020 unsigned char* buf = _malloc( 4096 );1021 pdesc = _malloc( sizeof(fat_cache_desc_t) );1022 1023 1019 // get missing cluster index lba 1024 1020 unsigned int lba; … … 1054 1050 } 1055 1051 1052 // allocate 4K buffer 1053 void* buf = _malloc( 4096 ); 1054 1056 1055 // load one cluster (8 blocks) from block device 1057 1056 if ( _fat_ioc_access( 1, // descheduling … … 1061 1060 8 ) ) 1062 1061 { 1062 _free( buf ); 1063 1063 _printf("\n[FAT ERROR] in _get_buffer_from_cache()" 1064 1064 " : cannot access block device for lba = %x\n", lba ); … … 1066 1066 } 1067 1067 1068 // update cache andbuffer descriptor1069 node->children[index] = pdesc;1068 // allocate buffer descriptor 1069 pdesc = _malloc( sizeof(fat_cache_desc_t) ); 1070 1070 pdesc->lba = lba; 1071 1071 pdesc->buffer = buf; 1072 1072 pdesc->dirty = 0; 1073 node->children[index] = pdesc; 1073 1074 1074 1075 #if (GIET_DEBUG_FAT & 1) … … 1225 1226 // search the 64-tree cache from top to bottom 1226 1227 fat_cache_node_t* node = inode->cache; 1227 unsigned int level = inode->levels;1228 1229 while ( level)1228 unsigned int level; 1229 1230 for ( level = inode->levels; level != 0; level-- ) 1230 1231 { 1231 1232 // compute child index … … 1241 1242 _exit(); 1242 1243 } 1243 1244 // allocate a cluster descriptor and a 4K buffer1245 pdesc = _malloc( sizeof(fat_cache_desc_t) );1246 unsigned char* buffer = _malloc( 4096 );1247 1244 1248 1245 #if (GIET_DEBUG_FAT & 1) … … 1252 1249 #endif 1253 1250 1254 // update cache and pdesc 1251 // allocate buffer descriptor 1252 pdesc = _malloc( sizeof(fat_cache_desc_t) ); 1253 pdesc->lba = _cluster_to_lba( cluster ); 1254 pdesc->buffer = _malloc( 4096 ); 1255 pdesc->dirty = 1; 1255 1256 node->children[index] = pdesc; 1256 pdesc->lba = _cluster_to_lba( cluster );1257 pdesc->buffer = buffer;1258 pdesc->dirty = 1;1259 1260 // prepare next iteration1261 level--;1262 1257 } 1263 1258 else // not last level => children are 64-tree nodes … … 1273 1268 // prepare next iteration 1274 1269 node = child; 1275 level--; 1276 } 1277 } // end while 1270 } 1271 } // end for 1278 1272 } // end _allocate_one_buffer 1279 1273
Note: See TracChangeset
for help on using the changeset viewer.