Changeset 161 for trunk/kernel/mm/kcm.c


Ignore:
Timestamp:
Jul 7, 2017, 2:14:49 PM (7 years ago)
Author:
max@…
Message:

style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/kcm.c

    r101 r161  
    4949        kcm_dmsg("\n[INFO] %s : enters for %s / page %x / count = %d / active = %d\n",
    5050                 __FUNCTION__ , kmem_type_str( kcm->type ) ,
    51              (intptr_t)kcm_page , kcm_page->count , kcm_page->active );
     51                 (intptr_t)kcm_page , kcm_page->count , kcm_page->active );
    5252
    5353        assert( kcm_page->active , __FUNCTION__ , "kcm_page should be active" );
     
    6767        if( kcm_page->count >= kcm->blocks_nr )
    6868        {
    69         kcm_page->active = 0;
     69                kcm_page->active = 0;
    7070                list_unlink( &kcm_page->list);
    7171                kcm->active_pages_nr --;
     
    7676        }
    7777
    78     // compute return pointer
    79     void * ptr = (void *)((intptr_t)kcm_page + CONFIG_KCM_SLOT_SIZE
    80                  + (index * kcm->block_size) );
     78        // compute return pointer
     79        void * ptr = (void *)((intptr_t)kcm_page + CONFIG_KCM_SLOT_SIZE
     80                     + (index * kcm->block_size) );
    8181
    8282        kcm_dmsg("\n[INFO] %s : allocated one block  %s / ptr = %p / page = %x / count = %d\n",
    8383                 __FUNCTION__ , kmem_type_str( kcm->type ) , ptr ,
    84              (intptr_t)kcm_page , kcm_page->count );
     84                 (intptr_t)kcm_page , kcm_page->count );
    8585
    8686        return ptr;
    87 
    88 }  // kcm_get_block()
     87}
    8988
    9089/////////////////////////////////////////////////////////////////////////////////////
     
    101100        uint32_t     index;
    102101
    103     // compute pointer on kcm_page from block pointer
     102        // compute pointer on kcm_page from block pointer
    104103        kcm_page = (kcm_page_t*)((intptr_t)ptr & ~CONFIG_PPM_PAGE_MASK);
    105104
    106     // compute block index from block pointer
     105        // compute block index from block pointer
    107106        index = ((uint8_t *)ptr - (uint8_t *)kcm_page - CONFIG_KCM_SLOT_SIZE) / kcm->block_size;
    108107
     
    132131                kcm->free_pages_nr ++;
    133132        }
    134 }  // kcm_put_block()
     133}
    135134
    136135/////////////////////////////////////////////////////////////////////////////////////
     
    174173
    175174        return 0;
    176 
    177 }  // freelist_populate()
     175}
    178176
    179177/////////////////////////////////////////////////////////////////////////////////////
     
    199197
    200198        return kcm_page;
    201 
    202 } // freelist_get()
    203 
     199}
    204200
    205201//////////////////////////////
     
    207203                   uint32_t   type )
    208204{
    209     // the kcm_page descriptor mut fit in the KCM slot
    210     assert( (sizeof(kcm_page_t) <= CONFIG_KCM_SLOT_SIZE) ,
    211              __FUNCTION__ , "KCM slot too small\n" );
     205        // the kcm_page descriptor mut fit in the KCM slot
     206        assert( (sizeof(kcm_page_t) <= CONFIG_KCM_SLOT_SIZE) ,
     207                 __FUNCTION__ , "KCM slot too small\n" );
    212208
    213209        // initialize lock
     
    225221        list_root_init( &kcm->active_root );
    226222
    227         // initialize block size 
     223        // initialize block size
    228224        uint32_t block_size = ARROUND_UP( kmem_type_size( type ) , CONFIG_KCM_SLOT_SIZE );
    229225        kcm->block_size = block_size;
     
    231227        // initialize number of blocks per page
    232228        uint32_t  blocks_nr = (CONFIG_PPM_PAGE_SIZE - CONFIG_KCM_SLOT_SIZE) / block_size;
    233     kcm->blocks_nr = blocks_nr;
     229        kcm->blocks_nr = blocks_nr;
    234230
    235231        kcm_dmsg("\n[INFO] %s : KCM %s initialised / block_size = %d / blocks_nr = %d\n",
    236232                 __FUNCTION__ , kmem_type_str( type ) , kcm->block_size , kcm->blocks_nr );
    237 
    238 }  // kcm_init()
     233}
    239234
    240235///////////////////////////////
     
    276271        // release KCM lock
    277272        spinlock_unlock( &kcm->lock );
    278 
    279 }  // kcm_destroy()
     273}
    280274
    281275///////////////////////////////
     
    299293                list_add_first( &kcm->active_root , &kcm_page->list );
    300294                kcm->active_pages_nr ++;
    301             kcm_page->active = 1;
    302 
    303         kcm_dmsg("\n[INFO] %s : enters for type %s at cycle %d / new page = %x / count = %d\n",
     295                kcm_page->active = 1;
     296
     297                kcm_dmsg("\n[INFO] %s : enters for type %s at cycle %d / new page = %x / count = %d\n",
    304298                         __FUNCTION__ , kmem_type_str( kcm->type ) , hal_get_cycles() ,
    305                  (intptr_t)kcm_page , kcm_page->count );
     299                         (intptr_t)kcm_page , kcm_page->count );
    306300
    307301        }
     
    312306
    313307                kcm_dmsg("\n[INFO] %s : enters for type %s at cycle %d / page = %x / count = %d\n",
    314                          __FUNCTION__ , kmem_type_str( kcm->type ) , hal_get_cycles() , 
    315                  (intptr_t)kcm_page , kcm_page->count );
     308                         __FUNCTION__ , kmem_type_str( kcm->type ) , hal_get_cycles() ,
     309                         (intptr_t)kcm_page , kcm_page->count );
    316310        }
    317311
     
    324318
    325319        return ptr;
    326 
    327 }  // end kcm_allo()
     320}
    328321
    329322///////////////////////////
     
    346339        // release lock
    347340        spinlock_unlock( &kcm->lock );
    348 
    349 }  // end kcm_free()
     341}
    350342
    351343////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.