aboutsummaryrefslogtreecommitdiff
path: root/kernel/vm/anon.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/vm/anon.c')
-rw-r--r--kernel/vm/anon.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/kernel/vm/anon.c b/kernel/vm/anon.c
index 4a92fc9..a433395 100644
--- a/kernel/vm/anon.c
+++ b/kernel/vm/anon.c
@@ -27,7 +27,8 @@ static mobj_ops_t anon_mobj_ops = {.get_pframe = NULL,
*/
void anon_init()
{
- NOT_YET_IMPLEMENTED("VM: anon_init");
+ // NOT_YET_IMPLEMENTED("VM: anon_init");
+ anon_allocator = slab_allocator_create("anon", sizeof(mobj_t));
}
/*
@@ -36,8 +37,17 @@ void anon_init()
*/
mobj_t *anon_create()
{
- NOT_YET_IMPLEMENTED("VM: anon_create");
- return NULL;
+ // NOT_YET_IMPLEMENTED("VM: anon_create");
+ // make a new mobj
+ mobj_t *mobj = (mobj_t *)slab_obj_alloc(anon_allocator);
+ // initialize the mobj
+ if (mobj)
+ {
+ mobj_init(mobj, MOBJ_ANON, &anon_mobj_ops);
+ mobj_lock(mobj);
+ return mobj;
+ }
+ panic("MINE anon_create: slab_obj_alloc failed");
}
/*
@@ -46,7 +56,15 @@ mobj_t *anon_create()
*/
static long anon_fill_pframe(mobj_t *o, pframe_t *pf)
{
- NOT_YET_IMPLEMENTED("VM: anon_fill_pframe");
+ // NOT_YET_IMPLEMENTED("VM: anon_fill_pframe");
+
+ // set the pframe's mobj to the given mobj
+ // pf->pf_addr = o;
+ // // set the pframe's flags to dirty
+ // pf->pf_dirty = 1;
+
+ memset(pf->pf_addr, 0, PAGE_SIZE);
+
return 0;
}
@@ -61,5 +79,10 @@ static long anon_flush_pframe(mobj_t *o, pframe_t *pf) { return 0; }
*/
static void anon_destructor(mobj_t *o)
{
- NOT_YET_IMPLEMENTED("VM: anon_destructor");
+ // NOT_YET_IMPLEMENTED("VM: anon_destructor");
+ // call the default destructor
+ mobj_default_destructor(o);
+
+ // free the mobj
+ slab_obj_free(anon_allocator, o);
}