From d48b2faedce25990b83076cfd71e713b222da25a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 16 Oct 2025 11:58:48 +0200 Subject: feat: `ne_launch`: cli application - and new framework. feat: `ddk`: feat: api! breaking api changes - for v0.0.7 NeKernel. Signed-off-by: Amlal El Mahrouss --- dev/launch/LaunchKit/.keep | 0 dev/launch/LaunchKit/Foundation.h | 21 +++++++++++++++++++++ dev/launch/LaunchKit/LaunchKit.h | 20 -------------------- dev/launch/launch.json | 20 ++++++++++++++++++++ dev/launch/ne_launch.json | 20 -------------------- dev/launch/src/AppMain.cc | 31 +++++++++++++++++++++++++++++++ dev/launch/src/CRT0.S | 18 ------------------ dev/launch/src/CRuntimeZero.S | 26 ++++++++++++++++++++++++++ dev/launch/src/LaunchSrv.cc | 17 ----------------- 9 files changed, 98 insertions(+), 75 deletions(-) delete mode 100644 dev/launch/LaunchKit/.keep create mode 100644 dev/launch/LaunchKit/Foundation.h delete mode 100644 dev/launch/LaunchKit/LaunchKit.h create mode 100644 dev/launch/launch.json delete mode 100644 dev/launch/ne_launch.json create mode 100644 dev/launch/src/AppMain.cc delete mode 100644 dev/launch/src/CRT0.S create mode 100644 dev/launch/src/CRuntimeZero.S delete mode 100644 dev/launch/src/LaunchSrv.cc (limited to 'dev/launch') diff --git a/dev/launch/LaunchKit/.keep b/dev/launch/LaunchKit/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/launch/LaunchKit/Foundation.h b/dev/launch/LaunchKit/Foundation.h new file mode 100644 index 00000000..24df46f6 --- /dev/null +++ b/dev/launch/LaunchKit/Foundation.h @@ -0,0 +1,21 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + + ------------------------------------------- */ + +#pragma once + +#include +#include + +/// @author Amlal El Mahrouss +/// @brief NeKernel Launch Kit - launch programs from it. + +#define NELAUNCH_INFO(MSG) PrintOut(nullptr, "INFO: [LAUNCH] %s\n", MSG) +#define NELAUNCH_WARN(MSG) PrintOut(nullptr, "WARN: [LAUNCH] %s\n", MSG) + +namespace Launch { +using AnyRef = CF::CFRef; +using StatusRef = CF::CFRef; +} // namespace Launch diff --git a/dev/launch/LaunchKit/LaunchKit.h b/dev/launch/LaunchKit/LaunchKit.h deleted file mode 100644 index 34f7c223..00000000 --- a/dev/launch/LaunchKit/LaunchKit.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - - ------------------------------------------- */ - -#pragma once - -#include - -/// @author Amlal El Mahrouss -/// @brief NeKernel Launch Kit. - -#define NELAUNCH_INFO(MSG) PrintOut(nullptr, "INFO: [LAUNCH] %s\n", MSG) -#define NELAUNCH_WARN(MSG) PrintOut(nullptr, "WARN: [LAUNCH] %s\n", MSG) - -namespace Launch { -using LaunchAny = VoidPtr; -using LaunchStatus = SInt32; -} // namespace Launch diff --git a/dev/launch/launch.json b/dev/launch/launch.json new file mode 100644 index 00000000..dbc111b2 --- /dev/null +++ b/dev/launch/launch.json @@ -0,0 +1,20 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["../", "./", "../../public/frameworks"], + "sources_path": ["src/*.cc", "src/*.S"], + "output_name": "ne_launch", + "compiler_flags": [ + "-ffreestanding", + "-shared", + "-fPIC", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17" + ], + "cpp_macros": [ + "kNeLaunchVersion=0x0100", + "kNeLaunchVersionHighest=0x0100", + "kNeLaunchVersionLowest=0x0100" + ] +} diff --git a/dev/launch/ne_launch.json b/dev/launch/ne_launch.json deleted file mode 100644 index e3d26a46..00000000 --- a/dev/launch/ne_launch.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-g++", - "compiler_std": "c++20", - "headers_path": ["../", "./"], - "sources_path": ["src/*.cc", "src/*.S"], - "output_name": "ne_launch", - "compiler_flags": [ - "-ffreestanding", - "-shared", - "-fPIC", - "-fno-rtti", - "-fno-exceptions", - "-Wl,--subsystem=17" - ], - "cpp_macros": [ - "kNeLaunchVersion=0x0100", - "kNeLaunchVersionHighest=0x0100", - "kNeLaunchVersionLowest=0x0100" - ] -} diff --git a/dev/launch/src/AppMain.cc b/dev/launch/src/AppMain.cc new file mode 100644 index 00000000..eef95fba --- /dev/null +++ b/dev/launch/src/AppMain.cc @@ -0,0 +1,31 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + + ------------------------------------------- */ + +#include +#include +#include + +/// @note This called by _NeMain from its own runtime. +extern "C" SInt32 nelaunch_startup_fn(Void) { + /// @todo Start LaunchServices.fwrk services, make the launcher manageable too (via mgmt.launch) + + NELAUNCH_INFO("Turning on launcher..."); + + UInt32* ret = (UInt32*) libsys_syscall_arg_1(libsys_hash_64("__launch_register_pid0")); + + if (ret) { + switch (*ret) { + case kErrorSuccess: { + libsys_syscall_arg_1(libsys_hash_64("__launch_listen_as_root")); + return *ret; + } + default: + break; + } + } + + return kErrorExecutable; +} diff --git a/dev/launch/src/CRT0.S b/dev/launch/src/CRT0.S deleted file mode 100644 index 84a293e6..00000000 --- a/dev/launch/src/CRT0.S +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - - ------------------------------------------- */ - - .text - -.extern nelaunch_startup_fn -.globl _NeMain - -_NeMain: - push %rbp - movq %rsp, %rbp - callq nelaunch_startup_fn - popq %rbp - - retq diff --git a/dev/launch/src/CRuntimeZero.S b/dev/launch/src/CRuntimeZero.S new file mode 100644 index 00000000..8892c661 --- /dev/null +++ b/dev/launch/src/CRuntimeZero.S @@ -0,0 +1,26 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + + ------------------------------------------- */ + +.text + +.extern nelaunch_startup_fn +.extern ThrExitMainThread +.globl _NeMain + +_NeMain: + push %rbp + movq %rsp, %rbp + callq nelaunch_startup_fn + xor %rax, %rax + popq %rbp + + push %rbp + movq %rsp, %rbp + movq %rcx, 0 + callq ThrExitMainThread + popq %rbp + + retq diff --git a/dev/launch/src/LaunchSrv.cc b/dev/launch/src/LaunchSrv.cc deleted file mode 100644 index b79fedf5..00000000 --- a/dev/launch/src/LaunchSrv.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - - ------------------------------------------- */ - -#include -#include - -/// @note This called by _NeMain from its own runtime. -extern "C" SInt32 nelaunch_startup_fn(Void) { - /// @todo Start LaunchServices.fwrk services, make the launcher manageable too (via mgmt.launch) - - NELAUNCH_INFO("Registering NeKernel Launcher..."); - - return kErrorSuccess; -} -- cgit v1.2.3