diff --git a/sdk/xtdk/mmfuncs.h b/sdk/xtdk/mmfuncs.h new file mode 100644 index 0000000..d481457 --- /dev/null +++ b/sdk/xtdk/mmfuncs.h @@ -0,0 +1,40 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: sdk/xtdk/mmfuncs.h + * DESCRIPTION: XTOS memory manager routine definitions + * DEVELOPERS: Aiken Harris + */ + +#ifndef __XTDK_MMFUNCS_H +#define __XTDK_MMFUNCS_H + +#include +#include +#include + + +/* Memory manager routines forward references */ +XTAPI +XTSTATUS +MmAllocatePool(IN MMPOOL_TYPE PoolType, + IN SIZE_T Bytes, + OUT PVOID *Memory); + +XTAPI +XTSTATUS +MmAllocatePoolWithTag(IN MMPOOL_TYPE PoolType, + IN SIZE_T Bytes, + OUT PVOID *Memory, + IN ULONG Tag); + +XTAPI +XTSTATUS +MmFreePool(IN PVOID VirtualAddress); + +XTAPI +XTSTATUS +MmFreePoolWithTag(IN PVOID VirtualAddress, + IN ULONG Tag); + +#endif /* __XTDK_MMFUNCS_H */ diff --git a/sdk/xtdk/xtkmapi.h b/sdk/xtdk/xtkmapi.h index e6cd9a1..0d82e1c 100644 --- a/sdk/xtdk/xtkmapi.h +++ b/sdk/xtdk/xtkmapi.h @@ -50,6 +50,7 @@ #include #include #include +#include #include /* Architecture specific XT routines */ diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 61d1c5c..b58b0ad 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -61,6 +61,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/mm/alloc.cc ${XTOSKRNL_SOURCE_DIR}/mm/colors.cc ${XTOSKRNL_SOURCE_DIR}/mm/data.cc + ${XTOSKRNL_SOURCE_DIR}/mm/exports.cc ${XTOSKRNL_SOURCE_DIR}/mm/hlpool.cc ${XTOSKRNL_SOURCE_DIR}/mm/kpool.cc ${XTOSKRNL_SOURCE_DIR}/mm/mmgr.cc diff --git a/xtoskrnl/mm/exports.cc b/xtoskrnl/mm/exports.cc new file mode 100644 index 0000000..a65e034 --- /dev/null +++ b/xtoskrnl/mm/exports.cc @@ -0,0 +1,102 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/mm/exports.cc + * DESCRIPTION: C-compatible API wrappers for exported kernel functions + * DEVELOPERS: Aiken Harris + */ + +#include + + +/** + * Allocates a block of memory from the specified pool type. + * + * @param PoolType + * Specifies the type of pool to allocate from. + * + * @param Bytes + * Specifies the number of bytes to allocate. + * + * @param Memory + * Supplies a pointer to the allocated memory. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +XTAPI +XTSTATUS +MmAllocatePool(IN MMPOOL_TYPE PoolType, + IN SIZE_T Bytes, + OUT PVOID *Memory) +{ + return MM::Allocator::AllocatePool(PoolType, Bytes, Memory); +} + +/** + * Allocates a block of memory from the specified pool type. + * + * @param PoolType + * Specifies the type of pool to allocate from. + * + * @param Bytes + * Specifies the number of bytes to allocate. + * + * @param Memory + * Supplies a pointer to the allocated memory. + * + * @param Tag + * Specifies the allocation identifying tag. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +XTAPI +XTSTATUS +MmAllocatePoolWithTag(IN MMPOOL_TYPE PoolType, + IN SIZE_T Bytes, + OUT PVOID *Memory, + IN ULONG Tag) +{ + return MM::Allocator::AllocatePool(PoolType, Bytes, Memory, Tag); +} + +/** + * Frees a previously allocated memory pool. + * + * @param VirtualAddress + * Supplies the base virtual address of the pool allocation to free. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +XTAPI +XTSTATUS +MmFreePool(IN PVOID VirtualAddress) +{ + return MM::Allocator::FreePool(VirtualAddress); +} + +/** + * Frees a previously allocated memory pool. + * + * @param VirtualAddress + * Supplies the base virtual address of the pool allocation to free. + * + * @param Tag + * Specifies the allocation identifying tag. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +XTAPI +XTSTATUS +MmFreePoolWithTag(IN PVOID VirtualAddress, + IN ULONG Tag) +{ + return MM::Allocator::FreePool(VirtualAddress, Tag); +} diff --git a/xtoskrnl/xtoskrnl.spec b/xtoskrnl/xtoskrnl.spec index 8ab66b0..8be25b5 100644 --- a/xtoskrnl/xtoskrnl.spec +++ b/xtoskrnl/xtoskrnl.spec @@ -42,6 +42,10 @@ @ stdcall KeSetTimer(ptr long long long ptr) @ stdcall KeSignalCallDpcDone(ptr) @ stdcall KeSignalCallDpcSynchronize(ptr) +@ stdcall MmAllocatePool(long long ptr) +@ stdcall MmAllocatePoolWithTag(long long ptr long) +@ stdcall MmFreePool(ptr) +@ stdcall MmFreePoolWithTag(ptr long) @ stdcall RtlClearAllBits(ptr) @ stdcall RtlClearBit(ptr long) @ stdcall RtlClearBits(ptr long long)