summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Private/KernelKit/ProcessScheduler.hpp3
-rw-r--r--Private/KernelKit/ThreadLocalStorage.hxx4
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx4
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootString.cxx (renamed from Private/NewBoot/Source/BootString.cxx)0
-rw-r--r--Private/Source/String.cxx9
-rw-r--r--Private/Source/ThreadLocalStorage.cxx4
-rw-r--r--Private/Source/Utils.cxx17
-rw-r--r--Public/Kits/System.Core/AMD64/HCoreAssemblyRoutines.s (renamed from Public/Kits/System.Core/HCoreHeap.s)3
-rw-r--r--Public/Kits/System.Core/ARM64/.gitkeep0
-rw-r--r--Public/Kits/System.Core/Defs.hxx17
-rw-r--r--Public/Kits/System.Core/Heap.cxx42
-rw-r--r--Public/Kits/System.Core/Heap.hxx22
-rw-r--r--Public/Kits/System.Core/HeapCoreImpl.cxx47
-rw-r--r--Public/Kits/System.Core/HeapImpl.cxx68
-rw-r--r--Public/Kits/System.Core/Makefile6
-rw-r--r--Public/Kits/System.Graphics/Stylesheet.hxx3
16 files changed, 121 insertions, 128 deletions
diff --git a/Private/KernelKit/ProcessScheduler.hpp b/Private/KernelKit/ProcessScheduler.hpp
index ba453fbe..e3cbbe86 100644
--- a/Private/KernelKit/ProcessScheduler.hpp
+++ b/Private/KernelKit/ProcessScheduler.hpp
@@ -205,7 +205,8 @@ public:
using ProcessPtr = Process *;
-//! @brief Kernel scheduler..
+/// @brief Process manager class.
+/// The main class which you call to schedule an app.
class ProcessManager final {
private:
explicit ProcessManager() = default;
diff --git a/Private/KernelKit/ThreadLocalStorage.hxx b/Private/KernelKit/ThreadLocalStorage.hxx
index c6be2c2b..09017fc0 100644
--- a/Private/KernelKit/ThreadLocalStorage.hxx
+++ b/Private/KernelKit/ThreadLocalStorage.hxx
@@ -11,9 +11,9 @@
//! @brief TLS implementation in C++
-#define kCookieMag0 'h'
+#define kCookieMag0 'H'
#define kCookieMag1 'C'
-#define kCookieMag2 'o'
+#define kCookieMag2 'R'
template <typename T>
T *tls_new_ptr(void);
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 93f5c6e2..31acff3f 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -154,6 +154,10 @@ inline UInt32 In32(UInt16 port) {
return value;
}
+inline Void rt_hlt() {
+ asm volatile("hlt");
+}
+
#endif // __EFI_x86_64__
/***********************************************************************************/
diff --git a/Private/NewBoot/Source/BootString.cxx b/Private/NewBoot/Source/HEL/AMD64/BootString.cxx
index 9fbe1a11..9fbe1a11 100644
--- a/Private/NewBoot/Source/BootString.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootString.cxx
diff --git a/Private/Source/String.cxx b/Private/Source/String.cxx
index 23955068..a27a3a37 100644
--- a/Private/Source/String.cxx
+++ b/Private/Source/String.cxx
@@ -60,8 +60,7 @@ ErrorOr<StringView> StringBuilder::Construct(const Char *data) {
StringView view(rt_string_len(data));
- rt_copy_memory(reinterpret_cast<voidPtr>(const_cast<Char *>(data)),
- reinterpret_cast<voidPtr>(view.Data()), view.Length());
+ view += data;
return ErrorOr<StringView>(view);
}
@@ -165,16 +164,16 @@ const char *StringBuilder::Format(const char *fmt, const char *fmt2) {
}
static void string_append(char *lhs, char *rhs, int cur) {
- if (lhs && rhs && cur < rt_string_len(lhs)) {
+ if (lhs && rhs) {
SizeT sz_rhs = rt_string_len(rhs);
+ if (sz_rhs == 0) return;
+
rt_copy_memory(rhs, lhs + cur, sz_rhs);
}
}
StringView &StringView::operator+=(const Char *rhs) {
- if (rt_string_len(rhs) > rt_string_len(this->m_Data)) return *this;
-
string_append(this->m_Data, const_cast<char *>(rhs), this->m_Cur);
this->m_Cur += rt_string_len(rhs);
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx
index 30a241ea..ab3b8383 100644
--- a/Private/Source/ThreadLocalStorage.cxx
+++ b/Private/Source/ThreadLocalStorage.cxx
@@ -21,14 +21,14 @@ using namespace HCore;
/**
* Check for cookie inside TIB.
- * @param ptr
+ * @param tib the TIB to check.
* @return if the cookie is enabled.
*/
Boolean tls_check_tib(ThreadInformationBlock* tib) {
if (!tib) return false;
- HCore::Encoder encoder;
+ Encoder encoder;
const char* tibAsBytes = encoder.AsBytes(tib);
kcout << "HCoreKrnl\\TLS: Checking for a valid cookie...\n";
diff --git a/Private/Source/Utils.cxx b/Private/Source/Utils.cxx
index b9264e36..d1b146f8 100644
--- a/Private/Source/Utils.cxx
+++ b/Private/Source/Utils.cxx
@@ -5,6 +5,7 @@
------------------------------------------- */
#include <NewKit/Utils.hpp>
+#include <KernelKit/DebugOutput.hpp>
namespace HCore {
Int rt_string_cmp(const Char *src, const Char *cmp, Size size) {
@@ -36,13 +37,17 @@ Size rt_string_len(const Char *str, SizeT _len) {
return len;
}
-Size rt_string_len(const Char *str) {
- if (*str == '\0') return 0;
+Size rt_string_len(const Char *ptr) {
+ if (!ptr) return 0;
- Size len{0};
- while (str[len] != '\0') ++len;
+ SizeT cnt = 0;
- return len;
+ while (*ptr != (Char)0) {
+ ++ptr;
+ ++cnt;
+ }
+
+ return cnt;
}
voidPtr rt_set_memory(voidPtr src, char value, Size len) {
@@ -70,7 +75,7 @@ Int rt_move_memory(const voidPtr src, voidPtr dst, Size len) {
dstChar[index] = srcChr[index];
srcChr[index] = 0;
- index++;
+ ++index;
}
return 0;
diff --git a/Public/Kits/System.Core/HCoreHeap.s b/Public/Kits/System.Core/AMD64/HCoreAssemblyRoutines.s
index 89d85680..71984042 100644
--- a/Public/Kits/System.Core/HCoreHeap.s
+++ b/Public/Kits/System.Core/AMD64/HCoreAssemblyRoutines.s
@@ -7,7 +7,8 @@
.globl HcGetProcessObject
.globl __assert_chk_fail
-/* Process Heap getter */
+/* @brief Process object getter */
+/* @throws: ApptError: appartement error. */
HcGetProcessObject:
mov $0x10, %rcx /* sysGetProcessObject */
int $0x21
diff --git a/Public/Kits/System.Core/ARM64/.gitkeep b/Public/Kits/System.Core/ARM64/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Public/Kits/System.Core/ARM64/.gitkeep
diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx
index 9a17d571..84bdc7bb 100644
--- a/Public/Kits/System.Core/Defs.hxx
+++ b/Public/Kits/System.Core/Defs.hxx
@@ -88,6 +88,7 @@ typedef bool BOOL;
#define CA_STATIC static
#define CA_INLINE inline
+#define CA_CONST const
#ifdef __cplusplus
#define CA_CONSTEXPR constexpr
@@ -110,19 +111,19 @@ enum HcProcessCall {
#include <System.Core/Hint.hxx>
-class Exception {
+class SystemException {
public:
- explicit Exception() = default;
- virtual ~Exception() = default;
+ explicit SystemException() = default;
+ virtual ~SystemException() = default;
public:
- HCORE_COPY_DEFAULT(Exception);
+ HCORE_COPY_DEFAULT(SystemException);
public:
- const char *Name();
- const char *Reason();
+ virtual const char *Name() = 0;
+ virtual const char *Reason() = 0;
private:
const char *mReason{
- "System.Core: System Exception: Catastrophic failure!"};
-};
+ "System.Core: SystemException: Catastrophic failure!"};
+}; \ No newline at end of file
diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap.cxx
new file mode 100644
index 00000000..4dfd34e4
--- /dev/null
+++ b/Public/Kits/System.Core/Heap.cxx
@@ -0,0 +1,42 @@
+/* -------------------------------------------
+
+ 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() { }
+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/Heap.hxx b/Public/Kits/System.Core/Heap.hxx
index 31e44c7e..1bfc00de 100644
--- a/Public/Kits/System.Core/Heap.hxx
+++ b/Public/Kits/System.Core/Heap.hxx
@@ -40,7 +40,7 @@ enum {
class Heap final {
private:
- explicit Heap() = default;
+ explicit Heap();
public:
~Heap();
@@ -56,24 +56,4 @@ class Heap final {
SizeT Size(HeapPtr me) noexcept;
HeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags);
};
-
-class MemoryException final {
- public:
- explicit MemoryException() = default;
- ~MemoryException() = default;
-
- public:
- HCORE_COPY_DEFAULT(MemoryException);
-
- public:
- const char *Name();
- const char *Reason();
-
- private:
- const char *mReason{
- "System.Core: Process Heap Exception: Catastrophic failure!"};
-
- private:
- friend Heap;
-};
} // namespace System \ No newline at end of file
diff --git a/Public/Kits/System.Core/HeapCoreImpl.cxx b/Public/Kits/System.Core/HeapCoreImpl.cxx
deleted file mode 100644
index 2980a3de..00000000
--- a/Public/Kits/System.Core/HeapCoreImpl.cxx
+++ /dev/null
@@ -1,47 +0,0 @@
-/** ===========================================
- (C) Mahrouss Logic
- ===========================================*/
-
-#include <System.Core/Heap.hxx>
-
-/// @brief Allocate from the user's heap.
-/// @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 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 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 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);
-}
diff --git a/Public/Kits/System.Core/HeapImpl.cxx b/Public/Kits/System.Core/HeapImpl.cxx
index f41c868f..2980a3de 100644
--- a/Public/Kits/System.Core/HeapImpl.cxx
+++ b/Public/Kits/System.Core/HeapImpl.cxx
@@ -1,41 +1,47 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
+/** ===========================================
+ (C) Mahrouss Logic
+ ===========================================*/
#include <System.Core/Heap.hxx>
-#include <System.Core/System.Core.hxx>
-using namespace System;
-
-/// @brief Shared instance of the heap.
+/// @brief Allocate from the user's heap.
+/// @param refObj Process object.
+/// @param sz size of object.
+/// @param flags flags.
/// @return
-Heap* Heap::Shared() noexcept {
- static Heap* heap = nullptr;
-
- if (!heap) {
- heap = new Heap();
- }
-
- return heap;
+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);
}
-Heap::~Heap() { delete this; }
-
-void Heap::Delete(HeapPtr me) noexcept {
- CA_MUST_PASS(me);
- HcFreeProcessHeap(kInstanceObject, me);
+/// @brief Free pointer from the user's heap.
+/// @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));
}
-SizeT Heap::Size(HeapPtr me) noexcept {
- CA_MUST_PASS(me);
- return HcProcessHeapSize(kInstanceObject, me);
+/// @brief Get pointer size.
+/// @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);
}
-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
+/// @brief Check if the pointer exists.
+/// @param refObj Process object.
+/// @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);
+}
diff --git a/Public/Kits/System.Core/Makefile b/Public/Kits/System.Core/Makefile
index 286c1120..fb0f3e87 100644
--- a/Public/Kits/System.Core/Makefile
+++ b/Public/Kits/System.Core/Makefile
@@ -7,9 +7,9 @@ CC=x86_64-w64-mingw32-g++
CCFLAGS=-shared -ffreestanding -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
OUTPUT=System.Core.dll
-.PHONY: build-core
-build-core:
- $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard *.cxx) $(wildcard *.s) -o $(OUTPUT)
+.PHONY: build-core-amd64
+build-core-amd64:
+ $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard *.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT)
.PHONY: all
all: build-core
diff --git a/Public/Kits/System.Graphics/Stylesheet.hxx b/Public/Kits/System.Graphics/Stylesheet.hxx
index 79efbcf4..f4106a7b 100644
--- a/Public/Kits/System.Graphics/Stylesheet.hxx
+++ b/Public/Kits/System.Graphics/Stylesheet.hxx
@@ -35,12 +35,13 @@ class G_API GStylesheet final {
class StylesheetParser final {
public:
- static MutableArray<GStylesheet> FromBlob(WideChar* Blob, SizeT BlobSz) {
+ static MutableArray<GStylesheet> FromBlob(Char* Blob, SizeT BlobSz) {
MutableArray<GStylesheet> stylesheet;
if (!Blob || BlobSz < 1) return stylesheet;
for (auto BlobIndex = 0UL; BlobIndex < BlobSz; ++BlobIndex) {
+
}
return stylesheet;