summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_object.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/vm/vm_object.c')
-rw-r--r--sys/vm/vm_object.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 3b3124c..10d58e7 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -222,6 +222,7 @@ _vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
object->size = size;
object->generation = 1;
object->ref_count = 1;
+ object->memattr = VM_MEMATTR_DEFAULT;
object->flags = 0;
object->uip = NULL;
object->charge = 0;
@@ -290,6 +291,36 @@ vm_object_clear_flag(vm_object_t object, u_short bits)
object->flags &= ~bits;
}
+/*
+ * Sets the default memory attribute for the specified object. Pages
+ * that are allocated to this object are by default assigned this memory
+ * attribute.
+ *
+ * Presently, this function must be called before any pages are allocated
+ * to the object. In the future, this requirement may be relaxed for
+ * "default" and "swap" objects.
+ */
+int
+vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr)
+{
+
+ VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
+ switch (object->type) {
+ case OBJT_DEFAULT:
+ case OBJT_DEVICE:
+ case OBJT_PHYS:
+ case OBJT_SWAP:
+ case OBJT_VNODE:
+ if (!TAILQ_EMPTY(&object->memq))
+ return (KERN_FAILURE);
+ break;
+ case OBJT_DEAD:
+ return (KERN_INVALID_ARGUMENT);
+ }
+ object->memattr = memattr;
+ return (KERN_SUCCESS);
+}
+
void
vm_object_pip_add(vm_object_t object, short i)
{
OpenPOWER on IntegriCloud