Subversion Repositories HelenOS-historic

Rev

Rev 1702 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1702 Rev 1780
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
 /** @addtogroup amd64mm   
29
/** @addtogroup amd64mm
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
Line 58... Line 58...
58
#  include <mm/page.h>
58
#  include <mm/page.h>
59
#  include <arch/types.h>
59
#  include <arch/types.h>
60
#endif
60
#endif
61
 
61
 
62
#ifndef __ASM__
62
#ifndef __ASM__
63
static inline __address ka2pa(__address x)
63
static inline uintptr_t ka2pa(uintptr_t x)
64
{
64
{
65
    if (x > 0xffffffff80000000)
65
    if (x > 0xffffffff80000000)
66
        return x - 0xffffffff80000000;
66
        return x - 0xffffffff80000000;
67
    else
67
    else
68
        return x - 0xffff800000000000;
68
        return x - 0xffff800000000000;
69
}
69
}
70
# define KA2PA(x)      ka2pa((__address)x)
70
# define KA2PA(x)      ka2pa((uintptr_t)x)
71
# define PA2KA_CODE(x)      (((__address) (x)) + 0xffffffff80000000)
71
# define PA2KA_CODE(x)      (((uintptr_t) (x)) + 0xffffffff80000000)
72
# define PA2KA(x)      (((__address) (x)) + 0xffff800000000000)
72
# define PA2KA(x)      (((uintptr_t) (x)) + 0xffff800000000000)
73
#else
73
#else
74
# define KA2PA(x)      ((x) - 0xffffffff80000000)
74
# define KA2PA(x)      ((x) - 0xffffffff80000000)
75
# define PA2KA(x)      ((x) + 0xffffffff80000000)
75
# define PA2KA(x)      ((x) + 0xffffffff80000000)
76
#endif
76
#endif
77
 
77
 
Line 83... Line 83...
83
#define PTL0_INDEX_ARCH(vaddr)  (((vaddr)>>39)&0x1ff)
83
#define PTL0_INDEX_ARCH(vaddr)  (((vaddr)>>39)&0x1ff)
84
#define PTL1_INDEX_ARCH(vaddr)  (((vaddr)>>30)&0x1ff)
84
#define PTL1_INDEX_ARCH(vaddr)  (((vaddr)>>30)&0x1ff)
85
#define PTL2_INDEX_ARCH(vaddr)  (((vaddr)>>21)&0x1ff)
85
#define PTL2_INDEX_ARCH(vaddr)  (((vaddr)>>21)&0x1ff)
86
#define PTL3_INDEX_ARCH(vaddr)  (((vaddr)>>12)&0x1ff)
86
#define PTL3_INDEX_ARCH(vaddr)  (((vaddr)>>12)&0x1ff)
87
 
87
 
88
#define GET_PTL1_ADDRESS_ARCH(ptl0, i)      ((pte_t *) ((((__u64) ((pte_t *)(ptl0))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl0))[(i)].addr_32_51)<<32 )))
88
#define GET_PTL1_ADDRESS_ARCH(ptl0, i)      ((pte_t *) ((((uint64_t) ((pte_t *)(ptl0))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl0))[(i)].addr_32_51)<<32 )))
89
#define GET_PTL2_ADDRESS_ARCH(ptl1, i)      ((pte_t *) ((((__u64) ((pte_t *)(ptl1))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl1))[(i)].addr_32_51)<<32 )))
89
#define GET_PTL2_ADDRESS_ARCH(ptl1, i)      ((pte_t *) ((((uint64_t) ((pte_t *)(ptl1))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl1))[(i)].addr_32_51)<<32 )))
90
#define GET_PTL3_ADDRESS_ARCH(ptl2, i)      ((pte_t *) ((((__u64) ((pte_t *)(ptl2))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl2))[(i)].addr_32_51)<<32 )))
90
#define GET_PTL3_ADDRESS_ARCH(ptl2, i)      ((pte_t *) ((((uint64_t) ((pte_t *)(ptl2))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl2))[(i)].addr_32_51)<<32 )))
91
#define GET_FRAME_ADDRESS_ARCH(ptl3, i)     ((__address *) ((((__u64) ((pte_t *)(ptl3))[(i)].addr_12_31)<<12) | (((__u64) ((pte_t *)(ptl3))[(i)].addr_32_51)<<32 )))
91
#define GET_FRAME_ADDRESS_ARCH(ptl3, i)     ((uintptr_t *) ((((uint64_t) ((pte_t *)(ptl3))[(i)].addr_12_31)<<12) | (((uint64_t) ((pte_t *)(ptl3))[(i)].addr_32_51)<<32 )))
92
 
92
 
93
#define SET_PTL0_ADDRESS_ARCH(ptl0)     (write_cr3((__address) (ptl0)))
93
#define SET_PTL0_ADDRESS_ARCH(ptl0)     (write_cr3((uintptr_t) (ptl0)))
94
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a)   set_pt_addr((pte_t *)(ptl0), (index_t)(i), a)
94
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a)   set_pt_addr((pte_t *)(ptl0), (index_t)(i), a)
95
#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)       set_pt_addr((pte_t *)(ptl1), (index_t)(i), a)
95
#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)       set_pt_addr((pte_t *)(ptl1), (index_t)(i), a)
96
#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)       set_pt_addr((pte_t *)(ptl2), (index_t)(i), a)
96
#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)       set_pt_addr((pte_t *)(ptl2), (index_t)(i), a)
97
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)  set_pt_addr((pte_t *)(ptl3), (index_t)(i), a)
97
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)  set_pt_addr((pte_t *)(ptl3), (index_t)(i), a)
98
 
98
 
Line 104... Line 104...
104
#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)     set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x))
104
#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)     set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x))
105
#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)         set_pt_flags((pte_t *)(ptl1), (index_t)(i), (x))
105
#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)         set_pt_flags((pte_t *)(ptl1), (index_t)(i), (x))
106
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)         set_pt_flags((pte_t *)(ptl2), (index_t)(i), (x))
106
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)         set_pt_flags((pte_t *)(ptl2), (index_t)(i), (x))
107
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)    set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x))
107
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)    set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x))
108
 
108
 
109
#define PTE_VALID_ARCH(p)           (*((__u64 *) (p)) != 0)
109
#define PTE_VALID_ARCH(p)           (*((uint64_t *) (p)) != 0)
110
#define PTE_PRESENT_ARCH(p)         ((p)->present != 0)
110
#define PTE_PRESENT_ARCH(p)         ((p)->present != 0)
111
#define PTE_GET_FRAME_ARCH(p)           ((((__address)(p)->addr_12_31)<<12) | ((__address)(p)->addr_32_51<<32))
111
#define PTE_GET_FRAME_ARCH(p)           ((((uintptr_t)(p)->addr_12_31)<<12) | ((uintptr_t)(p)->addr_32_51<<32))
112
#define PTE_WRITABLE_ARCH(p)            ((p)->writeable != 0)
112
#define PTE_WRITABLE_ARCH(p)            ((p)->writeable != 0)
113
#define PTE_EXECUTABLE_ARCH(p)          ((p)->no_execute == 0)
113
#define PTE_EXECUTABLE_ARCH(p)          ((p)->no_execute == 0)
114
 
114
 
115
#ifndef __ASM__
115
#ifndef __ASM__
116
 
116
 
Line 162... Line 162...
162
        (!p->no_execute)<<PAGE_EXEC_SHIFT |
162
        (!p->no_execute)<<PAGE_EXEC_SHIFT |
163
        p->global<<PAGE_GLOBAL_SHIFT
163
        p->global<<PAGE_GLOBAL_SHIFT
164
    );
164
    );
165
}
165
}
166
 
166
 
167
static inline void set_pt_addr(pte_t *pt, index_t i, __address a)
167
static inline void set_pt_addr(pte_t *pt, index_t i, uintptr_t a)
168
{
168
{
169
    pte_t *p = &pt[i];
169
    pte_t *p = &pt[i];
170
 
170
 
171
    p->addr_12_31 = (a >> 12) & 0xfffff;
171
    p->addr_12_31 = (a >> 12) & 0xfffff;
172
    p->addr_32_51 = a >> 32;
172
    p->addr_32_51 = a >> 32;
Line 195... Line 195...
195
 
195
 
196
#endif /* KERNEL */
196
#endif /* KERNEL */
197
 
197
 
198
#endif
198
#endif
199
 
199
 
200
 /** @}
200
/** @}
201
 */
201
 */
202
 
-