diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-26 13:44:38 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-26 13:47:32 +0100 |
| commit | 66e4f909bd1a495d3f1c34d2e1b5cd71099ab1ae (patch) | |
| tree | d64cc867d352d190dfd5693262a42b31e28b9239 /Public/Developer/System.Core/Headers | |
| parent | dbe4573f61ae059c9dafb8e7623370121d443451 (diff) | |
Kernel and System.Core: kernel related fixes and :boom: on User API.
- UserHeap.cxx: Document code and fix issue in ke_free_heap_internal.
- Scheduler: Rename ProcessManager to ProcessScheduler.
- The System API has been reworked to improve it's design, such as no
more C++ to improve it's portability.
- Moved containers into it's own API.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Developer/System.Core/Headers')
| -rw-r--r-- | Public/Developer/System.Core/Headers/Containers/ODF.hxx | 41 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Containers/XIFF.hxx | 63 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Defines.hxx | 84 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/File.hxx | 120 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Heap.hxx | 70 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Window/Window.hxx | 31 |
6 files changed, 56 insertions, 353 deletions
diff --git a/Public/Developer/System.Core/Headers/Containers/ODF.hxx b/Public/Developer/System.Core/Headers/Containers/ODF.hxx deleted file mode 100644 index 266726bf..00000000 --- a/Public/Developer/System.Core/Headers/Containers/ODF.hxx +++ /dev/null @@ -1,41 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __ODF__ -#define __ODF__ - -#include <System.Core/Headers/Defines.hxx> - -/** - * @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/Developer/System.Core/Headers/Containers/XIFF.hxx b/Public/Developer/System.Core/Headers/Containers/XIFF.hxx deleted file mode 100644 index 4c97e2a3..00000000 --- a/Public/Developer/System.Core/Headers/Containers/XIFF.hxx +++ /dev/null @@ -1,63 +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 <System.Core/Headers/Defines.hxx> - -/// @brief four-character code for XIFF. -#define kFourCCLength_XIFF 4 -#define kXIFFNameLength 255 - -#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; - -/// @brief XIFF metadata header, either located in forks or in file directly. -/// @author Amlal EL Mahrouss -struct ML_PACKED XiffMetadataHeader final { - ByteType f_Name[kXIFFNameLength]; - DWordType f_Flags; - DWordType f_Type; - QWordType f_Offset; - SizeType f_Size; -}; - -/// Pascal string -#define kXIFFStringMetadata4CC "strp" - -/// TrueType font -#define kXIFFFontMetadata4CC "font" - -/// UI resource -#define kXIFFResourceMetadata4CC "resx" - - -#endif // ifndef __XIFF__ diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.hxx index 867dac76..9d6d84ee 100644 --- a/Public/Developer/System.Core/Headers/Defines.hxx +++ b/Public/Developer/System.Core/Headers/Defines.hxx @@ -136,77 +136,6 @@ enum HcProcessCall { #include <System.Core/Headers/Hint.hxx> -class SystemException { - public: - explicit SystemException() = default; - virtual ~SystemException() = default; - - public: - CA_COPY_DEFAULT(SystemException); - - public: - virtual const char *Name() = 0; - virtual const char *Reason() = 0; - -}; - -/// @brief Object exception -/// Throws when the object isn't found. -class ObjectNotFoundException : public SystemException { - public: - explicit ObjectNotFoundException() = default; - virtual ~ObjectNotFoundException() = default; - - public: - CA_COPY_DEFAULT(ObjectNotFoundException); - - public: - const char *Name() override { return "ObjectNotFoundException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: ObjectNotFoundException: Catastrophic failure!"}; -}; - -/// @brief pointer exception -/// Throws when the object isn't found. -class PointerException : public SystemException { - public: - explicit PointerException() = default; - virtual ~PointerException() = default; - - public: - CA_COPY_DEFAULT(PointerException); - - public: - const char *Name() override { return "PointerException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: PointerException: Catastrophic failure!"}; -}; - -/// @brief pointer exception -/// Throws when the object isn't found. -class NullPointerException : public SystemException { - public: - explicit NullPointerException() = default; - virtual ~NullPointerException() = default; - - public: - CA_COPY_DEFAULT(NullPointerException); - - public: - const char *Name() override { return "NullPointerException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: NullPointerException: Catastrophic failure!"}; -}; - #define kObjectGlobalNamespaceSystem "HCORE_ROOT\\" #define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\" @@ -241,10 +170,15 @@ typedef struct Object final { VoidType(*Release)(struct Object* Self); IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...); VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); -} Object, *ObjectPtr; +} *ObjectRef; + +#define object_cast reinterpret_cast<ObjectRef> + +CA_EXTERN_C ObjectRef HcGetAppObject(VoidType); -#define object_cast reinterpret_cast<ObjectPtr> +CA_INLINE ObjectRef kApplicationObject; -CA_EXTERN_C ObjectPtr HcGetInstanceObject(void); +typedef CharacterTypeUTF8 Str255Type[255]; -CA_INLINE ObjectPtr kApplicationObject; +template <SizeType N> +using StrType = CharacterTypeUTF8[N]; diff --git a/Public/Developer/System.Core/Headers/File.hxx b/Public/Developer/System.Core/Headers/File.hxx deleted file mode 100644 index 3d3abf13..00000000 --- a/Public/Developer/System.Core/Headers/File.hxx +++ /dev/null @@ -1,120 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef __FILE_API__ -#define __FILE_API__ - -#include <System.Core/Headers/Defines.hxx> - -#define kFileOpenInterface 10 -#define kFileAliasInterface 11 - -namespace System { -class FileInterface; -class DirectoryInterface; - -typedef IntPtrType FSRef; - -enum { - kErrorNoSuchPath = -44, - kErrorNotAFile = -45, - kErrorNotADirectory = -46, - kErrorDirectory = -47, - kErrorBrokenSymlink = -48, -}; - -/// @brief System file interface - -class FileInterface final { - public: - explicit FileInterface(const char *path) { - CA_MUST_PASS(path); - - mHandle = kApplicationObject->Invoke( - kApplicationObject, kProcessCallOpenHandle, kFileOpenInterface, path); - } - - ~FileInterface() { - CA_MUST_PASS(kApplicationObject); - - kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle, - kFileOpenInterface, mHandle); - } - - public: - CA_COPY_DEFAULT(FileInterface); - - public: - PtrVoidType ReadFork(const CharacterTypeUTF8* name, UIntPtrType off, SizeType sz) { - return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, - 2, name, off, sz); - } - - PtrVoidType ReadFork(const CharacterTypeUTF8* name, SizeType sz) { - return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, - name, 3, sz); - } - - void WriteFork(const CharacterTypeUTF8* name, PtrVoidType buf, UIntPtrType off, SizeType sz) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 4, name, buf, off, sz); - } - - void WriteFork(const CharacterTypeUTF8* name, PtrVoidType buf, SizeType sz) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 5, name, buf, sz); - } - - void SeekFork(const CharacterTypeUTF8* name) { - kApplicationObject->Invoke(kApplicationObject, mHandle, 6, name); - } - - void RewindFork() { kApplicationObject->Invoke(kApplicationObject, mHandle, 7); } - - public: - const CharacterTypeUTF8 *MIME() { - return (const char *)kApplicationObject->Invoke(kApplicationObject, mHandle, - 8); - } - - void MIME(const CharacterTypeUTF8 *mime) { - CA_MUST_PASS(mime); - - kApplicationObject->Invoke(kApplicationObject, mHandle, 9, mime); - } - - private: - FSRef mHandle; -}; - -typedef FileInterface *FilePtr; - -/// @brief file exception -/// Throws when the file isn't found or invalid. -class FileException : public SystemException { - public: - explicit FileException() = default; - virtual ~FileException() = default; - - public: - CA_COPY_DEFAULT(FileException); - - public: - const char *Name() override { return "FileException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{"System.Core: FileException: Catastrophic failure!"}; -}; - -inline IntPtrType FSMakeAlias(const char *from, const char *outputWhere) { - CA_MUST_PASS(from); - CA_MUST_PASS(outputWhere); - - return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, - kFileAliasInterface, from); -} -} // namespace System - -#endif // ifndef __FILE_API__ diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.hxx index 8fea34d4..98ee5bd2 100644 --- a/Public/Developer/System.Core/Headers/Heap.hxx +++ b/Public/Developer/System.Core/Headers/Heap.hxx @@ -8,57 +8,25 @@ #include <System.Core/Headers/Defines.hxx> -namespace System { -class HeapException; -class HeapInterface; +#define kAllocationTypes 2 -typedef PtrVoidType HeapRef; - -enum { - kHeapExpandable = 2, - kHeapNoExecute = 4, - kHeapShared = 6, - kHeapReadOnly = 8, - kHeapNoFlags = 0 -}; - -class HeapInterface final { - private: - explicit HeapInterface(); - - public: - ~HeapInterface(); - - public: - CA_COPY_DEFAULT(HeapInterface); - - public: - static HeapInterface *Shared() noexcept; - - public: - void Delete(HeapRef me) noexcept; - SizeType Size(HeapRef me) noexcept; - HeapRef New(const SizeType &sz, - const DWordType flags = kHeapNoFlags); -}; - - -/// @brief heap exception -/// Throws when the heap pointer isn't found or invalid. -class HeapException : public SystemException { - public: - explicit HeapException() = default; - virtual ~HeapException() = default; - - public: - CA_COPY_DEFAULT(HeapException); - - public: - const char *Name() override { return "HeapException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{"System.Core: HeapException: Catastrophic failure!"}; +enum HcAllocationKind { + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, }; -} // namespace System +/// @brief Allocates a new heap from process pool. +/// @param refObj +/// @param sz +/// @param flags +/// @return +CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz, + DWordType flags); + +/// @brief Check if pointer exists. +/// @param refObj +/// @param ptr +/// @return +CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr); +CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr); +CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr); diff --git a/Public/Developer/System.Core/Headers/Window/Window.hxx b/Public/Developer/System.Core/Headers/Window/Window.hxx index 5eb1b3ce..4c79d50b 100644 --- a/Public/Developer/System.Core/Headers/Window/Window.hxx +++ b/Public/Developer/System.Core/Headers/Window/Window.hxx @@ -77,11 +77,23 @@ CA_EXTERN_C ControlRef CreateControl(const DWordType id); /// @return CA_EXTERN_C VoidType ReleaseControl(const ControlRef id); -CA_EXTERN_C BooleanType MoveControl(const ControlRef id, GraphicsPoint where); +/// @brief Moves a control inside a GraphicsPort. +/// @param id the control ref. +/// @param where where to move at. +/// @return +CA_EXTERN_C Int32Type SetControlPosition(const ControlRef id, GraphicsPoint where); -CA_EXTERN_C BooleanType EnableControl(const ControlRef id, BooleanType visible); +/// @brief Enable control. +/// @param id +/// @param enabled +/// @return +CA_EXTERN_C Int32Type SetControlEnabled(const ControlRef id, BooleanType enabled); -CA_EXTERN_C BooleanType VisibleControl(const ControlRef id, BooleanType visible); +/// @brief Make control visible. +/// @param id +/// @param visible +/// @return +CA_EXTERN_C Int32Type MakeControlVisible(const ControlRef id, BooleanType visible); /// @brief Creates a new window. /// @param name the window name @@ -104,3 +116,16 @@ CA_EXTERN_C VoidType ReleaseWindow(GraphicsPort* port); /// @param port the menu port. /// @return void CA_EXTERN_C VoidType ReleaseMenu(GraphicsPort* port); + +/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible is menu is provided.) +/// @param id the gfx port. +/// @param where to move. +/// @return error code. +CA_EXTERN_C Int32Type MoveWindow(const GraphicsPort* id, GraphicsPoint where); + +enum { + kWinErrIncompatible = 0x74, + kWinErrOutOfMemory, + kWinErrInvalidArg, + kWinErrNotImplemented, +}; |
