From e3b0df6ae2a5cd1f98400f671c374b5955bd0bcc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 11 Jan 2026 17:48:17 +0100 Subject: chore: kernel: specs fixes and kernel API impl improvements. Signed-off-by: Amlal El Mahrouss --- doc/specs/SPECFICATION_MACROS.md | 13 ------------- doc/specs/SPECIFICATION_FWRK.md | 2 +- doc/specs/SPECIFICATION_MACROS.md | 25 +++++++++++++++++++++++++ src/kernel/KernelKit/TraceSrv.h | 4 +++- src/kernel/NeKit/Atom.h | 9 ++++++--- src/kernel/NeKit/Function.h | 17 ++++++++++------- 6 files changed, 45 insertions(+), 25 deletions(-) delete mode 100644 doc/specs/SPECFICATION_MACROS.md create mode 100644 doc/specs/SPECIFICATION_MACROS.md diff --git a/doc/specs/SPECFICATION_MACROS.md b/doc/specs/SPECFICATION_MACROS.md deleted file mode 100644 index 08c57447..00000000 --- a/doc/specs/SPECFICATION_MACROS.md +++ /dev/null @@ -1,13 +0,0 @@ -# Configuration Macros of NeKernel. - -## NeKernel - -- `__nekernel_max_cores` -> Max SMP cores usable by NeKernel's scheduler. -- `__nekernel_boot_core_index` -> Index of the boot core (0, 1, or 3). -- `__nekernel_allow_non_nekernel_pe` -> Allow non-subsystem 17 to run on NeKernel. - -## KernelTest: - -- `__KT_TEST_MAIN` -> KernelTest entrypoint symbol. -- `KT_TESTING_ENABLED` -> Program is running under testing constraints. - diff --git a/doc/specs/SPECIFICATION_FWRK.md b/doc/specs/SPECIFICATION_FWRK.md index e7366987..6d965ef5 100644 --- a/doc/specs/SPECIFICATION_FWRK.md +++ b/doc/specs/SPECIFICATION_FWRK.md @@ -9,7 +9,7 @@ =================================== -# 1: The specification: +# 1: Specification: =================================== diff --git a/doc/specs/SPECIFICATION_MACROS.md b/doc/specs/SPECIFICATION_MACROS.md new file mode 100644 index 00000000..3b5cdf2d --- /dev/null +++ b/doc/specs/SPECIFICATION_MACROS.md @@ -0,0 +1,25 @@ +=================================== + +# 0: General Information: + +=================================== + +=================================== + +# NeKernel + +=================================== + +- `__nekernel_max_cores` -> Max SMP cores usable by NeKernel's scheduler. +- `__nekernel_boot_core_index` -> Index of the boot core (0, 1, or 3). +- `__nekernel_allow_non_nekernel_pe` -> Allow non-subsystem 17 to run on NeKernel. + +=================================== + +# KernelTest + +=================================== + +- `__KT_TEST_MAIN` -> KernelTest entrypoint symbol. +- `KT_TESTING_ENABLED` -> Program is running under testing constraints. + diff --git a/src/kernel/KernelKit/TraceSrv.h b/src/kernel/KernelKit/TraceSrv.h index 5a9d365c..1118e0d9 100644 --- a/src/kernel/KernelKit/TraceSrv.h +++ b/src/kernel/KernelKit/TraceSrv.h @@ -9,7 +9,8 @@ namespace Kernel { -namespace Detail { +namespace TraceSrv { + inline constexpr auto kDebugCmdLen = 256U; inline constexpr auto kDebugPort = 51820; /// \brief Debug Magic Value @@ -17,6 +18,7 @@ namespace Detail { inline constexpr auto kDebugVersion = 0x0100; inline constexpr auto kDebugDelim = ';'; inline constexpr auto kDebugEnd = '\r'; + } // namespace Detail } // namespace Kernel diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h index 9d6e9f24..3dedea32 100644 --- a/src/kernel/NeKit/Atom.h +++ b/src/kernel/NeKit/Atom.h @@ -1,13 +1,14 @@ -// 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/nekernel-org/nekernel -#ifndef __NE_KIT_ATOM_H__ -#define __NE_KIT_ATOM_H__ +#ifndef NEKIT_ATOM_H +#define NEKIT_ATOM_H #include namespace Kernel { + template class Atom final { public: @@ -24,6 +25,7 @@ class Atom final { const TypeAtomic& operator[](const SizeT& bit) { return (fArrayOfAtoms & (1 << bit)); } void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); } + Atom& operator|=(const SizeT& bit) { this->operator|(bit); return *this; @@ -39,6 +41,7 @@ class Atom final { private: TypeAtomic fArrayOfAtoms; }; + } // namespace Kernel #endif diff --git a/src/kernel/NeKit/Function.h b/src/kernel/NeKit/Function.h index d32c0f46..77d9aa23 100644 --- a/src/kernel/NeKit/Function.h +++ b/src/kernel/NeKit/Function.h @@ -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/nekernel-org/nekernel @@ -9,22 +9,21 @@ #include namespace Kernel { -/// ================================================================================ -/// @brief Function wrapper class. -/// ================================================================================ + +/// @brief Function Pointer Container. template class Function final { public: Function() = delete; Function(nullPtr) = delete; - ~Function() = default; - explicit Function(T (*Fn)(Args... args)) : fFn(Fn) { MUST_PASS(fFn); } + ~Function() = default; + Function(T (*Fn)(Args... args)) : fFn(Fn) { MUST_PASS(fFn); } Function& operator=(const Function&) = delete; Function(const Function&) = delete; - T operator()(Args&&... args) { return fFn(args...); } + T operator()(Args&&... args) { return fFn(forward(args)...); } explicit operator bool() { return fFn; } bool operator!() { return !fFn; } @@ -35,6 +34,10 @@ class Function final { template using FunctionOr = ErrorOr>; + +template +using FunctionRef = Ref>; + } // namespace Kernel #endif -- cgit v1.2.3