Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/mm/sun4v/as.c

    rda1bafb r8c2214e  
    4444
    4545#ifdef CONFIG_TSB
    46 
    4746#include <arch/mm/tsb.h>
    4847#include <arch/memstr.h>
     
    5150#include <bitops.h>
    5251#include <macros.h>
    53 
    5452#endif /* CONFIG_TSB */
    5553
     
    6361}
    6462
    65 int as_constructor_arch(as_t *as, unsigned int flags)
     63int as_constructor_arch(as_t *as, int flags)
    6664{
    6765#ifdef CONFIG_TSB
    68         uint8_t order = fnzb32(
     66        int order = fnzb32(
    6967                (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH);
    70        
     68
    7169        uintptr_t tsb = (uintptr_t) frame_alloc(order, flags);
    72        
     70
    7371        if (!tsb)
    7472                return -1;
    75        
     73
    7674        as->arch.tsb_description.page_size = PAGESIZE_8K;
    7775        as->arch.tsb_description.associativity = 1;
     
    8179        as->arch.tsb_description.reserved = 0;
    8280        as->arch.tsb_description.context = 0;
    83        
     81
    8482        memsetb((void *) PA2KA(as->arch.tsb_description.tsb_base),
    8583                TSB_ENTRY_COUNT * sizeof(tsb_entry_t), 0);
    8684#endif
    87        
    8885        return 0;
    8986}
     
    9491        size_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    9592        frame_free((uintptr_t) as->arch.tsb_description.tsb_base);
    96        
    9793        return cnt;
    9894#else
     
    10197}
    10298
    103 int as_create_arch(as_t *as, unsigned int flags)
     99int as_create_arch(as_t *as, int flags)
    104100{
    105101#ifdef CONFIG_TSB
    106102        tsb_invalidate(as, 0, (size_t) -1);
    107103#endif
    108        
    109104        return 0;
    110105}
     
    116111 *
    117112 * @param as Address space.
    118  *
    119113 */
    120114void as_install_arch(as_t *as)
    121115{
    122116        mmu_secondary_context_write(as->asid);
    123        
    124 #ifdef CONFIG_TSB
     117#ifdef CONFIG_TSB       
    125118        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    126        
     119
    127120        ASSERT(as->arch.tsb_description.tsb_base);
    128121        uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
    129        
     122               
    130123        if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    131124                /*
     
    133126                 * by the locked 4M kernel DTLB entry. We need
    134127                 * to map both TSBs explicitly.
    135                  *
    136128                 */
    137129                mmu_demap_page(tsb, 0, MMU_FLAG_DTLB);
    138130                dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true);
    139131        }
     132
     133        __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&(as->arch.tsb_description)));
    140134       
    141         __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&(as->arch.tsb_description)));
    142135#endif
    143136}
     
    149142 *
    150143 * @param as Address space.
    151  *
    152144 */
    153145void as_deinstall_arch(as_t *as)
    154146{
     147
    155148        /*
    156149         * Note that we don't and may not lock the address space. That's ok
     
    158151         *
    159152         * Moreover, the as->asid is protected by asidlock, which is being held.
    160          *
    161153         */
    162        
     154
    163155#ifdef CONFIG_TSB
    164156        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    165        
     157
    166158        ASSERT(as->arch.tsb_description.tsb_base);
    167        
     159
    168160        uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
    169        
     161               
    170162        if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    171163                /*
     
    173165                 * by the locked 4M kernel DTLB entry. We need
    174166                 * to demap the entry installed by as_install_arch().
    175                  *
    176167                 */
    177168                __hypercall_fast3(MMU_UNMAP_PERM_ADDR, tsb, 0, MMU_FLAG_DTLB);
Note: See TracChangeset for help on using the changeset viewer.