From 55059428bfd6a18451bc1ed3ee64e7bb04c395cd Mon Sep 17 00:00:00 2001 From: amlal Date: Sat, 16 Mar 2024 14:22:21 +0100 Subject: HCR-14: See below. - Pretty big modifications, add kernel mouse. Signed-off-by: amlal --- Public/Kits/System.Core/Containers/XIFF.hxx | 2 +- Public/Kits/System.Core/CoreAPI.hxx | 56 --------------------- Public/Kits/System.Core/Defs.hxx | 77 +++++++++++++++++++++++++++++ Public/Kits/System.Core/File.hxx | 42 ++++++++++++++++ Public/Kits/System.Core/FileAPI.hxx | 42 ---------------- Public/Kits/System.Core/HCoreBase.hxx | 2 +- Public/Kits/System.Core/Heap.cxx | 38 ++++++++++++++ Public/Kits/System.Core/Heap.hxx | 62 +++++++++++++++++++++++ Public/Kits/System.Core/HeapAPI.cxx | 38 -------------- Public/Kits/System.Core/HeapAPI.hxx | 66 ------------------------- Public/Kits/System.Core/System.Core.hxx | 15 ++++++ Public/Kits/System.Core/System.hxx | 6 +-- Public/Kits/System.Core/hcore.h | 15 ------ 13 files changed, 239 insertions(+), 222 deletions(-) delete mode 100644 Public/Kits/System.Core/CoreAPI.hxx create mode 100644 Public/Kits/System.Core/Defs.hxx create mode 100644 Public/Kits/System.Core/File.hxx delete mode 100644 Public/Kits/System.Core/FileAPI.hxx create mode 100644 Public/Kits/System.Core/Heap.cxx create mode 100644 Public/Kits/System.Core/Heap.hxx delete mode 100644 Public/Kits/System.Core/HeapAPI.cxx delete mode 100644 Public/Kits/System.Core/HeapAPI.hxx create mode 100644 Public/Kits/System.Core/System.Core.hxx delete mode 100644 Public/Kits/System.Core/hcore.h (limited to 'Public/Kits/System.Core') diff --git a/Public/Kits/System.Core/Containers/XIFF.hxx b/Public/Kits/System.Core/Containers/XIFF.hxx index dbfe5b04..002d05f4 100644 --- a/Public/Kits/System.Core/Containers/XIFF.hxx +++ b/Public/Kits/System.Core/Containers/XIFF.hxx @@ -12,7 +12,7 @@ ------------------------------------------------------- */ -#include +#include /// @brief four-character code for XIFF. #define kFourCCLength_XIFF 4 diff --git a/Public/Kits/System.Core/CoreAPI.hxx b/Public/Kits/System.Core/CoreAPI.hxx deleted file mode 100644 index 66d356d7..00000000 --- a/Public/Kits/System.Core/CoreAPI.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#ifndef __cplusplus -#error This API is meant to be used with C++ -#endif - -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS -#endif - -// unused by user side, it's a kernel thing. -#define CA_MUST_PASS(e) ((void)e) - -#define CA_EXTERN_C extern "C" - -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) - -#define CA_PASCALL CA_STDCALL - -typedef __UINT8_TYPE__ BYTE; -typedef __UINT16_TYPE__ WORD; -typedef __UINT32_TYPE__ DWORD; -typedef __UINT64_TYPE__ QWORD; - -typedef void* PVOID; -typedef void VOID; - -typedef __WCHAR_TYPE__ WCHAR; -typedef WCHAR* PWCHAR; - -#ifdef __x86_64__ -# define _M_AMD64 2 -#endif - -#ifdef __aarch64__ -# define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -# define _M_PPC64 4 -#endif - -#ifdef __64x0__ -# define _M_64000 5 -#endif - -#define CA_STATIC static -#define CA_INLINE inline \ No newline at end of file diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx new file mode 100644 index 00000000..3ebe5c2c --- /dev/null +++ b/Public/Kits/System.Core/Defs.hxx @@ -0,0 +1,77 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#ifndef __cplusplus +#error This API is meant to be used with C++ +#endif + +#ifdef CA_MUST_PASS +#undef CA_MUST_PASS +#endif + +#define CA_UNREFERENCED_PARAMETER(e) ((void)e) + +/// Assertion macros. + +#ifdef _DEBUG +#define CA_MUST_PASS(e) __assert(e) +#else +#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) +#endif + +#ifdef __cplusplus + +#define CA_EXTERN_C extern "C" + +#else + +#define CA_EXTERN_C extern + +#endif + +#define CA_STDCALL __attribute__((stdcall)) +#define CA_CDECL __attribute__((cdecl)) +#define CA_MSCALL __attribute__((ms_abi)) + +#define CA_PASCALL CA_STDCALL + +typedef __UINT8_TYPE__ BYTE; +typedef __UINT16_TYPE__ WORD; +typedef __UINT32_TYPE__ DWORD; +typedef __UINT64_TYPE__ QWORD; + +typedef void* PVOID; +typedef void VOID; + +typedef __WCHAR_TYPE__ WCHAR; +typedef WCHAR* PWCHAR; + +#ifdef __x86_64__ +# define _M_AMD64 2 +#endif + +#ifdef __aarch64__ +# define _M_AARCH64 3 +#endif + +#ifdef __powerpc64__ +# define _M_PPC64 4 +#endif + +#ifdef __64x0__ +# define _M_64000 5 +#endif + +#define CA_STATIC static +#define CA_INLINE inline + +#ifdef __cplusplus +#define CA_CONSTEXPR constexpr +#else +#define CA_CONSTEXPR +#endif // __cplusplus diff --git a/Public/Kits/System.Core/File.hxx b/Public/Kits/System.Core/File.hxx new file mode 100644 index 00000000..2f799330 --- /dev/null +++ b/Public/Kits/System.Core/File.hxx @@ -0,0 +1,42 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#ifndef _SYSTEM_KIT_HCORE_FILE_HPP +#define _SYSTEM_KIT_HCORE_FILE_HPP + +#include +#include + +using namespace HCore; + +/// @brief SOM class, translated to C++ + +namespace System { +class File final { + public: + explicit File(const char *path); + ~File(); + + public: + HCORE_COPY_DEFAULT(File); + + public: + voidPtr Read(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 Rewind(); + + public: + const char *MIME(); + void MIME(const char *mime); +}; + +typedef File *FilePtr; +} // namespace System + +#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP diff --git a/Public/Kits/System.Core/FileAPI.hxx b/Public/Kits/System.Core/FileAPI.hxx deleted file mode 100644 index 2f799330..00000000 --- a/Public/Kits/System.Core/FileAPI.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef _SYSTEM_KIT_HCORE_FILE_HPP -#define _SYSTEM_KIT_HCORE_FILE_HPP - -#include -#include - -using namespace HCore; - -/// @brief SOM class, translated to C++ - -namespace System { -class File final { - public: - explicit File(const char *path); - ~File(); - - public: - HCORE_COPY_DEFAULT(File); - - public: - voidPtr Read(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 Rewind(); - - public: - const char *MIME(); - void MIME(const char *mime); -}; - -typedef File *FilePtr; -} // namespace System - -#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP diff --git a/Public/Kits/System.Core/HCoreBase.hxx b/Public/Kits/System.Core/HCoreBase.hxx index c8a3a99c..5bb6f9af 100644 --- a/Public/Kits/System.Core/HCoreBase.hxx +++ b/Public/Kits/System.Core/HCoreBase.hxx @@ -4,7 +4,7 @@ #pragma once -#include +#include typedef struct HcObject { void(*Release)(void); diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap.cxx new file mode 100644 index 00000000..c7401aad --- /dev/null +++ b/Public/Kits/System.Core/Heap.cxx @@ -0,0 +1,38 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include +#include + +using namespace HCore; +using namespace System; + +STATIC HcObjectPtr kObjectHeap; + +Heap* Heap::Shared() noexcept { + static Heap* heap = nullptr; + + if (!heap) { + heap = new Heap(); + kObjectHeap = HcGetProcessHeap(); + } + + return heap; +} + +void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); } + +SizeT Heap::Size(HeapPtr me) noexcept { + CA_MUST_PASS(me); + return HcProcessHeapSize(kObjectHeap, me); +} + +HeapPtr Heap::New(const SizeT &sz, const Int32 flags) { + SizeT _sz = sz; + if (!_sz) ++_sz; + + return HcAllocateProcessHeap(kObjectHeap, _sz, flags); +} \ No newline at end of file diff --git a/Public/Kits/System.Core/Heap.hxx b/Public/Kits/System.Core/Heap.hxx new file mode 100644 index 00000000..292a1227 --- /dev/null +++ b/Public/Kits/System.Core/Heap.hxx @@ -0,0 +1,62 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include + +namespace System { +class MemoryException; + +typedef PVOID HeapPtr; + +enum { + kHeapExpandable = 2, + kHeapNoExecute = 4, + kHeapShared = 6, + kHeapReadOnly = 8, + kHeapNoFlags = 0 +}; + +class Heap final { + private: + explicit Heap(); + + public: + ~Heap(); + + public: + HCORE_COPY_DEFAULT(Heap); + + public: + static Heap *Shared() noexcept; + + public: + void Delete(HeapPtr me) noexcept; + 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/HeapAPI.cxx b/Public/Kits/System.Core/HeapAPI.cxx deleted file mode 100644 index 232b4927..00000000 --- a/Public/Kits/System.Core/HeapAPI.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include -#include - -using namespace HCore; -using namespace System; - -STATIC HcObjectPtr kObjectHeap; - -Heap* Heap::Shared() noexcept { - static Heap* heap = nullptr; - - if (!heap) { - heap = new Heap(); - kObjectHeap = HcGetProcessHeap(); - } - - return heap; -} - -void Heap::Delete(HeapPtr me) noexcept { HcFreeProcessHeap(kObjectHeap, me); } - -SizeT Heap::Size(HeapPtr me) noexcept { - CA_MUST_PASS(me); - return HcProcessHeapSize(kObjectHeap, me); -} - -HeapPtr Heap::New(const SizeT &sz, const Int32 flags) { - SizeT _sz = sz; - if (!_sz) ++_sz; - - return HcAllocateProcessHeap(kObjectHeap, _sz, flags); -} \ No newline at end of file diff --git a/Public/Kits/System.Core/HeapAPI.hxx b/Public/Kits/System.Core/HeapAPI.hxx deleted file mode 100644 index f50ff6f7..00000000 --- a/Public/Kits/System.Core/HeapAPI.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include -#include - -/// @brief SOM class, translated to C++ - -using namespace HCore; - -namespace System { -class MemoryException; - -typedef VoidPtr HeapPtr; - -enum { - kHeapExpandable = 2, - kHeapNoExecute = 4, - kHeapShared = 6, - kHeapReadOnly = 8, - kHeapNoFlags = 0 -}; - -class Heap final { - private: - explicit Heap(); - - public: - ~Heap(); - - public: - HCORE_COPY_DEFAULT(Heap); - - public: - static Heap *Shared() noexcept; - - public: - void Delete(HeapPtr me) noexcept; - 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{"HeapAPI: Memory Exception!"}; - - private: - friend Heap; -}; -} // namespace System \ No newline at end of file diff --git a/Public/Kits/System.Core/System.Core.hxx b/Public/Kits/System.Core/System.Core.hxx new file mode 100644 index 00000000..b368b997 --- /dev/null +++ b/Public/Kits/System.Core/System.Core.hxx @@ -0,0 +1,15 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#pragma once + +/// Core API +#include + +/// Process Heap API +#include + +/// File API & Device API. + +/// Process & Threading API \ No newline at end of file diff --git a/Public/Kits/System.Core/System.hxx b/Public/Kits/System.Core/System.hxx index 97d4bdac..37cab4a4 100644 --- a/Public/Kits/System.Core/System.hxx +++ b/Public/Kits/System.Core/System.hxx @@ -10,9 +10,9 @@ ------------------------------------------------------- */ -#include -#include -#include +#include +#include +#include #include using namespace HCore; diff --git a/Public/Kits/System.Core/hcore.h b/Public/Kits/System.Core/hcore.h deleted file mode 100644 index b368b997..00000000 --- a/Public/Kits/System.Core/hcore.h +++ /dev/null @@ -1,15 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#pragma once - -/// Core API -#include - -/// Process Heap API -#include - -/// File API & Device API. - -/// Process & Threading API \ No newline at end of file -- cgit v1.2.3