#ifndef _LIBJOVE_OBJECT_UNTYPED_H #define _LIBJOVE_OBJECT_UNTYPED_H 1 #include #include /**@STRUCT Represents a KO_MEMOY_UNTYPED*/ typedef struct _KernelObjectUntyped { KernelObjectTyped typed; size_t bytes; intmax_t alignment; KernelObjectTyped *children_head; KernelObjectTyped *sibling; } KernelObjectUntyped; extern KernelObjectDirectory __jove_untyped_directory; /**@FUNC INTERNAL FUNCTION DO NOT USE. * Initializes a block of memory as an untyped object. * @PARAM untyped pointer to new block of memory. * @PARAM parent directory this new object is a member of. * @PARAM membi index to place this new object.*/ void _jove_alloc_untyped_inplace(KernelObjectUntyped *untyped, struct _KernelObjectDirectory *parent, uint8_t membi); /**@FUNC INTERNAL FUNCTION DO NOT USE. * Allocates a block of memory representing an untyped object into the heap. * @PARAM parent directory this new object is a member of. * @PARAM membi index to place this new object. * @RETURN pointer to allocated object. NULL on failure. * Possible failures: * EJOVE_NOALLOC: libjove does not have an allocator set yet. * EJOVE_FULL: destination is already taken.*/ KernelObjectUntyped *_jove_alloc_untyped(struct _KernelObjectDirectory *parent, uint8_t membi); /**@FUNC Changes pointer type of typed object to untyped if correct. * @PARAM typed pointer to convert. * @RETURN pointer as KernelObjectUntyped*, NULL on failure. * Possible failures: * EJOVE_BADOBJ: passed object is not an untyped.*/ KernelObjectUntyped *jove_object_as_untyped(KernelObjectTyped *typed); /**@FUNC Gets the number of bytes a given untyped block represents. * @PARAM untyped block of untyped memory. * @RETURN number of bytes. negative on failure. * Possible failures: * EJOVE_BADOBJ: passed object does not exist / is not an untyped. */ int jove_untyped_size(KernelObjectUntyped *untyped); /**@FUNC Gets the byte alignment of a given untyped block up to a page. * @PARAM untyped block of untyped memory. * @RETURN alignment in bytes. negative on failure.*/ int jove_untyped_alignment(KernelObjectUntyped *untyped); /**@FUNC Splits a given untyped block of memory into a block with the given size * and the remainder. New untyped object is stored in dest at destmemb. * @PARAM untyped block of untyped memory to split. * @PARAM bytes number of bytes the new block should have. * Minimum sizeof(size_t) * @PARAM dest directory to store the new block. * @PARAM destmemb index in dest to store new block. * @RETURN Newly created block of memory. NULL on failure. * Possible failures: * EJOVE_BADSIZE: bytes < sizeof(size_t) * EJOVE_BADOBJ: dest or untyped are incorrect types / do not exist.*/ KernelObjectUntyped *jove_untyped_split( KernelObjectUntyped *untyped, size_t bytes, KernelObjectDirectory *dest, uint8_t destmemb); JoveError jove_untyped_split_inplace( KernelObjectUntyped *untyped, size_t bytes, KernelObjectUntyped *dest); #endif