diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-04-30 00:06:25 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-05-02 06:04:29 -0400 |
commit | 57d7909e0d2dd54567ae775e22b14076b777042a (patch) | |
tree | 6f2e14e0bbb92ff138ae89468136668e58e60d1f | |
parent | c3e8011ad1bf4791a9c6d70ac1b377df93a9f5af (diff) |
[POWERPC] Revise PPC44x MMU code for arch/powerpc
This patch takes the definitions for the PPC44x MMU (a software loaded
TLB) from asm-ppc/mmu.h, cleans them up of things no longer necessary
in arch/powerpc and puts them in a new asm-powerpc/mmu_44x.h file. It
also substantially simplifies arch/powerpc/mm/44x_mmu.c and makes a
couple of small fixes necessary for the 44x MMU code to build and work
properly in arch/powerpc.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/kernel/head_44x.S | 4 | ||||
-rw-r--r-- | arch/powerpc/mm/44x_mmu.c | 82 | ||||
-rw-r--r-- | arch/powerpc/mm/mmu_decl.h | 3 | ||||
-rw-r--r-- | include/asm-powerpc/mmu-44x.h | 72 | ||||
-rw-r--r-- | include/asm-powerpc/mmu.h | 7 |
5 files changed, 100 insertions, 68 deletions
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S index a15d4b8cce48..9ee6773cf026 100644 --- a/arch/powerpc/kernel/head_44x.S +++ b/arch/powerpc/kernel/head_44x.S | |||
@@ -120,8 +120,8 @@ skpinv: addi r4,r4,1 /* Increment */ | |||
120 | * Configure and load pinned entry into TLB slot 63. | 120 | * Configure and load pinned entry into TLB slot 63. |
121 | */ | 121 | */ |
122 | 122 | ||
123 | lis r3,KERNELBASE@h /* Load the kernel virtual address */ | 123 | lis r3,PAGE_OFFSET@h |
124 | ori r3,r3,KERNELBASE@l | 124 | ori r3,r3,PAGE_OFFSET@l |
125 | 125 | ||
126 | /* Kernel is at the base of RAM */ | 126 | /* Kernel is at the base of RAM */ |
127 | li r4, 0 /* Load the kernel physical address */ | 127 | li r4, 0 /* Load the kernel physical address */ |
diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c index 0a0a0487b334..ca4dcb07a939 100644 --- a/arch/powerpc/mm/44x_mmu.c +++ b/arch/powerpc/mm/44x_mmu.c | |||
@@ -24,73 +24,38 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/signal.h> | ||
28 | #include <linux/sched.h> | ||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/errno.h> | ||
31 | #include <linux/string.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/ptrace.h> | ||
34 | #include <linux/mman.h> | ||
35 | #include <linux/mm.h> | ||
36 | #include <linux/swap.h> | ||
37 | #include <linux/stddef.h> | ||
38 | #include <linux/vmalloc.h> | ||
39 | #include <linux/init.h> | 27 | #include <linux/init.h> |
40 | #include <linux/delay.h> | ||
41 | #include <linux/highmem.h> | ||
42 | |||
43 | #include <asm/pgalloc.h> | ||
44 | #include <asm/prom.h> | ||
45 | #include <asm/io.h> | ||
46 | #include <asm/mmu_context.h> | ||
47 | #include <asm/pgtable.h> | ||
48 | #include <asm/mmu.h> | 28 | #include <asm/mmu.h> |
49 | #include <asm/uaccess.h> | 29 | #include <asm/system.h> |
50 | #include <asm/smp.h> | 30 | #include <asm/page.h> |
51 | #include <asm/bootx.h> | ||
52 | #include <asm/machdep.h> | ||
53 | #include <asm/setup.h> | ||
54 | 31 | ||
55 | #include "mmu_decl.h" | 32 | #include "mmu_decl.h" |
56 | 33 | ||
57 | extern char etext[], _stext[]; | ||
58 | |||
59 | /* Used by the 44x TLB replacement exception handler. | 34 | /* Used by the 44x TLB replacement exception handler. |
60 | * Just needed it declared someplace. | 35 | * Just needed it declared someplace. |
61 | */ | 36 | */ |
62 | unsigned int tlb_44x_index = 0; | 37 | unsigned int tlb_44x_index; /* = 0 */ |
63 | unsigned int tlb_44x_hwater = 62; | 38 | unsigned int tlb_44x_hwater = PPC44x_TLB_SIZE - 1 - PPC44x_EARLY_TLBS; |
64 | 39 | ||
65 | /* | 40 | /* |
66 | * "Pins" a 256MB TLB entry in AS0 for kernel lowmem | 41 | * "Pins" a 256MB TLB entry in AS0 for kernel lowmem |
67 | */ | 42 | */ |
68 | static void __init | 43 | static void __init ppc44x_pin_tlb(unsigned int virt, unsigned int phys) |
69 | ppc44x_pin_tlb(int slot, unsigned int virt, unsigned int phys) | ||
70 | { | 44 | { |
71 | unsigned long attrib = 0; | 45 | __asm__ __volatile__( |
72 | 46 | "tlbwe %2,%3,%4\n" | |
73 | __asm__ __volatile__("\ | 47 | "tlbwe %1,%3,%5\n" |
74 | clrrwi %2,%2,10\n\ | 48 | "tlbwe %0,%3,%6\n" |
75 | ori %2,%2,%4\n\ | ||
76 | clrrwi %1,%1,10\n\ | ||
77 | li %0,0\n\ | ||
78 | ori %0,%0,%5\n\ | ||
79 | tlbwe %2,%3,%6\n\ | ||
80 | tlbwe %1,%3,%7\n\ | ||
81 | tlbwe %0,%3,%8" | ||
82 | : | 49 | : |
83 | : "r" (attrib), "r" (phys), "r" (virt), "r" (slot), | 50 | : "r" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G), |
84 | "i" (PPC44x_TLB_VALID | PPC44x_TLB_256M), | 51 | "r" (phys), |
85 | "i" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G), | 52 | "r" (virt | PPC44x_TLB_VALID | PPC44x_TLB_256M), |
53 | "r" (tlb_44x_hwater--), /* slot for this TLB entry */ | ||
86 | "i" (PPC44x_TLB_PAGEID), | 54 | "i" (PPC44x_TLB_PAGEID), |
87 | "i" (PPC44x_TLB_XLAT), | 55 | "i" (PPC44x_TLB_XLAT), |
88 | "i" (PPC44x_TLB_ATTRIB)); | 56 | "i" (PPC44x_TLB_ATTRIB)); |
89 | } | 57 | } |
90 | 58 | ||
91 | /* | ||
92 | * MMU_init_hw does the chip-specific initialization of the MMU hardware. | ||
93 | */ | ||
94 | void __init MMU_init_hw(void) | 59 | void __init MMU_init_hw(void) |
95 | { | 60 | { |
96 | flush_instruction_cache(); | 61 | flush_instruction_cache(); |
@@ -98,22 +63,13 @@ void __init MMU_init_hw(void) | |||
98 | 63 | ||
99 | unsigned long __init mmu_mapin_ram(void) | 64 | unsigned long __init mmu_mapin_ram(void) |
100 | { | 65 | { |
101 | unsigned int pinned_tlbs = 1; | 66 | unsigned long addr; |
102 | int i; | ||
103 | |||
104 | /* Determine number of entries necessary to cover lowmem */ | ||
105 | pinned_tlbs = (unsigned int) | ||
106 | (_ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT); | ||
107 | |||
108 | /* Write upper watermark to save location */ | ||
109 | tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs; | ||
110 | 67 | ||
111 | /* If necessary, set additional pinned TLBs */ | 68 | /* Pin in enough TLBs to cover any lowmem not covered by the |
112 | if (pinned_tlbs > 1) | 69 | * initial 256M mapping established in head_44x.S */ |
113 | for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) { | 70 | for (addr = PPC_PIN_SIZE; addr < total_lowmem; |
114 | unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC_PIN_SIZE; | 71 | addr += PPC_PIN_SIZE) |
115 | ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr); | 72 | ppc44x_pin_tlb(addr + PAGE_OFFSET, addr); |
116 | } | ||
117 | 73 | ||
118 | return total_lowmem; | 74 | return total_lowmem; |
119 | } | 75 | } |
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index 9c4538bb04b0..2558c34eedaa 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h | |||
@@ -40,7 +40,8 @@ extern int __map_without_bats; | |||
40 | extern unsigned long ioremap_base; | 40 | extern unsigned long ioremap_base; |
41 | extern unsigned int rtas_data, rtas_size; | 41 | extern unsigned int rtas_data, rtas_size; |
42 | 42 | ||
43 | extern PTE *Hash, *Hash_end; | 43 | struct _PTE; |
44 | extern struct _PTE *Hash, *Hash_end; | ||
44 | extern unsigned long Hash_size, Hash_mask; | 45 | extern unsigned long Hash_size, Hash_mask; |
45 | 46 | ||
46 | extern unsigned int num_tlbcam_entries; | 47 | extern unsigned int num_tlbcam_entries; |
diff --git a/include/asm-powerpc/mmu-44x.h b/include/asm-powerpc/mmu-44x.h new file mode 100644 index 000000000000..7bbc37e27d3c --- /dev/null +++ b/include/asm-powerpc/mmu-44x.h | |||
@@ -0,0 +1,72 @@ | |||
1 | #ifndef _ASM_POWERPC_MMU_44X_H_ | ||
2 | #define _ASM_POWERPC_MMU_44X_H_ | ||
3 | /* | ||
4 | * PPC440 support | ||
5 | */ | ||
6 | |||
7 | #define PPC44x_MMUCR_TID 0x000000ff | ||
8 | #define PPC44x_MMUCR_STS 0x00010000 | ||
9 | |||
10 | #define PPC44x_TLB_PAGEID 0 | ||
11 | #define PPC44x_TLB_XLAT 1 | ||
12 | #define PPC44x_TLB_ATTRIB 2 | ||
13 | |||
14 | /* Page identification fields */ | ||
15 | #define PPC44x_TLB_EPN_MASK 0xfffffc00 /* Effective Page Number */ | ||
16 | #define PPC44x_TLB_VALID 0x00000200 /* Valid flag */ | ||
17 | #define PPC44x_TLB_TS 0x00000100 /* Translation address space */ | ||
18 | #define PPC44x_TLB_1K 0x00000000 /* Page sizes */ | ||
19 | #define PPC44x_TLB_4K 0x00000010 | ||
20 | #define PPC44x_TLB_16K 0x00000020 | ||
21 | #define PPC44x_TLB_64K 0x00000030 | ||
22 | #define PPC44x_TLB_256K 0x00000040 | ||
23 | #define PPC44x_TLB_1M 0x00000050 | ||
24 | #define PPC44x_TLB_16M 0x00000070 | ||
25 | #define PPC44x_TLB_256M 0x00000090 | ||
26 | |||
27 | /* Translation fields */ | ||
28 | #define PPC44x_TLB_RPN_MASK 0xfffffc00 /* Real Page Number */ | ||
29 | #define PPC44x_TLB_ERPN_MASK 0x0000000f | ||
30 | |||
31 | /* Storage attribute and access control fields */ | ||
32 | #define PPC44x_TLB_ATTR_MASK 0x0000ff80 | ||
33 | #define PPC44x_TLB_U0 0x00008000 /* User 0 */ | ||
34 | #define PPC44x_TLB_U1 0x00004000 /* User 1 */ | ||
35 | #define PPC44x_TLB_U2 0x00002000 /* User 2 */ | ||
36 | #define PPC44x_TLB_U3 0x00001000 /* User 3 */ | ||
37 | #define PPC44x_TLB_W 0x00000800 /* Caching is write-through */ | ||
38 | #define PPC44x_TLB_I 0x00000400 /* Caching is inhibited */ | ||
39 | #define PPC44x_TLB_M 0x00000200 /* Memory is coherent */ | ||
40 | #define PPC44x_TLB_G 0x00000100 /* Memory is guarded */ | ||
41 | #define PPC44x_TLB_E 0x00000080 /* Memory is guarded */ | ||
42 | |||
43 | #define PPC44x_TLB_PERM_MASK 0x0000003f | ||
44 | #define PPC44x_TLB_UX 0x00000020 /* User execution */ | ||
45 | #define PPC44x_TLB_UW 0x00000010 /* User write */ | ||
46 | #define PPC44x_TLB_UR 0x00000008 /* User read */ | ||
47 | #define PPC44x_TLB_SX 0x00000004 /* Super execution */ | ||
48 | #define PPC44x_TLB_SW 0x00000002 /* Super write */ | ||
49 | #define PPC44x_TLB_SR 0x00000001 /* Super read */ | ||
50 | |||
51 | /* Number of TLB entries */ | ||
52 | #define PPC44x_TLB_SIZE 64 | ||
53 | |||
54 | #ifndef __ASSEMBLY__ | ||
55 | |||
56 | typedef unsigned long long phys_addr_t; | ||
57 | |||
58 | extern phys_addr_t fixup_bigphys_addr(phys_addr_t, phys_addr_t); | ||
59 | |||
60 | typedef struct { | ||
61 | unsigned long id; | ||
62 | unsigned long vdso_base; | ||
63 | } mm_context_t; | ||
64 | |||
65 | #endif /* !__ASSEMBLY__ */ | ||
66 | |||
67 | #define PPC44x_EARLY_TLBS 1 | ||
68 | |||
69 | /* Size of the TLBs used for pinning in lowmem */ | ||
70 | #define PPC_PIN_SIZE (1 << 28) /* 256M */ | ||
71 | |||
72 | #endif /* _ASM_POWERPC_MMU_44X_H_ */ | ||
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h index 06b3e6d336cb..fe510fff8907 100644 --- a/include/asm-powerpc/mmu.h +++ b/include/asm-powerpc/mmu.h | |||
@@ -5,9 +5,12 @@ | |||
5 | #ifdef CONFIG_PPC64 | 5 | #ifdef CONFIG_PPC64 |
6 | /* 64-bit classic hash table MMU */ | 6 | /* 64-bit classic hash table MMU */ |
7 | # include <asm/mmu-hash64.h> | 7 | # include <asm/mmu-hash64.h> |
8 | #elif defined(CONFIG_44x) | ||
9 | /* 44x-style software loaded TLB */ | ||
10 | # include <asm/mmu-44x.h> | ||
8 | #else | 11 | #else |
9 | /* 32-bit. FIXME: split up the 32-bit MMU types, and revise for | 12 | /* Other 32-bit. FIXME: split up the other 32-bit MMU types, and |
10 | * arch/powerpc */ | 13 | * revise for arch/powerpc */ |
11 | # include <asm-ppc/mmu.h> | 14 | # include <asm-ppc/mmu.h> |
12 | #endif | 15 | #endif |
13 | 16 | ||