summaryrefslogtreecommitdiffhomepage
path: root/dev/libSystem
diff options
context:
space:
mode:
Diffstat (limited to 'dev/libSystem')
-rw-r--r--dev/libSystem/AsmProc.h15
-rw-r--r--dev/libSystem/Err.h (renamed from dev/libSystem/Codes.h)2
-rw-r--r--dev/libSystem/Jail.h (renamed from dev/libSystem/SecurityPolicy.h)7
-rw-r--r--dev/libSystem/Macros.h10
-rw-r--r--dev/libSystem/Syscall.h19
-rw-r--r--dev/libSystem/System.h14
-rw-r--r--dev/libSystem/src/Makefile (renamed from dev/libSystem/src/GNUmakefile)8
-rw-r--r--dev/libSystem/src/SystemAPI.cc (renamed from dev/libSystem/src/System.cc)25
-rw-r--r--dev/libSystem/src/SystemProc.asm (renamed from dev/libSystem/src/SystemCalls+IO.asm)16
9 files changed, 60 insertions, 56 deletions
diff --git a/dev/libSystem/AsmProc.h b/dev/libSystem/AsmProc.h
deleted file mode 100644
index b707d533..00000000
--- a/dev/libSystem/AsmProc.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
-
-------------------------------------------- */
-
-#pragma once
-
-#include <libSystem/System.h>
-#include <cstdarg>
-
-IMPORT_C VoidPtr sci_syscall_arg_1(SizeT id);
-IMPORT_C VoidPtr sci_syscall_arg_2(SizeT id, VoidPtr arg1);
-IMPORT_C VoidPtr sci_syscall_arg_3(SizeT id, VoidPtr arg1, VoidPtr arg3);
-IMPORT_C VoidPtr sci_syscall_arg_4(SizeT id, VoidPtr arg1, VoidPtr arg3, VoidPtr arg4);
diff --git a/dev/libSystem/Codes.h b/dev/libSystem/Err.h
index 0451df64..e9fe013b 100644
--- a/dev/libSystem/Codes.h
+++ b/dev/libSystem/Err.h
@@ -8,7 +8,7 @@
#include <libSystem/Macros.h>
-/// @file Codes.h
+/// @file Err.h
/// @brief Process Codes type and values.
/// @author Amlal El Mahrouss (amlal@nekernel.org)
diff --git a/dev/libSystem/SecurityPolicy.h b/dev/libSystem/Jail.h
index 812f52e2..6a9259fc 100644
--- a/dev/libSystem/SecurityPolicy.h
+++ b/dev/libSystem/Jail.h
@@ -8,5 +8,8 @@
#include <libSystem/System.h>
-/// @file SecurityPolicy.h
-/// @brief Hardened Security Policy, used to restrict access to certain system calls. \ No newline at end of file
+/// @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
index 52dc904c..5b3a5ce1 100644
--- a/dev/libSystem/Macros.h
+++ b/dev/libSystem/Macros.h
@@ -64,19 +64,19 @@ typedef char Char;
typedef decltype(nullptr) nullPtr;
typedef nullPtr NullPtr;
-#define SCI_COPY_DELETE(KLASS) \
+#define LIBSYS_COPY_DELETE(KLASS) \
KLASS& operator=(const KLASS&) = delete; \
KLASS(const KLASS&) = delete;
-#define SCI_COPY_DEFAULT(KLASS) \
+#define LIBSYS_COPY_DEFAULT(KLASS) \
KLASS& operator=(const KLASS&) = default; \
KLASS(const KLASS&) = default;
-#define SCI_MOVE_DELETE(KLASS) \
+#define LIBSYS_MOVE_DELETE(KLASS) \
KLASS& operator=(KLASS&&) = delete; \
KLASS(KLASS&&) = delete;
-#define SCI_MOVE_DEFAULT(KLASS) \
+#define LIBSYS_MOVE_DEFAULT(KLASS) \
KLASS& operator=(KLASS&&) = default; \
KLASS(KLASS&&) = default;
@@ -123,4 +123,4 @@ IMPORT_C void _rtl_assert(Bool expr, const Char* origin);
#define tib_cast(X) ((UInt64) gib_cast(X) * 1024)
#endif
-#define SCI_UNUSED(X) ((void) X)
+#define LIBSYS_UNUSED(X) ((void) X)
diff --git a/dev/libSystem/Syscall.h b/dev/libSystem/Syscall.h
new file mode 100644
index 00000000..21f8287c
--- /dev/null
+++ b/dev/libSystem/Syscall.h
@@ -0,0 +1,19 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <libSystem/System.h>
+#include <cstdarg>
+
+#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
index 920ea2b2..88e1f173 100644
--- a/dev/libSystem/System.h
+++ b/dev/libSystem/System.h
@@ -7,8 +7,8 @@ Purpose: System Call Interface.
------------------------------------------- */
-#ifndef SCI_SYSTEM_CALLS_H
-#define SCI_SYSTEM_CALLS_H
+#ifndef LIBSYS_SYSTEM_CALLS_H
+#define LIBSYS_SYSTEM_CALLS_H
#include <libSystem/Macros.h>
@@ -16,12 +16,12 @@ Purpose: System Call Interface.
/// @brief Types API.
// ------------------------------------------------------------------------------------------ //
-struct RefType {
- UInt32 __hash;
- VoidPtr __self;
+struct REF_TYPE {
+ UInt64 __hash; /// @brief Hash of the syscall
+ VoidPtr __self; /// @brief Syscall self value.
};
-typedef RefType* Ref;
+typedef REF_TYPE* Ref;
typedef Ref IORef;
typedef Ref FSRef;
@@ -382,4 +382,4 @@ IMPORT_C Char* StrFmt(const Char* fmt, ...);
IMPORT_C UInt64 StrMathToNumber(const Char* in, const Char** endp, const SInt16 base);
-#endif // ifndef SCI_SYSTEM_CALLS_H
+#endif // ifndef LIBSYS_SYSTEM_CALLS_H
diff --git a/dev/libSystem/src/GNUmakefile b/dev/libSystem/src/Makefile
index 9b901f9f..41c99c4d 100644
--- a/dev/libSystem/src/GNUmakefile
+++ b/dev/libSystem/src/Makefile
@@ -9,8 +9,8 @@ FLAGS=-f win64
.PHONY: error
error:
@echo "==> Invalid rule."
- @echo "==> Use sci_asm_io_<arch> instead."
+ @echo "==> Use libsys_asm_io_<arch> instead."
-.PHONY: sci_asm_io_x64
-sci_asm_io_x64:
- $(ASM) $(FLAGS) SystemCalls+IO.asm -o SystemCalls+IO.stub.obj
+.PHONY: libsys_asm_io_x64
+libsys_asm_io_x64:
+ $(ASM) $(FLAGS) SystemProc.asm -o SystemProc.asm.obj
diff --git a/dev/libSystem/src/System.cc b/dev/libSystem/src/SystemAPI.cc
index 1c28303d..37e835c1 100644
--- a/dev/libSystem/src/System.cc
+++ b/dev/libSystem/src/SystemAPI.cc
@@ -4,11 +4,11 @@
------------------------------------------- */
-#include <libSystem/AsmProc.h>
+#include <libSystem/Syscall.h>
#include <libSystem/System.h>
-/// @file SystemCalls.cc
-/// @brief Source file for the memory functions/syscalls for libSystem.sys
+/// @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) {
@@ -46,22 +46,17 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt
return dest;
}
-//-----------------------------------------------------------------------------------------------------------//
-/// @brief Systems Calls implementation.
-/// @internal
-//-----------------------------------------------------------------------------------------------------------//
-
IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
- return sci_syscall_arg_3(1, reinterpret_cast<VoidPtr>(const_cast<Char*>(path)),
+ return (Ref)libsys_syscall_arg_3(SYSCALL_HASH('IoOpenFile'), reinterpret_cast<VoidPtr>(const_cast<Char*>(path)),
reinterpret_cast<VoidPtr>(const_cast<Char*>(drv_letter)));
}
IMPORT_C Void IoCloseFile(_Input Ref desc) {
- sci_syscall_arg_2(2, desc);
+ libsys_syscall_arg_2(2, desc);
}
IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) {
- auto ret = (volatile UInt64*) sci_syscall_arg_3(3, reinterpret_cast<VoidPtr>(desc),
+ auto ret = (volatile UInt64*) libsys_syscall_arg_3(SYSCALL_HASH('IoSeekFile'), reinterpret_cast<VoidPtr>(desc),
reinterpret_cast<VoidPtr>(&off));
MUST_PASS((*ret) != ~0UL);
@@ -69,7 +64,7 @@ IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) {
}
IMPORT_C UInt64 IoTellFile(_Input Ref desc) {
- auto ret = (volatile UInt64*) sci_syscall_arg_2(4, reinterpret_cast<VoidPtr>(desc));
+ auto ret = (volatile UInt64*) libsys_syscall_arg_2(SYSCALL_HASH('IoTellFile'), reinterpret_cast<VoidPtr>(desc));
return *ret;
}
@@ -78,8 +73,8 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) {
va_start(args, fmt);
- auto ret = (volatile UInt64*) sci_syscall_arg_4(
- 5, reinterpret_cast<VoidPtr>(desc), reinterpret_cast<VoidPtr>(const_cast<Char*>(fmt)), args);
+ auto ret = (volatile UInt64*) libsys_syscall_arg_4(
+ SYSCALL_HASH('PrintOut'), reinterpret_cast<VoidPtr>(desc), reinterpret_cast<VoidPtr>(const_cast<Char*>(fmt)), args);
va_end(args);
@@ -90,5 +85,7 @@ 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/SystemCalls+IO.asm b/dev/libSystem/src/SystemProc.asm
index 097046af..bc41059a 100644
--- a/dev/libSystem/src/SystemCalls+IO.asm
+++ b/dev/libSystem/src/SystemProc.asm
@@ -11,12 +11,12 @@
section .text
-global sci_syscall_arg_1
-global sci_syscall_arg_2
-global sci_syscall_arg_3
-global sci_syscall_arg_4
+global libsys_syscall_arg_1
+global libsys_syscall_arg_2
+global libsys_syscall_arg_3
+global libsys_syscall_arg_4
-sci_syscall_arg_1:
+libsys_syscall_arg_1:
push rbp
mov rbp, rsp
@@ -27,7 +27,7 @@ sci_syscall_arg_1:
ret
-sci_syscall_arg_2:
+libsys_syscall_arg_2:
push rbp
mov rbp, rsp
@@ -38,7 +38,7 @@ sci_syscall_arg_2:
ret
-sci_syscall_arg_3:
+libsys_syscall_arg_3:
push rbp
mov rbp, rsp
@@ -51,7 +51,7 @@ sci_syscall_arg_3:
ret
-sci_syscall_arg_4:
+libsys_syscall_arg_4:
push rbp
mov rbp, rsp