summaryrefslogtreecommitdiffhomepage
path: root/dev/libSystem
diff options
context:
space:
mode:
Diffstat (limited to 'dev/libSystem')
-rw-r--r--dev/libSystem/SystemKit/System.h4
-rw-r--r--dev/libSystem/SystemKit/Verify.h6
-rw-r--r--dev/libSystem/src/JailCalls.cc17
-rw-r--r--dev/libSystem/src/Makefile6
-rw-r--r--dev/libSystem/src/SystemCalls.cc (renamed from dev/libSystem/src/System.cc)11
-rw-r--r--dev/libSystem/src/SystemCallsABI+AMD64.asm (renamed from dev/libSystem/src/SystemProc.asm)2
-rw-r--r--dev/libSystem/src/VerifyCalls.cc18
7 files changed, 46 insertions, 18 deletions
diff --git a/dev/libSystem/SystemKit/System.h b/dev/libSystem/SystemKit/System.h
index f46fe523..88472513 100644
--- a/dev/libSystem/SystemKit/System.h
+++ b/dev/libSystem/SystemKit/System.h
@@ -79,7 +79,7 @@ IMPORT_C Void IoCloseFile(_Input Ref file_desc);
/// @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.
+/// @note This function is used to control the file descriptor, introduced for OpenHeFS.
IMPORT_C SInt32 IoCtrlFile(_Input Ref file_desc, _Input UInt32 ioctl_code, _Input VoidPtr in_data,
_Output VoidPtr out_data);
@@ -89,7 +89,7 @@ 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.
+/// @note only works in OpenHeFS, 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
diff --git a/dev/libSystem/SystemKit/Verify.h b/dev/libSystem/SystemKit/Verify.h
index cbf85830..bc0c8be3 100644
--- a/dev/libSystem/SystemKit/Verify.h
+++ b/dev/libSystem/SystemKit/Verify.h
@@ -11,7 +11,7 @@
#include <libSystem/SystemKit/System.h>
-namespace LibSystem::Detail {
+namespace LibSystem::Verify {
/// @author 0xf00sec, and Amlal El Mahrouss
/// @brief safe cast operator.
template <typename T, typename R = VoidPtr>
@@ -34,7 +34,7 @@ struct must_cast_traits<T, T> {
/// @brief Safe constexpr cast.
template <typename T, typename R>
inline constexpr R* sys_constexpr_cast(T* ptr) {
- static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are a mismatch!");
+ static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are mismatching!");
return static_cast<R*>(ptr);
}
-} // namespace LibSystem::Detail
+} // namespace LibSystem::Verify
diff --git a/dev/libSystem/src/JailCalls.cc b/dev/libSystem/src/JailCalls.cc
new file mode 100644
index 00000000..5cb47bb5
--- /dev/null
+++ b/dev/libSystem/src/JailCalls.cc
@@ -0,0 +1,17 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <libSystem/SystemKit/Err.h>
+#include <libSystem/SystemKit/Jail.h>
+#include <libSystem/SystemKit/Syscall.h>
+#include <libSystem/SystemKit/System.h>
+#include <libSystem/SystemKit/Verify.h>
+
+using namespace LibSystem;
+
+IMPORT_C struct JAIL* JailGetCurrent(Void) {
+ return (struct JAIL*) libsys_syscall_arg_1(SYSCALL_HASH("JailGetCurrent"));
+} \ No newline at end of file
diff --git a/dev/libSystem/src/Makefile b/dev/libSystem/src/Makefile
index 64ef02cc..ea8e9905 100644
--- a/dev/libSystem/src/Makefile
+++ b/dev/libSystem/src/Makefile
@@ -1,5 +1,5 @@
##################################################
-# (c) Amlal El Mahrouss, all rights reserved.
+# (c) Amlal El Mahrouss and NeKernel contributors, all rights reserved.
# This file is for libSystem.dll's syscall stubs.
##################################################
@@ -8,9 +8,9 @@ FLAGS=-f win64
.PHONY: error
error:
- @echo "==> Invalid rule."
+ @echo "==> Invalid recipe."
@echo "==> Use libsys_asm_io_<arch> instead."
.PHONY: libsys_asm_io_x64
libsys_asm_io_x64:
- $(ASM) $(FLAGS) SystemProc.asm -o SystemProc.stub.obj
+ $(ASM) $(FLAGS) SystemCallsABI+AMD64.asm -o SystemCallsABI+AMD64.stub.obj
diff --git a/dev/libSystem/src/System.cc b/dev/libSystem/src/SystemCalls.cc
index da9931fe..3db9368d 100644
--- a/dev/libSystem/src/System.cc
+++ b/dev/libSystem/src/SystemCalls.cc
@@ -11,13 +11,6 @@
using namespace LibSystem;
-IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) {
- if (!expr) {
- PrintOut(nullptr, "Assertion failed: %s\r", origin);
- libsys_syscall_arg_1(SYSCALL_HASH("_rtl_debug_break"));
- }
-}
-
/// @note this uses the FNV 64-bit variant.
IMPORT_C UInt64 libsys_hash_64(const Char* path) {
if (!path || *path == 0) return 0;
@@ -147,7 +140,7 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt
IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
return static_cast<Ref>(libsys_syscall_arg_3(
- SYSCALL_HASH("IoOpenFile"), Detail::sys_safe_cast(path), Detail::sys_safe_cast(drv_letter)));
+ SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast(path), Verify::sys_safe_cast(drv_letter)));
}
IMPORT_C Void IoCloseFile(_Input Ref desc) {
@@ -183,7 +176,7 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const Char* fmt, ...) {
// if truncated, `needed` >= kBufferSz; we still send truncated buffer
auto ret_ptr = libsys_syscall_arg_3(SYSCALL_HASH("PrintOut"), static_cast<VoidPtr>(desc),
- Detail::sys_safe_cast(buf));
+ Verify::sys_safe_cast(buf));
if (!ret_ptr) return -kErrorInvalidData;
diff --git a/dev/libSystem/src/SystemProc.asm b/dev/libSystem/src/SystemCallsABI+AMD64.asm
index 991a371f..da19f41f 100644
--- a/dev/libSystem/src/SystemProc.asm
+++ b/dev/libSystem/src/SystemCallsABI+AMD64.asm
@@ -1,7 +1,7 @@
;; /*
;; * ========================================================
;; *
-;; * libSystem/src/SystemProc.asm
+;; * libSystem/src/SystemCallsABI+AMD64.asm
;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
;; *
;; * ========================================================
diff --git a/dev/libSystem/src/VerifyCalls.cc b/dev/libSystem/src/VerifyCalls.cc
new file mode 100644
index 00000000..078f921b
--- /dev/null
+++ b/dev/libSystem/src/VerifyCalls.cc
@@ -0,0 +1,18 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#include <libSystem/SystemKit/Err.h>
+#include <libSystem/SystemKit/Syscall.h>
+#include <libSystem/SystemKit/Verify.h>
+
+using namespace LibSystem;
+
+IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) {
+ if (!expr) {
+ PrintOut(nullptr, "Assertion failed: %s\r", origin);
+ libsys_syscall_arg_1(SYSCALL_HASH("_rtl_debug_break"));
+ }
+} \ No newline at end of file