summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal <amlal@zka.com>2024-07-17 17:21:57 +0200
committerAmlal <amlal@zka.com>2024-07-17 17:21:57 +0200
commit08ee53082f5c4d0f730336a821c154515c76f4de (patch)
tree01b8d5593929acae9651651a7ef59f12f58c1066
parent7b8f6b0644e16614ebb07983ff2e8809581f8350 (diff)
[MHR-36] Rendering QR code when user is using AMD64 release of newosldr.
Signed-off-by: Amlal <amlal@zka.com>
-rw-r--r--Boot/BootKit/Vendor/Qr.hxx8
-rw-r--r--Boot/Sources/HEL/AMD64/BootMain.cxx30
-rw-r--r--Kernel/FirmwareKit/EFI/API.hxx30
3 files changed, 27 insertions, 41 deletions
diff --git a/Boot/BootKit/Vendor/Qr.hxx b/Boot/BootKit/Vendor/Qr.hxx
index 3616aaac..d1820330 100644
--- a/Boot/BootKit/Vendor/Qr.hxx
+++ b/Boot/BootKit/Vendor/Qr.hxx
@@ -1,6 +1,7 @@
#ifndef QR_HXX
#define QR_HXX
+#include "BootKit/BootKit.hxx"
extern "C" {
#include <math.h>
#include <stddef.h>
@@ -369,6 +370,11 @@ namespace qr
if (!this->status)
return false; // it may be invalid.
+ BTextWriter writer;
+ writer.Write(L"Printing QR-code...\r");
+
+ CGInit();
+
for (int y = 0; y < (this->side_size()); ++y)
{
for (int x = 0; x < (this->side_size()); ++x)
@@ -380,6 +386,8 @@ namespace qr
}
}
+ CGFini();
+
return false;
}
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx
index 13c887ff..51f8e8cf 100644
--- a/Boot/Sources/HEL/AMD64/BootMain.cxx
+++ b/Boot/Sources/HEL/AMD64/BootMain.cxx
@@ -58,7 +58,7 @@ STATIC Void InitVideoFB() noexcept
for (SizeT i = 0; i < kGop->Mode->MaxMode; ++i)
{
EfiGraphicsOutputProtocolModeInformation* infoPtr = nullptr;
- UInt32 sz = 0U;
+ UInt32 sz = 0U;
kGop->QueryMode(kGop, i, &sz, &infoPtr);
@@ -69,7 +69,6 @@ STATIC Void InitVideoFB() noexcept
break;
}
}
-
}
/// @brief check the BootDevice if suitable.
@@ -98,14 +97,6 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
.Write(BVersionString::The())
.Write("\r");
-#ifndef __DEBUG__
- writer.Write(L"\rnewosldr: AMD64 is only supported in debug mode.\r");
-
- EFI::Stop();
-
- CANT_REACH();
-#endif
-
UInt32* MapKey = new UInt32();
UInt32* SizePtr = new UInt32();
EfiMemoryDescriptor* Descriptor = nullptr;
@@ -158,20 +149,13 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
kHandoverHeader = handoverHdrPtr;
- // Start drawing the 'zka' icon.
-
- CGInit();
-
- CGDrawInRegion(cCGClearClr, handoverHdrPtr->f_GOP.f_Height,
- handoverHdrPtr->f_GOP.f_Width, 0, 0);
-
- CGFini();
-
- CGDrawBitMapInRegion(NewBoot, NEWBOOT_HEIGHT, NEWBOOT_WIDTH,
- (handoverHdrPtr->f_GOP.f_Width - NEWBOOT_WIDTH) / 2,
- (handoverHdrPtr->f_GOP.f_Height - NEWBOOT_HEIGHT) / 2);
+ // check if we are in AMD64
+#if defined(__NEWOS_AMD64__)
+ writer.Write(L"\rnewosldr: AMD64 support is not official.\r");
+ EFI::ThrowError(L"Beta-Software", L"Beta Software.");
+#endif
- CGFini();
+ // get memory map.
BS->GetMemoryMap(SizePtr, Descriptor, MapKey, SzDesc, RevDesc);
diff --git a/Kernel/FirmwareKit/EFI/API.hxx b/Kernel/FirmwareKit/EFI/API.hxx
index 3873afc6..597c1a8b 100644
--- a/Kernel/FirmwareKit/EFI/API.hxx
+++ b/Kernel/FirmwareKit/EFI/API.hxx
@@ -16,6 +16,8 @@
// forward decl.
class BTextWriter;
+#define cWebsiteMacro "https://zka-mobile.com/help"
+
#define __BOOTKIT_NO_INCLUDE__ 1
#include <BootKit/BootKit.hxx>
@@ -76,7 +78,6 @@ Bascially frees everything we have in the EFI side.
inline void ThrowError(const EfiCharType* ErrorCode,
const EfiCharType* Reason) noexcept
{
-#ifdef __DEBUG__
ST->ConOut->OutputString(ST->ConOut, L"\r*** STOP ***\r");
ST->ConOut->OutputString(ST->ConOut, L"*** Error: ");
@@ -86,36 +87,29 @@ Bascially frees everything we have in the EFI side.
ST->ConOut->OutputString(ST->ConOut, Reason);
ST->ConOut->OutputString(ST->ConOut, L" ***\r");
-#endif // ifdef __DEBUG__
#ifdef __NEWBOOT__
- CGInit();
-
- CGDrawBitMapInRegion(NewBootFatal, NEWBOOTFATAL_HEIGHT, NEWBOOTFATAL_WIDTH,
- (kHandoverHeader->f_GOP.f_Width - NEWBOOTFATAL_WIDTH) / 2,
- (kHandoverHeader->f_GOP.f_Height - NEWBOOTFATAL_HEIGHT) / 2);
-
- CGFini();
-
- /// Show the QR code now.
+ // Show the QR code now.
constexpr auto ver = 4;
auto ecc = qr::Ecc::H;
- auto str = "https://el-mahrouss-logic.com/";
- auto len = StrLen("https://el-mahrouss-logic.com/");
+ auto input = cWebsiteMacro;
+ auto len = StrLen(cWebsiteMacro);
qr::Qr<ver> encoder;
qr::QrDelegate encoderDelegate;
- encoder.encode(str, len, ecc, 0); // Manual mask 0
+ encoder.encode(input, len, ecc, 0); // Manual mask 0
- /// tell delegate to draw encoded QR.
- encoderDelegate.draw<ver>(encoder, (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) - 20,
- (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) / 2);
+ constexpr auto whereX = 10;
+ constexpr auto whereY = 10;
-#endif // ifdef __NEWBOOT__
+ /// tell delegate to draw encoded QR.
+ encoderDelegate.draw<ver>(encoder, whereX,
+ whereY);
EFI::Stop();
+#endif // ifdef __NEWBOOT__
}
} // namespace EFI