/**
 * PROJECT:         ExectOS
 * COPYRIGHT:       See COPYING.md in the top level directory
 * FILE:            xtoskrnl/includes/mm/mmgr.hh
 * DESCRIPTION:     Memory Manager
 * DEVELOPERS:      Aiken Harris <harraiken91@gmail.com>
 */

#ifndef __XTOSKRNL_MM_MMGR_HH
#define __XTOSKRNL_MM_MMGR_HH

#include <xtos.hh>


/* Memory Manager */
namespace MM
{
    class Manager
    {
        private:
            STATIC MMMEMORY_LAYOUT MemoryLayout;
            STATIC PFN_NUMBER NumberOfSystemPtes;
            STATIC PPHYSICAL_MEMORY_DESCRIPTOR PhysicalMemoryBlock;

        public:
            STATIC XTAPI ULONG_PTR GetInstalledMemorySize(VOID);
            STATIC XTAPI PMMMEMORY_LAYOUT GetMemoryLayout(VOID);
            STATIC XTAPI PFN_NUMBER GetNumberOfSystemPtes(VOID);
            STATIC XTAPI PPHYSICAL_MEMORY_DESCRIPTOR GetPhysicalMemoryBlock(VOID);
            STATIC XTAPI VOID InitializeMemoryLayout(VOID);
            STATIC XTAPI VOID InitializeMemoryManager(VOID);
            STATIC XTAPI XTSTATUS MapKernelSharedData(VOID);
            STATIC XTAPI BOOLEAN VerifyMemoryTypeFree(IN LOADER_MEMORY_TYPE MemoryType);
            STATIC XTAPI BOOLEAN VerifyMemoryTypeInvisible(IN LOADER_MEMORY_TYPE MemoryType);

        private:
            STATIC XTAPI VOID ComputeBootImageSize(OUT PPFN_NUMBER BootImageSize);
            STATIC XTAPI VOID ComputeMaximumNonPagedPoolSize(OUT PPFN_NUMBER PoolSize);
            STATIC XTAPI VOID ComputeNonPagedPoolSize(OUT PPFN_NUMBER PoolSize);
            STATIC XTAPI VOID ComputePagedPoolSize(OUT PPFN_NUMBER PoolSize);
            STATIC XTAPI VOID ComputeSessionSpaceSize(OUT PPFN_NUMBER SpaceSize);
            STATIC XTAPI VOID ComputeSystemPteSize(OUT PPFN_NUMBER PteSize);
            STATIC XTAPI VOID DumpMemoryLayout(VOID);
    };
}

#endif /* __XTOSKRNL_MM_MMGR_HH */
