Implement page allocation interface
This commit is contained in:
@@ -18,7 +18,18 @@ namespace MM
|
||||
class Allocator
|
||||
{
|
||||
public:
|
||||
STATIC XTAPI XTSTATUS AllocatePages(IN MMPOOL_TYPE PoolType,
|
||||
IN SIZE_T Bytes,
|
||||
OUT PVOID *Memory);
|
||||
STATIC XTAPI VOID InitializeNonPagedPool(VOID);
|
||||
STATIC XTAPI VOID InitializePagedPool(VOID);
|
||||
|
||||
private:
|
||||
STATIC XTAPI XTSTATUS AllocateNonPagedPoolPages(IN PFN_COUNT Pages,
|
||||
OUT PVOID *Memory);
|
||||
STATIC XTAPI XTSTATUS AllocatePagedPoolPages(IN PFN_COUNT Pages,
|
||||
OUT PVOID *Memory);
|
||||
STATIC XTAPI VOID MapNonPagedPool(VOID);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,3 +9,133 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Allocates pages from the non-paged pool.
|
||||
*
|
||||
* @param Pages
|
||||
* Specifies the number of pages to allocate.
|
||||
*
|
||||
* @param Memory
|
||||
* Supplies a pointer to the allocated pool.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages,
|
||||
OUT PVOID *Memory)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
||||
/* Return not implemented status code */
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates pages from the paged pool.
|
||||
*
|
||||
* @param Pages
|
||||
* Specifies the number of pages to allocate.
|
||||
*
|
||||
* @param Memory
|
||||
* Supplies a pointer to the allocated pool.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
MM::Allocator::AllocatePagedPoolPages(IN PFN_COUNT Pages,
|
||||
OUT PVOID *Memory)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
||||
/* Return not implemented status code */
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates pages from the specified pool type.
|
||||
*
|
||||
* @param PoolType
|
||||
* Specifies the type of pool to allocate pages from.
|
||||
*
|
||||
* @param Bytes
|
||||
* Specifies the number of bytes to allocate.
|
||||
*
|
||||
* @param Memory
|
||||
* Supplies a pointer to the allocated pool.
|
||||
*
|
||||
* @return This routine returns a status code.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
MM::Allocator::AllocatePages(IN MMPOOL_TYPE PoolType,
|
||||
IN SIZE_T Bytes,
|
||||
OUT PVOID *Memory)
|
||||
{
|
||||
PFN_COUNT Pages;
|
||||
|
||||
/* Initialize the output parameter */
|
||||
*Memory = NULLPTR;
|
||||
|
||||
/* Convert bytes to pages */
|
||||
Pages = SIZE_TO_PAGES(Bytes);
|
||||
|
||||
/* Check if there are any pages to allocate */
|
||||
if(!Pages)
|
||||
{
|
||||
/* Nothing to allocate, return NULLPTR */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Switch on pool type */
|
||||
switch(PoolType & MM_POOL_TYPE_MASK)
|
||||
{
|
||||
case NonPagedPool:
|
||||
/* Allocate non-paged pool */
|
||||
return AllocateNonPagedPoolPages(Pages, Memory);
|
||||
case PagedPool:
|
||||
/* Allocate paged pool */
|
||||
return AllocatePagedPoolPages(Pages, Memory);
|
||||
}
|
||||
|
||||
/* Invalid pool type specified, return error */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the non-paged pool for memory allocator.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
MM::Allocator::InitializeNonPagedPool(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
||||
/* Map PTEs for the non-paged pool */
|
||||
MapNonPagedPool();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the non-paged pool for memory allocator.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
MM::Allocator::InitializePagedPool(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,19 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Maps the PTE for the base of the non-paged pool.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
MM::Allocator::InitializeNonPagedPool(VOID)
|
||||
MM::Allocator::MapNonPagedPool(VOID)
|
||||
{
|
||||
PMMMEMORY_LAYOUT MemoryLayout;
|
||||
|
||||
UNIMPLEMENTED;
|
||||
|
||||
/* Retrieve memory layout */
|
||||
MemoryLayout = MM::Manager::GetMemoryLayout();
|
||||
|
||||
|
||||
@@ -9,12 +9,18 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Maps the PTE for the base of the non-paged pool.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
MM::Allocator::InitializeNonPagedPool(VOID)
|
||||
MM::Allocator::MapNonPagedPool(VOID)
|
||||
{
|
||||
PMMMEMORY_LAYOUT MemoryLayout;
|
||||
UNIMPLEMENTED;
|
||||
|
||||
/* Retrieve memory layout */
|
||||
MemoryLayout = MM::Manager::GetMemoryLayout();
|
||||
|
||||
Reference in New Issue
Block a user