From 858a52c06a4615bd58a6a906333f2ad707d41c0a Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Tue, 19 Aug 2025 15:04:04 -0400 Subject: usermode pager --- lib/libjove/include/object-dir.h | 82 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'lib/libjove/include/object-dir.h') diff --git a/lib/libjove/include/object-dir.h b/lib/libjove/include/object-dir.h index f258089..e4d9aaf 100644 --- a/lib/libjove/include/object-dir.h +++ b/lib/libjove/include/object-dir.h @@ -6,12 +6,92 @@ #include #include +#include -/**@STRUCT Represents a kobjdir.*/ +/**@STRUCT Represents cached information about a KO_OBJDIR. + * To update the information this struct contains, call jove_objdir_sync.*/ typedef struct _KernelObjectDirectory { KernelObjectTyped typed; + + uint8_t lastmemb; + uint8_t firstfree; + KernelObjectTyped *children[256]; } KernelObjectDirectory; extern KernelObjectDirectory __rootdir; +KernelObjectDirectory *jove_object_as_objdir(KernelObjectTyped *typed); + +/**@FUNC Populates a objdir struct for an empty directory at dir:memb. + * @PARAM dir address to populate. + * @PARAM parent directory to make dir child of. + * @PARAM memb index to place new objdir.*/ +void _jove_alloc_objdir_inplace( + KernelObjectDirectory *dir, + KernelObjectDirectory *parent, + uint8_t memb); + +/**@FUNC Allocates a block of memory to represent a kernel objdir. + * @PARAM parent directory to place new member into. + * @PARAM memb index to place new objdir. + * @RETURN pointer to new objdir. + * Possible failures: + * EJOVE_NOALLOC: libjove is missing an allocator. + * EJOVE_FULL: space at memb is already taken.*/ +KernelObjectDirectory *_jove_alloc_objdir( + KernelObjectDirectory *parent, + uint8_t memb); + +/**@FUNC Updates the dir struct with information obtained through the kernel. + * @PARAM dir directory to sync. + * @RETURN error code. 0 on success*/ +JoveError jove_objdir_sync(KernelObjectDirectory *dir); + +/**@FUNC Updates the dir struct at the given index with information obtained + * through the kernel. + * @PARAM dir directory to sync. + * @PARAM i index to sync. + * @PARAM memb pointer to place typed object in. Nullable + * @RETURN error code. 0 on success.*/ +JoveError jove_objdir_sync_at(KernelObjectDirectory *dir, uint8_t i, KernelObjectTyped** memb); + +/**@FUNC Returns the number of populated entries this directory holds. + * @PARAM dir directory to check + * @RETURN number of entries. negative return values indicate an error.*/ +int jove_objdir_nmemb(KernelObjectDirectory *dir); + +/**@FUNC Gets the highest populated index in a given directory. + * @PARAM dir directory to check. + * @RETURN last populated entry. negative return values indicate an error.*/ +int jove_objdir_lastmemb(KernelObjectDirectory *dir); + +/**@FUNC Gets the kernel object at a given index. + * This function only checks the cached result. If the directory has changed + * without updating the cache, jove_objdir_sync MUST be called first. + * + * @PARAM dir directory to check in. + * @PARAM index index to check. + * @RETURN the object at the given index. NULL if the spot is empty.*/ +KernelObjectTyped *jove_objdir_get(KernelObjectDirectory *dir, uint8_t index); + +/**@FUNC Moves a kernel object in this directory to a different place/directory. + * @PARAM dir directory holding the object. + * @PARAM memb member index of the object. + * @PARAM dest_dir destination directory. + * @PARAM dest_memb destination member.*/ +JoveError jove_objdir_move( + KernelObjectDirectory *dir, + uint8_t memb, + KernelObjectDirectory *dest_dir, + uint8_t dest_memb); + +JoveError jove_object_move( + KernelObjectTyped *typed, + KernelObjectDirectory *dest_dir, + uint8_t dest_memb); + +JoveError jove_object_move_inplace( + KernelObjectTyped *typed, + KernelObjectTyped *dest); + #endif -- cgit v1.2.1