summaryrefslogtreecommitdiffhomepage
path: root/Private/FirmwareKit
diff options
context:
space:
mode:
Diffstat (limited to 'Private/FirmwareKit')
-rw-r--r--Private/FirmwareKit/EFI/API.hxx46
-rw-r--r--Private/FirmwareKit/EPM.hxx12
-rw-r--r--Private/FirmwareKit/Handover.hxx9
3 files changed, 51 insertions, 16 deletions
diff --git a/Private/FirmwareKit/EFI/API.hxx b/Private/FirmwareKit/EFI/API.hxx
index 536d12c8..0e2ef200 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;
@@ -54,21 +61,23 @@ enum {
inline UInt32 Platform() noexcept { return kPEMachineAMD64; }
/***
- * @brief Raise Hard kernel error.
+ * @brief Throw an error, stop execution as well.
+ * @param ErrorCode error code to be print.
+ * @param Reason reason to be print.
*/
-inline void RaiseHardError(const EfiCharType *ErrorCode,
+inline void ThrowError(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 +87,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 = 4;
+ auto ecc = qr::Ecc::H;
+ auto str = "https://el-mahrouss-logic.com/";
+ auto len = BStrLen(L"https://el-mahrouss-logic.com/");
+
+ qr::Qr<ver> encoder;
+ qr::QrDelegate encoderDelegate;
+
+ encoder.encode(str, 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);
+
+#endif // ifdef __NEWBOOT__
EFI::Stop();
}
diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx
index b7f77742..3b3585be 100644
--- a/Private/FirmwareKit/EPM.hxx
+++ b/Private/FirmwareKit/EPM.hxx
@@ -29,6 +29,7 @@ typedef struct BlockGUID {
/**
* @brief The EPM bootloader block.
+ * @note NumBlock and LbaStart are ignored on UEFI.
*/
struct PACKED BootBlock {
NewOS::Char Magic[kEPMMagicLength];
@@ -42,7 +43,7 @@ struct PACKED BootBlock {
/**
* @brief The EPM partition block.
- * used to describe a partition inside a media.
+ * used to describe a partition inside a media, doesn't exist on uefi.
*/
struct PACKED PartitionBlock {
NewOS::Char Name[kEPMNameLength];
@@ -75,6 +76,10 @@ struct PACKED PartitionBlock {
#define kEPMMagicPPC "EPMPC"
+/* @brief UEFI magic for EPM */
+
+#define kEPMMagicUEFI "EPMUE"
+
/* @brief Invalid magic for EPM */
#define kEPMMagicError "EPM??"
@@ -109,7 +114,10 @@ typedef struct PartitionBlock PartitionBlockType;
#define kEPMStartPartitionBlk (0)
///! @brief Current EPM revision (2)
-#define kEPMRevision (21)
+#define kEPMRevision (2)
+
+///! @brief Current EPM revision (2)
+#define kEPMRevisionUEFI (0xF)
/// END SPECS
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