diff --git a/sdk/xtdk/mmtypes.h b/sdk/xtdk/mmtypes.h index 05ce4ee..3f8f799 100644 --- a/sdk/xtdk/mmtypes.h +++ b/sdk/xtdk/mmtypes.h @@ -55,6 +55,9 @@ /* Protection field shift */ #define MM_PROTECT_FIELD_SHIFT 5 +/* Process Quota Adjustment Thresholds */ +#define MMNONPAGED_QUOTA_INCREASE (64*1024) +#define MMPAGED_QUOTA_INCREASE (512*1024) /* C/C++ specific code */ #ifndef __XTOS_ASSEMBLER__ diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 8e3306c..0bc61f8 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -81,6 +81,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/mm/pfn.cc ${XTOSKRNL_SOURCE_DIR}/mm/pool.cc ${XTOSKRNL_SOURCE_DIR}/mm/pte.cc + ${XTOSKRNL_SOURCE_DIR}/mm/quota.cc ${XTOSKRNL_SOURCE_DIR}/po/idle.cc ${XTOSKRNL_SOURCE_DIR}/ps/process.cc ${XTOSKRNL_SOURCE_DIR}/ps/thread.cc diff --git a/xtoskrnl/includes/mm.hh b/xtoskrnl/includes/mm.hh index 1e3e841..5051c68 100644 --- a/xtoskrnl/includes/mm.hh +++ b/xtoskrnl/includes/mm.hh @@ -24,5 +24,6 @@ #include #include #include +#include #endif /* __XTOSKRNL_MM_HH */ diff --git a/xtoskrnl/includes/mm/quota.hh b/xtoskrnl/includes/mm/quota.hh new file mode 100644 index 0000000..8579833 --- /dev/null +++ b/xtoskrnl/includes/mm/quota.hh @@ -0,0 +1,33 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/includes/mm/quota.hh + * DESCRIPTION: Memory Manager Quota support + * DEVELOPERS: Aiken Harris + */ + +#ifndef __XTOSKRNL_MM_QUOTA_HH +#define __XTOSKRNL_MM_QUOTA_HH + +#include + + +/* Memory Manager */ +namespace MM +{ + class Quota + { + private: + STATIC SIZE_T PagedPoolQuota; + STATIC SIZE_T NonPagedPoolQuota; + + public: + STATIC XTAPI BOOLEAN RaisePoolQuota(IN MMPOOL_TYPE PoolType, + IN SIZE_T CurrentQuotaLimit, + OUT PSIZE_T NewQuotaLimit); + STATIC XTAPI VOID ReturnPoolQuota(IN MMPOOL_TYPE PoolType, + IN SIZE_T ReturnedQuota); + }; +} + +#endif /* __XTOSKRNL_MM_QUOTA_HH */ diff --git a/xtoskrnl/mm/quota.cc b/xtoskrnl/mm/quota.cc new file mode 100644 index 0000000..927412a --- /dev/null +++ b/xtoskrnl/mm/quota.cc @@ -0,0 +1,69 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/mm/quota.cc + * DESCRIPTION: Memory Manager Quota support + * DEVELOPERS: Aiken Harris + */ + +#include + + +/** + * Attempts to increase the pool quota limit. + * + * @param PoolType + * Supplies the type of memory pool whose quota limit is being evaluated for an increase. + * + * @param CurrentQuotaLimit + * Supplies the current quota limit, in bytes, for the requested pool. + * + * @param NewQuotaLimit + * Receives the newly established quota limit if the increase was successful. + * + * @return This routine returns TRUE if the quota limit was successfully raised, or FALSE otherwise. + * + * @since XT 1.0 + */ +XTAPI +BOOLEAN +MM::Quota::RaisePoolQuota(IN MMPOOL_TYPE PoolType, + IN SIZE_T CurrentQuotaLimit, + OUT PSIZE_T NewQuotaLimit +) +{ + UNIMPLEMENTED; + return FALSE; +} + +/** + * Returns a specified amount of quota back to the global system pool. + * + * @param PoolType + * Supplies the type of memory pool receiving the returned quota. + * + * @param ReturnedQuota + * Supplies the amount of quota, in bytes, being returned to the system. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +MM::Quota::ReturnPoolQuota(IN MMPOOL_TYPE PoolType, + IN SIZE_T ReturnedQuota) +{ + /* Route the returned quota to the appropriate pool */ + switch(PoolType) + { + case PagedPool: + /* Return quota to the paged pool */ + PagedPoolQuota -= ReturnedQuota; + break; + default: + /* Return quota to the non-paged pool */ + NonPagedPoolQuota -= ReturnedQuota; + break; + } +}