diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-20 16:47:35 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-20 16:47:35 +0200 |
| commit | bc97b2b790eb06d8f9adb8ef8fa41874d7d19770 (patch) | |
| tree | a6929db78467c2b07877abb9d9aad579d77139bb /dev/user | |
| parent | 699e395505a602f4a731c481646233d87f87a85c (diff) | |
kernel, dev: python script to make an ESP from files.
- Started implementing the wrt_* APIs (Wide string functions)
- Make user.sys link now, need to implement more syscalls.
- Tiny HEFS refactors too.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/user')
| -rw-r--r-- | dev/user/Opts.h | 12 | ||||
| -rw-r--r-- | dev/user/src/SystemCalls+IO.asm | 2 | ||||
| -rw-r--r-- | dev/user/src/SystemCalls.cc | 34 | ||||
| -rw-r--r-- | dev/user/user.json | 1 |
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" |
