summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-10-04 02:47:12 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-10-04 02:49:04 +0200
commitee64ca1014ee2bdf07bd5011f6aa9f77da104a4d (patch)
tree9918fe906103b4728991cf369d5fe5f92f049287
parentb1302067703566624390d780dffd621bb99bb439 (diff)
feat: kernel: new `kernel` process type, and usage of `explicit operator
bool` feat: libSystem: minor tweaks. feat: indexer: important fixes in `RemoveFlag` Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--compile_flags.txt3
-rw-r--r--dev/kernel/FSKit/Ext2+IFS.h4
-rw-r--r--dev/kernel/KernelKit/CodeMgr.h3
-rw-r--r--dev/kernel/KernelKit/CoreProcessScheduler.h3
-rw-r--r--dev/kernel/KernelKit/KernelTaskScheduler.h4
-rw-r--r--dev/kernel/KernelKit/PECodeMgr.h77
-rw-r--r--dev/kernel/KernelKit/UserProcessScheduler.h4
-rw-r--r--dev/kernel/amd64-desktop.make2
-rw-r--r--dev/kernel/src/FS/Ext2+FileMgr.cc16
-rw-r--r--dev/kernel/src/IndexableProperty.cc3
-rw-r--r--dev/libSystem/SystemKit/Verify.h4
-rw-r--r--dev/libSystem/src/SystemCalls.cc (renamed from dev/libSystem/src/System.cc)4
12 files changed, 28 insertions, 99 deletions
diff --git a/compile_flags.txt b/compile_flags.txt
index 828dc123..8f006960 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -35,4 +35,5 @@
-D__FSKIT_INCLUDES_EXT2__
-D__NE_VIRTUAL_MEMORY_SUPPORT__
-DBOOTZ_GPT_SUPPORT
--D__x86_64__ \ No newline at end of file
+-D__x86_64__
+-D__NE_USE_PEF__ \ No newline at end of file
diff --git a/dev/kernel/FSKit/Ext2+IFS.h b/dev/kernel/FSKit/Ext2+IFS.h
index 661c8d5f..72e01ecd 100644
--- a/dev/kernel/FSKit/Ext2+IFS.h
+++ b/dev/kernel/FSKit/Ext2+IFS.h
@@ -144,7 +144,7 @@ inline Kernel::ErrorOr<Ext2Node*> ext2_load_inode(Ext2Context* ctx, Kernel::UInt
*
* Provides high-level interface for EXT2 filesystem operations
*/
-class Ext2FileSystemParser {
+class Ext2FileSystemParser final {
private:
Ext2Context ctx; // Internal EXT2 context
@@ -157,6 +157,8 @@ class Ext2FileSystemParser {
*/
explicit Ext2FileSystemParser(DriveTrait* drive);
+ NE_COPY_DELETE(Ext2FileSystemParser)
+
/*
* Open a file or directory by path
*
diff --git a/dev/kernel/KernelKit/CodeMgr.h b/dev/kernel/KernelKit/CodeMgr.h
index c733bc47..fc737a90 100644
--- a/dev/kernel/KernelKit/CodeMgr.h
+++ b/dev/kernel/KernelKit/CodeMgr.h
@@ -14,9 +14,10 @@
#pragma once
+#ifdef __NE_USE_PEF__
#include <KernelKit/IPEFDylibObject.h>
-#include <KernelKit/PECodeMgr.h>
#include <KernelKit/PEFCodeMgr.h>
+#endif
/// @file CodeMgr.h
/// @brief Code Manager header file.
diff --git a/dev/kernel/KernelKit/CoreProcessScheduler.h b/dev/kernel/KernelKit/CoreProcessScheduler.h
index f40ffc81..49e9363e 100644
--- a/dev/kernel/KernelKit/CoreProcessScheduler.h
+++ b/dev/kernel/KernelKit/CoreProcessScheduler.h
@@ -147,7 +147,8 @@ enum class ProcessSubsystem : Int32 {
kProcessSubsystemUser,
kProcessSubsystemService,
kProcessSubsystemDriver,
- kProcessSubsystemCount = kProcessSubsystemDriver - kProcessSubsystemSecurity + 1,
+ kProcessSubsystemKernel,
+ kProcessSubsystemCount = kProcessSubsystemKernel - kProcessSubsystemSecurity + 1,
kProcessSubsystemInvalid = 0xFFFFFFF,
};
diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h
index ce0ff30d..1bc8975a 100644
--- a/dev/kernel/KernelKit/KernelTaskScheduler.h
+++ b/dev/kernel/KernelKit/KernelTaskScheduler.h
@@ -24,7 +24,7 @@ typedef ProcessID KID;
class KERNEL_TASK final {
public:
Char Name[kSchedNameLen] = {"KERNEL_TASK"};
- ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemDriver};
+ ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemKernel};
HAL::StackFramePtr StackFrame{nullptr};
UInt8* StackReserve{nullptr};
SizeT StackSize{kSchedMaxStackSz};
@@ -40,7 +40,7 @@ class KernelTaskHelper final {
public:
STATIC Bool Switch(HAL::StackFramePtr frame_ptr, ProcessID new_kid);
STATIC Bool CanBeScheduled(const KERNEL_TASK& process);
- STATIC ErrorOr<ProcessID> TheCurrentKID();
+ STATIC ErrorOr<KID> TheCurrentKID();
STATIC SizeT StartScheduling();
};
} // namespace Kernel \ No newline at end of file
diff --git a/dev/kernel/KernelKit/PECodeMgr.h b/dev/kernel/KernelKit/PECodeMgr.h
deleted file mode 100644
index 15c2b7ee..00000000
--- a/dev/kernel/KernelKit/PECodeMgr.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
-
- File: PECodeMgr.h
- Purpose: PE32+ Code Mgr and Dylib mgr.
-
- Revision History:
-
- 12/02/24: Added file (amlel)
-
-------------------------------------------- */
-
-#pragma once
-
-////////////////////////////////////////////////////
-
-// LAST REV: Mon Feb 12 13:52:01 CET 2024
-
-////////////////////////////////////////////////////
-
-#include <KernelKit/FileMgr.h>
-#include <KernelKit/LoaderInterface.h>
-#include <KernelKit/PE.h>
-#include <NeKit/ErrorOr.h>
-#include <NeKit/KString.h>
-
-#ifndef INC_PROCESS_SCHEDULER_H
-#include <KernelKit/ProcessScheduler.h>
-#endif
-
-#define kPeApplicationMime "application/vnd-portable-executable"
-
-namespace Kernel {
-///
-/// \name PE32Loader
-/// \brief PE32+ loader class.
-///
-class PE32Loader : public LoaderInterface {
- private:
- explicit PE32Loader() = delete;
-
- public:
- explicit PE32Loader(const VoidPtr blob);
- explicit PE32Loader(const Char* path);
- ~PE32Loader() override;
-
- public:
- NE_COPY_DEFAULT(PE32Loader)
-
- public:
- const Char* Path() override;
- const Char* AsString() override;
- const Char* MIME() override;
-
- public:
- ErrorOr<VoidPtr> FindStart() override;
- ErrorOr<VoidPtr> FindSymbol(const Char* name, Int32 kind) override;
- ErrorOr<VoidPtr> GetBlob() override;
-
- public:
- bool IsLoaded() noexcept;
-
- private:
-#ifdef __FSKIT_INCLUDES_NEFS__
- OwnPtr<FileStream<Char, NeFileSystemMgr>> fFile;
-#elif defined(__FSKIT_INCLUDES_HEFS__)
- OwnPtr<FileStream<Char, HeFileSystemMgr>> fFile;
-#else
- OwnPtr<FileStream<Char>> fFile;
-#endif // __FSKIT_INCLUDES_NEFS__
-
- Ref<KString> fPath;
- VoidPtr fCachedBlob;
- bool fBad;
-};
-} // namespace Kernel \ No newline at end of file
diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h
index e5b81f76..d106e511 100644
--- a/dev/kernel/KernelKit/UserProcessScheduler.h
+++ b/dev/kernel/KernelKit/UserProcessScheduler.h
@@ -86,7 +86,7 @@ class USER_PROCESS final {
/***********************************************************************************/
//! @brief boolean operator, check status.
/***********************************************************************************/
- operator bool();
+ explicit operator bool();
/***********************************************************************************/
///! @brief Crashes the app, exits with code ~0.
@@ -192,7 +192,7 @@ class UserProcessScheduler final : public ISchedulable {
NE_MOVE_DELETE(UserProcessScheduler)
public:
- operator bool();
+ explicit operator bool();
bool operator!();
public:
diff --git a/dev/kernel/amd64-desktop.make b/dev/kernel/amd64-desktop.make
index bfcca16b..a3040c89 100644
--- a/dev/kernel/amd64-desktop.make
+++ b/dev/kernel/amd64-desktop.make
@@ -5,7 +5,7 @@
CXX = x86_64-w64-mingw32-g++
LD = x86_64-w64-mingw32-ld
-CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -D__NE_VEPM__ -Wall -Wpedantic -Wextra -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_INCLUDES_HEFS__ -D__FSKIT_INCLUDES_EXT2__ -D__NE_SUPPORT_NX__ -O0 -I../vendor -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../boot
+CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -D__NE_USE_PEF__ -D__NE_VEPM__ -Wall -Wpedantic -Wextra -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_INCLUDES_HEFS__ -D__FSKIT_INCLUDES_EXT2__ -D__NE_SUPPORT_NX__ -O0 -I../vendor -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../boot
ASM = nasm
diff --git a/dev/kernel/src/FS/Ext2+FileMgr.cc b/dev/kernel/src/FS/Ext2+FileMgr.cc
index 7c28c0c9..c0c9c84e 100644
--- a/dev/kernel/src/FS/Ext2+FileMgr.cc
+++ b/dev/kernel/src/FS/Ext2+FileMgr.cc
@@ -17,14 +17,14 @@
#include <NeKit/KernelPanic.h>
#include <NeKit/Utils.h>
-constexpr UInt32 EXT2_DIRECT_BLOCKS = 12;
-constexpr UInt32 EXT2_SINGLE_INDIRECT_INDEX = 12;
-constexpr UInt32 EXT2_DOUBLE_INDIRECT_INDEX = 13;
-constexpr UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14;
-constexpr UInt32 EXT2_ROOT_INODE = 2;
-constexpr UInt32 EXT2_SUPERBLOCK_BLOCK = 1;
-constexpr UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2;
-constexpr UInt32 EXT2_GROUP_DESC_BLOCK_LARGE = 1;
+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_ROOT_INODE = 2;
+constexpr ATTRIBUTE(unused) static UInt32 EXT2_SUPERBLOCK_BLOCK = 1;
+constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2;
+constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_LARGE = 1;
static inline SizeT ext2_min(SizeT a, SizeT b) {
return a < b ? a : b;
diff --git a/dev/kernel/src/IndexableProperty.cc b/dev/kernel/src/IndexableProperty.cc
index c11e328d..56143607 100644
--- a/dev/kernel/src/IndexableProperty.cc
+++ b/dev/kernel/src/IndexableProperty.cc
@@ -22,7 +22,7 @@ namespace Indexer {
Void IndexableProperty::AddFlag(Int16 flag) { fFlags |= flag; }
- Void IndexableProperty::RemoveFlag(Int16 flag) { fFlags &= flag; }
+ Void IndexableProperty::RemoveFlag(Int16 flag) { fFlags &= ~(flag); }
Int16 IndexableProperty::HasFlag(Int16 flag) { return fFlags & flag; }
@@ -33,6 +33,7 @@ namespace Indexer {
/// @return none, check before if indexer can be claimed (using indexer.HasFlag(kIndexerClaimed)).
Void fs_index_file(const Char* filename, SizeT filenameLen, IndexableProperty& indexer) {
if (!indexer.HasFlag(kIndexerClaimed)) {
+ indexer.RemoveFlag(kIndexerUnclaimed);
indexer.AddFlag(kIndexerClaimed);
rt_copy_memory_safe(reinterpret_cast<VoidPtr>(const_cast<Char*>(filename)),
(VoidPtr) indexer.Leak().Path, filenameLen, kIndexerCatalogNameLength);
diff --git a/dev/libSystem/SystemKit/Verify.h b/dev/libSystem/SystemKit/Verify.h
index cbf85830..5ad0dbff 100644
--- a/dev/libSystem/SystemKit/Verify.h
+++ b/dev/libSystem/SystemKit/Verify.h
@@ -11,7 +11,7 @@
#include <libSystem/SystemKit/System.h>
-namespace LibSystem::Detail {
+namespace LibSystem::Verify {
/// @author 0xf00sec, and Amlal El Mahrouss
/// @brief safe cast operator.
template <typename T, typename R = VoidPtr>
@@ -34,7 +34,7 @@ struct must_cast_traits<T, T> {
/// @brief Safe constexpr cast.
template <typename T, typename R>
inline constexpr R* sys_constexpr_cast(T* ptr) {
- static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are a mismatch!");
+ static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are mismatching!");
return static_cast<R*>(ptr);
}
} // namespace LibSystem::Detail
diff --git a/dev/libSystem/src/System.cc b/dev/libSystem/src/SystemCalls.cc
index da9931fe..571a99a6 100644
--- a/dev/libSystem/src/System.cc
+++ b/dev/libSystem/src/SystemCalls.cc
@@ -147,7 +147,7 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt
IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
return static_cast<Ref>(libsys_syscall_arg_3(
- SYSCALL_HASH("IoOpenFile"), Detail::sys_safe_cast(path), Detail::sys_safe_cast(drv_letter)));
+ SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast(path), Verify::sys_safe_cast(drv_letter)));
}
IMPORT_C Void IoCloseFile(_Input Ref desc) {
@@ -183,7 +183,7 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const Char* fmt, ...) {
// if truncated, `needed` >= kBufferSz; we still send truncated buffer
auto ret_ptr = libsys_syscall_arg_3(SYSCALL_HASH("PrintOut"), static_cast<VoidPtr>(desc),
- Detail::sys_safe_cast(buf));
+ Verify::sys_safe_cast(buf));
if (!ret_ptr) return -kErrorInvalidData;