mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 15:46:13 +00:00
[BOOTLIB]: Fix from hermes for BlReplaceBootOptions
[BOOTLIB]: More WIP transfer code. svn path=/trunk/; revision=73689
This commit is contained in:
parent
0e90ca425c
commit
996dfea0be
4 changed files with 67 additions and 10 deletions
|
@ -93,6 +93,16 @@ DEFINE_GUID(BadMemoryGuid, 0x54B8275B, 0xD431, 0x473F, 0xAC, 0xFB, 0xE5, 0x36, 0
|
||||||
#define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG 0x20
|
#define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG 0x20
|
||||||
#define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG 0x2000
|
#define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG 0x2000
|
||||||
|
|
||||||
|
#define BL_MM_INCLUDE_MAPPED_ALLOCATED 0x01
|
||||||
|
#define BL_MM_INCLUDE_MAPPED_UNALLOCATED 0x02
|
||||||
|
#define BL_MM_INCLUDE_UNMAPPED_ALLOCATED 0x04
|
||||||
|
#define BL_MM_INCLUDE_UNMAPPED_UNALLOCATED 0x08
|
||||||
|
#define BL_MM_INCLUDE_RESERVED_ALLOCATED 0x10
|
||||||
|
#define BL_MM_INCLUDE_BAD_MEMORY 0x20
|
||||||
|
#define BL_MM_INCLUDE_FIRMWARE_MEMORY 0x40
|
||||||
|
#define BL_MM_INCLUDE_TRUNCATED_MEMORY 0x80
|
||||||
|
#define BL_MM_INCLUDE_PERSISTEND_MEMORY 0x100
|
||||||
|
|
||||||
#define BL_MM_REQUEST_DEFAULT_TYPE 1
|
#define BL_MM_REQUEST_DEFAULT_TYPE 1
|
||||||
#define BL_MM_REQUEST_TOP_DOWN_TYPE 2
|
#define BL_MM_REQUEST_TOP_DOWN_TYPE 2
|
||||||
|
|
||||||
|
|
|
@ -821,14 +821,15 @@ BlRemoveBootOption (
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
BlReplaceBootOptions (
|
BlReplaceBootOptions (
|
||||||
_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
|
_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
|
||||||
_In_ PBL_BCD_OPTION NewOptions
|
_In_ PBL_BCD_OPTION OldOptions
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG Size;
|
ULONG OptionSize;
|
||||||
|
PBL_BCD_OPTION NewOptions;
|
||||||
|
|
||||||
/* Make sure there's something to replace with */
|
/* Make sure there's something to replace with */
|
||||||
if (!NewOptions)
|
if (!OldOptions)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -849,17 +850,17 @@ BlReplaceBootOptions (
|
||||||
AppEntry->BcdData = NULL;
|
AppEntry->BcdData = NULL;
|
||||||
|
|
||||||
/* Get the size of the new list of options */
|
/* Get the size of the new list of options */
|
||||||
Size = BlGetBootOptionListSize(NewOptions);
|
OptionSize = BlGetBootOptionListSize(OldOptions);
|
||||||
|
|
||||||
/* Allocate a copy of the new list */
|
/* Allocate a copy of the new list */
|
||||||
NewOptions = BlMmAllocateHeap(Size);
|
NewOptions = BlMmAllocateHeap(OptionSize);
|
||||||
if (!NewOptions)
|
if (!NewOptions)
|
||||||
{
|
{
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy it in */
|
/* Copy it in */
|
||||||
RtlCopyMemory(NewOptions, NewOptions, Size);
|
RtlCopyMemory(NewOptions, OldOptions, OptionSize);
|
||||||
|
|
||||||
/* Set it as the new set of options and return */
|
/* Set it as the new set of options and return */
|
||||||
AppEntry->Flags |= BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL;
|
AppEntry->Flags |= BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL;
|
||||||
|
|
|
@ -1604,6 +1604,17 @@ BlpPdParseReturnArguments (
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
BlMmGetMemoryMap (
|
||||||
|
_In_ PLIST_ENTRY MemoryMap,
|
||||||
|
_In_ PBL_IMAGE_PARAMETERS ImageParameters,
|
||||||
|
_In_ ULONG WhichTypes,
|
||||||
|
_In_ ULONG Flags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
ImgpInitializeBootApplicationParameters (
|
ImgpInitializeBootApplicationParameters (
|
||||||
_In_ PBL_IMAGE_PARAMETERS ImageParameters,
|
_In_ PBL_IMAGE_PARAMETERS ImageParameters,
|
||||||
|
@ -1612,6 +1623,32 @@ ImgpInitializeBootApplicationParameters (
|
||||||
_In_ ULONG ImageSize
|
_In_ ULONG ImageSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PIMAGE_NT_HEADERS NtHeaders;
|
||||||
|
BL_IMAGE_PARAMETERS MemoryParameters;
|
||||||
|
LIST_ENTRY MemoryList;
|
||||||
|
|
||||||
|
Status = RtlImageNtHeaderEx(0, ImageBase, ImageSize, &NtHeaders);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryParameters.BufferSize = 0;
|
||||||
|
|
||||||
|
Status = BlMmGetMemoryMap(&MemoryList,
|
||||||
|
&MemoryParameters,
|
||||||
|
BL_MM_INCLUDE_FIRMWARE_MEMORY |
|
||||||
|
BL_MM_INCLUDE_MAPPED_ALLOCATED |
|
||||||
|
BL_MM_INCLUDE_MAPPED_UNALLOCATED |
|
||||||
|
BL_MM_INCLUDE_UNMAPPED_ALLOCATED |
|
||||||
|
BL_MM_INCLUDE_RESERVED_ALLOCATED,
|
||||||
|
0);
|
||||||
|
if ((Status != STATUS_BUFFER_TOO_SMALL) && (Status != STATUS_SUCCESS))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,28 +1686,34 @@ ImgArchEfiStartBootApplication (
|
||||||
goto Quickie;
|
goto Quickie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Zero the boot data */
|
||||||
RtlZeroMemory(BootData, BootSizeNeeded);
|
RtlZeroMemory(BootData, BootSizeNeeded);
|
||||||
|
|
||||||
|
/* Set the new stack, GDT and IDT */
|
||||||
NewStack = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE) - 8);
|
NewStack = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE) - 8);
|
||||||
NewGdt = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE));
|
NewGdt = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE));
|
||||||
NewIdt = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE) + Gdt.Limit + 1);
|
NewIdt = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE) + Gdt.Limit + 1);
|
||||||
|
|
||||||
|
/* Copy the current (firmware) GDT and IDT */
|
||||||
RtlCopyMemory(NewGdt, (PVOID)Gdt.Base, Gdt.Limit + 1);
|
RtlCopyMemory(NewGdt, (PVOID)Gdt.Base, Gdt.Limit + 1);
|
||||||
RtlCopyMemory(NewIdt, (PVOID)Idt.Base, Idt.Limit + 1);
|
RtlCopyMemory(NewIdt, (PVOID)Idt.Base, Idt.Limit + 1);
|
||||||
|
|
||||||
|
/* Read the NT headers so that we can get the entrypoint later on */
|
||||||
RtlImageNtHeaderEx(0, ImageBase, ImageSize, &NtHeaders);
|
RtlImageNtHeaderEx(0, ImageBase, ImageSize, &NtHeaders);
|
||||||
|
|
||||||
|
/* Prepare the application parameters */
|
||||||
RtlZeroMemory(&Parameters, sizeof(Parameters));
|
RtlZeroMemory(&Parameters, sizeof(Parameters));
|
||||||
|
|
||||||
Status = ImgpInitializeBootApplicationParameters(&Parameters,
|
Status = ImgpInitializeBootApplicationParameters(&Parameters,
|
||||||
AppEntry,
|
AppEntry,
|
||||||
ImageBase,
|
ImageBase,
|
||||||
ImageSize);
|
ImageSize);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
/* Set the firmware GDT/IDT as the one the application will use */
|
||||||
BootAppGdtRegister = Gdt;
|
BootAppGdtRegister = Gdt;
|
||||||
BootAppIdtRegister = Idt;
|
BootAppIdtRegister = Idt;
|
||||||
|
|
||||||
|
/* Set the entrypoint, parameters, and stack */
|
||||||
BootApp32EntryRoutine = (PVOID)((ULONG_PTR)ImageBase +
|
BootApp32EntryRoutine = (PVOID)((ULONG_PTR)ImageBase +
|
||||||
NtHeaders->OptionalHeader.
|
NtHeaders->OptionalHeader.
|
||||||
AddressOfEntryPoint);
|
AddressOfEntryPoint);
|
||||||
|
@ -1678,11 +1721,11 @@ ImgArchEfiStartBootApplication (
|
||||||
BootApp32Stack = NewStack;
|
BootApp32Stack = NewStack;
|
||||||
|
|
||||||
#if BL_KD_SUPPORT
|
#if BL_KD_SUPPORT
|
||||||
|
/* Disable the kernel debugger */
|
||||||
BlBdStop();
|
BlBdStop();
|
||||||
#endif
|
#endif
|
||||||
/* Not yet implemented. This is the last step! */
|
/* Not yet implemented. This is the last step! */
|
||||||
EfiPrintf(L"EFI APPLICATION START!!!\r\n");
|
EfiPrintf(L"EFI APPLICATION START!!!\r\n");
|
||||||
EfiStall(100000000);
|
|
||||||
|
|
||||||
/* Make it so */
|
/* Make it so */
|
||||||
Archx86TransferTo32BitApplicationAsm();
|
Archx86TransferTo32BitApplicationAsm();
|
||||||
|
@ -1690,17 +1733,22 @@ ImgArchEfiStartBootApplication (
|
||||||
/* Not yet implemented. This is the last step! */
|
/* Not yet implemented. This is the last step! */
|
||||||
EfiPrintf(L"EFI APPLICATION RETURNED!!!\r\n");
|
EfiPrintf(L"EFI APPLICATION RETURNED!!!\r\n");
|
||||||
EfiStall(100000000);
|
EfiStall(100000000);
|
||||||
|
|
||||||
#if BL_KD_SUPPORT
|
#if BL_KD_SUPPORT
|
||||||
|
/* Re-enable the kernel debugger */
|
||||||
BlBdStart();
|
BlBdStart();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Quickie:
|
Quickie:
|
||||||
|
/* Check if we had boot data allocated */
|
||||||
if (BootData)
|
if (BootData)
|
||||||
{
|
{
|
||||||
|
/* Free it */
|
||||||
//MmPapFreePages(bootData, TRUE);
|
//MmPapFreePages(bootData, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* All done */
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@ ULONG UtlNextUpdatePercentage;
|
||||||
BOOLEAN UtlProgressNeedsInfoUpdate;
|
BOOLEAN UtlProgressNeedsInfoUpdate;
|
||||||
PVOID UtlProgressInfo;
|
PVOID UtlProgressInfo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue