Changeset 29b2bbf in mainline for kernel/arch/sparc64/src/mm/as.c


Ignore:
Timestamp:
2006-09-18T22:10:20Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19dba2b
Parents:
57da95c
Message:

sparc64 work:

  • Experimental support for TSB (Translation Storage Buffer).
File:
1 edited

Legend:

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

    r57da95c r29b2bbf  
    4141#ifdef CONFIG_TSB
    4242#include <arch/mm/tsb.h>
     43#include <arch/memstr.h>
     44#include <synch/mutex.h>
     45#include <arch/asm.h>
     46#include <mm/frame.h>
     47#include <bitops.h>
     48#include <macros.h>
    4349#endif
    4450
     
    4854        as_operations = &as_ht_operations;
    4955        asid_fifo_init();
     56}
     57
     58int as_constructor_arch(as_t *as, int flags)
     59{
     60#ifdef CONFIG_TSB
     61        int order = fnzb32(((ITSB_ENTRY_COUNT+DTSB_ENTRY_COUNT)*sizeof(tsb_entry_t))>>FRAME_WIDTH);
     62        uintptr_t tsb = (uintptr_t) frame_alloc(order, flags);
     63
     64        if (!tsb)
     65                return -1;
     66
     67        as->arch.itsb = (tsb_entry_t *) tsb;
     68        as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT * sizeof(tsb_entry_t));
     69#endif
     70        return 0;
     71}
     72
     73int as_destructor_arch(as_t *as)
     74{
     75#ifdef CONFIG_TSB
     76        count_t cnt = ((ITSB_ENTRY_COUNT+DTSB_ENTRY_COUNT)*sizeof(tsb_entry_t))>>FRAME_WIDTH;
     77        frame_free((uintptr_t) as->arch.itsb);
     78        return cnt;
     79#else
     80        return 0;
     81#endif
     82}
     83
     84int as_create_arch(as_t *as, int flags)
     85{
     86#ifdef CONFIG_TSB
     87        ipl_t ipl;
     88
     89        memsetb((uintptr_t) as->arch.itsb, (ITSB_ENTRY_COUNT+DTSB_ENTRY_COUNT)*sizeof(tsb_entry_t), 0);
     90        ipl = interrupts_disable();
     91        mutex_lock_active(&as->lock);   /* completely unnecessary, but polite */
     92        tsb_invalidate(as, 0, (count_t) -1);
     93        mutex_unlock(&as->lock);
     94        interrupts_restore(ipl);
     95#endif
     96        return 0;
    5097}
    5198
     
    79126
    80127#ifdef CONFIG_TSB       
    81         if (as != AS_KERNEL) {
    82                 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
     128        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    83129
    84                 ASSERT(as->arch.itsb && as->arch.dtsb);
     130        ASSERT(as->arch.itsb && as->arch.dtsb);
    85131
    86                 uintptr_t tsb = as->arch.itsb;
     132        uintptr_t tsb = (uintptr_t) as->arch.itsb;
    87133               
    88                 if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    89                         /*
    90                         * TSBs were allocated from memory not covered
    91                         * by the locked 4M kernel DTLB entry. We need
    92                         * to map both TSBs explicitly.
    93                         */
    94                         dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb);
    95                         dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true);
    96                 }
     134        if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
     135                /*
     136                * TSBs were allocated from memory not covered
     137                * by the locked 4M kernel DTLB entry. We need
     138                * to map both TSBs explicitly.
     139                */
     140                dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb);
     141                dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true);
     142        }
    97143               
    98                 /*
    99                 * Setup TSB Base registers.
    100                 */
    101                 tsb_base_reg_t tsb_base;
     144        /*
     145        * Setup TSB Base registers.
     146        */
     147        tsb_base_reg_t tsb_base;
    102148               
    103                 tsb_base.value = 0;
    104                 tsb_base.size = TSB_SIZE;
    105                 tsb_base.split = 0;
     149        tsb_base.value = 0;
     150        tsb_base.size = TSB_SIZE;
     151        tsb_base.split = 0;
    106152
    107                 tsb_base.base = as->arch.itsb >> PAGE_WIDTH;
    108                 itsb_base_write(tsb_base.value);
    109                 tsb_base.base = as->arch.dtsb >> PAGE_WIDTH;
    110                 dtsb_base_write(tsb_base.value);
    111         }
     153        tsb_base.base = ((uintptr_t) as->arch.itsb) >> PAGE_WIDTH;
     154        itsb_base_write(tsb_base.value);
     155        tsb_base.base = ((uintptr_t) as->arch.dtsb) >> PAGE_WIDTH;
     156        dtsb_base_write(tsb_base.value);
    112157#endif
    113158}
     
    130175
    131176#ifdef CONFIG_TSB
    132         if (as != AS_KERNEL) {
    133                 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
     177        uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
    134178
    135                 ASSERT(as->arch.itsb && as->arch.dtsb);
     179        ASSERT(as->arch.itsb && as->arch.dtsb);
    136180
    137                 uintptr_t tsb = as->arch.itsb;
     181        uintptr_t tsb = (uintptr_t) as->arch.itsb;
    138182               
    139                 if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
    140                         /*
    141                          * TSBs were allocated from memory not covered
    142                          * by the locked 4M kernel DTLB entry. We need
    143                          * to demap the entry installed by as_install_arch().
    144                          */
    145                         dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb);
    146                 }
    147                
     183        if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
     184                /*
     185                 * TSBs were allocated from memory not covered
     186                 * by the locked 4M kernel DTLB entry. We need
     187                 * to demap the entry installed by as_install_arch().
     188                 */
     189                dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb);
    148190        }
    149191#endif
Note: See TracChangeset for help on using the changeset viewer.