Ignore:
Timestamp:
Mar 12, 2019, 1:37:38 PM (5 years ago)
Author:
alain
Message:

Fix several bugs to use the instruction MMU in kernel mode
in replacement of the instruction address extension register,
and remove the "kentry" segment.

This version is running on the tsar_generic_iob" platform.

One interesting bug: the cp0_ebase defining the kernel entry point
(for interrupts, exceptions and syscalls) must be initialized
early in kernel_init(), because the VFS initialisation done by
kernel_ini() uses RPCs, and RPCs uses Inter-Processor-Interrup.

File:
1 edited

Legend:

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

    r623 r624  
    174174} // end hal_gpt_create()
    175175
    176 
    177176///////////////////////////////////
    178177void hal_gpt_destroy( gpt_t * gpt )
     
    334333
    335334
    336 /////////////////////////////////////////////////////////////////////////////////////
    337 // FOr the TSAR architecture, this function allocates a first level PT1 (8 Kbytes),
    338 // and maps one single big page for the kerne code segment in slot[0].
    339 /////////////////////////////////////////////////////////////////////////////////////
    340 void hal_gpt_build_kpt( cxy_t   cxy,
    341                         gpt_t * gpt )
    342 {
    343     error_t error;
    344 
    345     // allocate memory for one gpt
    346     error = hal_gpt_create( gpt );
    347 
    348     if( error )
    349     {
    350         printk("\n[PANIC] in %s : cannot allocate kernel GPT in cluster %x\n",
    351         __FUNCTION__ , cxy );
    352         hal_core_sleep();
    353     }
    354 
    355     // compute attr and ppn for one PTE1
    356     uint32_t attr  = 0xCA800000;           // bits : V,T,C,X,G
    357     uint32_t ppn   = (cxy << 20) >> 9;
    358 
    359     // set PTE1
    360     error = hal_gpt_set_pte( XPTR( cxy , gpt ) , 0 , attr , ppn );
    361 
    362     if( error )
    363     {
    364         printk("\n[PANIC] in %s : cannot initialize kernel GPT in cluster %x\n",
    365         __FUNCTION__ , cxy );
    366         hal_core_sleep();
    367     }
    368 }
    369 
    370335//////////////////////////////////////////
    371336error_t hal_gpt_set_pte( xptr_t    gpt_xp,
     
    617582}  // end hal_gpt_reset_pte()
    618583
     584
     585/* unused until now (march 2019) [AG]
     586
     587//////////////////////////////////////
     588void hal_gpt_reset_range( gpt   * gpt,
     589                          vpn_t   vpn_min,
     590                          vpn_t   vpn_max )
     591{
     592    vpn_t      vpn;         // current vpn
     593
     594    uint32_t * pt1;         // PT1 base address
     595    uint32_t   pte1;        // PT1 entry value
     596
     597    ppn_t      pt2_ppn;     // PPN of PT2
     598    uint32_t * pt2;         // PT2 base address
     599
     600    uint32_t   ix1;         // index in PT1
     601    uint32_t   ix2;         // index in PT2
     602
     603    // get PT1
     604    pt1 = gpt->ptr;
     605
     606    // initialize current index
     607    vpn = vpn_min;
     608
     609    // loop on pages
     610    while( vpn <= vpn_max )
     611    {
     612        // get ix1 index from vpn
     613        ix1 = TSAR_MMU_IX1_FROM_VPN( vpn );
     614
     615        // get PTE1
     616        pte1 = pt1[ix1]
     617
     618            if( (pte1 & TSAR_MMU_MAPPED) == 0 )     // PT1[ix1] unmapped
     619        {
     620            // update vpn (next big page)
     621            (vpn = ix1 + 1) << 9;
     622        }
     623            if( (pte1 & TSAR_MMU_SMALL) == 0 )      // it's a PTE1 (big page)
     624            {
     625            // unmap the big page
     626            pt1[ix1] = 0;
     627                hal_fence();
     628           
     629            // update vpn (next big page)
     630            (vpn = ix1 + 1) << 9;
     631        }
     632        else                                    // it's a PTD1 (small page)
     633        {
     634            // compute PT2 base address
     635            pt2_ppn = TSAR_MMU_PTBA_FROM_PTE1( pte1 );
     636            pt2     = GET_PTR( ppm_ppn2base( pt2_ppn ) );
     637
     638            // get ix2 index from vpn
     639            ix2 = TSAR_MMU_IX2_FROM_VPN( vpn );
     640
     641            // unmap the small page
     642            pt2[2*ix2]   = 0;         
     643            hal_fence();       
     644
     645            // update vpn (next small page)
     646            vpn++;
     647        }
     648    }
     649}  // hal_gpt_reset_range()
     650*/
     651
    619652//////////////////////////////////////
    620653error_t hal_gpt_lock_pte( gpt_t * gpt,
Note: See TracChangeset for help on using the changeset viewer.