summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-05 14:50:32 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-05 14:50:32 +0200
commita974f2b8861bfd60613d1bf441f77a5aa0c6f76a (patch)
tree19ef849b3d1bb785519a7998f13ceb0e30b0b079
parentcc03f40d9fb1d68bfd945284a3ff5067dfd8475a (diff)
[IMP] QR code on ke_stop screen instead of bootscreen.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
-rw-r--r--Boot/BootKit/Support.hxx4
-rw-r--r--Boot/BootKit/Vendor/Qr.hxx9
-rw-r--r--Kernel/FirmwareKit/EFI/API.hxx23
-rw-r--r--Kernel/HALKit/POWER/Hart.hxx8
-rw-r--r--Kernel/Sources/KernelCheck.cxx38
-rw-r--r--Kernel/Sources/Utils.cxx5
-rw-r--r--Kernel/amd64-efi.make4
7 files changed, 50 insertions, 41 deletions
diff --git a/Boot/BootKit/Support.hxx b/Boot/BootKit/Support.hxx
index 4acffb75..95052435 100644
--- a/Boot/BootKit/Support.hxx
+++ b/Boot/BootKit/Support.hxx
@@ -12,12 +12,16 @@
#define cLongMax ((long)(~0UL >> 1))
#define cLongMin (~cLongMax)
+#ifdef __NEWOSLDR__
+
#define SetMem(dst, c, sz) memset(dst, c, sz)
#define MoveMem(dst, src, sz) memcpy(dst, src, sz)
#define CopyMem(dst, src, sz) memcpy(dst, src, sz)
#define StrLen(src) strlen(src)
#define StrCmp(dst, src) strcmp(dst, src)
+#endif // __NEWOSLDR__
+
inline int IsSpace(int c)
{
return c == ' ';
diff --git a/Boot/BootKit/Vendor/Qr.hxx b/Boot/BootKit/Vendor/Qr.hxx
index 365cd7d1..e7d82547 100644
--- a/Boot/BootKit/Vendor/Qr.hxx
+++ b/Boot/BootKit/Vendor/Qr.hxx
@@ -2,17 +2,20 @@
#define QR_HXX
extern "C" {
+
#include <math.h>
#include <stddef.h>
#include <stdint.h>
+
}
#include <BootKit/Vendor/Shared/base.h>
#include <BootKit/Vendor/Shared/bit.h>
#include <BootKit/Vendor/QrPrelude.hxx>
-#include <Modules/CoreCG/FbRenderer.hxx>
#include <BootKit/Support.hxx>
+
+#include <Modules/CoreCG/FbRenderer.hxx>
#include <CompilerKit/Detail.hxx>
/// @note the QR code is still code 128, it utilizes the same concept of having it's own character set.
@@ -202,7 +205,7 @@ namespace qr
}
// Reed-Solomon Ecc generator polynomial for the given degree.
- constexpr void gf_gen_poly(int degree, uint8_t* poly)
+ inline void gf_gen_poly(int degree, uint8_t* poly)
{
SetMem(poly, 0, degree);
@@ -218,7 +221,7 @@ namespace qr
}
// Polynomial division if Galois Field.
- constexpr void gf_poly_div(uint8_t* dividend, size_t len, uint8_t* divisor, int degree, uint8_t* result)
+ inline void gf_poly_div(uint8_t* dividend, size_t len, uint8_t* divisor, int degree, uint8_t* result)
{
SetMem(result, 0, degree);
diff --git a/Kernel/FirmwareKit/EFI/API.hxx b/Kernel/FirmwareKit/EFI/API.hxx
index 2883ee13..1466bdd1 100644
--- a/Kernel/FirmwareKit/EFI/API.hxx
+++ b/Kernel/FirmwareKit/EFI/API.hxx
@@ -16,8 +16,6 @@
// forward decl.
class BTextWriter;
-#define cWebsiteMacro "https://zka-tech.nl/hulp"
-
#define __BOOTKIT_NO_INCLUDE__ 1
#include <BootKit/BootKit.hxx>
@@ -88,28 +86,7 @@ Bascially frees everything we have in the EFI side.
ST->ConOut->OutputString(ST->ConOut, L" ***\r");
-#ifdef __NEWOSLDR__
- // Show the QR code now.
-
- constexpr auto cVer = 4;
- const auto cECC = qr::Ecc::H;
- const auto cInput = cWebsiteMacro;
- const auto cInputLen = StrLen(cWebsiteMacro);
-
- qr::Qr<cVer> encoder;
- qr::QrDelegate encoderDelegate;
-
- encoder.encode(cInput, cInputLen, cECC, 0); // Manual mask 0
-
- const auto cWhereStartX = (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) - 20;
- const auto cWhereStartY = (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) / 2;
-
- // tell delegate to draw encoded QR now.
- encoderDelegate.draw<cVer>(encoder, cWhereStartX,
- cWhereStartY);
-
EFI::Stop();
-#endif // ifdef __NEWOSLDR__
}
} // namespace EFI
diff --git a/Kernel/HALKit/POWER/Hart.hxx b/Kernel/HALKit/POWER/Hart.hxx
index a6000953..4839260c 100644
--- a/Kernel/HALKit/POWER/Hart.hxx
+++ b/Kernel/HALKit/POWER/Hart.hxx
@@ -15,20 +15,22 @@
#include <NewKit/Defines.hxx>
+struct HAL_HARDWARE_THREAD;
+
/// @brief hardware thread indentification type.
typedef Kernel::Int32 PPCHartType;
/// @brief Hardware thread information structure.
-typedef struct HalHardwareThread
+typedef struct HAL_HARDWARE_THREAD
{
Kernel::UIntPtr fStartAddress;
Kernel::UInt8 fPrivleged : 1;
Kernel::UInt32 fPageFlags;
PPCHartType fIdentNumber;
-} HalHardwareThread;
+} HAL_HARDWARE_THREAD;
/// @brief Set PC to specific hart.
/// @param hart the hart
/// @param epc the pc.
/// @return
-EXTERN_C Kernel::Void hal_set_pc_to_hart(HalHardwareThread* hart, Kernel::VoidPtr epc);
+EXTERN_C Kernel::Void hal_set_pc_to_hart(HAL_HARDWARE_THREAD* hart, Kernel::VoidPtr epc);
diff --git a/Kernel/Sources/KernelCheck.cxx b/Kernel/Sources/KernelCheck.cxx
index 900bbf6e..0fcc742f 100644
--- a/Kernel/Sources/KernelCheck.cxx
+++ b/Kernel/Sources/KernelCheck.cxx
@@ -15,14 +15,17 @@
#include <Modules/CoreCG/FbRenderer.hxx>
#include <Modules/CoreCG/TextRenderer.hxx>
-EXTERN_C Kernel::Void ke_wait_for_debugger()
-{
+#define SetMem(dst, byte, sz) Kernel::rt_set_memory((Kernel::VoidPtr)dst, byte, sz)
+#define CopyMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz)
+#define MoveMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz)
-}
+#include <BootKit/Vendor/Qr.hxx>
/* Each error code is attributed with an ID, which will prompt a string onto the
* screen. Wait for debugger... */
+#define cWebsiteMacro "https://zka-tech.nl/hulp"
+
namespace Kernel
{
void ke_stop(const Kernel::Int& id)
@@ -37,10 +40,29 @@ namespace Kernel
auto start_y = 10;
auto x = 10;
- cg_write_text("*** Kernel panic! ***\rnewoskrnl.dll stopped working properly so we had to shut it down.", start_y, x, panicTxt);
+ cg_write_text("*** Kernel panic! ***\rnewoskrnl.lib stopped working properly so we had to shut it down.", start_y, x, panicTxt);
CGFini();
+ // Show the QR code now.
+
+ constexpr auto cVer = 4;
+ const auto cECC = qr::Ecc::H;
+ const auto cInput = cWebsiteMacro;
+ const auto cInputLen = rt_string_len(cWebsiteMacro);
+
+ qr::Qr<cVer> encoder;
+ qr::QrDelegate encoderDelegate;
+
+ encoder.encode(cInput, cInputLen, cECC, 0); // Manual mask 0
+
+ const auto cWhereStartX = (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) - 20;
+ const auto cWhereStartY = (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) / 2;
+
+ // tell delegate to draw encoded QR now.
+ encoderDelegate.draw<cVer>(encoder, cWhereStartX,
+ cWhereStartY);
+
// ******* //
// shows in debug only.
// ******* //
@@ -112,10 +134,6 @@ namespace Kernel
Void RecoveryFactory::Recover() noexcept
{
-#ifdef __DEBUG__
- ke_wait_for_debugger();
-#endif // ifdef __DEBUG__
-
PowerFactoryInterface powerInterface(kHandoverHeader->f_HardwareTables.f_VendorPtr);
powerInterface.Shutdown();
}
@@ -126,8 +144,8 @@ namespace Kernel
if (!expr)
{
#ifdef __DEBUG__
- kcout << "newoskrnl: File: " << file << "\r";
- kcout << "newoskrnl: Line: " << line << "\r";
+ kcout << "newoskrnl: FILE: " << file << "\r";
+ kcout << "newoskrnl: LINE: " << line << "\r";
#endif // __DEBUG__
diff --git a/Kernel/Sources/Utils.cxx b/Kernel/Sources/Utils.cxx
index 6eaa7757..a8b3f00a 100644
--- a/Kernel/Sources/Utils.cxx
+++ b/Kernel/Sources/Utils.cxx
@@ -66,6 +66,7 @@ namespace Kernel
{
if (!src || len < 1)
return nullptr;
+
char* start = reinterpret_cast<Char*>(src);
while (len)
@@ -210,6 +211,8 @@ namespace Kernel
}
} // namespace Kernel
+#ifdef __FREESTANDING__
+
////////////////////////////////////////////////////////////////////////////////////////
/// Exported C functions
////////////////////////////////////////////////////////////////////////////////////////
@@ -250,3 +253,5 @@ EXTERN_C Kernel::SizeT strcmp(char* dst, char* src, Kernel::SizeT len)
{
return Kernel::rt_string_cmp(src, dst, len);
}
+
+#endif // __FREESTANDING__ \ No newline at end of file
diff --git a/Kernel/amd64-efi.make b/Kernel/amd64-efi.make
index ce9bcd90..e233ebdc 100644
--- a/Kernel/amd64-efi.make
+++ b/Kernel/amd64-efi.make
@@ -5,9 +5,9 @@
CC = x86_64-w64-mingw32-g++
LD = x86_64-w64-mingw32-ld
-CCFLAGS = -fshort-wchar -c -ffreestanding -shared -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \
+CCFLAGS = -fshort-wchar -c -shared -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \
-std=c++20 -D__NEWOS_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEWFS__ \
- -D__NEWOSKRNL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I./ -I../
+ -D__NEWOSKRNL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I./ -I../ -I../Boot
ASM = nasm