From 33a87e5cce4b8d1e64a842df8fbb2acc2f89cde8 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 06:24:35 +0100 Subject: [CHORE] Add PThread library. Signed-off-by: Amlal El Mahrouss --- src/libPThread/.keep | 0 src/libPThread/PThreadKit/.keep | 0 src/libPThread/PThreadKit/pthread.h | 14 ++++++++++++++ src/libPThread/libPThread.json | 25 +++++++++++++++++++++++++ src/libPThread/src/.keep | 0 src/libPThread/src/PThreadHandle.cpp | 0 6 files changed, 39 insertions(+) create mode 100644 src/libPThread/.keep create mode 100644 src/libPThread/PThreadKit/.keep create mode 100644 src/libPThread/PThreadKit/pthread.h create mode 100644 src/libPThread/libPThread.json create mode 100644 src/libPThread/src/.keep create mode 100644 src/libPThread/src/PThreadHandle.cpp (limited to 'src') diff --git a/src/libPThread/.keep b/src/libPThread/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/libPThread/PThreadKit/.keep b/src/libPThread/PThreadKit/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/libPThread/PThreadKit/pthread.h b/src/libPThread/PThreadKit/pthread.h new file mode 100644 index 00000000..053885e7 --- /dev/null +++ b/src/libPThread/PThreadKit/pthread.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 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 + +#ifndef LIBPOSIX_POSIXKIT_THREAD_H +#define LIBPOSIX_POSIXKIT_THREAD_H + +#include + +#define PTHREAD_UNSAFE /* hint */ +#define PTHREAD_SAFE /* hint */ + +#endif // LIBPOSIX_POSIXKIT_THREAD_H diff --git a/src/libPThread/libPThread.json b/src/libPThread/libPThread.json new file mode 100644 index 00000000..e5f5dbf3 --- /dev/null +++ b/src/libPThread/libPThread.json @@ -0,0 +1,25 @@ +{ + "compiler_path": "x86_64-w64-mingw32-gcc", + "compiler_std": "c++20", + "headers_path": ["../", "./"], + "sources_path": ["src/*.cpp"], + "output_name": "libPThread.dll", + "compiler_flags": [ + "-ffreestanding", + "-shared", + "-std=c++20", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17" + ], + "cpp_macros": [ + "__NEOSKRNL__", + "_XOPEN_SOURCE", + "_POSIX_SOURCE", + "kPosixVersionHighest=0x0100", + "kPosixVersionLowest=0x0100", + "kPosixVersion=0x0100" + ], + "description": "The NeKernel PThread System." +} +i diff --git a/src/libPThread/src/.keep b/src/libPThread/src/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/libPThread/src/PThreadHandle.cpp b/src/libPThread/src/PThreadHandle.cpp new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3 From 72c5d5fb1c06f91b7793c3af5c79cf10efc18c49 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 06:25:09 +0100 Subject: [CHORE] Add PThread library links. Signed-off-by: Amlal El Mahrouss --- src/libPThread/libPThread.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libPThread/libPThread.json b/src/libPThread/libPThread.json index e5f5dbf3..3ab8a9d2 100644 --- a/src/libPThread/libPThread.json +++ b/src/libPThread/libPThread.json @@ -20,6 +20,6 @@ "kPosixVersionLowest=0x0100", "kPosixVersion=0x0100" ], - "description": "The NeKernel PThread System." + "description": "The NeKernel PThread System. Refer to: https://man7.org/linux/man-pages/man7/pthreads.7.html" } i -- cgit v1.2.3 From fca7e2533bfd9ed5fd678aeec2600d1c13a2c5c8 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 13:04:33 +0100 Subject: [CHORE] Add PThread core features and NeLaunch ProgramData feature. Signed-off-by: Amlal El Mahrouss --- src/launch/src/CRuntimeZero.S | 18 ++++++++++++++++-- src/launch/src/RuntimeMain.cpp | 4 ++-- src/libPThread/PThreadKit/Thread.h | 14 ++++++++++++++ src/libPThread/PThreadKit/pthread.h | 14 -------------- src/libPThread/src/PThreadHandle.cpp | 0 src/libPThread/src/Thread.cpp | 33 +++++++++++++++++++++++++++++++++ src/libSystem/SystemKit/System.h | 1 + 7 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 src/libPThread/PThreadKit/Thread.h delete mode 100644 src/libPThread/PThreadKit/pthread.h delete mode 100644 src/libPThread/src/PThreadHandle.cpp create mode 100644 src/libPThread/src/Thread.cpp (limited to 'src') diff --git a/src/launch/src/CRuntimeZero.S b/src/launch/src/CRuntimeZero.S index 7dd283c9..2a7b195d 100644 --- a/src/launch/src/CRuntimeZero.S +++ b/src/launch/src/CRuntimeZero.S @@ -20,7 +20,21 @@ _NeMain: callq launch_startup_fn movq %rcx, 0 - callq ThrExitMainThread - popq %rbp + +.data +.global _ProgramData +_ProgramData: + //;; ident + .word 0xffeecc + //;; version + .word 0x0110 + //;; kind: 0x0 = LaunchSystem + .word 0x0 + //;; flags + .word 0x0 + //;; Launcher name + .asciz "NeKernel Launcher" + + diff --git a/src/launch/src/RuntimeMain.cpp b/src/launch/src/RuntimeMain.cpp index 3216dad0..833a2f55 100644 --- a/src/launch/src/RuntimeMain.cpp +++ b/src/launch/src/RuntimeMain.cpp @@ -12,13 +12,13 @@ IMPORT_C SInt32 launch_startup_fn(Void) { /// Start LaunchHelpers.fwrk services, and make the launcher manageable too (via mgmt.launch) UInt32* ret = - static_cast(libsys_syscall_arg_1(libsys_hash_64("__launch_register_service"))); + static_cast(libsys_syscall_arg_1(libsys_hash_64("__launch_register_service"))); // Register service based on program data. if (ret) { switch (*ret) { case kErrorSuccess: { ret = - static_cast(libsys_syscall_arg_1(libsys_hash_64("__launch_listen_as_super"))); + static_cast(libsys_syscall_arg_1(libsys_hash_64("__launch_attach_service"))); // Attach this program as the service process. return *ret; } default: diff --git a/src/libPThread/PThreadKit/Thread.h b/src/libPThread/PThreadKit/Thread.h new file mode 100644 index 00000000..053885e7 --- /dev/null +++ b/src/libPThread/PThreadKit/Thread.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 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 + +#ifndef LIBPOSIX_POSIXKIT_THREAD_H +#define LIBPOSIX_POSIXKIT_THREAD_H + +#include + +#define PTHREAD_UNSAFE /* hint */ +#define PTHREAD_SAFE /* hint */ + +#endif // LIBPOSIX_POSIXKIT_THREAD_H diff --git a/src/libPThread/PThreadKit/pthread.h b/src/libPThread/PThreadKit/pthread.h deleted file mode 100644 index 053885e7..00000000 --- a/src/libPThread/PThreadKit/pthread.h +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Copyright 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 - -#ifndef LIBPOSIX_POSIXKIT_THREAD_H -#define LIBPOSIX_POSIXKIT_THREAD_H - -#include - -#define PTHREAD_UNSAFE /* hint */ -#define PTHREAD_SAFE /* hint */ - -#endif // LIBPOSIX_POSIXKIT_THREAD_H diff --git a/src/libPThread/src/PThreadHandle.cpp b/src/libPThread/src/PThreadHandle.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/libPThread/src/Thread.cpp b/src/libPThread/src/Thread.cpp new file mode 100644 index 00000000..34a610cd --- /dev/null +++ b/src/libPThread/src/Thread.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 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 + +namespace POSIXKit::Detail { + + /// @brief Max path structure. + constexpr auto kMaxPathLen = 255; + static constexpr auto kCanaryValue = 0xf0f0488f; + + /// @brief Thread Information Structure. + struct ThreadFrameParams final { + SInt64 fCanary; + VoidPtr fStackPtr; + VoidPtr fCodePtr; + SizeT fCodeSz; + SizeT fStackSz; + SInt64 fThrdID; + SInt64 fUsrID, fGrpID; + SInt64* fFD{}; + SizeT fFDCnt; + Char fCWD[kMaxPathLen]; + Char fRoot[kMaxPathLen]; + ThreadRef fRef; + }; + +} // namespace POSIX::Detail + + + diff --git a/src/libSystem/SystemKit/System.h b/src/libSystem/SystemKit/System.h index 1a7298d8..4e766d9d 100644 --- a/src/libSystem/SystemKit/System.h +++ b/src/libSystem/SystemKit/System.h @@ -14,6 +14,7 @@ /// @brief Secure TTY device path. #define kSecurePrintDevicePath "/devices/stty{}{}" +/// @brief Laser-disc path (Blu-ray, DVD, CD, etc.) #define kCDDevicePath "/devices/dvd{}{}" // ------------------------------------------------------------------------------------------ // -- cgit v1.2.3 From 59f58be5d8edde230f5528ef2152d73294945445 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 13:05:10 +0100 Subject: [CHORE] Add PThread core features and NeLaunch ProgramData feature. Signed-off-by: Amlal El Mahrouss --- src/launch/src/CRuntimeZero.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/launch/src/CRuntimeZero.S b/src/launch/src/CRuntimeZero.S index 2a7b195d..1e5e2cbb 100644 --- a/src/launch/src/CRuntimeZero.S +++ b/src/launch/src/CRuntimeZero.S @@ -37,4 +37,4 @@ _ProgramData: //;; Launcher name .asciz "NeKernel Launcher" - + -- cgit v1.2.3 From ea01754db96b7dfeb866d83a73030d6983e7434e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 13:06:30 +0100 Subject: [FEAT] Add .launch_manifest Signed-off-by: Amlal El Mahrouss --- src/launch/.launch_manifest | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/launch/.launch_manifest (limited to 'src') diff --git a/src/launch/.launch_manifest b/src/launch/.launch_manifest new file mode 100644 index 00000000..201b1f61 --- /dev/null +++ b/src/launch/.launch_manifest @@ -0,0 +1,4 @@ +[Launch] +RunAsRoot=YES +# NOTE: This has to be generated and passed here to enable all-trustee permissions. +RootKey= -- cgit v1.2.3 From 8f593bba0d50b9f96f97c1d727e8f217b5d2b429 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 13:07:41 +0100 Subject: [FEAT] Add groundwork for future PR. Signed-off-by: Amlal El Mahrouss --- src/kernel/src/UserMgr.cpp | 7 ++++--- src/kernel/src/UserProcessScheduler.cpp | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/kernel/src/UserMgr.cpp b/src/kernel/src/UserMgr.cpp index 264dcc5f..cceda53d 100644 --- a/src/kernel/src/UserMgr.cpp +++ b/src/kernel/src/UserMgr.cpp @@ -16,7 +16,8 @@ /// @brief Multi-user support. namespace Kernel { - - - + namespace Detail { + struct UserPermissionControl; + struct UserPermissionElevator; + } } diff --git a/src/kernel/src/UserProcessScheduler.cpp b/src/kernel/src/UserProcessScheduler.cpp index c0b166cb..e7fe7398 100644 --- a/src/kernel/src/UserProcessScheduler.cpp +++ b/src/kernel/src/UserProcessScheduler.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include #include #include -- cgit v1.2.3 From f58844c6bb8e6c979347050782068bdfe58089d3 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 15 Mar 2026 13:10:33 +0100 Subject: [FEAT] Fix PThread formula. Signed-off-by: Amlal El Mahrouss --- src/libPThread/libPThread.json | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/libPThread/libPThread.json b/src/libPThread/libPThread.json index 3ab8a9d2..a5cfba73 100644 --- a/src/libPThread/libPThread.json +++ b/src/libPThread/libPThread.json @@ -14,12 +14,9 @@ ], "cpp_macros": [ "__NEOSKRNL__", - "_XOPEN_SOURCE", - "_POSIX_SOURCE", "kPosixVersionHighest=0x0100", "kPosixVersionLowest=0x0100", "kPosixVersion=0x0100" ], "description": "The NeKernel PThread System. Refer to: https://man7.org/linux/man-pages/man7/pthreads.7.html" } -i -- cgit v1.2.3