From 50c7c5676d110681528cc933c4b99844b11f1dd1 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 1 Dec 2024 19:47:27 +0100 Subject: ADD: Add GPU API regarding Mesa3D support for OpenGL ES. IMP: Refactor SCI Kit to have a better filesystem structure. --- dev/Modules/FB/FB.h | 2 +- dev/SCIKit/CompilerHint.h | 2 + dev/SCIKit/Foundation.h | 230 ----------------------- dev/SCIKit/GPU.h | 50 +++++ dev/SCIKit/LPC.h | 6 +- dev/SCIKit/SCI.h | 251 ++++++++++++++++++++++++++ dev/SCIKit/sci.json | 2 +- dev/SCIKit/src/DispatchSysCalls.asm | 50 ----- dev/SCIKit/src/GPU.cc | 10 + dev/SCIKit/src/LPC.cc | 10 + dev/SCIKit/src/Makefile | 2 +- dev/SCIKit/src/MemoryMgr.cc | 45 ----- dev/SCIKit/src/SCI.cc | 45 +++++ dev/SCIKit/src/SysCallDispatcher.asm | 50 +++++ dev/ZKAKit/FSKit/NeFS.h | 14 +- dev/ZKAKit/FirmwareKit/EFI/EFI.h | 18 +- dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc | 2 +- dev/ZKAKit/KernelKit/DriveMgr.h | 4 +- dev/ZKAKit/KernelKit/LPC.h | 6 +- dev/ZKAKit/KernelKit/LoaderInterface.h | 6 +- dev/ZKAKit/KernelKit/UserProcessScheduler.inl | 2 +- dev/ZKAKit/src/FS/NeFS.cc | 38 ++-- dev/ZKAKit/src/Network/IPC.cc | 2 +- 23 files changed, 470 insertions(+), 377 deletions(-) delete mode 100644 dev/SCIKit/Foundation.h create mode 100644 dev/SCIKit/GPU.h create mode 100644 dev/SCIKit/SCI.h delete mode 100644 dev/SCIKit/src/DispatchSysCalls.asm create mode 100644 dev/SCIKit/src/GPU.cc create mode 100644 dev/SCIKit/src/LPC.cc delete mode 100644 dev/SCIKit/src/MemoryMgr.cc create mode 100644 dev/SCIKit/src/SCI.cc create mode 100644 dev/SCIKit/src/SysCallDispatcher.asm (limited to 'dev') diff --git a/dev/Modules/FB/FB.h b/dev/Modules/FB/FB.h index ffd6edf9..f309c41c 100644 --- a/dev/Modules/FB/FB.h +++ b/dev/Modules/FB/FB.h @@ -76,7 +76,7 @@ *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ i + \ - 4 * u))) = cg_get_clear_clr(); \ + 4 * u))) = cg_get_clear_clr(); \ } \ } diff --git a/dev/SCIKit/CompilerHint.h b/dev/SCIKit/CompilerHint.h index 60838479..e38d5c7e 100644 --- a/dev/SCIKit/CompilerHint.h +++ b/dev/SCIKit/CompilerHint.h @@ -7,7 +7,9 @@ #ifndef __SCI_HINT_H__ #define __SCI_HINT_H__ +#ifdef __TK__ #pragma compiler(hint_manifest) +#endif #define _Input #define _Output diff --git a/dev/SCIKit/Foundation.h b/dev/SCIKit/Foundation.h deleted file mode 100644 index 039fe6ce..00000000 --- a/dev/SCIKit/Foundation.h +++ /dev/null @@ -1,230 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2024, ELMH Group, all rights reserved. - -File: Foundation.h -Purpose: SCIKit Foundation header. - -------------------------------------------- */ - -#ifndef SCIKIT_FOUNDATION_H -#define SCIKIT_FOUNDATION_H - -#include - -// ------------------------------------------------------------------------------------------ // -/// @brief Dynamic Loader API. -// ------------------------------------------------------------------------------------------ // - -/// @brief Get function which is part of the DLL. -/// @param symbol the symbol to look for -/// @param dll_handle the DLL handle. -/// @return the proc pointer. -IMPORT_C SCIObject LdrGetDLLSymbolFromHandle(_Input const Char* symbol, _Input SCIObject dll_handle); - -/// @brief Open DLL handle. -/// @param path -/// @param drv -/// @return -IMPORT_C SCIObject LdrOpenDLLHandle(_Input const Char* path, _Input const Char* drive_letter); - -/// @brief Close DLL handle -/// @param dll_handle -/// @return -IMPORT_C Void LdrCloseDLLHandle(_Input SCIObject* dll_handle); - -// ------------------------------------------------------------------------------------------ // -// File API. -// ------------------------------------------------------------------------------------------ // - -/// @brief Opens a file from a drive. -/// @param fs_path the filesystem path. -/// @param drive_letter drive name, use NULL to use default drive location. -/// @return the file descriptor of the file. -IMPORT_C SCIObject IoOpenFile(const Char* fs_path, const Char* drive_letter); - -/// @brief Closes a file and flushes its content. -/// @param file_desc the file descriptor. -/// @return Function doesn't return a type. -IMPORT_C Void IoCloseFile(_Input SCIObject file_desc); - -/// @brief Write data to a file. -/// @param file_desc the file descriptor. -/// @param out_data the data to write. -/// @param sz_data the size of the data to write. -/// @return the number of bytes written. -IMPORT_C UInt32 IoWriteFile(_Input SCIObject file_desc, _Output VoidPtr out_data, SizeT sz_data); - -/// @brief Read data from a file. -/// @param file_desc the file descriptor. -/// @param out_data the data to read. -/// @param sz_data the size of the data to read. -IMPORT_C UInt32 IoReadFile(_Input SCIObject file_desc, _Output VoidPtr* out_data, SizeT sz_data); - -/// @brief Rewind the file pointer to the beginning of the file. -/// @param file_desc the file descriptor. -/// @return the number of bytes read. -IMPORT_C UInt64 IoRewindFile(_Input SCIObject file_desc); - -/// @brief Tell the current position of the file pointer. -/// @param file_desc the file descriptor. -/// @return the current position of the file pointer. -IMPORT_C UInt64 IoTellFile(_Input SCIObject file_desc); - -/// @brief Seek file offset from file descriptor. -IMPORT_C UInt64 IoSeekFile(_Input SCIObject file_desc, UInt64 file_offset); - -// ------------------------------------------------------------------------ -// TLS API. -// ------------------------------------------------------------------------ - -/// @brief Installs the Thread Information Block and Global Information Block inside the current process. -/// @param void. -/// @return > 0 error ocurred or already present, = 0 success. -IMPORT_C UInt32 RtlTlsInstall(Void); - -// ------------------------------------------------------------------------ -// Memory Management API. -// ------------------------------------------------------------------------ - -/// @brief Creates a new heap from the process's address space. -/// @param len the length of it. -/// @param flags the flags of it. -/// @return heap pointer. -IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags); - -/// @brief Destroys the pointer -/// @param heap the heap itself. -/// @return void. -IMPORT_C Void MmDestroyHeap(_Input VoidPtr heap); - -/// @brief Change protection flags of a memory region. -IMPORT_C Void MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags); - -/// @brief Change protection flags of a memory region. -IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap); - -/// @brief Fill memory region with CRC32. -IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap); - -/// @brief Copy memory region. -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); - -/// @brief Fill memory region. -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value); - -// ------------------------------------------------------------------------ -// Error handling API. -// ------------------------------------------------------------------------ - -IMPORT_C SInt32 ErrGetLastError(Void); - -// ------------------------------------------------------------------------ -// Threading API. -// ------------------------------------------------------------------------ - -/// @brief Exit the current thread. -/// @param exit_code the exit code. -IMPORT_C Void ThrExitCurrentThread(_Input SInt32 exit_code); - -/// @brief Exit the main thread. -/// @param exit_code the exit code. -IMPORT_C Void ThrExitMainThread(_Input SInt32 exit_code); - -/// @brief Exit a thread. -/// @param thread the thread to exit. -/// @param exit_code the exit code. -IMPORT_C Void ThrExitThread(_Input ThreadObject thread, _Input SInt32 exit_code); - -/// @brief Thread procedure function type. -typedef Void (*ThreadProc)(Void); - -/// @brief Creates a thread. -/// @param procedure the thread procedure. -/// @param argument_count number of arguments inside that thread. -/// @param flags Thread flags. -/// @return the thread object. -IMPORT_C ThreadObject ThrCreateThread(ThreadProc procedure, SInt32 argument_count, SInt32 flags); - -/// @brief Yields the current thread. -/// @param thread the thread to yield. -IMPORT_C Void ThrYieldThread(Void); - -/// @brief Joins a thread. -/// @param thread the thread to join. -IMPORT_C Void ThrJoinThread(Void); - -/// @brief Detach sa thread. -/// @param thread the thread to detach. -IMPORT_C Void ThrDetachThread(Void); - -// ------------------------------------------------------------------------ -// Drive Management API. -// ------------------------------------------------------------------------ - -/// @brief Get the default drive letter. -/// @param void. -/// @return the drive letter. -IMPORT_C Char* DrvGetDefaultDriveLetter(Void); - -/// @brief Get the drive letter from a path. -/// @param path the path. -/// @return the drive letter. -IMPORT_C Char* DrvGetDriveLetterFromPath(_Input const Char* path); - -/// @brief Get a mounted drive from a letter. -/// @param letter the letter (A..Z). -/// @return the drive object. -IMPORT_C SCIObject DrvGetMountedDrive(_Input const Char letter); - -/// @brief Mount a drive. -/// @param path the path to mount. -/// @param letter the letter to mount. -IMPORT_C Void DrvMountDrive(_Input const Char* path, _Input const Char* letter); - -/// @brief Unmount a drive. -/// @param letter the letter to unmount. -IMPORT_C Void DrvUnmountDrive(_Input const Char letter); - -// ------------------------------------------------------------------------ -// Event handling API, use to listen to OS specific events. -// ------------------------------------------------------------------------ - -/// @brief Add an event listener. -/// @param event_name the event name. -/// @param listener the listener to add. -/// @return the event listener. -IMPORT_C Void EvtAddListener(_Input const Char* event_name, _Input SCIObject listener); - -/// @brief Remove an event listener. -/// @param event_name the event name. -/// @param listener the listener to remove. -/// @return the event listener. -IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input SCIObject listener); - -/// @brief Dispatch an event. -/// @param event_name the event name. -/// @param event_data the event data. -/// @return the event data. -IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); - -// ------------------------------------------------------------------------------------------ // -// Power API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C Void PwrShutdownMachine(const Char* _Input msg, _Input SInt32 code); -IMPORT_C Void PwrRebootMachine(const Char* _Input msg, _Input SInt32 code); -IMPORT_C Void PwrSleepMachine(const Char* _Input msg, _Input SInt32 code); - -IMPORT_C SInt32 PwrGetCode(_Output SInt32& code); - -// ------------------------------------------------------------------------------------------ // -// CD-ROM API. -// ------------------------------------------------------------------------------------------ // - -IMPORT_C SInt32 CdEjectDrive(_Input const Char drv_letter); - -IMPORT_C SInt32 CdOpenTray(Void); -IMPORT_C SInt32 CdCloseTray(Void); - -#endif // ifndef SCIKIT_FOUNDATION_H diff --git a/dev/SCIKit/GPU.h b/dev/SCIKit/GPU.h new file mode 100644 index 00000000..0c69a73d --- /dev/null +++ b/dev/SCIKit/GPU.h @@ -0,0 +1,50 @@ +/* ------------------------------------------- + +Copyright (C) 2024, ELMH Group, all rights reserved. + +File: GPU.h +Purpose: GFX System Calls. + +------------------------------------------- */ + +#ifndef SCIKIT_GPU_H +#define SCIKIT_GPU_H + +#include + +// ------------------------------------------------------------------------------------------ // +// GPU API. +// ------------------------------------------------------------------------------------------ // + +// ------------------------------------------------------------------------------------------ // +// @brief Command buffer structure type. +// ------------------------------------------------------------------------------------------ // +struct GPU_CMD_BUFFER final +{ + SizeT X, Y, Z; + VoidPtr FrameData; + SizeT FrameDataSz; + SizeT BackBufferLayer; + Bool IsGPGPUData; + Bool BackBufferFirst; + + Bool isGPGPUData() + { + return !this->BackBufferFirst && this->IsGPGPUData; + } + + Bool isValid() + { + return this->FrameData && this->FrameDataSz > 0; + } +}; + +typedef VoidPtr GPUObject; + +IMPORT_C GPUObject GPUNewFromDeviceName(_Input const Char* device_name); + +IMPORT_C SInt32 GPUDisposeDevice(GPUObject gpu_handle, Bool cancel_all, Bool flush_all); + +IMPORT_C SInt32 GPUSendCmdBufferListWithCnt(GPU_CMD_BUFFER** cmd_list, SizeT cmd_list_cnt); + +#endif // ifndef SCIKIT_GPU_H \ No newline at end of file diff --git a/dev/SCIKit/LPC.h b/dev/SCIKit/LPC.h index 4f2a4e86..60de8cb7 100644 --- a/dev/SCIKit/LPC.h +++ b/dev/SCIKit/LPC.h @@ -11,9 +11,9 @@ /// @file LPC.h /// @brief Local Process Code type and values. -#define ErrLocalIsOk() (kLastError == kErrorSuccess) -#define ErrLocalFailed() (kLastError != kErrorSuccess) -#define ErrLocal() (kLastError) +#define err_local_ok() (kLastError == kErrorSuccess) +#define err_local_fail() (kLastError != kErrorSuccess) +#define err_local_get() (kLastError) typedef SInt32 ErrObject; diff --git a/dev/SCIKit/SCI.h b/dev/SCIKit/SCI.h new file mode 100644 index 00000000..a4b0dd96 --- /dev/null +++ b/dev/SCIKit/SCI.h @@ -0,0 +1,251 @@ +/* ------------------------------------------- + +Copyright (C) 2024, ELMH Group, all rights reserved. + +File: SCI.h +Purpose: System Calls. + +------------------------------------------- */ + +#ifndef SCIKIT_FOUNDATION_H +#define SCIKIT_FOUNDATION_H + +#include + +// ------------------------------------------------------------------------------------------ // +/// @brief Dynamic Loader API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Get function which is part of the DLL. +/// @param symbol the symbol to look for +/// @param dll_handle the DLL handle. +/// @return the proc pointer. +IMPORT_C SCIObject LdrGetDLLSymbolFromHandle(_Input const Char* symbol, _Input SCIObject dll_handle); + +/// @brief Open DLL handle. +/// @param path +/// @param drv +/// @return +IMPORT_C SCIObject LdrOpenDLLHandle(_Input const Char* path, _Input const Char* drive_letter); + +/// @brief Close DLL handle +/// @param dll_handle +/// @return +IMPORT_C Void LdrCloseDLLHandle(_Input SCIObject* dll_handle); + +// ------------------------------------------------------------------------------------------ // +// File API. +// ------------------------------------------------------------------------------------------ // + +/// @brief Opens a file from a drive. +/// @param fs_path the filesystem path. +/// @param drive_letter drive name, use NULL to use default drive location. +/// @return the file descriptor of the file. +IMPORT_C SCIObject IoOpenFile(const Char* fs_path, const Char* drive_letter); + +/// @brief Closes a file and flushes its content. +/// @param file_desc the file descriptor. +/// @return Function doesn't return a type. +IMPORT_C Void IoCloseFile(_Input SCIObject file_desc); + +/// @brief Write data to a file. +/// @param file_desc the file descriptor. +/// @param out_data the data to write. +/// @param sz_data the size of the data to write. +/// @return the number of bytes written. +IMPORT_C UInt32 IoWriteFile(_Input SCIObject file_desc, _Output VoidPtr out_data, SizeT sz_data); + +/// @brief Read data from a file. +/// @param file_desc the file descriptor. +/// @param out_data the data to read. +/// @param sz_data the size of the data to read. +IMPORT_C UInt32 IoReadFile(_Input SCIObject file_desc, _Output VoidPtr* out_data, SizeT sz_data); + +/// @brief Rewind the file pointer to the beginning of the file. +/// @param file_desc the file descriptor. +/// @return the number of bytes read. +IMPORT_C UInt64 IoRewindFile(_Input SCIObject file_desc); + +/// @brief Tell the current position of the file pointer. +/// @param file_desc the file descriptor. +/// @return the current position of the file pointer. +IMPORT_C UInt64 IoTellFile(_Input SCIObject file_desc); + +/// @brief Seek file offset from file descriptor. +IMPORT_C UInt64 IoSeekFile(_Input SCIObject file_desc, UInt64 file_offset); + +// ------------------------------------------------------------------------ +// TLS API. +// ------------------------------------------------------------------------ + +/// @brief Installs the Thread Information Block and Global Information Block inside the current process. +/// @param void. +/// @return > 0 error ocurred or already present, = 0 success. +IMPORT_C UInt32 RtlTlsInstall(Void); + +// ------------------------------------------------------------------------ +// Memory Management API. +// ------------------------------------------------------------------------ + +/// @brief Creates a new heap from the process's address space. +/// @param len the length of it. +/// @param flags the flags of it. +/// @return heap pointer. +IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags); + +/// @brief Destroys the pointer +/// @param heap the heap itself. +/// @return void. +IMPORT_C Void MmDestroyHeap(_Input VoidPtr heap); + +/// @brief Change protection flags of a memory region. +IMPORT_C Void MmSetHeapFlags(_Input VoidPtr heap, _Input UInt32 flags); + +/// @brief Change protection flags of a memory region. +IMPORT_C UInt32 MmGetHeapFlags(_Input VoidPtr heap); + +/// @brief Fill memory region with CRC32. +IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap); + +/// @brief Copy memory region. +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len); + +/// @brief Fill memory region. +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value); + +// ------------------------------------------------------------------------ +// Error handling API. +// ------------------------------------------------------------------------ + +IMPORT_C SInt32 ErrGetLastError(Void); + +// ------------------------------------------------------------------------ +// Threading API. +// ------------------------------------------------------------------------ + +/// @brief Exit the current thread. +/// @param exit_code the exit code. +IMPORT_C Void ThrExitCurrentThread(_Input SInt32 exit_code); + +/// @brief Exit the main thread. +/// @param exit_code the exit code. +IMPORT_C Void ThrExitMainThread(_Input SInt32 exit_code); + +/// @brief Exit a thread. +/// @param thread the thread to exit. +/// @param exit_code the exit code. +IMPORT_C Void ThrExitThread(_Input ThreadObject thread, _Input SInt32 exit_code); + +/// @brief Thread procedure function type. +typedef Void (*thread_proc_kind)(Void); + +/// @brief Creates a thread. +/// @param procedure the thread procedure. +/// @param argument_count number of arguments inside that thread. +/// @param flags Thread flags. +/// @return the thread object. +IMPORT_C ThreadObject ThrCreateThread(thread_proc_kind procedure, SInt32 argument_count, SInt32 flags); + +/// @brief Yields the current thread. +/// @param thread the thread to yield. +IMPORT_C Void ThrYieldThread(ThreadObject thrd); + +/// @brief Joins a thread. +/// @param thread the thread to join. +IMPORT_C Void ThrJoinThread(ThreadObject thrd); + +/// @brief Detach a thread. +/// @param thread the thread to detach. +IMPORT_C Void ThrDetachThread(ThreadObject thrd); + +// ------------------------------------------------------------------------ +// Drive Management API. +// ------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------ // +/// @brief Get the default drive letter. +/// @param void. +/// @return the drive letter. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Char* DrvGetDefaultDriveLetter(Void); + +// ------------------------------------------------------------------------------------------ // +/// @brief Get the drive letter from a path. +/// @param path the path. +/// @return the drive letter. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Char* DrvGetDriveLetterFromPath(_Input const Char* path); + +// ------------------------------------------------------------------------------------------ // +/// @brief Get a mounted drive from a letter. +/// @param letter the letter (A..Z). +/// @return the drive object. +// ------------------------------------------------------------------------------------------ // +IMPORT_C SCIObject DrvGetMountedDrive(_Input const Char letter); + +// ------------------------------------------------------------------------------------------ // +/// @brief Mount a drive. +/// @param path the path to mount. +/// @param letter the letter to mount. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Void DrvMountDrive(_Input const Char* path, _Input const Char* letter); + +// ------------------------------------------------------------------------------------------ // +/// @brief Unmount a drive. +/// @param letter the letter to unmount. +// ------------------------------------------------------------------------------------------ // +IMPORT_C Void DrvUnmountDrive(_Input const Char letter); + +// ------------------------------------------------------------------------ +// Event handling API, use to listen to OS specific events. +// ------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------ // +/// @brief Add an event listener. +/// @param event_name the event name. +/// @param listener the listener to add. +/// @return the event listener. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Void EvtAddListener(_Input const Char* event_name, _Input SCIObject listener); + +// ------------------------------------------------------------------------------------------ // +/// @brief Remove an event listener. +/// @param event_name the event name. +/// @param listener the listener to remove. +/// @return the event listener. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Void EvtRemoveListener(_Input const Char* event_name, _Input SCIObject listener); + +// ------------------------------------------------------------------------------------------ // +/// @brief Dispatch an event. +/// @param event_name the event name. +/// @param event_data the event data. +/// @return the event data. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C VoidPtr EvtDispatchEvent(_Input const Char* event_name, _Input VoidPtr event_data); + +// ------------------------------------------------------------------------------------------ // +// Power API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C Void PwrShutdownMachine(const Char* _Input msg, _Input SInt32 code); + +IMPORT_C Void PwrRebootMachine(const Char* _Input msg, _Input SInt32 code); + +IMPORT_C Void PwrSleepMachine(const Char* _Input msg, _Input SInt32 code); + +IMPORT_C SInt32 PwrGetCode(_Output SInt32& code); + +// ------------------------------------------------------------------------------------------ // +// CD-ROM API. +// ------------------------------------------------------------------------------------------ // + +IMPORT_C SInt32 CdEjectDrive(_Input const Char drv_letter); + +IMPORT_C SInt32 CdOpenTray(Void); +IMPORT_C SInt32 CdCloseTray(Void); + +#endif // ifndef SCIKIT_FOUNDATION_H diff --git a/dev/SCIKit/sci.json b/dev/SCIKit/sci.json index eb8bece9..b0e267d2 100644 --- a/dev/SCIKit/sci.json +++ b/dev/SCIKit/sci.json @@ -2,7 +2,7 @@ "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["../"], - "sources_path": ["src/*.cc", "src/*.obj"], + "sources_path": ["src/*.cc", "src/*.o"], "output_name": "SCIKit.dylib", "compiler_flags": [ "-fPIC", diff --git a/dev/SCIKit/src/DispatchSysCalls.asm b/dev/SCIKit/src/DispatchSysCalls.asm deleted file mode 100644 index 368e8a92..00000000 --- a/dev/SCIKit/src/DispatchSysCalls.asm +++ /dev/null @@ -1,50 +0,0 @@ -;; /* -;; * ======================================================== -;; * -;; * SCI -;; * Copyright (C) 2024, ELMH Group, all rights reserved., 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/SCIKit/src/GPU.cc b/dev/SCIKit/src/GPU.cc new file mode 100644 index 00000000..f2947ec9 --- /dev/null +++ b/dev/SCIKit/src/GPU.cc @@ -0,0 +1,10 @@ +/* ------------------------------------------- + +Copyright (C) 2024, ELMH Group, all rights reserved. + +File: GPU.cc +Purpose: GPU Interface. + +------------------------------------------- */ + +#include \ No newline at end of file diff --git a/dev/SCIKit/src/LPC.cc b/dev/SCIKit/src/LPC.cc new file mode 100644 index 00000000..b33c15f6 --- /dev/null +++ b/dev/SCIKit/src/LPC.cc @@ -0,0 +1,10 @@ +/* ------------------------------------------- + +Copyright (C) 2024, ELMH Group, all rights reserved. + +File: LPC.cc +Purpose: Local Procedure Codes. + +------------------------------------------- */ + +#include \ No newline at end of file diff --git a/dev/SCIKit/src/Makefile b/dev/SCIKit/src/Makefile index 588f233a..ba4b6008 100644 --- a/dev/SCIKit/src/Makefile +++ b/dev/SCIKit/src/Makefile @@ -8,4 +8,4 @@ FLAGS=-f win64 .PHONY: syscall_unit syscall_unit: - $(ASM) $(FLAGS) DispatchSysCalls.asm -o DispatchSysCalls.obj + $(ASM) $(FLAGS) SysCallDispatcher.asm -o SysCallDispatcher.o diff --git a/dev/SCIKit/src/MemoryMgr.cc b/dev/SCIKit/src/MemoryMgr.cc deleted file mode 100644 index ea9e6ad3..00000000 --- a/dev/SCIKit/src/MemoryMgr.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024, ELMH Group, all rights reserved. - -------------------------------------------- */ - -#include - -/// @file MemoryMgr.cc -/// @brief Source file for the memory functions. - -/// @brief Copy memory region. -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) -{ - if (!len || - !dest || - !src) - { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) - { - ((Char*)dest)[i] = ((Char*)src)[i]; - } - - return dest; -} - -/// @brief Fill memory region with **value**. -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) -{ - if (!len || - !dest) - { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) - { - ((Char*)dest)[i] = value; - } - - return dest; -} diff --git a/dev/SCIKit/src/SCI.cc b/dev/SCIKit/src/SCI.cc new file mode 100644 index 00000000..4263b8f0 --- /dev/null +++ b/dev/SCIKit/src/SCI.cc @@ -0,0 +1,45 @@ +/* ------------------------------------------- + + Copyright (C) 2024, ELMH Group, all rights reserved. + +------------------------------------------- */ + +#include + +/// @file SCI.cc +/// @brief Source file for the memory functions of the SCI. + +/// @brief Copy memory region. +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) +{ + if (!len || + !dest || + !src) + { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) + { + ((Char*)dest)[i] = ((Char*)src)[i]; + } + + return dest; +} + +/// @brief Fill memory region with **value**. +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) +{ + if (!len || + !dest) + { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) + { + ((Char*)dest)[i] = value; + } + + return dest; +} diff --git a/dev/SCIKit/src/SysCallDispatcher.asm b/dev/SCIKit/src/SysCallDispatcher.asm new file mode 100644 index 00000000..368e8a92 --- /dev/null +++ b/dev/SCIKit/src/SysCallDispatcher.asm @@ -0,0 +1,50 @@ +;; /* +;; * ======================================================== +;; * +;; * SCI +;; * Copyright (C) 2024, ELMH Group, all rights reserved., 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/ZKAKit/FSKit/NeFS.h b/dev/ZKAKit/FSKit/NeFS.h index efd42107..e6f984e7 100644 --- a/dev/ZKAKit/FSKit/NeFS.h +++ b/dev/ZKAKit/FSKit/NeFS.h @@ -239,15 +239,15 @@ namespace Kernel /// @param theFork the fork itself. /// @return the fork _Output NFS_FORK_STRUCT* CreateFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input NFS_FORK_STRUCT& theFork); + _Input NFS_FORK_STRUCT& theFork); /// @brief Find fork inside New filesystem. /// @param catalog the catalog. /// @param name the fork name. /// @return the fork. _Output NFS_FORK_STRUCT* FindFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - Boolean dataOrRsrc); + _Input const Char* name, + Boolean dataOrRsrc); _Output Void RemoveFork(_Input NFS_FORK_STRUCT* fork); @@ -257,7 +257,7 @@ namespace Kernel _Output NFS_CATALOG_STRUCT* GetCatalog(_Input const Char* name); - _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name, + _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind); @@ -267,12 +267,12 @@ namespace Kernel _Input Bool isRsrcFork, _Input VoidPtr data, _Input SizeT sizeOfData, - _Input const Char* forkName); + _Input const Char* forkName); VoidPtr ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, _Input Bool isRsrcFork, _Input SizeT dataSz, - _Input const Char* forkName); + _Input const Char* forkName); bool Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off); @@ -284,7 +284,7 @@ namespace Kernel /// @brief Make a EPM+NeFS drive out of the disk. /// @param drive The drive to write on. - /// @return If it was sucessful, see ErrLocal(). + /// @return If it was sucessful, see err_local_get(). bool Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name); public: diff --git a/dev/ZKAKit/FirmwareKit/EFI/EFI.h b/dev/ZKAKit/FirmwareKit/EFI/EFI.h index 523e2156..2905678a 100644 --- a/dev/ZKAKit/FirmwareKit/EFI/EFI.h +++ b/dev/ZKAKit/FirmwareKit/EFI/EFI.h @@ -823,11 +823,11 @@ typedef struct _EfiProcessorInformation typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)( IN struct _EfiMpServicesProtocol* Self, - OUT UInt32* NumberOfProcessors, - OUT UInt32* NumberOfEnabledProcessors); + OUT UInt32* NumberOfProcessors, + OUT UInt32* NumberOfEnabledProcessors); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_PROCESSOR_INFO)( - IN struct _EfiMpServicesProtocol* Self, + IN struct _EfiMpServicesProtocol* Self, IN UInt32* ProcessorNumber, OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors); @@ -842,8 +842,8 @@ typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_ALL_APS)( IN Boolean SingleThread, IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here. IN UInt32 TimeoutInMicroSeconds, - IN Void* ProcedureArgument OPTIONAL, - OUT UInt32** FailedCpuList OPTIONAL); + IN Void* ProcedureArgument OPTIONAL, + OUT UInt32** FailedCpuList OPTIONAL); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_SWITCH_BSP)( IN struct _EfiMpServicesProtocol* This, @@ -856,18 +856,18 @@ typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_THIS_AP)( IN UInt32 ProcessorNumber, IN VoidPtr WaitEvent OPTIONAL, IN UInt32 TimeoutInMicroseconds, - IN Void* ProcedureArgument OPTIONAL, - OUT Boolean* Finished OPTIONAL); + IN Void* ProcedureArgument OPTIONAL, + OUT Boolean* Finished OPTIONAL); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_ENABLEDISABLEAP)( IN struct _EfiMpServicesProtocol* This, IN UInt32 ProcessorNumber, IN Boolean EnableAP, - IN UInt32* HealthFlag OPTIONAL); + IN UInt32* HealthFlag OPTIONAL); typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_WHOAMI)( IN struct _EfiMpServicesProtocol* This, - OUT UInt32* ProcessorNumber); + OUT UInt32* ProcessorNumber); typedef struct _EfiMpServicesProtocol { diff --git a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc index 179bc593..80abfdc1 100644 --- a/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc +++ b/dev/ZKAKit/HALKit/AMD64/Storage/AHCI-DMA.cc @@ -49,7 +49,7 @@ enum }; STATIC Kernel::PCI::Device kAhciDevice; -STATIC HbaPort* kAhciPort = nullptr; +STATIC HbaPort* kAhciPort = nullptr; STATIC Kernel::Lba kCurrentDiskSectorCount = 0UL; Kernel::Void drv_calculate_disk_geometry() diff --git a/dev/ZKAKit/KernelKit/DriveMgr.h b/dev/ZKAKit/KernelKit/DriveMgr.h index a8a410ba..e4d5dd68 100644 --- a/dev/ZKAKit/KernelKit/DriveMgr.h +++ b/dev/ZKAKit/KernelKit/DriveMgr.h @@ -120,7 +120,7 @@ namespace Kernel DriveTraitPtr GetAddressOf(const Int32& index) { - ErrLocal() = kErrorSuccess; + err_local_get() = kErrorSuccess; switch (index) { @@ -133,7 +133,7 @@ namespace Kernel case kDriveIndexD: return &mD; default: { - ErrLocal() = kErrorNoSuchDisk; + err_local_get() = kErrorNoSuchDisk; kcout << "No such disk index.\n"; break; diff --git a/dev/ZKAKit/KernelKit/LPC.h b/dev/ZKAKit/KernelKit/LPC.h index 68bc9196..0c4b0a56 100644 --- a/dev/ZKAKit/KernelKit/LPC.h +++ b/dev/ZKAKit/KernelKit/LPC.h @@ -11,9 +11,9 @@ /// @file LPC.h /// @brief Local Process Codes. -#define ErrLocalIsOk() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode() == Kernel::kErrorSuccess) -#define ErrLocalFailed() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode() != Kernel::kErrorSuccess) -#define ErrLocal() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode()) +#define err_local_ok() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode() == Kernel::kErrorSuccess) +#define err_local_fail() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode() != Kernel::kErrorSuccess) +#define err_local_get() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode()) #define ErrGlobalIsOk() (Kernel::kErrorLocalNumber == Kernel::kErrorSuccess) #define ErrGlobalFailed() (Kernel::kErrorLocalNumber != Kernel::kErrorSuccess) diff --git a/dev/ZKAKit/KernelKit/LoaderInterface.h b/dev/ZKAKit/KernelKit/LoaderInterface.h index dc9bc477..a95aae4e 100644 --- a/dev/ZKAKit/KernelKit/LoaderInterface.h +++ b/dev/ZKAKit/KernelKit/LoaderInterface.h @@ -25,9 +25,9 @@ namespace Kernel public: virtual _Output ErrorOr GetBlob() = 0; - virtual _Output const Char* AsString() = 0; - virtual _Output const Char* MIME() = 0; - virtual _Output const Char* Path() = 0; + virtual _Output const Char* AsString() = 0; + virtual _Output const Char* MIME() = 0; + virtual _Output const Char* Path() = 0; virtual _Output ErrorOr FindStart() = 0; virtual _Output VoidPtr FindSymbol(_Input const Char* name, _Input Int32 kind) = 0; }; diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.inl b/dev/ZKAKit/KernelKit/UserProcessScheduler.inl index b99fafbf..8da934ed 100644 --- a/dev/ZKAKit/KernelKit/UserProcessScheduler.inl +++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.inl @@ -4,7 +4,7 @@ namespace Kernel /** @brief Free pointer from usage. */ /***********************************************************************************/ - template + template Boolean UserProcess::Delete(ErrorOr ptr, const SizeT& sz) { if (!ptr || diff --git a/dev/ZKAKit/src/FS/NeFS.cc b/dev/ZKAKit/src/FS/NeFS.cc index e1a844c6..a5671763 100644 --- a/dev/ZKAKit/src/FS/NeFS.cc +++ b/dev/ZKAKit/src/FS/NeFS.cc @@ -61,7 +61,7 @@ STATIC MountpointInterface kDiskMountpoint; /// @return the fork /***********************************************************************************/ _Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input NFS_FORK_STRUCT& the_fork) + _Input NFS_FORK_STRUCT& the_fork) { if (catalog && the_fork.ForkName[0] != 0 && the_fork.DataSize <= kNeFSForkDataSz) @@ -170,8 +170,8 @@ _Output NFS_FORK_STRUCT* NeFSParser::CreateFork(_Input NFS_CATALOG_STRUCT* catal /// @return the fork. /***********************************************************************************/ _Output NFS_FORK_STRUCT* NeFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - Boolean isDataFork) + _Input const Char* name, + Boolean isDataFork) { auto drv = kDiskMountpoint.A(); NFS_FORK_STRUCT* the_fork = nullptr; @@ -193,12 +193,12 @@ _Output NFS_FORK_STRUCT* NeFSParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog switch (res) { case 1: - ErrLocal() = kErrorDiskReadOnly; + err_local_get() = kErrorDiskReadOnly; break; case 2: - ErrLocal() = kErrorDiskIsFull; + err_local_get() = kErrorDiskIsFull; break; - ErrLocal() = kErrorNoSuchDisk; + err_local_get() = kErrorNoSuchDisk; break; default: @@ -236,7 +236,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name) /// @param kind the catalog kind. /// @return catalog pointer. /***********************************************************************************/ -_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, +_Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind) { @@ -261,7 +261,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, if (catalog_copy) { kcout << "Catalog already exists: " << name << ".\r"; - ErrLocal() = kErrorFileExists; + err_local_get() = kErrorFileExists; return catalog_copy; } @@ -276,7 +276,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, if (*parentName == 0) { kcout << "Parent name is NUL.\r"; - ErrLocal() = kErrorFileNotFound; + err_local_get() = kErrorFileNotFound; return nullptr; } @@ -464,7 +464,7 @@ _Output NFS_CATALOG_STRUCT* NeFSParser::CreateCatalog(_Input const Char* name, /// @brief Make a EPM+NeFS drive out of the disk. /// @param drive The drive to write on. -/// @return If it was sucessful, see ErrLocal(). +/// @return If it was sucessful, see err_local_get(). bool NeFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name) { if (*part_name == 0 || @@ -480,7 +480,7 @@ bool NeFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endLb // if disk isn't good, then error out. if (false == drive->fPacket.fPacketGood) { - ErrLocal() = kErrorDiskIsCorrupted; + err_local_get() = kErrorDiskIsCorrupted; return false; } @@ -665,7 +665,7 @@ bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool i // check the fork, if it's position is valid. if (fork_data_input->DataOffset <= kNeFSCatalogStartAddress) { - ErrLocal() = kErrorDiskIsCorrupted; + err_local_get() = kErrorDiskIsCorrupted; kcout << "Invalid fork offset.\r"; @@ -875,7 +875,7 @@ Boolean NeFSParser::RemoveCatalog(_Input const Char* catalogName) if (!catalogName || StringBuilder::Equals(catalogName, NeFileSystemHelper::Root())) { - ErrLocal() = kErrorInternal; + err_local_get() = kErrorInternal; return false; } @@ -936,11 +936,11 @@ Boolean NeFSParser::RemoveCatalog(_Input const Char* catalogName) VoidPtr NeFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, _Input Bool is_rsrc_fork, _Input SizeT dataSz, - _Input const Char* forkName) + _Input const Char* forkName) { if (!catalog) { - ErrLocal() = kErrorFileNotFound; + err_local_get() = kErrorFileNotFound; return nullptr; } @@ -1000,11 +1000,11 @@ bool NeFSParser::Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off) { if (!catalog) { - ErrLocal() = kErrorFileNotFound; + err_local_get() = kErrorFileNotFound; return false; } - ErrLocal() = kErrorUnimplemented; + err_local_get() = kErrorUnimplemented; return false; } @@ -1018,11 +1018,11 @@ SizeT NeFSParser::Tell(_Input _Output NFS_CATALOG_STRUCT* catalog) { if (!catalog) { - ErrLocal() = kErrorFileNotFound; + err_local_get() = kErrorFileNotFound; return 0; } - ErrLocal() = kErrorUnimplemented; + err_local_get() = kErrorUnimplemented; return 0; } diff --git a/dev/ZKAKit/src/Network/IPC.cc b/dev/ZKAKit/src/Network/IPC.cc index 4f979dda..e1f969fd 100644 --- a/dev/ZKAKit/src/Network/IPC.cc +++ b/dev/ZKAKit/src/Network/IPC.cc @@ -49,7 +49,7 @@ Bool ipc_int_sanitize_packet(IPCMessage* pckt) return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == kIPCHeaderMagic; ipc_check_failed: - ErrLocal() = kErrorIPC; + err_local_get() = kErrorIPC; return false; } -- cgit v1.2.3