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",
.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);
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)",
.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)
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",
.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;
#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
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;
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",
.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);
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",
.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);
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
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,