diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-06-03 09:31:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-03 09:31:01 +0200 |
| commit | 6511afbf405c31513bc88ab06bca58218610a994 (patch) | |
| tree | e2509b7f9b59643b2a97773604aa383a2fd2e2f3 /dev/libSystem/src | |
| parent | 5c0bb7ee7b1b0fee02cc179fb21f4c57a61d6c2d (diff) | |
| parent | bebcbe04c2b47b3b4fcdc093b1736cc0295109fe (diff) | |
Merge pull request #36 from nekernel-org/dev
0.0.3 — NeKernel
Diffstat (limited to 'dev/libSystem/src')
| -rw-r--r-- | dev/libSystem/src/Makefile (renamed from dev/libSystem/src/GNUmakefile) | 8 | ||||
| -rw-r--r-- | dev/libSystem/src/SystemImpl.cc (renamed from dev/libSystem/src/System.cc) | 34 | ||||
| -rw-r--r-- | dev/libSystem/src/SystemProc.asm (renamed from dev/libSystem/src/SystemCalls+IO.asm) | 29 |
3 files changed, 38 insertions, 33 deletions
diff --git a/dev/libSystem/src/GNUmakefile b/dev/libSystem/src/Makefile index 9b901f9f..39af446b 100644 --- a/dev/libSystem/src/GNUmakefile +++ b/dev/libSystem/src/Makefile @@ -9,8 +9,8 @@ FLAGS=-f win64 .PHONY: error error: @echo "==> Invalid rule." - @echo "==> Use sci_asm_io_<arch> instead." + @echo "==> Use libsys_asm_io_<arch> instead." -.PHONY: sci_asm_io_x64 -sci_asm_io_x64: - $(ASM) $(FLAGS) SystemCalls+IO.asm -o SystemCalls+IO.stub.obj +.PHONY: libsys_asm_io_x64 +libsys_asm_io_x64: + $(ASM) $(FLAGS) SystemProc.asm -o SystemProc.stub.obj diff --git a/dev/libSystem/src/System.cc b/dev/libSystem/src/SystemImpl.cc index 1c28303d..d0682830 100644 --- a/dev/libSystem/src/System.cc +++ b/dev/libSystem/src/SystemImpl.cc @@ -4,11 +4,11 @@ ------------------------------------------- */
-#include <libSystem/AsmProc.h>
-#include <libSystem/System.h>
+#include <libSystem/SystemKit/Syscall.h>
+#include <libSystem/SystemKit/System.h>
-/// @file SystemCalls.cc
-/// @brief Source file for the memory functions/syscalls for libSystem.sys
+/// @file SystemAPI.cc
+/// @brief System wide API for NeKernel.
IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) {
if (!len || !dest || !src) {
@@ -46,30 +46,27 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt return dest;
}
-//-----------------------------------------------------------------------------------------------------------//
-/// @brief Systems Calls implementation.
-/// @internal
-//-----------------------------------------------------------------------------------------------------------//
-
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)));
+ return (Ref) libsys_syscall_arg_3(SYSCALL_HASH('IoOpenFile'),
+ 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);
+ libsys_syscall_arg_2(2, desc);
}
IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) {
- auto ret = (volatile UInt64*) sci_syscall_arg_3(3, reinterpret_cast<VoidPtr>(desc),
- reinterpret_cast<VoidPtr>(&off));
+ auto ret = (volatile UInt64*) libsys_syscall_arg_3(
+ SYSCALL_HASH('IoSeekFile'), reinterpret_cast<VoidPtr>(desc), reinterpret_cast<VoidPtr>(&off));
MUST_PASS((*ret) != ~0UL);
return *ret;
}
IMPORT_C UInt64 IoTellFile(_Input Ref desc) {
- auto ret = (volatile UInt64*) sci_syscall_arg_2(4, reinterpret_cast<VoidPtr>(desc));
+ auto ret = (volatile UInt64*) libsys_syscall_arg_2(SYSCALL_HASH('IoTellFile'),
+ reinterpret_cast<VoidPtr>(desc));
return *ret;
}
@@ -78,8 +75,9 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) { va_start(args, fmt);
- auto ret = (volatile UInt64*) sci_syscall_arg_4(
- 5, reinterpret_cast<VoidPtr>(desc), reinterpret_cast<VoidPtr>(const_cast<Char*>(fmt)), args);
+ auto ret = (volatile UInt64*) libsys_syscall_arg_4(
+ SYSCALL_HASH('PrintOut'), reinterpret_cast<VoidPtr>(desc),
+ reinterpret_cast<VoidPtr>(const_cast<Char*>(fmt)), args);
va_end(args);
@@ -90,5 +88,7 @@ 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);
+
+ libsys_syscall_arg_1(SYSCALL_HASH('_rtl_debug_break'));
}
}
diff --git a/dev/libSystem/src/SystemCalls+IO.asm b/dev/libSystem/src/SystemProc.asm index 097046af..299b59f9 100644 --- a/dev/libSystem/src/SystemCalls+IO.asm +++ b/dev/libSystem/src/SystemProc.asm @@ -11,34 +11,37 @@ section .text -global sci_syscall_arg_1 -global sci_syscall_arg_2 -global sci_syscall_arg_3 -global sci_syscall_arg_4 +global libsys_syscall_arg_1 +global libsys_syscall_arg_2 +global libsys_syscall_arg_3 +global libsys_syscall_arg_4 -sci_syscall_arg_1: +libsys_syscall_arg_1: push rbp mov rbp, rsp mov r8, rcx - syscall + + int 50 pop rbp ret -sci_syscall_arg_2: +libsys_syscall_arg_2: push rbp mov rbp, rsp mov r8, rcx mov r9, rdx - syscall + + int 50 + pop rbp ret -sci_syscall_arg_3: +libsys_syscall_arg_3: push rbp mov rbp, rsp @@ -46,12 +49,13 @@ sci_syscall_arg_3: mov r9, rdx mov r10, rbx - syscall + int 50 + pop rbp ret -sci_syscall_arg_4: +libsys_syscall_arg_4: push rbp mov rbp, rsp @@ -60,7 +64,8 @@ sci_syscall_arg_4: mov r10, rbx mov r11, rax - syscall + int 50 + pop rbp ret |
