Subversion Repositories HelenOS

Rev

Rev 3343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3343 Rev 3440
Line 59... Line 59...
59
/* TLB Demap Operation Context register encodings. */
59
/* TLB Demap Operation Context register encodings. */
60
#define TLB_DEMAP_PRIMARY   0
60
#define TLB_DEMAP_PRIMARY   0
61
#define TLB_DEMAP_SECONDARY 1
61
#define TLB_DEMAP_SECONDARY 1
62
#define TLB_DEMAP_NUCLEUS   2
62
#define TLB_DEMAP_NUCLEUS   2
63
 
63
 
-
 
64
/* there are more TLBs in one MMU in US3, their codes are defined here */
-
 
65
#if defined (US3)
-
 
66
    /* D-MMU: one 16-entry TLB and two 512-entry TLBs */
-
 
67
    #define TLB_DT16    0
-
 
68
    #define TLB_DT512_1 2
-
 
69
    #define TLB_DT512_2 3
-
 
70
   
-
 
71
    /* I-MMU: one 16-entry TLB and one 128-entry TLB */
-
 
72
    #define TLB_IT16    0
-
 
73
    #define TLB_IT128   2
-
 
74
#endif
-
 
75
 
64
#define TLB_DEMAP_CONTEXT_SHIFT 4
76
#define TLB_DEMAP_CONTEXT_SHIFT 4
65
 
77
 
66
/* TLB Tag Access shifts */
78
/* TLB Tag Access shifts */
67
#define TLB_TAG_ACCESS_CONTEXT_SHIFT    0
79
#define TLB_TAG_ACCESS_CONTEXT_SHIFT    0
68
#define TLB_TAG_ACCESS_CONTEXT_MASK ((1 << 13) - 1)
80
#define TLB_TAG_ACCESS_CONTEXT_MASK ((1 << 13) - 1)
Line 88... Line 100...
88
 
100
 
89
/** I-/D-TLB Data In/Access Register type. */
101
/** I-/D-TLB Data In/Access Register type. */
90
typedef tte_data_t tlb_data_t;
102
typedef tte_data_t tlb_data_t;
91
 
103
 
92
/** I-/D-TLB Data Access Address in Alternate Space. */
104
/** I-/D-TLB Data Access Address in Alternate Space. */
-
 
105
 
-
 
106
#if defined (US)
-
 
107
 
93
union tlb_data_access_addr {
108
union tlb_data_access_addr {
94
    uint64_t value;
109
    uint64_t value;
95
    struct {
110
    struct {
96
        uint64_t : 55;
111
        uint64_t : 55;
97
        unsigned tlb_entry : 6;
112
        unsigned tlb_entry : 6;
98
        unsigned : 3;
113
        unsigned : 3;
99
    } __attribute__ ((packed));
114
    } __attribute__ ((packed));
100
};
115
};
101
typedef union tlb_data_access_addr tlb_data_access_addr_t;
116
typedef union tlb_data_access_addr dtlb_data_access_addr_t;
-
 
117
typedef union tlb_data_access_addr dtlb_tag_read_addr_t;
-
 
118
typedef union tlb_data_access_addr itlb_data_access_addr_t;
102
typedef union tlb_data_access_addr tlb_tag_read_addr_t;
119
typedef union tlb_data_access_addr itlb_tag_read_addr_t;
-
 
120
 
-
 
121
#elif defined (US3)
-
 
122
 
-
 
123
/*
-
 
124
 * In US3, I-MMU and D-MMU have different formats of the data
-
 
125
 * access register virtual address. In the corresponding
-
 
126
 * structures the member variable for the entry number is
-
 
127
 * called "local_tlb_entry" - it contrast with the "tlb_entry"
-
 
128
 * for the US data access register VA structure. The rationale
-
 
129
 * behind this is to prevent careless mistakes in the code
-
 
130
 * caused by setting only the entry number and not the TLB
-
 
131
 * number in the US3 code (when taking the code from US).
-
 
132
 */
-
 
133
 
-
 
134
union dtlb_data_access_addr {
-
 
135
    uint64_t value;
-
 
136
    struct {
-
 
137
        uint64_t : 45;
-
 
138
        unsigned : 1;
-
 
139
        unsigned tlb_number : 2;
-
 
140
        unsigned : 4;
-
 
141
        unsigned local_tlb_entry : 9;
-
 
142
        unsigned : 3;
-
 
143
    } __attribute__ ((packed));
-
 
144
};
-
 
145
typedef union dtlb_data_access_addr dtlb_data_access_addr_t;
-
 
146
typedef union dtlb_data_access_addr dtlb_tag_read_addr_t;
-
 
147
 
-
 
148
union itlb_data_access_addr {
-
 
149
    uint64_t value;
-
 
150
    struct {
-
 
151
        uint64_t : 45;
-
 
152
        unsigned : 1;
-
 
153
        unsigned tlb_number : 2;
-
 
154
        unsigned : 6;
-
 
155
        unsigned local_tlb_entry : 7;
-
 
156
        unsigned : 3;
-
 
157
    } __attribute__ ((packed));
-
 
158
};
-
 
159
typedef union itlb_data_access_addr itlb_data_access_addr_t;
-
 
160
typedef union itlb_data_access_addr itlb_tag_read_addr_t;
-
 
161
 
-
 
162
#endif
103
 
163
 
104
/** I-/D-TLB Tag Read Register. */
164
/** I-/D-TLB Tag Read Register. */
105
union tlb_tag_read_reg {
165
union tlb_tag_read_reg {
106
    uint64_t value;
166
    uint64_t value;
107
    struct {
167
    struct {
Line 180... Line 240...
180
{
240
{
181
    asi_u64_write(ASI_DMMU, VA_SECONDARY_CONTEXT_REG, v);
241
    asi_u64_write(ASI_DMMU, VA_SECONDARY_CONTEXT_REG, v);
182
    flush_pipeline();
242
    flush_pipeline();
183
}
243
}
184
 
244
 
-
 
245
#if defined (US)
-
 
246
 
185
/** Read IMMU TLB Data Access Register.
247
/** Read IMMU TLB Data Access Register.
186
 *
248
 *
187
 * @param entry TLB Entry index.
249
 * @param entry TLB Entry index.
188
 *
250
 *
189
 * @return Current value of specified IMMU TLB Data Access Register.
251
 * @return Current value of specified IMMU TLB Data Access Register.
190
 */
252
 */
191
static inline uint64_t itlb_data_access_read(index_t entry)
253
static inline uint64_t itlb_data_access_read(index_t entry)
192
{
254
{
193
    tlb_data_access_addr_t reg;
255
    itlb_data_access_addr_t reg;
194
   
256
   
195
    reg.value = 0;
257
    reg.value = 0;
196
    reg.tlb_entry = entry;
258
    reg.tlb_entry = entry;
197
    return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
259
    return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
198
}
260
}
Line 202... Line 264...
202
 * @param entry TLB Entry index.
264
 * @param entry TLB Entry index.
203
 * @param value Value to be written.
265
 * @param value Value to be written.
204
 */
266
 */
205
static inline void itlb_data_access_write(index_t entry, uint64_t value)
267
static inline void itlb_data_access_write(index_t entry, uint64_t value)
206
{
268
{
207
    tlb_data_access_addr_t reg;
269
    itlb_data_access_addr_t reg;
208
   
270
   
209
    reg.value = 0;
271
    reg.value = 0;
210
    reg.tlb_entry = entry;
272
    reg.tlb_entry = entry;
211
    asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
273
    asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
212
    flush_pipeline();
274
    flush_pipeline();
Line 218... Line 280...
218
 *
280
 *
219
 * @return Current value of specified DMMU TLB Data Access Register.
281
 * @return Current value of specified DMMU TLB Data Access Register.
220
 */
282
 */
221
static inline uint64_t dtlb_data_access_read(index_t entry)
283
static inline uint64_t dtlb_data_access_read(index_t entry)
222
{
284
{
223
    tlb_data_access_addr_t reg;
285
    dtlb_data_access_addr_t reg;
224
   
286
   
225
    reg.value = 0;
287
    reg.value = 0;
226
    reg.tlb_entry = entry;
288
    reg.tlb_entry = entry;
227
    return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
289
    return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
228
}
290
}
Line 232... Line 294...
232
 * @param entry TLB Entry index.
294
 * @param entry TLB Entry index.
233
 * @param value Value to be written.
295
 * @param value Value to be written.
234
 */
296
 */
235
static inline void dtlb_data_access_write(index_t entry, uint64_t value)
297
static inline void dtlb_data_access_write(index_t entry, uint64_t value)
236
{
298
{
237
    tlb_data_access_addr_t reg;
299
    dtlb_data_access_addr_t reg;
238
   
300
   
239
    reg.value = 0;
301
    reg.value = 0;
240
    reg.tlb_entry = entry;
302
    reg.tlb_entry = entry;
241
    asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
303
    asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
242
    membar();
304
    membar();
Line 248... Line 310...
248
 *
310
 *
249
 * @return Current value of specified IMMU TLB Tag Read Register.
311
 * @return Current value of specified IMMU TLB Tag Read Register.
250
 */
312
 */
251
static inline uint64_t itlb_tag_read_read(index_t entry)
313
static inline uint64_t itlb_tag_read_read(index_t entry)
252
{
314
{
253
    tlb_tag_read_addr_t tag;
315
    itlb_tag_read_addr_t tag;
254
 
316
 
255
    tag.value = 0;
317
    tag.value = 0;
256
    tag.tlb_entry = entry;
318
    tag.tlb_entry = entry;
257
    return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
319
    return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
258
}
320
}
Line 263... Line 325...
263
 *
325
 *
264
 * @return Current value of specified DMMU TLB Tag Read Register.
326
 * @return Current value of specified DMMU TLB Tag Read Register.
265
 */
327
 */
266
static inline uint64_t dtlb_tag_read_read(index_t entry)
328
static inline uint64_t dtlb_tag_read_read(index_t entry)
267
{
329
{
268
    tlb_tag_read_addr_t tag;
330
    dtlb_tag_read_addr_t tag;
269
 
331
 
270
    tag.value = 0;
332
    tag.value = 0;
271
    tag.tlb_entry = entry;
333
    tag.tlb_entry = entry;
272
    return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
334
    return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
273
}
335
}
274
 
336
 
-
 
337
#elif defined (US3)
-
 
338
 
-
 
339
 
-
 
340
/** Read IMMU TLB Data Access Register.
-
 
341
 *
-
 
342
 * @param tlb TLB number (one of TLB_IT16 or TLB_IT128)
-
 
343
 * @param entry TLB Entry index.
-
 
344
 *
-
 
345
 * @return Current value of specified IMMU TLB Data Access Register.
-
 
346
 */
-
 
347
static inline uint64_t itlb_data_access_read(int tlb, index_t entry)
-
 
348
{
-
 
349
    itlb_data_access_addr_t reg;
-
 
350
   
-
 
351
    reg.value = 0;
-
 
352
    reg.tlb_number = tlb;
-
 
353
    reg.local_tlb_entry = entry;
-
 
354
    return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
-
 
355
}
-
 
356
 
-
 
357
/** Write IMMU TLB Data Access Register.
-
 
358
 * @param tlb TLB number (one of TLB_IT16 or TLB_IT128)
-
 
359
 * @param entry TLB Entry index.
-
 
360
 * @param value Value to be written.
-
 
361
 */
-
 
362
static inline void itlb_data_access_write(int tlb, index_t entry, uint64_t value)
-
 
363
{
-
 
364
    itlb_data_access_addr_t reg;
-
 
365
   
-
 
366
    reg.value = 0;
-
 
367
    reg.tlb_number = tlb;
-
 
368
    reg.local_tlb_entry = entry;
-
 
369
    asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
-
 
370
    flush_pipeline();
-
 
371
}
-
 
372
 
-
 
373
/** Read DMMU TLB Data Access Register.
-
 
374
 *
-
 
375
 * @param tlb TLB number (one of TLB_DT16, TLB_DT512_1, TLB_DT512_2)
-
 
376
 * @param entry TLB Entry index.
-
 
377
 *
-
 
378
 * @return Current value of specified DMMU TLB Data Access Register.
-
 
379
 */
-
 
380
static inline uint64_t dtlb_data_access_read(int tlb, index_t entry)
-
 
381
{
-
 
382
    dtlb_data_access_addr_t reg;
-
 
383
   
-
 
384
    reg.value = 0;
-
 
385
    reg.tlb_number = tlb;
-
 
386
    reg.local_tlb_entry = entry;
-
 
387
    return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
-
 
388
}
-
 
389
 
-
 
390
/** Write DMMU TLB Data Access Register.
-
 
391
 *
-
 
392
 * @param tlb TLB number (one of TLB_DT16, TLB_DT512_1, TLB_DT512_2)  
-
 
393
 * @param entry TLB Entry index.
-
 
394
 * @param value Value to be written.
-
 
395
 */
-
 
396
static inline void dtlb_data_access_write(int tlb, index_t entry, uint64_t value)
-
 
397
{
-
 
398
    dtlb_data_access_addr_t reg;
-
 
399
   
-
 
400
    reg.value = 0;
-
 
401
    reg.tlb_number = tlb;
-
 
402
    reg.local_tlb_entry = entry;
-
 
403
    asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
-
 
404
    membar();
-
 
405
}
-
 
406
 
-
 
407
/** Read IMMU TLB Tag Read Register.
-
 
408
 *
-
 
409
 * @param tlb TLB number (one of TLB_IT16 or TLB_IT128)
-
 
410
 * @param entry TLB Entry index.
-
 
411
 *
-
 
412
 * @return Current value of specified IMMU TLB Tag Read Register.
-
 
413
 */
-
 
414
static inline uint64_t itlb_tag_read_read(int tlb, index_t entry)
-
 
415
{
-
 
416
    itlb_tag_read_addr_t tag;
-
 
417
 
-
 
418
    tag.value = 0;
-
 
419
    tag.tlb_number = tlb;
-
 
420
    tag.local_tlb_entry = entry;
-
 
421
    return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
-
 
422
}
-
 
423
 
-
 
424
/** Read DMMU TLB Tag Read Register.
-
 
425
 *
-
 
426
 * @param tlb TLB number (one of TLB_DT16, TLB_DT512_1, TLB_DT512_2)  
-
 
427
 * @param entry TLB Entry index.
-
 
428
 *
-
 
429
 * @return Current value of specified DMMU TLB Tag Read Register.
-
 
430
 */
-
 
431
static inline uint64_t dtlb_tag_read_read(int tlb, index_t entry)
-
 
432
{
-
 
433
    dtlb_tag_read_addr_t tag;
-
 
434
 
-
 
435
    tag.value = 0;
-
 
436
    tag.tlb_number = tlb;
-
 
437
    tag.local_tlb_entry = entry;
-
 
438
    return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
-
 
439
}
-
 
440
 
-
 
441
#endif
-
 
442
 
-
 
443
 
275
/** Write IMMU TLB Tag Access Register.
444
/** Write IMMU TLB Tag Access Register.
276
 *
445
 *
277
 * @param v Value to be written.
446
 * @param v Value to be written.
278
 */
447
 */
279
static inline void itlb_tag_access_write(uint64_t v)
448
static inline void itlb_tag_access_write(uint64_t v)
Line 439... Line 608...
439
#endif /* !def __ASM__ */
608
#endif /* !def __ASM__ */
440
 
609
 
441
#endif
610
#endif
442
 
611
 
443
/** @}
612
/** @}
444
 */
613
 */
445
 
614