Squash commits for public release
This commit is contained in:
37
kernel/include/platform/riscv64/vmm/consts.h
Normal file
37
kernel/include/platform/riscv64/vmm/consts.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _KERNEL_PLATFORM_RISCV64_VMM_CONSTS_H
|
||||
#define _KERNEL_PLATFORM_RISCV64_VMM_CONSTS_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
|
||||
static inline int vm_page_size()
|
||||
{
|
||||
return 0x1000;
|
||||
}
|
||||
|
||||
static inline int vm_page_mask()
|
||||
{
|
||||
return 0xfff;
|
||||
}
|
||||
|
||||
#define VMM_LV0_ENTITY_COUNT (512)
|
||||
#define VMM_LV1_ENTITY_COUNT (512)
|
||||
#define VMM_LV2_ENTITY_COUNT (512)
|
||||
#define VMM_LV3_ENTITY_COUNT (512)
|
||||
#define VMM_PAGE_SIZE (vm_page_size())
|
||||
|
||||
#define PAGE_START(vaddr) ((vaddr & (~(uintptr_t)vm_page_mask())))
|
||||
#define FRAME(addr) (addr / VMM_PAGE_SIZE)
|
||||
|
||||
#define PTABLE_LV_TOP (3)
|
||||
#define PTABLE_LV0_VADDR_OFFSET (12)
|
||||
#define PTABLE_LV1_VADDR_OFFSET (21)
|
||||
#define PTABLE_LV2_VADDR_OFFSET (30)
|
||||
#define PTABLE_LV3_VADDR_OFFSET (39)
|
||||
|
||||
#define PTABLE_TOP_KERNEL_OFFSET (VMM_LV3_ENTITY_COUNT / 2)
|
||||
|
||||
#define USER_HIGH 0x7fffffffffff
|
||||
#define KERNEL_BASE 0xffff800000000000
|
||||
#define KERNEL_PADDR_BASE 0xffffffff00000000 // TODO(x64): up to 4gbs are supported.
|
||||
|
||||
#endif // _KERNEL_PLATFORM_RISCV64_VMM_CONSTS_H
|
||||
30
kernel/include/platform/riscv64/vmm/mmu.h
Normal file
30
kernel/include/platform/riscv64/vmm/mmu.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _KERNEL_PLATFORM_RISCV64_VMM_MMU_H
|
||||
#define _KERNEL_PLATFORM_RISCV64_VMM_MMU_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
#include <mem/bits/mmu.h>
|
||||
|
||||
// riscv64 uses one table to manage virtual space.
|
||||
#undef DOUBLE_TABLE_PAGING
|
||||
|
||||
typedef uint64_t ptable_entity_t;
|
||||
typedef uint64_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_RISCV64_VMM_MMU_H
|
||||
Reference in New Issue
Block a user