summaryrefslogtreecommitdiffhomepage
path: root/src/boot/modules/MemoryTest
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-27 10:22:39 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-27 10:22:39 +0100
commit9937bcb03d4b3c3e71c33786349d4a41203550c0 (patch)
treebdccb35393863256ab0fc806836173c9a7bd50cf /src/boot/modules/MemoryTest
parent0fece463b13c0b6982ceb1be3e26c12444b1cb9e (diff)
[FEAT] kernel: Fix SysChk, add MemoryTest, fix BootThread class.HEADdevelop
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/boot/modules/MemoryTest')
-rw-r--r--src/boot/modules/MemoryTest/MemoryTest.cpp30
-rw-r--r--src/boot/modules/MemoryTest/MemoryTestStartup.S24
-rw-r--r--src/boot/modules/MemoryTest/README.md3
-rw-r--r--src/boot/modules/MemoryTest/amd64.json35
-rw-r--r--src/boot/modules/MemoryTest/arm64.json35
5 files changed, 127 insertions, 0 deletions
diff --git a/src/boot/modules/MemoryTest/MemoryTest.cpp b/src/boot/modules/MemoryTest/MemoryTest.cpp
new file mode 100644
index 00000000..49f28dcb
--- /dev/null
+++ b/src/boot/modules/MemoryTest/MemoryTest.cpp
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
+// Licensed under the Apache License, Version 2.0 (see LICENSE file)
+// Official repository: https://github.com/ne-foss-org/nekernel
+
+#include <BootKit/BootKit.h>
+#include <BootKit/BootThread.h>
+#include <FirmwareKit/EFI/API.h>
+
+EXTERN_C Int32 MemoryTestModuleMain(Kernel::HEL::BootInfoHeader* handover) {
+ fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[Kernel::HEL::kHandoverTableST]);
+
+ Boot::BootTextWriter writer;
+ writer.Write("MemoryTest: Testing Memory...\r");
+
+ constexpr auto kTestValue = 0x20000000L;
+
+ Int32* mem = (Int32*) kTestValue;
+ if (!mem) return kEfiFail;
+
+ auto prev = *mem;
+ *mem = 42;
+ if (*mem != 42) {
+ return kEfiFail;
+ }
+
+ *mem = prev;
+
+ return kEfiOk;
+}
diff --git a/src/boot/modules/MemoryTest/MemoryTestStartup.S b/src/boot/modules/MemoryTest/MemoryTestStartup.S
new file mode 100644
index 00000000..a5832ee6
--- /dev/null
+++ b/src/boot/modules/MemoryTest/MemoryTestStartup.S
@@ -0,0 +1,24 @@
+;; /*
+;; * ========================================================
+;; *
+;; * BootZ
+;; * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+;; *
+;; * ========================================================
+;; */
+
+#ifdef __NE_AMD64__
+.code64
+.intel_syntax noprefix
+#endif
+
+#define kTypeDriver 101
+#define kArchAmd64 122
+#define kHandoverMagic 0xBADCC
+
+.section .ldr
+
+.quad kHandoverMagic
+.word kTypeDriver
+.word 0
+.word kArchAmd64 \ No newline at end of file
diff --git a/src/boot/modules/MemoryTest/README.md b/src/boot/modules/MemoryTest/README.md
new file mode 100644
index 00000000..fac97400
--- /dev/null
+++ b/src/boot/modules/MemoryTest/README.md
@@ -0,0 +1,3 @@
+# MemoryTest:
+
+This module tests the memory of a x64 machine by allocating to it.
diff --git a/src/boot/modules/MemoryTest/amd64.json b/src/boot/modules/MemoryTest/amd64.json
new file mode 100644
index 00000000..8d1f8bd3
--- /dev/null
+++ b/src/boot/modules/MemoryTest/amd64.json
@@ -0,0 +1,35 @@
+{
+ "compiler_path": "x86_64-w64-mingw32-g++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../",
+ "../../",
+ "../../../kernel",
+ "../../../",
+ "./"
+ ],
+ "sources_path": [
+ "*.cpp",
+ "*.S",
+ "../../src/HEL/AMD64/*.cpp",
+ "../../src/HEL/AMD64/*.S",
+ "../../src/*.cpp"
+ ],
+ "output_name": "memtest.efi",
+ "compiler_flags": [
+ "-nostdlib",
+ "-std=c++20",
+ "-fno-rtti",
+ "-fno-exceptions",
+ "-Wl,--subsystem=17,--image-base,0x20000000,-e,MemoryTestModuleMain"
+ ],
+ "cpp_macros": [
+ "__BOOTZ__",
+ "__BOOTZ_STANDALONE__",
+ "__NE_AMD64__",
+ "__nekernel_max_cores=8 ",
+ "kMemTestVersionHighest=0x0100",
+ "kMemTestVersionLowest=0x0100",
+ "kMemTestEFIVersion=0x0100"
+ ]
+}
diff --git a/src/boot/modules/MemoryTest/arm64.json b/src/boot/modules/MemoryTest/arm64.json
new file mode 100644
index 00000000..41590bb4
--- /dev/null
+++ b/src/boot/modules/MemoryTest/arm64.json
@@ -0,0 +1,35 @@
+{
+ "compiler_path": "x86_64-w64-mingw32-g++",
+ "compiler_std": "c++20",
+ "headers_path": [
+ "../",
+ "../../",
+ "../../../kernel",
+ "../../../",
+ "./"
+ ],
+ "sources_path": [
+ "*.cpp",
+ "*.S",
+ "../../src/HEL/ARM64/*.cpp",
+ "../../src/HEL/ARM64/*.S",
+ "../../src/*.cpp"
+ ],
+ "output_name": "memtest.efi",
+ "compiler_flags": [
+ "-nostdlib",
+ "-std=c++20",
+ "-fno-rtti",
+ "-fno-exceptions",
+ "-Wl,--subsystem=17,--image-base,0x20000000,-e,MemoryTestModuleMain"
+ ],
+ "cpp_macros": [
+ "__BOOTZ__",
+ "__BOOTZ_STANDALONE__",
+ "__NE_ARM64__",
+ "__nekernel_max_cores=8 ",
+ "kMemTestVersionHighest=0x0100",
+ "kMemTestVersionLowest=0x0100",
+ "kMemTestEFIVersion=0x0100"
+ ]
+}