From 9097561c8754c5e9f49a8b0f346de081b3c3bd94 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 10 Mar 2026 18:10:38 +0100 Subject: [CHORE] Add DDK testing, AsciiUtils tweaks, proof organization. Signed-off-by: Amlal El Mahrouss --- proofs/Kernel/HeapMgr.v | 10 ---------- proofs/Memory/HeapMgr.v | 10 ++++++++++ src/kernel/src/AsciiUtils.cpp | 9 +++++++-- src/libDDK/src/Allocator.cpp | 10 +++------- src/libSoundSystem/SoundSystemKit/VirtualMixer.h | 8 ++++---- test/kernel_tests/libddk_tests/Makefile | 22 ++++++++++++++++++++++ tools/kconf.py | 3 ++- 7 files changed, 48 insertions(+), 24 deletions(-) delete mode 100644 proofs/Kernel/HeapMgr.v create mode 100644 proofs/Memory/HeapMgr.v create mode 100644 test/kernel_tests/libddk_tests/Makefile diff --git a/proofs/Kernel/HeapMgr.v b/proofs/Kernel/HeapMgr.v deleted file mode 100644 index a709888e..00000000 --- a/proofs/Kernel/HeapMgr.v +++ /dev/null @@ -1,10 +0,0 @@ -(* - The HeapMgr, formally proven. - - Author: Amlal El Mahrouss - Formalization: March 2026 -*) - -From Coq Require Import Logic.Classical_Prop. - - diff --git a/proofs/Memory/HeapMgr.v b/proofs/Memory/HeapMgr.v new file mode 100644 index 00000000..a709888e --- /dev/null +++ b/proofs/Memory/HeapMgr.v @@ -0,0 +1,10 @@ +(* + The HeapMgr, formally proven. + + Author: Amlal El Mahrouss + Formalization: March 2026 +*) + +From Coq Require Import Logic.Classical_Prop. + + diff --git a/src/kernel/src/AsciiUtils.cpp b/src/kernel/src/AsciiUtils.cpp index 697739a5..c063ef11 100644 --- a/src/kernel/src/AsciiUtils.cpp +++ b/src/kernel/src/AsciiUtils.cpp @@ -1,4 +1,4 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// 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 @@ -27,8 +27,11 @@ Size rt_string_len(const Char* ptr) { const Char* rt_alloc_string(const Char* src) { SizeT slen = rt_string_len(src); Char* buffer = new Char[slen + 1]; + if (!buffer) return nullptr; + rt_set_memory(buffer, 0, slen); + if (rt_copy_memory_safe(reinterpret_cast(const_cast(src)), reinterpret_cast(buffer), slen, slen + 1) < 0) { delete[] buffer; @@ -100,7 +103,9 @@ Int32 rt_to_lower(Int ch) { } Int32 rt_is_alnum(Int ch) { - return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'); + return (ch >= 'a' && ch <= 'z') || + (ch >= 'A' && ch <= 'Z') || + (ch >= '0' && ch <= '9'); } Boolean rt_is_space(Int ch) { diff --git a/src/libDDK/src/Allocator.cpp b/src/libDDK/src/Allocator.cpp index b8bc6b4c..1122e310 100644 --- a/src/libDDK/src/Allocator.cpp +++ b/src/libDDK/src/Allocator.cpp @@ -1,10 +1,6 @@ -/* ======================================== - - Copyright Amlal El Mahrouss. - - Purpose: DDK allocator. - -======================================== */ +// 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 diff --git a/src/libSoundSystem/SoundSystemKit/VirtualMixer.h b/src/libSoundSystem/SoundSystemKit/VirtualMixer.h index e57ff29b..b6918f5a 100644 --- a/src/libSoundSystem/SoundSystemKit/VirtualMixer.h +++ b/src/libSoundSystem/SoundSystemKit/VirtualMixer.h @@ -9,9 +9,9 @@ #include namespace SoundSystem { - struct VirtualMixer; - struct VirtualSource; - struct VirtualVolume; -} +struct VirtualMixer; +struct VirtualSource; +struct VirtualVolume; +} // namespace SoundSystem #endif diff --git a/test/kernel_tests/libddk_tests/Makefile b/test/kernel_tests/libddk_tests/Makefile new file mode 100644 index 00000000..a2bb9d4f --- /dev/null +++ b/test/kernel_tests/libddk_tests/Makefile @@ -0,0 +1,22 @@ +################################################## +# (c) Amlal El Mahrouss and NeKernel Authors, licensed under the Apache 2.0 license. +# This file is for libsystem testing. +################################################## + +GCC=x86_64-w64-mingw32-g++ -Wl,-subsystem=17 +LIB=-L../../src/libSystem -lSystem +STD=-std=c++20 -DKT_TESTING_ENABLED +INCLUDE=-I../../src -I../../public -I../../public/frameworks/ -I../../ + +OBJ_FILES = \ + thread.test.exe \ + memory.test.exe \ + io.test.exe + +.PHONY: all +all: $(OBJ_FILES) + +%.exe: %.cc + @echo "==> Building test: $@" + $(GCC) $(LIB) $< \ + $(STD) $(INCLUDE) -o $(basename $<).exe \ No newline at end of file diff --git a/tools/kconf.py b/tools/kconf.py index f6403aee..910c7287 100755 --- a/tools/kconf.py +++ b/tools/kconf.py @@ -4,7 +4,8 @@ import os, json, sys if __name__ == '__main__': - print("kconf: running config script...") + print("kconf: running kernel as standalone...") + os.system("../script/debug_ahci_x64.sh") sys.exit(0) -- cgit v1.2.3