diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-09 19:55:54 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-09 19:56:35 +0200 |
| commit | 1c217ed09c6c4b13ec09b897270a208439f0db55 (patch) | |
| tree | 43c93aef6ee233fafcd7ca07a5700dd76d5ecdf5 /Kernel/Sources | |
| parent | acd8297fe927e601a7173cec7ca5445fd4a9c74a (diff) | |
[FIX] Fix bootloop on serial write, fixing more bugs now, still have to
fix allocation.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources')
| -rw-r--r-- | Kernel/Sources/HalPageAlloc.cxx | 2 | ||||
| -rw-r--r-- | Kernel/Sources/Heap.cxx | 19 | ||||
| -rw-r--r-- | Kernel/Sources/KernelCheck.cxx | 2 | ||||
| -rw-r--r-- | Kernel/Sources/User.cxx | 46 |
4 files changed, 41 insertions, 28 deletions
diff --git a/Kernel/Sources/HalPageAlloc.cxx b/Kernel/Sources/HalPageAlloc.cxx index 645b8e46..f22db98a 100644 --- a/Kernel/Sources/HalPageAlloc.cxx +++ b/Kernel/Sources/HalPageAlloc.cxx @@ -15,7 +15,7 @@ #include <NewKit/Defines.hxx> #include <NewKit/KernelCheck.hxx> -STATIC Kernel::Boolean kAllocationInProgress = false; +Kernel::Boolean kAllocationInProgress = false; namespace Kernel { diff --git a/Kernel/Sources/Heap.cxx b/Kernel/Sources/Heap.cxx index 72c0b77c..167636a0 100644 --- a/Kernel/Sources/Heap.cxx +++ b/Kernel/Sources/Heap.cxx @@ -18,10 +18,9 @@ namespace Kernel { - STATIC SizeT kHeapCount = 0UL; - STATIC PageManager kHeapPageManager; - - STATIC Bool kOperationInProgress = No; + SizeT kHeapCount = 0UL; + PageManager kHeapPageManager; + Bool kOperationInProgress = No; namespace Detail { @@ -48,19 +47,9 @@ namespace Kernel typedef HEAP_INFORMATION_BLOCK* HEAP_INFORMATION_BLOCK_PTR; - Bool mm_alloc_init_timeout(Void) noexcept + Void mm_alloc_init_timeout(Void) noexcept { - SizeT timOut = 0U; - - while (kOperationInProgress) - { - ++timOut; - if (timOut > 10000000) - return false; - } - kOperationInProgress = Yes; - return true; } Void mm_alloc_fini_timeout(Void) noexcept diff --git a/Kernel/Sources/KernelCheck.cxx b/Kernel/Sources/KernelCheck.cxx index bf3d91b6..cff17077 100644 --- a/Kernel/Sources/KernelCheck.cxx +++ b/Kernel/Sources/KernelCheck.cxx @@ -68,7 +68,7 @@ namespace Kernel switch (id) { case RUNTIME_CHECK_PROCESS: { - cg_write_text("Scheduler error.", start_y, x, panicTxt); + cg_write_text("Process scheduler error (Catasrophic failure).", start_y, x, panicTxt); break; } case RUNTIME_CHECK_ACPI: { diff --git a/Kernel/Sources/User.cxx b/Kernel/Sources/User.cxx index 2b22cf05..46dd0d76 100644 --- a/Kernel/Sources/User.cxx +++ b/Kernel/Sources/User.cxx @@ -33,33 +33,57 @@ namespace Kernel for (Size i_pass = 0; i_pass < rt_string_len(password); ++i_pass) { - Char cur_chr = password[i_pass]; + Char cur_chr = password[i_pass]; password[i_pass] = cur_chr + (user->IsStdUser() ? 0xCF : 0xEF); } - return 0; } - } + } // namespace Detail User::User(const Int32& sel, const Char* userName) : fRing((RingKind)sel) { MUST_PASS(sel >= 0); - - auto view = StringBuilder::Construct(userName); - this->fUserName += view.Leak().Leak(); + this->fUserName += userName; } User::User(const RingKind& ringKind, const Char* userName) : fRing(ringKind) { - auto view = StringBuilder::Construct(userName); - this->fUserName += view.Leak().Leak(); + this->fUserName += userName; } User::~User() = default; + Bool User::TrySave(const Char* password) noexcept + { + SizeT len = rt_string_len(password); + + Char* token = new Char[len]; + + MUST_PASS(token); + + rt_copy_memory((VoidPtr)password, token, rt_string_len(password)); + + Detail::cred_construct_token(token, this); + + if (NewFilesystemManager::GetMounted()) + { + if (auto dir = NewFilesystemManager::GetMounted()->CreateDirectory("\\Users")) + delete dir; + + auto node = NewFilesystemManager::GetMounted()->Create(kUsersFile); + NewFilesystemManager::GetMounted()->Write(this->fUserName.CData(), node, (VoidPtr)token, this->IsStdUser() ? 0xCF : 0xEF, len); + + delete node; + + return true; + } + + return false; + } + bool User::operator==(const User& lhs) { return lhs.fRing == this->fRing; @@ -129,7 +153,7 @@ namespace Kernel } else { - Char generated_token[255] = { 0 }; + Char generated_token[255] = {0}; // ================================================== // // Provide password on token variable. @@ -155,7 +179,7 @@ namespace Kernel return false; } - kcout << "newoskrnl: Correct credentials, moving on.\r"; + kcout << "newoskrnl: Credentials are correct, moving on.\r"; } // ------------------------------------------ // @@ -177,7 +201,7 @@ namespace Kernel } fCurrentUser = user; - Kernel::kcout << "newoskrnl: logged in as: " << fCurrentUser->Name().CData() << Kernel::endl; + Kernel::kcout << "newoskrnl: Logged in as: " << fCurrentUser->Name().CData() << Kernel::endl; return true; } |
