summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/RuntimeMain.cxx89
-rw-r--r--Private/NewBoot/Source/makefile2
2 files changed, 83 insertions, 8 deletions
diff --git a/Private/NewBoot/Source/RuntimeMain.cxx b/Private/NewBoot/Source/RuntimeMain.cxx
index 3c55c06b..cf1051fd 100644
--- a/Private/NewBoot/Source/RuntimeMain.cxx
+++ b/Private/NewBoot/Source/RuntimeMain.cxx
@@ -26,19 +26,17 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
#ifndef __DEBUG__
- writer.WriteString(
- L"MahroussLogic (R) HCore Version 1.00 (Release Channel)\r\n");
+ writer.WriteString(L"HCoreLdr: Version 1.00 (Release Channel)\r\n");
#else
- writer.WriteString(
- L"MahroussLogic (R) HCore Version 1.00 (Insiders Channel)\r\n");
+ writer.WriteString(L"HCoreLdr: Version 1.00 (Insiders Channel)\r\n");
#endif
const char strDate[] = __DATE__;
- writer.WriteString(L"Build Date: ");
+ writer.WriteString(L"HCoreLdr: Build-Date");
for (auto& ch : strDate) {
writer.WriteCharacter(ch);
@@ -66,9 +64,84 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
if (ptrHdr && ptrHdr->mMachine == EFI::Platform() &&
ptrHdr->mMagic == kPeMagic) {
if (ptrHdr->mNumberOfSections > 1) {
+ ExecOptionalHeaderPtr optHdr = reinterpret_cast<ExecOptionalHeaderPtr>(
+ ptrHdr + sizeof(ExecHeader));
+
+ UInt64 baseCode = optHdr->mBaseOfCode;
+ UInt64 codeSz = optHdr->mSizeOfCode;
+ VoidPtr codePtr = nullptr;
+
+ img.File()->SetPosition(img.File(), &baseCode);
+
+ BS->AllocatePool(EfiLoaderCode, codeSz, &codePtr);
+
+ writer.WriteString(L"HCoreLdr: Init [0/2]...\r\n");
+
+ if (!codePtr) {
+ EFI::RaiseHardError(L"HCoreLdr-BadAlloc", L"Bad alloc!");
+ }
+
+ img.File()->Read(img.File(), &codeSz, codePtr);
+
+ /// GET DATA
+
+ UInt64 baseData = optHdr->mBaseOfData;
+ UInt64 sizeofData =
+ optHdr->mSizeOfInitializedData + optHdr->mSizeOfUninitializedData;
+ VoidPtr dataPtr = nullptr;
+
+ BS->AllocatePool(EfiLoaderCode, sizeofData, &dataPtr);
+
+ if (!dataPtr) {
+ EFI::RaiseHardError(L"HCoreLdr-BadAlloc", L"Bad alloc!");
+ }
+
+ writer.WriteString(L"HCoreLdr: Init [1/2]...\r\n");
+
+ img.File()->SetPosition(img.File(), &baseData);
+
+ img.File()->Read(img.File(), &sizeofData, dataPtr);
+
UInt64 MapKey = 0;
+ UInt64 Size = 0;
+ EfiMemoryDescriptor* Descriptor = nullptr;
+ UInt64 SzDesc = 0;
+ UInt64 RevDesc = 0;
+
+ BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
+ (VoidPtr*)&Descriptor);
+
+ if (BS->GetMemoryMap(&Size, Descriptor, &MapKey, &SzDesc, &RevDesc) !=
+ kEfiOk) {
+ EFI::RaiseHardError(L"HCoreLdr: Bad-Call",
+ L"Bad call! (GetMemoryMap)");
+ }
+
+ writer.WriteString(L"HCoreLdr: Init [2/2]...\r\n");
+
+ HEL::HandoverInformationHeader* handoverHdrPtr = nullptr;
+
+ BS->AllocatePool(EfiLoaderData, sizeof(HEL::HandoverInformationHeader),
+ (VoidPtr*)&handoverHdrPtr);
+
+ HEL::HandoverProc fn = reinterpret_cast<HEL::HandoverProc>(
+ (UIntPtr)optHdr->mAddressOfEntryPoint);
+
+ handoverHdrPtr->f_GOP = (voidPtr)kGop->Mode->FrameBufferBase;
+ handoverHdrPtr->f_GOPSize = kGop->Mode->FrameBufferSize;
+
+ handoverHdrPtr->f_PhysicalStart = (voidPtr)Descriptor->PhysicalStart;
+ handoverHdrPtr->f_PhysicalSize = Descriptor->NumberOfPages;
+ handoverHdrPtr->f_VirtualStart = (voidPtr)Descriptor->VirtualStart;
+ handoverHdrPtr->f_VirtualSize = 0; /* not known */
+ handoverHdrPtr->f_FirmwareVendorLen =
+ BStrLen(SystemTable->FirmwareVendor);
+
+ BCopyMem(handoverHdrPtr->f_FirmwareVendorName,
+ SystemTable->FirmwareVendor,
+ handoverHdrPtr->f_FirmwareVendorLen);
- EFI::ExitBootServices(MapKey, ImageHandle);
+ EFI::ExitBootServices(MapKey, ImageHandle, fn, handoverHdrPtr);
// Launch PE app.
@@ -78,9 +151,11 @@ EFI_EXTERN_C EFI_API Int EfiMain(EfiHandlePtr ImageHandle,
} else {
writer.WriteString(L"HCoreLdr: Error-Code: HLDR-0001\r\n");
}
+ } else {
+ writer.WriteString(L"HCoreLdr: Error-Code: HLDR-0002\r\n");
}
} else {
- writer.WriteString(L"HCoreLdr: Error-Code: HLDR-0002\r\n");
+ writer.WriteString(L"HCoreLdr: Error-Code: HLDR-0003\r\n");
}
EFI::Stop();
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index fab7453d..d17f9671 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -27,7 +27,7 @@ bootloader-amd64:
.PHONY: run-efi-amd64
run-efi-amd64:
wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
- qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio
+ qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int
.PHONY: clean
clean: