Subversion Repositories HelenOS

Rev

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

Rev 3386 Rev 4581
Line 110... Line 110...
110
 
110
 
111
/* Set PTE address accessors for each level. */
111
/* Set PTE address accessors for each level. */
112
#define SET_PTL0_ADDRESS_ARCH(ptl0) \
112
#define SET_PTL0_ADDRESS_ARCH(ptl0) \
113
    (write_cr3((uintptr_t) (ptl0)))
113
    (write_cr3((uintptr_t) (ptl0)))
114
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
114
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
115
    set_pt_addr((pte_t *) (ptl0), (index_t) (i), a)
115
    set_pt_addr((pte_t *) (ptl0), (size_t) (i), a)
116
#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) \
116
#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a) \
117
    set_pt_addr((pte_t *) (ptl1), (index_t) (i), a)
117
    set_pt_addr((pte_t *) (ptl1), (size_t) (i), a)
118
#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) \
118
#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a) \
119
    set_pt_addr((pte_t *) (ptl2), (index_t) (i), a)
119
    set_pt_addr((pte_t *) (ptl2), (size_t) (i), a)
120
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
120
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
121
    set_pt_addr((pte_t *) (ptl3), (index_t) (i), a)
121
    set_pt_addr((pte_t *) (ptl3), (size_t) (i), a)
122
 
122
 
123
/* Get PTE flags accessors for each level. */
123
/* Get PTE flags accessors for each level. */
124
#define GET_PTL1_FLAGS_ARCH(ptl0, i) \
124
#define GET_PTL1_FLAGS_ARCH(ptl0, i) \
125
    get_pt_flags((pte_t *) (ptl0), (index_t) (i))
125
    get_pt_flags((pte_t *) (ptl0), (size_t) (i))
126
#define GET_PTL2_FLAGS_ARCH(ptl1, i) \
126
#define GET_PTL2_FLAGS_ARCH(ptl1, i) \
127
    get_pt_flags((pte_t *) (ptl1), (index_t) (i))
127
    get_pt_flags((pte_t *) (ptl1), (size_t) (i))
128
#define GET_PTL3_FLAGS_ARCH(ptl2, i) \
128
#define GET_PTL3_FLAGS_ARCH(ptl2, i) \
129
    get_pt_flags((pte_t *) (ptl2), (index_t) (i))
129
    get_pt_flags((pte_t *) (ptl2), (size_t) (i))
130
#define GET_FRAME_FLAGS_ARCH(ptl3, i) \
130
#define GET_FRAME_FLAGS_ARCH(ptl3, i) \
131
    get_pt_flags((pte_t *) (ptl3), (index_t) (i))
131
    get_pt_flags((pte_t *) (ptl3), (size_t) (i))
132
 
132
 
133
/* Set PTE flags accessors for each level. */
133
/* Set PTE flags accessors for each level. */
134
#define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
134
#define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
135
    set_pt_flags((pte_t *) (ptl0), (index_t) (i), (x))
135
    set_pt_flags((pte_t *) (ptl0), (size_t) (i), (x))
136
#define SET_PTL2_FLAGS_ARCH(ptl1, i, x) \
136
#define SET_PTL2_FLAGS_ARCH(ptl1, i, x) \
137
    set_pt_flags((pte_t *) (ptl1), (index_t) (i), (x))
137
    set_pt_flags((pte_t *) (ptl1), (size_t) (i), (x))
138
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x) \
138
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x) \
139
    set_pt_flags((pte_t *) (ptl2), (index_t) (i), (x))
139
    set_pt_flags((pte_t *) (ptl2), (size_t) (i), (x))
140
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
140
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
141
    set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x))
141
    set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
142
 
142
 
143
/* Macros for querying the last-level PTE entries. */
143
/* Macros for querying the last-level PTE entries. */
144
#define PTE_VALID_ARCH(p) \
144
#define PTE_VALID_ARCH(p) \
145
    (*((uint64_t *) (p)) != 0)
145
    (*((uint64_t *) (p)) != 0)
146
#define PTE_PRESENT_ARCH(p) \
146
#define PTE_PRESENT_ARCH(p) \
Line 174... Line 174...
174
/** When bit on this position os 1, the page fault was caused during instruction
174
/** When bit on this position os 1, the page fault was caused during instruction
175
 * fecth.
175
 * fecth.
176
 */
176
 */
177
#define PFERR_CODE_ID       (1 << 4)
177
#define PFERR_CODE_ID       (1 << 4)
178
 
178
 
179
static inline int get_pt_flags(pte_t *pt, index_t i)
179
static inline int get_pt_flags(pte_t *pt, size_t i)
180
{
180
{
181
    pte_t *p = &pt[i];
181
    pte_t *p = &pt[i];
182
   
182
   
183
    return ((!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT |
183
    return ((!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT |
184
        (!p->present) << PAGE_PRESENT_SHIFT |
184
        (!p->present) << PAGE_PRESENT_SHIFT |
Line 187... Line 187...
187
        p->writeable << PAGE_WRITE_SHIFT |
187
        p->writeable << PAGE_WRITE_SHIFT |
188
        (!p->no_execute) << PAGE_EXEC_SHIFT |
188
        (!p->no_execute) << PAGE_EXEC_SHIFT |
189
        p->global << PAGE_GLOBAL_SHIFT);
189
        p->global << PAGE_GLOBAL_SHIFT);
190
}
190
}
191
 
191
 
192
static inline void set_pt_addr(pte_t *pt, index_t i, uintptr_t a)
192
static inline void set_pt_addr(pte_t *pt, size_t i, uintptr_t a)
193
{
193
{
194
    pte_t *p = &pt[i];
194
    pte_t *p = &pt[i];
195
 
195
 
196
    p->addr_12_31 = (a >> 12) & 0xfffff;
196
    p->addr_12_31 = (a >> 12) & 0xfffff;
197
    p->addr_32_51 = a >> 32;
197
    p->addr_32_51 = a >> 32;
198
}
198
}
199
 
199
 
200
static inline void set_pt_flags(pte_t *pt, index_t i, int flags)
200
static inline void set_pt_flags(pte_t *pt, size_t i, int flags)
201
{
201
{
202
    pte_t *p = &pt[i];
202
    pte_t *p = &pt[i];
203
   
203
   
204
    p->page_cache_disable = !(flags & PAGE_CACHEABLE);
204
    p->page_cache_disable = !(flags & PAGE_CACHEABLE);
205
    p->present = !(flags & PAGE_NOT_PRESENT);
205
    p->present = !(flags & PAGE_NOT_PRESENT);