summaryrefslogtreecommitdiffhomepage
path: root/dev/user/src
diff options
context:
space:
mode:
Diffstat (limited to 'dev/user/src')
-rw-r--r--dev/user/src/GNUmakefile4
-rw-r--r--dev/user/src/SystemCalls+IO.asm (renamed from dev/user/src/SystemCall+IO.asm)2
-rw-r--r--dev/user/src/SystemCalls.cc50
3 files changed, 52 insertions, 4 deletions
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/SystemCalls+IO.asm
index 8f123ec8..58ea79e7 100644
--- a/dev/user/src/SystemCall+IO.asm
+++ b/dev/user/src/SystemCalls+IO.asm
@@ -9,6 +9,8 @@
[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
diff --git a/dev/user/src/SystemCalls.cc b/dev/user/src/SystemCalls.cc
index 19f1fe42..7ad0fe6f 100644
--- a/dev/user/src/SystemCalls.cc
+++ b/dev/user/src/SystemCalls.cc
@@ -6,9 +6,14 @@
#include <user/SystemCalls.h>
-/// @file libsci.cc
+/// @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 Copy memory region.
IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len)
{
@@ -27,7 +32,22 @@ IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input Si
return dest;
}
-/// @brief Fill memory region with **value**.
+IMPORT_C SInt64 MmStrLen(const Char* in)
+{
+ if (!in)
+ return 0;
+
+ SizeT len{0};
+
+ do
+ {
+ ++len;
+ } while (in[len] != '\0');
+
+ return len;
+}
+
+/// @brief Fill memory region **dest** with **value**.
IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value)
{
if (!len ||
@@ -43,3 +63,29 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt
return dest;
}
+
+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)),
+ reinterpret_cast<VoidPtr>(const_cast<Char*>(drv_letter)));
+}
+
+IMPORT_C Void IoCloseFile(_Input Ref desc)
+{
+ sci_syscall_arg_2(2, desc);
+}
+
+IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off)
+{
+ auto ret = (UInt64*)sci_syscall_arg_3(3, reinterpret_cast<VoidPtr>(desc),
+ reinterpret_cast<VoidPtr>(&off));
+
+ MUST_PASS((*ret) != ~0UL);
+ return *ret;
+}
+
+IMPORT_C UInt64 IoTellFile(_Input Ref desc)
+{
+ auto ret = (UInt64*)sci_syscall_arg_2(4, reinterpret_cast<VoidPtr>(desc));
+ return *ret;
+}