From be29b406526c931a606d4d4de545f71e62bc893a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 25 Mar 2024 16:43:00 +0100 Subject: Kernel: A lot of preliminary changes before AHCI and SMP support. --- Public/SDK/System.Core/Sources/DllMain.cxx | 14 -------------- Public/SDK/System.Core/Sources/Heap.cxx | 8 ++++---- Public/SDK/System.Core/Sources/LibEntrypoint.cxx | 14 ++++++++++++++ Public/SDK/System.Core/Sources/New+Delete.cxx | 24 ++++++------------------ 4 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 Public/SDK/System.Core/Sources/DllMain.cxx create mode 100644 Public/SDK/System.Core/Sources/LibEntrypoint.cxx (limited to 'Public/SDK/System.Core/Sources') diff --git a/Public/SDK/System.Core/Sources/DllMain.cxx b/Public/SDK/System.Core/Sources/DllMain.cxx deleted file mode 100644 index 9412cbbb..00000000 --- a/Public/SDK/System.Core/Sources/DllMain.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include - -/// @brief Inits the DLL. -/// @return if it was succesful or not. -DWordType __DllMain(VoidType) { - kInstanceObject = HcGetInstanceObject(); - CA_MUST_PASS(kInstanceObject); - - return 0; -} \ No newline at end of file diff --git a/Public/SDK/System.Core/Sources/Heap.cxx b/Public/SDK/System.Core/Sources/Heap.cxx index 3803af3a..18106f41 100644 --- a/Public/SDK/System.Core/Sources/Heap.cxx +++ b/Public/SDK/System.Core/Sources/Heap.cxx @@ -60,24 +60,24 @@ HeapInterface* HeapInterface::Shared() noexcept { } HeapInterface::HeapInterface() { - CA_MUST_PASS(HcProcessHeapExists(kInstanceObject, (PtrVoidType)this)); + CA_MUST_PASS(HcProcessHeapExists(kApplicationObject, (PtrVoidType)this)); } HeapInterface::~HeapInterface() { delete this; } void HeapInterface::Delete(PtrHeapType me) noexcept { CA_MUST_PASS(me); - HcFreeProcessHeap(kInstanceObject, me); + HcFreeProcessHeap(kApplicationObject, me); } SizeType HeapInterface::Size(PtrHeapType me) noexcept { CA_MUST_PASS(me); - return HcProcessHeapSize(kInstanceObject, me); + return HcProcessHeapSize(kApplicationObject, me); } PtrHeapType HeapInterface::New(const SizeType& sz, const DWordType flags) { SizeType _sz = sz; if (!_sz) ++_sz; - return HcAllocateProcessHeap(kInstanceObject, _sz, flags); + return HcAllocateProcessHeap(kApplicationObject, _sz, flags); } diff --git a/Public/SDK/System.Core/Sources/LibEntrypoint.cxx b/Public/SDK/System.Core/Sources/LibEntrypoint.cxx new file mode 100644 index 00000000..b874ef55 --- /dev/null +++ b/Public/SDK/System.Core/Sources/LibEntrypoint.cxx @@ -0,0 +1,14 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include + +/// @brief Inits the DLL. +/// @return if it was succesful or not. +DWordType __DllMain(VoidType) { + kApplicationObject = HcGetInstanceObject(); + CA_MUST_PASS(kApplicationObject); + + return 0; +} \ No newline at end of file diff --git a/Public/SDK/System.Core/Sources/New+Delete.cxx b/Public/SDK/System.Core/Sources/New+Delete.cxx index fe8ed43f..678aacce 100644 --- a/Public/SDK/System.Core/Sources/New+Delete.cxx +++ b/Public/SDK/System.Core/Sources/New+Delete.cxx @@ -5,44 +5,32 @@ ------------------------------------------- */ #include - -#define kAllocationTypes 2 - -enum HcAllocationKind { - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, - DWordType flags); -CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr); -CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr); -CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr); +#include typedef SizeType size_t; void* operator new[](size_t sz) { if (sz == 0) ++sz; - return HcAllocateProcessHeap(kInstanceObject, sz, kStandardAllocation); + return HcAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation); } void* operator new(size_t sz) { if (sz == 0) ++sz; - return HcAllocateProcessHeap(kInstanceObject, sz, kArrayAllocation); + return HcAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation); } void operator delete[](void* ptr) { if (ptr == nullptr) return; - HcFreeProcessHeap(kInstanceObject, ptr); + HcFreeProcessHeap(kApplicationObject, ptr); } void operator delete(void* ptr) { if (ptr == nullptr) return; - HcFreeProcessHeap(kInstanceObject, ptr); + HcFreeProcessHeap(kApplicationObject, ptr); } void operator delete(void* ptr, size_t sz) { @@ -50,5 +38,5 @@ void operator delete(void* ptr, size_t sz) { (void)sz; - HcFreeProcessHeap(kInstanceObject, ptr); + HcFreeProcessHeap(kApplicationObject, ptr); } -- cgit v1.2.3