Ignore:
Timestamp:
Jan 13, 2021, 12:47:53 AM (3 years ago)
Author:
alain
Message:

cosmetic

File:
1 edited

Legend:

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

    r679 r686  
    22 * hal_gpt.c - implementation of the Generic Page Table API for TSAR-MIPS32
    33 *
    4  * Author   Alain Greiner (2016,2017,2018,2019)
     4 * Author   Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3737
    3838////////////////////////////////////////////////////////////////////////////////////////
     39// The Page Table for the TSAR-MIPS32 MMU is defined as a two levels radix tree.
     40//
     41// It defines two page sizes : 4 Kbytes pages, and 2 Mbytes pages.
     42// The virtual address space size is 4 Gbytes (32 bits virtual addresses).
     43// The physical address space is limited to 1 Tbytes (40 bits physical addresses).
     44// - For a 4 Kbytes page, the VPN uses 20 bits, and the PPN requires 28 bits.
     45// - For a 2 Mbytes page, the PPN uses 11 bits, and the PPN requires 19 bits.
     46//
     47// The first level array (PT1) contains 2048 entries, each entry contains 4 bytes,
     48// and this array is aligned on a 8K bytes boundary.
     49//
     50// The second level array (PT2) contains 512 entries, each entry contains 8 bytes,
     51// and this array is ligned on a 4K bytes boundary.
     52////////////////////////////////////////////////////////////////////////////////////////
     53
     54
     55////////////////////////////////////////////////////////////////////////////////////////
    3956// This define the masks for the TSAR MMU PTE attributes (from TSAR MMU specification)
    4057////////////////////////////////////////////////////////////////////////////////////////
     
    152169
    153170// check page size
    154 assert( __FUNCTION__, (CONFIG_PPM_PAGE_SIZE == 4096) , "the TSAR page size must be 4 Kbytes\n" );
    155 
    156     // allocates 2 physical pages for PT1
    157         kmem_req_t req;
    158         req.type  = KMEM_PPM;
    159         req.order = 1;                     // 2 small pages
    160         req.flags = AF_KERNEL | AF_ZERO;
    161         base = kmem_alloc( &req );
     171assert( __FUNCTION__, (CONFIG_PPM_PAGE_SIZE == 4096) ,
     172"the TSAR page size must be 4 Kbytes\n" );
     173
     174    // allocates 8 Kbytes for PT1
     175        base = kmem_alloc( 13 , AF_ZERO );
    162176
    163177        if( base == NULL )
     
    197211    uint32_t   * pt2;
    198212    uint32_t     attr;
    199         kmem_req_t   req;
    200213
    201214    thread_t * this = CURRENT_THREAD;
     
    241254                }
    242255
    243                 // release the page allocated for the PT2
    244                 req.type = KMEM_PPM;
    245                 req.ptr  = pt2;
    246                 kmem_free( &req );
     256                // release the 4K bytes allocated for the PT2
     257                kmem_free( pt2 , 12 );
    247258            }
    248259        }
    249260        }
    250261
    251     // release the PT1
    252     req.type = KMEM_PPM;
    253     req.ptr  = pt1;
    254     kmem_free( &req );
     262    // release the 8K bytes allocated for PT1
     263    kmem_free( pt1 , 13 );
    255264
    256265#if DEBUG_HAL_GPT_DESTROY
     
    272281    xptr_t              pte1_xp;         // extended pointer on PT1[x1] entry
    273282        uint32_t            pte1;            // value of PT1[x1] entry
    274 
    275     kmem_req_t          req;             // kmem request fro PT2 allocation
    276 
    277283    uint32_t          * pt2;             // local pointer on PT2 base
    278284        ppn_t               pt2_ppn;         // PPN of page containing PT2
     
    334340            hal_disable_irq( &sr_save );
    335341
    336             req.type  = KMEM_PPM;
    337             req.order = 0; 
    338             req.flags = AF_ZERO | AF_KERNEL;
    339             pt2       = kmem_remote_alloc( gpt_cxy , &req );
     342            // allocate a 4K bytes PT2
     343            pt2       = kmem_remote_alloc( gpt_cxy , 12 , AF_ZERO );
    340344
    341345            if( pt2 == NULL )
     
    863867    uint32_t   * dst_pt2;   // local pointer on DST PT2
    864868
    865         kmem_req_t   req;       // for PT2 allocation
    866 
    867869    uint32_t     src_pte1;
    868870    uint32_t     dst_pte1;
     
    917919        if( (dst_pte1 & TSAR_PTE_MAPPED) == 0 )
    918920        {
    919             // allocate one physical page for a new PT2
    920                 req.type  = KMEM_PPM;
    921                 req.order = 0;                     // 1 small page
    922                 req.flags = AF_KERNEL | AF_ZERO;
    923                 dst_pt2   = kmem_alloc( &req );
     921            // allocate one 4K bytes physical page for a new PT2
     922                dst_pt2   = kmem_alloc( 12 , AF_ZERO );
    924923
    925924            if( dst_pt2 == NULL )
Note: See TracChangeset for help on using the changeset viewer.