From 59a374b0eed4313d1a67e2cdb673a295e79a6494 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 19 Oct 2021 15:56:26 +0300 Subject: Initial virtual memory mapping functions --- include/apos/mem.h | 7 +------ include/apos/vmem.h | 13 ++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/apos/mem.h b/include/apos/mem.h index 630fcd9..7c5a2dc 100644 --- a/include/apos/mem.h +++ b/include/apos/mem.h @@ -4,12 +4,6 @@ #include #include -enum mm_mode_t { - Sv48, - Sv39, - Sv32, -}; - #define MM_OINFO_WIDTH (sizeof(mm_info_t) * 8) #define pnum_to_index(pnum, order) (((pnum) >> __o_offset(order)) & (__o_width(order) - 1)) @@ -29,6 +23,7 @@ enum mm_mode_t { #define __o_offset(order) (__mm_shifts[order]) #define __o_width(order) (__mm_widths[order]) +#define __o_size(order) (__mm_sizes[order]) #define __o_elems(order) (__mm_widths[order] / MM_OINFO_WIDTH) #define __o_container(idx) ((idx) / MM_OINFO_WIDTH) diff --git a/include/apos/vmem.h b/include/apos/vmem.h index 589e814..d2dcedc 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -1,6 +1,8 @@ #ifndef APOS_VMEM_H #define APOS_VMEM_H +#include + /* arch-specific data */ #include @@ -14,19 +16,16 @@ * (un)map_vsize: map unknown physical region to unknown virtual region */ +/* defined by arch */ void map_vmem(struct vm_branch_t *branch, pm_t paddr, vm_t vaddr, uint8_t flags, enum mm_order_t order); void unmap_vmem(struct vm_branch_t *branch, vm_t vaddr, enum mm_order_t order); -#define map_kvregion(b, pb, pt) map_vregion(b, pb, pt, VMEM_BASE, VMEM_TOP); -#define map_uvregion(b, pb, pt) map_vregion(b, pb, pt, UMEM_BASE, UMEM_TOP); - -vm_t map_vregion(struct vm_branch_t *branch, pm_t base, pm_t top, vm_t start, vm_t end); -void unmap_vregion(struct vm_branch_t *branch, pm_t base, pm_t top); -vm_t map_vsize(struct vm_branch_t *branch, size_t size); -void unmap_vsize(struct vm_branch_t *branch, size_t size); +vm_t map_vregion(struct vm_branch_t *branch, pm_t base, vm_t start, size_t size, + uint8_t flags); +void unmap_vregion(struct vm_branch_t *branch, vm_t start); #endif /* APOS_VMEM_H */ -- cgit v1.3