From be29b406526c931a606d4d4de545f71e62bc893a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 25 Mar 2024 16:43:00 +0100 Subject: Kernel: A lot of preliminary changes before AHCI and SMP support. --- Public/SDK/System.Core/Headers/Containers/ODF.hxx | 43 ---------------------- Public/SDK/System.Core/Headers/Containers/XIFF.hxx | 42 --------------------- Public/SDK/System.Core/Headers/Defines.hxx | 2 +- Public/SDK/System.Core/Headers/File.hxx | 18 ++++----- .../SDK/System.Core/Headers/FormatManager/ODF.hxx | 41 +++++++++++++++++++++ .../SDK/System.Core/Headers/FormatManager/XIFF.hxx | 42 +++++++++++++++++++++ Public/SDK/System.Core/Headers/Heap.hxx | 15 +++++++- Public/SDK/System.Core/Headers/UI/.gitkeep | 0 Public/SDK/System.Core/Headers/UI/Dialog.hxx | 8 ---- Public/SDK/System.Core/Headers/UI/Imaging.hxx | 8 ---- Public/SDK/System.Core/Headers/UI/Menu.hxx | 8 ---- Public/SDK/System.Core/Headers/UI/Rsrc.hxx | 8 ---- Public/SDK/System.Core/Headers/UI/Window.hxx | 8 ---- .../SDK/System.Core/Headers/UIManager/Dialog.hxx | 8 ++++ Public/SDK/System.Core/Headers/UIManager/Image.hxx | 8 ++++ Public/SDK/System.Core/Headers/UIManager/Menu.hxx | 8 ++++ Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx | 8 ++++ .../SDK/System.Core/Headers/UIManager/TrueType.hxx | 7 ++++ .../SDK/System.Core/Headers/UIManager/Window.hxx | 8 ++++ Public/SDK/System.Core/Sources/DllMain.cxx | 14 ------- Public/SDK/System.Core/Sources/Heap.cxx | 8 ++-- Public/SDK/System.Core/Sources/LibEntrypoint.cxx | 14 +++++++ Public/SDK/System.Core/Sources/New+Delete.cxx | 24 +++--------- 23 files changed, 178 insertions(+), 172 deletions(-) delete mode 100644 Public/SDK/System.Core/Headers/Containers/ODF.hxx delete mode 100644 Public/SDK/System.Core/Headers/Containers/XIFF.hxx create mode 100644 Public/SDK/System.Core/Headers/FormatManager/ODF.hxx create mode 100644 Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx delete mode 100644 Public/SDK/System.Core/Headers/UI/.gitkeep delete mode 100644 Public/SDK/System.Core/Headers/UI/Dialog.hxx delete mode 100644 Public/SDK/System.Core/Headers/UI/Imaging.hxx delete mode 100644 Public/SDK/System.Core/Headers/UI/Menu.hxx delete mode 100644 Public/SDK/System.Core/Headers/UI/Rsrc.hxx delete mode 100644 Public/SDK/System.Core/Headers/UI/Window.hxx create mode 100644 Public/SDK/System.Core/Headers/UIManager/Dialog.hxx create mode 100644 Public/SDK/System.Core/Headers/UIManager/Image.hxx create mode 100644 Public/SDK/System.Core/Headers/UIManager/Menu.hxx create mode 100644 Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx create mode 100644 Public/SDK/System.Core/Headers/UIManager/TrueType.hxx create mode 100644 Public/SDK/System.Core/Headers/UIManager/Window.hxx delete mode 100644 Public/SDK/System.Core/Sources/DllMain.cxx create mode 100644 Public/SDK/System.Core/Sources/LibEntrypoint.cxx (limited to 'Public/SDK/System.Core') diff --git a/Public/SDK/System.Core/Headers/Containers/ODF.hxx b/Public/SDK/System.Core/Headers/Containers/ODF.hxx deleted file mode 100644 index e0cb0bc1..00000000 --- a/Public/SDK/System.Core/Headers/Containers/ODF.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __ODF__ -#define __ODF__ - -#include - -/** - * @brief Open Document Format - * @file ODF.hxx -*/ - -/// @brief four-character code for ODF. -#define kFourCCLength_ODF 4 - -/// @brief Document file header. -typedef struct ODFFileHeader -{ - CharacterTypeUTF8 f_Ident[kFourCCLength_ODF]; - - Int32Type f_DocumentKind; - Int32Type f_DocumentSize; - - Int64Type f_MetaForkOffset; - Int64Type f_DocumentForkOffset; - - CharacterTypeUTF8 f_Padding[4]; -} PACKED ODFFileHeader; - -/// @brief ODF Fork header -typedef struct ODFForkHeader -{ - CharacterTypeUTF8 f_MetadataName[255]; - - Int32Type f_MetadataKind; - Int32Type f_MetadataSize; - - CharacterTypeUTF8 f_Padding; -} PACKED ODFForkHeader; - -#endif // !__ODF__ \ No newline at end of file diff --git a/Public/SDK/System.Core/Headers/Containers/XIFF.hxx b/Public/SDK/System.Core/Headers/Containers/XIFF.hxx deleted file mode 100644 index 2531abce..00000000 --- a/Public/SDK/System.Core/Headers/Containers/XIFF.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __XIFF__ -#define __XIFF__ - -/** --------------------------------------------------- - - * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format. - * XIFF is used to make setup programs/audio/video files. - -------------------------------------------------------- */ - -#include - -/// @brief four-character code for XIFF. -#define kFourCCLength_XIFF 4 - -#define kXIFFContainerVideo "XVFF" -#define kXIFFContainerAudio "XAFF" -#define kXIFFContainerInstaller "XNFF" -#define kXIFFContainerGeneric "XIFF" -#define kXIFFContainerBinary "XBFF" - -/*** - * @brief Generic XIFF header - * Used by XIFF based containers. - */ - -struct PACKED XiffHeader final { - ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) - DWordType f_Size; // overall size of header (XiffHeader) in bytes - DWordType f_FormatType; // format type. generic - ByteType f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic - DWordType f_SpecificSize; // length of the format data - DWordType f_SpecificFormatType; // format type. generic -}; - -typedef struct XiffHeader XiffHeader; - -#endif // ifndef __XIFF__ diff --git a/Public/SDK/System.Core/Headers/Defines.hxx b/Public/SDK/System.Core/Headers/Defines.hxx index 3cbf22fd..867dac76 100644 --- a/Public/SDK/System.Core/Headers/Defines.hxx +++ b/Public/SDK/System.Core/Headers/Defines.hxx @@ -247,4 +247,4 @@ typedef struct Object final { CA_EXTERN_C ObjectPtr HcGetInstanceObject(void); -CA_INLINE ObjectPtr kInstanceObject; +CA_INLINE ObjectPtr kApplicationObject; diff --git a/Public/SDK/System.Core/Headers/File.hxx b/Public/SDK/System.Core/Headers/File.hxx index f8efd75a..60c37cc6 100644 --- a/Public/SDK/System.Core/Headers/File.hxx +++ b/Public/SDK/System.Core/Headers/File.hxx @@ -29,12 +29,12 @@ enum { class FileInterface final { public: explicit FileInterface(const char *path) { - mHandle = kInstanceObject->Invoke(kInstanceObject, kProcessCallOpenHandle, + mHandle = kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, 0, path); } ~FileInterface() { - kInstanceObject->Invoke(kInstanceObject, kProcessCallCloseHandle, 0, + kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle, 0, mHandle); } @@ -43,25 +43,25 @@ class FileInterface final { public: PtrVoidType Read(UIntPtrType off, SizeType sz) { - return (PtrVoidType)kInstanceObject->Invoke(kInstanceObject, mHandle, 2, + return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 2, off, sz); } PtrVoidType Read(SizeType sz) { - return (PtrVoidType)kInstanceObject->Invoke(kInstanceObject, mHandle, 3, + return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 3, sz); } void Write(PtrVoidType buf, UIntPtrType off, SizeType sz) { - kInstanceObject->Invoke(kInstanceObject, mHandle, 4, buf, off, sz); + kApplicationObject->Invoke(kApplicationObject, mHandle, 4, buf, off, sz); } void Write(PtrVoidType buf, SizeType sz) { - kInstanceObject->Invoke(kInstanceObject, mHandle, 5, buf, sz); + kApplicationObject->Invoke(kApplicationObject, mHandle, 5, buf, sz); } void Seek(UIntPtrType off) { - kInstanceObject->Invoke(kInstanceObject, mHandle, 5); + kApplicationObject->Invoke(kApplicationObject, mHandle, 5); } - void Rewind() { kInstanceObject->Invoke(kInstanceObject, mHandle, 6); } + void Rewind() { kApplicationObject->Invoke(kApplicationObject, mHandle, 6); } public: const char *MIME(); @@ -95,7 +95,7 @@ inline IntPtrType MakeSymlink(const char *from, const char *outputWhere) { CA_MUST_PASS(from); CA_MUST_PASS(outputWhere); - return kInstanceObject->Invoke(kInstanceObject, kProcessCallOpenHandle, 1, + return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, 1, from); } } // namespace System diff --git a/Public/SDK/System.Core/Headers/FormatManager/ODF.hxx b/Public/SDK/System.Core/Headers/FormatManager/ODF.hxx new file mode 100644 index 00000000..266726bf --- /dev/null +++ b/Public/SDK/System.Core/Headers/FormatManager/ODF.hxx @@ -0,0 +1,41 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#ifndef __ODF__ +#define __ODF__ + +#include + +/** + * @brief Open Document Format + * @file ODF.hxx + */ + +/// @brief four-character code for ODF. +#define kFourCCLength_ODF 4 + +/// @brief Document file header. +typedef struct ODFFileHeader { + CharacterTypeUTF8 f_Ident[kFourCCLength_ODF]; + + Int32Type f_DocumentKind; + Int32Type f_DocumentSize; + + Int64Type f_MetaForkOffset; + Int64Type f_DocumentForkOffset; + + CharacterTypeUTF8 f_Padding[4]; +} PACKED ODFFileHeader; + +/// @brief ODF Fork header +typedef struct ODFForkHeader { + CharacterTypeUTF8 f_MetadataName[255]; + + Int32Type f_MetadataKind; + Int32Type f_MetadataSize; + + CharacterTypeUTF8 f_Padding; +} PACKED ODFForkHeader; + +#endif // !__ODF__ \ No newline at end of file diff --git a/Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx b/Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx new file mode 100644 index 00000000..2531abce --- /dev/null +++ b/Public/SDK/System.Core/Headers/FormatManager/XIFF.hxx @@ -0,0 +1,42 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#ifndef __XIFF__ +#define __XIFF__ + +/** --------------------------------------------------- + + * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format. + * XIFF is used to make setup programs/audio/video files. + +------------------------------------------------------- */ + +#include + +/// @brief four-character code for XIFF. +#define kFourCCLength_XIFF 4 + +#define kXIFFContainerVideo "XVFF" +#define kXIFFContainerAudio "XAFF" +#define kXIFFContainerInstaller "XNFF" +#define kXIFFContainerGeneric "XIFF" +#define kXIFFContainerBinary "XBFF" + +/*** + * @brief Generic XIFF header + * Used by XIFF based containers. + */ + +struct PACKED XiffHeader final { + ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) + DWordType f_Size; // overall size of header (XiffHeader) in bytes + DWordType f_FormatType; // format type. generic + ByteType f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic + DWordType f_SpecificSize; // length of the format data + DWordType f_SpecificFormatType; // format type. generic +}; + +typedef struct XiffHeader XiffHeader; + +#endif // ifndef __XIFF__ diff --git a/Public/SDK/System.Core/Headers/Heap.hxx b/Public/SDK/System.Core/Headers/Heap.hxx index 0d7103c5..06f5d38e 100644 --- a/Public/SDK/System.Core/Headers/Heap.hxx +++ b/Public/SDK/System.Core/Headers/Heap.hxx @@ -61,4 +61,17 @@ class HeapException : public SystemException { const char *mReason{"System.Core: HeapException: Catastrophic failure!"}; }; -} // namespace System \ No newline at end of file +} // namespace System + +#define kAllocationTypes 2 + +enum HcAllocationKind { + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, +}; + +CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, + DWordType flags); +CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr); +CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr); +CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr); \ No newline at end of file diff --git a/Public/SDK/System.Core/Headers/UI/.gitkeep b/Public/SDK/System.Core/Headers/UI/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/SDK/System.Core/Headers/UI/Dialog.hxx b/Public/SDK/System.Core/Headers/UI/Dialog.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UI/Dialog.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UI/Imaging.hxx b/Public/SDK/System.Core/Headers/UI/Imaging.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UI/Imaging.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UI/Menu.hxx b/Public/SDK/System.Core/Headers/UI/Menu.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UI/Menu.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UI/Rsrc.hxx b/Public/SDK/System.Core/Headers/UI/Rsrc.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UI/Rsrc.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UI/Window.hxx b/Public/SDK/System.Core/Headers/UI/Window.hxx deleted file mode 100644 index 2a02b434..00000000 --- a/Public/SDK/System.Core/Headers/UI/Window.hxx +++ /dev/null @@ -1,8 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - diff --git a/Public/SDK/System.Core/Headers/UIManager/Dialog.hxx b/Public/SDK/System.Core/Headers/UIManager/Dialog.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/SDK/System.Core/Headers/UIManager/Dialog.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/SDK/System.Core/Headers/UIManager/Image.hxx b/Public/SDK/System.Core/Headers/UIManager/Image.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/SDK/System.Core/Headers/UIManager/Image.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/SDK/System.Core/Headers/UIManager/Menu.hxx b/Public/SDK/System.Core/Headers/UIManager/Menu.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/SDK/System.Core/Headers/UIManager/Menu.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx b/Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/SDK/System.Core/Headers/UIManager/Rsrc.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/SDK/System.Core/Headers/UIManager/TrueType.hxx b/Public/SDK/System.Core/Headers/UIManager/TrueType.hxx new file mode 100644 index 00000000..62ed1255 --- /dev/null +++ b/Public/SDK/System.Core/Headers/UIManager/TrueType.hxx @@ -0,0 +1,7 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once diff --git a/Public/SDK/System.Core/Headers/UIManager/Window.hxx b/Public/SDK/System.Core/Headers/UIManager/Window.hxx new file mode 100644 index 00000000..2a02b434 --- /dev/null +++ b/Public/SDK/System.Core/Headers/UIManager/Window.hxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + diff --git a/Public/SDK/System.Core/Sources/DllMain.cxx b/Public/SDK/System.Core/Sources/DllMain.cxx deleted file mode 100644 index 9412cbbb..00000000 --- a/Public/SDK/System.Core/Sources/DllMain.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include - -/// @brief Inits the DLL. -/// @return if it was succesful or not. -DWordType __DllMain(VoidType) { - kInstanceObject = HcGetInstanceObject(); - CA_MUST_PASS(kInstanceObject); - - return 0; -} \ No newline at end of file diff --git a/Public/SDK/System.Core/Sources/Heap.cxx b/Public/SDK/System.Core/Sources/Heap.cxx index 3803af3a..18106f41 100644 --- a/Public/SDK/System.Core/Sources/Heap.cxx +++ b/Public/SDK/System.Core/Sources/Heap.cxx @@ -60,24 +60,24 @@ HeapInterface* HeapInterface::Shared() noexcept { } HeapInterface::HeapInterface() { - CA_MUST_PASS(HcProcessHeapExists(kInstanceObject, (PtrVoidType)this)); + CA_MUST_PASS(HcProcessHeapExists(kApplicationObject, (PtrVoidType)this)); } HeapInterface::~HeapInterface() { delete this; } void HeapInterface::Delete(PtrHeapType me) noexcept { CA_MUST_PASS(me); - HcFreeProcessHeap(kInstanceObject, me); + HcFreeProcessHeap(kApplicationObject, me); } SizeType HeapInterface::Size(PtrHeapType me) noexcept { CA_MUST_PASS(me); - return HcProcessHeapSize(kInstanceObject, me); + return HcProcessHeapSize(kApplicationObject, me); } PtrHeapType HeapInterface::New(const SizeType& sz, const DWordType flags) { SizeType _sz = sz; if (!_sz) ++_sz; - return HcAllocateProcessHeap(kInstanceObject, _sz, flags); + return HcAllocateProcessHeap(kApplicationObject, _sz, flags); } diff --git a/Public/SDK/System.Core/Sources/LibEntrypoint.cxx b/Public/SDK/System.Core/Sources/LibEntrypoint.cxx new file mode 100644 index 00000000..b874ef55 --- /dev/null +++ b/Public/SDK/System.Core/Sources/LibEntrypoint.cxx @@ -0,0 +1,14 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include + +/// @brief Inits the DLL. +/// @return if it was succesful or not. +DWordType __DllMain(VoidType) { + kApplicationObject = HcGetInstanceObject(); + CA_MUST_PASS(kApplicationObject); + + return 0; +} \ No newline at end of file diff --git a/Public/SDK/System.Core/Sources/New+Delete.cxx b/Public/SDK/System.Core/Sources/New+Delete.cxx index fe8ed43f..678aacce 100644 --- a/Public/SDK/System.Core/Sources/New+Delete.cxx +++ b/Public/SDK/System.Core/Sources/New+Delete.cxx @@ -5,44 +5,32 @@ ------------------------------------------- */ #include - -#define kAllocationTypes 2 - -enum HcAllocationKind { - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, - DWordType flags); -CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr); -CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr); -CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr); +#include typedef SizeType size_t; void* operator new[](size_t sz) { if (sz == 0) ++sz; - return HcAllocateProcessHeap(kInstanceObject, sz, kStandardAllocation); + return HcAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation); } void* operator new(size_t sz) { if (sz == 0) ++sz; - return HcAllocateProcessHeap(kInstanceObject, sz, kArrayAllocation); + return HcAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation); } void operator delete[](void* ptr) { if (ptr == nullptr) return; - HcFreeProcessHeap(kInstanceObject, ptr); + HcFreeProcessHeap(kApplicationObject, ptr); } void operator delete(void* ptr) { if (ptr == nullptr) return; - HcFreeProcessHeap(kInstanceObject, ptr); + HcFreeProcessHeap(kApplicationObject, ptr); } void operator delete(void* ptr, size_t sz) { @@ -50,5 +38,5 @@ void operator delete(void* ptr, size_t sz) { (void)sz; - HcFreeProcessHeap(kInstanceObject, ptr); + HcFreeProcessHeap(kApplicationObject, ptr); } -- cgit v1.2.3