summaryrefslogtreecommitdiffhomepage
path: root/dev/user
diff options
context:
space:
mode:
Diffstat (limited to 'dev/user')
-rw-r--r--dev/user/Opts.h12
-rw-r--r--dev/user/src/SystemCalls+IO.asm2
-rw-r--r--dev/user/src/SystemCalls.cc34
-rw-r--r--dev/user/user.json1
4 files changed, 42 insertions, 7 deletions
diff --git a/dev/user/Opts.h b/dev/user/Opts.h
new file mode 100644
index 00000000..09a77570
--- /dev/null
+++ b/dev/user/Opts.h
@@ -0,0 +1,12 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#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/user/src/SystemCalls+IO.asm b/dev/user/src/SystemCalls+IO.asm
index 58ea79e7..77e22b59 100644
--- a/dev/user/src/SystemCalls+IO.asm
+++ b/dev/user/src/SystemCalls+IO.asm
@@ -1,7 +1,7 @@
;; /*
;; * ========================================================
;; *
-;; * libsci
+;; * user/src/SystemCalls+IO.asm
;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
;; *
;; * ========================================================
diff --git a/dev/user/src/SystemCalls.cc b/dev/user/src/SystemCalls.cc
index 7ad0fe6f..20eaa0e0 100644
--- a/dev/user/src/SystemCalls.cc
+++ b/dev/user/src/SystemCalls.cc
@@ -5,14 +5,10 @@
------------------------------------------- */
#include <user/SystemCalls.h>
+#include <user/Opts.h>
/// @file SystemCalls.cc
-/// @brief Source file for the memory functions of the libsci.
-
-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);
+/// @brief Source file for the memory functions of the user.sys.
/// @brief Copy memory region.
IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len)
@@ -32,6 +28,7 @@ IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input Si
return dest;
}
+/// @brief Get string length.
IMPORT_C SInt64 MmStrLen(const Char* in)
{
if (!in)
@@ -89,3 +86,28 @@ IMPORT_C UInt64 IoTellFile(_Input Ref desc)
auto ret = (UInt64*)sci_syscall_arg_2(4, reinterpret_cast<VoidPtr>(desc));
return *ret;
}
+
+/// @brief Print to the file descriptor.
+/// @param desc the file descriptor.
+IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+
+ auto ret = (UInt64*)sci_syscall_arg_4(5, reinterpret_cast<VoidPtr>(desc),
+ reinterpret_cast<VoidPtr>(const_cast<Char*>(fmt)), args);
+
+ va_end(args);
+
+ return *ret;
+}
+
+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);
+ }
+} \ No newline at end of file
diff --git a/dev/user/user.json b/dev/user/user.json
index 9581d4d4..05b90abf 100644
--- a/dev/user/user.json
+++ b/dev/user/user.json
@@ -7,6 +7,7 @@
"compiler_flags": [
"-ffreestanding",
"-shared",
+ "-fPIC",
"-fno-rtti",
"-fno-exceptions",
"-Wl,--subsystem=17"