Changeset 106 for trunk/hal


Ignore:
Timestamp:
Jun 30, 2017, 9:16:22 AM (7 years ago)
Author:
max@…
Message:

style and typos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/core/hal_ppm.c

    r62 r106  
    11/*
    2  * hal_gpt.C - Generic Physcal Page Table API implementation for the TSAR archtecture.
     2 * hal_ppm.c - Generic Physical Page Table API implementation for TSAR
    33 *
    44 * Authors  Alain Greiner (2016,2017)
    5  *
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    3635
    3736//////////////////////////////////////////////////////////////////////////////////////////
    38 // For The TSAR architecture, the kernel pointers are identity mapping:
    39 // - the 32 bits PTR value is identical to the 32 bits LPA value, 
     37// For The TSAR architecture, the kernel pointers are identity mapped:
     38// - the 32 bits PTR value is identical to the 32 bits LPA value,
    4039// - the 64 bits XPTR value is identical to the 64 bits PADDR value.
    4140// The pages_tbl[] is mapped in first free page after kernel code.
     
    4746error_t  hal_ppm_init( boot_info_t * info )
    4847{
    49     uint32_t i;
     48        uint32_t i;
    5049
    51     // get relevant info from boot_info structure
     50        // get relevant info from boot_info structure
    5251        uint32_t   pages_nr         = info->pages_nr;
    53     uint32_t   pages_tbl_offset = info->pages_offset;
    54     uint32_t   rsvd_nr          = info->rsvd_nr;
     52        uint32_t   pages_tbl_offset = info->pages_offset;
     53        uint32_t   rsvd_nr          = info->rsvd_nr;
    5554
    56     // check no reserved zones other than kernel code for TSAR
    57     assert( (rsvd_nr == 0 ) , __FUNCTION__ , "NO reserved zones for TSAR\n" );
     55        // check no reserved zones other than kernel code for TSAR
     56        assert( (rsvd_nr == 0 ) , __FUNCTION__ , "NO reserved zones for TSAR\n" );
    5857
    59     // get pointer on local Physical Page Manager
    60     ppm_t * ppm = &LOCAL_CLUSTER->ppm;
    61    
    62     // initialize lock protecting the free_pages[] lists
     58        // get pointer on local Physical Page Manager
     59        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
     60
     61        // initialize lock protecting the free_pages[] lists
    6362        spinlock_init( &ppm->free_lock );
    6463
    65     // initialize lock protecting the dirty_pages list
     64        // initialize lock protecting the dirty_pages list
    6665        spinlock_init( &ppm->dirty_lock );
    6766
    68     // initialize all free_pages[] lists as empty
     67        // initialize all free_pages[] lists as empty
    6968        for( i = 0 ; i < CONFIG_PPM_MAX_ORDER ; i++ )
    7069        {
     
    7372        }
    7473
    75     // initialize dirty_list as empty
    76     list_root_init( &ppm->dirty_root );
     74        // initialize dirty_list as empty
     75        list_root_init( &ppm->dirty_root );
    7776
    78     // initialize pages_nr, pages_tbl, and vaddr_base pointers
    79     // (TSAR uses identity mapping for kernel pointers)
    80     // I86 architectures should use vaddr_base = 0xFFFF8000000000 + (cxy << 36)
     77        // initialize pages_nr, pages_tbl, and vaddr_base pointers
     78        // (TSAR uses identity mapping for kernel pointers)
     79        // x86 architectures should use vaddr_base = 0xFFFF8000000000 + (cxy << 36)
     80        ppm->pages_nr      = pages_nr;
     81        ppm->vaddr_base = NULL;
     82        ppm->pages_tbl  = (page_t*)( ppm->vaddr_base +
     83                                     (pages_tbl_offset << CONFIG_PPM_PAGE_SHIFT) );
    8184
    82         ppm->pages_nr      = pages_nr;
    83     ppm->vaddr_base = NULL;
    84         ppm->pages_tbl  = (page_t*)( ppm->vaddr_base +
    85                                  (pages_tbl_offset << CONFIG_PPM_PAGE_SHIFT) );
     85        // compute size of pages_tbl[] array rounded to an integer number of pages
     86        uint32_t bytes = ARROUND_UP( pages_nr * sizeof(page_t), CONFIG_PPM_PAGE_SIZE );
    8687
    87     // compute size of pages_tbl[] array rounded to an integer number of pages
    88     uint32_t bytes = ARROUND_UP( pages_nr * sizeof(page_t), CONFIG_PPM_PAGE_SIZE );
    89 
    90     // compute number of pages required to store page descriptor array
     88        // compute number of pages required to store page descriptor array
    9189        uint32_t pages_tbl_nr = bytes >> CONFIG_PPM_PAGE_SHIFT;
    9290
    93     // compute total number of reserved pages (kernel code & pages_tbl[])
     91        // compute total number of reserved pages (kernel code & pages_tbl[])
    9492        uint32_t reserved_pages = pages_tbl_offset + pages_tbl_nr;
    9593
    96     // initialises all page descriptors in pages_tbl[]
     94        // initialize all page descriptors in pages_tbl[]
    9795        for( i = 0 ; i < pages_nr ; i++ )
    98     {
    99         page_init( &ppm->pages_tbl[i] );
     96        {
     97                page_init( &ppm->pages_tbl[i] );
    10098
    101         // TODO optimisation for this enormous loop on small pages:
    102         // make only a partial init with a memset, and complete the
    103         // initialisation when page is allocated [AG]
    104     }
     99                // TODO optimisation for this enormous loop on small pages:
     100                // make only a partial init with a memset, and complete the
     101                // initialisation when page is allocated [AG]
     102        }
    105103
    106     // - set PG_RESERVED flag for reserved pages (kernel code & pages_tbl[])
    107     // - release all other pages to populate the free lists
     104        // - set PG_RESERVED flag for reserved pages (kernel code & pages_tbl[])
     105        // - release all other pages to populate the free lists
    108106        for( i = 0 ; i < reserved_pages ; i++)
    109     {
    110         page_set_flag( &ppm->pages_tbl[i] , PG_RESERVED );
    111     }
     107        {
     108                page_set_flag( &ppm->pages_tbl[i] , PG_RESERVED );
     109        }
    112110        for( i = reserved_pages ; i < pages_nr ; i++ )
    113111        {
    114             ppm_free_pages_nolock( &ppm->pages_tbl[i] );
     112                ppm_free_pages_nolock( &ppm->pages_tbl[i] );
    115113
    116         // TODO optimisation : decompose this enormous set of small pages
    117         // to several sets of big pages with various order values
     114                // TODO optimisation : decompose this enormous set of small pages
     115                // to several sets of big pages with various order values
    118116        }
    119117
    120     // check consistency
    121     return ppm_assert_order( ppm );
     118        // check consistency
     119        return ppm_assert_order( ppm );
     120}
    122121
    123 }  // end hal_ppm_init()
    124 
Note: See TracChangeset for help on using the changeset viewer.