summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/System.Core
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-19 21:01:12 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-19 21:01:12 +0100
commitde413aa50bac1342e4ac8c7a66697ea3b551c2e4 (patch)
treeeef86262346e556f276727da3d8175ead9c6ff1d /Public/Kits/System.Core
parentaf7bb25934e8f6781cb7b34ef345ef9af723a2ff (diff)
Kernel(Secret): Major commit.
- Extensive cleanup of the code, and kernel improvements. - The System API has been reworked to be better designed. What is needed now: - AHCI disk driver. - HCFS/NewFS driver. - EPM layout implementation. - Separate bootloader and kernel.
Diffstat (limited to 'Public/Kits/System.Core')
-rw-r--r--Public/Kits/System.Core/Defs.hxx19
-rw-r--r--Public/Kits/System.Core/File.hxx4
-rw-r--r--Public/Kits/System.Core/HCoreBase.hxx7
-rw-r--r--Public/Kits/System.Core/HCoreHeap.hxx20
-rw-r--r--Public/Kits/System.Core/Heap+Impl.cxx37
-rw-r--r--Public/Kits/System.Core/Heap.hxx23
-rw-r--r--Public/Kits/System.Core/HeapCoreImpl.cxx (renamed from Public/Kits/System.Core/HCoreHeap+Impl.cxx)33
-rw-r--r--Public/Kits/System.Core/HeapImpl.cxx41
-rw-r--r--Public/Kits/System.Core/Hint.hxx (renamed from Public/Kits/System.Core/HintBase.hxx)0
-rw-r--r--Public/Kits/System.Core/InitRuntime.cxx (renamed from Public/Kits/System.Core/RuntimeInit.cxx)2
-rw-r--r--Public/Kits/System.Core/New+Delete.cxx2
-rw-r--r--Public/Kits/System.Core/System.Core.hxx9
12 files changed, 104 insertions, 93 deletions
diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx
index bcb3585c..9a17d571 100644
--- a/Public/Kits/System.Core/Defs.hxx
+++ b/Public/Kits/System.Core/Defs.hxx
@@ -108,4 +108,21 @@ enum HcProcessCall {
kProcessCallsCount = 7,
};
-#include <System.Core/HintBase.hxx>
+#include <System.Core/Hint.hxx>
+
+class Exception {
+ public:
+ explicit Exception() = default;
+ virtual ~Exception() = default;
+
+ public:
+ HCORE_COPY_DEFAULT(Exception);
+
+ public:
+ const char *Name();
+ const char *Reason();
+
+ private:
+ const char *mReason{
+ "System.Core: System Exception: Catastrophic failure!"};
+};
diff --git a/Public/Kits/System.Core/File.hxx b/Public/Kits/System.Core/File.hxx
index 2f799330..97377800 100644
--- a/Public/Kits/System.Core/File.hxx
+++ b/Public/Kits/System.Core/File.hxx
@@ -25,10 +25,10 @@ class File final {
public:
voidPtr Read(SizeT off, SizeT sz);
- void Write(voidPtr buf, SizeT off, SizeT sz);
+ void Write(VoidPtr buf, SizeT off, SizeT sz);
void Seek(SizeT off);
voidPtr Read(SizeT sz);
- void Write(voidPtr buf, SizeT sz);
+ void Write(VoidPtr buf, SizeT sz);
void Rewind();
public:
diff --git a/Public/Kits/System.Core/HCoreBase.hxx b/Public/Kits/System.Core/HCoreBase.hxx
deleted file mode 100644
index 774f9883..00000000
--- a/Public/Kits/System.Core/HCoreBase.hxx
+++ /dev/null
@@ -1,7 +0,0 @@
-/** ===========================================
- (C) Mahrouss Logic
- ===========================================*/
-
-#pragma once
-
-#include <System.Core/Defs.hxx>
diff --git a/Public/Kits/System.Core/HCoreHeap.hxx b/Public/Kits/System.Core/HCoreHeap.hxx
deleted file mode 100644
index 41143495..00000000
--- a/Public/Kits/System.Core/HCoreHeap.hxx
+++ /dev/null
@@ -1,20 +0,0 @@
-/** ===========================================
- (C) Mahrouss Logic
- ===========================================*/
-
-#pragma once
-
-#include <System.Core/HCoreBase.hxx>
-
-CA_EXTERN_C ObjectPtr HcGetProcessObject(void);
-CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags);
-CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr);
-CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr);
-CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr);
-
-enum HcAllocationKind {
- kStandardAllocation = 0xC,
- kArrayAllocation = 0xD,
-};
-
-#define kAllocationTypes 2
diff --git a/Public/Kits/System.Core/Heap+Impl.cxx b/Public/Kits/System.Core/Heap+Impl.cxx
deleted file mode 100644
index e3dcb11c..00000000
--- a/Public/Kits/System.Core/Heap+Impl.cxx
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-#include <System.Core/Heap.hxx>
-#include <System.Core/System.Core.hxx>
-
-using namespace System;
-
-Heap* Heap::Shared() noexcept {
- static Heap* heap = nullptr;
-
- if (!heap) {
- heap = new Heap();
- }
-
- return heap;
-}
-
-void Heap::Delete(HeapPtr me) noexcept {
- CA_MUST_PASS(me);
- HcFreeProcessHeap(kInstanceObject, me);
-}
-
-SizeT Heap::Size(HeapPtr me) noexcept {
- CA_MUST_PASS(me);
- return HcProcessHeapSize(kInstanceObject, me);
-}
-
-HeapPtr Heap::New(const SizeT &sz, const Int32 flags) {
- SizeT _sz = sz;
- if (!_sz) ++_sz;
-
- return HcAllocateProcessHeap(kInstanceObject, _sz, flags);
-} \ No newline at end of file
diff --git a/Public/Kits/System.Core/Heap.hxx b/Public/Kits/System.Core/Heap.hxx
index dfcb4587..31e44c7e 100644
--- a/Public/Kits/System.Core/Heap.hxx
+++ b/Public/Kits/System.Core/Heap.hxx
@@ -6,8 +6,22 @@
#pragma once
-#include <System.Core/Defs.hxx>
#include <CompilerKit/CompilerKit.hxx>
+#include <System.Core/Defs.hxx>
+
+#define kAllocationTypes 2
+
+CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz,
+ DWORD flags);
+CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr);
+CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr);
+CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr);
+CA_EXTERN_C ObjectPtr HcGetProcessObject(void);
+
+enum HcAllocationKind {
+ kStandardAllocation = 0xC,
+ kArrayAllocation = 0xD,
+};
namespace System {
using namespace HCore;
@@ -29,7 +43,7 @@ class Heap final {
explicit Heap() = default;
public:
- ~Heap() = default;
+ ~Heap();
public:
HCORE_COPY_DEFAULT(Heap);
@@ -56,9 +70,10 @@ class MemoryException final {
const char *Reason();
private:
- const char *mReason{"System.Core: Process Heap Exception: Catastrophic failure!"};
+ const char *mReason{
+ "System.Core: Process Heap Exception: Catastrophic failure!"};
private:
friend Heap;
};
-} // namespace System \ No newline at end of file
+} // namespace System \ No newline at end of file
diff --git a/Public/Kits/System.Core/HCoreHeap+Impl.cxx b/Public/Kits/System.Core/HeapCoreImpl.cxx
index 0e1b1732..2980a3de 100644
--- a/Public/Kits/System.Core/HCoreHeap+Impl.cxx
+++ b/Public/Kits/System.Core/HeapCoreImpl.cxx
@@ -2,43 +2,46 @@
(C) Mahrouss Logic
===========================================*/
-#include <System.Core/HCoreHeap.hxx>
+#include <System.Core/Heap.hxx>
/// @brief Allocate from the user's heap.
-/// @param refObj
-/// @param sz
-/// @param flags
+/// @param refObj Process object.
+/// @param sz size of object.
+/// @param flags flags.
/// @return
CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags)
{
+ CA_MUST_PASS(sz);
+ CA_MUST_PASS(flags);
+
return (PVOID)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags);
}
/// @brief Free pointer from the user's heap.
-/// @param refObj
-/// @param ptr
-/// @return
+/// @param refObj Process object.
+/// @param ptr the pointer to free.
CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr)
{
+ CA_MUST_PASS(ptr);
CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr));
}
/// @brief Get pointer size.
-/// @param refObj
-/// @param ptr
-/// @return
+/// @param refObj Process object.
+/// @param ptr the pointer to find.
+/// @return the size.
CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr)
{
+ CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallSizePtr, ptr);
}
/// @brief Check if the pointer exists.
/// @param refObj Process object.
-/// @param ptr
-/// @return
-CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr)
+/// @param ptr the pointer to check.
+/// @return if it exists
+CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr)
{
+ CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr);
}
-
-// EOF.
diff --git a/Public/Kits/System.Core/HeapImpl.cxx b/Public/Kits/System.Core/HeapImpl.cxx
new file mode 100644
index 00000000..f41c868f
--- /dev/null
+++ b/Public/Kits/System.Core/HeapImpl.cxx
@@ -0,0 +1,41 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <System.Core/Heap.hxx>
+#include <System.Core/System.Core.hxx>
+
+using namespace System;
+
+/// @brief Shared instance of the heap.
+/// @return
+Heap* Heap::Shared() noexcept {
+ static Heap* heap = nullptr;
+
+ if (!heap) {
+ heap = new Heap();
+ }
+
+ return heap;
+}
+
+Heap::~Heap() { delete this; }
+
+void Heap::Delete(HeapPtr me) noexcept {
+ CA_MUST_PASS(me);
+ HcFreeProcessHeap(kInstanceObject, me);
+}
+
+SizeT Heap::Size(HeapPtr me) noexcept {
+ CA_MUST_PASS(me);
+ return HcProcessHeapSize(kInstanceObject, me);
+}
+
+HeapPtr Heap::New(const SizeT& sz, const Int32 flags) {
+ SizeT _sz = sz;
+ if (!_sz) ++_sz;
+
+ return HcAllocateProcessHeap(kInstanceObject, _sz, flags);
+} \ No newline at end of file
diff --git a/Public/Kits/System.Core/HintBase.hxx b/Public/Kits/System.Core/Hint.hxx
index 86faf455..86faf455 100644
--- a/Public/Kits/System.Core/HintBase.hxx
+++ b/Public/Kits/System.Core/Hint.hxx
diff --git a/Public/Kits/System.Core/RuntimeInit.cxx b/Public/Kits/System.Core/InitRuntime.cxx
index b6022bef..01eb2c1f 100644
--- a/Public/Kits/System.Core/RuntimeInit.cxx
+++ b/Public/Kits/System.Core/InitRuntime.cxx
@@ -2,7 +2,7 @@
(C) Mahrouss Logic
===========================================*/
-#include <System.Core/HCoreHeap.hxx>
+#include <System.Core/Heap.hxx>
/// @brief Inits the C runtime
/// @return if it was succesful or not.
diff --git a/Public/Kits/System.Core/New+Delete.cxx b/Public/Kits/System.Core/New+Delete.cxx
index cac883f4..507cb7a3 100644
--- a/Public/Kits/System.Core/New+Delete.cxx
+++ b/Public/Kits/System.Core/New+Delete.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <System.Core/HCoreHeap.hxx>
+#include <System.Core/Heap.hxx>
void* operator new[](size_t sz)
{
diff --git a/Public/Kits/System.Core/System.Core.hxx b/Public/Kits/System.Core/System.Core.hxx
index b368b997..07b7199c 100644
--- a/Public/Kits/System.Core/System.Core.hxx
+++ b/Public/Kits/System.Core/System.Core.hxx
@@ -4,12 +4,11 @@
#pragma once
-/// Core API
-#include <System.Core/HCoreBase.hxx>
-
/// Process Heap API
-#include <System.Core/HCoreHeap.hxx>
+#include <System.Core/Heap.hxx>
/// File API & Device API.
+#include <System.Core/File.hxx>
-/// Process & Threading API \ No newline at end of file
+/// Process & Threading API
+#include <System.Core/Threading.hxx> \ No newline at end of file