From 610f91d87152cbe48d3054fcf437d8239da6ef35 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 21 Dec 2024 21:59:13 +0100 Subject: IMP: :boom: Breaking changes some checks are needed to be done. Signed-off-by: Amlal --- dev/BootLoader/src/HEL/ARM64/BootMain.cc | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 dev/BootLoader/src/HEL/ARM64/BootMain.cc (limited to 'dev/BootLoader/src/HEL/ARM64/BootMain.cc') 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 +#include +#include +#include + +#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(); +} -- cgit v1.2.3