summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-18 09:04:13 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-18 09:04:13 +0100
commited6d2f6007b572b907e3cb11b4303c13d1572c9c (patch)
tree47f177336db980a138a91a2fb109db8f1a65086c
parent3a5c7473910156051951f8ec98488a6c91a3eabd (diff)
chore: specification updates and patches on the DDK, new source `ddk_c++.cc`.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--docs/specs/SPECIFICATION_FWRK.md16
-rw-r--r--docs/specs/SPECIFICATION_MBCI.md6
-rw-r--r--docs/specs/SPECIFICATION_OS.md (renamed from docs/specs/SPECIFICATION_KERNEL.md)15
-rw-r--r--docs/tex/NOTICE.md6
-rw-r--r--src/boot/src/BootThread.cc11
-rw-r--r--src/kernel/NeKit/Atom.h24
-rw-r--r--src/kernel/NeKit/InitializerList.h25
-rw-r--r--src/libDDK/DriverKit/c++/driver_base.h15
-rw-r--r--src/libDDK/src/ddk_c++.cc9
9 files changed, 78 insertions, 49 deletions
diff --git a/docs/specs/SPECIFICATION_FWRK.md b/docs/specs/SPECIFICATION_FWRK.md
index b506b266..8d95abc7 100644
--- a/docs/specs/SPECIFICATION_FWRK.md
+++ b/docs/specs/SPECIFICATION_FWRK.md
@@ -9,15 +9,17 @@
===================================
-# 1: The specification
+# 1: The specification:
===================================
-## Overview
-
The NeKernel framework system (`.fwrk`) provides a standardized structure for creating modular, reusable libraries and components. Frameworks are self-contained packages that include headers, source code, metadata, and configuration for compilation and deployment within the NeKernel ecosystem.
-## Framework Directory Structure
+==================================
+
+# 2: Framework Directory Structure:
+
+==================================
Each framework follows the standardized directory layout below:
@@ -38,7 +40,11 @@ Each framework follows the standardized directory layout below:
└── .keep # Placeholder file
```
-## Component Specifications
+================================
+
+# 3: Component Specifications
+
+================================
### 1. Framework Manifest (`<FrameworkName>.json`)
diff --git a/docs/specs/SPECIFICATION_MBCI.md b/docs/specs/SPECIFICATION_MBCI.md
index 63452a85..648529cf 100644
--- a/docs/specs/SPECIFICATION_MBCI.md
+++ b/docs/specs/SPECIFICATION_MBCI.md
@@ -1,6 +1,6 @@
===================================
-# 0: General Information
+# 0: General Information:
===================================
@@ -10,7 +10,7 @@
===================================
-# 1: Concepts
+# 1: Concepts:
===================================
@@ -20,7 +20,7 @@
===================================
-# 2: Pinout
+# 2: Pinout:
===================================
diff --git a/docs/specs/SPECIFICATION_KERNEL.md b/docs/specs/SPECIFICATION_OS.md
index fe2cb9da..313ba342 100644
--- a/docs/specs/SPECIFICATION_KERNEL.md
+++ b/docs/specs/SPECIFICATION_OS.md
@@ -1,6 +1,6 @@
===================================
-# 0: General Information
+# 0: General Information:
===================================
@@ -17,7 +17,7 @@
- Drive/Device Abstraction.
- SMP, Preemptive Multi Threading.
- Separation of Files/Devices.
-- Networking.
+- Networking Support.
- Hardware Abstraction Layer.
- Native Filesystem support (NeFS, FAT32 and ffs2).
- Program Loaders interfaces.
@@ -27,10 +27,11 @@
- Dynamic Loader.
- Cross Platform.
- Permission Selectors.
+- Modular, and Security focused.
===================================
-# 2: The Filesystem (NeFS)
+# 2: The Filesystem (NeFS, OpenHeFS)
===================================
@@ -42,7 +43,7 @@
==================================
-# 3: Common naming conventions:
+# 3: Common conventions:
==================================
@@ -50,8 +51,7 @@
- RunTime -> rt_copy_mem
- Hal -> hal_foo_bar
- Class methods -> Class::FooBar
-
-Internals function shall be formated as such: (hali, rtli, rti...)
+- Internals function shall be formated as such: (hali, rtli, rti...)
===================================
@@ -60,7 +60,8 @@ Internals function shall be formated as such: (hali, rtli, rti...)
===================================
- Capable of booting from a network drive.
-- Loads a PE file which is the Kernel.
+- Loads a PE file which is the Kernel, or any modules.
- Sanity checks, based on the number of sections.
- Handover compliant.
- Does check for a valid partition (useful in the case of recovering)
+- Modular, and Security focused.
diff --git a/docs/tex/NOTICE.md b/docs/tex/NOTICE.md
index a556bfef..23417d2a 100644
--- a/docs/tex/NOTICE.md
+++ b/docs/tex/NOTICE.md
@@ -1,8 +1,8 @@
-# Notice
+# Notice: NeKernel specifications.
-## CoreProcessScheduler has moved!
+## Notice: CoreProcessScheduler paper.
-The CPS is now part of WG02, for more information clone the following repository: [https://github.com/nekernel-org/draft](https://github.com/nekernel-org/draft).
+The CPS has been moved to WG02,for more information, clone the following repository: [https://github.com/nekernel-org/draft](https://github.com/nekernel-org/draft).
## Recommended:
diff --git a/src/boot/src/BootThread.cc b/src/boot/src/BootThread.cc
index 336c5f9e..7d3beba8 100644
--- a/src/boot/src/BootThread.cc
+++ b/src/boot/src/BootThread.cc
@@ -15,6 +15,7 @@
#include <KernelKit/PEF.h>
#include <modules/CoreGfx/TextGfx.h>
+// \brief This macro defines the maximum size of a image's stack.
#define kBootThreadSz mib_cast(16)
/// @brief External boot services symbol.
@@ -26,9 +27,8 @@ namespace Boot {
EXTERN_C Int32 rt_jump_to_address(VoidPtr code, HEL::BootInfoHeader* handover, UInt8* stack);
BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) {
- // detect the format.
- const Char* blob_bytes = reinterpret_cast<char*>(fBlob);
-
+ // detect the image format (PEF, PE32, etc.)
+ const Char* blob_bytes = static_cast<Char*>(fBlob);
BootTextWriter writer;
if (!blob_bytes) {
@@ -151,11 +151,12 @@ BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) {
blob_bytes[2] == kPefMagic[2] && blob_bytes[3] == kPefMagic[3]) {
// ========================================= //
// PEF executable has been detected.
+ // This is stricly firmware level, by convention we only accept PE32+ here.
// ========================================= //
fStartAddress = nullptr;
- writer.Write("BootZ: PEF executable detected, won't load it.\r");
+ writer.Write("BootZ: PEF executable detected, BootZ won't load it.\r");
writer.Write("BootZ: note: PEF executables aren't supported for now.\r");
} else {
writer.Write("BootZ: Invalid Executable.\r");
@@ -215,4 +216,4 @@ Void BootThread::SetName(const Char* name) {
bool BootThread::IsValid() {
return fStartAddress != nullptr;
}
-} // namespace Boot \ No newline at end of file
+} // namespace Boot
diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h
index 7c4ebb5b..7deff14e 100644
--- a/src/kernel/NeKit/Atom.h
+++ b/src/kernel/NeKit/Atom.h
@@ -3,12 +3,14 @@
Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
======================================== */
-#pragma once
+
+#ifndef __NE_KIT_ATOM_H__
+#define __NE_KIT_ATOM_H__
#include <NeKit/Config.h>
namespace Kernel {
-template <typename T>
+template <class TypeAtomic>
class Atom final {
public:
explicit Atom() = default;
@@ -19,15 +21,19 @@ class Atom final {
Atom(const Atom&) = delete;
public:
- T operator[](Size bit) { return (fArrayOfAtoms & (1 << bit)); }
-
- void operator|(Size bit) { fArrayOfAtoms |= (1 << bit); }
+ using Type = TypeAtomic;
+
+ const TypeAtomic& operator[](const SizeT& bit) { return (fArrayOfAtoms & (1 << bit)); }
- friend Boolean operator==(Atom<T>& atomic, const T& idx) { return atomic[idx] == idx; }
-
- friend Boolean operator!=(Atom<T>& atomic, const T& idx) { return atomic[idx] != idx; }
+ void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); }
+ Atom& operator|=(const SizeT& bit) { this->operator|(bit); return *this; }
+
+ friend bool operator==(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] == idx; }
+ friend bool operator!=(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] != idx; }
private:
- T fArrayOfAtoms;
+ TypeAtomic fArrayOfAtoms;
};
} // namespace Kernel
+
+#endif
diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h
index d918ba85..46639d4d 100644
--- a/src/kernel/NeKit/InitializerList.h
+++ b/src/kernel/NeKit/InitializerList.h
@@ -1,19 +1,23 @@
/* ========================================
- Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
======================================== */
-#pragma once
+#ifndef __NE_KIT_INIT_LIST_H__
+#define __NE_KIT_INIT_LIST_H__
#include <NeKit/Config.h>
#include <NeKit/ErrorOr.h>
namespace Kernel {
-template <class T, SizeT N>
+ // \brief Initalizer List object for containers.
+template <class Type, SizeT N>
class InitializerList final {
public:
- explicit InitializerList(const T* list) {
+ InitializerList() = delete;
+
+ explicit InitializerList(const Type* list) {
if constexpr (N > 0) {
for (auto i = 0UL; i < N; ++i) {
fList[i] = list[i];
@@ -26,17 +30,20 @@ class InitializerList final {
InitializerList& operator=(const InitializerList&) = delete;
InitializerList(const InitializerList&) = delete;
- T* begin() { return fList; }
- T* end() { return fList + N; }
+ Type* begin() { return fList; }
+ Type* end() { return fList + N; }
+
constexpr SizeT size() const { return N; }
- T* operator->() { return fList; }
- T* operator*() { return fList; }
+ Type* operator->() { return this->begin(); }
+ Type* operator*() { return this->begin(); }
private:
- T fList[N];
+ Type fList[N];
};
template <class T, SizeT N>
using ErrorOrList = ErrorOr<InitializerList<T, N>>;
} // namespace Kernel
+
+#endif
diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h
index f43ae0bf..683969f3 100644
--- a/src/libDDK/DriverKit/c++/driver_base.h
+++ b/src/libDDK/DriverKit/c++/driver_base.h
@@ -3,13 +3,12 @@
Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
FILE: driver_base.h
- PURPOSE: IDriverBase and friends.
+ PURPOSE: C++ Driver Wrapper.
======================================== */
#pragma once
-#include <CompilerKit/CompilerKit.h>
#include <libDDK/DriverKit/macros.h>
#define DDK_DRIVER_IMPL \
@@ -30,12 +29,12 @@ class IDriverBase {
NE_COPY_DELETE(IDriverBase);
NE_MOVE_DEFAULT(IDriverBase);
- using PtrType = VoidPtr;
+ using PtrType = void*;
- virtual constexpr BOOL IsCastable() { return NO; }
- virtual constexpr BOOL IsActive() { return NO; }
+ virtual constexpr bool IsCastable() { return false; }
+ virtual constexpr bool IsActive() { return false; }
virtual PtrType Leak() { return nullptr; }
- virtual constexpr Int32 Type() { return kInvalidType; }
+ virtual constexpr int32_t Type() { return kInvalidType; }
};
/// @brief This concept requires the Driver to be IDriverBase compliant.
@@ -46,6 +45,6 @@ concept IsValidDriver = requires(Driver driver_base) {
/// @brief Consteval helper to detect whether a template is truly based on IDriverBase.
/// @note This helper is consteval only.
-template <IsValidDriver T>
-consteval void ce_ddk_is_valid(T) {}
+template <class Driver>
+inline bool ce_ddk_is_valid(Driver drv) { return IsValidDriver<Driver>(drv); }
} // namespace Kernel::DDK
diff --git a/src/libDDK/src/ddk_c++.cc b/src/libDDK/src/ddk_c++.cc
new file mode 100644
index 00000000..920697ac
--- /dev/null
+++ b/src/libDDK/src/ddk_c++.cc
@@ -0,0 +1,9 @@
+/* ========================================
+
+ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#include <libDDK/DriverKit/c++/driver_base.h>
+
+