diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-06 12:52:02 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-06 12:52:02 +0200 |
| commit | 39d95f7fb429c5c6b71cd7c1e985cadaf4ab7b83 (patch) | |
| tree | 33e5832930b82adadfec61ad2e509e79995b7cf1 /dev/ZKA | |
| parent | 1404bdfdbf767a7c8e445766af4c27fe17f7c205 (diff) | |
[ IMP ] Fixed Scheduler and Team object, also fixed other things.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ZKA')
| -rw-r--r-- | dev/ZKA/Docs/TODO-LIST.md | 2 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx | 21 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm | 5 | ||||
| -rw-r--r-- | dev/ZKA/NewKit/Array.hxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/CodeMgr.cxx | 4 | ||||
| -rw-r--r-- | dev/ZKA/Sources/FS/NeFS.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/PEFCodeMgr.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/UserProcessScheduler.cxx | 22 |
8 files changed, 36 insertions, 24 deletions
diff --git a/dev/ZKA/Docs/TODO-LIST.md b/dev/ZKA/Docs/TODO-LIST.md index ec50c89d..2b4ea96c 100644 --- a/dev/ZKA/Docs/TODO-LIST.md +++ b/dev/ZKA/Docs/TODO-LIST.md @@ -18,7 +18,7 @@ Status: -newosldr: Need to boot from EPM partition. [ X ] +NEWOSLDR: Need to boot from EPM partition. [ X ] <br> newoskrnl: New Filesystem is done. [ X ] diff --git a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx index 800d8b3d..7a6e726a 100644 --- a/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx +++ b/dev/ZKA/HALKit/AMD64/HalBMPMgr.cxx @@ -46,15 +46,12 @@ namespace Kernel kcout << "BMPMgr: Allocated pointer!\r"; kcout << "Magic Number: " << hex_number(ptr_bit_set[0]) << endl; - kcout << "Size of pointer: " << hex_number(ptr_bit_set[1]) << endl; + kcout << "Size of pointer (KIB): " << number(KIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (MIB): " << number(MIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (GIB): " << number(GIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (TIB): " << number(TIB(ptr_bit_set[1])) << endl; kcout << "Address Of Header: " << hex_number((UIntPtr)ptr_bit_set) << endl; - if (rw) - mm_update_pte(base_ptr, eFlagsRw); - - if (user) - mm_update_pte(base_ptr, eFlagsUser); - return (VoidPtr)ptr_bit_set; } } @@ -68,7 +65,10 @@ namespace Kernel kcout << "BMPMgr: Allocated pointer!\r"; kcout << "Magic Number: " << hex_number(ptr_bit_set[0]) << endl; - kcout << "Size of pointer: " << hex_number(ptr_bit_set[1]) << endl; + kcout << "Size of pointer (KIB): " << number(KIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (MIB): " << number(MIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (GIB): " << number(GIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (TIB): " << number(TIB(ptr_bit_set[1])) << endl; kcout << "Address Of Header: " << hex_number((UIntPtr)ptr_bit_set) << endl; if (rw) @@ -123,7 +123,10 @@ namespace Kernel kcout << "BMPMgr: Freed pointer!\r"; kcout << "Magic Number: " << hex_number(ptr_bit_set[0]) << endl; - kcout << "Size of pointer: " << hex_number(ptr_bit_set[1]) << endl; + kcout << "Size of pointer (KIB): " << number(KIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (MIB): " << number(MIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (GIB): " << number(GIB(ptr_bit_set[1])) << endl; + kcout << "Size of pointer (TIB): " << number(TIB(ptr_bit_set[1])) << endl; kcout << "Address Of Header: " << hex_number((UIntPtr)ptr_bit_set) << endl; ptr_bit_set[0] = cBitMpMagic; diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm index c26a346f..6b00715d 100644 --- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm +++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm @@ -34,12 +34,13 @@ mp_do_context_switch: mov r11, gs mov r12, fs - mov r11, 0x202 - mov fs, [r8 + (8 * 4)] mov gs, [r8 + (8 * 9)] mov r8, [r8] + mov r11, 0x202 + mov rsp, rdx + o64 sysret ;; @brief Gets the current stack frame. diff --git a/dev/ZKA/NewKit/Array.hxx b/dev/ZKA/NewKit/Array.hxx index 9fa545ef..9d1dc74a 100644 --- a/dev/ZKA/NewKit/Array.hxx +++ b/dev/ZKA/NewKit/Array.hxx @@ -23,7 +23,7 @@ namespace Kernel T& operator[](const SizeT& At) { - return (fArray[At]); + return fArray[At]; } Boolean Empty() const diff --git a/dev/ZKA/Sources/CodeMgr.cxx b/dev/ZKA/Sources/CodeMgr.cxx index 49968e73..ae4cb00b 100644 --- a/dev/ZKA/Sources/CodeMgr.cxx +++ b/dev/ZKA/Sources/CodeMgr.cxx @@ -14,7 +14,7 @@ namespace Kernel /// @note This sets up a new stack, anything on the main function that calls the Kernel will not be accessible. /// @param main the start of the process. /// @return if the process was started or not. - bool sched_execute_thread(MainKind main, const Char* process_name) noexcept + Bool sched_execute_thread(MainKind main, const Char* process_name) noexcept { if (!main) return No; @@ -27,6 +27,6 @@ namespace Kernel rt_copy_memory((VoidPtr)process_name, proc.Name, rt_string_len(process_name)); - return UserProcessScheduler::The().Add(proc) != 0; + return UserProcessScheduler::The().Add(proc) > 0; } } // namespace Kernel diff --git a/dev/ZKA/Sources/FS/NeFS.cxx b/dev/ZKA/Sources/FS/NeFS.cxx index 549a0217..1a9b89f7 100644 --- a/dev/ZKA/Sources/FS/NeFS.cxx +++ b/dev/ZKA/Sources/FS/NeFS.cxx @@ -724,7 +724,7 @@ bool NeFSParser::WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, Bool i _Output NFS_CATALOG_STRUCT* NeFSParser::FindCatalog(_Input const Char* catalogName, Lba& out_lba) { - kcout << "start finding catalog...\r"; + kcout << "Start finding catalog...\r"; NFS_ROOT_PARTITION_BLOCK fs_buf{0}; auto drive = sMountpointInterface.A(); diff --git a/dev/ZKA/Sources/PEFCodeMgr.cxx b/dev/ZKA/Sources/PEFCodeMgr.cxx index feafc35c..23dfae31 100644 --- a/dev/ZKA/Sources/PEFCodeMgr.cxx +++ b/dev/ZKA/Sources/PEFCodeMgr.cxx @@ -221,7 +221,7 @@ namespace Kernel proc.StackSize = mib_cast(cDefaultStackSizeMib); } - return UserProcessScheduler::The().Add(proc); + return UserProcessScheduler::The().Add(proc) > 0; } } // namespace Utils diff --git a/dev/ZKA/Sources/UserProcessScheduler.cxx b/dev/ZKA/Sources/UserProcessScheduler.cxx index f480bccc..c68104b9 100644 --- a/dev/ZKA/Sources/UserProcessScheduler.cxx +++ b/dev/ZKA/Sources/UserProcessScheduler.cxx @@ -54,7 +54,7 @@ namespace Kernel Void UserProcess::Crash() { - if (this->Name == 0) + if (*this->Name == 0) return; kcout << this->Name << ": crashed, ID = " << number(kErrorProcessFault) << endl; @@ -202,10 +202,10 @@ namespace Kernel cLastExitCode = exit_code; //! Delete image if not done already. - if (this->Image) + if (this->Image && mm_is_valid_heap(this->Image)) mm_delete_ke_heap(this->Image); - if (this->StackFrame) + if (this->StackFrame && mm_is_valid_heap(this->StackFrame)) mm_delete_ke_heap((VoidPtr)this->StackFrame); this->Image = nullptr; @@ -225,6 +225,8 @@ namespace Kernel if (this->StackReserve) delete[] this->StackReserve; + this->ProcessId = 0; + if (this->ProcessId > 0) UserProcessScheduler::The().Remove(this->ProcessId); } @@ -271,11 +273,14 @@ namespace Kernel return -kErrorProcessFault; } - process.Status = ProcessStatusKind::kStarting; - process.ProcessId = mTeam.mProcessAmount; + if (mTeam.mProcessAmount > kSchedProcessLimitPerTeam) + mTeam.mProcessAmount = 0UL; ++mTeam.mProcessAmount; + process.ProcessId = mTeam.mProcessAmount; + process.Status = ProcessStatusKind::kStarting; + mTeam.AsArray()[process.ProcessId] = process; return process.ProcessId; @@ -414,10 +419,13 @@ namespace Kernel * \param new_pid the process's PID. */ - bool UserProcessHelper::Switch(VoidPtr image_ptr, UInt8* stack, HAL::StackFramePtr frame_ptr, const PID& new_pid) + Bool UserProcessHelper::Switch(VoidPtr image_ptr, UInt8* stack, HAL::StackFramePtr frame_ptr, const PID& new_pid) { if (!stack || !frame_ptr || !image_ptr || new_pid < 0) - return false; + return No; + + while (Yes) + ; for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Count(); ++index) { |
