Rev 746 | Rev 748 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 746 | Rev 747 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
- | 2 | * Copyright (C) 2005 - 2006 Jakub Jermar |
|
2 | * Copyright (C) 2005 Jakub Jermar |
3 | * Copyright (C) 2006 Jakub Vana |
3 | * All rights reserved. |
4 | * All rights reserved. |
4 | * |
5 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * are met: |
Line 27... | Line 28... | ||
27 | */ |
28 | */ |
28 | 29 | ||
29 | #ifndef __ia64_PAGE_H__ |
30 | #ifndef __ia64_PAGE_H__ |
30 | #define __ia64_PAGE_H__ |
31 | #define __ia64_PAGE_H__ |
31 | 32 | ||
32 | #include <arch/types.h> |
- | |
33 | #include <arch/mm/frame.h> |
33 | #include <arch/mm/frame.h> |
- | 34 | #include <genarch/mm/page_ht.h> |
|
- | 35 | #include <arch/types.h> |
|
- | 36 | #include <typedefs.h> |
|
- | 37 | #include <debug.h> |
|
34 | 38 | ||
35 | #define PAGE_SIZE FRAME_SIZE |
39 | #define PAGE_SIZE FRAME_SIZE |
36 | #define PAGE_WIDTH FRAME_WIDTH |
40 | #define PAGE_WIDTH FRAME_WIDTH |
37 | 41 | ||
38 | #define KA2PA(x) ((__address) (x)) |
42 | #define KA2PA(x) ((__address) (x)) |
Line 49... | Line 53... | ||
49 | #define HT_INVALIDATE_SLOT_ARCH(t) |
53 | #define HT_INVALIDATE_SLOT_ARCH(t) |
50 | #define HT_GET_NEXT_ARCH(t) 0 |
54 | #define HT_GET_NEXT_ARCH(t) 0 |
51 | #define HT_SET_NEXT_ARCH(t, s) |
55 | #define HT_SET_NEXT_ARCH(t, s) |
52 | #define HT_SET_RECORD_ARCH(t, page, asid, frame, flags) |
56 | #define HT_SET_RECORD_ARCH(t, page, asid, frame, flags) |
53 | 57 | ||
54 | #define REGION_RID_MAIN 0 |
58 | #define VRN_KERNEL 0 |
55 | #define REGION_RID_FIRST_INVALID 16 |
- | |
56 | #define REGION_REGISTERS 8 |
59 | #define REGION_REGISTERS 8 |
57 | 60 | ||
58 | #define VHPT_WIDTH 16 /*64kB*/ |
61 | #define VHPT_WIDTH 20 /* 1M */ |
59 | #define VHPT_SIZE (1<<VHPT_WIDTH) |
62 | #define VHPT_SIZE (1<<VHPT_WIDTH) |
60 | 63 | ||
61 | #define VHPT_BASE 0 /* Must be aligned to VHPT_SIZE */ |
64 | #define VHPT_BASE page_ht /* Must be aligned to VHPT_SIZE */ |
62 | 65 | ||
63 | struct VHPT_tag_info |
66 | struct vhpt_tag_info { |
64 | { |
- | |
65 | unsigned long long tag :63; |
67 | unsigned long long tag : 63; |
66 | unsigned ti : 1; |
68 | unsigned ti : 1; |
67 | }__attribute__ ((packed)); |
69 | } __attribute__ ((packed)); |
68 | 70 | ||
69 | union VHPT_tag |
71 | union vhpt_tag { |
70 | { |
- | |
71 | struct VHPT_tag_info tag_info; |
72 | struct vhpt_tag_info tag_info; |
72 | unsigned tag_word; |
73 | unsigned tag_word; |
73 | }; |
74 | }; |
74 | 75 | ||
75 | struct VHPT_entry_present |
76 | struct vhpt_entry_present { |
76 | { |
- | |
77 | - | ||
78 | /* Word 0 */ |
77 | /* Word 0 */ |
79 | unsigned p : 1; |
78 | unsigned p : 1; |
80 | unsigned rv0 : 1; |
79 | unsigned : 1; |
81 | unsigned ma : 3; |
80 | unsigned ma : 3; |
82 | unsigned a : 1; |
81 | unsigned a : 1; |
83 | unsigned d : 1; |
82 | unsigned d : 1; |
84 | unsigned pl : 2; |
83 | unsigned pl : 2; |
85 | unsigned ar : 3; |
84 | unsigned ar : 3; |
86 | unsigned long long ppn :38; |
85 | unsigned long long ppn : 38; |
87 | unsigned rv1 : 2; |
86 | unsigned : 2; |
88 | unsigned ed : 1; |
87 | unsigned ed : 1; |
89 | unsigned ig1 :11; |
88 | unsigned ig1 : 11; |
90 | 89 | ||
91 | /* Word 1 */ |
90 | /* Word 1 */ |
92 | unsigned rv2 : 2; |
91 | unsigned : 2; |
93 | unsigned ps : 6; |
92 | unsigned ps : 6; |
94 | unsigned key :24; |
93 | unsigned key : 24; |
95 | unsigned rv3 :32; |
94 | unsigned : 32; |
96 | 95 | ||
97 | /* Word 2 */ |
96 | /* Word 2 */ |
98 | union VHPT_tag tag; /*This data is here as union because I'm not sure if anybody nead access to areas ti and tag in VHPT entry*/ |
- | |
99 | /* But I'm almost sure we nead access to whole word so there are both possibilities*/ |
- | |
100 | /* Word 3 */ |
97 | union vhpt_tag tag; |
101 | unsigned long long next :64; /* This ignored field will be (in my hopes ;-) ) used as pointer in link list of entries with same hash value*/ |
- | |
102 | 98 | ||
- | 99 | /* Word 3 */ |
|
- | 100 | unsigned long long next : 64; /**< Collision chain next pointer. */ |
|
103 | }__attribute__ ((packed)); |
101 | } __attribute__ ((packed)); |
104 | 102 | ||
105 | struct VHPT_entry_not_present |
103 | struct vhpt_entry_not_present { |
106 | { |
- | |
107 | /* Word 0 */ |
104 | /* Word 0 */ |
108 | unsigned p : 1; |
105 | unsigned p : 1; |
109 | unsigned long long ig0 :52; |
106 | unsigned long long ig0 : 52; |
110 | unsigned ig1 :11; |
107 | unsigned ig1 : 11; |
111 | 108 | ||
112 | /* Word 1 */ |
109 | /* Word 1 */ |
113 | unsigned rv2 : 2; |
110 | unsigned : 2; |
114 | unsigned ps : 6; |
111 | unsigned ps : 6; |
115 | unsigned long long ig2 :56; |
112 | unsigned long long ig2 : 56; |
116 | 113 | ||
117 | - | ||
118 | /* Word 2 */ |
114 | /* Word 2 */ |
119 | union VHPT_tag tag; /*This data is here as union because I'm not sure if anybody nead access to areas ti and tag in VHPT entry*/ |
115 | union vhpt_tag tag; |
120 | /* But I'm almost sure we nead access to whole word so there are both possibilities*/ |
- | |
- | 116 | ||
121 | /* Word 3 */ |
117 | /* Word 3 */ |
122 | unsigned long long next :64; /* This ignored field will be (in my hopes ;-) ) used as pointer in link list of entries with same hash value*/ |
118 | unsigned long long next : 64; /**< Collision chain next pointer. */ |
123 | 119 | ||
124 | }__attribute__ ((packed)); |
120 | } __attribute__ ((packed)); |
- | 121 | ||
- | 122 | typedef union vhpt_entry { |
|
- | 123 | struct vhpt_entry_present present; |
|
- | 124 | struct vhpt_entry_not_present not_present; |
|
- | 125 | } vhpt_entry; |
|
- | 126 | ||
- | 127 | struct region_register_map { |
|
- | 128 | unsigned ve : 1; |
|
- | 129 | unsigned : 1; |
|
- | 130 | unsigned ps : 6; |
|
- | 131 | unsigned rid : 24; |
|
- | 132 | unsigned : 32; |
|
- | 133 | } __attribute__ ((packed)); |
|
- | 134 | ||
- | 135 | typedef union region_register { |
|
- | 136 | struct region_register_map map; |
|
- | 137 | unsigned long long word; |
|
- | 138 | } region_register; |
|
- | 139 | ||
- | 140 | struct pta_register_map { |
|
- | 141 | unsigned ve : 1; |
|
- | 142 | unsigned : 1; |
|
- | 143 | unsigned size : 6; |
|
- | 144 | unsigned vf : 1; |
|
- | 145 | unsigned : 6; |
|
- | 146 | unsigned long long base : 49; |
|
- | 147 | } __attribute__ ((packed)); |
|
- | 148 | ||
- | 149 | typedef union pta_register { |
|
- | 150 | struct pta_register_map map; |
|
- | 151 | __u64 word; |
|
- | 152 | } pta_register; |
|
125 | 153 | ||
126 | typedef union VHPT_entry |
154 | /** Return Translation Hashed Entry Address. |
- | 155 | * |
|
- | 156 | * VRN bits are used to read RID (ASID) from one |
|
- | 157 | * of the eight region registers registers. |
|
- | 158 | * |
|
- | 159 | * @param va Virtual address including VRN bits. |
|
- | 160 | * |
|
- | 161 | * @return Address of the head of VHPT collision chain. |
|
- | 162 | */ |
|
- | 163 | static inline __u64 thash(__u64 va) |
|
127 | { |
164 | { |
128 | struct VHPT_entry_present present; |
- | |
129 | struct VHPT_entry_not_present not_present; |
- | |
130 | }VHPT_entry; |
165 | __u64 ret; |
131 | 166 | ||
132 | extern void page_arch_init(void); |
167 | __asm__ volatile ("thash %0 = %1\n" : "=r" (ret) : "r" (va)); |
133 | 168 | ||
- | 169 | return ret; |
|
- | 170 | } |
|
134 | 171 | ||
- | 172 | /** Return Translation Hashed Entry Tag. |
|
- | 173 | * |
|
- | 174 | * VRN bits are used to read RID (ASID) from one |
|
135 | struct region_register_map |
175 | * of the eight region registers. |
- | 176 | * |
|
- | 177 | * @param va Virtual address including VRN bits. |
|
- | 178 | * |
|
- | 179 | * @return The unique tag for VPN and RID in the collision chain returned by thash(). |
|
- | 180 | */ |
|
- | 181 | static inline __u64 ttag(__u64 va) |
|
136 | { |
182 | { |
137 | unsigned ve : 1; |
- | |
138 | unsigned r0 : 1; |
- | |
139 | unsigned ps : 6; |
- | |
140 | unsigned rid :24; |
- | |
141 | unsigned r1 :32; |
- | |
142 | }__attribute__ ((packed)); |
183 | __u64 ret; |
143 | 184 | ||
- | 185 | __asm__ volatile ("ttag %0 = %1\n" : "=r" (ret) : "r" (va)); |
|
144 | 186 | ||
145 | typedef union region_register |
187 | return ret; |
146 | { |
188 | } |
147 | struct region_register_map map; |
- | |
148 | unsigned long long word; |
- | |
149 | }region_register; |
- | |
150 | 189 | ||
151 | struct PTA_register_map |
190 | /** Read Region Register. |
- | 191 | * |
|
- | 192 | * @param i Region register index. |
|
- | 193 | * |
|
- | 194 | * @return Current contents of rr[i]. |
|
- | 195 | */ |
|
- | 196 | static inline __u64 rr_read(index_t i) |
|
152 | { |
197 | { |
153 | unsigned ve : 1; |
- | |
154 | unsigned r0 : 1; |
- | |
155 | unsigned size : 6; |
198 | __u64 ret; |
- | 199 | ||
156 | unsigned vf : 1; |
200 | // ASSERT(i < REGION_REGISTERS); |
157 | unsigned r1 : 6; |
201 | __asm__ volatile ("mov %0 = rr[%1]\n" : "=r" (ret) : "r" (i)); |
158 | unsigned long long base:49; |
- | |
- | 202 | ||
159 | }__attribute__ ((packed)); |
203 | return ret; |
- | 204 | } |
|
160 | 205 | ||
161 | 206 | ||
162 | typedef union PTA_register |
207 | /** Write Region Register. |
- | 208 | * |
|
- | 209 | * @param i Region register index. |
|
- | 210 | * @param v Value to be written to rr[i]. |
|
- | 211 | */ |
|
- | 212 | static inline void rr_write(index_t i, __u64 v) |
|
- | 213 | { |
|
- | 214 | // ASSERT(i < REGION_REGISTERS); |
|
- | 215 | __asm__ volatile ("mov rr[%0] = %1\n" : : "r" (i), "r" (v)); |
|
- | 216 | } |
|
- | 217 | ||
- | 218 | /** Read Page Table Register. |
|
- | 219 | * |
|
- | 220 | * @return Current value stored in PTA. |
|
- | 221 | */ |
|
- | 222 | static inline __u64 pta_read(void) |
|
- | 223 | { |
|
- | 224 | __u64 ret; |
|
- | 225 | ||
- | 226 | __asm__ volatile ("mov %0 = cr.pta\n" : "=r" (ret)); |
|
- | 227 | ||
- | 228 | return ret; |
|
- | 229 | } |
|
- | 230 | ||
- | 231 | /** Write Page Table Register. |
|
- | 232 | * |
|
- | 233 | * @param v New value to be stored in PTA. |
|
- | 234 | */ |
|
- | 235 | static inline void pta_write(__u64 v) |
|
163 | { |
236 | { |
164 | struct PTA_register_map map; |
- | |
165 | unsigned long long word; |
237 | __asm__ volatile ("mov cr.pta = %0\n" : : "r" (v)); |
166 | }PTA_register; |
238 | } |
167 | 239 | ||
- | 240 | extern void page_arch_init(void); |
|
168 | 241 | ||
169 | #endif |
242 | #endif |