diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-29 17:01:55 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-29 17:06:28 +0100 |
| commit | 7e5be1572c043484293ee0cdd840dd41f54e87ee (patch) | |
| tree | 171427b27eb240d4006fda89e485ce6da28fd749 /Public/Developer/System.Core/Headers | |
| parent | d7eb7affee3733dfeee6864045da4c2f5df2e919 (diff) | |
Kernel and SystemLib: See below.
What has been done:
- Rename most System.Core to SystemLib.
- Reworked it's API and the concept of ObjectRef to become the
ApplicationRef object.
- Remove unused ODF and XIFF file format from tree, ODF will be part of
the text editing program.
- Update Readme for SystemLib.
- Add Support folder on NewFS partitions.
What is next:
- NewFS filesystem support.
- Program loading.
- Preemptive scheduler on non-SMP systems using timers.
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/Defines.h | 207 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Dialog.h | 16 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/File.h | 44 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Heap.h | 38 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Hint.h | 18 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Thread.h | 43 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/TrueType.h | 32 | ||||
| -rw-r--r-- | Public/Developer/System.Core/Headers/Window.h | 153 |
8 files changed, 0 insertions, 551 deletions
diff --git a/Public/Developer/System.Core/Headers/Defines.h b/Public/Developer/System.Core/Headers/Defines.h deleted file mode 100644 index 56367cff..00000000 --- a/Public/Developer/System.Core/Headers/Defines.h +++ /dev/null @@ -1,207 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS -#endif - -#ifdef _DEBUG -#define CA_MUST_PASS(e) { if (!e) { DlgMsgBox("Sorry, an assertion failed.\nFile: %s\nLine: %i", __FILE__, __LINE__) __assert_chk_fail() } } -#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 - -CA_EXTERN_C void __assert_chk_fail(void); - -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) - -#define PACKED __attribute__((packed)) - -#define CA_PASCAL CA_STDCALL - -typedef __UINT8_TYPE__ ByteType; -typedef __UINT16_TYPE__ WordType; -typedef __UINT32_TYPE__ DWordType; -typedef __UINT64_TYPE__ QWordType; -typedef __SIZE_TYPE__ SizeType; - -typedef char CharacterTypeUTF8; -typedef CharacterTypeUTF8* PtrCharacterType; - -typedef void* PtrVoidType; -typedef void VoidType; - -typedef __UINTPTR_TYPE__ UIntPtrType; -typedef __INTPTR_TYPE__ IntPtrType; -typedef __UINT64_TYPE__ UInt64Type; -typedef __INT64_TYPE__ Int64Type; -typedef __UINT32_TYPE__ UInt32Type; -typedef __INT32_TYPE__ Int32Type; - -typedef CharacterTypeUTF8 BooleanType; - -#define CA_COPY_DELETE(KLASS) \ - KLASS &operator=(const KLASS &) = delete; \ - KLASS(const KLASS &) = delete; - - -#define CA_COPY_DEFAULT(KLASS) \ - KLASS &operator=(const KLASS &) = default; \ - KLASS(const KLASS &) = default; - - -#define CA_MOVE_DELETE(KLASS) \ - KLASS &operator=(KLASS &&) = delete; \ - KLASS(KLASS &&) = delete; - - -#define CA_MOVE_DEFAULT(KLASS) \ - KLASS &operator=(KLASS &&) = default; \ - KLASS(KLASS &&) = default; - - -#define Yes 1 -#define No 0 - -#define CA_PTR * - -#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)(e)) - -#ifdef __x86_64__ - -# define CA_FAR __far -# define CA_NEAR __near - -# define _M_AMD64 2 -#else - -# define CA_FAR -# define CA_NEAR - -#endif - -#ifdef __aarch64__ -# define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -# define _M_PPC64 4 -#endif - -#ifdef __64x0__ -# define _M_64000 5 -#endif - -#ifdef __riscv__ -# define _M_RISCV 6 -#endif - -#define CA_STATIC static -#define CA_INLINE inline -#define CA_CONST const - -#ifdef __cplusplus -#define CA_CONSTEXPR constexpr -#else -#define CA_CONSTEXPR -#endif // __cplusplus - -enum RtProcessCall { - kCallAllocPtr = 1, - kCallFreePtr, - kCallSizePtr, - kCallCheckPtr, - kCallAllocStack, - /// @brief Open a specific handle (can be used as sel to call methods related to it.) - kCallOpenFile, - kCallCloseFile, - kCallCreateWindow, - kCallCloseWindow, - kCallCreateMenu, - kCallCloseMenu, - kCallGetArgsCount, - kCallGetArgsPtr, - /// @brief Number of process calls. - kCallsCount, -}; - -#include <System.Core/Headers/Hint.h> -#include <System.Core/Headers/Dialog.h> - -#define kObjectGlobalNamespace ":\\" - -enum { - kObjectTypeGeneric, - kObjectTypeFile, - kObjectTypeDevice, - kObjectTypeNetwork, - kObjectTypeInvalid, - kObjectTypeCount = 5, -}; - -/** - * @brief GUID type, something you can also find in CFKit. - * @author Amlal El Mahrouss - */ -typedef struct GUID { - DWordType Data1; - WordType Data2; - WordType Data3; - ByteType Data4[8]; -} GUIDType, *PtrGUIDType; - -/// \brief Object handle. -/// \author Amlal El Mahrouss -typedef struct Object { - CharacterTypeUTF8 Name[255]; - DWordType Kind; - DWordType Flags; - - VoidType(*Release)(struct Object* Self); - IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...); - VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); -} *ObjectRef; - -#ifdef __cplusplus - -#define object_cast reinterpret_cast<ObjectRef> - -template <SizeType N> -using StrType = CharacterTypeUTF8[N]; - -#else - -#define object_cast (ObjectRef) - -#endif // ifdef C++ - -CA_EXTERN_C ObjectRef RtGetAppObject(VoidType); -CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType); -CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType); - -CA_EXTERN_C ObjectRef kApplicationObject; - -typedef CharacterTypeUTF8 Str255Type[255]; - -#define True 1 -#define False 0 -#define Bool BooleanType - -#define NULL ((PtrVoidType)0) diff --git a/Public/Developer/System.Core/Headers/Dialog.h b/Public/Developer/System.Core/Headers/Dialog.h deleted file mode 100644 index 9d4521cf..00000000 --- a/Public/Developer/System.Core/Headers/Dialog.h +++ /dev/null @@ -1,16 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include <System.Core/Headers/Window.h> - -/// @brief Shows an message box with a formatting. -/// @param title the message box title -/// @param format the format -/// @param va_list the va args, that goes along with it. -/// @return void this function returns nothing. -CA_EXTERN_C VoidType DlgMsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...); diff --git a/Public/Developer/System.Core/Headers/File.h b/Public/Developer/System.Core/Headers/File.h deleted file mode 100644 index 13bc7a00..00000000 --- a/Public/Developer/System.Core/Headers/File.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include <System.Core/Headers/Defines.h> - -/// @brief Filesystem wrapper. - -typedef QWordTyp FSRef; - -/// @brief Opens a new file. -/// @param path where to find it. -/// @param r the restrict (rw, rwe, r+, w+, r, w) -/// @return -CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r); - -/// @brief Closes the file and flushes it to the said file. -/// @param refFs the filesystem reference. -/// @return -CA_EXTERN_C VoidType FsCloseFile(FSRef refFs); - -typedef QWordTyp FSForkRef; - -/// @brief A fork information header. -typedef struct _Fork { - PtrVoidType forkData; - SizeType forkSize; - Int32Type forkFlags; - Int32Type forkKind; - CharacterTypeUTF8 forkName[256]; -} ForkType; - -/// @brief Gets the fork inside a file. -/// @param refFs the filesystem ref -/// @param forkName the fork's name -/// @return the fork data. -CA_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName); - -#define FsGetDataFork(refFs) FsGetFork(refFs, "data") -#define FsGetRsrcFork(refFs) FsGetFork(refFs, "rsrc") diff --git a/Public/Developer/System.Core/Headers/Heap.h b/Public/Developer/System.Core/Headers/Heap.h deleted file mode 100644 index 9f3215db..00000000 --- a/Public/Developer/System.Core/Headers/Heap.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include <System.Core/Headers/Defines.h> - -#define kAllocationTypes 2 - -enum RtAllocationKind { - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -/// @brief Allocates a new pointer from process pool. -/// @param sz the size -/// @param flags the allocation flags. -/// @return -CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz, - DWordType flags); - -/// @brief Check if the pointer exists. -/// @param ptr the pointer to free. -/// @return -CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr); - -/// @brief Gets the size of the process' pointer. -/// @param ptr the pointer to free. -/// @return -CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr); - -/// @brief Frees the process pointer. -/// @param ptr the pointer to free. -/// @return -CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr); diff --git a/Public/Developer/System.Core/Headers/Hint.h b/Public/Developer/System.Core/Headers/Hint.h deleted file mode 100644 index 86faf455..00000000 --- a/Public/Developer/System.Core/Headers/Hint.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut diff --git a/Public/Developer/System.Core/Headers/Thread.h b/Public/Developer/System.Core/Headers/Thread.h deleted file mode 100644 index 7d2bfe3c..00000000 --- a/Public/Developer/System.Core/Headers/Thread.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -// -// Created by Amlal on 3/18/24 -// - -#ifndef __THREAD__ -#define __THREAD__ - -#include <System.Core/Headers/Defines.h> - -#define kThreadErrorExit -33 - -/// @brief Thread Information Block, which holds information about the running -/// thread. -typedef QWordType ThreadRef; - -/// @brief Main application thread. -CA_EXTERN_C ThreadRef kMainThread; - -typedef VoidType(*ThreadEntrypointKind)(VoidType); - -/// @brief Creates a new thread, and runs the code. -/// @param threadName the thread's name. -/// @param threadStart where to start. -/// @return -CA_EXTERN_C ThreadRef TmCreateThread(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart); - -/// @brief Dispoes the thread, and exits with code kThreadErrorExit -/// @param ref the thread reference. -/// @return nothing. -CA_EXTERN_C VoidType TmDisposeThread(ThreadRef ref); - -/// @brief Waits for the thread to complete. -/// @param ref the thread reference. -/// @return nothing. -CA_EXTERN_C VoidType TmWaitForCompletion(ThreadRef ref); - -#endif // __THREAD__ diff --git a/Public/Developer/System.Core/Headers/TrueType.h b/Public/Developer/System.Core/Headers/TrueType.h deleted file mode 100644 index 2e8f4142..00000000 --- a/Public/Developer/System.Core/Headers/TrueType.h +++ /dev/null @@ -1,32 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include <System.Core/Headers/Window.h> - -/************************************************************* - * - * File: TrueType.hxx - * Purpose: TrueType font implementation for NewOS. - * Date: 3/26/24 - * - * Copyright Mahrouss Logic, all rights reserved. - * - *************************************************************/ - -typedef QWordType TTFFontRef; - -/// @brief Loads a new font into app's memory. -/// @param name -/// @return -CA_EXTERN_C TTFFontRef FnCreateFont(const CharacterTypeUTF8* name); - -/// @brief Dispose an allocated font. -/// @param fon -/// @return -CA_EXTERN_C VoidType FnDisposeFont(TTFFontRef fon); - diff --git a/Public/Developer/System.Core/Headers/Window.h b/Public/Developer/System.Core/Headers/Window.h deleted file mode 100644 index 846d5cff..00000000 --- a/Public/Developer/System.Core/Headers/Window.h +++ /dev/null @@ -1,153 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include <System.Core/Headers/Defines.h> - -/************************************************************* - * - * File: Window.hxx - * Purpose: Window Manager API for NewOS. - * Date: 3/26/24 - * - * Copyright Mahrouss Logic, all rights reserved. - * - *************************************************************/ - -struct _WmPoint; -struct _WindowPort; - -#ifdef __SINGLE_PRECISION__ -typedef float PositionType; -#else -typedef double PositionType; -#endif - -typedef QWordType DCRef; - -/// @brief A point, can represent the size, position of a window. -typedef struct _WmPoint { - PositionType X, Y; -} WmPoint; - -/// @brief Window port type, can be used to control the window. -typedef struct _WindowPort { - WordType windowPort; - WordType windowKind; - BooleanType windowVisible; - BooleanType windowMaximized; - BooleanType windowMinimized; - BooleanType windowMoving; - BooleanType windowDisableClose; - BooleanType windowDisableMinimize; - WmPoint windowPosition; - WmPoint windowSize; - BooleanType windowInvalidate; - DWordType windowClearColor; - struct _WindowPort* menuPort; - struct _WindowPort* parentPort; -} WindowPort; - -typedef struct _ControlPort { - WordType controlPort; - WordType controlKind; - BooleanType controlVisible; - BooleanType controlMoving; - WmPoint controlPosition; - WindowPort* parentPort; -} ControlPort; - -typedef UInt32Type ColorRef; - -/***********************************************************************************/ -/// Color utils. -/***********************************************************************************/ - -CA_EXTERN_C const ColorRef kRgbRed; -CA_EXTERN_C const ColorRef kRgbGreen; -CA_EXTERN_C const ColorRef kRgbBlue; -CA_EXTERN_C const ColorRef kRgbBlack; -CA_EXTERN_C const ColorRef kRgbWhite; - -/***********************************************************************************/ -/// Color macro. -/***********************************************************************************/ - -#define WmMakeColorRef(R, G, B) (ColorRef)(0x##R##G##B) - -#define kControlKindWindow 0 -#define kControlKindDialog 1 -#define kControlKindMenu 2 -#define kControlKindButton 3 -#define kControlKindLabel 4 -#define kControlKindDropdown 5 -#define kControlKindIcon 6 -#define kControlKindRadio 7 -#define kControlKindCheck 7 - -/// @brief Creates a new control -/// @param id the control rsrc fork. -/// @return -CA_EXTERN_C ControlPort* WmCreateControl(DWordType id); - -/// @brief Releases the control -/// @param id the control ref. -/// @return -CA_EXTERN_C VoidType WmReleaseControl(ControlPort* id); - -/// @brief Moves a control inside a ControlPort. -/// @param id the control ref. -/// @param where where to move at. -/// @return -CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* id, WmPoint where); - -/// @brief Enable control. -/// @param id -/// @param enabled -/// @return -CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabled); - -/// @brief Make control visible. -/// @param id -/// @param visible -/// @return -CA_EXTERN_C Int32Type WmMakeControlVisible(ControlPort* id, BooleanType visible); - -/// @brief Creates a new window. -/// @param name the window name -/// @param rsrcId the window fork rsrc id. -/// @return the window graphics port. -CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, const DWordType rsrcId); - -/// @brief Creates a new menu -/// @param name the menu's name -/// @param rsrcId the menu fork rsrc id. -/// @return the menu graphics port. -CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, const DWordType rsrcId); - -/// @brief Releases the window. -/// @param port the window port. -/// @return void -CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* port); - -/// @brief Releases the menu -/// @param port the menu port. -/// @return void -CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* 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 WmMoveWindow(WindowPort* id, WmPoint where); - -enum { - kWmErrIncompatible = 0x74, - kWmErrOutOfMemory, - kWmErrInvalidArg, - kWmErrNotImplemented, -}; |
