summaryrefslogtreecommitdiffhomepage
path: root/Public/Kits/System.Core
diff options
context:
space:
mode:
Diffstat (limited to 'Public/Kits/System.Core')
-rw-r--r--Public/Kits/System.Core/Defs.hxx19
-rw-r--r--Public/Kits/System.Core/HCoreHeap.hxx7
-rw-r--r--Public/Kits/System.Core/Heap.cxx5
-rw-r--r--Public/Kits/System.Core/HintBase.hxx18
-rw-r--r--Public/Kits/System.Core/Makefile2
-rw-r--r--Public/Kits/System.Core/New+Delete.cxx50
-rw-r--r--Public/Kits/System.Core/System.hxx2
-rw-r--r--Public/Kits/System.Core/ThreadAPI.hxx36
-rw-r--r--Public/Kits/System.Core/Threading.hxx35
9 files changed, 135 insertions, 39 deletions
diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx
index ad615ef9..d1e5d483 100644
--- a/Public/Kits/System.Core/Defs.hxx
+++ b/Public/Kits/System.Core/Defs.hxx
@@ -45,12 +45,29 @@ typedef __UINT16_TYPE__ WORD;
typedef __UINT32_TYPE__ DWORD;
typedef __UINT64_TYPE__ QWORD;
+typedef char CHAR;
+typedef CHAR* PCHAR;
+
typedef void* PVOID;
typedef void VOID;
+typedef __UINTPTR_TYPE__ UINT_PTR;
+typedef __INTPTR_TYPE__ INT_PTR;
+typedef __UINT64_TYPE__ UINT64;
+typedef __INT64_TYPE__ INT64;
+typedef __UINT32_TYPE__ UINT32;
+typedef __INT32_TYPE__ INT32;
+
typedef __WCHAR_TYPE__ WCHAR;
typedef WCHAR* PWCHAR;
+typedef bool BOOL;
+
+#define TRUE true
+#define FALSE false
+
+#define PTR *
+
#define CA_UNREFERENCED_PARAMETER(e) ((VOID)e)
#ifdef __x86_64__
@@ -90,3 +107,5 @@ enum {
kProcessHeapCallCloseHandle,
kProcessHeapCallsCnt,
};
+
+#include <System.Core/HintBase.hxx>
diff --git a/Public/Kits/System.Core/HCoreHeap.hxx b/Public/Kits/System.Core/HCoreHeap.hxx
index 0c6eb1dc..41143495 100644
--- a/Public/Kits/System.Core/HCoreHeap.hxx
+++ b/Public/Kits/System.Core/HCoreHeap.hxx
@@ -11,3 +11,10 @@ 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.cxx b/Public/Kits/System.Core/Heap.cxx
index 56188e95..aaac37a8 100644
--- a/Public/Kits/System.Core/Heap.cxx
+++ b/Public/Kits/System.Core/Heap.cxx
@@ -20,7 +20,10 @@ Heap* Heap::Shared() noexcept {
return heap;
}
-void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kInstanceObject, me); }
+void Heap::Delete(HeapPtr me) noexcept {
+ CA_MUST_PASS(me);
+ HcFreeProcessHeap(kInstanceObject, me);
+}
SizeT Heap::Size(HeapPtr me) noexcept {
CA_MUST_PASS(me);
diff --git a/Public/Kits/System.Core/HintBase.hxx b/Public/Kits/System.Core/HintBase.hxx
new file mode 100644
index 00000000..86faf455
--- /dev/null
+++ b/Public/Kits/System.Core/HintBase.hxx
@@ -0,0 +1,18 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#define _Input
+#define _Output
+
+#define _Optional
+
+#define _StrictCheckInput
+#define _StrictCheckOutput
+
+#define _InOut
+#define _StrictInOut
diff --git a/Public/Kits/System.Core/Makefile b/Public/Kits/System.Core/Makefile
index f358dfa5..286c1120 100644
--- a/Public/Kits/System.Core/Makefile
+++ b/Public/Kits/System.Core/Makefile
@@ -4,7 +4,7 @@
##################################################
CC=x86_64-w64-mingw32-g++
-CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
+CCFLAGS=-shared -ffreestanding -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
OUTPUT=System.Core.dll
.PHONY: build-core
diff --git a/Public/Kits/System.Core/New+Delete.cxx b/Public/Kits/System.Core/New+Delete.cxx
new file mode 100644
index 00000000..cac883f4
--- /dev/null
+++ b/Public/Kits/System.Core/New+Delete.cxx
@@ -0,0 +1,50 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <System.Core/HCoreHeap.hxx>
+
+void* operator new[](size_t sz)
+{
+ if (sz == 0)
+ ++sz;
+
+ return HcAllocateProcessHeap(kInstanceObject, sz, kStandardAllocation);
+}
+
+void* operator new(size_t sz)
+{
+ if (sz == 0)
+ ++sz;
+
+ return HcAllocateProcessHeap(kInstanceObject, sz, kArrayAllocation);
+}
+
+void operator delete[](void* ptr)
+{
+ if (ptr == nullptr)
+ return;
+
+ HcFreeProcessHeap(kInstanceObject, ptr);
+}
+
+void operator delete(void* ptr)
+{
+ if (ptr == nullptr)
+ return;
+
+ HcFreeProcessHeap(kInstanceObject, ptr);
+}
+
+void operator delete(void* ptr, size_t sz)
+{
+ if (ptr == nullptr)
+ return;
+
+ (void)sz;
+
+ HcFreeProcessHeap(kInstanceObject, ptr);
+}
+
diff --git a/Public/Kits/System.Core/System.hxx b/Public/Kits/System.Core/System.hxx
index 37cab4a4..05028d87 100644
--- a/Public/Kits/System.Core/System.hxx
+++ b/Public/Kits/System.Core/System.hxx
@@ -13,6 +13,6 @@
#include <System.Core/Defs.hxx>
#include <System.Core/File.hxx>
#include <System.Core/Heap.hxx>
-#include <System.Core/ThreadAPI.hxx>
+#include <System.Core/Threading.hxx>
using namespace HCore;
diff --git a/Public/Kits/System.Core/ThreadAPI.hxx b/Public/Kits/System.Core/ThreadAPI.hxx
deleted file mode 100644
index ec15a64c..00000000
--- a/Public/Kits/System.Core/ThreadAPI.hxx
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-//
-// Created by Amlal on 1/27/24.
-//
-
-#ifndef __THREAD_API__
-#define __THREAD_API__
-
-#include <NewKit/Defines.hpp>
-
-namespace HCore {
-/// @brief Thread Information Block for Local Storage.
-/// Located in GS on AMD64, Virtual Address 0x10000 (64x0, 32x0, ARM64)
-struct ThreadInformationBlock final {
- const Char Name[255]; // Module Name
- const UIntPtr StartAddress; // Start Address
- const UIntPtr StartHeap; // Allocation Heap
- const UIntPtr StartStack; // Stack Pointer.
- const Int32 Arch; // Architecture and/or platform.
-};
-
-enum {
- kPC_IA64,
- kPC_AMD64 = kPC_IA64,
- kPC_ARM,
- kMACS_64x0,
- kMACS_32x0,
-};
-} // namespace HCore
-
-#endif // __THREAD_API__
diff --git a/Public/Kits/System.Core/Threading.hxx b/Public/Kits/System.Core/Threading.hxx
new file mode 100644
index 00000000..5d5ed0a6
--- /dev/null
+++ b/Public/Kits/System.Core/Threading.hxx
@@ -0,0 +1,35 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+//
+// Created by Amlal on 3/18/24
+//
+
+#ifndef __THREAD_API__
+#define __THREAD_API__
+
+#include <System.Core/Defs.hxx>
+
+/// @brief Thread Information Block variant for scheduling.
+struct ThreadInformationBlock final {
+ const CHAR Name[255]; // Module Name
+ const UINT_PTR StartAddress; // Start Address
+ const UINT_PTR StartHeap; // Allocation Heap
+ const UINT_PTR StartStack; // Stack Pointer.
+ const DWORD Arch; // Architecture and/or platform.
+ const WORD TID; // Execution Thread ID.
+};
+
+ThreadInformationBlock* HcCreateThread(_Input PVOID Start,
+ _Optional _InOut PVOID HeapOpt, _Optional _InOut PVOID StackOpt);
+
+BOOL HcDestroyThread(_Input ThreadInformationBlock* TIB);
+
+BOOL HcStopThread(_Input ThreadInformationBlock* TIB);
+
+BOOL HcResumeThread(_Input ThreadInformationBlock* TIB);
+
+#endif // __THREAD_API__