Subversion Repositories HelenOS-historic

Rev

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

Rev 747 Rev 748
Line 36... Line 36...
36
#include <mm/frame.h>
36
#include <mm/frame.h>
37
#include <config.h>
37
#include <config.h>
38
#include <panic.h>
38
#include <panic.h>
39
#include <arch/asm.h>
39
#include <arch/asm.h>
40
#include <arch/barrier.h>
40
#include <arch/barrier.h>
-
 
41
#include <memstr.h>
41
 
42
 
42
/** Initialize VHPT and region registers. */
43
/** Initialize VHPT and region registers. */
43
static void set_vhpt_environment(void)
44
static void set_vhpt_environment(void)
44
{
45
{
45
    region_register rr;
46
    region_register rr;
Line 64... Line 65...
64
        /* skip kernel rr */
65
        /* skip kernel rr */
65
        if (i == VRN_KERNEL)
66
        if (i == VRN_KERNEL)
66
            continue;
67
            continue;
67
   
68
   
68
        rr.word == rr_read(i);
69
        rr.word == rr_read(i);
-
 
70
        rr.map.ve = 0;      /* disable VHPT walker */
69
        rr.map.rid = ASID_INVALID;
71
        rr.map.rid = ASID_INVALID;
70
        rr_write(i, rr.word);
72
        rr_write(i, rr.word);
71
        srlz_i();
73
        srlz_i();
72
        srlz_d();
74
        srlz_d();
73
    }
75
    }
74
 
76
 
75
    /*
77
    /*
76
     * Allocate VHPT and invalidate all its entries.
78
     * Allocate VHPT and invalidate all its entries.
77
     */
79
     */
78
    page_ht = (pte_t *) frame_alloc(FRAME_KA, VHPT_WIDTH - FRAME_WIDTH, NULL);
80
    page_ht = (pte_t *) frame_alloc(FRAME_KA, VHPT_WIDTH - FRAME_WIDTH, NULL);
-
 
81
    memsetb((__address) page_ht, VHPT_SIZE, 0);
79
    ht_invalidate_all();
82
    ht_invalidate_all();   
80
   
83
   
81
    /*
84
    /*
82
     * Set up PTA register.
85
     * Set up PTA register.
83
     */
86
     */
84
    pta.word = pta_read();
87
    pta.word = pta_read();
Line 96... Line 99...
96
{
99
{
97
    page_operations = &page_ht_operations;
100
    page_operations = &page_ht_operations;
98
    pk_disable();
101
    pk_disable();
99
    set_vhpt_environment();
102
    set_vhpt_environment();
100
}
103
}
-
 
104
 
-
 
105
/** Calculate address of collision chain from VPN and ASID.
-
 
106
 *
-
 
107
 * This is rather non-trivial function.
-
 
108
 * First, it has to translate ASID to RID.
-
 
109
 * This is achieved by taking VRN bits of
-
 
110
 * page into account.
-
 
111
 * Second, it must preserve the region register
-
 
112
 * it writes the RID to.
-
 
113
 *
-
 
114
 * @param page Address of virtual page including VRN bits.
-
 
115
 * @param asid Address space identifier.
-
 
116
 *
-
 
117
 * @return Head of VHPT collision chain for page and asid.
-
 
118
 */
-
 
119
pte_t *vhpt_hash(__address page, asid_t asid)
-
 
120
{
-
 
121
    region_register rr_save, rr;
-
 
122
    pte_t *t;
-
 
123
 
-
 
124
    rr_save.word = rr_read(VRN_WORK);
-
 
125
    rr.word = rr_save.word;
-
 
126
    if ((page >> VRN_SHIFT) != VRN_KERNEL)
-
 
127
        rr.map.rid = (asid * RIDS_PER_ASID) + (page >> VRN_SHIFT);
-
 
128
    else
-
 
129
        rr.map.rid = ASID_KERNEL;
-
 
130
    rr_write(VRN_WORK, rr.word);
-
 
131
    srlz_i();
-
 
132
    t = (pte_t *) thash((VRN_WORK << VRN_SHIFT) | (~(VRN_MASK) & page));
-
 
133
    rr_write(VRN_WORK, rr_save.word);
-
 
134
    srlz_i();
-
 
135
    srlz_d();
-
 
136
 
-
 
137
    return t;
-
 
138
}