Changeset 639 for soft


Ignore:
Timestamp:
Jul 20, 2015, 6:02:55 PM (9 years ago)
Author:
guerin
Message:

fat32: add Fat-Cache levels on demand

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_fat32/fat32.c

    r638 r639  
    420420
    421421//////////////////////////////////////////////////////////////////////////////////
     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
     428static fat_cache_node_t* _allocate_one_cache_node( fat_cache_node_t* first_child );
     429
     430//////////////////////////////////////////////////////////////////////////////////
    422431// The following function allocates and initializes a new inode,
    423432// using the values defined by the arguments.
    424433// 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.
    426434// It returns a pointer on the new inode.
    427435//////////////////////////////////////////////////////////////////////////////////
     
    874882
    875883
     884////////////////////////////////////////////////////////////
     885static 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
    876900
    877901////////////////////////////////////////////////////////////
     
    901925    if ( cache_allocate )
    902926    {
    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 );
    906928        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;
    910929    }
    911930
     
    11941213                                  unsigned int  cluster )
    11951214{
     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)
     1219if ( _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
    11961227    // search the 64-tree cache from top to bottom
    11971228    fat_cache_node_t*  node   = inode->cache;
Note: See TracChangeset for help on using the changeset viewer.