diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-13 00:20:21 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-13 00:20:21 +0200 |
| commit | bc7870aea4c437e1a80b779eb7a968d55733d24c (patch) | |
| tree | 7998fe2f1ef8d3bdf8d37a0b2b2600143bc285ed | |
| parent | 710ce66beaba3bee7289047406ef794c258143e6 (diff) | |
[IMP] Kernel properties (such as \KernelVersion)
[REFACTOR] Rename KernelHeap to just Heap.
[FIX] Scheduler's way of checking boundaries was not correct.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
24 files changed, 149 insertions, 102 deletions
diff --git a/Boot/BootKit/STB.hxx b/Boot/BootKit/STB.hxx index 64f433e5..e99edc36 100644 --- a/Boot/BootKit/STB.hxx +++ b/Boot/BootKit/STB.hxx @@ -22,6 +22,6 @@ #define STBI_FREE(x) Kernel::ke_delete_ke_heap(x) #define STB_IMAGE_IMPLEMENTATION 1 -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <BootKit/Vendor/stb_image.hxx> diff --git a/Kernel/CFKit/Property.hpp b/Kernel/CFKit/Property.hpp index bf6ce770..519f486e 100644 --- a/Kernel/CFKit/Property.hpp +++ b/Kernel/CFKit/Property.hpp @@ -4,14 +4,16 @@ ------------------------------------------- */ -#ifndef __INC_PLIST_HPP__ -#define __INC_PLIST_HPP__ +#ifndef __INC_PROPS_HPP__ +#define __INC_PROPS_HPP__ #include <NewKit/Array.hpp> #include <NewKit/Defines.hpp> #include <NewKit/Function.hpp> #include <NewKit/String.hpp> +#define cMaxPropLen 4096 + namespace Kernel { /// @brief handle to anything (number, ptr, string...) @@ -22,23 +24,24 @@ namespace Kernel class Property { public: - explicit Property(const StringView& sw); + Property() = default; virtual ~Property(); public: Property& operator=(const Property&) = default; Property(const Property&) = default; - bool StringEquals(StringView& name); - const PropertyId& GetPropertyById(); + bool StringEquals(StringView& name); + PropertyId& GetValue(); + StringView& GetKey(); private: - Ref<StringView> fName; - PropertyId fAction; + StringView fName{cMaxPropLen}; + PropertyId fAction{No}; }; template <SizeT N> using PropertyArray = Array<Property, N>; } // namespace Kernel -#endif // !__INC_PLIST_HPP__ +#endif // !__INC_PROPS_HPP__ diff --git a/Kernel/FSKit/IndexableProperty.hxx b/Kernel/FSKit/IndexableProperty.hxx index 49c3d1b3..ecc6a436 100644 --- a/Kernel/FSKit/IndexableProperty.hxx +++ b/Kernel/FSKit/IndexableProperty.hxx @@ -28,8 +28,12 @@ namespace Kernel { public: explicit IndexableProperty() - : Property(StringBuilder::Construct("\\Filesystem\\IsIndexable?").Leak().Leak()) + : Property() { + Kernel::StringView strProp(cMaxPropLen); + strProp += "\\Properties\\Indexable"; + + this->GetKey() = strProp; } ~IndexableProperty() override = default; diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index d9bb4baa..d9918570 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -8,7 +8,7 @@ #include <HALKit/AMD64/Processor.hxx> #include <NewKit/String.hpp> #include <ArchKit/ArchKit.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> namespace Kernel { diff --git a/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/Kernel/HALKit/AMD64/HalInterruptAPI.asm index 5eaf60b4..c09d5a06 100644 --- a/Kernel/HALKit/AMD64/HalInterruptAPI.asm +++ b/Kernel/HALKit/AMD64/HalInterruptAPI.asm @@ -121,19 +121,11 @@ IntNormal 31 [extern hal_apic_acknowledge] -%define cAPICAddress 0xFEE00000 - __NEW_INT_34: -;; make this active, SMP works again. push rax call hal_apic_acknowledge pop rax - mov rax, 0 - - ;; tell there local apic that we're done. - mov qword [cAPICAddress + 0xB0], rax ; send end of interrupt. - iretq IntNormal 32 diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 869e4ae4..fcd12247 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -9,7 +9,7 @@ #include <FirmwareKit/Handover.hxx> #include <KernelKit/FileManager.hpp> #include <KernelKit/Framebuffer.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <KernelKit/PEFCodeManager.hxx> #include <KernelKit/ProcessScheduler.hxx> #include <KernelKit/ProcessHeap.hxx> @@ -18,11 +18,16 @@ #include <KernelKit/CodeManager.hpp> #include <Modules/ACPI/ACPIFactoryInterface.hxx> #include <NetworkKit/IPCEP.hxx> +#include <CFKit/Property.hpp> #define mInitKernel(X) \ X; \ Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP); + + +Kernel::Property cKernelVersion; + /// @brief This symbol is the kernel main symbol. EXTERN_C void KeMain(); @@ -210,6 +215,14 @@ EXTERN_C void hal_init_platform( kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true; kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fHooked = true; + // newoskrnl version 1.00 + // + Kernel::StringView strVer(cMaxPropLen); + strVer += "\\Properties\\KernelVersion"; + + cKernelVersion.GetKey() = strVer; + cKernelVersion.GetValue() = 1100; + Kernel::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_RsdPtr); mInitKernel(KeMain()); diff --git a/Kernel/HALKit/ARM64/HalKernelMain.cxx b/Kernel/HALKit/ARM64/HalKernelMain.cxx index 54a75365..5e66a3d8 100644 --- a/Kernel/HALKit/ARM64/HalKernelMain.cxx +++ b/Kernel/HALKit/ARM64/HalKernelMain.cxx @@ -9,7 +9,7 @@ #include <FirmwareKit/Handover.hxx> #include <KernelKit/FileManager.hpp> #include <KernelKit/Framebuffer.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <KernelKit/PEFCodeManager.hxx> #include <KernelKit/ProcessScheduler.hxx> #include <KernelKit/ProcessHeap.hxx> diff --git a/Kernel/KernelKit/KernelHeap.hpp b/Kernel/KernelKit/Heap.hxx index 95412761..0f673ffb 100644 --- a/Kernel/KernelKit/KernelHeap.hpp +++ b/Kernel/KernelKit/Heap.hxx @@ -4,10 +4,11 @@ ------------------------------------------- */ -#pragma once +#ifndef _INC_KERNEL_HEAP_HXX_ +#define _INC_KERNEL_HEAP_HXX_ // last-rev 30/01/24 -// file: KernelHeap.hpp +// file: KernelHeap.hxx // description: heap allocation for the kernel. #include <NewKit/Defines.hpp> @@ -46,3 +47,5 @@ namespace Kernel /// @return Int32 ke_make_ke_page(VoidPtr allocatedPtr); } // namespace Kernel + +#endif // !_INC_KERNEL_HEAP_HXX_ diff --git a/Kernel/NewKit/ErrorOr.hpp b/Kernel/NewKit/ErrorOr.hpp index 482b85e0..a528de57 100644 --- a/Kernel/NewKit/ErrorOr.hpp +++ b/Kernel/NewKit/ErrorOr.hpp @@ -34,7 +34,7 @@ namespace Kernel } explicit ErrorOr(T Class) - : mRef(Class) + : mRef(Class, true) { } diff --git a/Kernel/NewKit/Json.hxx b/Kernel/NewKit/Json.hxx index 8d4f3a8d..4b994606 100644 --- a/Kernel/NewKit/Json.hxx +++ b/Kernel/NewKit/Json.hxx @@ -15,7 +15,8 @@ #include <NewKit/String.hpp> #include <NewKit/Utils.hpp> -#define cMaxJsonPath 4096 +#define cMaxJsonPath 4096 +#define cUndefinedLen 32 namespace Kernel { @@ -24,8 +25,10 @@ namespace Kernel { public: explicit JsonType() - : Kernel::JsonType(1, 1) + : Kernel::JsonType(cUndefinedLen, cUndefinedLen) { + this->AsKey() += "undefined"; + this->AsValue() += "undefined"; } explicit JsonType(SizeT lhsLen, SizeT rhsLen) @@ -37,7 +40,10 @@ namespace Kernel NEWOS_COPY_DEFAULT(JsonType); + Bool IsUndefined() { return fUndefined; } + private: + Bool fUndefined; // is this instance undefined? StringView fKey; StringView fValue; diff --git a/Kernel/NewKit/New.hpp b/Kernel/NewKit/New.hpp index fae35f3b..eade355d 100644 --- a/Kernel/NewKit/New.hpp +++ b/Kernel/NewKit/New.hpp @@ -6,7 +6,7 @@ ------------------------------------------- */ #pragma once -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> typedef __SIZE_TYPE__ size_t; // gcc will complain about that diff --git a/Kernel/NewKit/Ref.hpp b/Kernel/NewKit/Ref.hpp index da5d6206..0b0f89cc 100644 --- a/Kernel/NewKit/Ref.hpp +++ b/Kernel/NewKit/Ref.hpp @@ -43,6 +43,11 @@ namespace Kernel return fClass; } + T& Fetch() const noexcept + { + return fClass; + } + T operator*() { return fClass; diff --git a/Kernel/NewKit/String.hpp b/Kernel/NewKit/String.hpp index cfff3e3c..7440900c 100644 --- a/Kernel/NewKit/String.hpp +++ b/Kernel/NewKit/String.hpp @@ -8,6 +8,7 @@ #include <NewKit/Defines.hpp> #include <NewKit/ErrorOr.hpp> +#include <NewKit/Utils.hpp> #include <NewKit/KernelCheck.hpp> namespace Kernel @@ -15,7 +16,15 @@ namespace Kernel class StringView final { public: - explicit StringView() = default; + explicit StringView() + { + fSz = 4096; + + fData = new Char[fSz]; + MUST_PASS(fData); + + rt_set_memory(fData, 0, fSz); + } explicit StringView(Size Sz) : fSz(Sz) @@ -23,6 +32,8 @@ namespace Kernel MUST_PASS(Sz > 1); fData = new Char[Sz]; MUST_PASS(fData); + + rt_set_memory(fData, 0, Sz); } ~StringView() diff --git a/Kernel/Sources/KernelHeap.cxx b/Kernel/Sources/Heap.cxx index 510584dd..6ac91448 100644 --- a/Kernel/Sources/KernelHeap.cxx +++ b/Kernel/Sources/Heap.cxx @@ -6,7 +6,7 @@ #include <KernelKit/DebugOutput.hpp> #include <KernelKit/HError.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <NewKit/Crc32.hpp> #include <NewKit/PageManager.hpp> diff --git a/Kernel/Sources/KeMain.cxx b/Kernel/Sources/Main.cxx index c06325ba..8c80d70c 100644 --- a/Kernel/Sources/KeMain.cxx +++ b/Kernel/Sources/Main.cxx @@ -2,18 +2,19 @@ Copyright ZKA Technologies - File: KeMain.cxx - Purpose: Kernel main loop. + File: Main.cxx + Purpose: Main entrypoint of kernel. ------------------------------------------- */ +#include "KernelKit/DebugOutput.hpp" #include <ArchKit/ArchKit.hpp> #include <Modules/CoreCG/CoreCG.hxx> #include <CompilerKit/Detail.hxx> #include <FirmwareKit/Handover.hxx> #include <KernelKit/FileManager.hpp> #include <KernelKit/Framebuffer.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <KernelKit/PEF.hpp> #include <KernelKit/PEFCodeManager.hxx> #include <KernelKit/ProcessScheduler.hxx> @@ -23,6 +24,9 @@ #include <NewKit/String.hpp> #include <NewKit/Utils.hpp> #include <KernelKit/CodeManager.hpp> +#include <CFKit/Property.hpp> + +EXTERN Kernel::Property cKernelVersion; namespace Kernel::Detail { @@ -39,7 +43,7 @@ namespace Kernel::Detail { /// Mounted partition, cool! Kernel::kcout - << "newoskrnl: No need to create for a NewFS partition here...\r"; + << "newoskrnl: No need to create for a NewFS+EPM partition here...\r"; } else { @@ -63,7 +67,7 @@ namespace Kernel::Detail if (catalogDir) { - Kernel::kcout << "newoskrnl: already here.\r"; + Kernel::kcout << "newoskrnl: already exists.\r"; delete catalogDir; continue; @@ -121,11 +125,6 @@ namespace Kernel::Detail if (catalogDisk) { - auto bufferInfoDisk = (Kernel::Char*)this->fNewFS->GetParser()->ReadCatalog(catalogDisk, kNewFSSectorSz, cSrcName); - Kernel::kcout << bufferInfoDisk; - Kernel::end_line(); - - delete bufferInfoDisk; delete catalogDisk; } else @@ -163,9 +162,6 @@ namespace Kernel::Detail (Kernel::VoidPtr)diskFolder.CData(), kNewFSSectorSz, cSrcName); - Kernel::kcout << diskFolder.CData(); - Kernel::end_line(); - delete catalogDisk; } } @@ -188,6 +184,7 @@ namespace Kernel::Detail /// @return void no return value. STATIC Kernel::Void ke_user_switch(Kernel::Void) { + Kernel::kcout << "newoskrnl: " << cKernelVersion.GetKey().CData() << ": " << Kernel::number(cKernelVersion.GetValue()) << Kernel::endl; } } // namespace Kernel::Detail diff --git a/Kernel/Sources/New+Delete.cxx b/Kernel/Sources/New+Delete.cxx index 32a76769..2921e079 100644 --- a/Kernel/Sources/New+Delete.cxx +++ b/Kernel/Sources/New+Delete.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <NewKit/New.hpp> void* operator new[](size_t sz) diff --git a/Kernel/Sources/NewFS+FileManager.cxx b/Kernel/Sources/NewFS+FileManager.cxx index 3ff675bc..146f721d 100644 --- a/Kernel/Sources/NewFS+FileManager.cxx +++ b/Kernel/Sources/NewFS+FileManager.cxx @@ -5,7 +5,7 @@ ------------------------------------------- */ #include <KernelKit/FileManager.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #ifdef __FSKIT_USE_NEWFS__ diff --git a/Kernel/Sources/PEFCodeManager.cxx b/Kernel/Sources/PEFCodeManager.cxx index a39dc158..8b1918ef 100644 --- a/Kernel/Sources/PEFCodeManager.cxx +++ b/Kernel/Sources/PEFCodeManager.cxx @@ -5,7 +5,7 @@ ------------------------------------------- */ #include <KernelKit/DebugOutput.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <KernelKit/PEFCodeManager.hxx> #include <KernelKit/ProcessScheduler.hxx> #include <NewKit/Defines.hpp> diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx index 42e7285a..a536bf52 100644 --- a/Kernel/Sources/ProcessScheduler.cxx +++ b/Kernel/Sources/ProcessScheduler.cxx @@ -11,7 +11,7 @@ #include <KernelKit/ProcessScheduler.hxx> #include <KernelKit/SMPManager.hpp> -#include <KernelKit/KernelHeap.hpp> +#include <KernelKit/Heap.hxx> #include <NewKit/String.hpp> #include <KernelKit/HError.hpp> @@ -29,14 +29,9 @@ namespace Kernel STATIC Int32 cLastExitCode = 0U; - /// @brief Gets the latest exit code. + /// @brief Gets the last exit code. /// @note Not thread-safe. /// @return Int32 the last exit code. - const Int32& ProcessHeader::GetExitCode() noexcept - { - return fLastExitCode; - } - const Int32& rt_get_exit_code() noexcept { return cLastExitCode; @@ -55,6 +50,14 @@ namespace Kernel this->Exit(kErrorProcessFault); } + /// @brief Gets the local last exit code. + /// @note Not thread-safe. + /// @return Int32 the last exit code. + const Int32& ProcessHeader::GetExitCode() noexcept + { + return this->fLastExitCode; + } + Int32& ProcessHeader::GetLocalCode() noexcept { return fLocalCode; @@ -76,13 +79,13 @@ namespace Kernel { ErrLocal() = kErrorHeapOutOfMemory; - /* we're going out of memory */ + /* We're going out of memory! crash... */ this->Crash(); return nullptr; } - this->HeapCursor = (VoidPtr)((UIntPtr)this->HeapCursor + (sizeof(sz))); + this->HeapCursor = reinterpret_cast<VoidPtr>((UIntPtr)this->HeapCursor + (sizeof(sz))); VoidPtr ptr = this->HeapCursor; ++this->UsedMemory; @@ -97,21 +100,17 @@ namespace Kernel /***********************************************************************************/ /* @brief checks if runtime pointer is in region. */ - bool rt_is_in_pool(VoidPtr pool_ptr, VoidPtr pool, const SizeT& sz) + bool rt_is_in_pool(VoidPtr pool_ptr, VoidPtr pool, const SizeT& pool_ptr_cur_sz, const SizeT& pool_ptr_used_sz) { - UIntPtr* _pool_ptr = (UIntPtr*)pool_ptr; - UIntPtr* _pool = (UIntPtr*)pool; - - for (SizeT index = sz; _pool[sz] != kUserHeapMag; --index) - { - if (&_pool[index] > &_pool_ptr[sz]) - continue; + if (pool == nullptr || + pool_ptr == nullptr) + return false; - if (_pool[index] == _pool_ptr[index]) - return true; - } + UIntPtr* uint_pool_ptr = (UIntPtr*)pool_ptr; + UIntPtr* uint_pool = (UIntPtr*)pool; - return false; + return (UIntPtr)&uint_pool > (UIntPtr)&uint_pool_ptr && + pool_ptr_cur_sz > pool_ptr_used_sz; } /* @brief free pointer from usage. */ @@ -124,7 +123,7 @@ namespace Kernel if (this->UsedMemory < 1) return false; - if (rt_is_in_pool(ptr, this->HeapCursor, this->UsedMemory)) + if (rt_is_in_pool(ptr, this->HeapCursor, this->UsedMemory, this->FreeMemory)) { this->HeapCursor = (VoidPtr)((UIntPtr)this->HeapCursor - (sizeof(sz))); rt_zero_memory(ptr, sz); diff --git a/Kernel/Sources/Property.cxx b/Kernel/Sources/Property.cxx index 47969bd5..60bd03da 100644 --- a/Kernel/Sources/Property.cxx +++ b/Kernel/Sources/Property.cxx @@ -8,21 +8,19 @@ namespace Kernel { - Property::Property(const StringView& sw) - : fName(sw) - { - kcout << "newoskrnl: Property created: " << sw.CData(); - endl; - } - Property::~Property() = default; bool Property::StringEquals(StringView& name) { - return fName && this->fName == name; + return this->fName && this->fName == name; + } + + StringView& Property::GetKey() + { + return this->fName; } - const PropertyId& Property::GetPropertyById() + PropertyId& Property::GetValue() { return fAction; } diff --git a/Kernel/Sources/String.cxx b/Kernel/Sources/String.cxx index 2b58d551..2ed52029 100644 --- a/Kernel/Sources/String.cxx +++ b/Kernel/Sources/String.cxx @@ -22,7 +22,7 @@ namespace Kernel Size StringView::Length() const { - return rt_string_len(fData); + return fSz; } bool StringView::operator==(const StringView& rhs) const @@ -214,22 +214,25 @@ namespace Kernel return ret; } - static void string_append(char* lhs, char* rhs, int cur) + STATIC void rt_string_append(Char* lhs, Char* rhs, Int cur) { - if (lhs && rhs) - { - SizeT sz_rhs = rt_string_len(rhs); - - if (sz_rhs == 0) - return; + SizeT sz_rhs = rt_string_len(rhs); + SizeT rhs_i = 0; - rt_copy_memory(rhs, lhs + cur, sz_rhs); + for (; rhs_i < sz_rhs; ++rhs_i) + { + lhs[rhs_i + cur] = rhs[rhs_i]; } + + lhs[rhs_i + cur] = 0; } StringView& StringView::operator+=(const Char* rhs) { - string_append(this->fData, const_cast<char*>(rhs), this->fCur); + if (rt_string_len(rhs) > this->Length()) + return *this; + + rt_string_append(this->fData, const_cast<Char*>(rhs), this->fCur); this->fCur += rt_string_len(rhs); return *this; @@ -237,11 +240,11 @@ namespace Kernel StringView& StringView::operator+=(const StringView& rhs) { - if (rt_string_len(rhs.fData) > rt_string_len(this->fData)) + if (rt_string_len(rhs.fData) > this->Length()) return *this; - string_append(this->fData, const_cast<char*>(rhs.fData), this->fCur); - this->fCur += rt_string_len(const_cast<char*>(rhs.fData)); + rt_string_append(this->fData, const_cast<Char*>(rhs.fData), this->fCur); + this->fCur += rt_string_len(const_cast<Char*>(rhs.fData)); return *this; } diff --git a/Kernel/Sources/ThreadLocalStorage.cxx b/Kernel/Sources/ThreadLocalStorage.cxx index f5fc2d3e..245ffa1c 100644 --- a/Kernel/Sources/ThreadLocalStorage.cxx +++ b/Kernel/Sources/ThreadLocalStorage.cxx @@ -7,6 +7,8 @@ * ======================================================== */ +#include <NewKit/String.hpp> +#include <CFKit/Property.hpp> #include <KernelKit/ProcessScheduler.hxx> #include <KernelKit/ThreadLocalStorage.hxx> @@ -14,11 +16,13 @@ /***********************************************************************************/ /// @file ThreadLocalStorage.cxx -/// @brief TLS implementation in kernel. +/// @brief TLS inside the kernel. /***********************************************************************************/ using namespace Kernel; +Kernel::Property cTLSEnforceCheck; + /** * @brief Check for cookie inside TIB. * @param tib the TIB to check. @@ -33,7 +37,7 @@ Boolean tls_check_tib(ThreadInformationBlock* tib) Encoder encoder; const char* tibAsBytes = encoder.AsBytes(tib); - kcout << "newoskrnl: Checking for a valid cookie...\r"; + kcout << "newoskrnl: checking for a valid cookie...\r"; return tibAsBytes[0] == kCookieMag0 && tibAsBytes[1] == kCookieMag1 && tibAsBytes[2] == kCookieMag2; @@ -44,18 +48,28 @@ Boolean tls_check_tib(ThreadInformationBlock* tib) * @param stackPtr The call frame. * @return */ -EXTERN_C Void tls_check_syscall_impl(Kernel::VoidPtr TIB) noexcept +EXTERN_C Void tls_check_syscall_impl(Kernel::VoidPtr tib_ptr) noexcept { - if (!TIB) - return; + if (!tib_ptr) + { + if (cTLSEnforceCheck.GetValue() == No) + { + return; + } + else + { + kcout << "newoskrnl: crashing because of an invalid TIB...\r"; + ProcessScheduler::The().Leak().TheCurrent().Leak().Crash(); + } + } - ThreadInformationBlock* tib = (ThreadInformationBlock*)TIB; + ThreadInformationBlock* tib_struct = (ThreadInformationBlock*)tib_ptr; - if (!tls_check_tib(tib)) + if (!tls_check_tib(tib_struct)) { kcout << "newoskrnl: crashing because of an invalid TIB...\r"; ProcessScheduler::The().Leak().TheCurrent().Leak().Crash(); } - kcout << "newoskrnl: Verification succeeded! Keeping on...\r"; + kcout << "newoskrnl: Verification succeeded! staying alive...\r"; } diff --git a/Kernel/Sources/Utils.cxx b/Kernel/Sources/Utils.cxx index b152888b..12e2e2a8 100644 --- a/Kernel/Sources/Utils.cxx +++ b/Kernel/Sources/Utils.cxx @@ -48,15 +48,14 @@ namespace Kernel Size rt_string_len(const Char* ptr) { - if (!ptr) + if (*ptr == 0) return 0; SizeT cnt = 0; - while (*ptr != (Char)0) + while (ptr[cnt] != (Char)0) { - ++ptr; - ++cnt; + cnt++; } return cnt; diff --git a/newoskrnl.files b/newoskrnl.files index c1c2ddf4..abdc19e8 100644 --- a/newoskrnl.files +++ b/newoskrnl.files @@ -158,7 +158,7 @@ Kernel/KernelKit/DriveManager.hxx Kernel/KernelKit/FileManager.hpp
Kernel/KernelKit/Framebuffer.hpp
Kernel/KernelKit/HError.hpp
-Kernel/KernelKit/KernelHeap.hpp
+Kernel/KernelKit/Heap.hxx
Kernel/KernelKit/LoaderInterface.hpp
Kernel/KernelKit/LockDelegate.hpp
Kernel/KernelKit/MSDOS.hxx
|
