diff options
Diffstat (limited to 'lib/untyped-retype.c')
-rw-r--r-- | lib/untyped-retype.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/untyped-retype.c b/lib/untyped-retype.c index 70fb4d2..526f19e 100644 --- a/lib/untyped-retype.c +++ b/lib/untyped-retype.c @@ -1,11 +1,43 @@ -#include <object.h> -#include <memory.h> +#include "object.h" +#include "memory.h" #include <stddef.h> -#include <error.h> +#include "error.h" +#include "string.h" int ko_untyped_retype_objdir(objdir_entry_t *target) { size_t *untyped = ko_entry_data(target); if(*untyped != 0x1000) return -KE_BADSIZE; + + objdir_t *objdir = (objdir_t*)untyped; + memset(objdir, 0, 0x1000); + + objdir->self = (objdir_entry_t) { + .type = KO_OBJECT_DIRECTORY, + .data = target->data + }; + *target = (objdir_entry_t) { + .type = KO_OBJECT_DIRECTORY, + .lock = 0, + .extra = 0, + .data = objdir->self.data + }; + return 0; +} + +int +ko_untyped_retype_message(objdir_entry_t *target, uintptr_t vptr) +{ + size_t *untyped = ko_entry_data(target); + if(*untyped != 0x1000) return -KE_BADSIZE; + + memset(untyped, 0, KO_MESSAGE_BYTES); + *target = (objdir_entry_t) { + .type = KO_OBJECT_DIRECTORY, + .lock = 0, + .extra = 0, + .data = target->data + }; + return 0; } |