All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ppc/85xx: Add a simple function to search the TLB
@ 2009-09-03 13:22 Kumar Gala
  2009-09-05 18:03 ` Kumar Gala
  0 siblings, 1 reply; 2+ messages in thread
From: Kumar Gala @ 2009-09-03 13:22 UTC (permalink / raw)
  To: u-boot

Allow us to search the TLB array based on an address.  This is useful
if we want to change an entry but dont know where it happens to be
located.

For example, the boot page mapping we use on MP or the flash TLB that
we change the WIMGE settings for after we've relocated.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 cpu/mpc85xx/tlb.c     |   27 +++++++++++++++++++++++++++
 include/asm-ppc/mmu.h |    7 +++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/cpu/mpc85xx/tlb.c b/cpu/mpc85xx/tlb.c
index f3d3080..0497a29 100644
--- a/cpu/mpc85xx/tlb.c
+++ b/cpu/mpc85xx/tlb.c
@@ -106,6 +106,33 @@ void init_tlbs(void)
 	return ;
 }
 
+static void tlbsx (const volatile unsigned *addr)
+{
+	__asm__ __volatile__ ("tlbsx 0,%0" : : "r" (addr), "m" (*addr));
+}
+
+/* return -1 if we didn't find anything */
+int find_tlb_idx(void *addr, u8 tlbsel)
+{
+	u32 _mas0, _mas1;
+
+	/* zero out Search PID, AS */
+	mtspr(MAS6, 0);
+
+	tlbsx(addr);
+
+	_mas0 = mfspr(MAS0);
+	_mas1 = mfspr(MAS1);
+
+	/* we found something, and its in the TLB we expect */
+	if ((MAS1_VALID & _mas1) &&
+		(MAS0_TLBSEL(tlbsel) == (_mas0 & MAS0_TLBSEL_MSK))) {
+		return ((_mas0 & MAS0_ESEL_MSK) >> 16);
+	}
+
+	return -1;
+}
+
 #ifdef CONFIG_ADDR_MAP
 void init_addr_map(void)
 {
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h
index fa92b90..eda2959 100644
--- a/include/asm-ppc/mmu.h
+++ b/include/asm-ppc/mmu.h
@@ -387,8 +387,10 @@ extern void print_bats(void);
  * FSL Book-E support
  */
 
-#define MAS0_TLBSEL(x)	((x << 28) & 0x30000000)
-#define MAS0_ESEL(x)	((x << 16) & 0x0FFF0000)
+#define MAS0_TLBSEL_MSK	0x30000000
+#define MAS0_TLBSEL(x)	((x << 28) & MAS0_TLBSEL_MSK)
+#define MAS0_ESEL_MSK	0x0FFF0000
+#define MAS0_ESEL(x)	((x << 16) & MAS0_ESEL_MSK)
 #define MAS0_NV(x)	((x) & 0x00000FFF)
 
 #define MAS1_VALID	0x80000000
@@ -474,6 +476,7 @@ extern void set_tlb(u8 tlb, u32 epn, u64 rpn,
 extern void disable_tlb(u8 esel);
 extern void invalidate_tlb(u8 tlb);
 extern void init_tlbs(void);
+extern int find_tlb_idx(void *addr, u8 tlbsel);
 
 extern unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg);
 
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] ppc/85xx: Add a simple function to search the TLB
  2009-09-03 13:22 [U-Boot] [PATCH] ppc/85xx: Add a simple function to search the TLB Kumar Gala
@ 2009-09-05 18:03 ` Kumar Gala
  0 siblings, 0 replies; 2+ messages in thread
From: Kumar Gala @ 2009-09-05 18:03 UTC (permalink / raw)
  To: u-boot


On Sep 3, 2009, at 8:22 AM, Kumar Gala wrote:

> Allow us to search the TLB array based on an address.  This is useful
> if we want to change an entry but dont know where it happens to be
> located.
>
> For example, the boot page mapping we use on MP or the flash TLB that
> we change the WIMGE settings for after we've relocated.
>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> cpu/mpc85xx/tlb.c     |   27 +++++++++++++++++++++++++++
> include/asm-ppc/mmu.h |    7 +++++--
> 2 files changed, 32 insertions(+), 2 deletions(-)

applied to 85xx

- k

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-05 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-03 13:22 [U-Boot] [PATCH] ppc/85xx: Add a simple function to search the TLB Kumar Gala
2009-09-05 18:03 ` Kumar Gala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.