Date: Sat, 3 Apr 2010 07:27:32 +0000 (UTC) From: Juli Mallett <jmallett@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r206123 - in user/jmallett/octeon/sys/mips: include mips Message-ID: <201004030727.o337RWWm016958@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jmallett Date: Sat Apr 3 07:27:32 2010 New Revision: 206123 URL: http://svn.freebsd.org/changeset/base/206123 Log: o) Add a macro which masks the software-managed bits in the PTE. o) Use PDE_OFFSET() in a couple of places that should use it. o) Move a reduced-in-features tlb show command to tlb.c. Modified: user/jmallett/octeon/sys/mips/include/pte.h user/jmallett/octeon/sys/mips/mips/pmap.c user/jmallett/octeon/sys/mips/mips/tlb.c user/jmallett/octeon/sys/mips/mips/vm_machdep.c Modified: user/jmallett/octeon/sys/mips/include/pte.h ============================================================================== --- user/jmallett/octeon/sys/mips/include/pte.h Sat Apr 3 07:19:31 2010 (r206122) +++ user/jmallett/octeon/sys/mips/include/pte.h Sat Apr 3 07:27:32 2010 (r206123) @@ -72,6 +72,7 @@ typedef pt_entry_t *pd_entry_t; * other 0 fields. */ #define TLBLO_SWBITS_SHIFT (30) +#define TLBLO_SWBITS_MASK (0x3U << TLBLO_SWBITS_SHIFT) #define TLBLO_PFN_SHIFT (6 + (PAGE_SHIFT - TLBMASK_SHIFT)) #define TLBLO_PFN_MASK (0x03FFFFFC0) #define TLBLO_PA_TO_PFN(pa) ((((pa) >> TLB_PAGE_SHIFT) << TLBLO_PFN_SHIFT) & TLBLO_PFN_MASK) Modified: user/jmallett/octeon/sys/mips/mips/pmap.c ============================================================================== --- user/jmallett/octeon/sys/mips/mips/pmap.c Sat Apr 3 07:19:31 2010 (r206122) +++ user/jmallett/octeon/sys/mips/mips/pmap.c Sat Apr 3 07:27:32 2010 (r206123) @@ -68,7 +68,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "opt_ddb.h" #include "opt_msgbuf.h" #include <sys/param.h> #include <sys/systm.h> @@ -3406,53 +3405,3 @@ pmap_flush_pvcache(vm_page_t m) } } } - -#if 0 -#ifdef DDB -#include <ddb/ddb.h> - -DB_SHOW_COMMAND(tlb, ddb_dump_tlb) -{ - int cpu, tlbno; - struct tlb *tlb; - - if (have_addr) - cpu = ((addr >> 4) % 16) * 10 + (addr % 16); - else - cpu = PCPU_GET(cpuid); - - if (cpu < 0 || cpu >= mp_ncpus) { - db_printf("Invalid CPU %d\n", cpu); - return; - } else - db_printf("CPU %d:\n", cpu); - - if (cpu == PCPU_GET(cpuid)) - pmap_save_tlb(); - - for (tlbno = 0; tlbno < num_tlbentries; ++tlbno) { - tlb = &tlbstash[cpu][tlbno]; - if (pte_test(&tlb->tlb_lo0, PG_V) || - pte_test(&tlb->tlb_lo1, PG_V)) { - printf("TLB %2d vad 0x%0lx ", - tlbno, (long)(tlb->tlb_hi & 0xffffff00)); - } else { - printf("TLB*%2d vad 0x%0lx ", - tlbno, (long)(tlb->tlb_hi & 0xffffff00)); - } - printf("0=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo0)); - printf("%c", tlb->tlb_lo0 & PG_V ? 'V' : '-'); - printf("%c", tlb->tlb_lo0 & PG_D ? 'D' : '-'); - printf("%c", tlb->tlb_lo0 & PG_G ? 'G' : '-'); - printf(" atr %x ", (tlb->tlb_lo0 >> 3) & 7); - printf("1=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo1)); - printf("%c", tlb->tlb_lo1 & PG_V ? 'V' : '-'); - printf("%c", tlb->tlb_lo1 & PG_D ? 'D' : '-'); - printf("%c", tlb->tlb_lo1 & PG_G ? 'G' : '-'); - printf(" atr %x ", (tlb->tlb_lo1 >> 3) & 7); - printf(" sz=%x pid=%x\n", tlb->tlb_mask, - (tlb->tlb_hi & 0x000000ff)); - } -} -#endif /* DDB */ -#endif Modified: user/jmallett/octeon/sys/mips/mips/tlb.c ============================================================================== --- user/jmallett/octeon/sys/mips/mips/tlb.c Sat Apr 3 07:19:31 2010 (r206122) +++ user/jmallett/octeon/sys/mips/mips/tlb.c Sat Apr 3 07:27:32 2010 (r206123) @@ -26,6 +26,8 @@ * $FreeBSD$ */ +#include "opt_ddb.h" + #include <sys/param.h> #include <sys/kernel.h> #include <sys/systm.h> @@ -137,3 +139,37 @@ tlb_invalidate_one(unsigned i) mips_wr_index(i); tlb_write_indexed(); } + +#ifdef DDB +#include <ddb/ddb.h> + +DB_SHOW_COMMAND(tlb, ddb_dump_tlb) +{ + register_t ehi, elo0, elo1; + unsigned i; + + db_printf("Beginning TLB dump...\n"); + for (i = 0; i < num_tlbentries; i++) { + if (i == mips_rd_wired()) { + if (i != 0) + db_printf("^^^ WIRED ENTRIES ^^^\n"); + else + db_printf("(No wired entries.)\n"); + } + mips_wr_index(i); + tlb_read(); + + ehi = mips_rd_entryhi(); + elo0 = mips_rd_entrylo0(); + elo1 = mips_rd_entrylo1(); + + if (elo0 == 0 && elo1 == 0) + continue; + + db_printf("#%u\t=> %jx\n", i, (intmax_t)ehi); + db_printf(" Lo0\t%jx\n", (intmax_t)elo0); + db_printf(" Lo1\t%jx\n", (intmax_t)elo1); + } + db_printf("Finished.\n"); +} +#endif Modified: user/jmallett/octeon/sys/mips/mips/vm_machdep.c ============================================================================== --- user/jmallett/octeon/sys/mips/mips/vm_machdep.c Sat Apr 3 07:19:31 2010 (r206122) +++ user/jmallett/octeon/sys/mips/mips/vm_machdep.c Sat Apr 3 07:27:32 2010 (r206123) @@ -224,10 +224,10 @@ cpu_thread_swapin(struct thread *td) */ if (!(pte = pmap_segmap(kernel_pmap, td->td_kstack))) panic("cpu_thread_swapin: invalid segmap"); - pte += ((vm_offset_t)td->td_kstack >> PAGE_SHIFT) & (NPTEPG - 1); + pte += PDE_OFFSET(td->td_kstack); for (i = 0; i < KSTACK_PAGES; i++) { - td->td_md.md_upte[i] = *pte & ~(PG_RO | PG_W); + td->td_md.md_upte[i] = *pte & ~TLBLO_SWBITS_MASK; pte++; } } @@ -249,10 +249,10 @@ cpu_thread_alloc(struct thread *td) if (!(pte = pmap_segmap(kernel_pmap, td->td_kstack))) panic("cpu_thread_alloc: invalid segmap"); - pte += ((vm_offset_t)td->td_kstack >> PAGE_SHIFT) & (NPTEPG - 1); + pte += PDE_OFFSET(td->td_kstack); for (i = 0; i < KSTACK_PAGES; i++) { - td->td_md.md_upte[i] = *pte & ~(PG_RO | PG_W); + td->td_md.md_upte[i] = *pte & ~TLBLO_SWBITS_MASK; pte++; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004030727.o337RWWm016958>