summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/launch/LaunchKit/.keep0
-rw-r--r--dev/launch/LaunchKit/Foundation.h (renamed from dev/launch/LaunchKit/LaunchKit.h)7
-rw-r--r--dev/launch/launch.json (renamed from dev/launch/ne_launch.json)2
-rw-r--r--dev/launch/src/AppMain.cc31
-rw-r--r--dev/launch/src/CRuntimeZero.S (renamed from dev/launch/src/CRT0.S)10
-rw-r--r--dev/launch/src/LaunchSrv.cc17
-rw-r--r--dev/libDDK/DriverKit/dev.h4
-rw-r--r--dev/libDDK/src/ddk_dev.c6
-rw-r--r--dev/libDDK/src/ddk_io.c4
9 files changed, 52 insertions, 29 deletions
diff --git a/dev/launch/LaunchKit/.keep b/dev/launch/LaunchKit/.keep
deleted file mode 100644
index e69de29b..00000000
--- a/dev/launch/LaunchKit/.keep
+++ /dev/null
diff --git a/dev/launch/LaunchKit/LaunchKit.h b/dev/launch/LaunchKit/Foundation.h
index 34f7c223..24df46f6 100644
--- a/dev/launch/LaunchKit/LaunchKit.h
+++ b/dev/launch/LaunchKit/Foundation.h
@@ -7,14 +7,15 @@
#pragma once
#include <libSystem/SystemKit/System.h>
+#include <CoreFoundation.fwrk/headers/Ref.h>
/// @author Amlal El Mahrouss
-/// @brief NeKernel Launch Kit.
+/// @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 LaunchAny = VoidPtr;
-using LaunchStatus = SInt32;
+using AnyRef = CF::CFRef<VoidPtr>;
+using StatusRef = CF::CFRef<SInt32>;
} // namespace Launch
diff --git a/dev/launch/ne_launch.json b/dev/launch/launch.json
index e3d26a46..dbc111b2 100644
--- a/dev/launch/ne_launch.json
+++ b/dev/launch/launch.json
@@ -1,7 +1,7 @@
{
"compiler_path": "x86_64-w64-mingw32-g++",
"compiler_std": "c++20",
- "headers_path": ["../", "./"],
+ "headers_path": ["../", "./", "../../public/frameworks"],
"sources_path": ["src/*.cc", "src/*.S"],
"output_name": "ne_launch",
"compiler_flags": [
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 <LaunchKit/Foundation.h>
+#include <libSystem/SystemKit/Err.h>
+#include <libSystem/SystemKit/Syscall.h>
+
+/// @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/CRuntimeZero.S
index 84a293e6..8892c661 100644
--- a/dev/launch/src/CRT0.S
+++ b/dev/launch/src/CRuntimeZero.S
@@ -4,15 +4,23 @@
------------------------------------------- */
- .text
+.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 <LaunchKit/LaunchKit.h>
-#include <libSystem/SystemKit/Err.h>
-
-/// @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;
-}
diff --git a/dev/libDDK/DriverKit/dev.h b/dev/libDDK/DriverKit/dev.h
index adb1c1d0..28f3617d 100644
--- a/dev/libDDK/DriverKit/dev.h
+++ b/dev/libDDK/DriverKit/dev.h
@@ -29,8 +29,8 @@ typedef struct _DDK_DEVICE DDK_FINAL {
/// @brief Open a new device from path.
/// @param path the device's path.
-DDK_EXTERN DDK_DEVICE_PTR open(const char* path);
+DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* path);
/// @brief Close any device.
/// @param device valid device.
-DDK_EXTERN BOOL close(DDK_DEVICE_PTR device);
+DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device);
diff --git a/dev/libDDK/src/ddk_dev.c b/dev/libDDK/src/ddk_dev.c
index d20684aa..c0396eb5 100644
--- a/dev/libDDK/src/ddk_dev.c
+++ b/dev/libDDK/src/ddk_dev.c
@@ -10,15 +10,15 @@
#include <DriverKit/str.h>
/// @brief Open a new binary device from path.
-DDK_EXTERN DDK_DEVICE_PTR open(const char* devicePath) {
+DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* devicePath) {
if (nil == devicePath) return nil;
- return ke_call_dispatch("dk_open_dev", 1, (void*) devicePath, kstrlen(devicePath));
+ return (DDK_DEVICE_PTR)ke_call_dispatch("dk_open_dev", 1, (void*) devicePath, kstrlen(devicePath));
}
/// @brief Close any device.
/// @param device valid device.
-DDK_EXTERN BOOL close(DDK_DEVICE_PTR device) {
+DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device) {
if (nil == device) return NO;
ke_call_dispatch("dk_close_dev", 1, device, sizeof(DDK_DEVICE));
diff --git a/dev/libDDK/src/ddk_io.c b/dev/libDDK/src/ddk_io.c
index 825e82a7..ab0dd624 100644
--- a/dev/libDDK/src/ddk_io.c
+++ b/dev/libDDK/src/ddk_io.c
@@ -1,6 +1,6 @@
/* -------------------------------------------
- libDDK.
+ libDDK - Device Driver Kit
Copyright 2025 - Amlal El Mahrouss and NeKernel contributors.
File: ddk_io.c
@@ -24,7 +24,7 @@ DDK_EXTERN void kputc(const char ch) {
/// @param message UART to transmit.
DDK_EXTERN void kprint(const char* message) {
if (nil == message) return;
- if (*message == 0) return;
+ if (*message == '\0') return;
size_t index = 0;
size_t len = kstrlen(message);