Changeset 639 for soft/giet_vm/giet_fat32/fat32.c
- Timestamp:
- Jul 20, 2015, 6:02:55 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r638 r639 420 420 421 421 ////////////////////////////////////////////////////////////////////////////////// 422 // The following function allocates and initializes a new Fat-Cache node. 423 // Its first child can be specified (used when adding a cache level). 424 // The Fat-Cache is initialized as empty: all children set to NULL. 425 // It returns a pointer to a new Fat-Cache node. 426 ////////////////////////////////////////////////////////////////////////////////// 427 428 static fat_cache_node_t* _allocate_one_cache_node( fat_cache_node_t* first_child ); 429 430 ////////////////////////////////////////////////////////////////////////////////// 422 431 // The following function allocates and initializes a new inode, 423 432 // using the values defined by the arguments. 424 433 // If the "cache_allocate" argument is true ans empty cache is allocated. 425 // The Fat-Cache is initialised as empty: all children set to NULL.426 434 // It returns a pointer on the new inode. 427 435 ////////////////////////////////////////////////////////////////////////////////// … … 874 882 875 883 884 //////////////////////////////////////////////////////////// 885 static fat_cache_node_t* _allocate_one_cache_node( fat_cache_node_t* first_child ) 886 { 887 fat_cache_node_t* cnode; 888 unsigned int i; 889 890 cnode = _malloc( sizeof(fat_cache_node_t) ); 891 892 cnode->children[0] = first_child; 893 for ( i = 1 ; i < 64 ; i++ ) 894 cnode->children[i] = NULL; 895 896 return cnode; 897 } // end _allocate_one_cache_node() 898 899 876 900 877 901 //////////////////////////////////////////////////////////// … … 901 925 if ( cache_allocate ) 902 926 { 903 fat_cache_node_t* new_cache = _malloc( sizeof(fat_cache_node_t) ); 904 905 new_inode->cache = new_cache; 927 new_inode->cache = _allocate_one_cache_node( NULL ); 906 928 new_inode->levels = _get_levels_from_size( size ); 907 908 unsigned int index;909 for ( index = 0 ; index < 64 ; index ++ ) new_cache->children[index] = NULL;910 929 } 911 930 … … 1194 1213 unsigned int cluster ) 1195 1214 { 1215 // add cache levels if needed 1216 while ( _get_levels_from_size( (cluster_id + 1) * 4096 ) > inode->levels ) 1217 { 1218 #if (GIET_DEBUG_FAT & 1) 1219 if ( _get_proctime() > GIET_DEBUG_FAT ) 1220 _printf("\n[DEBUG FAT] _allocate_one_buffer() : adding a cache level\n" ); 1221 #endif 1222 1223 inode->cache = _allocate_one_cache_node( inode->cache ); 1224 inode->levels++; 1225 } 1226 1196 1227 // search the 64-tree cache from top to bottom 1197 1228 fat_cache_node_t* node = inode->cache;
Note: See TracChangeset
for help on using the changeset viewer.