Changeset cc205f1 in mainline for arch/mips32/src/mm/tlb.c


Ignore:
Timestamp:
2005-10-06T12:45:22Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd3c9e5
Parents:
bca1b47
Message:

Add mm/mapping1 test.
(Will not make it past TLB Invalid exception on mips32.)
Fixes in asid.c.
Make TLB register types union with u32 value.
Implement tlb_invalidate() for mips32.
(TLB invalidation and shootdown path will have to be revised.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/mips32/src/mm/tlb.c

    rbca1b47 rcc205f1  
    3838#include <synch/spinlock.h>
    3939#include <print.h>
     40#include <debug.h>
    4041
    4142static void tlb_refill_fail(struct exception_regdump *pstate);
     
    4445
    4546static pte_t *find_mapping_and_check(__address badvaddr);
    46 static void prepare_entry_lo(struct entry_lo *lo, bool g, bool v, bool d, int c, __address pfn);
     47static void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, int c, __address pfn);
    4748
    4849/** Initialize TLB
     
    8384void tlb_refill(struct exception_regdump *pstate)
    8485{
    85         struct entry_lo lo;
     86        entry_lo_t lo;
    8687        __address badvaddr;
    8788        pte_t *pte;
     
    105106         */
    106107        if ((badvaddr/PAGE_SIZE) % 2 == 0) {
    107                 cp0_entry_lo0_write(*((__u32 *) &lo));
     108                cp0_entry_lo0_write(lo.value);
    108109                cp0_entry_lo1_write(0);
    109110        }
    110111        else {
    111112                cp0_entry_lo0_write(0);
    112                 cp0_entry_lo1_write(*((__u32 *) &lo));
     113                cp0_entry_lo1_write(lo.value);
    113114        }
    114115        tlbwr();
     
    130131void tlb_invalid(struct exception_regdump *pstate)
    131132{
    132         struct index index;
     133        tlb_index_t index;
    133134        __address badvaddr;
    134         struct entry_lo lo;
     135        entry_lo_t lo;
    135136        pte_t *pte;
    136137
     
    141142         */
    142143        tlbp();
    143         *((__u32 *) &index) = cp0_index_read();
     144        index.value = cp0_index_read();
    144145       
    145146        spinlock_lock(&VM->lock);       
     
    148149         * Fail if the entry is not in TLB.
    149150         */
    150         if (index.p)
    151                 goto fail;
     151        if (index.p) {
     152                printf("TLB entry not found.\n");
     153                goto fail;
     154        }
    152155
    153156        pte = find_mapping_and_check(badvaddr);
     
    171174         */
    172175        if ((badvaddr/PAGE_SIZE) % 2 == 0)
    173                 cp0_entry_lo0_write(*((__u32 *) &lo));
     176                cp0_entry_lo0_write(lo.value);
    174177        else
    175                 cp0_entry_lo1_write(*((__u32 *) &lo));
     178                cp0_entry_lo1_write(lo.value);
    176179        tlbwi();
    177180
     
    190193 * @param pstate Interrupted register context.
    191194 */
    192 
    193195void tlb_modified(struct exception_regdump *pstate)
    194196{
    195         struct index index;
     197        tlb_index_t index;
    196198        __address badvaddr;
    197         struct entry_lo lo;
     199        entry_lo_t lo;
    198200        pte_t *pte;
    199201
     
    204206         */
    205207        tlbp();
    206         *((__u32 *) &index) = cp0_index_read();
     208        index.value = cp0_index_read();
    207209       
    208210        spinlock_lock(&VM->lock);       
     
    211213         * Fail if the entry is not in TLB.
    212214         */
    213         if (index.p)
    214                 goto fail;
     215        if (index.p) {
     216                printf("TLB entry not found.\n");
     217                goto fail;
     218        }
    215219
    216220        pte = find_mapping_and_check(badvaddr);
     
    241245         */
    242246        if ((badvaddr/PAGE_SIZE) % 2 == 0)
    243                 cp0_entry_lo0_write(*((__u32 *) &lo));
     247                cp0_entry_lo0_write(lo.value);
    244248        else
    245                 cp0_entry_lo1_write(*((__u32 *) &lo));
     249                cp0_entry_lo1_write(lo.value);
    246250        tlbwi();
    247251
     
    289293}
    290294
    291 
    292 void tlb_invalidate(int asid)
    293 {
     295/** Invalidate TLB entries with specified ASID
     296 *
     297 * Invalidate TLB entries with specified ASID.
     298 *
     299 * @param asid ASID.
     300 */
     301void tlb_invalidate(asid_t asid)
     302{
     303        entry_hi_t hi;
    294304        pri_t pri;
    295        
     305        int i; 
     306       
     307        ASSERT(asid != ASID_INVALID);
     308
    296309        pri = cpu_priority_high();
    297310       
    298         // TODO
     311        for (i = 0; i < TLB_SIZE; i++) {
     312                cp0_index_write(i);
     313                tlbr();
     314               
     315                hi.value = cp0_entry_hi_read();
     316                if (hi.asid == asid) {
     317                        cp0_pagemask_write(TLB_PAGE_MASK_16K);
     318                        cp0_entry_hi_write(0);
     319                        cp0_entry_lo0_write(0);
     320                        cp0_entry_lo1_write(0);
     321                        tlbwi();
     322                }
     323        }
    299324       
    300325        cpu_priority_restore(pri);
     
    312337pte_t *find_mapping_and_check(__address badvaddr)
    313338{
    314         struct entry_hi hi;
     339        entry_hi_t hi;
    315340        pte_t *pte;
    316341
    317         *((__u32 *) &hi) = cp0_entry_hi_read();
     342        hi.value = cp0_entry_hi_read();
    318343
    319344        /*
    320345         * Handler cannot succeed if the ASIDs don't match.
    321346         */
    322         if (hi.asid != VM->asid)
     347        if (hi.asid != VM->asid) {
     348                printf("EntryHi.asid=%d, VM->asid=%d\n", hi.asid, VM->asid);
    323349                return NULL;
     350        }
    324351       
    325352        /*
     
    327354         */
    328355        pte = find_mapping(badvaddr, 0);
    329         if (!pte)
     356        if (!pte) {
     357                printf("No such mapping.\n");
    330358                return NULL;
     359        }
    331360
    332361        /*
    333362         * Handler cannot succeed if the mapping is marked as invalid.
    334363         */
    335         if (!pte->v)
     364        if (!pte->v) {
     365                printf("Invalid mapping.\n");
    336366                return NULL;
     367        }
    337368
    338369        return pte;
    339370}
    340371
    341 void prepare_entry_lo(struct entry_lo *lo, bool g, bool v, bool d, int c, __address pfn)
     372void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, int c, __address pfn)
    342373{
    343374        lo->g = g;
Note: See TracChangeset for help on using the changeset viewer.