summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-17 21:38:54 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-17 21:39:15 +0100
commita4bfc396a78ddd553de519ab927d8479d0c3c45d (patch)
tree6ff41607784ee4db226843c1aec6b06d4be5a779
parenta8366afaf39321ae2bbae70740f5ca65bee06769 (diff)
unrelated: See below.
Public: Kits: Implemented System API and the concept of object handles. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
-rw-r--r--.gitignore2
-rw-r--r--.vscode/c_cpp_properties.json4
-rw-r--r--.vscode/settings.json5
-rw-r--r--Private/NewBoot/Source/makefile2
-rw-r--r--Private/ObjectKit/Object.hxx18
-rw-r--r--Private/makefile2
-rw-r--r--Public/Kits/System.Core/Containers/XIFF.hxx4
-rw-r--r--Public/Kits/System.Core/Defs.hxx23
-rw-r--r--Public/Kits/System.Core/HCoreBase.hxx6
-rw-r--r--Public/Kits/System.Core/HCoreHeap.hxx10
-rw-r--r--Public/Kits/System.Core/HCoreHeap.s23
-rw-r--r--Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx27
-rw-r--r--Public/Kits/System.Core/Heap.cxx11
-rw-r--r--Public/Kits/System.Core/Heap.hxx6
-rw-r--r--Public/Kits/System.Core/Makefile12
-rw-r--r--Public/Kits/System.Graphics/Core.cxx2
-rw-r--r--Public/Kits/System.Graphics/Makefile8
-rw-r--r--Public/Kits/System.Zip/Makefile8
-rw-r--r--Public/Kits/System.Zip/NewFS-Addon.hpp20
-rw-r--r--Public/Kits/System.Zip/Shell.hpp17
-rw-r--r--Public/Kits/System.Zip/Zip.cxx19
-rw-r--r--Public/Kits/System.Zip/Zip.hpp13
22 files changed, 143 insertions, 99 deletions
diff --git a/.gitignore b/.gitignore
index ce3034d1..633f2770 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,6 +92,8 @@ local.properties
.loadpath
.recommenders
+.vscode/settings.json
+
# External tool builders
.externalToolBuilders/
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 549f3266..e2b440d3 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -1,7 +1,7 @@
{
"configurations": [
{
- "name": "HCore (Mac)",
+ "name": "HCore (Macintosh MinGW)",
"includePath": [
"${workspaceFolder}/Private/**",
"${workspaceFolder}/Private/NewBoot/**",
@@ -14,7 +14,7 @@
"intelliSenseMode": "gcc-x64"
},
{
- "name": "HCore (Win)",
+ "name": "HCore (Windows MinGW)",
"includePath": [
"${workspaceFolder}/Private/**",
"${workspaceFolder}/Private/NewBoot/**",
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 253de998..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "files.associations": {
- "*.rsrc": "cpp"
- }
-} \ No newline at end of file
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 511a4894..eaaac592 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -1,5 +1,5 @@
##################################################
-# ; (C) Mahrouss Logic, 2024, all rights reserved.
+# (C) Mahrouss Logic, 2024, all rights reserved.
# This is the bootloader makefile.
##################################################
diff --git a/Private/ObjectKit/Object.hxx b/Private/ObjectKit/Object.hxx
index af228163..9840a52e 100644
--- a/Private/ObjectKit/Object.hxx
+++ b/Private/ObjectKit/Object.hxx
@@ -12,17 +12,15 @@
#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\"
#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\"
-namespace HCore {
/// \brief Object handle.
typedef struct Object final {
- WideChar ObjectName[255];
- Int32 ObjectType;
- WideChar ObjectNamespace[255];
-
- Void(*Release)(struct Object* Self);
- Void(*Invoke)(struct Object* Self, Int32 Sel, ...);
- Void(*QueryInterface)(VoidPtr* Dst, SizeT SzDst, XRN::GUIDSequence GuidOf);
-} Ojbect, *ObjectPtr;
-} // namespace HCore
+ HCore::WideChar ObjectName[255];
+ HCore::Int32 ObjectType;
+ HCore::WideChar ObjectNamespace[255];
+
+ HCore::Void(*Release)(struct Object* Self);
+ HCore::IntPtr(*Invoke)(struct Object* Self, HCore::Int32 Sel, ...);
+ HCore::Void(*QueryInterface)(HCore::VoidPtr* Dst, HCore::SizeT SzDst, HCore::XRN::GUIDSequence GuidOf);
+} Object, *ObjectPtr;
#define object_cast reinterpret_cast
diff --git a/Private/makefile b/Private/makefile
index ebd9b595..1088e9b5 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -1,5 +1,5 @@
##################################################
-# ; (C) Mahrouss Logic, 2024, all rights reserved.
+# (C) Mahrouss Logic, 2024, all rights reserved.
# This is the microkernel makefile.
##################################################
diff --git a/Public/Kits/System.Core/Containers/XIFF.hxx b/Public/Kits/System.Core/Containers/XIFF.hxx
index 002d05f4..b9fa741e 100644
--- a/Public/Kits/System.Core/Containers/XIFF.hxx
+++ b/Public/Kits/System.Core/Containers/XIFF.hxx
@@ -35,8 +35,8 @@ typedef struct XiffHeader XiffHeader;
#define kXIFFContainerVideo "XVFF"
#define kXIFFContainerAudio "XAFF"
-#define kXIFFContainerInstaller "XnFF"
+#define kXIFFContainerInstaller "XNFF"
#define kXIFFContainerGeneric "XIFF"
-#define kXIFFContainerBinary "XEFF"
+#define kXIFFContainerBinary "XBFF"
#endif // ifndef __XIFF__
diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx
index 3ebe5c2c..ad615ef9 100644
--- a/Public/Kits/System.Core/Defs.hxx
+++ b/Public/Kits/System.Core/Defs.hxx
@@ -14,12 +14,10 @@
#undef CA_MUST_PASS
#endif
-#define CA_UNREFERENCED_PARAMETER(e) ((void)e)
-
-/// Assertion macros.
+#include <ObjectKit/Object.hxx>
#ifdef _DEBUG
-#define CA_MUST_PASS(e) __assert(e)
+#define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } }
#else
#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e)
#endif
@@ -34,6 +32,8 @@
#endif
+CA_EXTERN_C void __assert_chk_fail(void);
+
#define CA_STDCALL __attribute__((stdcall))
#define CA_CDECL __attribute__((cdecl))
#define CA_MSCALL __attribute__((ms_abi))
@@ -51,6 +51,8 @@ typedef void VOID;
typedef __WCHAR_TYPE__ WCHAR;
typedef WCHAR* PWCHAR;
+#define CA_UNREFERENCED_PARAMETER(e) ((VOID)e)
+
#ifdef __x86_64__
# define _M_AMD64 2
#endif
@@ -75,3 +77,16 @@ typedef WCHAR* PWCHAR;
#else
#define CA_CONSTEXPR
#endif // __cplusplus
+
+CA_INLINE ObjectPtr kInstanceObject;
+
+enum {
+ kProcessHeapCallAlloc = 1,
+ kProcessHeapCallFree,
+ kProcessHeapCallSize,
+ kProcessHeapCallCheck,
+ kProcessHeapCallAllocStack,
+ kProcessHeapCallOpenHandle,
+ kProcessHeapCallCloseHandle,
+ kProcessHeapCallsCnt,
+};
diff --git a/Public/Kits/System.Core/HCoreBase.hxx b/Public/Kits/System.Core/HCoreBase.hxx
index 5bb6f9af..774f9883 100644
--- a/Public/Kits/System.Core/HCoreBase.hxx
+++ b/Public/Kits/System.Core/HCoreBase.hxx
@@ -5,9 +5,3 @@
#pragma once
#include <System.Core/Defs.hxx>
-
-typedef struct HcObject {
- void(*Release)(void);
- void(*Invoke)(void);
- void(*QueryInterface)(void);
-} *HcObjectPtr;
diff --git a/Public/Kits/System.Core/HCoreHeap.hxx b/Public/Kits/System.Core/HCoreHeap.hxx
index 88cbbeb7..0c6eb1dc 100644
--- a/Public/Kits/System.Core/HCoreHeap.hxx
+++ b/Public/Kits/System.Core/HCoreHeap.hxx
@@ -6,8 +6,8 @@
#include <System.Core/HCoreBase.hxx>
-CA_EXTERN_C HcObjectPtr HcGetProcessHeap(void);
-CA_EXTERN_C void* HcAllocateProcessHeap(HcObjectPtr refObj, long long int sz, int flags);
-CA_EXTERN_C void HcFreeProcessHeap(HcObjectPtr refObj, void* ptr);
-CA_EXTERN_C long long int HcProcessHeapSize(HcObjectPtr refObj, void* ptr);
-CA_EXTERN_C long long int HcProcessHeapExists(HcObjectPtr refObj, void* ptr);
+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);
diff --git a/Public/Kits/System.Core/HCoreHeap.s b/Public/Kits/System.Core/HCoreHeap.s
new file mode 100644
index 00000000..108c6fcf
--- /dev/null
+++ b/Public/Kits/System.Core/HCoreHeap.s
@@ -0,0 +1,23 @@
+/** ===========================================
+ (C) Mahrouss Logic
+ ===========================================*/
+
+.section .text
+
+.globl HcGetProcessObject
+.globl __assert_chk_fail
+
+/* Process Heap getter */
+HcGetProcessObject:
+ mov $0x1, %rcx /* sysGetProcessObject */
+ int $0x21
+
+ /* rax gets saved and returned. */
+ ret
+
+__assert_chk_fail:
+ mov $0x2, %rcx /* sysTerminateCurrentProcess */
+ int $0x21
+
+ ret
+
diff --git a/Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx b/Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx
new file mode 100644
index 00000000..86b2bf47
--- /dev/null
+++ b/Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx
@@ -0,0 +1,27 @@
+/** ===========================================
+ (C) Mahrouss Logic
+ ===========================================*/
+
+#include <System.Core/HCoreHeap.hxx>
+
+CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags)
+{
+ return (PVOID)refObj->Invoke(refObj, kProcessHeapCallAlloc, sz, flags);
+}
+
+CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr)
+{
+ CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessHeapCallFree, ptr));
+}
+
+CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr)
+{
+ return refObj->Invoke(refObj, kProcessHeapCallSize, ptr);
+}
+
+CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr)
+{
+ return refObj->Invoke(refObj, kProcessHeapCallCheck, ptr);
+}
+
+// eof.
diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap.cxx
index c7401aad..56188e95 100644
--- a/Public/Kits/System.Core/Heap.cxx
+++ b/Public/Kits/System.Core/Heap.cxx
@@ -7,32 +7,29 @@
#include <System.Core/Heap.hxx>
#include <System.Core/System.Core.hxx>
-using namespace HCore;
using namespace System;
-STATIC HcObjectPtr kObjectHeap;
-
Heap* Heap::Shared() noexcept {
static Heap* heap = nullptr;
if (!heap) {
heap = new Heap();
- kObjectHeap = HcGetProcessHeap();
+ kInstanceObject = HcGetProcessObject();
}
return heap;
}
-void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); }
+void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kInstanceObject, me); }
SizeT Heap::Size(HeapPtr me) noexcept {
CA_MUST_PASS(me);
- return HcProcessHeapSize(kObjectHeap, me);
+ return HcProcessHeapSize(kInstanceObject, me);
}
HeapPtr Heap::New(const SizeT &sz, const Int32 flags) {
SizeT _sz = sz;
if (!_sz) ++_sz;
- return HcAllocateProcessHeap(kObjectHeap, _sz, flags);
+ 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 292a1227..dfcb4587 100644
--- a/Public/Kits/System.Core/Heap.hxx
+++ b/Public/Kits/System.Core/Heap.hxx
@@ -10,6 +10,8 @@
#include <CompilerKit/CompilerKit.hxx>
namespace System {
+using namespace HCore;
+
class MemoryException;
typedef PVOID HeapPtr;
@@ -24,10 +26,10 @@ enum {
class Heap final {
private:
- explicit Heap();
+ explicit Heap() = default;
public:
- ~Heap();
+ ~Heap() = default;
public:
HCORE_COPY_DEFAULT(Heap);
diff --git a/Public/Kits/System.Core/Makefile b/Public/Kits/System.Core/Makefile
index d710b2e8..f358dfa5 100644
--- a/Public/Kits/System.Core/Makefile
+++ b/Public/Kits/System.Core/Makefile
@@ -1,18 +1,18 @@
##################################################
-# ; (C) Mahrouss Logic, 2024, all rights reserved.
+# (C) Mahrouss Logic, 2024, all rights reserved.
# This is the System.Graphics Makefile.
##################################################
CC=x86_64-w64-mingw32-g++
-CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20
+CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
OUTPUT=System.Core.dll
-.PHONY: build-gkit
-build-gkit:
- $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) *.cxx -o $(OUTPUT)
+.PHONY: build-core
+build-core:
+ $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard *.cxx) $(wildcard *.s) -o $(OUTPUT)
.PHONY: all
-all: build-gkit
+all: build-core
@echo "[System.Core.dll] Build done."
.PHONY: clean
diff --git a/Public/Kits/System.Graphics/Core.cxx b/Public/Kits/System.Graphics/Core.cxx
index 9a218f88..9a4ef7a7 100644
--- a/Public/Kits/System.Graphics/Core.cxx
+++ b/Public/Kits/System.Graphics/Core.cxx
@@ -2,7 +2,7 @@
Copyright Mahrouss Logic
- File: Core.cpp
+ File: Core.cxx
Purpose:
Revision History:
diff --git a/Public/Kits/System.Graphics/Makefile b/Public/Kits/System.Graphics/Makefile
index c049857f..1530f699 100644
--- a/Public/Kits/System.Graphics/Makefile
+++ b/Public/Kits/System.Graphics/Makefile
@@ -1,5 +1,5 @@
##################################################
-# ; (C) Mahrouss Logic, 2024, all rights reserved.
+# (C) Mahrouss Logic, 2024, all rights reserved.
# This is the System.Graphics Makefile.
##################################################
@@ -7,12 +7,12 @@ CC=x86_64-w64-mingw32-g++
CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20
OUTPUT=System.Graphics.dll
-.PHONY: build-gkit
-build-gkit:
+.PHONY: build-gfx
+build-gfx:
$(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) *.cxx -o $(OUTPUT)
.PHONY: all
-all: build-gkit
+all: build-gfx
@echo "[System.Graphics.dll] Build done."
.PHONY: clean
diff --git a/Public/Kits/System.Zip/Makefile b/Public/Kits/System.Zip/Makefile
index 4423d876..22dcd108 100644
--- a/Public/Kits/System.Zip/Makefile
+++ b/Public/Kits/System.Zip/Makefile
@@ -1,5 +1,5 @@
##################################################
-# ; (C) Mahrouss Logic, 2024, all rights reserved.
+# (C) Mahrouss Logic, 2024, all rights reserved.
# This is the System.Zip Makefile.
##################################################
@@ -9,12 +9,12 @@ ASM=nasm
ASMFLAGS=-f elf64
OUTPUT=System.Zip.dll
-.PHONY: build-zipkit
-build-zipkit:
+.PHONY: build-zip
+build-zip:
$(CC) -I../ -I../../../Private/ $(CCFLAGS) *.cxx -o $(OUTPUT)
.PHONY: all
-all: build-zipkit
+all: build-zip
@echo "[System.Zip.dll] Done."
.PHONY: clean
diff --git a/Public/Kits/System.Zip/NewFS-Addon.hpp b/Public/Kits/System.Zip/NewFS-Addon.hpp
deleted file mode 100644
index 1018bd22..00000000
--- a/Public/Kits/System.Zip/NewFS-Addon.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
-
-#pragma once
-
-/// TODO: integrate NewFS compression.
-
-/// @brief NewFS catalog is compressed.
-#define kNewFSIsZip 255
-
-/// @brief NewFS catalog has password attached to it.
-#define kNewFSHasPassword 256
-
-class ShellInterface;
diff --git a/Public/Kits/System.Zip/Shell.hpp b/Public/Kits/System.Zip/Shell.hpp
new file mode 100644
index 00000000..19de8f07
--- /dev/null
+++ b/Public/Kits/System.Zip/Shell.hpp
@@ -0,0 +1,17 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+/// TODO: integrate compression into the shell.
+
+/// @brief NewFS catalog is compressed.
+#define kNewFSIsZip 255
+
+/// @brief NewFS catalog has password attached to it.
+#define kNewFSHasPassword 256
+
+class ShellInterface;
diff --git a/Public/Kits/System.Zip/Zip.cxx b/Public/Kits/System.Zip/Zip.cxx
index 1e4a28cb..8fb7668d 100644
--- a/Public/Kits/System.Zip/Zip.cxx
+++ b/Public/Kits/System.Zip/Zip.cxx
@@ -1,21 +1,18 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
#include <System.Zip/Zip.hpp>
#include <System.Core/Defs.hxx>
-#define kInitialSz 4096
+#define kZipInitialSize 4096
namespace System::Zip {
ZipStream::ZipStream()
- : fSharedData(System::Heap::Shared()->New(kInitialSz, kHeapExpandable)),
- fSharedSz(kInitialSz) {}
+ : fSharedData(System::Heap::Shared()->New(kZipInitialSize, kHeapExpandable)),
+ fSharedSz(kZipInitialSize) {}
ZipStream::~ZipStream() noexcept {
if (fSharedData) System::Heap::Shared()->Delete(fSharedData);
diff --git a/Public/Kits/System.Zip/Zip.hpp b/Public/Kits/System.Zip/Zip.hpp
index 7affe917..35d7da3a 100644
--- a/Public/Kits/System.Zip/Zip.hpp
+++ b/Public/Kits/System.Zip/Zip.hpp
@@ -1,11 +1,8 @@
-/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
#pragma once