Ignore:
File:
1 edited

Legend:

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

    r9d58539 re08162b  
    6363{
    6464#ifdef CONFIG_TSB
    65         /*
    66          * The order must be calculated with respect to the emulated
    67          * 16K page size.
    68          *
    69          */
    70         uint8_t order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    71             sizeof(tsb_entry_t)) >> FRAME_WIDTH);
    72        
    73         uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA);
    74        
    75         if (!tsb)
     65        uintptr_t tsb_base = frame_alloc(TSB_FRAMES, flags, TSB_SIZE - 1);
     66        if (!tsb_base)
    7667                return -1;
    77        
    78         as->arch.itsb = (tsb_entry_t *) tsb;
    79         as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT *
    80             sizeof(tsb_entry_t));
    81        
    82         memsetb(as->arch.itsb,
    83             (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * sizeof(tsb_entry_t), 0);
     68
     69        tsb_entry_t *tsb = (tsb_entry_t *) PA2KA(tsb_base);
     70        memsetb(tsb, TSB_SIZE, 0);
     71       
     72        as->arch.itsb = tsb;
     73        as->arch.dtsb = tsb + ITSB_ENTRY_COUNT;
    8474#endif
    8575       
     
    9080{
    9181#ifdef CONFIG_TSB
    92         /*
    93          * The count must be calculated with respect to the emualted 16K page
    94          * size.
    95          */
    96         size_t cnt = ((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    97             sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    98         frame_free(KA2PA((uintptr_t) as->arch.itsb));
    99        
    100         return cnt;
     82        frame_free(KA2PA((uintptr_t) as->arch.itsb), TSB_FRAMES);
     83       
     84        return TSB_FRAMES;
    10185#else
    10286        return 0;
     
    146130        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    147131       
    148         ASSERT(as->arch.itsb && as->arch.dtsb);
     132        ASSERT(as->arch.itsb);
     133        ASSERT(as->arch.dtsb);
    149134       
    150135        uintptr_t tsb = (uintptr_t) as->arch.itsb;
    151136       
    152         if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
     137        if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    153138                /*
    154139                 * TSBs were allocated from memory not covered
     
    165150         *
    166151         */
    167         tsb_base_reg_t tsb_base;
    168        
    169         tsb_base.value = 0;
    170         tsb_base.size = TSB_SIZE;
    171         tsb_base.split = 0;
    172        
    173         tsb_base.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH;
    174         itsb_base_write(tsb_base.value);
    175         tsb_base.base = ((uintptr_t) as->arch.dtsb) >> MMU_PAGE_WIDTH;
    176         dtsb_base_write(tsb_base.value);
     152        tsb_base_reg_t tsb_base_reg;
     153       
     154        tsb_base_reg.value = 0;
     155        tsb_base_reg.size = TSB_BASE_REG_SIZE;
     156        tsb_base_reg.split = 0;
     157       
     158        tsb_base_reg.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH;
     159        itsb_base_write(tsb_base_reg.value);
     160        tsb_base_reg.base = ((uintptr_t) as->arch.dtsb) >> MMU_PAGE_WIDTH;
     161        dtsb_base_write(tsb_base_reg.value);
    177162       
    178163#if defined (US3)
     
    217202        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    218203       
    219         ASSERT(as->arch.itsb && as->arch.dtsb);
     204        ASSERT(as->arch.itsb);
     205        ASSERT(as->arch.dtsb);
    220206       
    221207        uintptr_t tsb = (uintptr_t) as->arch.itsb;
    222208       
    223         if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
     209        if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    224210                /*
    225211                 * TSBs were allocated from memory not covered
Note: See TracChangeset for help on using the changeset viewer.