4 #define PAGE_SIZE 4096ul
6 #define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
8 #define LARGE_PAGE_SIZE (1024 * PAGE_SIZE)
11 #define PTE_PRESENT (1ull << 0)
12 #define PTE_PSE (1ull << 7)
13 #define PTE_WRITE (1ull << 1)
14 #define PTE_ADDR (0xffffffffff000ull)
18 void *vmalloc(unsigned long size
);
19 void vfree(void *mem
);
20 void *vmap(unsigned long long phys
, unsigned long size
);
22 void install_pte(unsigned long *cr3
,
26 unsigned long *pt_page
);
30 void install_large_page(unsigned long *cr3
,unsigned long phys
,
32 void install_page(unsigned long *cr3
, unsigned long phys
, void *virt
);
34 static inline unsigned long virt_to_phys(const void *virt
)
36 return (unsigned long)virt
;
39 static inline void *phys_to_virt(unsigned long phys
)
45 static inline void load_cr3(unsigned long cr3
)
47 asm ( "mov %0, %%cr3" : : "r"(cr3
) );
50 static inline unsigned long read_cr3()
54 asm volatile ( "mov %%cr3, %0" : "=r"(cr3
) );
58 static inline void load_cr0(unsigned long cr0
)
60 asm volatile ( "mov %0, %%cr0" : : "r"(cr0
) );
63 static inline unsigned long read_cr0()
67 asm volatile ( "mov %%cr0, %0" : "=r"(cr0
) );
72 static inline void load_cr4(unsigned long cr4
)
74 asm volatile ( "mov %0, %%cr4" : : "r"(cr4
) );
77 static inline unsigned long read_cr4()
81 asm volatile ( "mov %%cr4, %0" : "=r"(cr4
) );