From bc97b2b790eb06d8f9adb8ef8fa41874d7d19770 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 20 Apr 2025 16:47:35 +0200 Subject: 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 --- dev/user/src/SystemCalls+IO.asm | 2 +- dev/user/src/SystemCalls.cc | 34 ++++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'dev/user/src') 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 +#include /// @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(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(desc), + reinterpret_cast(const_cast(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 -- cgit v1.2.3