]> xenbits.xensource.com Git - mini-os.git/commitdiff
mini-os: add function to map one frame
authorJuergen Gross <jgross@suse.com>
Thu, 4 Aug 2016 14:14:31 +0000 (16:14 +0200)
committerJuergen Gross <jgross@suse.com>
Thu, 11 Aug 2016 11:04:09 +0000 (13:04 +0200)
Add a function to map one physical frame to a specified virtual
address as read/write. This will be used later multiple times.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
include/arm/arch_mm.h
include/mm.h
mm.c

index 085d4e5bc4acea11aa18193938d90014a5f3d3f9..f4685d86c39faa82a786463c6a0add741af30ec8 100644 (file)
@@ -14,6 +14,8 @@ extern uint32_t physical_address_offset;      /* Add this to a virtual address to get
 
 #define L1_PAGETABLE_SHIFT      12
 
+#define L1_PROT          0
+
 #define to_phys(x)                 (((paddr_t)(x)+physical_address_offset) & 0xffffffff)
 #define to_virt(x)                 ((void *)(((x)-physical_address_offset) & 0xffffffff))
 
index 9244e26b9ad8853590ac9d4803805ebdd9d11cec..6add683d2e2208adef977303cb87b4f3f4ce1e8e 100644 (file)
@@ -72,6 +72,7 @@ int do_map_frames(unsigned long addr,
         const unsigned long *f, unsigned long n, unsigned long stride,
        unsigned long increment, domid_t id, int *err, unsigned long prot);
 int unmap_frames(unsigned long va, unsigned long num_frames);
+int map_frame_rw(unsigned long addr, unsigned long mfn);
 #ifdef HAVE_LIBC
 extern unsigned long heap, brk, heap_mapped, heap_end;
 #endif
diff --git a/mm.c b/mm.c
index c53b0caa7a72ff255145e69645465cc54106d130..707a3e038caee85cb178aade51af6e575d1eb562 100644 (file)
--- a/mm.c
+++ b/mm.c
@@ -319,6 +319,11 @@ int free_physical_pages(xen_pfn_t *mfns, int n)
     return HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 }
 
+int map_frame_rw(unsigned long addr, unsigned long mfn)
+{
+    return do_map_frames(addr, &mfn, 1, 1, 1, DOMID_SELF, NULL, L1_PROT);
+}
+
 #ifdef HAVE_LIBC
 void *sbrk(ptrdiff_t increment)
 {