summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 19:54:04 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 19:56:13 +0100
commit4cadbff15541ca09ced3321acfdf302fced29ee9 (patch)
tree279a18b8268add19ad9ac1010d3d70c39a102e7b /Private/NewBoot/Source
parent65254486efff0fd1bb78a48ff90b7713a5ce539f (diff)
NewBoot: Working on EFI implementation to load kernel into memory...
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx26
1 files changed, 23 insertions, 3 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
index 0d44086b..9174293e 100644
--- a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
@@ -11,13 +11,33 @@
#include <BootKit/Processor.hxx>
#include <BootKit/Protocol.hxx>
+// don't remove EfiGUID, it will call initializer_list!
+
EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle,
- EfiSystemTable *SystemTable) {
+ EfiSystemTable* SystemTable) {
SystemTable->ConOut->OutputString(SystemTable->ConOut,
L"HCoreLdr: Starting \\EPM\\HCore...\r\n");
- if (SystemTable->BootServices->ExitBootServices(
- ImageHandle, kBaseHandoverStruct) != kEfiOk) {
+ EfiLoadImageProtocol* protocol{};
+
+ EfiGUID guid = EfiGUID EFI_LOADED_IMAGE_PROTOCOL_GUID;
+
+ SystemTable->BootServices->LocateProtocol(&guid, nullptr,
+ (VoidPtr*)&protocol);
+
+ if (!protocol) {
+ SystemTable->ConOut->OutputString(
+ SystemTable->ConOut,
+ L"HCoreLdr: Could not locate EfiLoadImageProtocol! Aborting...\r\n");
+
+ return kEfiFail;
+ }
+
+ SystemTable->BootServices->OpenProtocol(
+ ImageHandle, &guid, (VoidPtr*)&protocol, ImageHandle, ImageHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
+ if (SystemTable->BootServices->ExitBootServices(ImageHandle, 0) != kEfiOk) {
SystemTable->ConOut->OutputString(
SystemTable->ConOut,
L"HCoreLdr: Could not Exit UEFI!\r\nHanging...\r\n");