From 56a97ff6398c03de22dabd7b93f54b1292f66b97 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 15 Apr 2025 16:54:06 +0200 Subject: dev, user: user.sys refactors. Signed-off-by: Amlal El Mahrouss --- dev/user/SystemCalls.h | 17 ++++++++------ dev/user/src/GNUmakefile | 4 ++-- dev/user/src/SystemCall+IO.asm | 50 --------------------------------------- dev/user/src/SystemCalls+IO.asm | 52 +++++++++++++++++++++++++++++++++++++++++ dev/user/src/SystemCalls.cc | 2 +- 5 files changed, 65 insertions(+), 60 deletions(-) delete mode 100644 dev/user/src/SystemCall+IO.asm create mode 100644 dev/user/src/SystemCalls+IO.asm (limited to 'dev') diff --git a/dev/user/SystemCalls.h b/dev/user/SystemCalls.h index 97a49469..df91bc1e 100644 --- a/dev/user/SystemCalls.h +++ b/dev/user/SystemCalls.h @@ -322,14 +322,17 @@ IMPORT_C SInt32 SchedBreakPoint(Void); // @brief Filesystem API. // ------------------------------------------------------------------------------------------ // -IMPORT_C BOOL FsCopy(const char* path, const char* dst); -IMPORT_C BOOL FsMove(const char* path, const char* dst); +IMPORT_C BOOL FsCopy(const Char* path, const Char* dst); -IMPORT_C BOOL FsExists(const char* path); +IMPORT_C BOOL FsMove(const Char* path, const Char* dst); -IMPORT_C BOOL FsCreateDir(const char* path); -IMPORT_C BOOL FsCreateFile(const char* path); -IMPORT_C BOOL FsCreateAlias(const char* path, const char* from); +IMPORT_C BOOL FsExists(const Char* path); + +IMPORT_C BOOL FsCreateDir(const Char* path); + +IMPORT_C BOOL FsCreateFile(const Char* path); + +IMPORT_C BOOL FsCreateAlias(const Char* path, const Char* from); // ------------------------------------------------------------------------------------------ // // @brief Format API. @@ -337,6 +340,6 @@ IMPORT_C BOOL FsCreateAlias(const char* path, const char* from); IMPORT_C Char* StrFmt(const Char* fmt, ...); -IMPORT_C UInt64 MathToNumber(const Char* in, const Char** endp, const SInt16 base); +IMPORT_C UInt64 StrMathToNumber(const Char* in, const Char** endp, const SInt16 base); #endif // ifndef SCI_SCI_H diff --git a/dev/user/src/GNUmakefile b/dev/user/src/GNUmakefile index c0ddd5b4..09993d16 100644 --- a/dev/user/src/GNUmakefile +++ b/dev/user/src/GNUmakefile @@ -1,6 +1,6 @@ ################################################## # (c) Amlal El Mahrouss, all rights reserved. -# This is the bootloader makefile. +# This file is for user.sys's syscall stubs. ################################################## ASM=nasm @@ -13,4 +13,4 @@ error: .PHONY: sci_asm_io_x64 sci_asm_io_x64: - $(ASM) $(FLAGS) SystemCall+IO.asm -o SystemCall+IO.o + $(ASM) $(FLAGS) SystemCalls+IO.asm -o SystemCalls+IO.asm.o diff --git a/dev/user/src/SystemCall+IO.asm b/dev/user/src/SystemCall+IO.asm deleted file mode 100644 index 8f123ec8..00000000 --- a/dev/user/src/SystemCall+IO.asm +++ /dev/null @@ -1,50 +0,0 @@ -;; /* -;; * ======================================================== -;; * -;; * libsci -;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. -;; * -;; * ======================================================== -;; */ - -[bits 64] - -section .text - -global sci_syscall_arg_1 -global sci_syscall_arg_2 -global sci_syscall_arg_3 -global sci_syscall_arg_4 - -sci_syscall_arg_1: - mov r8, rcx - syscall - ret - -sci_syscall_arg_2: - mov r8, rcx - mov r9, rdx - syscall - ret - -sci_syscall_arg_3: - mov rbx, r8 - - mov r8, rcx - mov r9, rdx - mov r10, rbx - - syscall - ret - -sci_syscall_arg_4: - mov rbx, r8 - mov rax, r9 - - mov r8, rcx - mov r9, rdx - mov r10, rbx - mov r11, rax - - syscall - ret diff --git a/dev/user/src/SystemCalls+IO.asm b/dev/user/src/SystemCalls+IO.asm new file mode 100644 index 00000000..58ea79e7 --- /dev/null +++ b/dev/user/src/SystemCalls+IO.asm @@ -0,0 +1,52 @@ +;; /* +;; * ======================================================== +;; * +;; * libsci +;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +;; * +;; * ======================================================== +;; */ + +[bits 64] + +;; @brief Syscall dispatch, also taking note the Microsoft's calling convention to translate it to NeKernel's ABI. + +section .text + +global sci_syscall_arg_1 +global sci_syscall_arg_2 +global sci_syscall_arg_3 +global sci_syscall_arg_4 + +sci_syscall_arg_1: + mov r8, rcx + syscall + ret + +sci_syscall_arg_2: + mov r8, rcx + mov r9, rdx + syscall + ret + +sci_syscall_arg_3: + mov rbx, r8 + + mov r8, rcx + mov r9, rdx + mov r10, rbx + + syscall + ret + +sci_syscall_arg_4: + mov rbx, r8 + mov rax, r9 + + mov r8, rcx + mov r9, rdx + mov r10, rbx + mov r11, rax + + syscall + ret diff --git a/dev/user/src/SystemCalls.cc b/dev/user/src/SystemCalls.cc index 19f1fe42..2dd27dc0 100644 --- a/dev/user/src/SystemCalls.cc +++ b/dev/user/src/SystemCalls.cc @@ -27,7 +27,7 @@ IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input Si return dest; } -/// @brief Fill memory region with **value**. +/// @brief Fill memory region **dest** with **value**. IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) { if (!len || -- cgit v1.2.3