summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--meta/media/ne_logotype.pngbin0 -> 2017517 bytes
-rw-r--r--src/boot/src/BootSupport.cpp19
-rw-r--r--src/kernel/HALKit/AMD64/CxxAbi.cpp5
-rw-r--r--src/kernel/HALKit/AMD64/HalCommonAPI.asm12
-rw-r--r--src/kernel/HALKit/AMD64/HalHandoverStub.asm12
-rw-r--r--src/kernel/HALKit/AMD64/HalInterruptAPI.asm14
-rw-r--r--src/kernel/HALKit/AMD64/HalUtilsAPI.asm12
-rw-r--r--src/kernel/src/FS/Ext2+IFS.cpp31
-rw-r--r--src/launch/launch.json2
10 files changed, 68 insertions, 41 deletions
diff --git a/README.md b/README.md
index ef43c68a..b88c514b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
<!-- Read Me of NeKernel -->
+![Logotype](meta/media/ne_logotype.png)
+
<div align="center">
<h1>
<b>The NeKernel System.</b>
diff --git a/meta/media/ne_logotype.png b/meta/media/ne_logotype.png
new file mode 100644
index 00000000..6ef8bc26
--- /dev/null
+++ b/meta/media/ne_logotype.png
Binary files differ
diff --git a/src/boot/src/BootSupport.cpp b/src/boot/src/BootSupport.cpp
index 4ef887bb..232ac965 100644
--- a/src/boot/src/BootSupport.cpp
+++ b/src/boot/src/BootSupport.cpp
@@ -12,9 +12,26 @@
#include <KernelKit/PE.h>
#ifdef __BOOTZ_STANDALONE__
+
+#define kAtExitMaxDestructors (128U)
+
+typedef struct atexit_func_entry {
+ void(*destructor_func)();
+} atexit_func_entry_t;
+
+typedef long long uarch_t;
+
+atexit_func_entry_t __atexit_funcs[kAtExitMaxDestructors];
+uarch_t __atexit_func_count;
+
/// @note This function is a stub, not implemented by the bootloader as of right now. (AMLALE)
EXTERN_C int atexit(void (*f)()) {
- NE_UNUSED(f);
+ if (__atexit_func_count >= kAtExitMaxDestructors) return 1;
+
+ __atexit_funcs[__atexit_func_count].destructor_func = f;
+
+ __atexit_func_count++;
+
return 0;
}
diff --git a/src/kernel/HALKit/AMD64/CxxAbi.cpp b/src/kernel/HALKit/AMD64/CxxAbi.cpp
index 26192f91..50b6ccf2 100644
--- a/src/kernel/HALKit/AMD64/CxxAbi.cpp
+++ b/src/kernel/HALKit/AMD64/CxxAbi.cpp
@@ -8,8 +8,9 @@
#include <KernelKit/UserProcessScheduler.h>
#include <NeKit/CxxAbi.h>
-atexit_func_entry_t __atexit_funcs[kAtExitMacDestructors];
+#define kAtExitMaxDestructors (128U)
+atexit_func_entry_t __atexit_funcs[kAtExitMaxDestructors];
uarch_t __atexit_func_count;
/// @brief dynamic shared object Handle.
@@ -31,7 +32,7 @@ EXTERN_C void ___chkstk_ms(PtrDiff frame_size) {
}
EXTERN_C int atexit(void (*f)()) {
- if (__atexit_func_count >= kAtExitMacDestructors) return 1;
+ if (__atexit_func_count >= kAtExitMaxDestructors) return 1;
__atexit_funcs[__atexit_func_count].destructor_func = f;
diff --git a/src/kernel/HALKit/AMD64/HalCommonAPI.asm b/src/kernel/HALKit/AMD64/HalCommonAPI.asm
index f571aba7..2202d046 100644
--- a/src/kernel/HALKit/AMD64/HalCommonAPI.asm
+++ b/src/kernel/HALKit/AMD64/HalCommonAPI.asm
@@ -1,11 +1,7 @@
-;; /*
-;; * ========================================================
-;; *
-;; * NeKernel
-;; * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-;; *
-;; * ========================================================
-;; */
+;; // 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
section .text
diff --git a/src/kernel/HALKit/AMD64/HalHandoverStub.asm b/src/kernel/HALKit/AMD64/HalHandoverStub.asm
index b66f52e4..15c3a38b 100644
--- a/src/kernel/HALKit/AMD64/HalHandoverStub.asm
+++ b/src/kernel/HALKit/AMD64/HalHandoverStub.asm
@@ -1,11 +1,7 @@
-;; /*
-;; * ========================================================
-;; *
-;; * NeKernel
-;; * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-;; *
-;; * ========================================================
-;; */
+;; // 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
[bits 64]
diff --git a/src/kernel/HALKit/AMD64/HalInterruptAPI.asm b/src/kernel/HALKit/AMD64/HalInterruptAPI.asm
index ada65474..cdb5ecdd 100644
--- a/src/kernel/HALKit/AMD64/HalInterruptAPI.asm
+++ b/src/kernel/HALKit/AMD64/HalInterruptAPI.asm
@@ -1,13 +1,7 @@
-;; /*
-;; * ---------------------------------------------------
-;; *
-;; * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-;; *
-;; * File: HalInterruptAPI.asm
-;; * Purpose: Interrupt API, redirect raw interrupts into their handlers.
-;; *
-;; * ---------------------------------------------------
-;; */
+;; // 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
[bits 64]
diff --git a/src/kernel/HALKit/AMD64/HalUtilsAPI.asm b/src/kernel/HALKit/AMD64/HalUtilsAPI.asm
index 2a0a5eff..aeb54c50 100644
--- a/src/kernel/HALKit/AMD64/HalUtilsAPI.asm
+++ b/src/kernel/HALKit/AMD64/HalUtilsAPI.asm
@@ -1,11 +1,7 @@
-;; /*
-;; * ========================================================
-;; *
-;; * NeKernel
-;; * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-;; *
-;; * ========================================================
-;; */
+;; // 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
[bits 64]
diff --git a/src/kernel/src/FS/Ext2+IFS.cpp b/src/kernel/src/FS/Ext2+IFS.cpp
index d27aca62..30fb2f0d 100644
--- a/src/kernel/src/FS/Ext2+IFS.cpp
+++ b/src/kernel/src/FS/Ext2+IFS.cpp
@@ -18,11 +18,13 @@
#include <NeKit/Utils.h>
/// @note There's no current maintainer of Ext2, the position is vacant.
+/// @note AMLALE: @0xf00sec has written this driver, and I @amlel-el-mahrouss is currently working on adding triple indirect indices.
+/// @note AMLALE: This driver is too verbose, we need a complete overhaul of it.
constexpr static UInt32 EXT2_DIRECT_BLOCKS = 12;
constexpr static UInt32 EXT2_SINGLE_INDIRECT_INDEX = 12;
constexpr static UInt32 EXT2_DOUBLE_INDIRECT_INDEX = 13;
-constexpr ATTRIBUTE(unused) static UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14;
+constexpr static UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14;
constexpr static UInt32 EXT2_ROOT_INODE = 2;
constexpr ATTRIBUTE(unused) static UInt32 EXT2_SUPERBLOCK_BLOCK = 1;
constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2;
@@ -385,6 +387,8 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
// Double
UInt32 doubleStart = EXT2_DIRECT_BLOCKS + blocksPerPointerBlock;
UInt32 doubleSpan = blocksPerPointerBlock * blocksPerPointerBlock;
+ UInt32 tripleSpan = blocksPerPointerBlock * blocksPerPointerBlock * blocksPerPointerBlock;
+
if (logicalBlockIndex < doubleStart + doubleSpan) {
if (node->inode.fBlock[EXT2_DOUBLE_INDIRECT_INDEX] == 0) {
auto groupInfoRes = ext2_get_group_descriptor_info(ctx, node->inodeNumber);
@@ -430,6 +434,7 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
UInt32 secondIdx = idxWithin % blocksPerPointerBlock;
auto doubleRes = ext2_read_block_ptr(ctx, node->inode.fBlock[EXT2_DOUBLE_INDIRECT_INDEX]);
+
if (doubleRes.HasError()) return ErrorOr<Void*>(doubleRes.Error());
UInt32* doublePtr = doubleRes.Leak().Leak();
@@ -438,6 +443,7 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
// Allocate single-indirect if missing
if (singleIndirectBlock == 0) {
auto groupInfoRes = ext2_get_group_descriptor_info(ctx, node->inodeNumber);
+
if (groupInfoRes.HasError()) {
mm_free_ptr(doublePtr);
return ErrorOr<Void*>(groupInfoRes.Error());
@@ -445,6 +451,7 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
auto groupInfo = groupInfoRes.Leak().Leak();
auto newBlockRes = ext2_alloc_block(ctx, groupInfo->groupDesc);
+
if (newBlockRes.HasError()) {
mm_free_ptr(doublePtr);
mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer));
@@ -469,13 +476,16 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
// Zero single-indirect block
auto zeroBuf = mm_alloc_ptr(blockSize, true, false);
+
if (!zeroBuf) {
mm_free_ptr(doublePtr);
return ErrorOr<Void*>(kErrorHeapOutOfMemory);
}
rt_zero_memory(zeroBuf, blockSize);
+
UInt32 singleLba = ext2_block_to_lba(ctx, singleIndirectBlock);
+
if (!ext2_write_block(ctx->drive, singleLba, zeroBuf, blockSize)) {
mm_free_ptr(zeroBuf);
mm_free_ptr(doublePtr);
@@ -486,6 +496,7 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
// Write double-indirect back to disk
UInt32 dblLba = ext2_block_to_lba(ctx, node->inode.fBlock[EXT2_DOUBLE_INDIRECT_INDEX]);
+
if (!ext2_write_block(ctx->drive, dblLba, doublePtr, blockSize)) {
mm_free_ptr(doublePtr);
return ErrorOr<Void*>(kErrorDisk);
@@ -509,10 +520,24 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node,
mm_free_ptr(singlePtr);
return ErrorOr<Void*>(nullptr);
+ } else if (logicalBlockIndex < doubleStart + tripleSpan) {
+ UInt32 tripleLba = ext2_block_to_lba(ctx, node->inode.fBlock[EXT2_TRIPLE_INDIRECT_INDEX]);
+ auto triplePtrRef = ext2_read_block_ptr(ctx, node->inode.fBlock[EXT2_TRIPLE_INDIRECT_INDEX]);
+
+ if (triplePtrRef.HasError()) {
+ return ErrorOr<Void*>(kErrorDisk);
+ }
+
+ if (!ext2_write_block(ctx->drive, tripleLba, triplePtrRef.Leak().Leak(), blockSize)) {
+ mm_free_ptr(triplePtrRef.Leak().Leak());
+ return ErrorOr<Void*>(kErrorDisk);
+ }
+
+ mm_free_ptr(triplePtrRef.Leak().Leak());
}
- // Triple indirect blocks not implemented
- return ErrorOr<Void*>(kErrorUnimplemented);
+
+ return ErrorOr<Void*>(kErrorDisk);
}
// Find a directory entry by name within a directory inode
diff --git a/src/launch/launch.json b/src/launch/launch.json
index 1230b34d..77774618 100644
--- a/src/launch/launch.json
+++ b/src/launch/launch.json
@@ -3,7 +3,7 @@
"compiler_std": "c++20",
"headers_path": ["../", "./", "../../public/frameworks"],
"sources_path": ["src/*.cpp", "src/*.S"],
- "output_name": "ne_launch.exe",
+ "output_name": "launch.exe",
"compiler_flags": [
"-ffreestanding",
"-shared",