diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-12-21 21:59:13 +0100 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-12-21 21:59:45 +0100 |
| commit | 610f91d87152cbe48d3054fcf437d8239da6ef35 (patch) | |
| tree | a386f7047ab73d088169ab2371ddc6ffe8020f1c /dev/BootLoader/src/HEL/ARM64/BootMain.cc | |
| parent | 509fcca5986651c8ba712fb395f8498f2dea4109 (diff) | |
IMP: :boom: Breaking changes some checks are needed to be done.
Signed-off-by: Amlal <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/BootLoader/src/HEL/ARM64/BootMain.cc')
| -rw-r--r-- | dev/BootLoader/src/HEL/ARM64/BootMain.cc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/dev/BootLoader/src/HEL/ARM64/BootMain.cc b/dev/BootLoader/src/HEL/ARM64/BootMain.cc new file mode 100644 index 00000000..7f3ba6cf --- /dev/null +++ b/dev/BootLoader/src/HEL/ARM64/BootMain.cc @@ -0,0 +1,76 @@ +/* ------------------------------------------- + + Copyright (C) 2024, TQ B.V, all rights reserved. + +------------------------------------------- */ + +#include <FirmwareKit/EFI/API.h> +#include <FirmwareKit/EFI.h> +#include <BootKit/Thread.h> +#include <BootKit/BootKit.h> + +#ifndef kExpectedWidth +#define kExpectedWidth 844 +#endif + +#ifndef kExpectedHeight +#define kExpectedHeight 390 +#endif + +EXTERN EfiBootServices* BS; + +STATIC EfiGraphicsOutputProtocol* kGop = nullptr; +STATIC UInt16 kGopStride = 0U; +STATIC EfiGUID kGopGuid; + +/// @brief Main EFI entrypoint. +/// @param ImageHandle Handle of this image. +/// @param SystemTable The system table of it. +/// @return nothing, never returns. +EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, + EfiSystemTable* SystemTable) +{ + InitEFI(SystemTable); + + kGopGuid = EfiGUID(EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID); + kGop = nullptr; + + BS->LocateProtocol(&kGopGuid, nullptr, (VoidPtr*)&kGop); + + kGopStride = 4; + + Boot::BTextWriter writer; + + for (SizeT i = 0; i < kGop->Mode->MaxMode; ++i) + { + EfiGraphicsOutputProtocolModeInformation* infoPtr = nullptr; + UInt32 sz = 0U; + + kGop->QueryMode(kGop, i, &sz, &infoPtr); + + writer.Write(infoPtr->HorizontalResolution); + writer.Write(infoPtr->VerticalResolution); + writer.Write("\r"); + + if (infoPtr->HorizontalResolution == kExpectedWidth && + infoPtr->VerticalResolution == kExpectedHeight) + { + kGop->SetMode(kGop, i); + break; + } + } + + Boot::BFileReader reader_kernel(L"minoskrnl.exe", ImageHandle); + + reader_kernel.ReadAll(0); + + if (reader_kernel.Blob()) + { + auto kernel_thread = Boot::BThread(reader_kernel.Blob()); + + if (kernel_thread.IsValid()) + kernel_thread.Start(nullptr, YES); + } + + CANT_REACH(); +} |
