Fork us on GitHub Follow us on Facebook Follow us on Twitter

Ignore:
Timestamp:
2009-11-06T16:59:40Z (12 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master
Children:
74cbac7
Parents:
66e08d02
Message:

TLB & CPU init implemented, now the code reaches creation of the first thread.

File:
1 edited

Legend:

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

    r66e08d02 rb4655da  
    3737#include <mm/as.h>
    3838#include <mm/asid.h>
     39#include <arch/sun4v/hypercall.h>
    3940#include <arch/mm/frame.h>
    4041#include <arch/mm/page.h>
    41 #include <arch/mm/mmu.h>
     42#include <arch/mm/tte.h>
     43#include <arch/mm/tlb.h>
    4244#include <arch/interrupt.h>
    4345#include <interrupt.h>
     
    7072};
    7173
     74/** Invalidate all unlocked ITLB and DTLB entries. */
     75void tlb_invalidate_all(void)
     76{
     77        uint64_t errno =  __hypercall_fast3(MMU_DEMAP_ALL, 0, 0,
     78                MMU_FLAG_DTLB | MMU_FLAG_ITLB);
     79        if (errno != EOK) {
     80                panic("Error code = %d.\n", errno);
     81        }
     82}
     83
    7284void tlb_arch_init(void)
    7385{
    74         /*
    75          * Invalidate all non-locked DTLB and ITLB entries.
    76          */
    77         //MH
    78         //tlb_invalidate_all();
    79 
    80         /*
    81          * Clear both SFSRs.
    82          */
    83         //MH
    84         //dtlb_sfsr_write(0);
    85         //itlb_sfsr_write(0);
     86        tlb_invalidate_all();
    8687}
    8788
     
    9798    bool locked, bool cacheable)
    9899{
     100#if 0
    99101        tlb_tag_access_reg_t tag;
    100102        tlb_data_t data;
     
    124126
    125127        dtlb_data_in_write(data.value);
     128#endif
    126129}
    127130
     
    135138void dtlb_pte_copy(pte_t *t, size_t index, bool ro)
    136139{
     140#if 0
    137141        tlb_tag_access_reg_t tag;
    138142        tlb_data_t data;
     
    163167
    164168        dtlb_data_in_write(data.value);
     169#endif
    165170}
    166171
     
    172177void itlb_pte_copy(pte_t *t, size_t index)
    173178{
     179#if 0
    174180        tlb_tag_access_reg_t tag;
    175181        tlb_data_t data;
     
    197203       
    198204        itlb_data_in_write(data.value);
     205#endif
    199206}
    200207
     
    362369static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
    363370{
     371#if 0
    364372        printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
    365373            "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
     
    367375            t.context, d.v, d.size, d.nfo, d.ie, d.soft2,
    368376            d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
     377#endif
    369378}
    370379
     
    502511}
    503512
    504 #if defined (US)
    505 /** Invalidate all unlocked ITLB and DTLB entries. */
    506 void tlb_invalidate_all(void)
    507 {
    508         int i;
    509        
    510         /*
    511          * Walk all ITLB and DTLB entries and remove all unlocked mappings.
    512          *
    513          * The kernel doesn't use global mappings so any locked global mappings
    514          * found must have been created by someone else. Their only purpose now
    515          * is to collide with proper mappings. Invalidate immediately. It should
    516          * be safe to invalidate them as late as now.
    517          */
    518 
    519         tlb_data_t d;
    520         tlb_tag_read_reg_t t;
    521 
    522         for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
    523                 d.value = itlb_data_access_read(i);
    524                 if (!d.l || d.g) {
    525                         t.value = itlb_tag_read_read(i);
    526                         d.v = false;
    527                         itlb_tag_access_write(t.value);
    528                         itlb_data_access_write(i, d.value);
    529                 }
    530         }
    531 
    532         for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
    533                 d.value = dtlb_data_access_read(i);
    534                 if (!d.l || d.g) {
    535                         t.value = dtlb_tag_read_read(i);
    536                         d.v = false;
    537                         dtlb_tag_access_write(t.value);
    538                         dtlb_data_access_write(i, d.value);
    539                 }
    540         }
    541 
    542 }
    543 
    544 #elif defined (US3)
    545 
    546 /** Invalidate all unlocked ITLB and DTLB entries. */
    547 void tlb_invalidate_all(void)
    548 {
    549         itlb_demap(TLB_DEMAP_ALL, 0, 0);
    550         dtlb_demap(TLB_DEMAP_ALL, 0, 0);
    551 }
    552 
    553 #endif
    554 
    555513/** Invalidate all ITLB and DTLB entries that belong to specified ASID
    556514 * (Context).
Note: See TracChangeset for help on using the changeset viewer.