summaryrefslogtreecommitdiffhomepage
path: root/Private/FirmwareKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-24 19:57:10 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-24 19:57:10 +0200
commit8153dc983802115951836f2b164af371ee6e3d73 (patch)
treeb06f35ba0d21f6d336b5be7af2a36672ea19fc43 /Private/FirmwareKit
parentf7a7080d18ac2be758b242c22f020c018b1c4824 (diff)
MHR-16: Add QR-code when bootloader crashes alongside other welcomed changes.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/FirmwareKit')
-rw-r--r--Private/FirmwareKit/EFI/API.hxx40
-rw-r--r--Private/FirmwareKit/Handover.hxx9
2 files changed, 37 insertions, 12 deletions
diff --git a/Private/FirmwareKit/EFI/API.hxx b/Private/FirmwareKit/EFI/API.hxx
index 536d12c8..212f3686 100644
--- a/Private/FirmwareKit/EFI/API.hxx
+++ b/Private/FirmwareKit/EFI/API.hxx
@@ -7,16 +7,23 @@
#ifndef __EFI_API__
#define __EFI_API__
-#ifdef __NEWBOOT__
-#include <BootKit/Rsrc/NewBootFatal.rsrc>
-#include <Builtins/Toolbox/Toolbox.hxx>
-#endif // ifdef __NEWBOOT__
-
#include <FirmwareKit/EFI/EFI.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/MSDOS.hpp>
#include <KernelKit/PE.hxx>
+#ifdef __NEWBOOT__
+// forward decl.
+class BTextWriter;
+
+#define __BOOTKIT_NO_INCLUDE__ 1
+
+#include <BootKit/BootKit.hxx>
+#include <BootKit/Rsrc/NewBootFatal.rsrc>
+#include <BootKit/Vendor/Qr.hxx>
+#include <Builtins/Toolbox/Toolbox.hxx>
+#endif // ifdef __NEWBOOT__
+
inline EfiSystemTable *ST = nullptr;
inline EfiBootServices *BS = nullptr;
@@ -58,17 +65,17 @@ inline UInt32 Platform() noexcept { return kPEMachineAMD64; }
*/
inline void RaiseHardError(const EfiCharType *ErrorCode,
const EfiCharType *Reason) noexcept {
+#ifdef __DEBUG__
ST->ConOut->OutputString(ST->ConOut, L"\r\n*** STOP ***\r\n");
ST->ConOut->OutputString(ST->ConOut, L"*** Error: ");
ST->ConOut->OutputString(ST->ConOut, ErrorCode);
-#ifdef __DEBUG__
ST->ConOut->OutputString(ST->ConOut, L", Reason: ");
ST->ConOut->OutputString(ST->ConOut, Reason);
-#endif // ifdef __DEBUG__
ST->ConOut->OutputString(ST->ConOut, L" ***\r\n");
+#endif // ifdef __DEBUG__
#ifdef __NEWBOOT__
ToolboxInitRsrc();
@@ -78,7 +85,24 @@ inline void RaiseHardError(const EfiCharType *ErrorCode,
(kHandoverHeader->f_GOP.f_Height - NEWBOOTFATAL_HEIGHT) / 2);
ToolboxClearRsrc();
-#endif // ifdef __NEWBOOT__
+
+ /// Show the QR code now.
+
+ constexpr auto ver = 7;
+ auto ecc = qr::Ecc::H;
+ auto str = "https://www.mahrouss-logic.com/help";
+ auto len = BStrLen(L"https://www.mahrouss-logic.com/help");
+
+ qr::Qr<ver> encoder;
+ qr::QrDelegate encoderDelegate;
+
+ encoder.encode(str, len, ecc, -1); // Automatic mask.
+
+ /// tell delegate to draw encoded QR.
+ encoderDelegate.draw<ver>(encoder, (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) / 2,
+ (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) - 20);
+
+#endif // ifdef __NEWBOOT__
EFI::Stop();
}
diff --git a/Private/FirmwareKit/Handover.hxx b/Private/FirmwareKit/Handover.hxx
index 5ab19fdf..4131467d 100644
--- a/Private/FirmwareKit/Handover.hxx
+++ b/Private/FirmwareKit/Handover.hxx
@@ -81,10 +81,11 @@ struct HandoverInformationHeader {
} f_GOP;
};
-/**
- @brief Handover Jump Proc
-*/
-typedef void (*HandoverProc)(HandoverInformationHeader* pHandover);
+/// @brief Bootloader main type.
+typedef void (*BootMainKind)(NewOS::HEL::HandoverInformationHeader* handoverInfo);
+
+/// @brief Alias of bootloader main type.
+typedef void (*HandoverProc)(HandoverInformationHeader* handoverInfo);
} // namespace NewOS::HEL