memobj: adding missing implementation of unfill for memobj_numa
authorReto Achermann <reto.achermann@inf.ethz.ch>
Tue, 16 Jun 2015 09:18:18 +0000 (11:18 +0200)
committerReto Achermann <reto.achermann@inf.ethz.ch>
Tue, 16 Jun 2015 09:33:30 +0000 (11:33 +0200)
Signed-off-by: Reto Achermann <reto.achermann@inf.ethz.ch>

lib/barrelfish/vspace/memobj_numa.c

index ab752b7..2227afb 100644 (file)
@@ -215,7 +215,23 @@ static errval_t unfill(struct memobj *memobj,
                        struct capref *ret_frame,
                        genvaddr_t *ret_offset)
 {
-    USER_PANIC("NYI");
+    struct memobj_numa *mo_numa = (struct memobj_numa*) memobj;
+
+    /* we take a single capability per node using offset as the node ID */
+    if (offset >= mo_numa->node_count) {
+        return LIB_ERR_MEMOBJ_WRONG_OFFSET;
+    }
+
+    /* check if we already have a capability for that node */
+    if (capref_is_null((mo_numa->frames[offset]))) {
+        return LIB_ERR_MEMOBJ_UNFILL_TOO_HIGH_OFFSET;
+    }
+
+    if (ret_frame) {
+        *ret_frame = mo_numa->frames[offset];
+    }
+    mo_numa->frames[offset] = NULL_CAP;
+
     return SYS_ERR_OK;
 }