xref: /linux/arch/powerpc/include/asm/nohash/32/pte-44x.h (revision 17ed9e3192b2b29ad24ffe711fa4b71716ef3ff3)
1*17ed9e31SAneesh Kumar K.V #ifndef _ASM_POWERPC_NOHASH_32_PTE_44x_H
2*17ed9e31SAneesh Kumar K.V #define _ASM_POWERPC_NOHASH_32_PTE_44x_H
3*17ed9e31SAneesh Kumar K.V #ifdef __KERNEL__
4*17ed9e31SAneesh Kumar K.V 
5*17ed9e31SAneesh Kumar K.V /*
6*17ed9e31SAneesh Kumar K.V  * Definitions for PPC440
7*17ed9e31SAneesh Kumar K.V  *
8*17ed9e31SAneesh Kumar K.V  * Because of the 3 word TLB entries to support 36-bit addressing,
9*17ed9e31SAneesh Kumar K.V  * the attribute are difficult to map in such a fashion that they
10*17ed9e31SAneesh Kumar K.V  * are easily loaded during exception processing.  I decided to
11*17ed9e31SAneesh Kumar K.V  * organize the entry so the ERPN is the only portion in the
12*17ed9e31SAneesh Kumar K.V  * upper word of the PTE and the attribute bits below are packed
13*17ed9e31SAneesh Kumar K.V  * in as sensibly as they can be in the area below a 4KB page size
14*17ed9e31SAneesh Kumar K.V  * oriented RPN.  This at least makes it easy to load the RPN and
15*17ed9e31SAneesh Kumar K.V  * ERPN fields in the TLB. -Matt
16*17ed9e31SAneesh Kumar K.V  *
17*17ed9e31SAneesh Kumar K.V  * This isn't entirely true anymore, at least some bits are now
18*17ed9e31SAneesh Kumar K.V  * easier to move into the TLB from the PTE. -BenH.
19*17ed9e31SAneesh Kumar K.V  *
20*17ed9e31SAneesh Kumar K.V  * Note that these bits preclude future use of a page size
21*17ed9e31SAneesh Kumar K.V  * less than 4KB.
22*17ed9e31SAneesh Kumar K.V  *
23*17ed9e31SAneesh Kumar K.V  *
24*17ed9e31SAneesh Kumar K.V  * PPC 440 core has following TLB attribute fields;
25*17ed9e31SAneesh Kumar K.V  *
26*17ed9e31SAneesh Kumar K.V  *   TLB1:
27*17ed9e31SAneesh Kumar K.V  *   0  1  2  3  4  ... 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
28*17ed9e31SAneesh Kumar K.V  *   RPN.................................  -  -  -  -  -  - ERPN.......
29*17ed9e31SAneesh Kumar K.V  *
30*17ed9e31SAneesh Kumar K.V  *   TLB2:
31*17ed9e31SAneesh Kumar K.V  *   0  1  2  3  4  ... 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32*17ed9e31SAneesh Kumar K.V  *   -  -  -  -  -    - U0 U1 U2 U3 W  I  M  G  E   - UX UW UR SX SW SR
33*17ed9e31SAneesh Kumar K.V  *
34*17ed9e31SAneesh Kumar K.V  * Newer 440 cores (440x6 as used on AMCC 460EX/460GT) have additional
35*17ed9e31SAneesh Kumar K.V  * TLB2 storage attibute fields. Those are:
36*17ed9e31SAneesh Kumar K.V  *
37*17ed9e31SAneesh Kumar K.V  *   TLB2:
38*17ed9e31SAneesh Kumar K.V  *   0...10    11   12   13   14   15   16...31
39*17ed9e31SAneesh Kumar K.V  *   no change WL1  IL1I IL1D IL2I IL2D no change
40*17ed9e31SAneesh Kumar K.V  *
41*17ed9e31SAneesh Kumar K.V  * There are some constrains and options, to decide mapping software bits
42*17ed9e31SAneesh Kumar K.V  * into TLB entry.
43*17ed9e31SAneesh Kumar K.V  *
44*17ed9e31SAneesh Kumar K.V  *   - PRESENT *must* be in the bottom three bits because swap cache
45*17ed9e31SAneesh Kumar K.V  *     entries use the top 29 bits for TLB2.
46*17ed9e31SAneesh Kumar K.V  *
47*17ed9e31SAneesh Kumar K.V  *   - CACHE COHERENT bit (M) has no effect on original PPC440 cores,
48*17ed9e31SAneesh Kumar K.V  *     because it doesn't support SMP. However, some later 460 variants
49*17ed9e31SAneesh Kumar K.V  *     have -some- form of SMP support and so I keep the bit there for
50*17ed9e31SAneesh Kumar K.V  *     future use
51*17ed9e31SAneesh Kumar K.V  *
52*17ed9e31SAneesh Kumar K.V  * With the PPC 44x Linux implementation, the 0-11th LSBs of the PTE are used
53*17ed9e31SAneesh Kumar K.V  * for memory protection related functions (see PTE structure in
54*17ed9e31SAneesh Kumar K.V  * include/asm-ppc/mmu.h).  The _PAGE_XXX definitions in this file map to the
55*17ed9e31SAneesh Kumar K.V  * above bits.  Note that the bit values are CPU specific, not architecture
56*17ed9e31SAneesh Kumar K.V  * specific.
57*17ed9e31SAneesh Kumar K.V  *
58*17ed9e31SAneesh Kumar K.V  * The kernel PTE entry holds an arch-dependent swp_entry structure under
59*17ed9e31SAneesh Kumar K.V  * certain situations. In other words, in such situations some portion of
60*17ed9e31SAneesh Kumar K.V  * the PTE bits are used as a swp_entry. In the PPC implementation, the
61*17ed9e31SAneesh Kumar K.V  * 3-24th LSB are shared with swp_entry, however the 0-2nd three LSB still
62*17ed9e31SAneesh Kumar K.V  * hold protection values. That means the three protection bits are
63*17ed9e31SAneesh Kumar K.V  * reserved for both PTE and SWAP entry at the most significant three
64*17ed9e31SAneesh Kumar K.V  * LSBs.
65*17ed9e31SAneesh Kumar K.V  *
66*17ed9e31SAneesh Kumar K.V  * There are three protection bits available for SWAP entry:
67*17ed9e31SAneesh Kumar K.V  *	_PAGE_PRESENT
68*17ed9e31SAneesh Kumar K.V  *	_PAGE_HASHPTE (if HW has)
69*17ed9e31SAneesh Kumar K.V  *
70*17ed9e31SAneesh Kumar K.V  * So those three bits have to be inside of 0-2nd LSB of PTE.
71*17ed9e31SAneesh Kumar K.V  *
72*17ed9e31SAneesh Kumar K.V  */
73*17ed9e31SAneesh Kumar K.V 
74*17ed9e31SAneesh Kumar K.V #define _PAGE_PRESENT	0x00000001		/* S: PTE valid */
75*17ed9e31SAneesh Kumar K.V #define _PAGE_RW	0x00000002		/* S: Write permission */
76*17ed9e31SAneesh Kumar K.V #define _PAGE_EXEC	0x00000004		/* H: Execute permission */
77*17ed9e31SAneesh Kumar K.V #define _PAGE_ACCESSED	0x00000008		/* S: Page referenced */
78*17ed9e31SAneesh Kumar K.V #define _PAGE_DIRTY	0x00000010		/* S: Page dirty */
79*17ed9e31SAneesh Kumar K.V #define _PAGE_SPECIAL	0x00000020		/* S: Special page */
80*17ed9e31SAneesh Kumar K.V #define _PAGE_USER	0x00000040		/* S: User page */
81*17ed9e31SAneesh Kumar K.V #define _PAGE_ENDIAN	0x00000080		/* H: E bit */
82*17ed9e31SAneesh Kumar K.V #define _PAGE_GUARDED	0x00000100		/* H: G bit */
83*17ed9e31SAneesh Kumar K.V #define _PAGE_COHERENT	0x00000200		/* H: M bit */
84*17ed9e31SAneesh Kumar K.V #define _PAGE_NO_CACHE	0x00000400		/* H: I bit */
85*17ed9e31SAneesh Kumar K.V #define _PAGE_WRITETHRU	0x00000800		/* H: W bit */
86*17ed9e31SAneesh Kumar K.V 
87*17ed9e31SAneesh Kumar K.V /* TODO: Add large page lowmem mapping support */
88*17ed9e31SAneesh Kumar K.V #define _PMD_PRESENT	0
89*17ed9e31SAneesh Kumar K.V #define _PMD_PRESENT_MASK (PAGE_MASK)
90*17ed9e31SAneesh Kumar K.V #define _PMD_BAD	(~PAGE_MASK)
91*17ed9e31SAneesh Kumar K.V 
92*17ed9e31SAneesh Kumar K.V /* ERPN in a PTE never gets cleared, ignore it */
93*17ed9e31SAneesh Kumar K.V #define _PTE_NONE_MASK	0xffffffff00000000ULL
94*17ed9e31SAneesh Kumar K.V 
95*17ed9e31SAneesh Kumar K.V 
96*17ed9e31SAneesh Kumar K.V #endif /* __KERNEL__ */
97*17ed9e31SAneesh Kumar K.V #endif /*  _ASM_POWERPC_NOHASH_32_PTE_44x_H */
98