summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/SystemLib
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-29 17:01:55 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-29 17:06:28 +0100
commit7e5be1572c043484293ee0cdd840dd41f54e87ee (patch)
tree171427b27eb240d4006fda89e485ce6da28fd749 /Public/Developer/SystemLib
parentd7eb7affee3733dfeee6864045da4c2f5df2e919 (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/SystemLib')
-rw-r--r--Public/Developer/SystemLib/.gitkeep0
-rw-r--r--Public/Developer/SystemLib/AMD64/HCoreAssemblyRoutines.s24
-rw-r--r--Public/Developer/SystemLib/ARM64/.gitkeep0
-rw-r--r--Public/Developer/SystemLib/Headers/Defines.h196
-rw-r--r--Public/Developer/SystemLib/Headers/Dialog.h16
-rw-r--r--Public/Developer/SystemLib/Headers/File.h44
-rw-r--r--Public/Developer/SystemLib/Headers/Heap.h38
-rw-r--r--Public/Developer/SystemLib/Headers/Hint.h18
-rw-r--r--Public/Developer/SystemLib/Headers/Thread.h43
-rw-r--r--Public/Developer/SystemLib/Headers/TrueType.h31
-rw-r--r--Public/Developer/SystemLib/Headers/Window.h153
-rw-r--r--Public/Developer/SystemLib/Makefile23
-rw-r--r--Public/Developer/SystemLib/RISCV/.gitkeep0
-rw-r--r--Public/Developer/SystemLib/ReadMe.md14
-rw-r--r--Public/Developer/SystemLib/Sources/Application.c25
-rw-r--r--Public/Developer/SystemLib/Sources/ApplicationStart.c14
-rw-r--r--Public/Developer/SystemLib/Sources/Heap.c42
-rw-r--r--Public/Developer/SystemLib/Sources/Window.c70
-rw-r--r--Public/Developer/SystemLib/compile_flags.txt4
19 files changed, 755 insertions, 0 deletions
diff --git a/Public/Developer/SystemLib/.gitkeep b/Public/Developer/SystemLib/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Public/Developer/SystemLib/.gitkeep
diff --git a/Public/Developer/SystemLib/AMD64/HCoreAssemblyRoutines.s b/Public/Developer/SystemLib/AMD64/HCoreAssemblyRoutines.s
new file mode 100644
index 00000000..58bb1260
--- /dev/null
+++ b/Public/Developer/SystemLib/AMD64/HCoreAssemblyRoutines.s
@@ -0,0 +1,24 @@
+/** ===========================================
+ (C) Mahrouss Logic
+ ===========================================*/
+
+.section .text
+
+.globl RtGetAppObject
+.globl __assert_chk_fail
+
+/* @brief Process object getter */
+/* @throws: ApptError: appartement error. */
+RtGetAppObject:
+ mov $0x10, %rcx /* sysGetProcessObject */
+ int $0x21
+
+ /* rax gets saved and returned. */
+ ret
+
+__assert_chk_fail:
+ mov $0x11, %rcx /* sysTerminateCurrentProcess */
+ int $0x21
+
+ ret
+
diff --git a/Public/Developer/SystemLib/ARM64/.gitkeep b/Public/Developer/SystemLib/ARM64/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Public/Developer/SystemLib/ARM64/.gitkeep
diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h
new file mode 100644
index 00000000..c4cc552b
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Defines.h
@@ -0,0 +1,196 @@
+/* -------------------------------------------
+
+ 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 <Headers/Hint.h>
+#include <Headers/Dialog.h>
+
+/**
+ * @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 Application Interface.
+/// \author Amlal El Mahrouss
+typedef struct Application {
+ VoidType(*Release)(struct Application* Self, DWordType ExitCode);
+ IntPtrType(*Invoke)(struct Application* Self, DWordType Sel, ...);
+ VoidType(*Query)(struct Application* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf);
+} Application, *ApplicationRef;
+
+#ifdef __cplusplus
+
+#define object_cast reinterpret_cast<ApplicationRef>
+
+template <SizeType N>
+using StrType = CharacterTypeUTF8[N];
+
+#else
+
+#define object_cast (ApplicationRef)
+
+#endif // ifdef C++
+
+CA_EXTERN_C ApplicationRef RtGetAppObject(VoidType);
+CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType);
+CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType);
+
+CA_EXTERN_C ApplicationRef kSharedApplication;
+
+typedef CharacterTypeUTF8 StrType255[255];
+
+#define True 1
+#define False 0
+#define Bool BooleanType
+
+#define NullPtr ((PtrVoidType)0)
+
+#ifndef kInvalidRef
+#define kInvalidRef 0
+#endif
diff --git a/Public/Developer/SystemLib/Headers/Dialog.h b/Public/Developer/SystemLib/Headers/Dialog.h
new file mode 100644
index 00000000..d3e8df44
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Dialog.h
@@ -0,0 +1,16 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <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/SystemLib/Headers/File.h b/Public/Developer/SystemLib/Headers/File.h
new file mode 100644
index 00000000..0bce05f9
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/File.h
@@ -0,0 +1,44 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <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/SystemLib/Headers/Heap.h b/Public/Developer/SystemLib/Headers/Heap.h
new file mode 100644
index 00000000..2dc13b0f
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Heap.h
@@ -0,0 +1,38 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <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/SystemLib/Headers/Hint.h b/Public/Developer/SystemLib/Headers/Hint.h
new file mode 100644
index 00000000..86faf455
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Hint.h
@@ -0,0 +1,18 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#define _Input
+#define _Output
+
+#define _Optional
+
+#define _StrictCheckInput
+#define _StrictCheckOutput
+
+#define _InOut
+#define _StrictInOut
diff --git a/Public/Developer/SystemLib/Headers/Thread.h b/Public/Developer/SystemLib/Headers/Thread.h
new file mode 100644
index 00000000..4a54d841
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Thread.h
@@ -0,0 +1,43 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+//
+// Created by Amlal on 3/18/24
+//
+
+#ifndef __THREAD__
+#define __THREAD__
+
+#include <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/SystemLib/Headers/TrueType.h b/Public/Developer/SystemLib/Headers/TrueType.h
new file mode 100644
index 00000000..0636bf61
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/TrueType.h
@@ -0,0 +1,31 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <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/SystemLib/Headers/Window.h b/Public/Developer/SystemLib/Headers/Window.h
new file mode 100644
index 00000000..4d526782
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Window.h
@@ -0,0 +1,153 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <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,
+};
diff --git a/Public/Developer/SystemLib/Makefile b/Public/Developer/SystemLib/Makefile
new file mode 100644
index 00000000..21b21ad9
--- /dev/null
+++ b/Public/Developer/SystemLib/Makefile
@@ -0,0 +1,23 @@
+##################################################
+# (C) Mahrouss Logic, all rights reserved.
+# This is the SystemLib Makefile.
+##################################################
+
+CC=x86_64-w64-mingw32-gcc
+AR=x86_64-w64-mingw32-ar
+ARFLAGS=-rcs
+CCINC=-I./
+CCFLAGS=-D__SINGLE_PRECISION__ -nostdlib -std=c17 -ffreestanding -Xlinker --subsystem=17 -shared
+OUTPUT=SystemLib.lib
+
+.PHONY: all
+all: build-core-amd64
+ @echo "[SystemLib.lib] Build done."
+
+.PHONY: build-core-amd64
+build-core-amd64:
+ $(CC) $(CCINC) $(CCFLAGS) $(wildcard Sources/*.c) $(wildcard AMD64/*.s) -o $(OUTPUT)
+
+.PHONY: clean
+clean:
+ rm -f $(wildcard *.o)
diff --git a/Public/Developer/SystemLib/RISCV/.gitkeep b/Public/Developer/SystemLib/RISCV/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Public/Developer/SystemLib/RISCV/.gitkeep
diff --git a/Public/Developer/SystemLib/ReadMe.md b/Public/Developer/SystemLib/ReadMe.md
new file mode 100644
index 00000000..ff89e847
--- /dev/null
+++ b/Public/Developer/SystemLib/ReadMe.md
@@ -0,0 +1,14 @@
+# SystemLib
+## System API.
+
+Currently contains:
+- Heap API.
+- File API.
+- Window Manager API.
+- Dialogs API.
+- Data types.
+- Threading API.
+
+Needs:
+- Device API
+- Drive API. \ No newline at end of file
diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/Application.c
new file mode 100644
index 00000000..d7a83d3e
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Application.c
@@ -0,0 +1,25 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Defines.h>
+
+/// @brief Main Application object, retrieved from the RtGetAppObject symbol.
+ApplicationRef kSharedApplication = NullPtr;
+
+/// @brief Gets the app arguments count.
+/// @param void no arguments.
+/// @return
+CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
+ return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount);
+}
+
+/// @brief Gets the app arguments pointer.
+/// @param void no arguments.
+/// @return
+CA_EXTERN_C CharacterTypeUTF8* RtGetAppArgumentsPtr(VoidType) {
+ return (CharacterTypeUTF8*)kSharedApplication->Invoke(kSharedApplication,
+ kCallGetArgsPtr);
+} \ No newline at end of file
diff --git a/Public/Developer/SystemLib/Sources/ApplicationStart.c b/Public/Developer/SystemLib/Sources/ApplicationStart.c
new file mode 100644
index 00000000..5b91ba18
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/ApplicationStart.c
@@ -0,0 +1,14 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Defines.h>
+
+/// @brief Inits the system library.
+/// @return if it was succesful or not.
+CA_EXTERN_C VoidType __start(VoidType) {
+ kSharedApplication = RtGetAppObject();
+ CA_MUST_PASS(kSharedApplication);
+}
diff --git a/Public/Developer/SystemLib/Sources/Heap.c b/Public/Developer/SystemLib/Sources/Heap.c
new file mode 100644
index 00000000..c9b2b938
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Heap.c
@@ -0,0 +1,42 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Heap.h>
+
+/// @brief Allocate from the user's heap.
+/// @param sz size of object.
+/// @param flags flags.
+/// @return
+CA_EXTERN_C PtrVoidType RtAllocateProcessPtr(QWordType sz,
+ DWordType flags) {
+ CA_MUST_PASS(sz);
+ CA_MUST_PASS(flags);
+
+ return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, kCallAllocPtr, sz, flags);
+}
+
+/// @brief Free pointer from the user's heap.
+/// @param ptr the pointer to free.
+CA_EXTERN_C VoidType RtFreeProcessPtr(PtrVoidType ptr) {
+ CA_MUST_PASS(ptr);
+ CA_UNREFERENCED_PARAMETER(kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr));
+}
+
+/// @brief Get pointer size.
+/// @param ptr the pointer to find.
+/// @return the size.
+CA_EXTERN_C QWordType RtProcessPtrSize(PtrVoidType ptr) {
+ CA_MUST_PASS(ptr);
+ return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr);
+}
+
+/// @brief Check if the pointer exists.
+/// @param ptr the pointer to check.
+/// @return if it exists
+CA_EXTERN_C BooleanType RtProcessPtrExists(PtrVoidType ptr) {
+ CA_MUST_PASS(ptr);
+ return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr);
+}
diff --git a/Public/Developer/SystemLib/Sources/Window.c b/Public/Developer/SystemLib/Sources/Window.c
new file mode 100644
index 00000000..2527e041
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Window.c
@@ -0,0 +1,70 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Window.h>
+
+/// invalid resource handle, they always start from 1.
+#define kInvalidRsrc (0U)
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
+ const DWordType rsrcId) {
+ CA_MUST_PASS(name);
+ CA_MUST_PASS(rsrcId != kInvalidRsrc);
+
+ return (WindowPort*)kSharedApplication->Invoke(
+ kSharedApplication, kCallCreateWindow, name, rsrcId);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort) {
+ CA_MUST_PASS(winPort);
+
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseWindow, winPort);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name,
+ const DWordType rsrcId) {
+ CA_MUST_PASS(name);
+ CA_MUST_PASS(rsrcId != kInvalidRsrc);
+
+ return (WindowPort*)kSharedApplication->Invoke(kSharedApplication,
+ kCallCreateMenu, name, rsrcId);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) {
+ CA_MUST_PASS(winPort);
+
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseMenu, winPort);
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) {
+ if (!id) {
+ return kWmErrInvalidArg;
+ }
+
+ id->windowPosition.X = where.X;
+ id->windowPosition.Y = where.Y;
+ id->windowMoving = True;
+
+ return 0;
+}
+
+/// @brief Color refs.
+
+const ColorRef kRgbRed = 0x000000FF;
+const ColorRef kRgbGreen = 0x0000FF00;
+const ColorRef kRgbBlue = 0x00FF0000;
+const ColorRef kRgbBlack = 0x00000000;
+const ColorRef kRgbWhite = 0xFFFFFFFF;
diff --git a/Public/Developer/SystemLib/compile_flags.txt b/Public/Developer/SystemLib/compile_flags.txt
new file mode 100644
index 00000000..6e721e73
--- /dev/null
+++ b/Public/Developer/SystemLib/compile_flags.txt
@@ -0,0 +1,4 @@
+-I./
+-I../
+-I../../../Private
+-std=c++20