source: rtems/c/src/lib/libbsp/mips/hurricane/startup/idttlb.S @ efdfd48

4.104.115
Last change on this file since efdfd48 was efdfd48, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/29/09 at 15:27:07

Whitespace removal.

  • Property mode set to 100644
File size: 9.3 KB
Line 
1/*
2
3Based upon IDT provided code with the following release:
4
5This source code has been made available to you by IDT on an AS-IS
6basis. Anyone receiving this source is licensed under IDT copyrights
7to use it in any way he or she deems fit, including copying it,
8modifying it, compiling it, and redistributing it either with or
9without modifications.  No license under IDT patents or patent
10applications is to be implied by the copyright license.
11
12Any user of this software should understand that IDT cannot provide
13technical support for this software and will not be responsible for
14any consequences resulting from the use of this software.
15
16Any person who transfers this source code or any derivative work must
17include the IDT copyright notice, this paragraph, and the preceeding
18two paragraphs in the transferred software.
19
20COPYRIGHT IDT CORPORATION 1996
21LICENSED MATERIAL - PROGRAM PROPERTY OF IDT
22
23*/
24
25/*
26 * $Id$
27 */
28
29#include <rtems/mips/iregdef.h>
30#include <rtems/mips/idtcpu.h>
31#include <rtems/asm.h>
32
33
34        .text
35
36#if __mips == 1
37/*
38** ret_tlblo -- returns the 'entrylo' contents for the TLB
39**      'c' callable - as ret_tlblo(index) - where index is the
40**      tlb entry to return the lo value for - if called from assembly
41**      language then index should be in register a0.
42*/
43FRAME(ret_tlblo,sp,0,ra)
44        .set    noreorder
45        mfc0    t0,C0_SR                # save sr
46        nop
47        and     t0,~SR_PE               # dont inadvertantly clear PE
48        mtc0    zero,C0_SR              # clear interrupts
49        mfc0    t1,C0_TLBHI             # save pid
50        sll     a0,TLBINX_INXSHIFT      # position index
51        mtc0    a0,C0_INX               # write to index register
52        nop
53        tlbr                            # put tlb entry in entrylo and hi
54        nop
55        mfc0    v0,C0_TLBLO             # get the requested entry lo
56        mtc0    t1,C0_TLBHI             # restore pid
57        mtc0    t0,C0_SR                # restore status register
58        j       ra
59        nop
60        .set    reorder
61ENDFRAME(ret_tlblo)
62#endif
63#if __mips == 3
64/*
65** ret_tlblo[01] -- returns the 'entrylo' contents for the TLB
66**      'c' callable - as ret_tlblo(index) - where index is the
67**      tlb entry to return the lo value for - if called from assembly
68**      language then index should be in register a0.
69*/
70FRAME(ret_tlblo0,sp,0,ra)
71        mfc0    t0,C0_SR                # save sr
72        mtc0    zero,C0_SR              # clear interrupts
73        mfc0    t1,C0_TLBHI             # save pid
74        mtc0    a0,C0_INX               # write to index register
75        .set noreorder
76        nop; nop; nop; nop; nop; nop; nop; nop
77        .set reorder
78        tlbr                            # put tlb entry in entrylo and hi
79        .set noreorder
80        nop; nop; nop; nop; nop; nop; nop; nop
81        .set reorder
82        mfc0    v0,C0_TLBLO0            # get the requested entry lo
83        mtc0    t1,C0_TLBHI             # restore pid
84        mtc0    t0,C0_SR                # restore status register
85        j       ra
86ENDFRAME(ret_tlblo0)
87
88FRAME(ret_tlblo1,sp,0,ra)
89        mfc0    t0,C0_SR                # save sr
90        mtc0    zero,C0_SR              # clear interrupts
91        mfc0    t1,C0_TLBHI             # save pid
92        mtc0    a0,C0_INX               # write to index register
93        .set noreorder
94        nop; nop; nop; nop; nop; nop; nop; nop
95        .set reorder
96        tlbr                            # put tlb entry in entrylo and hi
97        .set noreorder
98        nop; nop; nop; nop; nop; nop; nop; nop
99        .set reorder
100        mfc0    v0,C0_TLBLO1            # get the requested entry lo
101        mtc0    t1,C0_TLBHI             # restore pid
102        mtc0    t0,C0_SR                # restore status register
103        j       ra
104ENDFRAME(ret_tlblo1)
105
106/*
107** ret_pagemask(index) -- return pagemask contents of tlb entry "index"
108*/
109FRAME(ret_pagemask,sp,0,ra)
110        mfc0    t0,C0_SR                # save sr
111        mtc0    zero,C0_SR              # disable interrupts
112        mfc0    t1,C0_TLBHI             # save current pid
113        mtc0    a0,C0_INX               # drop it in C0 register
114        .set noreorder
115        nop; nop; nop; nop; nop; nop; nop; nop
116        .set reorder
117        tlbr                            # read entry to entry hi/lo
118        .set noreorder
119        nop; nop; nop; nop; nop; nop; nop; nop
120        .set reorder
121        mfc0    v0,C0_PAGEMASK          # to return value
122        mtc0    t1,C0_TLBHI             # restore current pid
123        mtc0    t0,C0_SR                # restore sr
124        j       ra
125ENDFRAME(ret_pagemask)
126
127/*
128** ret_tlbwired(void) -- return wired register
129*/
130FRAME(ret_tlbwired,sp,0,ra)
131        mfc0    v0,C0_WIRED
132        j       ra
133ENDFRAME(ret_tlbwired)
134#endif
135
136/*
137** ret_tlbhi -- return the tlb entry high content for tlb entry
138**                      index
139*/
140FRAME(ret_tlbhi,sp,0,ra)
141#if __mips == 1
142        .set    noreorder
143        mfc0    t0,C0_SR                # save sr
144        nop
145        and     t0,~SR_PE
146        mtc0    zero,C0_SR              # disable interrupts
147        mfc0    t1,C0_TLBHI             # save current pid
148        sll     a0,TLBINX_INXSHIFT      # position index
149        mtc0    a0,C0_INX               # drop it in C0 register
150        nop
151        tlbr                            # read entry to entry hi/lo
152        nop
153        mfc0    v0,C0_TLBHI             # to return value
154        mtc0    t1,C0_TLBHI             # restore current pid
155        mtc0    t0,C0_SR                # restore sr
156        j       ra
157        nop
158        .set    reorder
159#endif
160#if __mips == 3
161        mfc0    t0,C0_SR                # save sr
162        mtc0    zero,C0_SR              # disable interrupts
163        mfc0    t1,C0_TLBHI             # save current pid
164        mtc0    a0,C0_INX               # drop it in C0 register
165        .set noreorder
166        nop; nop; nop; nop; nop; nop; nop; nop
167        .set reorder
168        tlbr                            # read entry to entry hi/lo0/lo1/mask
169        .set noreorder
170        nop; nop; nop; nop; nop; nop; nop; nop
171        .set reorder
172        mfc0    v0,C0_TLBHI             # to return value
173        mtc0    t1,C0_TLBHI             # restore current pid
174        mtc0    t0,C0_SR                # restore sr
175        j       ra
176#endif
177ENDFRAME(ret_tlbhi)
178
179/*
180** ret_tlbpid() -- return tlb pid contained in the current entry hi
181*/
182FRAME(ret_tlbpid,sp,0,ra)
183#if __mips == 1
184        .set    noreorder
185        mfc0    v0,C0_TLBHI             # fetch tlb high
186        nop
187        and     v0,TLBHI_PIDMASK        # isolate and position
188        srl     v0,TLBHI_PIDSHIFT
189        j       ra
190        nop
191        .set    reorder
192#endif
193#if __mips == 3
194        mfc0    v0,C0_TLBHI     # to return value
195        nop
196        and     v0,TLBHI_PIDMASK
197        j       ra
198#endif
199ENDFRAME(ret_tlbpid)
200
201/*
202** tlbprobe(address, pid) -- probe the tlb to see if address is currently
203**                              mapped
204**      a0 = vpn  - virtual page numbers are 0=0 1=0x1000, 2=0x2000...
205**                      virtual page numbers for the r3000 are in
206**                      entry hi bits 31-12
207**      a1 = pid  - this is a process id ranging from 0 to 63
208**                  this process id is shifted left 6 bits and or'ed into
209**                  the entry hi register
210**      returns an index value (0-63) if successful -1 -f not
211*/
212FRAME(tlbprobe,sp,0,ra)
213#if __mips == 1
214        .set    noreorder
215        mfc0    t0,C0_SR                /* fetch status reg */
216        and     a0,TLBHI_VPNMASK        /* isolate just the vpn */
217        and     t0,~SR_PE               /* don't inadvertantly clear pe */
218        mtc0    zero,C0_SR
219        mfc0    t1,C0_TLBHI
220        sll     a1,TLBHI_PIDSHIFT       /* possition the pid */
221        and     a1,TLBHI_PIDMASK
222        or      a0,a1                   /* build entry hi value */
223        mtc0    a0,C0_TLBHI
224        nop
225        tlbp                            /* do the probe */
226        nop
227        mfc0    v1,C0_INX
228        li      v0,-1
229        bltz    v1,1f
230        nop
231        sra     v0,v1,TLBINX_INXSHIFT   /* get index positioned for return */
2321:
233        mtc0    t1,C0_TLBHI             /* restore tlb hi */
234        mtc0    t0,C0_SR                /* restore the status reg */
235        j       ra
236        nop
237        .set    reorder
238#endif
239#if __mips == 3
240        mfc0    t0,C0_SR                # save sr
241        mtc0    zero,C0_SR              # disable interrupts
242        mfc0    t1,C0_TLBHI             # save current pid
243        and     a0,TLBHI_VPN2MASK       # construct tlbhi for probe
244        and     a1,TLBHI_PIDMASK
245        or      a0,a1
246        mtc0    a0,C0_TLBHI
247        .set noreorder
248        nop; nop; nop; nop; nop; nop; nop; nop
249        .set reorder
250        tlbp                            # probe entry to entry hi/lo0/lo1/mask
251        .set noreorder
252        nop; nop; nop; nop; nop; nop; nop; nop
253        .set reorder
254        mfc0    v1,C0_INX
255        li      v0,-1
256        bltz    v1,1f
257        move    v0,v1
2581:      mtc0    t1,C0_TLBHI             # restore current pid
259        mtc0    t0,C0_SR                # restore sr
260        j       ra
261#endif
262ENDFRAME(tlbprobe)
263
264/*
265** resettlb(index) Invalidate the  TLB entry specified by index
266*/
267FRAME(resettlb,sp,0,ra)
268#if __mips == 1
269        .set    noreorder
270        mfc0    t0,C0_TLBHI             # fetch the current hi
271        mfc0    v0,C0_SR                # fetch the status reg.
272        li      t2,K0BASE&TLBHI_VPNMASK
273        and     v0,~SR_PE               # dont inadvertantly clear PE
274        mtc0    zero,C0_SR
275        mtc0    t2,C0_TLBHI             # set up tlbhi
276        mtc0    zero,C0_TLBLO
277        sll     a0,TLBINX_INXSHIFT
278        mtc0    a0,C0_INX
279        nop
280        tlbwi                           # do actual invalidate
281        nop
282        mtc0    t0,C0_TLBHI
283        mtc0    v0,C0_SR
284        j       ra
285        nop
286        .set    reorder
287#endif
288#if __mips == 3
289        li      t2,K0BASE&TLBHI_VPN2MASK
290        mfc0    t0,C0_TLBHI             # save current TLBHI
291        mfc0    v0,C0_SR                # save SR and disable interrupts
292        mtc0    zero,C0_SR
293        mtc0    t2,C0_TLBHI             # invalidate entry
294        mtc0    zero,C0_TLBLO0
295        mtc0    zero,C0_TLBLO1
296        mtc0    a0,C0_INX
297        .set noreorder
298        nop; nop; nop; nop; nop; nop; nop; nop
299        .set reorder
300        tlbwi
301        .set noreorder
302        nop; nop; nop; nop; nop; nop; nop; nop
303        .set reorder
304        mtc0    t0,C0_TLBHI
305        mtc0    v0,C0_SR
306        j       ra
307#endif
308ENDFRAME(resettlb)
309
310#if __mips == 1
311/*
312** Setup TLB entry
313**
314** map_tlb(index, tlbhi, phypage)
315**      a0  =  TLB entry index
316**      a1  =  virtual page number and PID
317**      a2  =  physical page
318*/
319FRAME(map_tlb,sp,0,ra)
320        .set    noreorder
321        sll     a0,TLBINX_INXSHIFT
322        mfc0    v0,C0_SR                # fetch the current status
323        mfc0    a3,C0_TLBHI             # save the current hi
324        and     v0,~SR_PE               # dont inadvertantly clear parity
325
326        mtc0    zero,C0_SR
327        mtc0    a1,C0_TLBHI             # set the hi entry
328        mtc0    a2,C0_TLBLO             # set the lo entry
329        mtc0    a0,C0_INX               # load the index
330        nop
331        tlbwi                           # put the hi/lo in tlb entry indexed
332        nop
333        mtc0    a3,C0_TLBHI             # put back the tlb hi reg
334        mtc0    v0,C0_SR                # restore the status register
335        j       ra
336        nop
337        .set    reorder
338ENDFRAME(map_tlb)
339#endif
340#if __mips == 3
341/*
342** Setup R4000 TLB entry
343**
344** map_tlb4000(mask_index, tlbhi, pte_even, pte_odd)
345**      a0  =  TLB entry index and page mask
346**      a1  =  virtual page number and PID
347**      a2  =  pte -- contents of even pte
348**      a3  =  pte -- contents of odd pte
349*/
350FRAME(map_tlb4000,sp,0,ra)
351        and     t2,a0,TLBPGMASK_MASK
352        and     a0,TLBINX_INXMASK
353        mfc0    t1,C0_TLBHI             # save current TLBPID
354        mfc0    v0,C0_SR                # save SR and disable interrupts
355        mtc0    zero,C0_SR
356        mtc0    t2,C0_PAGEMASK          # set
357        mtc0    a1,C0_TLBHI             # set VPN and TLBPID
358        mtc0    a2,C0_TLBLO0            # set PPN and access bits
359        mtc0    a3,C0_TLBLO1            # set PPN and access bits
360        mtc0    a0,C0_INX               # set INDEX to wired entry
361        .set noreorder
362        nop; nop; nop; nop; nop; nop; nop; nop
363        .set reorder
364        tlbwi                           # drop it in
365        .set noreorder
366        nop; nop; nop; nop; nop; nop; nop; nop
367        .set reorder
368        mtc0    t1,C0_TLBHI             # restore TLBPID
369        mtc0    v0,C0_SR                # restore SR
370        j       ra
371ENDFRAME(map_tlb4000)
372#endif
373
374
375/*
376** Set current TLBPID. This assumes PID is positioned correctly in reg.
377**                      a0.
378*/
379FRAME(set_tlbpid,sp,0,ra)
380        .set    noreorder
381        mtc0    a0,C0_TLBHI
382        j       ra
383        nop
384        .set    reorder
385ENDFRAME(set_tlbpid)
386
Note: See TracBrowser for help on using the repository browser.