Skip to contentSkip to conversation

powerpc: Split the various pgtable-* headers based on MMU type

PATCH New Benjamin Herrenschmidt 1 participant 1 message Feb 24, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Split the various pgtable-* headers based on MMU type

This patch moves the definition of the PTE format for each MMU type to separate files instead of all in one file. This improves overall maintainability and will make it easier to add new types.

There are still some type-related ifdef's in the generic headers, we might remove them in the long run, but this page shouldn't result in any code change, just definitions being moved around.

---

 arch/powerpc/include/asm/pgtable-40x.h        |   64 +++++
 arch/powerpc/include/asm/pgtable-44x.h        |  102 ++++++++
 arch/powerpc/include/asm/pgtable-8xx.h        |   64 +++++
 arch/powerpc/include/asm/pgtable-fsl-booke.h  |   46 +++
 arch/powerpc/include/asm/pgtable-hash32.h     |   49 +++
 arch/powerpc/include/asm/pgtable-hash64-4k.h  |  117 +++++++++
 arch/powerpc/include/asm/pgtable-hash64-64k.h |  155 ++++++++++++
 arch/powerpc/include/asm/pgtable-hash64.h     |   47 +++
 arch/powerpc/include/asm/pgtable-ppc32.h      |  321 +-------------------------
 arch/powerpc/include/asm/pgtable-ppc64.h      |   53 ----
 10 files changed, 676 insertions(+), 342 deletions(-)
arch/powerpc/include/asm/pgtable-40x.h new file +64 -0
@@ -0,0 +1,64 @@
+#ifndef _ASM_POWERPC_PGTABLE_40x_H
+#define _ASM_POWERPC_PGTABLE_40x_H
+#ifdef __KERNEL__
+
+/*
+ * At present, all PowerPC 400-class processors share a similar TLB
+ * architecture. The instruction and data sides share a unified,
+ * 64-entry, fully-associative TLB which is maintained totally under
+ * software control. In addition, the instruction side has a
+ * hardware-managed, 4-entry, fully-associative TLB which serves as a
+ * first level to the shared TLB. These two TLBs are known as the UTLB
+ * and ITLB, respectively (see "mmu.h" for definitions).
+ *
+ * There are several potential gotchas here.  The 40x hardware TLBLO
+ * field looks like this:
+ *
+ * 0  1  2  3  4  ... 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ * RPN.....................  0  0 EX WR ZSEL.......  W  I  M  G
+ *
+ * Where possible we make the Linux PTE bits match up with this
+ *
+ * - bits 20 and 21 must be cleared, because we use 4k pages (40x can
+ *   support down to 1k pages), this is done in the TLBMiss exception
+ *   handler.
+ * - We use only zones 0 (for kernel pages) and 1 (for user pages)
+ *   of the 16 available.  Bit 24-26 of the TLB are cleared in the TLB
+ *   miss handler.  Bit 27 is PAGE_USER, thus selecting the correct
+ *   zone.
+ * - PRESENT *must* be in the bottom two bits because swap cache
+ *   entries use the top 30 bits.  Because 40x doesn't support SMP
+ *   anyway, M is irrelevant so we borrow it for PAGE_PRESENT.  Bit 30
+ *   is cleared in the TLB miss handler before the TLB entry is loaded.
+ * - All other bits of the PTE are loaded into TLBLO without
+ *   modification, leaving us only the bits 20, 21, 24, 25, 26, 30 for
+ *   software PTE bits.  We actually use use bits 21, 24, 25, and
+ *   30 respectively for the software bits: ACCESSED, DIRTY, RW, and
+ *   PRESENT.
+ */
+
+#define	_PAGE_GUARDED	0x001	/* G: page is guarded from prefetch */
+#define _PAGE_FILE	0x001	/* when !present: nonlinear file mapping */
+#define _PAGE_PRESENT	0x002	/* software: PTE contains a translation */
+#define	_PAGE_NO_CACHE	0x004	/* I: caching is inhibited */
+#define	_PAGE_WRITETHRU	0x008	/* W: caching is write-through */
+#define	_PAGE_USER	0x010	/* matches one of the zone permission bits */
+#define	_PAGE_RW	0x040	/* software: Writes permitted */
+#define	_PAGE_DIRTY	0x080	/* software: dirty page */
+#define _PAGE_HWWRITE	0x100	/* hardware: Dirty & RW, set in exception */
+#define _PAGE_HWEXEC	0x200	/* hardware: EX permission */
+#define _PAGE_ACCESSED	0x400	/* software: R: page referenced */
+
+#define _PMD_PRESENT	0x400	/* PMD points to page of PTEs */
+#define _PMD_BAD	0x802
+#define _PMD_SIZE	0x0e0	/* size field, != 0 for large-page PMD entry */
+#define _PMD_SIZE_4M	0x0c0
+#define _PMD_SIZE_16M	0x0e0
+
+#define PMD_PAGE_SIZE(pmdval)	(1024 << (((pmdval) & _PMD_SIZE) >> 4))
+
+/* Until my rework is finished, 40x still needs atomic PTE updates */
+#define PTE_ATOMIC_UPDATES	1
+
+#endif /* __KERNEL__ */
+#endif /*  _ASM_POWERPC_PGTABLE_40x_H */
arch/powerpc/include/asm/pgtable-44x.h new file +102 -0

102 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-8xx.h new file +64 -0

64 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-fsl-booke.h new file +46 -0

46 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-hash32.h new file +49 -0

49 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-ppc32.h +22 -299

349 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-hash64-4k.h new file +117 -0

117 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-hash64-64k.h new file +155 -0

155 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-hash64.h new file +47 -0

47 lines not on this page · raw message

arch/powerpc/include/asm/pgtable-ppc64.h +10 -43

82 lines not on this page · raw message