Compare commits

..

No commits in common. "75197cc8b5118750510360ebd8a8c9ae85ae4443" and "437b19a0f5e03a7f355903490be07c92e15ed38c" have entirely different histories.

7 changed files with 15 additions and 156 deletions

View File

@ -63,11 +63,6 @@ BlpFwInitialize (
IN PBOOT_FIRMWARE_DATA FirmwareData
);
NTSTATUS
BlpMmInitializeConstraints (
VOID
);
NTSTATUS
BlpMmInitialize (
IN PBOOT_MEMORY_INFO MemoryInfo,

View File

@ -18,8 +18,7 @@ Abstract:
#include "bootlib.h"
#define MDL_OPERATION_FLAGS_TRUNCATE 0x00000002
#define MDL_OPERATION_FLAGS_PHYSICAL 0x40000000
#define MDL_OPERATION_FLAGS_TRUNCATE 0x02
NTSTATUS
MmFwGetMemoryMap (
@ -53,15 +52,6 @@ MmMdRemoveDescriptorFromList (
IN PMEMORY_DESCRIPTOR Descriptor
);
NTSTATUS
MmMdRemoveRegionFromMdlEx (
IN PMEMORY_DESCRIPTOR_LIST Mdl,
IN ULONGLONG FirstPage,
IN ULONGLONG PageCount,
IN ULONG Flags,
OUT PMEMORY_DESCRIPTOR_LIST Unused
);
NTSTATUS
MmMdFreeDescriptor (
IN PMEMORY_DESCRIPTOR Descriptor

View File

@ -17,36 +17,6 @@ Abstract:
#include "bootlib.h"
#include "mm.h"
NTSTATUS
BlpMmInitializeConstraints (
VOID
)
/*++
Routine Description:
Initializes physical address constraints.
Arguments:
None.
Return Value:
STATUS_SUCCESS if successful,
--*/
{
//
// TODO: Implement this.
//
return STATUS_SUCCESS;
}
NTSTATUS
BlpMmInitialize (
IN PBOOT_MEMORY_INFO MemoryInfo,

View File

@ -347,9 +347,9 @@ Routine Description:
Arguments:
Mdl - MDL to remove Descriptor from.
Mdl - the MDL to remove Descriptor from.
Descriptor - Descriptor to remove from Mdl.
Descriptor - the descriptor to remove from Mdl.
Return Value:
@ -386,67 +386,6 @@ Return Value:
}
}
NTSTATUS
MmMdRemoveRegionFromMdlEx (
IN PMEMORY_DESCRIPTOR_LIST Mdl,
IN ULONGLONG FirstPage,
IN ULONGLONG PageCount,
IN ULONG Flags,
OUT PMEMORY_DESCRIPTOR_LIST Unused
)
/*++
Routine Description:
Removes a region from a MDL.
Arguments:
Mdl - MDL to remove the region from.
FirstPage - The first page in the region.
PageCount - The number of pages in the region.
Flags - MDL_OPERATION_FLAGS_*.
Unused - Unused.
Return Value:
None.
--*/
{
ULONGLONG RemoveEnd, DescriptorEnd;
PLIST_ENTRY Entry;
PMEMORY_DESCRIPTOR Descriptor;
MEMORY_DESCRIPTOR RemovedDescriptor;
(VOID)Flags;
(VOID)Unused;
RemoveEnd = FirstPage + PageCount;
Entry = Mdl->Head->Flink;
while (Entry != Mdl->Head) {
Descriptor = (PMEMORY_DESCRIPTOR)Entry;
DescriptorEnd = Descriptor->FirstPage + Descriptor->PageCount;
RtlCopyMemory(&RemovedDescriptor, Descriptor, sizeof(MEMORY_DESCRIPTOR));
// if (FirstPage <= Descriptor->FirstPage && Descriptor->FirstPage < RemoveEnd) {
// }
}
//
// TODO: Finish this function.
//
return STATUS_SUCCESS;
}
NTSTATUS
MmMdFreeDescriptor (
IN PMEMORY_DESCRIPTOR Descriptor

View File

@ -79,78 +79,44 @@ Arguments:
Return Value:
STATUS_SUCCESS if successful,
STATUS_INVALID_PARAMETER if regions in MemoryInfo could not be removed.
STATUS_NO_MEMORY if a new descriptor cannot be allocated.
--*/
{
NTSTATUS Status;
PMEMORY_DESCRIPTOR Descriptor, NewDescriptor;
(VOID)MemoryInfo;
DebugPrint(L"Initializing page allocator...\r\n");
//
// Initialize page allocator settings.
//
PapMinimumAllocationCount = MinimumAllocation;
PapMinimumPhysicalPage = 1;
PapMaximumPhysicalPage = MAXULONGLONG >> PAGE_SHIFT;
DebugPrintf(L"Maximum physical page: %x %x\r\n", HIDWORD(PapMaximumPhysicalPage), LODWORD(PapMaximumPhysicalPage));
//
// Initialize MDLs.
//
InitializeMdl(&MmMdlFwAllocationTracker);
InitializeMdl(&MmMdlBadMemory);
InitializeMdl(&MmMdlTruncatedMemory);
InitializeMdl(&MmMdlPersistentMemory);
InitializeMdl(&MmMdlReservedAllocated);
InitializeMdl(&MmMdlReservedAllocated);;
InitializeMdl(&MmMdlMappedAllocated);
InitializeMdl(&MmMdlMappedUnallocated);
InitializeMdl(&MmMdlUnmappedAllocated);
InitializeMdl(&MmMdlUnmappedUnallocated);
//
// Get the firmware memory map.
//
Status = MmFwGetMemoryMap(&MmMdlUnmappedUnallocated, 0x03);
if (!NT_SUCCESS(Status)) {
return Status;
}
//
// Remove regions described in MemoryInfo from the
// MDL the memory manager will use for allocation.
//
Descriptor = (PMEMORY_DESCRIPTOR)((PUCHAR)MemoryInfo + MemoryInfo->MdlOffset);
for (ULONG DescriptorCount = MemoryInfo->DescriptorCount; DescriptorCount > 0; DescriptorCount--) {
//
// Remove from the usable MDL.
//
Status = MmMdRemoveRegionFromMdlEx(&MmMdlUnmappedUnallocated, Descriptor->FirstPage, Descriptor->PageCount, MDL_OPERATION_FLAGS_PHYSICAL, NULL);
if (!NT_SUCCESS(Status)) {
return STATUS_INVALID_PARAMETER;
}
//
// ... and add to the reserved MDL.
//
NewDescriptor = MmMdInitDescriptor(
Descriptor->FirstPage,
Descriptor->MappedFirstPage,
Descriptor->PageCount,
Descriptor->Attributes,
Descriptor->Type
);
if (NewDescriptor == NULL) {
return STATUS_NO_MEMORY;
}
Status = MmMdAddDescriptorToList(&MmMdlReservedAllocated, NewDescriptor, 0x00);
if (!NT_SUCCESS(Status)) {
return Status;
}
Descriptor = (PMEMORY_DESCRIPTOR)((PUCHAR)Descriptor + MemoryInfo->DescriptorSize);
}
Status = BlpMmInitializeConstraints();
if (!NT_SUCCESS(Status)) {
return Status;
}
return STATUS_SUCCESS;
}

View File

@ -82,7 +82,7 @@ Return Value:
return Status;
}
ConsolePrint(L"> Alcyone EFI Boot Manager\r\n");
ConsolePrint(L"-------- Alcyone EFI Boot Manager --------\r\n");
ConsolePrintf(L"Image base: %x %x\r\nImage size: %x\r\n", HIDWORD((ULONG_PTR)InputParameters->ImageBase), LODWORD((ULONG_PTR)InputParameters->ImageBase), InputParameters->ImageSize);
DebugPrint(L"Initializing boot library...\r\n");

View File

@ -25,7 +25,6 @@ Abstract:
#define STATUS_UNSUCCESSFUL ((NTSTATUS) 0xC0000001L)
#define STATUS_NOT_IMPLEMENTED ((NTSTATUS) 0xC0000002L)
#define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xC000000DL)
#define STATUS_NO_MEMORY ((NTSTATUS) 0xC0000017L)
#define STATUS_ACCESS_DENIED ((NTSTATUS) 0xC0000022L)
#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xC0000023L)
#define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS) 0xC0000032L)