79 lines
1.5 KiB
C
79 lines
1.5 KiB
C
/*++
|
|
|
|
Copyright (c) 2024, Quinn Stephens.
|
|
Provided under the BSD 3-Clause license.
|
|
|
|
Module Name:
|
|
|
|
mm.c
|
|
|
|
Abstract:
|
|
|
|
Provides boot library memory manager routines.
|
|
|
|
--*/
|
|
|
|
#include <ntrtl.h>
|
|
#include "bootlib.h"
|
|
#include "mm.h"
|
|
|
|
NTSTATUS
|
|
BlpMmInitialize (
|
|
IN PBOOT_MEMORY_INFO MemoryInfo,
|
|
IN ULONG TranslationType,
|
|
IN PBOOT_LIBRARY_PARAMETERS LibraryParameters
|
|
)
|
|
|
|
/*++
|
|
|
|
Routine Description:
|
|
|
|
Initializes the boot memory manager.
|
|
|
|
Arguments:
|
|
|
|
MemoryInfo - pointer to the memory info structure.
|
|
|
|
TranslationType - the current translation type being used.
|
|
|
|
LibraryParameters - pointer to the library parameters structure.
|
|
|
|
Return Value:
|
|
|
|
STATUS_SUCCESS if successful,
|
|
STATUS_INVALID_PARAMETER if TranslationType is invalid,
|
|
Other NTSTATUS value if an error occurs.
|
|
|
|
--*/
|
|
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
DebugPrint(L"Initializing memory manager...\r\n");
|
|
|
|
//
|
|
// Check TranslationType.
|
|
//
|
|
if (
|
|
TranslationType > BOOT_TRANSLATION_TYPE_MAX ||
|
|
LibraryParameters->TranslationType > BOOT_TRANSLATION_TYPE_MAX
|
|
) {
|
|
DebugPrint(L"BlpMmInitialize(): TranslationType is invalid\r\n");
|
|
return STATUS_INVALID_PARAMETER;
|
|
}
|
|
|
|
//
|
|
// Initialize memory descriptor manager.
|
|
//
|
|
MmMdInitialize(0, LibraryParameters);
|
|
|
|
//
|
|
// Initialize page allocator.
|
|
//
|
|
Status = MmPaInitialize(MemoryInfo, LibraryParameters->MinimumPageAllocation);
|
|
if (!NT_SUCCESS(Status)) {
|
|
return Status;
|
|
}
|
|
|
|
return STATUS_SUCCESS;
|
|
} |