#pragma once #include "common/common_types.h" #include "game/kernel/common/Ptr.h" /*! * A kheap has a top/bottom linear allocator */ struct kheapinfo { Ptr base; //! beginning of heap Ptr top; //! current location of bottom of top allocations Ptr current; //! current location of top of bottom allocations Ptr top_base; //! end of heap }; // Kernel heaps extern Ptr kglobalheap; extern Ptr kdebugheap; extern bool kheaplogging; // flags for kmalloc/ksmalloc constexpr u32 KMALLOC_TOP = 0x2000; //! Flag to allocate temporary memory from heap top constexpr u32 KMALLOC_MEMSET = 0x1000; //! Flag to clear memory constexpr u32 KMALLOC_ALIGN_256 = 0x100; constexpr u32 KMALLOC_ALIGN_64 = 0x40; constexpr u32 KMALLOC_ALIGN_16 = 0x10; void kmalloc_init_globals_common(); Ptr ksmalloc(Ptr heap, s32 size, u32 flags, char const* name); Ptr kheapstatus(Ptr heap); Ptr kinitheap(Ptr heap, Ptr mem, s32 size); u32 kheapused(Ptr heap); Ptr kmalloc(Ptr heap, s32 size, u32 flags, char const* name); void kfree(Ptr a);