Changeset 18 for trunk/kernel/mm/ppm.c


Ignore:
Timestamp:
Jun 3, 2017, 4:42:49 PM (5 years ago)
Author:
max@…
Message:

cosmetic, and a few typos

File:
1 edited

Legend:

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

    r14 r18  
    5656
    5757////////////////////////////////////////////
    58 inline page_t * ppm_base2page( void * base ) 
     58inline page_t * ppm_base2page( void * base )
    5959{
    6060        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
     
    105105    // search the buddy page descriptor
    106106    // - merge with current page descriptor if found
    107     // - exit to release the current page descriptor if not found 
    108     current       = page , 
     107    // - exit to release the current page descriptor if not found
     108    current       = page ,
    109109    current_index = (uint32_t)(page - ppm->pages_tbl);
    110         for( current_order = page->order ; 
     110        for( current_order = page->order ;
    111111         current_order < CONFIG_PPM_MAX_ORDER ;
    112112         current_order++ )
     
    114114                buddy_index = current_index ^ (1 << current_order);
    115115                buddy       = pages_tbl + buddy_index;
    116    
     116
    117117                if( !page_is_flag( buddy , PG_FREE ) || (buddy->order != current_order) ) break;
    118118
    119         // remove buddy from free list 
     119        // remove buddy from free list
    120120                list_unlink( &buddy->list );
    121121                ppm->free_pages_nr[current_order] --;
    122122        ppm->total_free_pages -= (1 << current_order);
    123    
     123
    124124        // merge buddy with current
    125125                buddy->order = 0;
    126126                current_index &= buddy_index;
    127127        }
    128  
     128
    129129    // update merged page descriptor order
    130130        current        = pages_tbl + current_index;
     
    162162    list_root_init( &ppm->dirty_root );
    163163
    164     // initialize pointer on page descriptors array 
     164    // initialize pointer on page descriptors array
    165165        ppm->pages_tbl = (page_t*)( pages_offset << CONFIG_PPM_PAGE_SHIFT );
    166166
     
    174174        uint32_t reserved_pages = pages_offset + pages_array;
    175175
    176         // set pages numbers 
     176        // set pages numbers
    177177        ppm->pages_nr      = pages_nr;
    178178    ppm->pages_offset  = reserved_pages;
     
    180180    // initialises all page descriptors in pages_tbl[]
    181181        for( i = 0 ; i < pages_nr ; i++ )
    182     { 
     182    {
    183183        page_init( &ppm->pages_tbl[i] );
    184184
     
    186186        // complete the initialisation when page is allocated [AG]
    187187        // ppm->pages_tbl[i].flags = 0;
    188     } 
    189 
    190     // - set PG_RESERVED flag for reserved pages (kernel code & pages_tbl[]) 
     188    }
     189
     190    // - set PG_RESERVED flag for reserved pages (kernel code & pages_tbl[])
    191191    // - release all other pages to populate the free lists
    192         for( i = 0 ; i < reserved_pages ; i++) 
     192        for( i = 0 ; i < reserved_pages ; i++)
    193193    {
    194194        page_set_flag( &ppm->pages_tbl[i] , PG_RESERVED );
     
    250250        return NULL;
    251251    }
    252  
    253     // update free-lists after removing a block 
     252
     253    // update free-lists after removing a block
    254254        ppm->total_free_pages -= (1 << current_order);
    255         ppm->free_pages_nr[current_order] --; 
     255        ppm->free_pages_nr[current_order] --;
    256256        current_size = (1 << current_order);
    257257
     
    262262                current_order --;
    263263                current_size >>= 1;
    264    
     264
    265265                remaining_block = block + current_size;
    266266                remaining_block->order = current_order;
     
    270270        ppm->total_free_pages += (1 << current_order);
    271271        }
    272  
     272
    273273    // update page descriptor
    274274    page_clear_flag( block , PG_FREE );
     
    278278    // release lock protecting free lists
    279279        spinlock_unlock( &ppm->free_lock );
    280  
     280
    281281    ppm_dmsg("\n[INFO] %s : base = %x / order = %d\n",
    282282             __FUNCTION__ , (uint32_t)ppm_page2base( block ) , order );
     
    294294{
    295295        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
    296  
     296
    297297    // get lock protecting free_pages[] array
    298298        spinlock_lock( &ppm->free_lock );
    299299
    300         ppm_free_pages_nolock( page ); 
     300        ppm_free_pages_nolock( page );
    301301
    302302    // release lock protecting free_pages[] array
     
    316316
    317317        printk("\n***  PPM state in cluster %x %s : pages = %d / offset = %d / free = %d ***\n",
    318                local_cxy , string , ppm->pages_nr , ppm->pages_offset , ppm->total_free_pages ); 
    319        
     318               local_cxy , string , ppm->pages_nr , ppm->pages_offset , ppm->total_free_pages );
     319
    320320        for( order = 0 ; order < CONFIG_PPM_MAX_ORDER ; order++ )
    321321        {
    322322                printk("- order = %d / free_pages = %d  [",
    323323               order , ppm->free_pages_nr[order] );
    324                
     324
    325325                LIST_FOREACH( &ppm->free_pages_root[order] , iter )
    326326                {
     
    328328                        printk("%d," , page - ppm->pages_tbl );
    329329                }
    330    
     330
    331331                printk("]\n", NULL );
    332332        }
     
    336336
    337337}  // end ppm_print()
    338  
     338
    339339//////////////////////////u/////////
    340340void ppm_assert_order( ppm_t * ppm )
     
    343343        list_entry_t * iter;
    344344        page_t       * page;
    345        
     345
    346346        for(order=0; order < CONFIG_PPM_MAX_ORDER; order++)
    347347        {
    348348                if( list_is_empty( &ppm->free_pages_root[order] ) ) continue;
    349                
     349
    350350                LIST_FOREACH( &ppm->free_pages_root[order] , iter )
    351351                {
Note: See TracChangeset for help on using the changeset viewer.