Rev 958 | Rev 1044 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 958 | Rev 993 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | #include <arch/interrupt.h> |
40 | #include <arch/interrupt.h> |
41 | #include <arch/pal/pal.h> |
41 | #include <arch/pal/pal.h> |
42 | #include <arch/asm.h> |
42 | #include <arch/asm.h> |
43 | #include <typedefs.h> |
43 | #include <typedefs.h> |
44 | #include <panic.h> |
44 | #include <panic.h> |
- | 45 | #include <print.h> |
|
45 | #include <arch.h> |
46 | #include <arch.h> |
46 | 47 | ||
47 | - | ||
48 | - | ||
49 | /** Invalidate all TLB entries. */ |
48 | /** Invalidate all TLB entries. */ |
50 | void tlb_invalidate_all(void) |
49 | void tlb_invalidate_all(void) |
51 | { |
50 | { |
- | 51 | ipl_t ipl; |
|
52 | __address adr; |
52 | __address adr; |
53 | __u32 count1,count2,stride1,stride2; |
53 | __u32 count1, count2, stride1, stride2; |
54 | 54 | ||
55 | int i,j; |
55 | int i,j; |
56 | 56 | ||
57 | adr=PAL_PTCE_INFO_BASE(); |
57 | adr = PAL_PTCE_INFO_BASE(); |
58 | count1=PAL_PTCE_INFO_COUNT1(); |
58 | count1 = PAL_PTCE_INFO_COUNT1(); |
59 | count2=PAL_PTCE_INFO_COUNT2(); |
59 | count2 = PAL_PTCE_INFO_COUNT2(); |
60 | stride1=PAL_PTCE_INFO_STRIDE1(); |
60 | stride1 = PAL_PTCE_INFO_STRIDE1(); |
61 | stride2=PAL_PTCE_INFO_STRIDE2(); |
61 | stride2 = PAL_PTCE_INFO_STRIDE2(); |
62 | 62 | ||
63 | interrupts_disable(); |
63 | ipl = interrupts_disable(); |
64 | 64 | ||
65 | for(i=0;i<count1;i++) |
65 | for(i = 0; i < count1; i++) { |
66 | { |
- | |
67 | for(j=0;j<count2;j++) |
66 | for(j = 0; j < count2; j++) { |
68 | { |
- | |
69 | asm volatile |
67 | __asm__ volatile ( |
70 | ( |
- | |
71 | "ptc.e %0;;" |
68 | "ptc.e %0 ;;" |
72 | : |
69 | : |
73 | :"r" (adr) |
70 | : "r" (adr) |
74 | ); |
71 | ); |
75 | adr+=stride2; |
72 | adr += stride2; |
76 | } |
73 | } |
77 | adr+=stride1; |
74 | adr += stride1; |
78 | } |
75 | } |
79 | 76 | ||
80 | interrupts_enable(); |
77 | interrupts_restore(ipl); |
81 | 78 | ||
82 | srlz_d(); |
79 | srlz_d(); |
83 | srlz_i(); |
80 | srlz_i(); |
84 | } |
81 | } |
85 | 82 | ||
Line 87... | Line 84... | ||
87 | * |
84 | * |
88 | * @param asid Address space identifier. |
85 | * @param asid Address space identifier. |
89 | */ |
86 | */ |
90 | void tlb_invalidate_asid(asid_t asid) |
87 | void tlb_invalidate_asid(asid_t asid) |
91 | { |
88 | { |
92 | /* TODO */ |
- | |
93 | tlb_invalidate_all(); |
89 | tlb_invalidate_all(); |
94 | } |
90 | } |
95 | 91 | ||
96 | 92 | ||
97 | void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt) |
93 | void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt) |
98 | { |
94 | { |
99 | - | ||
100 | - | ||
101 | region_register rr; |
95 | region_register rr; |
102 | bool restore_rr = false; |
96 | bool restore_rr = false; |
103 | int b=0; |
97 | int b = 0; |
104 | int c=cnt; |
98 | int c = cnt; |
105 | 99 | ||
106 | __address va; |
100 | __address va; |
107 | va=page; |
101 | va = page; |
108 | 102 | ||
109 | rr.word = rr_read(VA2VRN(va)); |
103 | rr.word = rr_read(VA2VRN(va)); |
110 | if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) { |
104 | if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(va))))) { |
111 | /* |
105 | /* |
112 | * The selected region register does not contain required RID. |
106 | * The selected region register does not contain required RID. |
Line 119... | Line 113... | ||
119 | rr_write(VA2VRN(va), rr0.word); |
113 | rr_write(VA2VRN(va), rr0.word); |
120 | srlz_d(); |
114 | srlz_d(); |
121 | srlz_i(); |
115 | srlz_i(); |
122 | } |
116 | } |
123 | 117 | ||
124 | while(c>>=1) b++; |
118 | while(c >>= 1) |
- | 119 | b++; |
|
125 | b>>=1; |
120 | b >>= 1; |
126 | __u64 ps; |
121 | __u64 ps; |
127 | 122 | ||
128 | switch(b) |
123 | switch (b) { |
129 | { |
- | |
130 | case 0: /*cnt 1-3*/ |
124 | case 0: /*cnt 1-3*/ |
131 | { |
- | |
132 | ps=PAGE_WIDTH; |
125 | ps = PAGE_WIDTH; |
133 | break; |
126 | break; |
134 | } |
- | |
135 | case 1: /*cnt 4-15*/ |
127 | case 1: /*cnt 4-15*/ |
136 | { |
- | |
137 | /*cnt=((cnt-1)/4)+1;*/ |
128 | /*cnt=((cnt-1)/4)+1;*/ |
138 | ps=PAGE_WIDTH+2; |
129 | ps = PAGE_WIDTH+2; |
139 | va&=~((1<<ps)-1); |
130 | va &= ~((1<<ps)-1); |
140 | break; |
131 | break; |
141 | } |
- | |
142 | case 2: /*cnt 16-63*/ |
132 | case 2: /*cnt 16-63*/ |
143 | { |
- | |
144 | /*cnt=((cnt-1)/16)+1;*/ |
133 | /*cnt=((cnt-1)/16)+1;*/ |
145 | ps=PAGE_WIDTH+4; |
134 | ps = PAGE_WIDTH+4; |
146 | va&=~((1<<ps)-1); |
135 | va &= ~((1<<ps)-1); |
147 | break; |
136 | break; |
148 | } |
- | |
149 | case 3: /*cnt 64-255*/ |
137 | case 3: /*cnt 64-255*/ |
150 | { |
- | |
151 | /*cnt=((cnt-1)/64)+1;*/ |
138 | /*cnt=((cnt-1)/64)+1;*/ |
152 | ps=PAGE_WIDTH+6; |
139 | ps = PAGE_WIDTH+6; |
153 | va&=~((1<<ps)-1); |
140 | va &= ~((1<<ps)-1); |
154 | break; |
141 | break; |
155 | } |
- | |
156 | case 4: /*cnt 256-1023*/ |
142 | case 4: /*cnt 256-1023*/ |
157 | { |
- | |
158 | /*cnt=((cnt-1)/256)+1;*/ |
143 | /*cnt=((cnt-1)/256)+1;*/ |
159 | ps=PAGE_WIDTH+8; |
144 | ps = PAGE_WIDTH+8; |
160 | va&=~((1<<ps)-1); |
145 | va &= ~((1<<ps)-1); |
161 | break; |
146 | break; |
162 | } |
- | |
163 | case 5: /*cnt 1024-4095*/ |
147 | case 5: /*cnt 1024-4095*/ |
164 | { |
- | |
165 | /*cnt=((cnt-1)/1024)+1;*/ |
148 | /*cnt=((cnt-1)/1024)+1;*/ |
166 | ps=PAGE_WIDTH+10; |
149 | ps = PAGE_WIDTH+10; |
167 | va&=~((1<<ps)-1); |
150 | va &= ~((1<<ps)-1); |
168 | break; |
151 | break; |
169 | } |
- | |
170 | case 6: /*cnt 4096-16383*/ |
152 | case 6: /*cnt 4096-16383*/ |
171 | { |
- | |
172 | /*cnt=((cnt-1)/4096)+1;*/ |
153 | /*cnt=((cnt-1)/4096)+1;*/ |
173 | ps=PAGE_WIDTH+12; |
154 | ps = PAGE_WIDTH+12; |
174 | va&=~((1<<ps)-1); |
155 | va &= ~((1<<ps)-1); |
175 | break; |
156 | break; |
176 | } |
- | |
177 | case 7: /*cnt 16384-65535*/ |
157 | case 7: /*cnt 16384-65535*/ |
178 | case 8: /*cnt 65536-(256K-1)*/ |
158 | case 8: /*cnt 65536-(256K-1)*/ |
179 | { |
- | |
180 | /*cnt=((cnt-1)/16384)+1;*/ |
159 | /*cnt=((cnt-1)/16384)+1;*/ |
181 | ps=PAGE_WIDTH+14; |
160 | ps = PAGE_WIDTH+14; |
182 | va&=~((1<<ps)-1); |
161 | va &= ~((1<<ps)-1); |
183 | break; |
162 | break; |
184 | } |
- | |
185 | default: |
163 | default: |
186 | { |
- | |
187 | /*cnt=((cnt-1)/(16384*16))+1;*/ |
164 | /*cnt=((cnt-1)/(16384*16))+1;*/ |
188 | ps=PAGE_WIDTH+18; |
165 | ps=PAGE_WIDTH+18; |
189 | va&=~((1<<ps)-1); |
166 | va&=~((1<<ps)-1); |
190 | break; |
167 | break; |
191 | } |
- | |
192 | } |
168 | } |
193 | /*cnt+=(page!=va);*/ |
169 | /*cnt+=(page!=va);*/ |
194 | for(;va<(page+cnt*(PAGE_SIZE));va+=(1<<ps)) { |
170 | for(; va<(page+cnt*(PAGE_SIZE)); va += (1<<ps)) { |
195 | __asm__ volatile |
171 | __asm__ volatile ( |
196 | ( |
- | |
197 | "ptc.l %0,%1;;" |
172 | "ptc.l %0,%1;;" |
198 | : |
173 | : |
199 | : "r"(va), "r"(ps<<2) |
174 | : "r" (va), "r" (ps<<2) |
200 | ); |
175 | ); |
201 | } |
176 | } |
202 | srlz_d(); |
177 | srlz_d(); |
203 | srlz_i(); |
178 | srlz_i(); |
204 | 179 | ||
205 | - | ||
206 | if (restore_rr) { |
180 | if (restore_rr) { |
207 | rr_write(VA2VRN(va), rr.word); |
181 | rr_write(VA2VRN(va), rr.word); |
208 | srlz_d(); |
182 | srlz_d(); |
209 | srlz_i(); |
183 | srlz_i(); |
210 | } |
184 | } |
211 | - | ||
212 | - | ||
213 | } |
185 | } |
214 | 186 | ||
215 | 187 | ||
216 | /** Insert data into data translation cache. |
188 | /** Insert data into data translation cache. |
217 | * |
189 | * |
Line 504... | Line 476... | ||
504 | } else { |
476 | } else { |
505 | /* |
477 | /* |
506 | * Forward the page fault to address space page fault handler. |
478 | * Forward the page fault to address space page fault handler. |
507 | */ |
479 | */ |
508 | if (!as_page_fault(va)) { |
480 | if (!as_page_fault(va)) { |
509 | panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid); |
481 | panic("%s: va=%P, rid=%d, iip=%P\n", __FUNCTION__, va, rid, istate->cr_iip); |
510 | } |
482 | } |
511 | } |
483 | } |
512 | } |
484 | } |
513 | 485 | ||
514 | /** Data nested TLB fault handler. |
486 | /** Data nested TLB fault handler. |
Line 610... | Line 582... | ||
610 | itc_pte_copy(t); |
582 | itc_pte_copy(t); |
611 | else |
583 | else |
612 | dtc_pte_copy(t); |
584 | dtc_pte_copy(t); |
613 | } else { |
585 | } else { |
614 | if (!as_page_fault(va)) { |
586 | if (!as_page_fault(va)) { |
615 | panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid); |
587 | panic("%s: va=%P, rid=%d\n", __FUNCTION__, va, rr.map.rid); |
616 | } |
588 | } |
617 | } |
589 | } |
618 | } |
590 | } |