From 83d870e58457a1d335a1d9b9966a6a1887cc297b Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 24 Nov 2025 03:02:43 +0100 Subject: feat! breaking changes on kernel sources. Signed-off-by: Amlal El Mahrouss --- src/launch/.keep | 0 src/launch/LaunchKit/Foundation.h | 21 +++++++++++++++++++++ src/launch/launch.json | 20 ++++++++++++++++++++ src/launch/obj/.keep | 0 src/launch/src/.keep | 0 src/launch/src/AppMain.cc | 28 ++++++++++++++++++++++++++++ src/launch/src/CRuntimeZero.S | 23 +++++++++++++++++++++++ 7 files changed, 92 insertions(+) create mode 100644 src/launch/.keep create mode 100644 src/launch/LaunchKit/Foundation.h create mode 100644 src/launch/launch.json create mode 100644 src/launch/obj/.keep create mode 100644 src/launch/src/.keep create mode 100644 src/launch/src/AppMain.cc create mode 100644 src/launch/src/CRuntimeZero.S (limited to 'src/launch') diff --git a/src/launch/.keep b/src/launch/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/launch/LaunchKit/Foundation.h b/src/launch/LaunchKit/Foundation.h new file mode 100644 index 00000000..d7eb901f --- /dev/null +++ b/src/launch/LaunchKit/Foundation.h @@ -0,0 +1,21 @@ +/* ======================================== + + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + + ======================================== */ + +#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/src/launch/launch.json b/src/launch/launch.json new file mode 100644 index 00000000..dbc111b2 --- /dev/null +++ b/src/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/src/launch/obj/.keep b/src/launch/obj/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/launch/src/.keep b/src/launch/src/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/launch/src/AppMain.cc b/src/launch/src/AppMain.cc new file mode 100644 index 00000000..10e9ff2b --- /dev/null +++ b/src/launch/src/AppMain.cc @@ -0,0 +1,28 @@ +/* ======================================== + + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + + ======================================== */ + +#include +#include +#include + +/// @note This called by _NeMain from its own runtime. +extern "C" SInt32 nelaunch_startup_fn(Void) { + /// Start LaunchHelpers.fwrk services, and make the launcher manageable too (via mgmt.launch) + UInt32* ret = (UInt32*) libsys_syscall_arg_1(libsys_hash_64("__launch_register_launch_service")); + + 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/src/launch/src/CRuntimeZero.S b/src/launch/src/CRuntimeZero.S new file mode 100644 index 00000000..4f983b46 --- /dev/null +++ b/src/launch/src/CRuntimeZero.S @@ -0,0 +1,23 @@ +/* ======================================== + + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + + ======================================== */ + +.text + +.extern nelaunch_startup_fn +.extern ThrExitMainThread +.globl _NeMain + +_NeMain: + push %rbp + movq %rsp, %rbp + + callq nelaunch_startup_fn + + movq %rcx, 0 + + callq ThrExitMainThread + + popq %rbp -- cgit v1.2.3