From 7f350e7ee1c2c38e5ac0b6c22c17388f6c78f0b5 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 10 Sep 2025 13:28:28 -0400 Subject: refactor paging code. regression on loading init program --- lib/untyped-retype.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'lib/untyped-retype.c') 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 -#include +#include "object.h" +#include "memory.h" #include -#include +#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; } -- cgit v1.2.1