diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2025-08-19 15:04:04 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2025-08-19 15:04:04 -0400 |
commit | 858a52c06a4615bd58a6a906333f2ad707d41c0a (patch) | |
tree | 16870cd4d67da283567a72a74d28c04464da292a /lib/libjove/include/object-dir.h | |
parent | 65ba015d6c1f248d36ad01a653bc49637804b15b (diff) | |
download | jove-os-858a52c06a4615bd58a6a906333f2ad707d41c0a.tar.gz jove-os-858a52c06a4615bd58a6a906333f2ad707d41c0a.tar.bz2 jove-os-858a52c06a4615bd58a6a906333f2ad707d41c0a.zip |
usermode pager
Diffstat (limited to 'lib/libjove/include/object-dir.h')
-rw-r--r-- | lib/libjove/include/object-dir.h | 82 |
1 files changed, 81 insertions, 1 deletions
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 <kernel/object.h> #include <jove/object-typed.h> +#include <jove/error.h> -/**@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 |