diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-08 17:10:31 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-08 17:10:31 +0200 |
| commit | 5c079a35ae724d9c6be0b8adf0717728a1368c69 (patch) | |
| tree | 944050de13b26295424dd513d140f34d6ec8b029 | |
| parent | df8393cebbae61ed7686be17a28d80c657f49b7e (diff) | |
[FIXES] SEE BELOW.
+ Cleanup SCIBase.hxx, using functions instead of passing arguments to syscall.
+ Update Process scheduler, refactored the code and improved some chunk
of it.
+ Update the THREAD_INFORMATION_BLOCK structure.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
| -rw-r--r-- | Kernel/KernelKit/ProcessScheduler.hxx | 10 | ||||
| -rw-r--r-- | Kernel/KernelKit/ThreadLocalStorage.hxx | 10 | ||||
| -rw-r--r-- | Kernel/Sources/ProcessScheduler.cxx | 6 | ||||
| -rw-r--r-- | SCIKit/SCIBase.cxx (renamed from SCIKit/SCIBinaryInterface.cxx) | 0 | ||||
| -rw-r--r-- | SCIKit/SCIBase.hxx | 86 |
5 files changed, 39 insertions, 73 deletions
diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx index 4b149a52..cd0a7a93 100644 --- a/Kernel/KernelKit/ProcessScheduler.hxx +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -143,20 +143,22 @@ namespace Kernel const Int32& GetExitCode() noexcept; public: - Char Name[kProcessLen] = {"Unknown Process"}; + Char Name[kProcessLen] = {"PROCESS"}; ProcessSubsystem SubSystem{ProcessSubsystem::eProcessSubsystemInvalid}; ProcessLevelRing Selector{ProcessLevelRing::kRingStdUser}; HAL::StackFramePtr StackFrame{nullptr}; - AffinityKind Affinity; - ProcessStatus Status; + AffinityKind Affinity{AffinityKind::kStandard}; + ProcessStatus Status{ProcessStatus::kDead}; // Memory, images. HeapPtrKind HeapCursor{nullptr}; ImagePtr Image{nullptr}; HeapPtrKind HeapPtr{nullptr}; + typedef PEFSharedObjectInterface ProcessDLLInterface; + // shared library handle, reserved for kSharedLib only. - PEFSharedObjectInterface* SharedObjectPEF{nullptr}; + ProcessDLLInterface* DLLPtr{nullptr}; // Memory usage. SizeT UsedMemory{0}; diff --git a/Kernel/KernelKit/ThreadLocalStorage.hxx b/Kernel/KernelKit/ThreadLocalStorage.hxx index c6973fd4..a1bc7733 100644 --- a/Kernel/KernelKit/ThreadLocalStorage.hxx +++ b/Kernel/KernelKit/ThreadLocalStorage.hxx @@ -24,10 +24,12 @@ struct THREAD_INFORMATION_BLOCK; struct PACKED THREAD_INFORMATION_BLOCK final { Kernel::Char f_Cookie[kTLSCookieLen]; // Process cookie. - Kernel::UIntPtr f_Code; // Start Address - Kernel::UIntPtr f_Data; // Allocation Heap - Kernel::UIntPtr f_BSS; // Stack Pointer. - Kernel::Int32 f_ID; // Thread execution ID. + Kernel::UIntPtr f_Code; // Start address (Instruction Pointer) + Kernel::UIntPtr f_Data; // Allocated Heap for process. + Kernel::UIntPtr f_Stack; // Application Stack pointer. + Kernel::Int32 f_ID; // Thread execution ID. + Kernel::Int64 f_UsedHeapPercent; // used heap in percent. + Kernel::Int64 f_FreeHeapPercent; // heap free in percent. }; ///! @brief Cookie Sanity check. diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx index cacdd060..4d421ee4 100644 --- a/Kernel/Sources/ProcessScheduler.cxx +++ b/Kernel/Sources/ProcessScheduler.cxx @@ -197,11 +197,11 @@ namespace Kernel if (this->Kind == kSharedObjectKind) { bool success = false; - rtl_fini_shared_object(this, this->SharedObjectPEF, &success); + rtl_fini_shared_object(this, this->DLLPtr, &success); if (success) { - this->SharedObjectPEF = nullptr; + this->DLLPtr = nullptr; } } @@ -233,7 +233,7 @@ namespace Kernel } else if (process.Leak().Kind == PROCESS_HEADER_BLOCK::kSharedObjectKind) { - process.Leak().SharedObjectPEF = rtl_init_shared_object(&process.Leak()); + process.Leak().DLLPtr = rtl_init_shared_object(&process.Leak()); process.Leak().HeapPtr = sched_new_heap(kUserHeapUser | kUserHeapRw | kUserHeapShared); } else diff --git a/SCIKit/SCIBinaryInterface.cxx b/SCIKit/SCIBase.cxx index 02766870..02766870 100644 --- a/SCIKit/SCIBinaryInterface.cxx +++ b/SCIKit/SCIBase.cxx diff --git a/SCIKit/SCIBase.hxx b/SCIKit/SCIBase.hxx index e8208c49..07b50b0a 100644 --- a/SCIKit/SCIBase.hxx +++ b/SCIKit/SCIBase.hxx @@ -31,26 +31,6 @@ typedef void* VoidPtr; typedef __UINTPTR_TYPE__ UIntPtr;
typedef char Char;
-inline constexpr auto cSerialAlertSyscall = 0x10;
-inline constexpr auto cTlsSyscall = 0x11;
-inline constexpr auto cTlsInstallSyscall = 0x12;
-inline constexpr auto cNewSyscall = 0x13;
-inline constexpr auto cDeleteSyscall = 0x14;
-inline constexpr auto cExitSyscall = 0x15;
-inline constexpr auto cLastExitSyscall = 0x16;
-inline constexpr auto cCatalogOpenSyscall = 0x17;
-inline constexpr auto cForkReadSyscall = 0x18;
-inline constexpr auto cForkWriteSyscall = 0x19;
-inline constexpr auto cCatalogCloseSyscall = 0x20;
-inline constexpr auto cCatalogRemoveSyscall = 0x21;
-inline constexpr auto cCatalogCreateSyscall = 0x22;
-inline constexpr auto cRebootSyscallSyscall = 0x23;
-inline constexpr auto cShutdownSyscall = 0x24;
-inline constexpr auto cLPCSendMsgSyscall = 0x25;
-inline constexpr auto cLPCOpenMsgSyscall = 0x26;
-inline constexpr auto cLPCCloseMsgSyscall = 0x27;
-inline constexpr auto cLPCSanitizeMsgSyscall = 0x28;
-
#ifdef __NEWOS_SYMS__
#include <SCIKit/scm.internal.inl>
#else
@@ -90,48 +70,30 @@ public: #endif
-/* ================================================ */
-/* SCI structures */
-/* ================================================ */
-
-struct HEAP_ALLOC_INFO final
-{
- VoidPtr fThe;
- SizeT fTheSz;
-};
-
-struct THREAD_INFORMATION_BLOCK final
-{
- Char f_Cookie[3]; // Process cookie.
- UIntPtr f_Code; // Start Address
- UIntPtr f_Data; // Allocation Heap
- UIntPtr f_BSS; // Stack Pointer.
- SInt32 f_ID; // Thread execution ID.
-};
-
-struct PROCESS_BLOCK_INFO final
-{
- THREAD_INFORMATION_BLOCK* fTIB;
- THREAD_INFORMATION_BLOCK* fGIB;
-};
-
-struct PROCESS_EXIT_INFO final
-{
- static constexpr auto cReasonLen = 512;
-
- SInt64 fCode;
- Char fReason[cReasonLen];
-};
-
-/// @brief Raise system call.
-/// @param id the system call id could be 0x10 for example.
-/// @param data the data associated with it.
-/// @param data_sz the size of the data associated with it.
-/// @return status code.
-IMPORT_C SInt32 RtlRaiseSysCall(const SInt32 id, VoidPtr data, SizeT data_sz);
-
/// @note Part of NK loader API.
IMPORT_C VoidPtr RtlGetDLLProc(const char* symbol, VoidPtr dll_handle);
-IMPORT_C VoidPtr RtlOpenDLL(const char* path);
-IMPORT_C UInt0 RtlCloseDLL(VoidPtr dll_handle);
\ No newline at end of file +
+/// @brief Open DLL handle.
+/// @param path
+/// @param drv
+/// @return
+IMPORT_C VoidPtr RtlOpenDLL(const char* path, const char* drv);
+
+/// @brief Close DLL handle
+/// @param dll_handle
+/// @return
+IMPORT_C UInt0 RtlCloseDLL(VoidPtr dll_handle);
+
+/// @note Part of NK file API.
+
+/// @brief Opens a file from a drive.
+/// @param path the filesystem path.
+/// @param drv drive name, use NULL to use default one.
+/// @return the file descriptor of the file.
+IMPORT_C UInt64 RtlOpenFile(const char* path, const char* drv);
+
+/// @brief Closes a file and flushes its content.
+/// @param file_desc the file descriptor.
+/// @return
+IMPORT_C UInt0 RtlCloseFile(UInt64 file_desc);
|
