From owner-svn-src-user@FreeBSD.ORG Sat Apr 3 07:27:34 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D2D2106566B; Sat, 3 Apr 2010 07:27:34 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4C0358FC08; Sat, 3 Apr 2010 07:27:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o337RW6d016963; Sat, 3 Apr 2010 07:27:32 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o337RWWm016958; Sat, 3 Apr 2010 07:27:32 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201004030727.o337RWWm016958@svn.freebsd.org> From: Juli Mallett Date: Sat, 3 Apr 2010 07:27:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206123 - in user/jmallett/octeon/sys/mips: include mips X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Apr 2010 07:27:34 -0000 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 __FBSDID("$FreeBSD$"); -#include "opt_ddb.h" #include "opt_msgbuf.h" #include #include @@ -3406,53 +3405,3 @@ pmap_flush_pvcache(vm_page_t m) } } } - -#if 0 -#ifdef DDB -#include - -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 #include #include @@ -137,3 +139,37 @@ tlb_invalidate_one(unsigned i) mips_wr_index(i); tlb_write_indexed(); } + +#ifdef DDB +#include + +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++; } }