Subversion Repositories HelenOS

Rev

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

Rev 3022 Rev 4055
Line 38... Line 38...
38
#include <arch/mm/frame.h>
38
#include <arch/mm/frame.h>
39
 
39
 
40
#define PAGE_WIDTH  FRAME_WIDTH
40
#define PAGE_WIDTH  FRAME_WIDTH
41
#define PAGE_SIZE   FRAME_SIZE
41
#define PAGE_SIZE   FRAME_SIZE
42
 
42
 
43
#define PAGE_COLOR_BITS 0           /* dummy */
-
 
44
 
-
 
45
#ifdef KERNEL
43
#ifdef KERNEL
46
 
44
 
47
#ifndef __ASM__
45
#ifndef __ASM__
48
#   define KA2PA(x) (((uintptr_t) (x)) - 0x80000000)
46
#   define KA2PA(x) (((uintptr_t) (x)) - 0x80000000)
49
#   define PA2KA(x) (((uintptr_t) (x)) + 0x80000000)
47
#   define PA2KA(x) (((uintptr_t) (x)) + 0x80000000)
Line 120... Line 118...
120
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
118
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
121
    set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x))
119
    set_pt_flags((pte_t *) (ptl3), (index_t) (i), (x))
122
 
120
 
123
/* Macros for querying the last-level PTEs. */
121
/* Macros for querying the last-level PTEs. */
124
#define PTE_VALID_ARCH(pte)         (*((uint32_t *) (pte)) != 0)
122
#define PTE_VALID_ARCH(pte)         (*((uint32_t *) (pte)) != 0)
125
#define PTE_PRESENT_ARCH(pte)           ((pte)->p != 0)
123
#define PTE_PRESENT_ARCH(pte)           ((pte)->present != 0)
126
#define PTE_GET_FRAME_ARCH(pte)         ((pte)->pfn << 12)
124
#define PTE_GET_FRAME_ARCH(pte)         ((pte)->pfn << 12)
127
#define PTE_WRITABLE_ARCH(pte)          1
125
#define PTE_WRITABLE_ARCH(pte)          1
128
#define PTE_EXECUTABLE_ARCH(pte)        1
126
#define PTE_EXECUTABLE_ARCH(pte)        1
129
 
127
 
130
#ifndef __ASM__
128
#ifndef __ASM__
Line 134... Line 132...
134
 
132
 
135
static inline int get_pt_flags(pte_t *pt, index_t i)
133
static inline int get_pt_flags(pte_t *pt, index_t i)
136
{
134
{
137
    pte_t *p = &pt[i];
135
    pte_t *p = &pt[i];
138
   
136
   
139
    return ((1 << PAGE_CACHEABLE_SHIFT) |
137
    return (((!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT) |
140
        ((!p->p) << PAGE_PRESENT_SHIFT) |
138
        ((!p->present) << PAGE_PRESENT_SHIFT) |
141
        (1 << PAGE_USER_SHIFT) |
139
        (1 << PAGE_USER_SHIFT) |
142
        (1 << PAGE_READ_SHIFT) |
140
        (1 << PAGE_READ_SHIFT) |
143
        (1 << PAGE_WRITE_SHIFT) |
141
        (1 << PAGE_WRITE_SHIFT) |
144
        (1 << PAGE_EXEC_SHIFT) |
142
        (1 << PAGE_EXEC_SHIFT) |
145
        (p->g << PAGE_GLOBAL_SHIFT));
143
        (p->global << PAGE_GLOBAL_SHIFT));
146
}
144
}
147
 
145
 
148
static inline void set_pt_flags(pte_t *pt, index_t i, int flags)
146
static inline void set_pt_flags(pte_t *pt, index_t i, int flags)
149
{
147
{
150
    pte_t *p = &pt[i];
148
    pte_t *p = &pt[i];
151
   
149
   
-
 
150
    p->page_cache_disable = !(flags & PAGE_CACHEABLE);
152
    p->p = !(flags & PAGE_NOT_PRESENT);
151
    p->present = !(flags & PAGE_NOT_PRESENT);
153
    p->g = (flags & PAGE_GLOBAL) != 0;
152
    p->global = (flags & PAGE_GLOBAL) != 0;
154
    p->valid = 1;
153
    p->valid = 1;
155
}
154
}
156
 
155
 
157
extern void page_arch_init(void);
156
extern void page_arch_init(void);
158
 
157