Subversion Repositories HelenOS

Rev

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

Rev 3618 Rev 3742
Line 52... Line 52...
52
 
52
 
53
#ifdef CONFIG_TSB
53
#ifdef CONFIG_TSB
54
#include <arch/mm/tsb.h>
54
#include <arch/mm/tsb.h>
55
#endif
55
#endif
56
 
56
 
57
static void dtlb_pte_copy(pte_t *t, index_t index, bool ro);
57
static void dtlb_pte_copy(pte_t *, index_t, bool);
58
static void itlb_pte_copy(pte_t *t, index_t index);
58
static void itlb_pte_copy(pte_t *, index_t);
59
static void do_fast_instruction_access_mmu_miss_fault(istate_t *istate,
59
static void do_fast_instruction_access_mmu_miss_fault(istate_t *, const char *);
60
    const char *str);
-
 
61
static void do_fast_data_access_mmu_miss_fault(istate_t *istate,
60
static void do_fast_data_access_mmu_miss_fault(istate_t *, tlb_tag_access_reg_t,
62
    tlb_tag_access_reg_t tag, const char *str);
61
    const char *);
63
static void do_fast_data_access_protection_fault(istate_t *istate,
62
static void do_fast_data_access_protection_fault(istate_t *,
64
    tlb_tag_access_reg_t tag, const char *str);
63
    tlb_tag_access_reg_t, const char *);
65
 
64
 
66
char *context_encoding[] = {
65
char *context_encoding[] = {
67
    "Primary",
66
    "Primary",
68
    "Secondary",
67
    "Secondary",
69
    "Nucleus",
68
    "Nucleus",
Line 84... Line 83...
84
    itlb_sfsr_write(0);
83
    itlb_sfsr_write(0);
85
}
84
}
86
 
85
 
87
/** Insert privileged mapping into DMMU TLB.
86
/** Insert privileged mapping into DMMU TLB.
88
 *
87
 *
89
 * @param page Virtual page address.
88
 * @param page      Virtual page address.
90
 * @param frame Physical frame address.
89
 * @param frame     Physical frame address.
91
 * @param pagesize Page size.
90
 * @param pagesize  Page size.
92
 * @param locked True for permanent mappings, false otherwise.
91
 * @param locked    True for permanent mappings, false otherwise.
93
 * @param cacheable True if the mapping is cacheable, false otherwise.
92
 * @param cacheable True if the mapping is cacheable, false otherwise.
94
 */
93
 */
95
void dtlb_insert_mapping(uintptr_t page, uintptr_t frame, int pagesize,
94
void dtlb_insert_mapping(uintptr_t page, uintptr_t frame, int pagesize,
96
    bool locked, bool cacheable)
95
    bool locked, bool cacheable)
97
{
96
{
98
    tlb_tag_access_reg_t tag;
97
    tlb_tag_access_reg_t tag;
Line 124... Line 123...
124
    dtlb_data_in_write(data.value);
123
    dtlb_data_in_write(data.value);
125
}
124
}
126
 
125
 
127
/** Copy PTE to TLB.
126
/** Copy PTE to TLB.
128
 *
127
 *
129
 * @param t     Page Table Entry to be copied.
128
 * @param t         Page Table Entry to be copied.
130
 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage.
129
 * @param index     Zero if lower 8K-subpage, one if higher 8K-subpage.
131
 * @param ro    If true, the entry will be created read-only, regardless of its
130
 * @param ro        If true, the entry will be created read-only, regardless
132
 *      w field.
131
 *          of its w field.
133
 */
132
 */
134
void dtlb_pte_copy(pte_t *t, index_t index, bool ro)
133
void dtlb_pte_copy(pte_t *t, index_t index, bool ro)
135
{
134
{
136
    tlb_tag_access_reg_t tag;
135
    tlb_tag_access_reg_t tag;
137
    tlb_data_t data;
136
    tlb_data_t data;
Line 163... Line 162...
163
    dtlb_data_in_write(data.value);
162
    dtlb_data_in_write(data.value);
164
}
163
}
165
 
164
 
166
/** Copy PTE to ITLB.
165
/** Copy PTE to ITLB.
167
 *
166
 *
168
 * @param t     Page Table Entry to be copied.
167
 * @param t     Page Table Entry to be copied.
169
 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage.
168
 * @param index     Zero if lower 8K-subpage, one if higher 8K-subpage.
170
 */
169
 */
171
void itlb_pte_copy(pte_t *t, index_t index)
170
void itlb_pte_copy(pte_t *t, index_t index)
172
{
171
{
173
    tlb_tag_access_reg_t tag;
172
    tlb_tag_access_reg_t tag;
174
    tlb_data_t data;
173
    tlb_data_t data;
Line 233... Line 232...
233
/** DTLB miss handler.
232
/** DTLB miss handler.
234
 *
233
 *
235
 * Note that some faults (e.g. kernel faults) were already resolved by the
234
 * Note that some faults (e.g. kernel faults) were already resolved by the
236
 * low-level, assembly language part of the fast_data_access_mmu_miss handler.
235
 * low-level, assembly language part of the fast_data_access_mmu_miss handler.
237
 *
236
 *
238
 * @param tag Content of the TLB Tag Access register as it existed when the
237
 * @param tag       Content of the TLB Tag Access register as it existed
239
 *    trap happened. This is to prevent confusion created by clobbered
238
 *          when the trap happened. This is to prevent confusion
240
 *    Tag Access register during a nested DTLB miss.
239
 *          created by clobbered Tag Access register during a nested
-
 
240
 *          DTLB miss.
241
 * @param istate Interrupted state saved on the stack.
241
 * @param istate    Interrupted state saved on the stack.
242
 */
242
 */
243
void fast_data_access_mmu_miss(tlb_tag_access_reg_t tag, istate_t *istate)
243
void fast_data_access_mmu_miss(tlb_tag_access_reg_t tag, istate_t *istate)
244
{
244
{
245
    uintptr_t va;
245
    uintptr_t va;
246
    index_t index;
246
    index_t index;
Line 285... Line 285...
285
    }
285
    }
286
}
286
}
287
 
287
 
288
/** DTLB protection fault handler.
288
/** DTLB protection fault handler.
289
 *
289
 *
290
 * @param tag Content of the TLB Tag Access register as it existed when the
290
 * @param tag       Content of the TLB Tag Access register as it existed
291
 *    trap happened. This is to prevent confusion created by clobbered
291
 *          when the trap happened. This is to prevent confusion
292
 *    Tag Access register during a nested DTLB miss.
292
 *          created by clobbered Tag Access register during a nested
-
 
293
 *          DTLB miss.
293
 * @param istate Interrupted state saved on the stack.
294
 * @param istate    Interrupted state saved on the stack.
294
 */
295
 */
295
void fast_data_access_protection(tlb_tag_access_reg_t tag, istate_t *istate)
296
void fast_data_access_protection(tlb_tag_access_reg_t tag, istate_t *istate)
296
{
297
{
297
    uintptr_t va;
298
    uintptr_t va;
298
    index_t index;
299
    index_t index;
Line 334... Line 335...
334
/** Print TLB entry (for debugging purposes).
335
/** Print TLB entry (for debugging purposes).
335
 *
336
 *
336
 * The diag field has been left out in order to make this function more generic
337
 * The diag field has been left out in order to make this function more generic
337
 * (there is no diag field in US3 architeture).
338
 * (there is no diag field in US3 architeture).
338
 *
339
 *
339
 * @param i TLB entry number
340
 * @param i     TLB entry number
340
 * @param t TLB entry tag
341
 * @param t     TLB entry tag
341
 * @param d TLB entry data
342
 * @param d     TLB entry data
342
 */
343
 */
343
static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
344
static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
344
{
345
{
345
    printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
346
    printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
346
        "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
347
        "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
Line 471... Line 472...
471
    printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, "
472
    printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, "
472
        "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w,
473
        "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w,
473
        sfsr.ow, sfsr.fv);
474
        sfsr.ow, sfsr.fv);
474
#elif defined (US3)
475
#elif defined (US3)
475
    printf("DTLB SFSR: nf=%d, asi=%#x, tm=%d, ft=%#x, e=%d, ct=%d, pr=%d, "
476
    printf("DTLB SFSR: nf=%d, asi=%#x, tm=%d, ft=%#x, e=%d, ct=%d, pr=%d, "
476
           "w=%d, ow=%d, fv=%d\n", sfsr.nf, sfsr.asi, sfsr.tm, sfsr.ft,
477
        "w=%d, ow=%d, fv=%d\n", sfsr.nf, sfsr.asi, sfsr.tm, sfsr.ft,
477
        sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
478
        sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
478
#endif
479
#endif
479
       
480
       
480
    printf("DTLB SFAR: address=%p\n", sfar);
481
    printf("DTLB SFAR: address=%p\n", sfar);
481
   
482
   
482
    dtlb_sfsr_write(0);
483
    dtlb_sfsr_write(0);
483
}
484
}
484
 
485
 
485
#if defined (US3)
486
#if defined (US3)
486
/** Invalidates given TLB entry if and only if it is non-locked or global.
487
/** Invalidates given TLB entry if and only if it is non-locked or global.
487
 *
488
 *
488
 * @param tlb
-
 
489
 *  TLB number (one of TLB_DSMALL, TLB_DBIG_0, TLB_DBIG_1,
489
 * @param tlb       TLB number (one of TLB_DSMALL, TLB_DBIG_0, TLB_DBIG_1,
490
 *  TLB_ISMALL, TLB_IBIG)
490
 *          TLB_ISMALL, TLB_IBIG).
491
 * @param entry entry index within the given TLB
491
 * @param entry     Entry index within the given TLB.
492
 */
492
 */
493
static void tlb_invalidate_entry(int tlb, index_t entry)
493
static void tlb_invalidate_entry(int tlb, index_t entry)
494
{
494
{
495
    tlb_data_t d;
495
    tlb_data_t d;
496
    tlb_tag_read_reg_t t;
496
    tlb_tag_read_reg_t t;
Line 594... Line 594...
594
}
594
}
595
 
595
 
596
/** Invalidate all ITLB and DTLB entries for specified page range in specified
596
/** Invalidate all ITLB and DTLB entries for specified page range in specified
597
 * address space.
597
 * address space.
598
 *
598
 *
599
 * @param asid Address Space ID.
599
 * @param asid      Address Space ID.
600
 * @param page First page which to sweep out from ITLB and DTLB.
600
 * @param page      First page which to sweep out from ITLB and DTLB.
601
 * @param cnt Number of ITLB and DTLB entries to invalidate.
601
 * @param cnt       Number of ITLB and DTLB entries to invalidate.
602
 */
602
 */
603
void tlb_invalidate_pages(asid_t asid, uintptr_t page, count_t cnt)
603
void tlb_invalidate_pages(asid_t asid, uintptr_t page, count_t cnt)
604
{
604
{
605
    unsigned int i;
605
    unsigned int i;
606
    tlb_context_reg_t pc_save, ctx;
606
    tlb_context_reg_t pc_save, ctx;