From 81027667166d9624ee12f45f011426678d1bbbf4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 29 May 2025 17:19:57 +0200 Subject: feat: Improve libSystem's architecture and implementation. fix: Fix NeKit's Ref, and ErrorOr classes. fix: Fix userland tools. next: - Finish the latest tickets and then release nekernel 0.0.3 Signed-off-by: Amlal El Mahrouss --- dev/libSystem/src/SystemProc.asm | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 dev/libSystem/src/SystemProc.asm (limited to 'dev/libSystem/src/SystemProc.asm') diff --git a/dev/libSystem/src/SystemProc.asm b/dev/libSystem/src/SystemProc.asm new file mode 100644 index 00000000..bc41059a --- /dev/null +++ b/dev/libSystem/src/SystemProc.asm @@ -0,0 +1,66 @@ +;; /* +;; * ======================================================== +;; * +;; * libSystem/src/SystemCalls+IO.asm +;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +;; * +;; * ======================================================== +;; */ + +[bits 64] + +section .text + +global libsys_syscall_arg_1 +global libsys_syscall_arg_2 +global libsys_syscall_arg_3 +global libsys_syscall_arg_4 + +libsys_syscall_arg_1: + push rbp + mov rbp, rsp + + mov r8, rcx + syscall + + pop rbp + + ret + +libsys_syscall_arg_2: + push rbp + mov rbp, rsp + + mov r8, rcx + mov r9, rdx + syscall + pop rbp + + ret + +libsys_syscall_arg_3: + push rbp + mov rbp, rsp + + mov r8, rcx + mov r9, rdx + mov r10, rbx + + syscall + pop rbp + + ret + +libsys_syscall_arg_4: + push rbp + mov rbp, rsp + + mov r8, rcx + mov r9, rdx + mov r10, rbx + mov r11, rax + + syscall + pop rbp + + ret -- cgit v1.2.3 From 86b89793dcaf290206faeb7fe3100dd0a5f71d1d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 30 May 2025 14:42:35 +0200 Subject: global: architectural changes, see commit details. refactor: Refactor libSystem, user frameworks, and preparing for OpenMSG. feat: Jail info client structure (libSystem) feat: Document what the RTime is doing starting from line 504. feat: use `int 50` instead of `syscall` for now. Signed-off-by: Amlal El Mahrouss --- dev/kernel/src/UserProcessScheduler.cc | 1 + dev/libSystem/Err.h | 58 ---- dev/libSystem/Jail.h | 15 - dev/libSystem/Macros.h | 126 ------- dev/libSystem/Syscall.h | 19 - dev/libSystem/System.h | 385 --------------------- dev/libSystem/SystemKit/Err.h | 58 ++++ dev/libSystem/SystemKit/Jail.h | 23 ++ dev/libSystem/SystemKit/Macros.h | 126 +++++++ dev/libSystem/SystemKit/Syscall.h | 19 + dev/libSystem/SystemKit/System.h | 385 +++++++++++++++++++++ dev/libSystem/src/Makefile | 2 +- dev/libSystem/src/SystemAPI.cc | 91 ----- dev/libSystem/src/SystemImpl.cc | 91 +++++ dev/libSystem/src/SystemProc.asm | 13 +- dev/open_msg/.keep | 0 dev/open_msg/MsgKit/Server.h | 22 ++ dev/open_msg/obj/.keep | 0 dev/open_msg/script/window.msg | 6 + dev/open_msg/src/.keep | 0 dev/system_sdk/.keep | 0 .../CoreFoundation.fwrk/CoreFoundation.json | 2 +- .../frameworks/CoreFoundation.fwrk/headers/Array.h | 2 +- .../CoreFoundation.fwrk/headers/Foundation.h | 2 +- .../CoreFoundation.fwrk/headers/Property.h | 2 +- .../frameworks/CoreFoundation.fwrk/headers/Ref.h | 2 +- public/frameworks/DiskImage.fwrk/DiskImage.json | 2 +- .../frameworks/DiskImage.fwrk/headers/DiskImage.h | 2 +- public/frameworks/KernelTest.fwrk/KernelTest.json | 2 +- public/frameworks/OpenMSG.fwrk/.keep | 0 public/frameworks/OpenMSG.fwrk/OpenMSG.json | 19 + public/frameworks/OpenMSG.fwrk/headers/.keep | 0 public/frameworks/OpenMSG.fwrk/src/.keep | 0 public/frameworks/OpenMSG.fwrk/src/DylibMain.cc | 5 + public/frameworks/OpenMSG.fwrk/xml/.keep | 0 public/frameworks/OpenMSG.fwrk/xml/app.xml | 2 + public/tools/cc/src/CommandLine.cc | 2 +- public/tools/ld.dyn/src/CommandLine.cc | 2 +- public/tools/ld.fwrk/src/CommandLine.cc | 2 +- public/tools/manual/src/CommandLine.cc | 2 +- public/tools/mgmt/src/CommandLine.cc | 2 +- public/tools/mk.fwrk/Common.h | 2 +- public/tools/mk.fwrk/src/CommandLine.cc | 2 +- public/tools/mk.hefs/src/CommandLine.cc | 2 +- public/tools/mk.nefs/src/CommandLine.cc | 2 +- public/tools/open/src/CommandLine.cc | 2 +- public/tools/ping/src/CommandLine.cc | 2 +- tooling/mk_app.py | 2 +- tooling/mk_fwrk.py | 4 +- 49 files changed, 789 insertions(+), 721 deletions(-) delete mode 100644 dev/libSystem/Err.h delete mode 100644 dev/libSystem/Jail.h delete mode 100644 dev/libSystem/Macros.h delete mode 100644 dev/libSystem/Syscall.h delete mode 100644 dev/libSystem/System.h create mode 100644 dev/libSystem/SystemKit/Err.h create mode 100644 dev/libSystem/SystemKit/Jail.h create mode 100644 dev/libSystem/SystemKit/Macros.h create mode 100644 dev/libSystem/SystemKit/Syscall.h create mode 100644 dev/libSystem/SystemKit/System.h delete mode 100644 dev/libSystem/src/SystemAPI.cc create mode 100644 dev/libSystem/src/SystemImpl.cc create mode 100644 dev/open_msg/.keep create mode 100644 dev/open_msg/MsgKit/Server.h create mode 100644 dev/open_msg/obj/.keep create mode 100644 dev/open_msg/script/window.msg create mode 100644 dev/open_msg/src/.keep delete mode 100644 dev/system_sdk/.keep create mode 100644 public/frameworks/OpenMSG.fwrk/.keep create mode 100644 public/frameworks/OpenMSG.fwrk/OpenMSG.json create mode 100644 public/frameworks/OpenMSG.fwrk/headers/.keep create mode 100644 public/frameworks/OpenMSG.fwrk/src/.keep create mode 100644 public/frameworks/OpenMSG.fwrk/src/DylibMain.cc create mode 100644 public/frameworks/OpenMSG.fwrk/xml/.keep create mode 100644 public/frameworks/OpenMSG.fwrk/xml/app.xml (limited to 'dev/libSystem/src/SystemProc.asm') diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc index 1454585c..e6309589 100644 --- a/dev/kernel/src/UserProcessScheduler.cc +++ b/dev/kernel/src/UserProcessScheduler.cc @@ -504,6 +504,7 @@ SizeT UserProcessScheduler::Run() noexcept { if (UserProcessHelper::Switch(process.StackFrame, process.ProcessId)) { process.PTime = static_cast(process.Affinity); + // We add a bigger cooldown according to the RTime and affinity here. if (process.PTime < process.RTime && AffinityKind::kRealTime != process.Affinity) { if (process.RTime < (Int32) AffinityKind::kVeryHigh) process.RTime = (Int32) AffinityKind::kLowUsage / 2; diff --git a/dev/libSystem/Err.h b/dev/libSystem/Err.h deleted file mode 100644 index e9fe013b..00000000 --- a/dev/libSystem/Err.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include - -/// @file Err.h -/// @brief Process Codes type and values. -/// @author Amlal El Mahrouss (amlal@nekernel.org) - -#define err_local_ok() (kLastError == kErrorSuccess) -#define err_local_fail() (kLastError != kErrorSuccess) -#define err_local_get() (kLastError) - -typedef SInt32 ErrRef; - -inline constexpr ErrRef kErrorSuccess = 0; -inline constexpr ErrRef kErrorExecutable = 33; -inline constexpr ErrRef kErrorExecutableLib = 34; -inline constexpr ErrRef kErrorFileNotFound = 35; -inline constexpr ErrRef kErrorDirectoryNotFound = 36; -inline constexpr ErrRef kErrorDiskReadOnly = 37; -inline constexpr ErrRef kErrorDiskIsFull = 38; -inline constexpr ErrRef kErrorProcessFault = 39; -inline constexpr ErrRef kErrorSocketHangUp = 40; -inline constexpr ErrRef kErrorThreadLocalStorage = 41; -inline constexpr ErrRef kErrorMath = 42; -inline constexpr ErrRef kErrorNoNetwork = 43; -inline constexpr ErrRef kErrorHeapOutOfMemory = 44; -inline constexpr ErrRef kErrorNoSuchDisk = 45; -inline constexpr ErrRef kErrorFileExists = 46; -inline constexpr ErrRef kErrorFormatFailed = 47; -inline constexpr ErrRef kErrorNetworkTimeout = 48; -inline constexpr ErrRef kErrorInternal = 49; -inline constexpr ErrRef kErrorForkAlreadyExists = 50; -inline constexpr ErrRef kErrorOutOfTeamSlot = 51; -inline constexpr ErrRef kErrorHeapNotPresent = 52; -inline constexpr ErrRef kErrorNoEntrypoint = 53; -inline constexpr ErrRef kErrorDiskIsCorrupted = 54; -inline constexpr ErrRef kErrorDisk = 55; -inline constexpr ErrRef kErrorInvalidData = 56; -inline constexpr ErrRef kErrorAsync = 57; -inline constexpr ErrRef kErrorNonBlocking = 58; -inline constexpr ErrRef kErrorIPC = 59; -inline constexpr ErrRef kErrorSign = 60; -inline constexpr ErrRef kErrorInvalidCreds = 61; -inline constexpr ErrRef kErrorCDTrayBroken = 62; -inline constexpr ErrRef kErrorUnrecoverableDisk = 63; -inline constexpr ErrRef kErrorFileLocked = 64; -inline constexpr ErrRef kErrorDiskIsTooTiny = 65; -inline constexpr ErrRef kErrorUnimplemented = -1; - -/// @brief The last error reported by the system to the process. -IMPORT_C ErrRef kLastError; diff --git a/dev/libSystem/Jail.h b/dev/libSystem/Jail.h deleted file mode 100644 index 6a9259fc..00000000 --- a/dev/libSystem/Jail.h +++ /dev/null @@ -1,15 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include - -/// @file Jail.h -/// @brief NeKernel Jail System - -struct JAIL_INFO; -struct JAIL; \ No newline at end of file diff --git a/dev/libSystem/Macros.h b/dev/libSystem/Macros.h deleted file mode 100644 index 5b3a5ce1..00000000 --- a/dev/libSystem/Macros.h +++ /dev/null @@ -1,126 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -File: Macros.h -Purpose: libsci Macros header. - -------------------------------------------- */ - -#pragma once - -/***********************************************************************************/ -/// @file libSystem/Macros.h -/// @brief Macros and Core types of the SCI (System Call Interface). -/***********************************************************************************/ - -#include - -#define ATTRIBUTE(X) __attribute__((X)) - -#define IMPORT_CXX extern "C++" -#define IMPORT_C extern "C" - -#define DEPRECATED ATTRIBUTE(deprecated) - -#define EXIT_SUCCESS (0) -#define EXIT_FAILURE (1) - -#define FILE_MAX_LEN (256) - -#ifndef BOOL -#define BOOL bool -#endif - -typedef bool Bool; -typedef bool Boolean; -typedef void Void; - -#ifndef __cplusplus -#define true (1) -#define false (0) -#endif - -#define YES true -#define NO false - -typedef __UINT64_TYPE__ UInt64; -typedef __UINT32_TYPE__ UInt32; -typedef __UINT16_TYPE__ UInt16; -typedef __UINT8_TYPE__ UInt8; - -typedef __SIZE_TYPE__ SizeT; - -typedef __INT64_TYPE__ SInt64; -typedef __INT32_TYPE__ SInt32; -typedef __INT16_TYPE__ SInt16; -typedef __INT8_TYPE__ SInt8; - -typedef void* VoidPtr; -typedef __UINTPTR_TYPE__ UIntPtr; -typedef char Char; - -#ifdef __cplusplus -typedef decltype(nullptr) nullPtr; -typedef nullPtr NullPtr; - -#define LIBSYS_COPY_DELETE(KLASS) \ - KLASS& operator=(const KLASS&) = delete; \ - KLASS(const KLASS&) = delete; - -#define LIBSYS_COPY_DEFAULT(KLASS) \ - KLASS& operator=(const KLASS&) = default; \ - KLASS(const KLASS&) = default; - -#define LIBSYS_MOVE_DELETE(KLASS) \ - KLASS& operator=(KLASS&&) = delete; \ - KLASS(KLASS&&) = delete; - -#define LIBSYS_MOVE_DEFAULT(KLASS) \ - KLASS& operator=(KLASS&&) = default; \ - KLASS(KLASS&&) = default; - -#endif - -IMPORT_C void _rtl_assert(Bool expr, const Char* origin); - -#define MUST_PASS(X) _rtl_assert(X, __FILE__) - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(X) \ - (((sizeof(X) / sizeof(*(X))) / (static_cast(!(sizeof(X) % sizeof(*(X))))))) -#endif - -#ifndef KIB -#define KIB(X) (UInt64)((X) / 1024) -#endif - -#ifndef kib_cast -#define kib_cast(X) (UInt64)((X) *1024) -#endif - -#ifndef MIB -#define MIB(X) (UInt64)((UInt64) KIB(X) / 1024) -#endif - -#ifndef mib_cast -#define mib_cast(X) (UInt64)((UInt64) kib_cast(X) * 1024) -#endif - -#ifndef GIB -#define GIB(X) (UInt64)((UInt64) MIB(X) / 1024) -#endif - -#ifndef gib_cast -#define gib_cast(X) (UInt64)((UInt64) mib_cast(X) * 1024) -#endif - -#ifndef TIB -#define TIB(X) (UInt64)((UInt64) GIB(X) / 1024) -#endif - -#ifndef tib_cast -#define tib_cast(X) ((UInt64) gib_cast(X) * 1024) -#endif - -#define LIBSYS_UNUSED(X) ((void) X) diff --git a/dev/libSystem/Syscall.h b/dev/libSystem/Syscall.h deleted file mode 100644 index 21f8287c..00000000 --- a/dev/libSystem/Syscall.h +++ /dev/null @@ -1,19 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include -#include - -#ifndef SYSCALL_HASH -#define SYSCALL_HASH(str) (UInt64)str -#endif // !SYSCALL_HASH - -IMPORT_C VoidPtr libsys_syscall_arg_1(SizeT id); -IMPORT_C VoidPtr libsys_syscall_arg_2(SizeT id, VoidPtr arg1); -IMPORT_C VoidPtr libsys_syscall_arg_3(SizeT id, VoidPtr arg1, VoidPtr arg3); -IMPORT_C VoidPtr libsys_syscall_arg_4(SizeT id, VoidPtr arg1, VoidPtr arg3, VoidPtr arg4); diff --git a/dev/libSystem/System.h b/dev/libSystem/System.h deleted file mode 100644 index 88e1f173..00000000 --- a/dev/libSystem/System.h +++ /dev/null @@ -1,385 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -File: System.h -Purpose: System Call Interface. - -------------------------------------------- */ - -#ifndef LIBSYS_SYSTEM_CALLS_H -#define LIBSYS_SYSTEM_CALLS_H - -#include - -// ------------------------------------------------------------------------------------------ // -/// @brief Types API. -// ------------------------------------------------------------------------------------------ // - -struct REF_TYPE { - UInt64 __hash; /// @brief Hash of the syscall - VoidPtr __self; /// @brief Syscall self value. -}; - -typedef REF_TYPE* Ref; - -typedef Ref IORef; -typedef Ref FSRef; -typedef Ref DylibRef; -typedef Ref ThreadRef; -typedef Ref SocketRef; -typedef Ref NetworkRef; -typedef Ref MutexRef; -typedef Ref EventRef; -typedef Ref SemaphoreRef; - -// ------------------------------------------------------------------------------------------ // -/// @brief Dynamic Loader API. -// ------------------------------------------------------------------------------------------ // - -/// @brief Get function which is part of the Dylib. -/// @param symbol the symbol to look for -/// @param dll_handle the Dylib handle. -/// @return the proc pointer. -IMPORT_C Ref LdrGetDylibSymbolFromHandle(_Input const Char* symbol, _Input Ref dll_handle); - -/// @brief Open Dylib handle. -/// @param path dll path. -/// @param drv driver letter. -/// @return a dylib ref. -IMPORT_C Ref LdrOpenDylibHandle(_Input const Char* path, _Input const Char* drive_letter); - -/// @brief Close Dylib handle -/// @param dll_handle the dylib ref. -/// @return whether it closed or not. -IMPORT_C UInt32 LdrCloseDylibHandle(_Input Ref* dll_handle); - -// ------------------------------------------------------------------------------------------ // -// File API. -// ------------------------------------------------------------------------------------------ // - -/// @brief Opens a file from a drive. -/// @param fs_path the filesystem path. -/// @param drive_letter drive name, use NULL to use default drive location. -/// @return the file descriptor of the file. -IMPORT_C Ref IoOpenFile(const Char* fs_path, const Char* drive_letter); - -/// @brief Closes a file and flushes its content. -/// @param file_desc the file descriptor. -/// @return Function doesn't return a type. -IMPORT_C Void IoCloseFile(_Input Ref file_desc); - -/// @brief I/O control (ioctl) on a file. -/// @param file_desc the file descriptor. -/// @param ioctl_code the ioctl code. -/// @param in_data the input data. -/// @param out_data the output data. -/// @return the number of bytes written. -/// @note This function is used to control the file descriptor, introduced for HeFS. -IMPORT_C SInt32 IoCtrlFile(_Input Ref file_desc, _Input UInt32 ioctl_code, _Input VoidPtr in_data, - _Output VoidPtr out_data); - -/// @brief Gets the file mime (if any) -/// @param file_desc the file descriptor. -IMPORT_C const Char* IoMimeFile(_Input Ref file_desc); - -/// @brief Gets the dir DIM. -/// @param dir_desc directory descriptor. -/// @note only works in HeFS, will return nil-x/nil if used on any other filesystem. -IMPORT_C const Char* IoDimFile(_Input Ref dir_desc); - -/// @brief Write data to a file ref -/// @param file_desc the file descriptor. -/// @param out_data the data to write. -/// @param sz_data the size of the data to write. -/// @return the number of bytes written. -IMPORT_C UInt32 IoWriteFile(_Input Ref file_desc, _Output VoidPtr out_data, SizeT sz_data); - -/// @brief Read data from a file. -/// @param file_desc the file descriptor. -/// @param out_data the data to read. -/// @param sz_data the size of the data to read. -IMPORT_C UInt32 IoReadFile(_Input Ref file_desc, _Output VoidPtr* out_data, SizeT sz_data); - -/// @brief Rewind the file pointer to the beginning of the file. -/// @param file_desc the file descriptor. -/// @return the number of bytes read. -IMPORT_C UInt64 IoRewindFile(_Input Ref file_desc); - -/// @brief Tell the current position of the file pointer. -/// @param file_desc the file descriptor. -/// @return the current position of the file pointer. -IMPORT_C UInt64 IoTellFile(_Input Ref file_desc); - -/// @brief Seek file offset from file descriptor. -IMPORT_C UInt64 IoSeekFile(_Input Ref file_desc, UInt64 file_offset); - -// ------------------------------------------------------------------------ -// Process API. -// ------------------------------------------------------------------------ - -/// @brief Spawns a Thread Information Block and Global Information Block inside the current -/// process. -/// @param process_id Target Process ID, must be valid. -/// @return > 0 error occurred or already present, = 0 success. -IMPORT_C UInt32 RtlSpawnIB(UIntPtr process_id); - -/// @brief Spawns a process with a unique pid (stored as UIntPtr). -/// @param process_path process filesystem path. -/// @return > 0 process was created. -IMPORT_C UIntPtr RtlSpawnProcess(const Char* process_path, SizeT argc, Char** argv, Char** envp, - SizeT envp_len); - -/// @brief Exits a process with an exit_code. -/// @return if it has succeeded true, otherwise false. -IMPORT_C Bool RtlExitProcess(UIntPtr handle, UIntPtr exit_code); - -// ------------------------------------------------------------------------ -// Memory Manager API. -// ------------------------------------------------------------------------ - -/// @brief Creates a new heap from the process's address space. -/// @param len the length of it. -/// @param flags the flags of it. -/// @return heap pointer. -IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags); - -/// @brief Destroys the pointer -/// @param heap the heap itself. -/// @return void. -IMPORT_C SInt32 MmDestroyHeap(_Input VoidPtr heap); - -/// @brief Change protection flags of a memory region. -IMPORT_C SInt32 MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags); - -/// @brief Change protection flags of a memory region. -IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap); - -/// @brief Fill memory region with CRC32. -IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap); - -/// @brief Copy memory region. -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); - -/// @brief Compare memory regions. -IMPORT_C SInt64 MmCmpMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); - -/// @brief Fill memory region. -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value); - -/// @brief Compare string regions. -IMPORT_C SInt64 MmStrCmp(_Input const Char* dest, _Input const Char* src); - -/// @brief Get length of string. -IMPORT_C SInt64 MmStrLen(const Char* str); - -// ------------------------------------------------------------------------ -// @brief Error API. -// ------------------------------------------------------------------------ - -IMPORT_C SInt32 ErrGetLastError(Void); - -// ------------------------------------------------------------------------ -// @brief Threading API. -// ------------------------------------------------------------------------ - -/// @brief Exit the current thread. -/// @param exit_code the exit code. -IMPORT_C SInt32 ThrExitCurrentThread(_Input SInt32 exit_code); - -/// @brief Exit the main thread. -/// @param exit_code the exit code. -IMPORT_C SInt32 ThrExitMainThread(_Input SInt32 exit_code); - -/// @brief Exit a thread. -/// @param thread the thread to exit. -/// @param exit_code the exit code. -IMPORT_C SInt32 ThrExitThread(_Input ThreadRef thread, _Input SInt32 exit_code); - -/// @brief Thread procedure function type. -typedef SInt32 (*ThrProcKind)(SInt32 argc, Char** argv); - -/// @brief Creates a thread. -/// @param procedure the thread procedure. -/// @param argument_count number of arguments inside that thread. -/// @param flags Thread flags. -/// @return the thread object. -IMPORT_C ThreadRef ThrCreateThread(const Char* thread_name, ThrProcKind procedure, - SInt32 argument_count, SInt32 flags); - -/// @brief Yields the current thread. -/// @param thread the thread to yield. -IMPORT_C SInt32 ThrYieldThread(ThreadRef thrd); - -/// @brief Joins a thread. -/// @param thread the thread to join. -IMPORT_C SInt32 ThrJoinThread(ThreadRef thrd); - -/// @brief Detach a thread. -/// @param thread the thread to detach. -IMPORT_C SInt32 ThrDetachThread(ThreadRef thrd); - -// ------------------------------------------------------------------------ -// @brief Drive Management API. -// ------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------ // -/// @brief Get the default drive letter. -/// @param void. -/// @return the drive letter. -// ------------------------------------------------------------------------------------------ // -IMPORT_C Char* DrvGetDefaultDriveLetter(Void); - -// ------------------------------------------------------------------------------------------ // -/// @brief Get the drive letter from a path. -/// @param path the path. -/// @return the drive letter. -// ------------------------------------------------------------------------------------------ // -IMPORT_C Char* DrvGetDriveLetterFromPath(_Input const Char* path); - -// ------------------------------------------------------------------------------------------ // -/// @brief Get a mounted drive from a letter. -/// @param letter the letter (A..Z). -/// @return the drive object. -// ------------------------------------------------------------------------------------------ // -IMPORT_C Ref DrvGetMountedDrive(_Input Char letter); - -// ------------------------------------------------------------------------------------------ // -/// @brief Mount a drive. -/// @param path the path to mount. -/// @param letter the letter to mount. -// ------------------------------------------------------------------------------------------ // -IMPORT_C Void DrvMountDrive(_Input const Char* path, _Input const Char* letter); - -// ------------------------------------------------------------------------------------------ // -/// @brief Unmount a drive. -/// @param letter the letter to unmount. -// ------------------------------------------------------------------------------------------ // -IMPORT_C Void DrvUnmountDrive(_Input Char letter); - -// ------------------------------------------------------------------------ -// Event handling API, use to listen to OS specific events. -// ------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------ // -/// @brief Add an event listener. -/// @param event_name the event name. -/// @param listener the listener to add. -/// @return the event listener. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C Void EvtAddListener(_Input const Char* event_name, _Input Ref listener); - -// ------------------------------------------------------------------------------------------ // -/// @brief Remove an event listener. -/// @param event_name the event name. -/// @param listener the listener to remove. -/// @return the event listener. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input Ref listener); - -// ------------------------------------------------------------------------------------------ // -/// @brief Dispatch an event. -/// @param event_name the event name. -/// @param event_data the event data. -/// @return the event data. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); - -// ------------------------------------------------------------------------------------------ // -// Power API. -// ------------------------------------------------------------------------------------------ // - -enum { - kPowerCodeInvalid = 0, - kPowerCodeShutdown = 12, - kPowerCodeReboot, - kPowerCodeSleep, - kPowerCodeWake, - kPowerCodeCount, -}; - -IMPORT_C SInt32 PwrReadCode(_Output SInt32& code); - -IMPORT_C SInt32 PwrSendCode(_Output SInt32& code); - -// ------------------------------------------------------------------------------------------ // -// CD-ROM API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C SInt32 CdEjectDrive(_Input Char drv_letter); - -IMPORT_C SInt32 CdOpenTray(Void); - -IMPORT_C SInt32 CdCloseTray(Void); - -// ------------------------------------------------------------------------------------------ // -// Printer API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C SInt32 PrintOut(IORef file /* nullptr to direct to stdout */, const Char* fmt, ...); - -IMPORT_C SInt32 PrintIn(IORef file /* nullptr to direct to stdout */, const Char* fmt, ...); - -IMPORT_C IORef PrintCreate(Void); - -IMPORT_C SInt32 PrintRelease(IORef); - -IMPORT_C IORef PrintGet(const Char* path); - -// ------------------------------------------------------------------------------------------ // -// @brief Scheduler/Debug API. -// ------------------------------------------------------------------------------------------ // - -typedef SInt32 AffinityRef; -typedef UInt64 ProcessRef; - -IMPORT_C SInt32 SchedSetAffinity(_Input ProcessRef, SInt32 req, _Input AffinityRef*); - -IMPORT_C SInt32 SchedGetAffinity(_Input ProcessRef, _InOut AffinityRef*); - -IMPORT_C SInt32 SchedFireSignal(_Input ProcessRef, SInt32); - -IMPORT_C SInt32 SchedReadMemory(_Input ProcessRef, SInt32, SInt32); - -IMPORT_C SInt32 SchedWriteMemory(_Input ProcessRef, SInt32, SInt32); - -IMPORT_C UIntPtr SchedGetCurrentProcessID(Void); - -// ------------------------------------------------------------------------------------------ // -// @brief Filesystem API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C BOOL FsCopy(const Char* path, const Char* dst); - -IMPORT_C BOOL FsMove(const Char* path, const Char* dst); - -IMPORT_C BOOL FsExists(const Char* path); - -IMPORT_C BOOL FsCreateDir(const Char* path); - -IMPORT_C BOOL FsCreateFile(const Char* path); - -IMPORT_C BOOL FsCreateAlias(const Char* path, const Char* from); - -// ------------------------------------------------------------------------------------------ // -// @brief Installable Filesystem API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C BOOL IfsMount(const Char* path, const Char* drive_letter); - -IMPORT_C BOOL IfsUnmount(const Char* drive_letter); - -IMPORT_C BOOL IfsIsMounted(const Char* drive_letter); - -// ------------------------------------------------------------------------------------------ // -// @brief String Manip API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C Char* StrFmt(const Char* fmt, ...); - -IMPORT_C UInt64 StrMathToNumber(const Char* in, const Char** endp, const SInt16 base); - -#endif // ifndef LIBSYS_SYSTEM_CALLS_H diff --git a/dev/libSystem/SystemKit/Err.h b/dev/libSystem/SystemKit/Err.h new file mode 100644 index 00000000..c0a2282b --- /dev/null +++ b/dev/libSystem/SystemKit/Err.h @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include + +/// @file Err.h +/// @brief Process Codes type and values. +/// @author Amlal El Mahrouss (amlal@nekernel.org) + +#define err_local_ok() (kLastError == kErrorSuccess) +#define err_local_fail() (kLastError != kErrorSuccess) +#define err_local_get() (kLastError) + +typedef SInt32 ErrRef; + +inline constexpr ErrRef kErrorSuccess = 0; +inline constexpr ErrRef kErrorExecutable = 33; +inline constexpr ErrRef kErrorExecutableLib = 34; +inline constexpr ErrRef kErrorFileNotFound = 35; +inline constexpr ErrRef kErrorDirectoryNotFound = 36; +inline constexpr ErrRef kErrorDiskReadOnly = 37; +inline constexpr ErrRef kErrorDiskIsFull = 38; +inline constexpr ErrRef kErrorProcessFault = 39; +inline constexpr ErrRef kErrorSocketHangUp = 40; +inline constexpr ErrRef kErrorThreadLocalStorage = 41; +inline constexpr ErrRef kErrorMath = 42; +inline constexpr ErrRef kErrorNoNetwork = 43; +inline constexpr ErrRef kErrorHeapOutOfMemory = 44; +inline constexpr ErrRef kErrorNoSuchDisk = 45; +inline constexpr ErrRef kErrorFileExists = 46; +inline constexpr ErrRef kErrorFormatFailed = 47; +inline constexpr ErrRef kErrorNetworkTimeout = 48; +inline constexpr ErrRef kErrorInternal = 49; +inline constexpr ErrRef kErrorForkAlreadyExists = 50; +inline constexpr ErrRef kErrorOutOfTeamSlot = 51; +inline constexpr ErrRef kErrorHeapNotPresent = 52; +inline constexpr ErrRef kErrorNoEntrypoint = 53; +inline constexpr ErrRef kErrorDiskIsCorrupted = 54; +inline constexpr ErrRef kErrorDisk = 55; +inline constexpr ErrRef kErrorInvalidData = 56; +inline constexpr ErrRef kErrorAsync = 57; +inline constexpr ErrRef kErrorNonBlocking = 58; +inline constexpr ErrRef kErrorIPC = 59; +inline constexpr ErrRef kErrorSign = 60; +inline constexpr ErrRef kErrorInvalidCreds = 61; +inline constexpr ErrRef kErrorCDTrayBroken = 62; +inline constexpr ErrRef kErrorUnrecoverableDisk = 63; +inline constexpr ErrRef kErrorFileLocked = 64; +inline constexpr ErrRef kErrorDiskIsTooTiny = 65; +inline constexpr ErrRef kErrorUnimplemented = -1; + +/// @brief The last error reported by the system to the process. +IMPORT_C ErrRef kLastError; diff --git a/dev/libSystem/SystemKit/Jail.h b/dev/libSystem/SystemKit/Jail.h new file mode 100644 index 00000000..93734dcf --- /dev/null +++ b/dev/libSystem/SystemKit/Jail.h @@ -0,0 +1,23 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include + +/// @file Jail.h +/// @brief NeKernel Jail System + +struct JAIL_INFO; +struct JAIL; + +/// @brief Jail information (client side struct) +struct JAIL_INFO +{ + SInt32 fParentID; + SInt32 fJailHash; + SInt64 fACL; +}; \ No newline at end of file diff --git a/dev/libSystem/SystemKit/Macros.h b/dev/libSystem/SystemKit/Macros.h new file mode 100644 index 00000000..48c586cc --- /dev/null +++ b/dev/libSystem/SystemKit/Macros.h @@ -0,0 +1,126 @@ +/* ------------------------------------------- + +Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +File: Macros.h +Purpose: libsci Macros header. + +------------------------------------------- */ + +#pragma once + +/***********************************************************************************/ +/// @file libSystem/Macros.h +/// @brief Macros and Core types of the SCI (System Call Interface). +/***********************************************************************************/ + +#include + +#define ATTRIBUTE(X) __attribute__((X)) + +#define IMPORT_CXX extern "C++" +#define IMPORT_C extern "C" + +#define DEPRECATED ATTRIBUTE(deprecated) + +#define EXIT_SUCCESS (0) +#define EXIT_FAILURE (1) + +#define FILE_MAX_LEN (256) + +#ifndef BOOL +#define BOOL bool +#endif + +typedef bool Bool; +typedef bool Boolean; +typedef void Void; + +#ifndef __cplusplus +#define true (1) +#define false (0) +#endif + +#define YES true +#define NO false + +typedef __UINT64_TYPE__ UInt64; +typedef __UINT32_TYPE__ UInt32; +typedef __UINT16_TYPE__ UInt16; +typedef __UINT8_TYPE__ UInt8; + +typedef __SIZE_TYPE__ SizeT; + +typedef __INT64_TYPE__ SInt64; +typedef __INT32_TYPE__ SInt32; +typedef __INT16_TYPE__ SInt16; +typedef __INT8_TYPE__ SInt8; + +typedef void* VoidPtr; +typedef __UINTPTR_TYPE__ UIntPtr; +typedef char Char; + +#ifdef __cplusplus +typedef decltype(nullptr) nullPtr; +typedef nullPtr NullPtr; + +#define LIBSYS_COPY_DELETE(KLASS) \ + KLASS& operator=(const KLASS&) = delete; \ + KLASS(const KLASS&) = delete; + +#define LIBSYS_COPY_DEFAULT(KLASS) \ + KLASS& operator=(const KLASS&) = default; \ + KLASS(const KLASS&) = default; + +#define LIBSYS_MOVE_DELETE(KLASS) \ + KLASS& operator=(KLASS&&) = delete; \ + KLASS(KLASS&&) = delete; + +#define LIBSYS_MOVE_DEFAULT(KLASS) \ + KLASS& operator=(KLASS&&) = default; \ + KLASS(KLASS&&) = default; + +#endif + +#define MUST_PASS(X) _rtl_assert(X, __FILE__) + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(X) \ + (((sizeof(X) / sizeof(*(X))) / (static_cast(!(sizeof(X) % sizeof(*(X))))))) +#endif + +#ifndef KIB +#define KIB(X) (UInt64)((X) / 1024) +#endif + +#ifndef kib_cast +#define kib_cast(X) (UInt64)((X) *1024) +#endif + +#ifndef MIB +#define MIB(X) (UInt64)((UInt64) KIB(X) / 1024) +#endif + +#ifndef mib_cast +#define mib_cast(X) (UInt64)((UInt64) kib_cast(X) * 1024) +#endif + +#ifndef GIB +#define GIB(X) (UInt64)((UInt64) MIB(X) / 1024) +#endif + +#ifndef gib_cast +#define gib_cast(X) (UInt64)((UInt64) mib_cast(X) * 1024) +#endif + +#ifndef TIB +#define TIB(X) (UInt64)((UInt64) GIB(X) / 1024) +#endif + +#ifndef tib_cast +#define tib_cast(X) ((UInt64) gib_cast(X) * 1024) +#endif + +#define LIBSYS_UNUSED(X) ((void) X) + +IMPORT_C void _rtl_assert(Bool expr, const Char* origin); diff --git a/dev/libSystem/SystemKit/Syscall.h b/dev/libSystem/SystemKit/Syscall.h new file mode 100644 index 00000000..1a334ead --- /dev/null +++ b/dev/libSystem/SystemKit/Syscall.h @@ -0,0 +1,19 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include +#include + +#ifndef SYSCALL_HASH +#define SYSCALL_HASH(str) (UInt64)str +#endif // !SYSCALL_HASH + +IMPORT_C VoidPtr libsys_syscall_arg_1(SizeT id); +IMPORT_C VoidPtr libsys_syscall_arg_2(SizeT id, VoidPtr arg1); +IMPORT_C VoidPtr libsys_syscall_arg_3(SizeT id, VoidPtr arg1, VoidPtr arg3); +IMPORT_C VoidPtr libsys_syscall_arg_4(SizeT id, VoidPtr arg1, VoidPtr arg3, VoidPtr arg4); diff --git a/dev/libSystem/SystemKit/System.h b/dev/libSystem/SystemKit/System.h new file mode 100644 index 00000000..b3d10e32 --- /dev/null +++ b/dev/libSystem/SystemKit/System.h @@ -0,0 +1,385 @@ +/* ------------------------------------------- + +Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +File: System.h +Purpose: System Call Interface. + +------------------------------------------- */ + +#ifndef LIBSYS_SYSTEM_CALLS_H +#define LIBSYS_SYSTEM_CALLS_H + +#include + +// ------------------------------------------------------------------------------------------ // +/// @brief Types API. +// ------------------------------------------------------------------------------------------ // + +struct REF_TYPE { + UInt64 __hash; /// @brief Hash of the syscall + VoidPtr __self; /// @brief Syscall self value. +}; + +typedef REF_TYPE* Ref; + +typedef Ref IORef; +typedef Ref FSRef; +typedef Ref DylibRef; +typedef Ref ThreadRef; +typedef Ref SocketRef; +typedef Ref NetworkRef; +typedef Ref MutexRef; +typedef Ref EventRef; +typedef Ref SemaphoreRef; + +// ------------------------------------------------------------------------------------------ // +/// @brief Dynamic Loader API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Get function which is part of the Dylib. +/// @param symbol the symbol to look for +/// @param dll_handle the Dylib handle. +/// @return the proc pointer. +IMPORT_C Ref LdrGetDylibSymbolFromHandle(_Input const Char* symbol, _Input Ref dll_handle); + +/// @brief Open Dylib handle. +/// @param path dll path. +/// @param drv driver letter. +/// @return a dylib ref. +IMPORT_C Ref LdrOpenDylibHandle(_Input const Char* path, _Input const Char* drive_letter); + +/// @brief Close Dylib handle +/// @param dll_handle the dylib ref. +/// @return whether it closed or not. +IMPORT_C UInt32 LdrCloseDylibHandle(_Input Ref* dll_handle); + +// ------------------------------------------------------------------------------------------ // +// File API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Opens a file from a drive. +/// @param fs_path the filesystem path. +/// @param drive_letter drive name, use NULL to use default drive location. +/// @return the file descriptor of the file. +IMPORT_C Ref IoOpenFile(const Char* fs_path, const Char* drive_letter); + +/// @brief Closes a file and flushes its content. +/// @param file_desc the file descriptor. +/// @return Function doesn't return a type. +IMPORT_C Void IoCloseFile(_Input Ref file_desc); + +/// @brief I/O control (ioctl) on a file. +/// @param file_desc the file descriptor. +/// @param ioctl_code the ioctl code. +/// @param in_data the input data. +/// @param out_data the output data. +/// @return the number of bytes written. +/// @note This function is used to control the file descriptor, introduced for HeFS. +IMPORT_C SInt32 IoCtrlFile(_Input Ref file_desc, _Input UInt32 ioctl_code, _Input VoidPtr in_data, + _Output VoidPtr out_data); + +/// @brief Gets the file mime (if any) +/// @param file_desc the file descriptor. +IMPORT_C const Char* IoMimeFile(_Input Ref file_desc); + +/// @brief Gets the dir DIM. +/// @param dir_desc directory descriptor. +/// @note only works in HeFS, will return nil-x/nil if used on any other filesystem. +IMPORT_C const Char* IoDimFile(_Input Ref dir_desc); + +/// @brief Write data to a file ref +/// @param file_desc the file descriptor. +/// @param out_data the data to write. +/// @param sz_data the size of the data to write. +/// @return the number of bytes written. +IMPORT_C UInt32 IoWriteFile(_Input Ref file_desc, _Output VoidPtr out_data, SizeT sz_data); + +/// @brief Read data from a file. +/// @param file_desc the file descriptor. +/// @param out_data the data to read. +/// @param sz_data the size of the data to read. +IMPORT_C UInt32 IoReadFile(_Input Ref file_desc, _Output VoidPtr* out_data, SizeT sz_data); + +/// @brief Rewind the file pointer to the beginning of the file. +/// @param file_desc the file descriptor. +/// @return the number of bytes read. +IMPORT_C UInt64 IoRewindFile(_Input Ref file_desc); + +/// @brief Tell the current position of the file pointer. +/// @param file_desc the file descriptor. +/// @return the current position of the file pointer. +IMPORT_C UInt64 IoTellFile(_Input Ref file_desc); + +/// @brief Seek file offset from file descriptor. +IMPORT_C UInt64 IoSeekFile(_Input Ref file_desc, UInt64 file_offset); + +// ------------------------------------------------------------------------ +// Process API. +// ------------------------------------------------------------------------ + +/// @brief Spawns a Thread Information Block and Global Information Block inside the current +/// process. +/// @param process_id Target Process ID, must be valid. +/// @return > 0 error occurred or already present, = 0 success. +IMPORT_C UInt32 RtlSpawnIB(UIntPtr process_id); + +/// @brief Spawns a process with a unique pid (stored as UIntPtr). +/// @param process_path process filesystem path. +/// @return > 0 process was created. +IMPORT_C UIntPtr RtlSpawnProcess(const Char* process_path, SizeT argc, Char** argv, Char** envp, + SizeT envp_len); + +/// @brief Exits a process with an exit_code. +/// @return if it has succeeded true, otherwise false. +IMPORT_C Bool RtlExitProcess(UIntPtr handle, UIntPtr exit_code); + +// ------------------------------------------------------------------------ +// Memory Manager API. +// ------------------------------------------------------------------------ + +/// @brief Creates a new heap from the process's address space. +/// @param len the length of it. +/// @param flags the flags of it. +/// @return heap pointer. +IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags); + +/// @brief Destroys the pointer +/// @param heap the heap itself. +/// @return void. +IMPORT_C SInt32 MmDestroyHeap(_Input VoidPtr heap); + +/// @brief Change protection flags of a memory region. +IMPORT_C SInt32 MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags); + +/// @brief Change protection flags of a memory region. +IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap); + +/// @brief Fill memory region with CRC32. +IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap); + +/// @brief Copy memory region. +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); + +/// @brief Compare memory regions. +IMPORT_C SInt64 MmCmpMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); + +/// @brief Fill memory region. +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value); + +/// @brief Compare string regions. +IMPORT_C SInt64 MmStrCmp(_Input const Char* dest, _Input const Char* src); + +/// @brief Get length of string. +IMPORT_C SInt64 MmStrLen(const Char* str); + +// ------------------------------------------------------------------------ +// @brief Error API. +// ------------------------------------------------------------------------ + +IMPORT_C SInt32 ErrGetLastError(Void); + +// ------------------------------------------------------------------------ +// @brief Threading API. +// ------------------------------------------------------------------------ + +/// @brief Exit the current thread. +/// @param exit_code the exit code. +IMPORT_C SInt32 ThrExitCurrentThread(_Input SInt32 exit_code); + +/// @brief Exit the main thread. +/// @param exit_code the exit code. +IMPORT_C SInt32 ThrExitMainThread(_Input SInt32 exit_code); + +/// @brief Exit a thread. +/// @param thread the thread to exit. +/// @param exit_code the exit code. +IMPORT_C SInt32 ThrExitThread(_Input ThreadRef thread, _Input SInt32 exit_code); + +/// @brief Thread procedure function type. +typedef SInt32 (*ThrProcKind)(SInt32 argc, Char** argv); + +/// @brief Creates a thread. +/// @param procedure the thread procedure. +/// @param argument_count number of arguments inside that thread. +/// @param flags Thread flags. +/// @return the thread object. +IMPORT_C ThreadRef ThrCreateThread(const Char* thread_name, ThrProcKind procedure, + SInt32 argument_count, SInt32 flags); + +/// @brief Yields the current thread. +/// @param thread the thread to yield. +IMPORT_C SInt32 ThrYieldThread(ThreadRef thrd); + +/// @brief Joins a thread. +/// @param thread the thread to join. +IMPORT_C SInt32 ThrJoinThread(ThreadRef thrd); + +/// @brief Detach a thread. +/// @param thread the thread to detach. +IMPORT_C SInt32 ThrDetachThread(ThreadRef thrd); + +// ------------------------------------------------------------------------ +// @brief Drive Management API. +// ------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------ // +/// @brief Get the default drive letter. +/// @param void. +/// @return the drive letter. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Char* DrvGetDefaultDriveLetter(Void); + +// ------------------------------------------------------------------------------------------ // +/// @brief Get the drive letter from a path. +/// @param path the path. +/// @return the drive letter. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Char* DrvGetDriveLetterFromPath(_Input const Char* path); + +// ------------------------------------------------------------------------------------------ // +/// @brief Get a mounted drive from a letter. +/// @param letter the letter (A..Z). +/// @return the drive object. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Ref DrvGetMountedDrive(_Input Char letter); + +// ------------------------------------------------------------------------------------------ // +/// @brief Mount a drive. +/// @param path the path to mount. +/// @param letter the letter to mount. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Void DrvMountDrive(_Input const Char* path, _Input const Char* letter); + +// ------------------------------------------------------------------------------------------ // +/// @brief Unmount a drive. +/// @param letter the letter to unmount. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Void DrvUnmountDrive(_Input Char letter); + +// ------------------------------------------------------------------------ +// Event handling API, use to listen to OS specific events. +// ------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------ // +/// @brief Add an event listener. +/// @param event_name the event name. +/// @param listener the listener to add. +/// @return the event listener. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Void EvtAddListener(_Input const Char* event_name, _Input Ref listener); + +// ------------------------------------------------------------------------------------------ // +/// @brief Remove an event listener. +/// @param event_name the event name. +/// @param listener the listener to remove. +/// @return the event listener. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input Ref listener); + +// ------------------------------------------------------------------------------------------ // +/// @brief Dispatch an event. +/// @param event_name the event name. +/// @param event_data the event data. +/// @return the event data. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); + +// ------------------------------------------------------------------------------------------ // +// Power API. +// ------------------------------------------------------------------------------------------ // + +enum { + kPowerCodeInvalid = 0, + kPowerCodeShutdown = 12, + kPowerCodeReboot, + kPowerCodeSleep, + kPowerCodeWake, + kPowerCodeCount, +}; + +IMPORT_C SInt32 PwrReadCode(_Output SInt32& code); + +IMPORT_C SInt32 PwrSendCode(_Output SInt32& code); + +// ------------------------------------------------------------------------------------------ // +// CD-ROM API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C SInt32 CdEjectDrive(_Input Char drv_letter); + +IMPORT_C SInt32 CdOpenTray(Void); + +IMPORT_C SInt32 CdCloseTray(Void); + +// ------------------------------------------------------------------------------------------ // +// Printer API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C SInt32 PrintOut(IORef file /* nullptr to direct to stdout */, const Char* fmt, ...); + +IMPORT_C SInt32 PrintIn(IORef file /* nullptr to direct to stdout */, const Char* fmt, ...); + +IMPORT_C IORef PrintCreate(Void); + +IMPORT_C SInt32 PrintRelease(IORef); + +IMPORT_C IORef PrintGet(const Char* path); + +// ------------------------------------------------------------------------------------------ // +// @brief Scheduler/Debug API. +// ------------------------------------------------------------------------------------------ // + +typedef SInt32 AffinityRef; +typedef UInt64 ProcessRef; + +IMPORT_C SInt32 SchedSetAffinity(_Input ProcessRef, SInt32 req, _Input AffinityRef*); + +IMPORT_C SInt32 SchedGetAffinity(_Input ProcessRef, _InOut AffinityRef*); + +IMPORT_C SInt32 SchedFireSignal(_Input ProcessRef, SInt32); + +IMPORT_C SInt32 SchedReadMemory(_Input ProcessRef, SInt32, SInt32); + +IMPORT_C SInt32 SchedWriteMemory(_Input ProcessRef, SInt32, SInt32); + +IMPORT_C UIntPtr SchedGetCurrentProcessID(Void); + +// ------------------------------------------------------------------------------------------ // +// @brief Filesystem API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C BOOL FsCopy(const Char* path, const Char* dst); + +IMPORT_C BOOL FsMove(const Char* path, const Char* dst); + +IMPORT_C BOOL FsExists(const Char* path); + +IMPORT_C BOOL FsCreateDir(const Char* path); + +IMPORT_C BOOL FsCreateFile(const Char* path); + +IMPORT_C BOOL FsCreateAlias(const Char* path, const Char* from); + +// ------------------------------------------------------------------------------------------ // +// @brief Installable Filesystem API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C BOOL IfsMount(const Char* path, const Char* drive_letter); + +IMPORT_C BOOL IfsUnmount(const Char* drive_letter); + +IMPORT_C BOOL IfsIsMounted(const Char* drive_letter); + +// ------------------------------------------------------------------------------------------ // +// @brief String Manip API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Char* StrFmt(const Char* fmt, ...); + +IMPORT_C UInt64 StrMathToNumber(const Char* in, const Char** endp, const SInt16 base); + +#endif // ifndef LIBSYS_SYSTEM_CALLS_H diff --git a/dev/libSystem/src/Makefile b/dev/libSystem/src/Makefile index 41c99c4d..39af446b 100644 --- a/dev/libSystem/src/Makefile +++ b/dev/libSystem/src/Makefile @@ -13,4 +13,4 @@ error: .PHONY: libsys_asm_io_x64 libsys_asm_io_x64: - $(ASM) $(FLAGS) SystemProc.asm -o SystemProc.asm.obj + $(ASM) $(FLAGS) SystemProc.asm -o SystemProc.stub.obj diff --git a/dev/libSystem/src/SystemAPI.cc b/dev/libSystem/src/SystemAPI.cc deleted file mode 100644 index 37e835c1..00000000 --- a/dev/libSystem/src/SystemAPI.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include -#include - -/// @file SystemAPI.cc -/// @brief System wide API for NeKernel. - -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) { - if (!len || !dest || !src) { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) { - ((Char*) dest)[i] = ((Char*) src)[i]; - } - - return dest; -} - -IMPORT_C SInt64 MmStrLen(const Char* in) { - if (!in) return 0; - - SizeT len{0}; - - do { - ++len; - } while (in[len] != '\0'); - - return len; -} - -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) { - if (!len || !dest) { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) { - ((Char*) dest)[i] = value; - } - - return dest; -} - -IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) { - return (Ref)libsys_syscall_arg_3(SYSCALL_HASH('IoOpenFile'), reinterpret_cast(const_cast(path)), - reinterpret_cast(const_cast(drv_letter))); -} - -IMPORT_C Void IoCloseFile(_Input Ref desc) { - libsys_syscall_arg_2(2, desc); -} - -IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) { - auto ret = (volatile UInt64*) libsys_syscall_arg_3(SYSCALL_HASH('IoSeekFile'), reinterpret_cast(desc), - reinterpret_cast(&off)); - - MUST_PASS((*ret) != ~0UL); - return *ret; -} - -IMPORT_C UInt64 IoTellFile(_Input Ref desc) { - auto ret = (volatile UInt64*) libsys_syscall_arg_2(SYSCALL_HASH('IoTellFile'), reinterpret_cast(desc)); - return *ret; -} - -IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) { - va_list args; - - va_start(args, fmt); - - auto ret = (volatile UInt64*) libsys_syscall_arg_4( - SYSCALL_HASH('PrintOut'), reinterpret_cast(desc), reinterpret_cast(const_cast(fmt)), args); - - va_end(args); - - return *ret; -} - -IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { - if (!expr) { - PrintOut(nullptr, "Assertion failed: %s\r", origin); - PrintOut(nullptr, "Origin: %s\r", origin); - - libsys_syscall_arg_1(SYSCALL_HASH('_rtl_debug_break')); - } -} diff --git a/dev/libSystem/src/SystemImpl.cc b/dev/libSystem/src/SystemImpl.cc new file mode 100644 index 00000000..6c2201fe --- /dev/null +++ b/dev/libSystem/src/SystemImpl.cc @@ -0,0 +1,91 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include +#include + +/// @file SystemAPI.cc +/// @brief System wide API for NeKernel. + +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) { + if (!len || !dest || !src) { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) { + ((Char*) dest)[i] = ((Char*) src)[i]; + } + + return dest; +} + +IMPORT_C SInt64 MmStrLen(const Char* in) { + if (!in) return 0; + + SizeT len{0}; + + do { + ++len; + } while (in[len] != '\0'); + + return len; +} + +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) { + if (!len || !dest) { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) { + ((Char*) dest)[i] = value; + } + + return dest; +} + +IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) { + return (Ref)libsys_syscall_arg_3(SYSCALL_HASH('IoOpenFile'), reinterpret_cast(const_cast(path)), + reinterpret_cast(const_cast(drv_letter))); +} + +IMPORT_C Void IoCloseFile(_Input Ref desc) { + libsys_syscall_arg_2(2, desc); +} + +IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) { + auto ret = (volatile UInt64*) libsys_syscall_arg_3(SYSCALL_HASH('IoSeekFile'), reinterpret_cast(desc), + reinterpret_cast(&off)); + + MUST_PASS((*ret) != ~0UL); + return *ret; +} + +IMPORT_C UInt64 IoTellFile(_Input Ref desc) { + auto ret = (volatile UInt64*) libsys_syscall_arg_2(SYSCALL_HASH('IoTellFile'), reinterpret_cast(desc)); + return *ret; +} + +IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) { + va_list args; + + va_start(args, fmt); + + auto ret = (volatile UInt64*) libsys_syscall_arg_4( + SYSCALL_HASH('PrintOut'), reinterpret_cast(desc), reinterpret_cast(const_cast(fmt)), args); + + va_end(args); + + return *ret; +} + +IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { + if (!expr) { + PrintOut(nullptr, "Assertion failed: %s\r", origin); + PrintOut(nullptr, "Origin: %s\r", origin); + + libsys_syscall_arg_1(SYSCALL_HASH('_rtl_debug_break')); + } +} diff --git a/dev/libSystem/src/SystemProc.asm b/dev/libSystem/src/SystemProc.asm index bc41059a..299b59f9 100644 --- a/dev/libSystem/src/SystemProc.asm +++ b/dev/libSystem/src/SystemProc.asm @@ -21,7 +21,8 @@ libsys_syscall_arg_1: mov rbp, rsp mov r8, rcx - syscall + + int 50 pop rbp @@ -33,7 +34,9 @@ libsys_syscall_arg_2: mov r8, rcx mov r9, rdx - syscall + + int 50 + pop rbp ret @@ -46,7 +49,8 @@ libsys_syscall_arg_3: mov r9, rdx mov r10, rbx - syscall + int 50 + pop rbp ret @@ -60,7 +64,8 @@ libsys_syscall_arg_4: mov r10, rbx mov r11, rax - syscall + int 50 + pop rbp ret diff --git a/dev/open_msg/.keep b/dev/open_msg/.keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/open_msg/MsgKit/Server.h b/dev/open_msg/MsgKit/Server.h new file mode 100644 index 00000000..867d3b54 --- /dev/null +++ b/dev/open_msg/MsgKit/Server.h @@ -0,0 +1,22 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include +#include + +struct OPENMSG_EXPR; + +struct OPENMSG_EXPR { + Kernel::KString* l_head; + Kernel::MutableArray l_args; +}; + +typedef Kernel::Void(*openmsg_func_t)(OPENMSG_EXPR* arg); + +EXTERN_C Kernel::Void openmsg_init_library(openmsg_func_t* funcs, Kernel::SizeT cnt); +EXTERN_C Kernel::UInt32 openmsg_close_library(Kernel::Void); diff --git a/dev/open_msg/obj/.keep b/dev/open_msg/obj/.keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/open_msg/script/window.msg b/dev/open_msg/script/window.msg new file mode 100644 index 00000000..77d6ef69 --- /dev/null +++ b/dev/open_msg/script/window.msg @@ -0,0 +1,6 @@ +(window + :id 1 + :pos (x 100 y 100) + :size (w 300 h 200) + :title "My App" + :on-click (lambda () (log "Clicked!"))) \ No newline at end of file diff --git a/dev/open_msg/src/.keep b/dev/open_msg/src/.keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/system_sdk/.keep b/dev/system_sdk/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/public/frameworks/CoreFoundation.fwrk/CoreFoundation.json b/public/frameworks/CoreFoundation.fwrk/CoreFoundation.json index a208f57a..076b35ae 100644 --- a/public/frameworks/CoreFoundation.fwrk/CoreFoundation.json +++ b/public/frameworks/CoreFoundation.fwrk/CoreFoundation.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../", "./", "../../../dev", "../../../dev/kernel"], "sources_path": ["src/*.cc"], - "output_name": "./dist/libCoreFoundation.dylib", + "output_name": "./dist/libCoreFoundation.fwrk.dylib", "compiler_flags": [ "-ffreestanding", "-shared", diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index 55e75e5e..d9c528d9 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -6,7 +6,7 @@ #pragma once -#include +#include namespace CF { template diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h index 1f295ea5..500ad544 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h @@ -10,7 +10,7 @@ #pragma once -#include +#include namespace CF { class CFString; diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Property.h b/public/frameworks/CoreFoundation.fwrk/headers/Property.h index 4da173c7..5210bd95 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h @@ -8,7 +8,7 @@ #define _PROPS_H #include -#include +#include #define kMaxPropLen (256U) diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h index cb72a034..87005db1 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -9,7 +9,7 @@ #define _REF_H_ #include -#include +#include namespace CF { template diff --git a/public/frameworks/DiskImage.fwrk/DiskImage.json b/public/frameworks/DiskImage.fwrk/DiskImage.json index aaff409c..16c538e5 100644 --- a/public/frameworks/DiskImage.fwrk/DiskImage.json +++ b/public/frameworks/DiskImage.fwrk/DiskImage.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../", "./", "../../../dev", "../../../dev/kernel"], "sources_path": ["src/*.cc"], - "output_name": "./dist/libDiskImage.dylib", + "output_name": "./dist/libDiskImage.fwrk.dylib", "compiler_flags": [ "-ffreestanding", "-shared", diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index efc21253..53348f3e 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #ifndef __DISK_IMAGE_CDROM__ #define kDISectorSz (512) diff --git a/public/frameworks/KernelTest.fwrk/KernelTest.json b/public/frameworks/KernelTest.fwrk/KernelTest.json index aa70db30..b8c322b6 100644 --- a/public/frameworks/KernelTest.fwrk/KernelTest.json +++ b/public/frameworks/KernelTest.fwrk/KernelTest.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../", "./", "../../../dev", "../../../dev/kernel"], "sources_path": ["src/*.cc"], - "output_name": "./dist/libKernelTest.dylib", + "output_name": "./dist/libKernelTest.fwrk.dylib", "compiler_flags": [ "-ffreestanding", "-shared", diff --git a/public/frameworks/OpenMSG.fwrk/.keep b/public/frameworks/OpenMSG.fwrk/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/frameworks/OpenMSG.fwrk/OpenMSG.json b/public/frameworks/OpenMSG.fwrk/OpenMSG.json new file mode 100644 index 00000000..4bda8798 --- /dev/null +++ b/public/frameworks/OpenMSG.fwrk/OpenMSG.json @@ -0,0 +1,19 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": [ + "./", + "../../../dev/kernel", + "../../../public/frameworks/", + "../../../dev/", + "./" + ], + "sources_path": [], + "output_name": "./dist/libOpenMSG.fwrk.dylib", + "cpp_macros": [ + "kSampleFWVersion=0x0100", + "kSampleFWVersionHighest=0x0100", + "kSampleFWVersionLowest=0x0100", + "__NE_SDK__" + ] +} \ No newline at end of file diff --git a/public/frameworks/OpenMSG.fwrk/headers/.keep b/public/frameworks/OpenMSG.fwrk/headers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/frameworks/OpenMSG.fwrk/src/.keep b/public/frameworks/OpenMSG.fwrk/src/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/frameworks/OpenMSG.fwrk/src/DylibMain.cc b/public/frameworks/OpenMSG.fwrk/src/DylibMain.cc new file mode 100644 index 00000000..814132e3 --- /dev/null +++ b/public/frameworks/OpenMSG.fwrk/src/DylibMain.cc @@ -0,0 +1,5 @@ +#include + +SInt32 _DylibAttach(SInt32 argc, Char* argv[]) { + return EXIT_FAILURE; +} \ No newline at end of file diff --git a/public/frameworks/OpenMSG.fwrk/xml/.keep b/public/frameworks/OpenMSG.fwrk/xml/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/frameworks/OpenMSG.fwrk/xml/app.xml b/public/frameworks/OpenMSG.fwrk/xml/app.xml new file mode 100644 index 00000000..6a46e598 --- /dev/null +++ b/public/frameworks/OpenMSG.fwrk/xml/app.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/public/tools/cc/src/CommandLine.cc b/public/tools/cc/src/CommandLine.cc index f1c72b64..62757c43 100644 --- a/public/tools/cc/src/CommandLine.cc +++ b/public/tools/cc/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024-2025 Amlal El Mahrouss */ -#include +#include /// @brief Placeholder program. diff --git a/public/tools/ld.dyn/src/CommandLine.cc b/public/tools/ld.dyn/src/CommandLine.cc index 70a0dbd9..e64e7837 100644 --- a/public/tools/ld.dyn/src/CommandLine.cc +++ b/public/tools/ld.dyn/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024-2025 Amlal El Mahrouss */ -#include +#include /// @brief Library loader. diff --git a/public/tools/ld.fwrk/src/CommandLine.cc b/public/tools/ld.fwrk/src/CommandLine.cc index 853a4ef7..323e58c7 100644 --- a/public/tools/ld.fwrk/src/CommandLine.cc +++ b/public/tools/ld.fwrk/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024-2025 Amlal El Mahrouss */ -#include +#include /// @brief This program loads a code framework into Kernel's memory. diff --git a/public/tools/manual/src/CommandLine.cc b/public/tools/manual/src/CommandLine.cc index 68594c09..8c75d565 100644 --- a/public/tools/manual/src/CommandLine.cc +++ b/public/tools/manual/src/CommandLine.cc @@ -1,4 +1,4 @@ -#include +#include SInt32 _NeMain(SInt32 argc, Char* argv[]) { LIBSYS_UNUSED(argc); diff --git a/public/tools/mgmt/src/CommandLine.cc b/public/tools/mgmt/src/CommandLine.cc index f3840d01..6015988e 100644 --- a/public/tools/mgmt/src/CommandLine.cc +++ b/public/tools/mgmt/src/CommandLine.cc @@ -1,4 +1,4 @@ -#include +#include SInt32 _NeMain(SInt32 argc, Char* argv[]) { return EXIT_FAILURE; diff --git a/public/tools/mk.fwrk/Common.h b/public/tools/mk.fwrk/Common.h index 89e52471..8e434043 100644 --- a/public/tools/mk.fwrk/Common.h +++ b/public/tools/mk.fwrk/Common.h @@ -7,6 +7,6 @@ #define APPS_COMMON_H #include -#include +#include #endif // APPS_COMMON_H diff --git a/public/tools/mk.fwrk/src/CommandLine.cc b/public/tools/mk.fwrk/src/CommandLine.cc index 423dc12f..87945ddc 100644 --- a/public/tools/mk.fwrk/src/CommandLine.cc +++ b/public/tools/mk.fwrk/src/CommandLine.cc @@ -7,7 +7,7 @@ #include #include -#include +#include #include diff --git a/public/tools/mk.hefs/src/CommandLine.cc b/public/tools/mk.hefs/src/CommandLine.cc index 0b38386a..91a3527d 100644 --- a/public/tools/mk.hefs/src/CommandLine.cc +++ b/public/tools/mk.hefs/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2025 Amlal El Mahrouss */ -#include +#include /// @brief Placeholder program. diff --git a/public/tools/mk.nefs/src/CommandLine.cc b/public/tools/mk.nefs/src/CommandLine.cc index 0b38386a..91a3527d 100644 --- a/public/tools/mk.nefs/src/CommandLine.cc +++ b/public/tools/mk.nefs/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2025 Amlal El Mahrouss */ -#include +#include /// @brief Placeholder program. diff --git a/public/tools/open/src/CommandLine.cc b/public/tools/open/src/CommandLine.cc index 6fa4e2f2..e02fcebc 100644 --- a/public/tools/open/src/CommandLine.cc +++ b/public/tools/open/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024-2025 Amlal El Mahrouss */ -#include +#include /// @brief This program opens an application from **OPEN_APP_BASE_PATH** /// @file CommandLine.cc diff --git a/public/tools/ping/src/CommandLine.cc b/public/tools/ping/src/CommandLine.cc index 580d7973..a9ba177a 100644 --- a/public/tools/ping/src/CommandLine.cc +++ b/public/tools/ping/src/CommandLine.cc @@ -1,4 +1,4 @@ -#include +#include SInt32 _NeMain(SInt32 argc, Char* argv[]) { LIBSYS_UNUSED(argc); diff --git a/tooling/mk_app.py b/tooling/mk_app.py index 5ee6d5b7..7f7cef17 100755 --- a/tooling/mk_app.py +++ b/tooling/mk_app.py @@ -64,7 +64,7 @@ def create_directory_structure(base_path, project_name): proj_cpp_path = os.path.join(base_path, project_name, f"src/CommandLine.cc") - cpp_file = "#include \n\nSInt32 _NeMain(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}" + cpp_file = "#include \n\nSInt32 _NeMain(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}" with open(proj_cpp_path, 'w') as cpp_file_io: cpp_file_io.write(cpp_file) diff --git a/tooling/mk_fwrk.py b/tooling/mk_fwrk.py index e4e5d7de..b2ef99ff 100755 --- a/tooling/mk_fwrk.py +++ b/tooling/mk_fwrk.py @@ -56,7 +56,7 @@ def create_directory_structure(base_path_fwrk, project_file_name, project_name): "sources_path": [ ], - "output_name": f"./dist/{project_name}", + "output_name": f"./dist/lib{project_name}.dylib", "cpp_macros": [ "kSampleFWVersion=0x0100", "kSampleFWVersionHighest=0x0100", @@ -70,7 +70,7 @@ def create_directory_structure(base_path_fwrk, project_file_name, project_name): proj_cpp_path = os.path.join(base_path_fwrk, project_name, f"src/DylibMain.cc") - cpp_file = "#include \n\nSInt32 _DylibAttach(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}" + cpp_file = "#include \n\nSInt32 _DylibAttach(SInt32 argc, Char* argv[]) {\n\treturn EXIT_FAILURE;\n}" with open(proj_cpp_path, 'w') as cpp_file_io: cpp_file_io.write(cpp_file) -- cgit v1.2.3