From: Kees Jongenburger Date: Wed, 25 Sep 2013 08:41:26 +0000 (+0200) Subject: arm:vm allow per memory type flags. X-Git-Tag: v3.3.0~773 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/howto.html?a=commitdiff_plain;h=73ed75a45436f1d4f1f2fc12f6a89b2432351537;p=minix.git arm:vm allow per memory type flags. Change-Id: Id5a5bd479bdfbbc3fb52a85c29e1d7712a1171a7 --- diff --git a/servers/vm/mem_anon.c b/servers/vm/mem_anon.c index 5158f882d..68a7813e9 100644 --- a/servers/vm/mem_anon.c +++ b/servers/vm/mem_anon.c @@ -29,6 +29,7 @@ static int anon_writable(struct phys_region *pr); static int anon_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l); static u32_t anon_regionid(struct vir_region *region); static int anon_refcount(struct vir_region *vr); +static int anon_pt_flags(struct vir_region *vr); struct mem_type mem_type_anon = { .name = "anonymous memory", @@ -40,9 +41,18 @@ struct mem_type mem_type_anon = { .ev_split = anon_split, .regionid = anon_regionid, .writable = anon_writable, - .refcount = anon_refcount + .refcount = anon_refcount, + .pt_flags = anon_pt_flags, }; +static int anon_pt_flags(struct vir_region *vr){ +#if defined(__arm__) + return ARM_VM_PTE_CACHED; +#else + return 0; +#endif +} + static int anon_unreference(struct phys_region *pr) { assert(pr->ph->refcount == 0); diff --git a/servers/vm/mem_anon_contig.c b/servers/vm/mem_anon_contig.c index ee6e8ea1a..4b09ec52f 100644 --- a/servers/vm/mem_anon_contig.c +++ b/servers/vm/mem_anon_contig.c @@ -17,6 +17,7 @@ static int anon_contig_sanitycheck(struct phys_region *pr, char *file, int line) static int anon_contig_writable(struct phys_region *pr); static int anon_contig_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l); static int anon_contig_new(struct vir_region *vr); +static int anon_contig_pt_flags(struct vir_region *vr); struct mem_type mem_type_anon_contig = { .name = "anonymous memory (physically contiguous)", @@ -26,9 +27,18 @@ struct mem_type mem_type_anon_contig = { .ev_pagefault = anon_contig_pagefault, .ev_resize = anon_contig_resize, .ev_sanitycheck = anon_contig_sanitycheck, - .writable = anon_contig_writable + .writable = anon_contig_writable, + .pt_flags = anon_contig_pt_flags, }; +static int anon_contig_pt_flags(struct vir_region *vr){ +#if defined(__arm__) + return ARM_VM_PTE_DEVICE; +#else + return 0; +#endif +} + static int anon_contig_pagefault(struct vmproc *vmp, struct vir_region *region, struct phys_region *ph, int write, vfs_callback_t cb, void *state, int len, int *io) diff --git a/servers/vm/mem_cache.c b/servers/vm/mem_cache.c index 646008eb0..674efe4c7 100644 --- a/servers/vm/mem_cache.c +++ b/servers/vm/mem_cache.c @@ -31,6 +31,7 @@ static int cache_resize(struct vmproc *vmp, struct vir_region *vr, vir_bytes l); static int cache_pagefault(struct vmproc *vmp, struct vir_region *region, struct phys_region *ph, int write, vfs_callback_t cb, void *state, int len, int *io); +static int cache_pt_flags(struct vir_region *vr); struct mem_type mem_type_cache = { .name = "cache memory", @@ -40,8 +41,18 @@ struct mem_type mem_type_cache = { .ev_sanitycheck = cache_sanitycheck, .ev_pagefault = cache_pagefault, .writable = cache_writable, + .pt_flags = cache_pt_flags, }; +static int cache_pt_flags(struct vir_region *vr){ +#if defined(__arm__) + return ARM_VM_PTE_CACHED; +#else + return 0; +#endif +} + + static int cache_reference(struct phys_region *pr, struct phys_region *pr2) { return OK; diff --git a/servers/vm/mem_directphys.c b/servers/vm/mem_directphys.c index 542765761..ea4ceb87b 100644 --- a/servers/vm/mem_directphys.c +++ b/servers/vm/mem_directphys.c @@ -9,6 +9,8 @@ #include "vm.h" #include "proto.h" +#include "region.h" +#include "glo.h" /* These functions are static so as to not pollute the * global namespace, and are accessed through their function @@ -21,15 +23,25 @@ static int phys_pagefault(struct vmproc *vmp, struct vir_region *region, struct phys_region *ph, int write, vfs_callback_t cb, void *state, int len, int *io); static int phys_copy(struct vir_region *vr, struct vir_region *newvr); +static int phys_pt_flags(struct vir_region *vr); struct mem_type mem_type_directphys = { .name = "physical memory mapping", .ev_copy = phys_copy, .ev_unreference = phys_unreference, .writable = phys_writable, - .ev_pagefault = phys_pagefault + .ev_pagefault = phys_pagefault, + .pt_flags = phys_pt_flags }; +static int phys_pt_flags(struct vir_region *vr){ +#if defined(__arm__) + return ARM_VM_PTE_DEVICE; +#else + return 0; +#endif +} + static int phys_unreference(struct phys_region *pr) { return OK; diff --git a/servers/vm/mem_file.c b/servers/vm/mem_file.c index 9fc51140d..023e0f968 100644 --- a/servers/vm/mem_file.c +++ b/servers/vm/mem_file.c @@ -25,6 +25,7 @@ static int mappedfile_writable(struct phys_region *pr); static int mappedfile_copy(struct vir_region *vr, struct vir_region *newvr); static int mappedfile_lowshrink(struct vir_region *vr, vir_bytes len); static void mappedfile_delete(struct vir_region *region); +static int mappedfile_pt_flags(struct vir_region *vr); struct mem_type mem_type_mappedfile = { .name = "file-mapped memory", @@ -36,8 +37,17 @@ struct mem_type mem_type_mappedfile = { .ev_split = mappedfile_split, .ev_lowshrink = mappedfile_lowshrink, .ev_delete = mappedfile_delete, + .pt_flags = mappedfile_pt_flags, }; +static int mappedfile_pt_flags(struct vir_region *vr){ +#if defined(__arm__) + return ARM_VM_PTE_CACHED; +#else + return 0; +#endif +} + static int mappedfile_unreference(struct phys_region *pr) { assert(pr->ph->refcount == 0); diff --git a/servers/vm/mem_shared.c b/servers/vm/mem_shared.c index 7a0f95fc1..19239b09f 100644 --- a/servers/vm/mem_shared.c +++ b/servers/vm/mem_shared.c @@ -23,6 +23,7 @@ static void shared_delete(struct vir_region *region); static u32_t shared_regionid(struct vir_region *region); static int shared_copy(struct vir_region *vr, struct vir_region *newvr); static int shared_refcount(struct vir_region *vr); +static int shared_pt_flags(struct vir_region *vr); struct mem_type mem_type_shared = { .name = "shared memory", @@ -33,9 +34,18 @@ struct mem_type mem_type_shared = { .ev_delete = shared_delete, .regionid = shared_regionid, .refcount = shared_refcount, - .writable = shared_writable + .writable = shared_writable, + .pt_flags = shared_pt_flags, }; +static int shared_pt_flags(struct vir_region *vr){ +#if defined(__arm__) + return ARM_VM_PTE_CACHED; +#else + return 0; +#endif +} + static int shared_unreference(struct phys_region *pr) { return mem_type_anon.ev_unreference(pr); diff --git a/servers/vm/memtype.h b/servers/vm/memtype.h index 3574dd363..a8c14dce9 100644 --- a/servers/vm/memtype.h +++ b/servers/vm/memtype.h @@ -27,6 +27,7 @@ typedef struct mem_type { int (*ev_lowshrink)(struct vir_region *vr, vir_bytes len); u32_t (*regionid)(struct vir_region *vr); int (*refcount)(struct vir_region *vr); + int (*pt_flags)(struct vir_region *vr); /* page table flags */ } mem_type_t; #endif diff --git a/servers/vm/region.c b/servers/vm/region.c index 7928d2538..9728bdd1c 100644 --- a/servers/vm/region.c +++ b/servers/vm/region.c @@ -273,13 +273,9 @@ int map_ph_writept(struct vmproc *vmp, struct vir_region *vr, else flags |= PTF_READ; -#if defined(__arm__) - if (pb->phys >= 0x80000000 && pb->phys < (0xc0000000 - VM_PAGE_SIZE)) { - // LSC Do this only for actual RAM - // KEJO:fishy will need to look into this - flags |= ARM_VM_PTE_DEVICE; - } -#endif + + if(vr->def_memtype->pt_flags) + flags |= vr->def_memtype->pt_flags(vr); if(pt_writemap(vmp, &vmp->vm_pt, vr->vaddr + pr->offset, pb->phys, VM_PAGE_SIZE, flags,