Squash commits for public release
This commit is contained in:
29
kernel/include/platform/x86/i386/vmm/consts.h
Normal file
29
kernel/include/platform/x86/i386/vmm/consts.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef _KERNEL_PLATFORM_X86_I386_VMM_CONSTS_H
|
||||
#define _KERNEL_PLATFORM_X86_I386_VMM_CONSTS_H
|
||||
|
||||
static inline int vm_page_mask()
|
||||
{
|
||||
return 0xfff;
|
||||
}
|
||||
|
||||
#define VMM_LV0_ENTITY_COUNT (1024)
|
||||
#define VMM_LV1_ENTITY_COUNT (1024)
|
||||
#define VMM_PAGE_SIZE (4096)
|
||||
|
||||
#define VMM_OFFSET_IN_DIRECTORY(a) (((a) >> 22) & 0x3ff)
|
||||
#define VMM_OFFSET_IN_TABLE(a) (((a) >> 12) & 0x3ff)
|
||||
#define VMM_OFFSET_IN_PAGE(a) ((a)&0xfff)
|
||||
#define TABLE_START(vaddr) ((vaddr >> 22) << 22)
|
||||
#define PAGE_START(vaddr) ((vaddr >> 12) << 12)
|
||||
#define FRAME(addr) (addr / VMM_PAGE_SIZE)
|
||||
|
||||
#define PTABLE_TOP_KERNEL_OFFSET 768
|
||||
|
||||
#define PTABLE_LV_TOP (1)
|
||||
#define PTABLE_LV0_VADDR_OFFSET (12)
|
||||
#define PTABLE_LV1_VADDR_OFFSET (22)
|
||||
|
||||
#define USER_HIGH 0xbfffffff
|
||||
#define KERNEL_BASE 0xc0000000
|
||||
|
||||
#endif //_KERNEL_PLATFORM_X86_I386_VMM_CONSTS_H
|
||||
29
kernel/include/platform/x86/i386/vmm/mmu.h
Normal file
29
kernel/include/platform/x86/i386/vmm/mmu.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef _KERNEL_PLATFORM_X86_I386_VMM_MMU_H
|
||||
#define _KERNEL_PLATFORM_X86_I386_VMM_MMU_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
#include <mem/bits/mmu.h>
|
||||
#include <platform/x86/i386/vmm/pde.h>
|
||||
#include <platform/x86/i386/vmm/pte.h>
|
||||
|
||||
typedef uint32_t ptable_entity_t;
|
||||
typedef uint32_t arch_pf_info_t;
|
||||
|
||||
ptable_entity_t vm_mmu_to_arch_flags(mmu_flags_t mmu_flags, ptable_lv_t lv);
|
||||
mmu_flags_t vm_arch_to_mmu_flags(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
mmu_pf_info_flags_t vm_arch_parse_pf_info(arch_pf_info_t info);
|
||||
|
||||
void vm_ptable_entity_set_default_flags(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
void vm_ptable_entity_allocated(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
void vm_ptable_entity_invalidate(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
|
||||
void vm_ptable_entity_set_mmu_flags(ptable_entity_t* entity, ptable_lv_t lv, mmu_flags_t mmu_flags);
|
||||
void vm_ptable_entity_rm_mmu_flags(ptable_entity_t* entity, ptable_lv_t lv, mmu_flags_t mmu_flags);
|
||||
void vm_ptable_entity_set_frame(ptable_entity_t* entity, ptable_lv_t lv, uintptr_t frame);
|
||||
uintptr_t vm_ptable_entity_get_frame(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
|
||||
ptable_state_t vm_ptable_entity_state(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
bool vm_ptable_entity_is_present(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
bool vm_ptable_entity_is_only_allocated(ptable_entity_t* entity, ptable_lv_t lv);
|
||||
|
||||
#endif // _KERNEL_PLATFORM_X86_I386_VMM_MMU_H
|
||||
25
kernel/include/platform/x86/i386/vmm/pde.h
Normal file
25
kernel/include/platform/x86/i386/vmm/pde.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _KERNEL_PLATFORM_X86_I386_VMM_PDE_H
|
||||
#define _KERNEL_PLATFORM_X86_I386_VMM_PDE_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
|
||||
#define table_desc_t uint32_t
|
||||
#define pde_t uint32_t
|
||||
|
||||
#define TABLE_DESC_FRAME_OFFSET 12
|
||||
|
||||
enum TABLE_DESC_PAGE_FLAGS {
|
||||
TABLE_DESC_PRESENT = 0x1,
|
||||
TABLE_DESC_WRITABLE = 0x2,
|
||||
TABLE_DESC_USER = 0x4,
|
||||
TABLE_DESC_PWT = 0x8,
|
||||
TABLE_DESC_PCD = 0x10,
|
||||
TABLE_DESC_ACCESSED = 0x20,
|
||||
TABLE_DESC_DIRTY = 0x40,
|
||||
TABLE_DESC_4MB = 0x80,
|
||||
TABLE_DESC_CPU_GLOBAL = 0x100,
|
||||
TABLE_DESC_LV4_GLOBAL = 0x200,
|
||||
TABLE_DESC_COPY_ON_WRITE = 0x400,
|
||||
};
|
||||
|
||||
#endif //_KERNEL_PLATFORM_X86_I386_VMM_PDE_H
|
||||
23
kernel/include/platform/x86/i386/vmm/pte.h
Normal file
23
kernel/include/platform/x86/i386/vmm/pte.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _KERNEL_PLATFORM_X86_I386_VMM_PTE_H
|
||||
#define _KERNEL_PLATFORM_X86_I386_VMM_PTE_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
#include <mem/bits/mmu.h>
|
||||
|
||||
#define PAGE_DESC_FRAME_OFFSET 12
|
||||
|
||||
enum PAGE_DESC_PAGE_FLAGS {
|
||||
PAGE_DESC_PRESENT = 0x1,
|
||||
PAGE_DESC_WRITABLE = 0x2,
|
||||
PAGE_DESC_USER = 0x4,
|
||||
PAGE_DESC_WRITETHOUGH = 0x8,
|
||||
PAGE_DESC_NOT_CACHEABLE = 0x10,
|
||||
PAGE_DESC_ACCESSED = 0x20,
|
||||
PAGE_DESC_DIRTY = 0x40,
|
||||
PAGE_DESC_PAT = 0x80,
|
||||
PAGE_DESC_CPU_GLOBAL = 0x100,
|
||||
PAGE_DESC_LV4_GLOBAL = 0x200,
|
||||
PAGE_DESC_COPY_ON_WRITE = 0x400,
|
||||
};
|
||||
|
||||
#endif //_KERNEL_PLATFORM_X86_I386_VMM_PTE_H
|
||||
Reference in New Issue
Block a user