Rev 3228 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3228 | Rev 3230 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2003-2004 Jakub Jermar |
2 | * Copyright (c) 2003-2004 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup mips32mm |
29 | /** @addtogroup mips32mm |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #ifndef KERN_mips32_TLB_H_ |
35 | #ifndef KERN_mips32_TLB_H_ |
36 | #define KERN_mips32_TLB_H_ |
36 | #define KERN_mips32_TLB_H_ |
37 | 37 | ||
38 | #include <arch/types.h> |
38 | #include <arch/types.h> |
39 | #include <typedefs.h> |
39 | #include <typedefs.h> |
40 | #include <arch/mm/asid.h> |
40 | #include <arch/mm/asid.h> |
41 | #include <arch/exception.h> |
41 | #include <arch/exception.h> |
42 | 42 | ||
43 | #ifdef TLBCNT |
43 | #ifdef TLBCNT |
44 | # define TLB_ENTRY_COUNT TLBCNT |
44 | # define TLB_ENTRY_COUNT TLBCNT |
45 | #else |
45 | #else |
46 | # define TLB_ENTRY_COUNT 48 |
46 | # define TLB_ENTRY_COUNT 48 |
47 | #endif |
47 | #endif |
48 | 48 | ||
49 | #define TLB_WIRED 1 |
49 | #define TLB_WIRED 1 |
50 | #define TLB_KSTACK_WIRED_INDEX 0 |
50 | #define TLB_KSTACK_WIRED_INDEX 0 |
51 | 51 | ||
- | 52 | #define TLB_PAGE_MASK_4K (0x000 << 13) |
|
52 | #define TLB_PAGE_MASK_16K (0x3 << 13) |
53 | #define TLB_PAGE_MASK_16K (0x003 << 13) |
- | 54 | #define TLB_PAGE_MASK_64K (0x00f << 13) |
|
- | 55 | #define TLB_PAGE_MASK_256K (0x03f << 13) |
|
- | 56 | #define TLB_PAGE_MASK_1M (0x0ff << 13) |
|
- | 57 | #define TLB_PAGE_MASK_4M (0x3ff << 13) |
|
- | 58 | #define TLB_PAGE_MASK_16M (0xfff << 13) |
|
53 | 59 | ||
54 | #define PAGE_UNCACHED 2 |
60 | #define PAGE_UNCACHED 2 |
55 | #define PAGE_CACHEABLE_EXC_WRITE 5 |
61 | #define PAGE_CACHEABLE_EXC_WRITE 5 |
56 | 62 | ||
57 | typedef union { |
63 | typedef union { |
58 | struct { |
64 | struct { |
59 | #ifdef BIG_ENDIAN |
65 | #ifdef BIG_ENDIAN |
60 | unsigned : 2; /* zero */ |
66 | unsigned : 2; /* zero */ |
61 | unsigned pfn : 24; /* frame number */ |
67 | unsigned pfn : 24; /* frame number */ |
62 | unsigned c : 3; /* cache coherency attribute */ |
68 | unsigned c : 3; /* cache coherency attribute */ |
63 | unsigned d : 1; /* dirty/write-protect bit */ |
69 | unsigned d : 1; /* dirty/write-protect bit */ |
64 | unsigned v : 1; /* valid bit */ |
70 | unsigned v : 1; /* valid bit */ |
65 | unsigned g : 1; /* global bit */ |
71 | unsigned g : 1; /* global bit */ |
66 | #else |
72 | #else |
67 | unsigned g : 1; /* global bit */ |
73 | unsigned g : 1; /* global bit */ |
68 | unsigned v : 1; /* valid bit */ |
74 | unsigned v : 1; /* valid bit */ |
69 | unsigned d : 1; /* dirty/write-protect bit */ |
75 | unsigned d : 1; /* dirty/write-protect bit */ |
70 | unsigned c : 3; /* cache coherency attribute */ |
76 | unsigned c : 3; /* cache coherency attribute */ |
71 | unsigned pfn : 24; /* frame number */ |
77 | unsigned pfn : 24; /* frame number */ |
72 | unsigned : 2; /* zero */ |
78 | unsigned : 2; /* zero */ |
73 | #endif |
79 | #endif |
74 | } __attribute__ ((packed)); |
80 | } __attribute__ ((packed)); |
75 | uint32_t value; |
81 | uint32_t value; |
76 | } entry_lo_t; |
82 | } entry_lo_t; |
77 | 83 | ||
78 | typedef union { |
84 | typedef union { |
79 | struct { |
85 | struct { |
80 | #ifdef BIG_ENDIAN |
86 | #ifdef BIG_ENDIAN |
81 | unsigned vpn2 : 19; |
87 | unsigned vpn2 : 19; |
82 | unsigned : 5; |
88 | unsigned : 5; |
83 | unsigned asid : 8; |
89 | unsigned asid : 8; |
84 | #else |
90 | #else |
85 | unsigned asid : 8; |
91 | unsigned asid : 8; |
86 | unsigned : 5; |
92 | unsigned : 5; |
87 | unsigned vpn2 : 19; |
93 | unsigned vpn2 : 19; |
88 | #endif |
94 | #endif |
89 | } __attribute__ ((packed)); |
95 | } __attribute__ ((packed)); |
90 | uint32_t value; |
96 | uint32_t value; |
91 | } entry_hi_t; |
97 | } entry_hi_t; |
92 | 98 | ||
93 | typedef union { |
99 | typedef union { |
94 | struct { |
100 | struct { |
95 | #ifdef BIG_ENDIAN |
101 | #ifdef BIG_ENDIAN |
96 | unsigned : 7; |
102 | unsigned : 7; |
97 | unsigned mask : 12; |
103 | unsigned mask : 12; |
98 | unsigned : 13; |
104 | unsigned : 13; |
99 | #else |
105 | #else |
100 | unsigned : 13; |
106 | unsigned : 13; |
101 | unsigned mask : 12; |
107 | unsigned mask : 12; |
102 | unsigned : 7; |
108 | unsigned : 7; |
103 | #endif |
109 | #endif |
104 | } __attribute__ ((packed)); |
110 | } __attribute__ ((packed)); |
105 | uint32_t value; |
111 | uint32_t value; |
106 | } page_mask_t; |
112 | } page_mask_t; |
107 | 113 | ||
108 | typedef union { |
114 | typedef union { |
109 | struct { |
115 | struct { |
110 | #ifdef BIG_ENDIAN |
116 | #ifdef BIG_ENDIAN |
111 | unsigned p : 1; |
117 | unsigned p : 1; |
112 | unsigned : 27; |
118 | unsigned : 27; |
113 | unsigned index : 4; |
119 | unsigned index : 4; |
114 | #else |
120 | #else |
115 | unsigned index : 4; |
121 | unsigned index : 4; |
116 | unsigned : 27; |
122 | unsigned : 27; |
117 | unsigned p : 1; |
123 | unsigned p : 1; |
118 | #endif |
124 | #endif |
119 | } __attribute__ ((packed)); |
125 | } __attribute__ ((packed)); |
120 | uint32_t value; |
126 | uint32_t value; |
121 | } tlb_index_t; |
127 | } tlb_index_t; |
122 | 128 | ||
123 | /** Probe TLB for Matching Entry |
129 | /** Probe TLB for Matching Entry |
124 | * |
130 | * |
125 | * Probe TLB for Matching Entry. |
131 | * Probe TLB for Matching Entry. |
126 | */ |
132 | */ |
127 | static inline void tlbp(void) |
133 | static inline void tlbp(void) |
128 | { |
134 | { |
129 | asm volatile ("tlbp\n\t"); |
135 | asm volatile ("tlbp\n\t"); |
130 | } |
136 | } |
131 | 137 | ||
132 | 138 | ||
133 | /** Read Indexed TLB Entry |
139 | /** Read Indexed TLB Entry |
134 | * |
140 | * |
135 | * Read Indexed TLB Entry. |
141 | * Read Indexed TLB Entry. |
136 | */ |
142 | */ |
137 | static inline void tlbr(void) |
143 | static inline void tlbr(void) |
138 | { |
144 | { |
139 | asm volatile ("tlbr\n\t"); |
145 | asm volatile ("tlbr\n\t"); |
140 | } |
146 | } |
141 | 147 | ||
142 | /** Write Indexed TLB Entry |
148 | /** Write Indexed TLB Entry |
143 | * |
149 | * |
144 | * Write Indexed TLB Entry. |
150 | * Write Indexed TLB Entry. |
145 | */ |
151 | */ |
146 | static inline void tlbwi(void) |
152 | static inline void tlbwi(void) |
147 | { |
153 | { |
148 | asm volatile ("tlbwi\n\t"); |
154 | asm volatile ("tlbwi\n\t"); |
149 | } |
155 | } |
150 | 156 | ||
151 | /** Write Random TLB Entry |
157 | /** Write Random TLB Entry |
152 | * |
158 | * |
153 | * Write Random TLB Entry. |
159 | * Write Random TLB Entry. |
154 | */ |
160 | */ |
155 | static inline void tlbwr(void) |
161 | static inline void tlbwr(void) |
156 | { |
162 | { |
157 | asm volatile ("tlbwr\n\t"); |
163 | asm volatile ("tlbwr\n\t"); |
158 | } |
164 | } |
159 | 165 | ||
160 | #define tlb_invalidate(asid) tlb_invalidate_asid(asid) |
166 | #define tlb_invalidate(asid) tlb_invalidate_asid(asid) |
161 | 167 | ||
162 | extern void tlb_invalid(istate_t *istate); |
168 | extern void tlb_invalid(istate_t *istate); |
163 | extern void tlb_refill(istate_t *istate); |
169 | extern void tlb_refill(istate_t *istate); |
164 | extern void tlb_modified(istate_t *istate); |
170 | extern void tlb_modified(istate_t *istate); |
165 | extern void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn); |
171 | extern void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn); |
166 | extern void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr); |
172 | extern void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr); |
167 | 173 | ||
168 | #endif |
174 | #endif |
169 | 175 | ||
170 | /** @} |
176 | /** @} |
171 | */ |
177 | */ |
172 | 178 |